- Joined
- Jun 7, 2008
- Messages
- 440
Can anyone help me find out why the timer fires twice?
JASS:
function Trig_DestroyGroup takes nothing returns nothing
local unit u = GetEnumUnit()
call SetUnitExploded(u, true)
call KillUnit(u)
set u = null
endfunction
function GG_Callback takes nothing returns nothing
local timer t = GetExpiredTimer()
local integer count = LoadInteger(udg_DDHash,GetHandleId(t),1)
local real x = GetLocationX(udg_Temp_Loc)
local real y = GetLocationY(udg_Temp_Loc)
local unit u
local unit dest = CreateUnit(udg_Target, udg_DestructionSphere[count], x, y, 0.00)
call UnitApplyTimedLife(dest, 'BTLF', .5)
set dest = null
call DisplayTextToForce(GetPlayersAll(), I2S(count)) //How I found out if fired 2x
if count == 10 then
call ForGroup( udg_Temp_Group, function Trig_DestroyGroup )
call SetUnitExploded(udg_Relic, true)
call KillUnit(udg_Relic)
call PauseTimer(t)
call DestroyTimer(t)
call FlushChildHashtable(udg_DDHash,GetHandleId(t))
endif
call SaveInteger(udg_DDHash,GetHandleId(t),1,count+1)
endfunction
function Trig_Tower_Destruction_Actions takes nothing returns nothing
local timer t = CreateTimer()
call SaveInteger (udg_DDHash, GetHandleId(t), 1, 0)
call TimerStart(t, .5, true, function GG_Callback)
if (IsPlayerInForce(GetLocalPlayer(), bj_FORCE_ALL_PLAYERS)) then
call EnableUserControl(false)
endif
set udg_In_Event = false
endfunction
//===========================================================================
function InitTrig_Tower_Destruction takes nothing returns nothing
set gg_trg_Tower_Destruction = CreateTrigger( )
call DisableTrigger( gg_trg_Tower_Destruction )
call TriggerAddAction( gg_trg_Tower_Destruction, function Trig_Tower_Destruction_Actions )