• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Help with Timer & Hashtable

Status
Not open for further replies.
Level 2
Joined
Aug 11, 2009
Messages
22
Hi,
I made a very straight forward trigger with JASS, using a timer and a hashtable to transfer information from one action to another. However it doesn't save the unithandles I created. I'm fairly inexperienced with hashtables so bare with me if it's something obvious.

Here is the code:

JASS:
function Reset takes nothing returns nothing

    local timer t = GetExpiredTimer()
    local unit u = LoadUnitHandle(udg_Hashtable, GetHandleId(t), 0)
    local integer lvl = GetUnitAbilityLevel(u , 'A023')
    
    call KillUnit(u)
    
    call AddUnitAnimationProperties(u, "Attack Walk Spin", false)
    call EnableTrigger(gg_trg_Bladestorm_Reset)
    call PauseTimer(t)
    call DestroyTimer(t)
    set t = null    

endfunction

function Trig_Bladestorm_Actions takes nothing returns nothing

    local unit caster = GetTriggerUnit()
    local location loc = GetUnitLoc(caster)
    local integer level = GetUnitAbilityLevel(caster, GetSpellAbilityId())
    local real damage = level * 80 + GetHeroStr(caster, true)
    local group targets = CreateGroup()
    local unit fog
    local timer t = CreateTimer()
    
    
    call AddUnitAnimationProperties(caster, "Attack Walk Spin", true)
    call BJDebugMsg(R2S(damage))
    call GroupEnumUnitsInRangeOfLoc(targets, loc, 220., Filter(function Enum))
    call DisableTrigger(gg_trg_Bladestorm_Reset)
    call SaveUnitHandle(udg_Hashtable, GetHandleId(t), 0, caster)
    call TimerStart(t, .3, false, function Reset)

I left out some parts of the code, which work fine. The call KillUnit in the TimerExpired action is only there to test it quickly. What did I do wrong? :vw_wtf:
 
Level 2
Joined
Aug 11, 2009
Messages
22
Yea exactly. I thought that it was the same as with unit groups, which work once you create the global variable. Well, now I know better.
 
Status
Not open for further replies.
Top