scope Forward
private struct ForwardData
unit caster
unit target
real TotalDist
real DistLeft
real angle
static method Timer_Actions takes nothing returns nothing
local timer t = GetExpiredTimer()
local thistype D = GetTimerData(t)
local real x
local real y
local real x2
local real y2
if D.DistLeft > 0 then
set x = GetUnitX(D.caster)
set y = GetUnitY(D.caster)
set x2 = x + 5 * Cos(D.angle * bj_DEGTORAD)
set y2 = y + 5 * Cos(D.angle * bj_DEGTORAD)
call SetUnitX(D.caster, x2)
call SetUnitY(D.caster, y2)
set D.DistLeft = D.DistLeft - 5
else
call ReleaseTimer(t)
call SetUnitPathing(D.caster, true)
call PauseUnit(D.caster, false)
call SetUnitAnimation(D.caster, "stand")
call D.deallocate()
endif
set t = null
endmethod
static method create takes nothing returns thistype
local thistype D = thistype.allocate()
local real xdist
local real ydist
local timer t = NewTimer()
set D.caster = GetTriggerUnit()
set D.target = GetSpellTargetUnit()
set xdist = GetUnitX(D.caster) - GetUnitX(D.target)
set ydist = GetUnitY(D.caster) - GetUnitY(D.target)
set D.TotalDist = SquareRoot((xdist * xdist) + (ydist * ydist))
set D.DistLeft = D.TotalDist
call SetUnitPathing(D.caster, false)
call PauseUnit(D.caster, true)
call SetUnitAnimation(D.caster, "walk")
set D.angle = bj_RADTODEG * (Atan2(GetUnitY(D.target) - GetUnitY(D.caster), GetUnitX(D.target) - GetUnitX(D.caster)))
call SetTimerData(t, D)
call TimerStart(t, 0.03, true, function thistype.Timer_Actions)
set t = null
return D
endmethod
static method Conditions takes nothing returns boolean
if GetSpellAbilityId() == 'A001' then
call thistype.create()
endif
return false
endmethod
static method onInit takes nothing returns nothing
local trigger t = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_SPELL_EFFECT)
call TriggerAddCondition(t, Condition(function thistype.Conditions))
set t = null
endmethod
endstruct
endscope