• 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.

[Solved] Reference of a dead unit.

Status
Not open for further replies.
Level 21
Joined
May 16, 2012
Messages
644
Hey, it's me again, so if i declare a local unit and set that local variable let's say
JASS:
v = GetTriggerUnit()
and that unit dies, my variable will keep the value of the unit or it will be nulled?

Exemple, This code:
JASS:
function Frozen_Sword_Actions takes nothing returns nothing
local unit u
local unit v
    set u = GetAttacker()
    set v = GetTriggerUnit()
    loop
        exitwhen v == null
            Some Code
        call TriggerSleepAction(1.0)
    endloop
    set u = null
endfunction
, It will eventually exit the loop when the unit dies or it will nerver exit the loop and keep running forever?
 
and that unit dies, my variable will keep the value of the unit or it will be nulled?
Unless you're storing the value periodically, it will still hold the value of the unit prior to its death. Regardless, a unit dying does not remove its reference. As far as I know, the only time a unit would ever return null is if they have been removed from the game.

It will eventually exit the loop when the unit dies or it will nerver exit the loop and keep running forever?
It will never exit the loop.

Keep in mind that a unit returning null and nulling a local are two different things. Agents, unlike handles, do not recycle the IDs given to them. Nulling the agents frees their given ID to be used by another.
 
Level 21
Joined
May 16, 2012
Messages
644
Unless you're storing the value periodically, it will still hold the value of the unit prior to its death. Regardless, a unit dying does not remove its reference. As far as I know, the only time a unit would ever return null is if they have been removed from the game.


It will never exit the loop.

Keep in mind that a unit returning null and nulling a local are two different things. Agents, unlike handles, do not recycle the IDs given to them. Nulling the agents frees their given ID to be used by another.
oh thx, i will simply use IsUnitAlive to exit the loop then.
 
Status
Not open for further replies.
Top