• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[JASS] Can't figure this one out

Status
Not open for further replies.
Level 9
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 )
 
Status
Not open for further replies.
Top