To correct what I said last week, archers in FE 7 use the 28 target AI until you face the black fang, then they use AI 08.
Alright I’m back, and this time i’m using graphs (made from the calculations in the wikipost) to judge each target AI behavior.
For my own sake, I will discuss each behavior from most simple to most complicated.
(Also, each of the calculations are slightly simplified, I leave out TP caps and class modifiers (unused) among other things. For the complete calculations check out the wiki post)
0x20
0x20 checks the following formula:
TP = (Hitrate * Damage)/100
and chooses the target which gives the highest TP.
If an attack could be lethal it gets highest priority.
(if two or more attacks are lethal then it comes down to inventory order and unit order)
0x08
0x08 is the kamikaze AI.
Most units in FE 7 use this.
It aims to:
- Get player HP as low as possible
- Take any lethal blows
- Stay near allies
Accuracy/Hitrate is less of a priority to this AI &
it does not consider defense (aside from staying near allies).
TP Calculation
TP = (Hitrate * Damage)/100 + 2*(20 - Attacker's_remaining_HP) + 2*allies_nearby
0x00
0x00 is the soldier/commander AI.
This AI is used on many of the enemies in Fe6 on some of the bosses in Fe7.
It takes every known modifier into consideration.
Here's the calculation
TP = 2*(Hitrate * Damage)/100
+ (20 - Defender's_remaining_HP)
+ allies_nearby
+ Turncount
- (Defender's_Hitrate * Defender's_Damage)/100
- enemies_nearby
- (20 - Attacker's_remaining_HP)
(I excluded the Class modifier because that is not used in Fe7)
This makes an AI which is quite a bit more “intelligent” than the ones we have looked at so far.
This AI considers attack, defense, nearby allies, nearby enemies, whether the enemy can counter, and terrain effects as well
Although this AI considers many factors, it’s most prominent component is:
TP = (Hitrate * Damage)/50
(Which is an alternate version of the 0x20 AI)
This is what leads 0x00 to emphasize Accuracy more than 0x08 and act more cautiously than 0x20 or 0x08
0x18
0x18 is much like 0x00.
The calculation is almost the same aside from three things:
- 2*(20 - Defender’s_remaining_HP)
- 2*(Nearby_allies)
- 0*Turncount
This means we have an AI which functions similarly to 0x00, but prioritizes
- Staying near allies, and
- Targeting enemies who will be below 20hp
Functionally, this is a good defensive AI.
0x10
0x10 is quite possibly the most complex AI.
AI 0x10 effectively has two personalities.
Ordinarily, Target AI 0x10 is the most defensive AI.
It prioritizes damage taken, counterattacks, and personal health more than all the other AIs I’ve discussed.
When working well, this means you’ll have a unit which uses terrain to their advantage and attacks so that they are taking minimal damage.
Our Calculation is:
TP = (Hitrate * Damage)/100
+ 2*(20 - Defender's_remaining_HP)
+ 2*allies_nearby
+ 2*Turncount
- 2*(Defender's_Hitrate * Defender's_Damage)/100
- enemies_nearby
- 2*(20 - Attacker's_remaining_HP)
"If TP<=0, TP = result from step [0]"
Here’s the issue: we have 4 positive modifiers and 3 negative ones. If our total TP comes out as a negative number then we scrap everything and get
(Hitrate * Damage)/100 as our result (with a cap of 40).
This means if the AI has too many negative influences on an attack (low health, too many enemies, not enough hitrate) Then the AI will treat that particular combination like AI 0x20 would. ((Hitrate * Damage)/100)
Here’s the kicker, this changes over time.
As the turn count goes up the AI gets more TP on each calculation.
This means a particular calculation will change from negative to positive.
So a unit with this AI may
Turn 1: act like 0x20
Turn 2: act like 0x20
Turn 3: Calculate some attacks as 0x10 and some as 0x20
Turn 4: Calculate some attacks as 0x10 and some as 0x20
Turn 5: act like 0x10
Whether the unit behaves like 0x20 or 0x10 is also largely impacted by its remaining health. If it has >20HP it will behave more like 0x10, if it has <20HP it may behave like 0x20.
This all may be due to an oversight in design, or maybe Intelligent Systems really wanted Jaffar to have a multifaceted personality.
TL;DR 0x10 is offensive at the beginning of a chapter and defensive at the end; Defensive at high HP and Offensive at low HP.
0x28
(I’m almost done)
0x28 calculates the same as 0x00 except it does not consider the defense modifiers. This AI is used for all the archers in Fe6.
The most fascinating thing about this AI is the undocumented “28” in its data table.
This may be connected the TP routines at $080391E4 and $08039094 which Venno mentioned.
AI 0x30 & 0x038 - Both have the same modifiers as 0x28, but the undocumented data bit moves over for each one. (Idk the technical terms, I’m new to this stuff)