Author Topic: Formations - how I think they could work  (Read 1404 times)

Mr War

  • Guest
Formations - how I think they could work
« on: 10 December 2011, 09:15:53 »
Glest / MG is not really suited to formations of troops - the pathfinding, rendering of each unit individually and current maps don't suit it.

BUT... for historical mods like Japanese and Ming it'd be very cool to form your troops up. Frankly it'd look cool. However, it'd have to be limited formation capability.

My suggestion is to make it so that you can form formations, but not march in formation etc. They are just neatly aligned static placements of units.

The formations could be listed in a specific XML in the Faction folder - no XML, no formations. That way each mod could create it's own formations, or borrow from others. Formations would be described as cell-maps like buildings, but with specified depth and width. Eg:
111111
000000
111111
= two rows of 6 units with a gap in between. You can formate any moving piece but if unit size is greater than 1 then they will take up more than one cell etc.

In-game, I think you'd select the units and click a hotkey, and a list of formation icons (again modder defined) would appear where action buttons normally do. 64x64 BMP/PNG etc:


Pick the formation, and click on the map where to center it. Each formation has a front (first row of cell-map) so orientation buttons appear. or rotation hotkey. But only 8 directions (eg every 45 degrees). logic here is similar to placing buildings:


Pick your direction and the troops now use regular pathfinding to get into place - any troops in excess of slots are left behind. Fill-order is front left to bottom right or whatever.


The units then all face direction of formation. If the user wants them to HOLD they need to do this as a separate action in the normal way.

Cool idea or dumb?

TotalNoob

  • Guest
Re: Formations - how I think they could work
« Reply #1 on: 10 December 2011, 17:06:17 »
Well this idea does not describe how to behave in a large set of situations (like what if some units are bigger than others or what if there is an obstacle in a place where you want to send a unit). But it is a good start I think. One thing from me: making formation with a limited number of units is not nice. Maybe instead of defining a strict way of how formation should look like, it should be a definition of repeatable outline. Thanks to that we will use all units from the selected group. For example for a two line formation from your example XML definition would be like this:

x
0
x

we assume that repetition goes always right. For loose formation (like this one):

1010101010
0000000000
1010101010

its definition would be like this:

x0
00
x0

To make it more clear how we build the formation from the outline:

stage 1:
x0
00
x0

stage 2:
10
00
10

stage 3:
10x0
0000
10x0

stage 4:
1010
0000
1010

...and so on as long as we got units to deal with.

will

  • Golem
  • ******
  • Posts: 783
    • View Profile
Re: Formations - how I think they could work
« Reply #2 on: 10 December 2011, 17:25:38 »
In Glest, units are aligned on a grid.

When you select more than one unit and then click on a destination, they each try to actually go to the exact destination tile.  Obviously one of them will win this race, and the others will all get as close as they can until their way is blocked.  So they end up in a tight bunch.

A 'poor mans' formations that might be relatively straightforward to add to glest is, when selecting more than unit and holding down a new 'formation' key as clicking on the destination, you are telling the units to form the same shape as they currently are in but with that shape centred on the destination.  That is, if you have managed to get 4 units in a nice line, then clicking on a destination with the 'formation' key pressed will get them to go to that spot and be in the same line as they started with.  As a finesse, when you release the formation key but still have the mouse button down, you might be orientating the destination (it can be nicely highlighted on the map) so you can ensure they are facing the right way.

Of course each unit is still plotting their own path to the destination, and they might not reach their destination at the same time nor maintain the formation as they march.

And if they aren't in some defensive mode they'll break-rank when engaging.

John.d.h

  • Moderator
  • Airship
  • ********
  • Posts: 3,757
  • I have to go now. My planet needs me.
    • View Profile
Re: Formations - how I think they could work
« Reply #3 on: 10 December 2011, 18:29:01 »
For marching in formation, would a simple way be to give each unit's destination the same offset as they have from the center of the formation?  I.E., if the unit is two tiles to the left and one tile to the front, then the unit's destination will be +2 to the left and +1 to the front.

will

  • Golem
  • ******
  • Posts: 783
    • View Profile
Re: Formations - how I think they could work
« Reply #4 on: 10 December 2011, 23:28:48 »
For marching in formation, would a simple way be to give each unit's destination the same offset as they have from the center of the formation?  I.E., if the unit is two tiles to the left and one tile to the front, then the unit's destination will be +2 to the left and +1 to the front.

