[FE7] The Official AI Documentation Thread


#146

After another check into the method, You’re right. I missed one of the cases in the middle and mistook one of them.


#147

AI1 0x0C
I know that particular AI gets used a few times in FE6. Let’s see what my CUE searcher program says:

AI 1 : 0x0C
=== Chapter 2 ===
0x0A Fighter (Iron Axe) [15,06] [0C 11 09 00]
0x0B Archer (Iron Bow) [17,04] [0C 12 29 00]
=== Chapter 23 ===
0x31 Sniper (Killer Bow) [06,02] [0C 14 0A 20]
0x32 Sniper (Killer Bow) [04,02] [0C 13 0A 20]
0x33 Druid (Flux, Physic, Berserk) [04,03] [0C 15 0A 20]
0x34 Druid (Nosfertau, Physic, Blue Gem) [05,03] [0C 16 0A 20]
0x35 Druid (Flux, Physic, Sleep) [06,03] [0C 17 0A 20]

Oh, that’s strange. Each enemy has a different AI2. And many have that weird 0x20 for AI4.


#148

The “otherwise, move forward” part is probably due to AI2.

AI1 = 0x0C, AI2 = 0x00
Enemy attacks if foe within movement/2 range, otherwise move forward.

AI1 = 0x0C, AI2 = 0x03
Enemy attacks if foe within movement/2 range, otherwise don’t move.

Yeah, I wouldn’t recommend using AI2 0x00 with AI1 0x0C since it looks silly to have an enemy move up to a player unit without attacking.


#149

Edited to reflect this.


#150

You know how in FE12 certain enemies won’t move until another specific “trigger” enemy attacks? Well, it looks like the GBA FE’s already have built-in support for similar behavior. (It only gets used a few times in FE6)

AI1 0x0D
Move/attack if the unit’s leader has foe in range.
Switches AI1/A12 to 0x00/0x00 (aggressive) when leader is defeated.
The unit must be auto-leveled in order for the unit’s leader data to be loaded.

To create FE12-style enemy traps:
Leader/trigger enemy: AI1 = 0x00, AI2 = 0x03 (attack when foe in range)
Followers: AI1 = 0x0D, AI2 = 0x03 (make sure leader is set and unit is auto-leveled)

Strangely, FE6 mostly uses this AI with an already aggressive leader:
Leader/trigger enemy: AI1 = 0x00, AI2 = 0x00 (aggressive)
Followers: AI1 = 0x0D, AI2 = 0x00
So there might be more to this AI? Or maybe IntSys is just weird.


[FE7] The Primordial AI Expansion
Fire Emblem: Bloodlines|Version 1.4 OUT!
#151

What else is new?

01 00 FF 00 00 00 00 00 BD A5 03 08 00 00 00 00 @Execute this routine. Do nothing if Support#7 is 00 or player unit
https://www.dropbox.com/s/xa6rpewdkdgqkmu/AI%20Byte%201%20Commands.txt?dl=0
From [the Unified FE Hacking Dropbox][1]

This loads the 0x38 byte of the unit data. For player units, this is Support #7. Am I to assume it’s the leader for enemies?
[1]:Unified FE Hacking Doc Dropbox


#152

Yep, byte 0x38 = enemy leader.


#153

Are we sure these are right? Where’s the post that found this out? From the AI codes I’m looking at, they seem to be backwards.


#155
AI1PointerTable(0x00, SeekWallsAI)
AI2PointerTable(0x00, Pursue)

Bad:
UNIT Batta Brigand 0x00 Level(1,Enemy,False) [10,7] [10,7] [IronAxe] [0x00, 0x0 ,0x0, 0x0]
UNIT

SeekWallsAI:
GetEnemyInCoefMoveRange(OneMove)
ConditionalGoto(0, LT, 1)
GetEnemyInCoefMoveRange(ThreeMove)
ConditionalGoto(0, LT, 2)
SeekWalls
LoopAI
Label(1)
DefaultAction
LoopAI
Label(2)
MoveTowardsOpponents
LoopAI

OneMove:
defMovementCoefficient(0x1)

ThreeMove:
defMovementCoefficient(0x3)

Pursue:
MoveTowardsOpponents
LoopAI

Help guys it’s too readable.


