• 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.
  • The Hive's 22nd Icon Contest: Creep Abilities is now concluded, time to vote for your favourite set of icons! Click here to vote!
  • ✅ The POLL for Hive's Texturing Contest #34 is OPEN! Vote for the TOP 3 SKINS! 🔗Click here to cast your vote!
  • ✅ The POLL for Hive's Techtree Contest #20 is OPEN! Vote for the TOP 3 FACTIONS! 🔗Click here to cast your vote!

What happens with unit in array when its removed from the game?

Status
Not open for further replies.
Level 7
Joined
May 10, 2024
Messages
121
Hello!

I have an array of Units with initial value set to noUnit. I want to detect removed unit while iterating over array.

As far as I know unit can be removed by the engine after decay or by using Unit - Remove() function. Methods below is not working:

1. GUI unit comparison unitArray[unitIndex] equal to No Unit
2. JASS if udg_unitArray[udg_unitIndex] == null then

What happens to unit in array in such situations?
 
Hello!

I have an array of Units with initial value set to noUnit. I want to detect removed unit while iterating over array.

As far as I know unit can be removed by the engine after decay or by using Unit - Remove() function. Methods below is not working:

1. GUI unit comparison unitArray[unitIndex] equal to No Unit
2. JASS if udg_unitArray[udg_unitIndex] == null then

What happens to unit in array in such situations?
See Dr's last comment:

Either manually null the units at the time of decay/removing them or you can rely on something like this to detect a removed unit:
vJASS:
if GetUnitTypeId(yourUnit) == 0 then
 // It's been removed from the game
endif
 
Status
Not open for further replies.
Back
Top