Unable to add units to unit group

Xan_Kriegor

I can change this now in User CP.
Reaction score
12
In one of my triggers I (attempt to) add a unit to a unit group. Immediately after (next line in trigger) I do an integer comparison to see if the unit group is empty or not, and it always returns empty. Not only this, but I have debug text to make sure I'm referring to the unit correctly (spits out the Picked Unit's name) that properly displays the unit's name so I know it picked the right unit.
Trigger:
  • Actions
    • Unit Group - Pick every unit in (Units within 100.00 of Point matching ((Owner of (Matching unit)) Equal to Neutral Passive)) and do (Actions)
    • Loop - Actions
    • Unit Group - Add (Picked unit) to ugTemp
    • Game - Display to (All players) the text: (Picked unit - + (Name of (Picked unit)))
    • Unit Group - Pick every unit in ugTemp and do (Actions)
    • Loop - Actions
    • Game - Display to (All players) the text: (Name of (Picked unit))

There's the snippet in my trigger. The unit is owned by Neutral Passive so that's not the issue. When this trigger runs I only get one message, the one from the first loop. For the record, there are no DestroyGroup calls made in this trigger preceding the snippet.

Anyone know what would lock a unit group from having more units added?
 

Accname

2D-Graphics enthusiast
Reaction score
1,462
Only if the group was destroyed at some point.
A unit group that was destroyed can not have any units added to it. In any other case units can always be added.

So either you assume the unit was not destroyed but it actually was without your knowing or strange voodoo magic is happening and you have to sacrifice your first born child to the dark goddess kali to fix your issue.
 

Accname

2D-Graphics enthusiast
Reaction score
1,462
Not important, unit groups are initialized on map initialization.

But you could, of course, test if your unit group is destroyed by simply creating it at the start of the trigger. If everything is now magically working then you can be assured that the unit group was destroyed somewhere.
 

Xan_Kriegor

I can change this now in User CP.
Reaction score
12
A unit group that was destroyed can not have any units added to it. In any other case units can always be added.

Alright, that's my issue. But now I'm curious because I've already destroyed and reused the same group a few times before this trigger runs and the previous triggers work fine: I can't add units to the destroyed group but I can set it to a new group and it will work fine after that, correct?

Thanks a bunch guys!
 

Accname

2D-Graphics enthusiast
Reaction score
1,462
Whenever you set a unit group you will create a new one.
But when you attempt to add / remove to / from the group the same group will be reused.
That is why you are supposed to destroy a unit group before you use the "set unit group" command in order to avoid memory leaks.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top