[FE8] The Official AI Documentation Thread


#1

It’s recommended that you take a glance at the corresponding FE7 documentation so you get a general idea of how the AI functions.

It is assumed you have read that.


AI1: Primary AI Byte
AI1 0x00 through 0x06 are all identical to the FE7 entries.

0x00 = Action 100%
0x01 = Action 80%, end turn without moving/acting 20%
0x02 = Action 50%, end turn without moving/acting 50%
0x03 = Action without moving 100%
0x04 = Action without moving 80%, end turn without moving/acting 20%
0x05 = Action without moving 50%, end turn without moving/acting 50%
0x06 = Do Nothing
0x07 = Do not attack character 0xD (Natasha, character at 5A8A00)
0x08 = Do not attack character 0xFC (character at 5A8B3C)
0x09 = Do not attack character 0x0 (character at 5A817C)
0x0A = Only attack character ??? if deployed. (currently 00 01, set it at 5A8BA4)
0x0B = Same as 0x0
0x0C = Attack if within Mov/2+Range(?)
0x0D = CHAI [0x0, 0x0] if the unit's leader has foe in range.(?)
0x0E = Heal allies under 50% HP(?)
0x0F = Alternate between 0xE and 0x3
0x10 = Pick Locks/Steal, then CHAI [0x6, 0xC] (Escape)(?)
0x11 = Pick Locks/Steal
0x12 = Do not attack character ??? (points to 00 01 00 01)
0x13 = Do not attack character ??? (points to 00 01 00 00)
0x14 = Try to use Nightmare (but not on turn one), then try to Summon Units, then act like 0x0 (AttackInRange)

AI2: Secondary AI Byte

0x04 = Loot villages/chests then change AI1 to 0x00 and AI2 to 0x00 (brigand AI)(???)

0x0A = Move to character 0x1 Eirika; once in range, alternate between pursuing enemies and pursuing character 0x01. Used by Ross in chapter 2.

AI3: Recovery and Targeting

FE8’s TP mod table is identical to the table in FE6 and FE7. Like FE7, there are no classes defined to get TP bonuses.

FE8 TP mod table: 080D8178
Pointers to class sets (all point to 00): 085A8150

Summoning Units

Being researched.
The units the demon king summons are at 88D1F54, just as event assembler units.
807B2BC - number of units in that array


The Communal To-Do List
The Grand Library of FEU [UNDER CONSTRUCTION]
#2

AI 1 0x07: Do not attack character 0xD (Natasha) - Used by Joshua in Chapter 5

AI 2 0x0A: Move to character 0x1 Eirika; once in range, alternate between pursuing enemies and pursuing character 0x01. Used by Ross in chapter 2.


#3

FE8’s TP mod table is identical to the table in FE6 and FE7. Like FE7, there are no classes defined to get TP bonuses.

FE8 TP mod table: 080D8178
Pointers to class sets (all point to 00): 085A8150


#4

Some AI bytes I think are worth investigating:

AI 1 0x0E: Something to do with healing; appears to be used exclusively by Physic users. Perhaps it tells them to keep their distance? It’s also used by NPC L’Arachel

AI 2 0x0B: Probably Pursue Ephraim (ID 0x0F); used by some Fighters on Chapter 10 Eph so they don’t go after Duessel, and by some units on the Phantom Ship.

AI 3 0x60 (0x40+0x20) - Used by the Civilian man on Chapter 6.


#5

Due to the differing nature of AIs 3+4, I’ll be investigating AIs 1+2 first. (After the like, 3 tings I want to hack in first @_@)


#6

Pointers to AI1 entries: 085A9184
Pointers to AI2 entries: 085A9138

AI1 0x00 through 0x06 are all identical to the FE7 entries.
AI1 0x07 (do not attack Natasha) follows the format for FE7 “do not attack character” entries.

Then umm…
0x08 = Do not attack character 0xFC
0x09 = Do not attack character ??? (points to 00 00 06 00)
0x12 = Do not attack character ??? (points to 00 01 00 01)
0x13 = Do not attack character ??? (points to 00 01 00 00)

