globals
hashtable H = InitHashtable()
integer Charges = 5
endglobals
function Trig_Mine_Count_Conditions takes nothing returns boolean
return GetUnitTypeId(GetTriggerUnit()) == 'nglm'
endfunction
function TimerMines takes nothing returns nothing
local timer t = GetExpiredTimer()
local unit u = LoadUnitHandle(H, GetHandleId(t), 0)
set Charges = Charges+1
if Charges == 1 then
call UnitRemoveAbility(u, 'A001') // Remove Disabled Mines
call UnitAddAbility(u, 'A000') // Add Enabled Mines
endif
call PauseTimer(t)
call FlushChildHashtable(H, GetHandleId(t))
call DestroyTimer(t)
set t = null
set u = null
call BJDebugMsg("Timer Expired. Your charges increases to |cffff0000" + I2S(Charges) + "|r")
endfunction
function Trig_Mine_Count_Actions takes nothing returns nothing
local unit u = GetSummoningUnit()
local timer t = CreateTimer()
local real Cooldown = 15
set Charges = Charges-1 // Reduce Charges
call TimerStart(t, Cooldown, false, function TimerMines) // Start Timer
call SaveUnitHandle(H, GetHandleId(t), 0, u)
if Charges == 0 then
call TriggerSleepAction(0.0) // Allow Finishing Casting Animation
call UnitRemoveAbility(u, 'A000') // Remove Enabled Mines
call UnitAddAbility(u, 'A001') // Add Disabled Mines
endif
set u = null
set t = null
call BJDebugMsg("|cffff0000" + I2S(Charges) + "|r Charges remaining")
endfunction
//===========================================================================
function InitTrig_Mine_Count takes nothing returns nothing
set gg_trg_Mine_Count = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Mine_Count, EVENT_PLAYER_UNIT_SUMMON )
call TriggerAddCondition( gg_trg_Mine_Count, Condition( function Trig_Mine_Count_Conditions ) )
call TriggerAddAction( gg_trg_Mine_Count, function Trig_Mine_Count_Actions )
endfunction