RTS Unit Organization: Formation System
I am currently writing the code for the formation system in my RTS game. It utilizes the standard movement command to move all the units in a squad, or higher order unit grouping, to a specific offset from the leader. I have a few questions about preferences and implementation.
Currently in my idea you can define premade formations for a given leader unit type in XML. You assign the offets and name the formation and the unit type will have a button to organize your forces that way. I will ask some questions first and then some problems I have foreseen.
What is the best way to determine position? I could merely allow you to assign a series of offsets. The problem here is how to choose what unit goes where. Ideally ranged and support units would need to go towards the back. If you have one set of offsets and one button the player would have to add units in the proper order if you tried to specify special offsets for support.
My second plan was to assign special offset vectors for each unit class. So you would have one for melee and one for range. You could further subdivide, optionally of course, and have a first row, second row, and third row of melee, and then a row for archers and one for healers and mages or other support units.
I know that Kohan had some formation work, but it was quite hard coded. You always had the same formation layout and it never really went above the first level.
Now I really wanted the system to be customizable. There is no hard limit on the number of units in a squad, or the squads in a century and so forth for cohorts, legions, and finally hosts. So I have to figure out how to deal with people who put more than 10 units in a squad for instance. Most default formations will allow for the leader and 9 other units.
There are free form formations, basically a vector with up to a leader and 100 units in a squad, a leader plus 25 squads in the century and so forth. Basically the idea is that you have enough space in a group to go all the way up to the next level. After you get to 100 units in a squad you are at the level of a century. And when you have 25 squads in century you are up to a cohort so why keep overloading a century? And so forth down the line. At the host level its not really a vector of hosts so you have no cap. So you are pretty much free to organize your armies how you like.
But how do I get default formations to deal with overloaded squads? I guess you could have an overflow like if all your melee rows are full start stacking units on the outside of the first rows. Or stick them in a new automatic row in front of previous front rows.
The problem with the free form system is you have to assign the positions in game. Essentially put all units in there spot and then hit a button. And of course your unit can only remember a few specialty formations, well not technically but just the amount of time to set it up especially for larger selections of units.
So does anyone have opinions on the best way to set up the non-free form formations? Or any thoughts in general about units moving in formations? This thread is mostly about implementing formations, I will have probably have another one discussing the strategical and tactical implementations.