- Joined
- Mar 21, 2011
- Messages
- 1,611
[SOLVED]Add ability for x seconds
Hi,
i want to make a simple trigger in Jass which adds an ability to a unit for x seconds. I use TimerUtils, but i dont know how to catch the unit in the called function at the end of the duration.
Hi,
i want to make a simple trigger in Jass which adds an ability to a unit for x seconds. I use TimerUtils, but i dont know how to catch the unit in the called function at the end of the duration.
JASS:
function RemoveDetector takes nothing returns nothing
call UnitRemoveAbility(?UNIT?, 'A00S')
call ReleaseTimer(GetExpiredTimer())
endfunction
function Trig_Detector_Conditions takes nothing returns boolean
local timer t
if (GetSpellAbilityId() == 'A00T')) then
set t = NewTimer()
call TimerStart(t, 30.00, false, function RemoveDetector)
call UnitAddAbility(GetTriggerUnit(), 'A00S')
set t = null
endif
return false
endfunction
//===========================================================================
function InitTrig_Detector takes nothing returns nothing
local integer index
set index = 0
set gg_trg_Detector = CreateTrigger()
loop
call TriggerRegisterPlayerUnitEvent(gg_trg_Detector, Player(index), EVENT_PLAYER_UNIT_SPELL_EFFECT, null)
set index = index + 1
exitwhen index == bj_MAX_PLAYER_SLOTS
endloop
call TriggerAddCondition(gg_trg_Detector, Condition(function Trig_Detector_Conditions))
endfunction
Last edited: