library StormRage requires LLAlloc
globals
private constant real FPS = 0.050000000000
endglobals
private struct Loop extends array
private real temp
private unit u
private static timer period = CreateTimer()
//! runtextmacro LL_Alloc()
static method periodic takes nothing returns nothing
local thistype this = first
loop
exitwhen this == 0
set this.temp = this.temp - FPS
if this.temp <= 0 then
call GroupRemoveUnit(SR_Grp, this.u)
call this.unchain()
call this.deallocate()
endif
if empty() then
call PauseTimer(period)
endif
set this = this.next
endloop
endmethod
static method Debug takes unit U, real duration returns nothing
local thistype this = thistype.allocate()
set this.temp = duration
set this.u = U
if empty() then
call TimerStart(period, FPS, true, function thistype.periodic)
endif
call this.chain()
endmethod
private static method cond takes nothing returns boolean
local unit u
if GetSpellAbilityId() == 'A009' then
set u = GetTriggerUnit()
call GroupAddUnit(SR_Grp,u)
call Debug(u,10)
call TimedStats.AddTimedStatBonus(u, SR_BONUS[GetUnitAbilityLevel(u, 'A009')]*GetHeroAgi(u, false)/100, 2, 10)
endif
return false
endmethod
private static method act takes nothing returns boolean
local unit u
local unit u1 = GetTriggerUnit()
local real r
if (GetIssuedOrderId() == OrderId("attack") or GetIssuedOrderId() == OrderId("smart")) and IsUnitInGroup(u1, SR_Grp) then
set u = GetOrderTargetUnit()
if u != null and SquareRoot(GetUnitX(u)*GetUnitX(u1) + GetUnitY(u)*GetUnitY(u1)) < (200+ SR_AOE_FACTOR[GetUnitAbilityLevel(u1,'A009')]*GetHeroAgi(u1,true)) then
set r = GetRandomReal(0,360)
call SetUnitX(u1, PolarProjectionX(GetUnitX(u), r, 100))
call SetUnitY(u1, PolarProjectionY(GetUnitY(u), r, 100))
endif
set u = null
endif
set u1 = null
return false
endmethod
private static method onInit takes nothing returns nothing
local trigger t = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ(t, ConvertPlayerUnitEvent(274))
call TriggerAddCondition(t, Condition(function thistype.cond))
set t = null
//
set t = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_ISSUED_TARGET_ORDER)
call TriggerAddCondition(t, Condition(function thistype.act))
set t = null
endmethod
endstruct
endlibrary