These are kind of messed up.
I don’t think it’s a coincidence that in FE7 these entries are for “do not attack character” AI. That reminds me, the 0x09 entry in FE7 is also “do not attack character” with a bad pointer. I guess any AI1 or AI2 that doesn’t get used in FE7/FE8 could be leftover data from an earlier game.


#7

Dang, nice, I didn’t expect that! (er, no offense, Gryz)
Did you use a debugger :D? Welcome to the club.


#8

In this case, no.
I just did a hex editor search on the hunch that the first few entries for AI1 weren’t going to change from FE7.

I have used a debugger before - like in the FE7 AI thread to figure out some of the routines related to AI3 and targeting. I did some debugging stuff before that but not a lot. I’m just really slow and easily frustrated. I actually did try to use a debugger during my search of thief escape points but that was a disaster.


#9

The Summoning AI used by the Demon King:
AI 1 0x14:
At $085A8A7C: 01 00 0F (indicates staff usage and similar)
More importantly, eight bytes later we have two pointers: one to $080411F9 - an AI asm routine - and one to $085A8A70. At this location, we have the following bytes:

05 04 50 00 05 03 0000 ($088D1F54)

$088D1F54 is the ROM location of the unit data of the monsters the Demon King summons. More on this later as I document the routine at $080411F8, but custom summoning AI is not far off!

Here’s some reference on other AI 1 values:

0x07: $5A8A04 (do not attack Natasha)
0x08: $5A8B40 (Do not attack 0xFC)
0x09: $5A8B80 (messed up 'do not attack' pointer)
0x0A: $5A8BA0 (something?)
0x0B: $5A8BA0 (attack enemies in range)
0x0C: $5A8C00 01 00 (some complex thing- two pointers, $0803F019 and $080D8668)
0x0D: $5A8C70 01 00 (as above, but only one pointer to $0803F51D)
0x0E: $5A8F90 01 00 (as 0x0C; ptrs to $0803F791 and $080D8670)
0x0F: $5A8FB0 01 00 (copy of 0x0E)
0x10: $5A8FE0 01 00 ($0803F7DD, $080D8674)
0x11: $5A9040 01 00 ($0803F7DD, $080D8678)
0x12: $5A8A2C 05 64 (do not attack ??? bad formatting)
0x13: $5A8A40 05 64 (like 0x12, bad formatting)

#10

@Arch, wiki my first post in this thread so I can conglomerate all that info into one place!


#11

Is it possible to make so that the AI byte 4 = 0x20 does that, as @Arch suggested?


#12

Do somebody know which is the AI used by brigands/pirates to destroy villages? I tried a few I found in disassembled events but they didn’t work.


#13

[0x00,0x04,0x01,0x00]

I think the second byte being 0x04 is the one that’s supposed to do it along with general thief stuff?


#14

That’s not the case.
I’ve searched for enemy reinforcements data in hex and I found out that the correct AI in FE8 to make pirates/brigands destroy villages is [0x3,0x4,0x9,0x0].
They also “attack in range” and “pursue once the village is destroyed”. They will prioritize the enemies instead of pursuing the villages, if there are any in range.


#15

What exactly is the difference with that AI command compared to the one I gave you? From my experience that command does just what you’ve described. Do the brigands just not pursue after destroying villages? Or do they not destroy them?


#16

I don’t know. I wanted to make sure and used the one that vanilla FE8 uses. Probably, there’s no difference.


#17

This is strange. I should test to see if AI2 0x4 behaves this way in FE7…


#18

Correction: they’ll prioritize the enemies that they can kill, otherwise they’ll just go for the villages instead.


#19

Ok. [0x00, 0x04] should always attack enemies that are in range.


#20

It appears the same as in FE7. This is a conditional check for having a target in Mov/2 range.

If there’s something with a pointer to D8664, that’s checking for within 2*mov range. -6C is mov/2 again.

In FE7, the pattern of the data used were for opening doors/looting.
This also matches up with what 0x10 and 0x11 actually are in FE7 (steal/open locks; and open doors)