function Conditions takes nothing returns boolean
return GetSpellAbilityId() == 'A001'
endfunction
function Timer takes nothing returns nothing
local timer t = GetExpiredTimer()
local unit u = LoadUnitHandle (udg_Hash, GetHandleId (t), StringHash("unit"))
call UnitRemoveAbility (u, 'A002')
call FlushChildHashtable (udg_Hash, GetHandleId(u))
set t = null
set u = null
endfunction
function Actions takes nothing returns nothing
local unit u = GetSpellTargetUnit()
local timer t = CreateTimer()
local timer t1 = LoadTimerHandle (udg_Hash, GetHandleId(u), StringHash("timer"))
if GetUnitAbilityLevel (u, 'A002') < 1 then
call UnitAddAbility (u, 'A002')
else
call UnitRemoveAbility (u, 'A002')
call PauseTimer(t1)
call FlushChildHashtable (udg_Hash, GetHandleId(t1))
call DestroyTimer (t1)
call UnitAddAbility (u, 'A002')
endif
call SaveUnitHandle (udg_Hash, GetHandleId(t), StringHash("unit"), u)
call SaveTimerHandle (udg_Hash, GetHandleId(u), StringHash("timer"), t)
call TimerStart (t, 20, false, function Timer)
set u = null
set t = null
set t1 = null
endfunction
//===========================================================================
function InitTrig_Lightning_Shield takes nothing returns nothing
local trigger t = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ (t, EVENT_PLAYER_UNIT_SPELL_EFFECT)
call TriggerAddCondition (t, Condition( function Conditions))
call TriggerAddAction (t, function Actions)
endfunction