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?
Edit: oh god im sorry for posting this in the wrong section...
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) > 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;h002039;, 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...