• Check out the results of the Techtree Contest #19!
  • 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.
  • Create a void inspired texture for Warcraft 3 and enter Hive's 34th Texturing Contest: Void! Click here to enter!
  • The Hive's 22nd Icon Contest: Creep Abilities is now concluded, time to vote for your favourite set of icons! Click here to vote!

[Solved] Dead units in unit group get removed automatically now?

Level 2
Joined
Dec 15, 2023
Messages
4
I read about how people were trying to remove dead units from unit groups via triggers.

When I was testing, it appears that decaying units are still part of the unit group, however, when completely decayed or the corpse get messed with (reanimate, raise dead, ..), the unit will get removed from the unit group automatically. Practically, whenever there is no corpse (e.g. flying unit), then unit will get removed from unit group.
And with removed I mean it won't count against unit count and cannot be referred to by triggers (no idea about JASS and leaks).

Has this been changed recently? Can anyone confirm this observation?
Is there any way to keep those bodiless units in the unit group?
 
Last edited:
A decayed unit is officially removed from the game, and as far I know there's no longer a concept of their existence.

When you remove a unit from the game manually:
  • Unit - Remove (Some unit) from the game
The unit can still be referenced until the end of the frame because it's actually "marked for removal" as opposed to being removed immediately. But after that it no longer exists.


What I believe you're seeing in your Unit count function is that it skips null references, so it's only incrementing the counter if the unit it's looking at is valid.

In other words:
You have 5 units in a Unit Group, 2 of which have decayed. You then use the "Get number of units in unit group" function.

The function loops from 1 to 5 doing the following Action:
If (Picked unit) is valid then Increment counter by 1

The final result will be 3, since the counter skipped the two invalid (null) units. But those two units are still in the group as memory leaks and can cause potential harm since you'll likely be using them as arguments in other functions.

Understand that Warcraft 3 is designed to avoid errors/null reference exceptions, meaning it'll do a great job at preventing things from breaking when you tell it to do something "impossible". This "safety net" could be misleading you into thinking that the units were removed automatically when they were really just ignored.

Anyway, if you don't notice any issues then you probably shouldn't worry about it. It's just something to keep in the back of your mind for when/if you experience performance issues (memory leaks) or weird bugs down the line.
 
Last edited:
Thanks, I get it.
It sounds like you get it but I just want to be 100% clear.

Dead units remain in unit group
Yes, both Dead and Removed units will remain in a Unit Group.

But remember that a Dead unit and a Removed unit are two different things.

Dead units are meant to remain in Unit Groups so that you can continue to interact with them. This allows you to create triggers that work like Resurrect, Cannibalize, Raise Dead, etc.

Removed units are NOT meant to remain in Unit Groups but they do. It's a problem that you might need to fix.

A Dead unit becomes a Removed unit once it fully decays.

(which may cause leaks)
A Dead unit in a Unit Group does NOT cause a leak.
A Removed unit in a Unit Group does cause a leak.

but do not interfere with editor triggers/functions.
Not exactly. Both Dead and Removed units interact and interfere with triggers/functions differently. It all depends on the functions used.

For example, I assume that a Removed unit is always considered "Is Dead" when you check it in your Conditions.
  • Conditions
    • ((Your unit) is Dead) Equal to True
This would happen because the function that tells you whether "Dead = True/False" defaults to False if the unit no longer exists.
 
Last edited:
I guess with dead dead I meant fully decayed or no corpse (flying unit).

Out of curiosity:
Is there any confirmed meaningful interaction of removed units in a unit group with editor functions that yields a non-default result?
I mean you cannot count it, you cannot ask it for its name, so my assumption is that wc3 will just provide default responses for functions that try to target removed units due to said robustness.
 
Out of curiosity:
Is there any confirmed meaningful interaction of removed units in a unit group with editor functions that yields a non-default result?
I mean you cannot count it, you cannot ask it for its name, so my assumption is that wc3 will just provide default responses for functions that try to target removed units due to said robustness.
I can't think of any non-default results, and yes, your assumption is correct. Although, I'm sure that there's rare cases where the game can crash.

Here's an example of when the the removed units would cause a problem:
  • Unit Group - Pick every unit in MyGroup and do (Actions)
    • Loop - Actions
      • Special Effect - Create a Special Effect at (Position of (Picked unit)) using ...
This loop would create a Special Effect at the (0,0,0) coordinates for any removed units that it encounters. This happens because the default for a null Point is the center of the map and the Point will be null because it can't get the position of something that doesn't exist. So the end result will be a bunch of unwanted special effects appearing in the center of the map.

These are the types of issues to be aware of, but there's always the possibility that you're using the Unit Group in a way that doesn't cause issues.
 
Last edited:
Back
Top