• 🏆 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!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

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