scope LifeBreak initializer init
globals
private constant real speed = 30
private hashtable hash = InitHashtable()
private group LifeBreakers = CreateGroup()
private group tempGrp = CreateGroup()
endglobals
function Cond takes nothing returns boolean
return GetSpellAbilityId() == 'A000'
endfunction
function Movement takes nothing returns nothing
local unit u1
local unit u2
local real x1
local real x2
local real y1
local real y2
local real a
call GroupAddGroup(LifeBreakers, tempGrp)
loop
set u1 = FirstOfGroup(tempGrp)
exitwhen u1 == null
call GroupRemoveUnit(tempGrp, u1)
set u2 = LoadUnitHandle(hash, GetHandleId(u1), 0)
set x1 = GetUnitX(u1)
set x2 = GetUnitX(u2)
set y1 = GetUnitY(u1)
set y2 = GetUnitY(u2)
if SquareRoot(Pow(y2 - y1, 2) + Pow(x2 - x1, 2)) > 100 then
set a = Atan2(y2 - y1, x2 - x1)
call SetUnitX(u1, x1 + Cos(a) * speed)
call SetUnitY(u1, y1 + Sin(a) * speed)
call IssueImmediateOrder(u1, "stop")
else
call GroupRemoveUnit(LifeBreakers, u1)
call SetUnitPathing(u1, true)
endif
set u1 = null
set u2 = null
endloop
call GroupClear(tempGrp)
endfunction
function Effect takes nothing returns nothing
local unit u1 = GetTriggerUnit()
local unit u2 = GetSpellTargetUnit()
call SetUnitPathing(u1, false)
call GroupAddUnit(LifeBreakers, u1)
call SaveUnitHandle(hash, GetHandleId(u1), 0, u2)
set u1 = null
set u2 = null
endfunction
function EndCast takes nothing returns nothing
call SetUnitAnimationByIndex(GetTriggerUnit(), 17)
endfunction
function init takes nothing returns nothing
local trigger t = CreateTrigger()
local timer tmr = CreateTimer()
call TriggerAddAction(t, function Effect)
call TriggerAddCondition(t, function Cond)
call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_SPELL_EFFECT)
set t = CreateTrigger()
call TriggerAddAction(t, function EndCast)
call TriggerAddCondition(t, function Cond)
call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_SPELL_ENDCAST)
call TimerStart(tmr, 0.03, true, function Movement)
call FogMaskEnable(false)
call FogEnable(false)
set t = null
set tmr = null
endfunction
endscope[/Hidden]