• 🏆 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] All timers affected!?

Status
Not open for further replies.
Level 6
Joined
Jul 25, 2005
Messages
221
Yo, anyone wanna solve this puzzle? I cannot see any mistakes to this code, then again I wrote it...

The whole problem in it is that every time I order a unit to "manashieldoff", all other timers using the 'decelerationanimation' function are deleted as well.
I don't know if I can give rep to anyone, but help would be highly appreciated.

Clarification:
decdeso = decelerator destroy o (trigger o destroys all vars)
decdese = -=- e (trigger e destroys all vars )

I'm using the H2I bug so, I might've missed something in that area?
Constructive critisicm please:cute:

IMPORTANT NOTE: The only problem is when I use manashieldoff order, not manashieldon

JASS:
function deccond takes nothing returns boolean
    return GetIssuedOrderId() == OrderId("manashieldon")
endfunction

function decdescond takes nothing returns boolean
    return GetIssuedOrderId() == OrderId("manashieldoff")
endfunction

function decdeso takes nothing returns nothing
local gamecache gc = udg_GameCache
local string to = I2S(H2I(GetTriggeringTrigger()))
local timer t = I2T(GetStoredInteger(gc,to,"t"))
local trigger te = I2TR(GetStoredInteger(gc,to,"e"))
    call BJDebugMsg(to)
    call DestroyTimer(t)
    call DestroyTrigger(te)
    call DestroyTrigger(GetTriggeringTrigger())
    set t = null
    set te = null
    set to = null
endfunction

function decdese takes nothing returns nothing
local gamecache gc = udg_GameCache
local string te = I2S(H2I(GetTriggeringTrigger()))
local timer t = I2T(GetStoredInteger(gc,te,"t"))
local trigger to = I2TR(GetStoredInteger(gc,te,"e"))
    call DestroyTimer(t)
    call DestroyTrigger(to)
    call DestroyTrigger(GetTriggeringTrigger())
    set t = null
    set to = null
    set te = null
endfunction

function decelerationanimation takes nothing returns nothing
local gamecache gc = udg_GameCache
local string s = I2S(H2I(GetExpiredTimer()))
local unit u = I2U(GetStoredInteger(gc,s,"u"))
local unit d
local integer i = 0
    loop
        exitwhen i > 3
        set d = CreateUnit(GetOwningPlayer(u),'e004', GetUnitX(u)+250*Cos((i*90)*(bj_PI/180)), GetUnitY(u)+250*Sin((i*90)*(bj_PI/180)), i*90)
        call KillUnit(d)
        set i = i+1
    endloop
    set d = null
    set u = null
    set s = null
endfunction

function deceleratoractivate takes nothing returns nothing
local gamecache gc = udg_GameCache
local timer t = CreateTimer()
local unit u = GetOrderedUnit()
local trigger o = CreateTrigger()
local trigger e = CreateTrigger()
local string s = I2S(H2I(t))
local string to = I2S(H2I(o))
local string te = I2S(H2I(e))
local integer i = 0
    call StoreInteger(gc,s,"u",H2I(u))
    call TimerStart(t,1.5,true,function decelerationanimation)
    loop
        exitwhen i > bj_MAX_PLAYERS
            call TriggerRegisterPlayerUnitEvent(o,Player(i), EVENT_PLAYER_UNIT_ISSUED_ORDER, null)
            set i = i+1
    endloop
    call StoreInteger(gc,to,"t",H2I(t))
    call StoreInteger(gc,to,"e",H2I(e))
    call TriggerAddCondition(o, Condition(function decdescond))
    call TriggerAddAction(o,function decdeso)  
    call StoreInteger(gc,te,"t",H2I(t))
    call StoreInteger(gc,te,"o",H2I(o))
    call TriggerRegisterUnitManaEvent(e, u, LESS_THAN_OR_EQUAL, 0)
    call TriggerAddAction(e,function decdese)
    call BJDebugMsg(I2S(H2I(t)))
    set s = null
    set to = null
    set te = null
    set o = null
    set e = null
    set u = null
    set t = null
endfunction

//===========================================================================
function InitTrig_decelerator takes nothing returns nothing
local integer i = 0
    set gg_trg_decelerator = CreateTrigger(  )
    loop
        exitwhen i > bj_MAX_PLAYERS
            call TriggerRegisterPlayerUnitEvent(gg_trg_decelerator,Player(i), EVENT_PLAYER_UNIT_ISSUED_ORDER, null)
            set i = i+1
    endloop
    //call TriggerRegisterPlayerUnitEvent(gg_trg_decelerator,Player(13), EVENT_PLAYER_UNIT_ISSUED_ORDER, null)
    call TriggerAddCondition(gg_trg_decelerator, Condition(function deccond))
    call TriggerAddAction( gg_trg_decelerator, function deceleratoractivate )
endfunction
//Copyright 2008
 
Level 6
Joined
Jul 25, 2005
Messages
221
But flushing the gamecache removes all values, doesn't it? How do you remove a single value from gamecache, by setting the value to null? >.<
 
Level 6
Joined
Jul 25, 2005
Messages
221
Didn't work, although it does make the game free from storing too much data, if there is such a thing... :cute:

Anyway, the problem still remain, help still needed.

Edit: Until a genious tells me what the problem is, I'm gonna discard the 'manashieldoff' order completely, since I have no use of it in my map, however, I still want to know what the problem is :sad:
 
Status
Not open for further replies.
Top