Sign in to follow this  
EvilProgrammer

RTS: Who keeps track of selection?

Recommended Posts

EvilProgrammer    122
It seems to me that in an RTS the player should have a list of all selected units, rather than having each individual unit know whether or not it is selected. Reasoning: For one thing, a unit may be selected by more than one player. Most RTS's support the ability for the player to select an enemy unit (for information, not to issue commands). Furthermore, when issuing commands, updating information about selected units on the HUD, etc., it is not necessary to go through all the units to find out which ones are selected. Also if a unit dies, it merely needs to send a message back to the player saying so, or else the player can just check each frame to make sure all selected units are still alive. With this being the case, it would seem there is no need at all for a unit to even know if it is selected. The reason I bring this up is because I remember running into a number of sources in the past that all supported the "each unit keeps track" idea, but I can't remember why. Is this just a matter of style or is there a specific reason why one way is better?

Share this post


Link to post
Share on other sites
Fruny    1658
Selection is entirely a client-side issue, so it doesn't matter that a unit might be selected by multiple players. The other players don't need to know what units you got selected.

[Edited by - Fruny on October 15, 2004 2:44:03 AM]

Share this post


Link to post
Share on other sites
Mr_Ridd    130
Hey

If I was making an RTS I think I would go for the Player knows what is selected, not the unit. I think to do that you would have to store an array of indexs. In terms of processing, I think it would be a much of a muchness, whether you are running through your unit loop to check if the indexs match or running through the unit loop to see if it selected. The reason why I would go for the "Player Knows" way is so that each indivdual unit doesn't have to store extra data about how it was selcted, info, player, ally etc.

Actually thinking about it, I think it would be faster the "Player Knows" way. If it's the "Unit Knows" way, you'll have to do a check so see if it is seleted, and then do another check to get the selection type.

Share this post


Link to post
Share on other sites
bmarci    786
Quote:
If I was making an RTS I think I would go for the Player knows what is selected, not the unit. I think to do that you would have to store an array of indexs.

I'd suggest to store the unit pointers instead of indices. It needs less "management" when the unit list changes (eg: somebody dies..ect) But still has the disadvantage of you have to keep track of the selected units, in case of death and when they are transported into ships, or if they simply become invisible, you need to update the selection list all the time.
An other point: you should keep track of the kind of the units are in the selection. At some point you'll need to decide whether the selection is a "military" or "neutral" or "siege"...etc. It helps when you wanna display the unit commands. Handling the formation depending on the unit kind (cavalry in the first row, the catapults at the back) is an other story :)

Share this post


Link to post
Share on other sites
Stru    118
Quote:
Original post by Fruny
Selection is entirely a client-side issue, so it doesn't matter that a unit might be selected by multiple players. The other players don't need to know what units you got selected.


Not true. If you are doing a multiplayer RTS where the game is synchronized across multiple computers (like how Starcraft, Warcraft, etc. work) then when networking its best to send unit selection information to all players. This will result in less overall network traffic because when you give the units you have selected orders it is only one order sent to all players. Otherwise you have to send one order per unit you have selected. With 12 units thats 12 times as much data being sent every time you give orders to a large group. And I know for a fact that in Warcraft 3 unit selection information is sent by all players (allies and enemies) over the network.

However, I think that the unit also needs be aware of the fact that it is selected for the purpose of displaying a selection circle and/or healthbar.

Of course, if its not multiplayer then it doesn't really matter how you do it.

Share this post


Link to post
Share on other sites
KnightBlade    218
Quote:
Original post by Stru

However, I think that the unit also needs be aware of the fact that it is selected for the purpose of displaying a selection circle and/or healthbar.


Hmm, you can still have a separate function that draws the selection and healthbar using just a list of selected units.

Also, you can denote one unit as a 'leader' unit (which does not even have to be an actual leader in the game world), and have all the other selected units inherit commands from him. So when issued a move order to the selected group, we just need to make the leader move. Then when we are updating the other units' game state, we just have to see if we are selected (use a bool, check against selected list), and then see who the leader unit of that list is, and then inherit orders from him.

The leader unit doesn't even have to exist in the game world, it could be just a dummy unit that is created when a group is seleted, and destroyed when the group is no more.

Share this post


Link to post
Share on other sites
Krylloan    142
Player Knows:
Allows a unit to be in multiple groups, such as "the selection group" and "group 7 which is selected by pressing 7".

I think it is best to have a group-class, and make the selection group just an instance of this class.



Unit Knows:
If you've ever played Total Annihilation you might remember that some of the interface ideas were well ahead of their time. Such as the idea that you can group a structure and have all units that come out of that structure automatically put into that group.

If a building knows what group it is in, it can automatically add all units that it builds to the group.


When I get to this point in my game I plan on using both unit knows and player knows so as to have all the efficiency of the former and the flexibility of the latter.

Share this post


Link to post
Share on other sites
_Phalanx_    180
this is a bit of a tangeant, but why do some rts's limit the amount of selectable units?

this was particularity annoying in starcraft and horrible in wc1 (one unit)

Share this post


Link to post
Share on other sites
EvilProgrammer    122
I'm not sure, but it's a very good question. I know that in war3, the decision to limit unit selection to 12 was a very deliberate one. I believe they thought the efficiency of the groups was diminished once the number of units in the group became very large, so they put that limit on it.

Other games, for example, Empire Earth, Homeworld, etc. allow you to select as many units at a time as you want. But if you select and move 80 units, they will group into a formation that will stretch for miles. This is often not very efficient. I guess the developers decided not to force that kind of efficiency on the player. I'm thinking at Blizzard they realized that for their type of game the unit group pathing AI would really suck with tons of units or something, I don't know.

Share this post


Link to post
Share on other sites
Krylloan    142
Another possible reason for blizzard's annoying limit is that they wanted to keep their selected units bar static and not have to scale or remove some selected units from the bar.

Or possibly they just wanted to benefit players that were able to press hotkeys and click faster than others.

Either way, if you ever decide to limit selection size, just know that a large number of your players will curse your decision.

Share this post


Link to post
Share on other sites
Pipo DeClown    804
Selecting should COMPLETELY be own-clientside. So if one unit is selected by another user, nothing is different, it just seems like it's computer-controlled, it moves.

I'd make an offline selection and events system, that works with the network code, to send the final event to the server.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this