function Trig_M1_Conditions takes nothing returns boolean
return GetSpellAbilityId() == 'A000'
endfunction
function ElseRemoval takes nothing returns nothing
local trigger t = GetTriggeringTrigger()
local integer id = GetHandleId (t)
local unit u = LoadUnitHandle (udg_M_Hash, id, StringHash("unit"))
call UnitRemoveAbility (u, 'A001')
call FlushChildHashtable (udg_M_Hash, id)
call DestroyTrigger (t)
set u = null
endfunction
function Removal takes nothing returns nothing
local timer t = GetExpiredTimer()
local integer id = GetHandleId (t)
local unit u = LoadUnitHandle (udg_M_Hash, id, StringHash("unit"))
local trigger tr
if GetWidgetLife (u) > 0.415 then
call UnitRemoveAbility (u, 'A001')
else
set tr = CreateTrigger()
call SaveUnitHandle (udg_M_Hash, GetHandleId (tr), StringHash("unit"), u)
call TriggerRegisterUnitLifeEvent (tr, u, GREATER_THAN, 0.415)
call TriggerAddAction (tr, function ElseRemoval)
endif
call FlushChildHashtable (udg_M_Hash, id)
call DestroyTimer (t)
set u = null
set t = null
endfunction
function Trig_M1_Actions takes nothing returns nothing
local unit u = GetSpellTargetUnit()
local real d = GetUnitAbilityLevel (u, 'A000') * 5
local timer t = CreateTimer()
local integer id = GetHandleId (t)
call SaveUnitHandle (udg_M_Hash, id, StringHash("unit"), u)
call TimerStart (t, d, false, function Removal)
call UnitAddAbility (u, 'A001')
set u = null
set t = null
endfunction
//===========================================================================
function InitTrig_M1 takes nothing returns nothing
set gg_trg_M1 = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_M1, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition( gg_trg_M1, Condition( function Trig_M1_Conditions ) )
call TriggerAddAction( gg_trg_M1, function Trig_M1_Actions )
endfunction