I am creating a squad-based combat map and have only run into this one wall that I dont seem to get over.
Maybe there is somebody out there that knows the answer?
All I need is to be able to find the Unit Group of a specific unit. My unit groups are pre-determined when the map starts up and all have a region and variable attached to them. It seems so simple but I really cant find a clean, good way to do it.
This is an example of what I want to accomplish:
Unit Selection - Select (All units in (unit group of (Triggering unit)))
Sadly this example doesnt exist in the trigger editor, but If there is any way to do this that I haven't found yet, maybe by using "All units in (unit group matching condition)" or something similar, I need your help! This would spare my map hundreds of lines of codes.
Since a unit can be part of multiple unit groups at once you will have to work your way around for this.
If you saved your unit groups as an array, you could save the index of the group your unit belongs to as one of it's custom values when you add it to the group.
(add unit to group[i] -> set unit custom value 0 to i).
Then you can get the group of your unit back by group[Integer(custom value 0 of unit)] (needs real to integer conversion since custom values are saved as reals).
Oh, that should probably work, it's a bit of a workaround but its definitely better then anything else I had considered!
How could I forget about custom values..
Thanks for the response!
Rollback Post to RevisionRollBack
To post a comment, please login or register a new account.
I am creating a squad-based combat map and have only run into this one wall that I dont seem to get over. Maybe there is somebody out there that knows the answer?
All I need is to be able to find the Unit Group of a specific unit. My unit groups are pre-determined when the map starts up and all have a region and variable attached to them. It seems so simple but I really cant find a clean, good way to do it.
This is an example of what I want to accomplish:
Unit Selection - Select (All units in (unit group of (Triggering unit)))
Sadly this example doesnt exist in the trigger editor, but If there is any way to do this that I haven't found yet, maybe by using "All units in (unit group matching condition)" or something similar, I need your help! This would spare my map hundreds of lines of codes.
Thank you!
Since a unit can be part of multiple unit groups at once you will have to work your way around for this.
If you saved your unit groups as an array, you could save the index of the group your unit belongs to as one of it's custom values when you add it to the group.
(add unit to group[i] -> set unit custom value 0 to i).
Then you can get the group of your unit back by group[Integer(custom value 0 of unit)] (needs real to integer conversion since custom values are saved as reals).
Oh, that should probably work, it's a bit of a workaround but its definitely better then anything else I had considered! How could I forget about custom values..
Thanks for the response!