Be warned, this topic is a bit confusing due to the order of processing (priority). Keep in mind the first met condition sets the command.
AI allies (affiliation/alliance) are forced to join Hail or Retreat of players when on the same side of the battle (kinda random when both opponents are allies of a third party). However, player Ram commands confuse the AI (cf. AI jihad retreat/ram). So setting all ships to Ram (be it just to get closer to the enemy) forces AI allies to Hail. This can be exploited to prevent an expected Retreat to provide the enemy with more targets.
Code: Select all
00477FD5 cmp edx, 9 // player ally Ram check for AI join Hail/Retreat -> 0x773D7 = FF fixes AI confusion
Following three main parameters suffer from debatable reliability and validity: (default range 0-4)
: how mad the AI is at someone (see post above) by default 5+ is restricted to jihad, highest value determines primary target
: of the fleet task (cf. first post) highest value of e.g. raid/harras 0 (1 own sector), own station 3, invade/attack 3 (4 arrived)
: 0 defeat with no enemy losses, 1 defeat, 2 equal, 3 win, 4 win with no losses
At 5907B4 (0x185EB4 +14h*raceID) is five modifiers per empire and five shared for all minors (race ID 5):
2nd - Bravery
: increases chance of uphill battles instead of Retreat (defaults card-rom 60 55 40 85 50 minors 50)
5th - Peaceableness
: increases chance to use Hail (defaults card-rom 50 85 75 25 75 minors 50)
Only the 2nd & 5th values are actually used (base range 0-64h but not percentages)
A reasonable main condition for fleet retreat if there is no possibility to destroy the weakest enemy ship. To prevent this just bring some weak scouts (best set to evade). One could argue to merge Retreat with an improved Hail check to spare AI the morale losses from evitable retreats. Note the prognosis fails to regard distances/movements. This can mislead to overestimating chances vs stations or of the cloak advantage.
Hail is restricted to no war & sympathy 2+ (out of range 0-8)
Counterside Hail & Importance
0-3 & Prognosis
else for Prognosis
2-4 if random 0-99 lower than (Peaceableness
[+30 if Prognosis
2] - Pugnacity
Counterside doesn't Hail or Importance
4 works only for the first turn with Pugnacity
0-4 (no jihad)
If random 0-99 lower than (Peaceableness
0 & (own ship losses expected or Pugnacity
Ship & Combat-Group Commands
0 - fast attack
1 - long range / artillery
2 - command / slow / cruiser
3 - support / non-combat
4 - monster
All ships not expected to survive the next three turns & Pugnacity
Groups 0-2 if NO warship is expected to survive the next three turns & Bravery
+ 10x (Pugnacity
) lower than 100
Retreat (group 3 always)
Armed group 3 ships expected to survive the next three turns which 'could' kill an enemy
Assault else Evade
Note the above Ram and Assault orders specify no target (wildcard -1). Same with AI stations set to Attack.
Target 'wildcard' is an AI function shared by player ships and not part of the AI commands, like targeting when using Hold or Evade or remaining shots after kills. The first-turn random commands for players are wildcard until changed. Wildcard commands, which require a target, can cause glitches and crashes (e.g. vs Edo God).
All remaining ships of combat-groups 0-2 'should' target the same enemy ship/station:
Get primary enemy fleet by highest Pugnacity
If combat simulation indicates the AI 'could' destroy objects of this enemy next turn -> most expensive of them
Else if this enemy has un-cloaked objects with shields down -> lowest hull points
Else if this enemy has un-cloaked objects which died in combat simulation -> quickest kill in turns
Else repeat for secondary enemy fleet.
Else i.e. all enemies destroyed in combat simulation cloaked
Hold (weapons free)
The code iterates for each ship i.e. there can be random deviations of targets between combat-simulation iterations.
All targets are set in solo-mode (hard to notice if equal). The last ship processed also sets the group command (albeit pointless if all set to solo targeting). Relevance of the 'group leader' feature is unclear.
Combat Group 0-2 Commands vs enemy Outposts & Starbases:
Command Probabilities for Combat Groups 0-2
Code: Select all
0047874B mov eax, edx(is 5) ; Strafe for group 0 // example to change this 0x77B4B (89 D0) -> B0 01 (Charge)
00478741 mov eax, 2 ; Assault for group 1
00478737 mov eax, 1 ; Charge for group 2
vs enemy Combat Groups 0-4:
At 5905D4 (0x18E3D4 + [own group ID x 160] + [enemy group ID x 32]) is four command entries each.
8 bytes per entry -> Command ID / Relative Frequency (0 = unused)
4th random command (default always evade) is not used if the own ship is cloaked
Own/enemy combat-group 'fast vs fast' reads:
By default sum of 1-4 is 100 i.e. Relative Frequency = Command Probability in % (unless cloaked).
Command Probability = relative frequency / (sum of all used command frequencies)
5th four commands vs Monster Group 4 are not used:
- Combat Drone & Husnock -> enemy fast group 0
- all other Monster -> enemy command group 2
I did not test whether these random commands are actually used vs monsters.
To spice the things up one could change some of the unused evade entries with frequency 0 into low frequency Hold (group 1) and Ram (group 2).
Below is a test patch modifying code of random commands for groups 0-2.
Cloaked ships always use Charge, ships killed next turn in combat simulation use Evade, Prognosis
4 (victory with no losses) all ships set to Charge. Remember the order of processing. All codes above the random commands still have priority.
Code: Select all
NAME: Improving AI Combat Commands for Warships vs enemy Ships
DESC: Cloaked ships use Charge, ships killed next turn in combat simulation use Evade, Prognosis 4 all ships Charge
>> 0x77A24 59
<< 0x77A24 69
>> 0x77AE4 89 DD
<< 0x77AE4 90 90
>> 0x77B5B 83 B9 78 01 00 00 01 0F 85 87 00 00 00
<< 0x77B5B 85 ED 75 D8 83 7B 7C 01 7C B7 90 90 90
>> 0x77BA4 85 ED 0F 85 80 00 00 00
<< 0x77BA4 3B 05 70 58 5B 00 7C 8B
# remove player Ram check of AI ally join Hail/Retreat code
>> 0x773D7 09
<< 0x773D7 FF
I don't know how many bugs is too many but that point is reached somewhere before however many in BotF is.