Spell Problem

eskimojoe_66

Member
Reaction score
2
oThis spell creates a rock dummy and moves it in the targeted direction, dealing damage and stunning the first enemy that it encounters. However, as soon as the spell is cast, the dummy is killed (which is supposed to happen when it encounters an enemy). What am I doing wrong?
JASS:
function hurlboulder_groupcheck takes nothing returns boolean
  if (IsUnitAliveBJ(GetFilterUnit()) == false) then
    return false
  endif
  if (IsUnitEnemy(GetFilterUnit(), GetOwningPlayer(GetTriggerUnit())) == false) then
    return false
  endif
  return true
endfunction

function hurlboulder_effect takes nothing returns nothing
  local unit caster = GetTriggerUnit()
  local player owner = GetOwningPlayer(caster)
  local integer i = GetConvertedPlayerId(owner)
  local location origin = GetUnitLoc(udg_hurlboulder_dummy<i>)
  local real angle = GetUnitFacing(udg_hurlboulder_dummy<i>)
  local location moveloc = PolarProjectionBJ(origin, 10, angle)
  local group g = GetUnitsInRangeOfLocMatching(50, moveloc, Condition(function hurlboulder_groupcheck))
  local unit target

  set udg_hurlboulder_distance<i> = udg_hurlboulder_distance<i> + 10
  call SetUnitPositionLoc(udg_hurlboulder_dummy<i>, moveloc)
  if CountUnitsInGroup(g) &gt; 0 then
    set target = FirstOfGroup(g)
    call KillUnit(udg_hurlboulder_dummy<i>)
    call DestroyTimer(GetExpiredTimer())
  endif
endfunction

function hurlboulder_start takes nothing returns nothing
  local unit caster = GetTriggerUnit()
  local player owner = GetOwningPlayer(caster)
  local integer i = GetConvertedPlayerId(owner)
  local location origin = GetUnitLoc(caster)
  local location targloc = GetSpellTargetLoc()
  local real angle = AngleBetweenPoints(origin, targloc)
  local location spawnloc = PolarProjectionBJ(origin, 50, angle)
  local timer t = CreateTimer()

  set udg_hurlboulder_dummy<i> = CreateUnitAtLoc(owner, &#039;h002&#039;, spawnloc, 0)
  set udg_hurlboulder_distance<i> = 0
  set udg_hurlboulder_damage<i> = 50
  call TimerStart(t, 0.01, true, function hurlboulder_effect)
endfunction

//===========================================================================
function InitTrig_hurl_boulder takes nothing returns nothing
  local trigger trig = CreateTrigger()
  call TriggerRegisterAnyUnitEventBJ(trig, EVENT_PLAYER_UNIT_SPELL_EFFECT)
  call TriggerAddCondition(trig, Condition(function hurlboulder_check))
  call TriggerAddAction(trig, function hurlboulder_start)
endfunction
</i></i></i></i></i></i></i></i></i>


Edit: oh god im sorry for posting this in the wrong section...
 

BlackRose

Forum User
Reaction score
239
This might be the cause, I;m not sure, but it is probably because you didn't pass any data onto the timer.

JASS:
function hurlboulder_effect takes nothing returns nothing
  local unit caster = GetTriggerUnit()

There is no value of caster, GetTriggerUnit() doesn't work I believe.

Use vJASS structs and a attaching system like KT2. Also, your conditions are terrible.
 

eskimojoe_66

Member
Reaction score
2
haha yeah i know about that... i have a mac so i cant use vJASS/NewGen until then... but i think that GetTriggerUnit() does work because i use that to get the PlayerId for: call KillUnit(udg_hurlboulderdummy). If GetTriggerUnit() didnt work, wouldn't that mean that the dummy wouldnt be killed?

and yes the conditions are very general, but it should still exclude the caster.
 

eskimojoe_66

Member
Reaction score
2
oooo ok ill try that... yeah im still learning JASS soo :D

Edit: i restructured the conditions... it looks much cleaner but the effect is still the same. Where would i add the 'call BJDebugMsg'?
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top