Multi unit formations?

Thalassicus

Bytes and Nibblers
Joined
Nov 9, 2005
Messages
11,057
Location
Texas
I'm experimenting with MultiUnitFormations.xml. For my first test I'd like to make the AI always escort its settlers with a military unit. I found these entries:
PHP:
<Row>
  <MultiUnitFormationType>MUFORMATION_SETTLER_ESCORT</MultiUnitFormationType>
  <PrimaryUnitType>UNITAI_SETTLE</PrimaryUnitType>
  <SecondaryUnitType>UNITAI_SETTLE</SecondaryUnitType>
  <MultiUnitPositionType>MUPOSITION_CIVILIAN_SUPPORT</MultiUnitPositionType>
  <RequiredSlot>true</RequiredSlot>
</Row>
<Row>
  <MultiUnitFormationType>MUFORMATION_SETTLER_ESCORT</MultiUnitFormationType>
  <PrimaryUnitType>UNITAI_DEFENSE</PrimaryUnitType>
  <SecondaryUnitType>UNITAI_COUNTER</SecondaryUnitType>
  <MultiUnitPositionType>MUPOSITION_FRONT_LINE</MultiUnitPositionType>
</Row>
I'm guessing that setting RequiredSlot=true for the second entry will ensure an escort is present. It's difficult to test things in this file, however. Has anyone else tried changing AI formations?
 
Has anyone else tried changing AI formations?

Only for custom units I've made. I'm pretty sure your guess is correct, that flagging the escort unit as required will keep the AI from killing it off, but I don't know whether the game can handle having multiple units in the formation with that flag, since that might screw up the art when it needs to take damage; are there any units in vanilla that have more than one required slot?
 
are there any units in vanilla that have more than one required slot?

Most formations appear to have multiple required slots, such as this one:

PHP:
<Row>
  <MultiUnitFormationType>MUFORMATION_FAST_PILLAGERS</MultiUnitFormationType>
  <PrimaryUnitType>UNITAI_FAST_ATTACK</PrimaryUnitType>
  <SecondaryUnitType>UNITAI_DEFENSE</SecondaryUnitType>
  <MultiUnitPositionType>MUPOSITION_FRONT_LINE</MultiUnitPositionType>
  <RequiredSlot>true</RequiredSlot>
</Row>
<Row><MultiUnitFormationType>MUFORMATION_FAST_PILLAGERS</MultiUnitFormationType>
  <PrimaryUnitType>UNITAI_FAST_ATTACK</PrimaryUnitType>
  <SecondaryUnitType>UNITAI_DEFENSE</SecondaryUnitType>
  <MultiUnitPositionType>MUPOSITION_FRONT_LINE</MultiUnitPositionType>
  <RequiredSlot>true</RequiredSlot>
</Row>
<Row><MultiUnitFormationType>MUFORMATION_FAST_PILLAGERS</MultiUnitFormationType>
  <PrimaryUnitType>UNITAI_FAST_ATTACK</PrimaryUnitType>
  <SecondaryUnitType>UNITAI_DEFENSE</SecondaryUnitType>
  <MultiUnitPositionType>MUPOSITION_FRONT_LINE</MultiUnitPositionType>
  <RequiredSlot>true</RequiredSlot>
</Row>
If I'm reading this right, I think it means the "fast pillagers" formation consists of exactly 3 units of the "fast_attack" or "defense" AI types.
 
Most formations appear to have multiple required slots, such as this one:

Assuming that formation is used for any existing units and isn't a relic of the previous system, then yes, it appears that your change should work. The only possible conflict I can think of would be with units that have multiple Damage States, which are generally single-unit models (mostly ships); I'm not sure how the game would choose to represent taking X damage, whether it'd try to damage the units before removing them or vice-versa. But assuming you're not doing anything like that, you should be fine.
 
This affects unit art? The fields in this table seem to indicate it's used by the tactical AI to coordinate groups of units to perform a common task... at least that's what I'm trying to change, wherever it is. These AI formations appear to be different from the art "formations" controlling how units display on a tile.
 
These AI formations appear to be different from the art "formations" controlling how units display on a tile.

Right, sorry, got a wire crossed there, scratch that part about damage states. (This is what happens when I post from work.) This formation required logic is separate, dealing with whether an AI uses that particular logic algorithm; I have tweaked a few of those over time (mainly to get the AI to use its future-era units in my mod better), but I invariably end up going back to the baseline once something breaks with the AI. As you can guess, a LOT of stuff breaks when you mess with the AI.

In this particular case, I'd have to wonder: if you force the AI to always escort every settler, what does that do at the start of a game (when you'll usually send your military units out to scout while your first settler plants himself, or even your second settler)? Does it slow down the AIs too much, to where the human player will find it too easy to get the ruins? And if it only classifies units with the "Defense" AI as the best choice for escorts, how many of the ancient-era units would qualify for that? I mean, back in Civ4 it made sense since every city needed to be garrisoned, so you'd send a defensive unit along, but a newly planted city in Civ5 can defend itself pretty well in the early eras. Having to drag your scouting units back home just to spend five or six turns walking each Settler to its site is kind of a waste; it's only once you get a road network in place that this gets more manageable. (And even there, it's skewed against the AI, who won't build roads towards a settlement site, only between existing cities.)

If you don't want it to be quite so absolute, then you could just add another military unit (maybe even one with the Attack AI instead of only Defense/Counter) to the formation, and keep both military units non-required. Presumably this'd just increase the odds the AI sends something with the settler, even if you made it favor a defensive unit. And it might open up some options; if it sent an Archer as an escort for your second city then it might have a harder time dealing with Barbarians along the way, but it'd be a much better complement once the city was founded... Even if you don't want to go the Attack route, just making a second (or even third) military unit with similar AI settings should just encourage the AI to protect its Settlers better. You might still get an unescorted one here and there, but you'd be just as likely to see two or three units screening in. So if the first unit is Defense/Counter (which basically means spearmen, pikemen, etc., plus the occasional Warrior/Swordsman) then add a second one that's Defense/Attack, a third that's Defense/Fast Attack, etc.; it'd still prefer using defensive units for this, but it'd now see mounted or archer units as acceptable substitutes if there isn't a melee escort around.

For a scenario I'd say go with the required flag, but for general play it might cause too many issues in the early eras. You should experiment with it before dropping the idea, of course.
 
AIs start with 2+ units on average difficulties so they've got one to spare in the early eras. Sending a defensive unit where none is required is probably better than what's currently happening. I explore around an AI and find 3-5 settlers captured by the surrounding barbarian camps.
 
Back
Top Bottom