Okay, so in one of the long tutorials, they kind of glanced over object groups, so I figured I would cover them more in detail because they are a beautiful thing and they make life so much easier. This is on my list of things I new before I started making my first map.
How are Object Groups Going Help Me?
Object Groups are a great way to manage units you already have placed on your map. When it comes to working with triggers, which I'll show you later, the Object Groups get saved as variables, so you don't have to try and find some clever way to add units to a unit group and try to recall that value later with a data table. While the general term for what we're working with is "Object Group" when we're handling units we're actually dealing with Unit Groups.
Making your first Object Group
A lot of people like to create a new map, usually with the default Agria settings to demonstrate what they're talking about, I'm going to use my current map in progress.
The first thing you need to do is select the units one you map that you want to create an Object Group out of. Once you have a few of them selected, you can either go do Edit in the menu bar and then select Merge Selected or you can just hit Numpad 0. Because I have different plans for these units here, I'm going to select what I call my robots and use Numpad 0 to make them into an Object Group
If you're not happy with the units you selected you can delete the Unit Group by selecting one of the units, which will select them all and then going to Edit in the menu and selecting Split Selected or by pressing Ctrl + Numpad 0. While it might be called "Split Selected" it should really be called "Destroy Selected" as it completely destroys the unit group. It's the same thing with "Merge Selected" it actually creates a new Unit Group rather than adding the selected units to the Unit Group of other selected units.
Lets take a loot at how we can actually add or remove individual units to and from the group without having to nuke the whole thing.
Managing Your First Object Group
After that, you want to go to Map and select Object Groups... or hit Alt + A and then G to open up the Object Window.
Here you can see our new Unit Group. I'm going to make a couple more unit groups and start giving them names. Lets call the one we just made "White Robots"
These are the different fields that we have to play with when it comes to managing our Unit Group.
Group Name: Normally we can hit F2 to rename something like a trigger in the Galaxy Editor, unfortunately that doesn't work here and we actually have to go to the name field.
Icon: We can give our little Unit Group a cool little icon. I however have yet to find a use for this icon.
Loot: This field lets us bring up a menu in which we can select what loop the members of this Unit Group will drop. This allows us to handle loot in a more regional manner rather than based on the actual unit, like in the data editor. This does require; however, that you have set up loot because the only available loot is all test data.
Patrol Pathing: While this box has amazing prospects, because you can set up different points as patrol points, and even add wait timers for said points, I've yet to find a way to get the units to actually execute the path we set for them.
Units: This box is very important as it is the only way to manage the membership of your unit group without the use of triggers. Once you've merged your group together, to change what units are in the group you have to either use the red or green x under this box or right click and select add or remove unit.
Okay, now that we've gone over the functions in this window, lets see how we can plug these guys into a trigger. I'm going to make an empty unit group and name it White Zone before we head to the Trigger Manager.
Using Your Unit Group in a Trigger
Okay, for our first trigger, lets set it to kick off when the game starts and we'll skip right down to actions. We're going to use one of the actions I was recently introduced to, "for each Unit in Unit Group do Action." Since the Galaxy Editor is not consistent on what actions can be executed on groups versus single units, we have to use a trigger like this to get around actions that can only be done on a sole soldier. Basically we're doing an action on each and every unit in our group, one at a time.
If you click on the Unit Group variable hyperclick, and then click on Variable to take us to that tab, you'll see all of the Unit Groups that were in the Object Manager, including the empty one, and a count of the number of units that belong to each group. Lets select White Robots and then create another action to set the color of "Picked Unit" to White. Our next action is that we're going to combine all of the unit groups that reside in the White Zone into a single Unit Group, that way we can set triggers for the little Unit Groups or all of the units in that region at once.
This is what our final trigger looks like. What should happen is that all of the 'robots' that player 3 owns become colored white while their humans stay red, but an action can bet set to befall all of the units in that zone at the same time.
I hope you enjoyed the tutorial and I hope it makes handling Unit Groups in your triggers easier. If you see something I've missed, or would like me to expound upon something with a little more detail and/or a picture, let me know. Also, for those of you gurus that might be reading this, I would appreciate you adding to any deficiencies I may have had, such as if you've managed to actually find a use for the Icons or managed to get a Unit Group to follow through with the patrol set forth in the Patrol Pathing.