function MySpell_Stop_Conditions takes nothing returns boolean
return GetSpellAbilityId() == 'A000' or GetTriggerUnit() == null
endfunction
function MySpell_Stop_Actions takes nothing returns nothing
local trigger trig = GetTriggeringTrigger()
local timer t = GetHandleTimer(trig, "t")
// ....do whatever you must kill/remove/destroy/stop/change.......
call FlushHandleLocals(t) // most likely
call PauseTimer(t) // to avoid a bug
call DestroyTimer(t)
call FlushHandleLocals(trig)
call DestroyTrigger(t)
set trig = null
set t = null
// .....some more nullifications if necessary.....
endfunction
//===========================================
function MySpell_Conditions takes nothing returns boolean
return GetSpellAbilityId() == 'A000'
endfunction
function MySpell_Actions takes nothing returns nothing
local timer t = CreateTimer()
local unit c = GetTriggerUnit()
local trigger trig = CreateTrigger()
local trigggeraction ta = TriggerAddAction(trig, function MySpell_Stop_Actions)
local triggercondition tc = TriggerAddCondition(trig, Condition(function MySpell_Stop_Conditions)
// ....some more locals......
call TriggerRegisterPlayerUnitEvent(trig, GetOwningPlayer(c), EVENT_PLAYER_UNIT_SPELL_ENDCAST, null)
call TriggerRegisterTimerEvent(trig, <spell duration>, false) // this is when the spell finishes, meaning it hasn't been stopped
// ....attach stuff to the timer......
call SetHandleHandle(trig, "t", t) //!
call TimerStart(t, 1, true, function SomeFunctionThatIsNotHere)
set t = null
set c = null
set trig = null
set ta = null
set tc = null
// .....nullify the rest of the handles.......
endfunction