Game Development Community

Un-selecting certain units from a group

by Chris Jones-Gill · in RTS Starter Kit · 11/17/2004 (7:56 am) · 1 replies

Ok this'll be a good one I think that most people may want, but I am a bit stuck, so need some pointers unless someone else is working on the same thing.
working with the default units in the demo.

When you select all the units and the unit command menu pops up with the different types of soldiers grouped - you know what I mean.
Wouldn't it be cool to say click on one of the profile images and that profileType in the selection, the total is reduced by 1 or that type of soldiers is dropped altogther from that group or selection?

What I have done is to turn the Profile images into buttons in the gui and created a basic commandaction like the commandMenu does, (currently it just fires some text to say "I clicked here")

what I cannot figure out is how to get the name of the unit (maybe not the best way) or the GhostID for that unit in the profilegui, so I can then pass it to a new function in the groupManager.cs / selection.cs to deslect that unit and if the original selection is / has been asigned a group number, to adjust that group acordingly

appriciate any pointers

#1
11/21/2004 (3:05 pm)
As I recall, the selection gui is generated from the selection SimSet. So there's no one-to-one mapping between buttons and units. You have two cases to deal with - either the buttons are representing single units (the case if there are fewer than six or so units) or unit types. If the former, then when you click I'd have it select the unit the button is representing. If the latter, then I'd have it change the selection to consist solely of units of that type.

You can do the former by clear()ing the SimSet, and the latter by iterating over it and removing everything of the wrong datablock. (getDatablock() and removeObject()).

Hope this helps!