• 🏆 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] GetEnumUnit() isnt working

Status
Not open for further replies.
Level 9
Joined
Aug 21, 2008
Messages
533
JASS:
function Fly takes nothing returns nothing
    local unit u = GetEnumUnit()
    local real rx = LoadReal( udg_hashTable, GetHandleId(u), StringHash("X"))
    local real ry = LoadReal( udg_hashTable, GetHandleId(u), StringHash("Y"))
    local real time = LoadReal( udg_hashTable, GetHandleId(u), StringHash("t"))
    if (time>0) then 
    call SetUnitX(u,GetUnitX(u)+rx)
    call SetUnitY(u,GetUnitY(u)+ry)
    endif
    call DisplayTextToForce( GetPlayersAll(), "Work")
    set u = null
    call KillUnit(u)
endfunction

function Trig_Fly_Actions takes nothing returns nothing
    call ForGroup( udg_misslegroup, function Fly )
endfunction
//===========================================================================
function InitTrig_Fly takes nothing returns nothing
    set gg_trg_Fly = CreateTrigger(  )
    call TriggerRegisterTimerEventPeriodic( gg_trg_Fly, 0.03 )
    call TriggerAddAction( gg_trg_Fly, function Trig_Fly_Actions )
endfunction

call DisplayTextToForce( GetPlayersAll(), "Work") is working
but the rest of the trigger8whoch is related to "u") isnt working.
Pls help:cry:
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,201
Your testing does not concluded that GetEnumUnit is not working, it purly concludes that the hashtable recall is failing.

JASS:
function Fly takes nothing returns nothing
    local unit u = GetEnumUnit()
    local real rx = LoadReal( udg_hashTable, GetHandleId(u), StringHash("X")) //Imagine this fails and rx becomes 0.
    local real ry = LoadReal( udg_hashTable, GetHandleId(u), StringHash("Y")) //Imagine this fails and ry becomes 0.
    local real time = LoadReal( udg_hashTable, GetHandleId(u), StringHash("t")) //Imagine this fails and time becomes 0.
    if (time>0) then //Will not work unless time is greater than 0, so obviously nothing will happen if the hashtable fails to work. 
        call SetUnitX(u,GetUnitX(u)+rx) //If hashtable load fails you move the unit to where it is already.
        call SetUnitY(u,GetUnitY(u)+ry) //If hashtable load fails you move the unit to where it is already.
    endif
    call DisplayTextToForce( GetPlayersAll(), "Work") //This means shit all for a test.
    set u = null
    call KillUnit(u) //Um, this is usless and should be deleted as you are removing null which makes shit all sense.   Invert this line with the line above as you are after killing the unit and then nulling the local which held it.
endfunction

function Trig_Fly_Actions takes nothing returns nothing
    call ForGroup( udg_misslegroup, function Fly )
endfunction
//===========================================================================
function InitTrig_Fly takes nothing returns nothing
    set gg_trg_Fly = CreateTrigger(  )
    call TriggerRegisterTimerEventPeriodic( gg_trg_Fly, 0.03 )
    call TriggerAddAction( gg_trg_Fly, function Trig_Fly_Actions )
endfunction

Thus in conclusion, your GetEnumUnit() is working perfectly, everything else is not.
Make sure the hashtable you reference is actually created, afterall null can not store values (make sure you initialize a hashtable to the global).
Also make sure the recall makes sense of the values (they are the same type as was attached and in the same indexes).
 
Level 9
Joined
Aug 21, 2008
Messages
533
no its not empty it is filled with a other trigger...

as long the other trigger doesnt fire this trigger doesnt do anything, after the other one fired this lione suddenly is working:
DisplayTextToForce( GetPlayersAll(), "Work")
But not the FIRST one! which is the most important one

JASS:
function Trig_Balls_Conditions takes nothing returns boolean
    if ( GetSpellAbilityId() == 'A000' ) then
        return true
    endif
    return false
endfunction

function Trig_Balls_Actions takes nothing returns nothing
    //variables
        local unit u = GetTriggerUnit()
        local location l = GetSpellTargetLoc()
        local unit u2 = CreateUnitAtLoc(GetOwningPlayer(u),'h000',l,0)
        local real array r
        local real rx
        local real ry
        local real rr
        set r[0] = GetUnitX(u)
        set r[1] = GetUnitY(u)
        set r[2] = GetUnitX(u2)
        set r[3] = GetUnitY(u2)
        set rx = r[2]-r[0]
        set ry = r[3]-r[1]
        set rr = SquareRoot(rx*rx+ry*ry)
        set rx = rx/rr
        set ry = ry/rr
    //code
        call SetUnitX (u2,r[0])
        call SetUnitY (u2,r[1])
        call SetUnitX (u2,r[0]+rx*500)
        call SetUnitY (u2,r[1]+ry*500)
        call GroupAddUnit(udg_misslegroup,u2)
        call SaveReal( udg_hashTable, GetHandleId(u2), StringHash("X"),rx*3)
        call SaveReal( udg_hashTable, GetHandleId(u2), StringHash("Y"),ry*3)
        call SaveReal( udg_hashTable, GetHandleId(u2), StringHash("t"),2.1)
    //leaks
        call RemoveLocation(l)
        set u= null
        set u2= null
        set l = null
endfunction

//===========================================================================
function InitTrig_Balls takes nothing returns nothing
    set gg_trg_Balls = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Balls, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Balls, Condition( function Trig_Balls_Conditions ) )
    call TriggerAddAction( gg_trg_Balls, function Trig_Balls_Actions )
endfunction

This is the other trigger
 
Level 9
Joined
Aug 21, 2008
Messages
533
JASS:
function Trig_Hash_Actions takes nothing returns nothing
    call InitHashtableBJ(  )
    set udg_hashTable = GetLastCreatedHashtableBJ()
endfunction

//===========================================================================
function InitTrig_Hash takes nothing returns nothing
    set gg_trg_Hash = CreateTrigger(  )
    call TriggerAddAction( gg_trg_Hash, function Trig_Hash_Actions )
endfunction
thats my hasch init trigger
 
Status
Not open for further replies.
Top