• 🏆 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!
  • ✅ The POLL for Hive's Texturing Contest #33 is OPEN! Vote for the TOP 3 SKINS! 🔗Click here to cast your vote!

[Solved] Reference of a dead unit.

Status
Not open for further replies.
Level 20
Joined
May 16, 2012
Messages
635
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 20
Joined
May 16, 2012
Messages
635
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