[JASS] Sacing integer in hashtable

Status
Not open for further replies.
Level 20
Joined
Jul 6, 2009
Messages
1,885
Can someone explain me why in this function...
JASS:
function Track_Actions takes nothing returns nothing
    set bj_lastCreatedUnit =  CreateUnit(GetOwningPlayer(GetTriggerUnit()),'h005',GetUnitX(GetSpellTargetUnit()),GetUnitY(GetSpellTargetUnit()),0.00)
    call UnitApplyTimedLife(bj_lastCreatedUnit, 'BTLF',1.00)
    call IssueTargetOrder(bj_lastCreatedUnit, "faeriefire", GetSpellTargetUnit())
    call SaveInteger(udg_Hashtable,GetHandleId(GetSpellTargetUnit()),1,10)
    call SaveInteger(udg_Hashtable,GetHandleId(GetSpellTargetUnit()),2,GetPlayerId(GetOwningPlayer(GetTriggerUnit())))
endfunction
...the SaveInteger functions don't work? (The values don't get saved)
Also if i put them on function start like...
JASS:
function Track_Actions takes nothing returns nothing
    call SaveInteger(udg_Hashtable,GetHandleId(GetSpellTargetUnit()),1,10)
    call SaveInteger(udg_Hashtable,GetHandleId(GetSpellTargetUnit()),2,GetPlayerId(GetOwningPlayer(GetTriggerUnit())))    
    set bj_lastCreatedUnit =  CreateUnit(GetOwningPlayer(GetTriggerUnit()),'h005',GetUnitX(GetSpellTargetUnit()),GetUnitY(GetSpellTargetUnit()),0.00)
    call UnitApplyTimedLife(bj_lastCreatedUnit, 'BTLF',1.00)
    call IssueTargetOrder(bj_lastCreatedUnit, "faeriefire", GetSpellTargetUnit())
endfunction
...they do work!
How can function schedule affect it?! :eekani:

Oh and "Sacing" is a typo,it's supposed to be "Saving"...
 
Last edited:
Level 18
Joined
Jan 21, 2006
Messages
2,552
Have you tried putting debug messages throughout the code? Perhaps one of your other lines of code is causing the thread to crash. It doesn't appear to be wrong in any way but maybe I am missing something, I would check anyways. Also where do you initialize udg_Hashtable?
 
call IssueTargetOrder(bj_lastCreatedUnit, "faeriefire", GetSpellTargetUnit())
this will change the result of
GetSpellTargetUnit()
so actually you are saving the stuff to bj_lastCreatedUnit instead


edit:
right
that does not make sense
I once had a similar problem (a little more obfuscated though)
but even if it does not make sense it might be the cause
I'm curious about what will happen if you comment out the order (it's a spell order nevertheless and GetSpellTargetUnit is very touchy)
 
Last edited:
Level 20
Joined
Jul 6, 2009
Messages
1,885
@Berb,
It doesn't crash or give errors,it doesn't seem to save it properly. It returns 0 when i load it in other trigger. Also i do init hashtable at another trigger,the hashtable works in some other triggers.

@G4ND4LF,
How can issuing order change the result of GetSpellTargetUnit?
The last created unit isn't the target o_O
 
Level 26
Joined
Aug 18, 2009
Messages
4,097
How can issuing order change the result of GetSpellTargetUnit?
The last created unit isn't the target o_O

Well, because it does. Probably it's a bug but GetSpellTargetUnit is not very constantly (maybe even locally) protected. Issuing an order overwrites it. I do not know whether it changes to the ordered unit but imho it is common sense to save event responses at the beginning of the thread.
 
I would like to see the initialiser for this trigger (including how it is called). Other than that, use this because it doesn't leak the locations.

JASS:
function Track_Actions takes nothing returns nothing
    local unit u = GetSpellTargetUnit()
    set bj_lastCreatedUnit = CreateUnit(GetTriggerPlayer(), 'h005', GetSpellTargetX(), GetSpellTargetY(), 0.)
    call BJDebugMsg("dummy created")
    call UnitApplyTimedLife(bj_lastCreatedUnit, 'BTLF', 1.)
    call IssueTargetOrder(bj_lastCreatedUnit, "faeriefire", u)
    call BJDebugMsg("dummy cast spell")
    call SaveInteger(udg_Hashtable, GetHandleId(u), 1, 10)
    call SaveInteger(udg_Hashtable, GetHandleId(u), 2, GetPlayerId(GetTriggerPlayer()))
    call BJDebugMsg("variables saved")
    set u = null
endfunction

If all three debug messages show up, your problem lies elsewhere.
 
Status
Not open for further replies.
Top