• 🏆 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!

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

Level 3
Joined
May 10, 2024
Messages
20
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?
 

Uncle

Warcraft Moderator
Level 68
Joined
Aug 10, 2018
Messages
7,109
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
 
Top