Very helpful as always Mirathei!
Not exactly formation scripts but I was wondering (given that its a battlefield tactics kit in general) if it were possible to set up a system for translating world map context into battlefield starting orders and position.
For example, currently in Native, if on the world map I have 40 Khergit Horse Archers and attack 30 Mountain Bandits, who are "Running Away From Player", I get the 'cowardly' dialogue (i.e. "Eh? What do you want") from the Mountain Bandits and then I go to lead_charge. Now, despite the cowardly behaviour on the world map, the Mountain Bandits still charge my horse archers in a suicidal manner on the battlefield. This is of course stupid and makes things predictable.
So an alternative system: There are two factors at work on the world map of relevance, these are relative speeds of the parties (e.g. Khergit Horsemen are faster than Peasants) and the differing attitudes of the parties (generally one party is fleeing, and/or another party is attacking). Relevant battlefield properties associated with this are to my mind, starting location(s) and default AI orders (Hold, Charge etc.)
The logic of this system would be to as said, translate these properties from world map to battlefield. So (forgive the crude pseudocode):
Strength:
IF ai_party_attitude == attack_player_on_world_map AND ai_party_speed <= player_party_speed THEN
Both parties spawn at opposite edges of field
AI starting orders Charging, Player is Holding
IF ai_party_attitude == attack_player_on_world_map AND ai_party_speed > player_party_speed THEN
Player spawns in CENTRE of battlefield
AI spawns on two opposite edges of battlefield
AI starting orders Charging, Player is Holding
IF ai_party_attitude == flee_player AND ai_party_speed <= player_party_speed THEN
AI spawns in CENTRE of battlefield
Player spawns on one edge of battlefield
AI starting orders Holding, Player is charging
IF ai_party_attitude == flee_player AND ai_party_speed > player_party_speed THEN
Both spawn on two opposite edges of battlefield
AI starting orders Holding, Player is charging
NB: Mounted skirmishers would always charge.
The effect of this would be more intelligent battles, hopefully. For example, if your 20 pikemen are attacked on the world map by a party of 20 Swadian Knights and 25 Footmen, then you would start the battle in the centre of the field, in a pincer movement caught between the two enemy troops (knights on one side, footmen on the other)
The major snag with the formations I guess would be if there was only one type of unit (e.g 20 pikemen versus 40 horsemen) on each side - the pincer movement would be difficult to keep together as the two units spawned on each side of the battlefield would try to get into one formation at the start of the battle, though you could add some logic checks to disable this I guess.
I'm not sure how feasible it is, just putting it out there. Even a simple system of the AI holding by default if running away on world map would be an improvement. Of course it would be even better if AI units adopted tactics and formations appropriately depending on the tactical situation on the battlefield.
Oh yeah, finally re the formations and morale:
1) Possibly better keys for the formation orders would be: G for "Wedge", N for "Line", K for "Ranks" (as is), and F9 (Spread out) for "Formation Disassemble". G and N are phonetically better when the player thinks of the worlds "line" and "wedge". Spread Out and Formation Disassemble are functionally very similar orders. Unless you've got future plans for spread out and stand closer..
2) I noticed that there are no logic checks for the "your enemies/your troops are wavering" and "your enemies/troops flee in terror" messages appearing when there are e.g. no more of your troops on the battlefield, from Chel's morale system. Maybe hes adding them himself later and youre waiting for him, just thought I'd note it.
3) Would be great to have a circular formation as well, for infantry. This was a commonly used formation by the Romans and the Saxons, albeit purely defensively. Would be nice to have.
In any case this is great work and you've basically completely revolutionized the native AI and made the developers look rather feeble, so thanks for all your efforts!