Yes the offset was what I was meaning in my 'poor man's' approach

They would likely march in formation if all have the same speed and there is no obstacles nor turns and so on.  So basically, I think they'd likely keep some semblance of formation when doing basic movement but it might look a bit wonky more often than not.

Omega

  • MegaGlest Team
  • Dragon
  • ********
  • Posts: 6,167
  • Professional bug writer
    • View Profile
    • Personal site
Re: Formations - how I think they could work
« Reply #5 on: 11 December 2011, 04:10:14 »
I can think of some potential issues that would have to be dealt with:

-Larger than size 1 units: they'd totally mess up any formation by the proposed system.

-When units from different fields are selected: What happens if you have an air and a land unit? Or a land and a future-water unit?

-If they have to be faction defined and no XML defining formations means no formations period, isn't that pretty restrictive? Why not a default set of formations?

And my personal opinion:
I'd prefer to see formations being a generic shape that units would arrange to, rather than being some specific outline where there must be a specific number of units. If I recall correctly, AoE2 had a strong formations system like I have in mind. So having four units arrange in a "line" formation could work, so could having 20. I don't see how the concept of defining the layout in an XML would be able to expand when more or less units are selected, and Extrapolation doesn't work.

Now, I haven't played AoE2 for a long time, but if I recall correctly, formations were generated "on the fly". So if you had units scattered around, selected them, and told them to use a rectangular formation, they'd move together to get into that formation. As well, units weren't "stuck" in a particular spot in the formation, but moved around when necessary (eg, trying to fit a 3x4 rectangle in a 2 cell-wide aisle won't work without adapting). Units with less health tried to stay towards the center, so as to keep vulnerable units safe. The AoE2 method of formations would solve the issues of large units, be familiar to gamers, and be friendlier to differing numbers of units.

In AoE2, the formations were:[More info]
  • Line: A solid rectangle.
  • Staggered: Rectangular, but spread out.
  • Box: Melee units made a box around ranged and healing units.
  • Flank: Divides the units into two even groups which try to surround the foe.

To sum that up, formations would just be a few generic shapes the units would have to form, and would not be modder defined. Sure, that's less customizible, but it would adapt better for all mods in general, and perhaps more importantly, work.

However, modders could optionally define the "type" of a unit. Ideally, this would be done with a tag (from GAE). Then we could use tags to define if a unit is supposed to be melee, ranged, cavalry, or "vulnerable" (a vulnerable unit would be one like a dedicated healer, where they should generally be protected in formations. If those tags were not defined, the engine would try and determine that itself (larger than size one units with greater than average health would be cavalry (eg, horsemen, tanks), units with a melee attack would be melee (eg, guards, battle machines), units with a ranged attack would be ranged (eg, archers, gunmen), and units with no attacks, or that have a repair skill and a considerably weaker than average attack would be "vulnerable" (eg, workers, healers).
« Last Edit: 18 June 2016, 17:29:29 by filux »
Edit the MegaGlest wiki: http://docs.megaglest.org/

My personal projects: http://github.com/KatrinaHoffert

softcoder

  • MegaGlest Team
  • Battle Machine
  • ********
  • Posts: 2,239
    • View Profile
Re: Formations - how I think they could work
« Reply #6 on: 11 December 2011, 07:28:34 »
I actually DO have code to do something like this but disabled it because it was causing out of synch's for network play (likely due to the way i implemented it). I'll try to take another look to see how to get it working again without making problems.

Mr War

  • Guest
Re: Formations - how I think they could work
« Reply #7 on: 11 December 2011, 15:39:31 »
Interesting stuff.

Will, if I understand u right, moving "in formation" is easier than forming the formation in the first place?

Omega

  • MegaGlest Team
  • Dragon
  • ********
  • Posts: 6,167
  • Professional bug writer
    • View Profile
    • Personal site
Re: Formations - how I think they could work
« Reply #8 on: 12 December 2011, 02:34:04 »
Interesting stuff.

Will, if I understand u right, moving "in formation" is easier than forming the formation in the first place?
Except turns and obstacles in the way could be tricky.
Edit the MegaGlest wiki: http://docs.megaglest.org/

My personal projects: http://github.com/KatrinaHoffert

 

anything