scope Wheel initializer init
globals
private constant integer SPELLID = 'AEfk'
private constant integer DUMMYID = 'h000'
private constant real LIFE = 10
private constant real ROTATIONSPEED1 = 2.
private constant real ROTATIONSPEED2 = 2.
private constant real OFFSET = 200.
private constant real TIMERSPEED = 0.03125
private constant string LIGHTNING = "DRAL"
private constant hashtable HASH = InitHashtable()
endglobals
private struct WWheel
unit caster
unit dummy1
unit dummy2
real angle1
real angle2
real x
real y
lightning lig1
lightning lig2
static method onMove takes nothing returns nothing
local timer t = GetExpiredTimer()
local thistype this = LoadInteger(HASH, GetHandleId(t), 1)
set .angle1 = .angle1+ROTATIONSPEED1*bj_DEGTORAD
call SetUnitX(.dummy1, .x+OFFSET*Cos(.angle1))
call SetUnitY(.dummy1, .y+OFFSET*Sin(.angle1))
set .angle2 = .angle2+ROTATIONSPEED2
call SetUnitX(.dummy2, GetUnitX(.dummy1)+OFFSET*Cos(.angle2))
call SetUnitY(.dummy2, GetUnitY(.dummy1)+OFFSET*Sin(.angle2))
call MoveLightningEx(.lig2, true, GetUnitX(.dummy1), GetUnitY(.dummy1), 100, GetUnitX(.dummy2), GetUnitY(.dummy2), 100)
if GetWidgetLife(.dummy1) > 0.405 and GetWidgetLife(.dummy2) > 0.405 then
else
call PauseTimer(t)
call DestroyTimer(t)
call DestroyLightning(.lig1)
call DestroyLightning(.lig2)
endif
set t = null
endmethod
static method onCreate takes unit u returns thistype
local thistype this = thistype.create()
local timer t = CreateTimer()
local real xx
local real yy
local real dist
set .caster = u
set .x = GetUnitX(u)
set .y = GetUnitY(u)
set .dummy1 = CreateUnit(GetTriggerPlayer(), DUMMYID, .x, .y, 0)
set .dummy2 = CreateUnit(GetTriggerPlayer(), DUMMYID, .x, .y, 0)
set .angle1 = 0
set .angle2 = 0
set .lig1 = AddLightning(LIGHTNING, true, GetUnitX(.dummy1), GetUnitY(.dummy1), GetUnitX(.dummy2), GetUnitY(.dummy2))
set .lig2 = AddLightning(LIGHTNING, true, GetUnitX(.dummy1), GetUnitY(.dummy1), GetUnitX(.dummy2), GetUnitY(.dummy2))
call UnitApplyTimedLife(.dummy1, 'BTLF', LIFE)
call UnitApplyTimedLife(.dummy2, 'BTLF', LIFE)
call SaveInteger(HASH, GetHandleId(t), 1, this)
call TimerStart(t, TIMERSPEED, true, function thistype.onMove)
return this
endmethod
endstruct
private function CAST takes nothing returns boolean
if GetSpellAbilityId()==SPELLID then
call WWheel.onCreate(GetTriggerUnit())
endif
return false
endfunction
private function init takes nothing returns nothing
local trigger t = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_SPELL_EFFECT)
call TriggerAddCondition(t, Condition(function CAST))
set t = null
endfunction
endscope