#156

AI assembler! That’s awesome.

AI2 0x13, 0x14, 0x15, 0x16, 0x1D
Yeah, you’re right. There’s clearly a change AI command in there, but it doesn’t get used.

Here’s how it’s supposed to work:
If unit is within a rectangular area, switch AI1/AI2 to [0x00,0x00]
Otherwise, move unit towards a specific point (which should be located within the rectangle)

(X1, Y1) = Upper-left corner of rectangle
(X2, Y2) = Lower-right corner of rectangle
Routine 0803A548 checks whether the unit is within the rectangular area.
Currently, the parameters are formatted like this: X1 Y1 00 00 X2 Y2 00 00
But they should be formatted like this: X1 Y1 X2 Y2
Due to this error, units with this AI will just crowd around the interior point.

AI2 0x17, 0x19, 0x1A, 0x1E
These units won’t move back. After stepping on the target point, this AI essentially turns into AI1 0x00.


#157

rectangular area AI? far out, I have some comprehensive re-eventing to do now


#158

Taking a look at the AI Commands for AI2 0x8:

AI2 0x08 - 08B975B8 - ???
01 00 FF 00 00 00 00 00 D9 A4 03 08 00 00 00 00 @Seen in unreached commands in AI 0x17?
00 00 FF 01 00 00 00 00 72 A9 03 02 00 00 00 00 @If 0<Memory, Goto 1
03 00 FF 00 00 00 00 00 00 00 00 00 00 00 00 00 @Goto 0
1B 00 FF 01 00 00 00 00 00 00 00 00 00 00 00 00 @Label 1
01 00 FF 00 00 00 00 00 F1 A3 03 08 44 3B 1D 08 @ Parameters = FF 01 00 00
01 00 FF 00 00 00 00 00 C1 A0 03 08 48 3B 1D 08 @Get Foe in Expanded Range
00 00 FF 01 00 00 00 00 72 A9 03 02 00 00 00 00 @If foe in expanded range, goto 1
0E 00 FF 00 00 00 00 00 00 00 00 00 00 00 00 00 @Nop
03 00 FF 00 00 00 00 00 00 00 00 00 00 00 00 00 @Goto 0

#159

Had a hunch based on the 0x32 there, confirmed experimentally.


#160

Is there a way to make the enemy target more units?
I know AI1 0x0A makes the enemy attack the character 0x03, but can you make them attack other units?
Like, 0x0A = Target 0x03, 0x1A = Target 0x04, 0x1B = Target 0x05 and so on.

I don’t know is this is doable, but is there something to force the enemy to attack certain units?
–But I suppose this haven’t been figured out yet, because I remember someone wanted to create the Provoke skill based on AI and he couldn’t.–


#161

The actual code for AI 0xA is
AI 0xA - 08B97ABC - Only attack character 0x03 (tutorial Lyn) (B97AC0)
04 64 FF 00 03 00 00 00 00 00 00 00 00 00 00 00 @??? Data = 03 = Lyn_t
00 05 FF 00 03 00 00 00 72 A9 03 02 00 00 00 00 @If memory != 0x3, goto top
05 64 FF 00 00 00 00 00 00 00 00 00 00 00 00 00 @Default behaviour if can’t find Lyn_t?
03 00 FF 00 00 00 00 00 00 00 00 00 00 00 00 00 @Goto top

So to expand it just add more 04-type commands. AI Assembly. Blah. Stuff. Sorry I’d explain more but I have to leave so this is a rushed post.


#162

A post was split to a new topic: AI Help Needed


#163

ok I think it’s better to just ask because my own tests are giving me something weird. For making the custom AI, is the order [A1,A2,A3,A4] or is it actually [A3,A4,A1,A2] like the first post was suggesting?


#164

I think they are read in the latter order but actually written in the first


#165

If you’re asking about when assembling events, the traditional [AI1, AI2, AI3, AI3] order still works, but I’m now recommending the format which I defined for the newest event assembler of [AI1, AI2] AI3 AI4.

If you’re talking about making your own AI, then it doesn’t matter; you specify whether it’s AI1 or AI2 by overwriting different pointer tables.


#166

Ah thank you both, using the old event assembler so it will be a1 - a4 then.