• 🏆 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!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

One unit in multiple unit groups? Having an issue with groups

Status
Not open for further replies.
Level 6
Joined
Jun 14, 2008
Messages
176
Is it possible for one unit to be in multiple unit groups? If so, any exceptions ?

Does having a unit group variable "Set Unit Group Variable - Units in region" (for example) remove the affected unit from any other unit groups?

I have two problems:
1. Currently I have a trigger:
Event - Unit dies(I need the trigger to add the dead unit to the global group) > Action - Add triggering unit (dying unit) to [Global Unit Group 1]. (Yes I made sure the variable is a global group variable).

I also added an action which displays the number of units in the group every ime a unit dies so I know how many are in the group (that's how I can tell that there's an issue with the unit group)

Though for some reason the unit group keeps getting "reset", it never manages to get past 1 (well it does sometimes but then it gets reset back to 1). It seems every time the trigger runs, the unit group gets emptied.

I thought it may be because I had another trigger (which ran periodically) which set all units owned by the player to a unit group but I disabled it and the problem still occurs. Any other ideas?

2. I also had another weird issue with unit groups: I had a trigger which had a unit group in another unit group, example -

Set Unit Group 1 - Units in region.
Pick each unit in [Unit Group 1] and do actions:
--Set Unit Group 2 - Units in region (example).
--Pick each unit in [Unit Group 2] and do actions:

In this example of a trigger I had, the unit group stopped "looping"(which seems to be the case for SC2's unit groups as opposed to WC3), it only worked the first time then stopped after the the second unit group was being used.

Is this intended? Any explanation to why that happens?

Anyway any help, info, and/or explanations regarding Unit Groups and my issues with them will be appreciated, thanks.
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,199
1. Its cause dead units are removed (to free up memory). As such the units you add to the group stop existing shortly after being added to the group and so only a few units may ever exist in it at any time. If you want to reuse dead units, you will need to make them permant (so they become paused when dead instead of destroyed). If you want to count how many units die, use an integer and simply incriment (add to it) every time a unit dies.

Problem 2 is probably caused by the way the engine handles enums through groups. It may not permit nested enums of the same type for example. Eithor that or the groups you are using get damage in some way.
 
Level 6
Joined
Jun 14, 2008
Messages
176
Thanks for the reply :).

As for my reason for wanting to store dead units in a unit group - I made a revive ability, it works when I use "Unit > Stats (Tab) > Death Time" and set it above 0 (how long until the unit is removed from the game after dying).

However the problem is that:

1. Dead units block structures, you can't build on top of dead units.

2. Also some actors (like say any buff model for example) or abilities (channeling for example) linger on dead units (this can be fixed by validating the actor or ability to check if the unit is alive but I'd like to find a way to skip that hassle of doing it on all actors and channeling abilities).

So I'm trying to find an alternative to this, the goal of storing dead units in a unit group was to store their unit type and point so I can "revive" them later (by creating a unit of the same type at the same point).

Is there anyway to:

1. Allow structures to be built on dead units (or any unit with a behavior change for that matter)? I tried "Suppress Collision" but this affects only collision with units and not structures.

There does not seem to be a way to individually modify "Unit > Movement (Tab)" > Collide settings (it's possibly by using upgrades but that affects all the units owned by the player at once unfortunately).

OR

2. Store a dead unit's unit type and position without having to pause or use "Death Time" (since doing either of those causes the issues mentioned above)?
 
A way to bypass all of these issues is again solved with global variables.



Event -> Marine (unit type) dies
Condition ->
Action -> Set (variable) <marines dead> (current value of <marines dead> + 1)


Event -> _________
Condition ->
Event -> Create (variable) <marines dead> marines for player _ _______
-> Set (variable) <marines dead> (0)
 
Yes, in my triggers the idea would be to set the variable to 0.
If my understanding is sound, he wants to revive units for a player.
That means that if 3 units die in a fight, I want to revive the 3, not the 4 from the last fight that I've already revived, plus the 7 before that, all of which have already been revived.
By clearing the variable when you cast revive, you only revive the units that have died since the last time you cast revive.
 
Status
Not open for further replies.
Top