I think they are read in the latter order but actually written in the first
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.
Ah thank you both, using the old event assembler so it will be a1 - a4 then.
Reposting from the FE8 AI thread:
This routine is super important for AI execution.
Routine 08034E50
Writes command data to 0203A97C
Parameters:
r0 = move to x
r1 = move to y
r2 = command
r3 = target unit deployment number (escape x)
sp+0x00 = inventory slot to use or steal (0xFF = ballista)(escape y)
sp+0x04 = snag/wall x-coordinate (escape direction)
sp+0x08 = snag/wall y-coordinate
Commands:
00 = none. 01 = attack. 02 = escape (remove unit from map). 03 = steal.
04 = pillage village. 05 = staff. 06 = item. 07 = dance/play. 08 = talk.
Note: dance/play doesnāt work.
0203A97C
0x00 = command
0x01 = enemy deployment number
0x02 = move to x
0x03 = move to y
0x04 = (skipped)
0x05 = (skipped)
0x06 = target unit deployment number (escape x)
0x07 = inventory slot to use or steal (0xFF = ballista)(escape y)
0x08 = snag/wall x-coordinate (escape direction)
0x09 = snag/wall y-coordinate
0x0A = 01 (indicates a command was written)
Not 100% sure on talk command bytes 0x06-0x09 yet.
Looks like the deployment numbers of the talkers and maybe the talk event id.
Oh my god this is amazing Iām going to put this to good use.
Edit: Can you find a corresponding routine in FE8?
Edit2: I donāt have time this week, but I want to mess with this asap. So, next week. Not being able to/not putting enough effort into find this routine was a sticking point with me not meddling too much with AI anymore.
What am I looking for in these images?
Enemies using items that they normally donāt, like promotion and stats boost items.
Iām not sure about the Batta vs. Batta.
Promoting enemies would be the biggest troll
Yeti had a video where he attacks an enemy in fexp and the enemy autolevels to 20/20 and promotes. It was pretty funny.
Enemies using stat boost items is suuuuuuch a tease.
It would be a good challenge on maps, putting stat boost items on chests and a thief stealing and using them.
Even better with promotion items.
I wonder if is possible to give items to brigand/thief after destroying villages and then theyāre able to use themā¦
Two quick questionsā¦On factionsā¦Can animations be Used??
And how do i make a Thief that after looting gets angry and attacks your units instead of trying to run away??
On factionsā¦Can animations be Used??
Donāt understand what youāre asking here, sorry.
after looting gets angry and attacks your units
I think youād need to put an event on the chest that checks who opened it and CHAIs appropriately.
Yep, crazy colors made factions by changing one byte of the AI, but his tech demo had no animations, just map sprites. and ill check the Chai, or maybe Briggand Ai could work??
I was reading through to learn how the last part of the third AI byte (Target) works.
In summary of what @Gryz has put (as well as looking through fe 6) it would appear that:
00 = Prioritize damage taken more than 8 but much less than 10
prioritize accuracy more than 8 but much less than 20
(For intelligent enemies like bosses)
08 = Prioritize damage (Standard)
10 = Prioritize damage taken (Jaffar)
20 = Prioritize accuracy (Never used in Fe 7)
28 = Archers
In Fe 7, 08 is the standard while 00, 28, & 10, are used for a few commanders, almost every archer, and a few units who want to live (mainly NPC jaffar) respectivly.
In Fe 6, 00 is the standard behavior (used by most of the army), 08 is for the brigands at the beginning and some mercenaries, 10 is used by staff wielders,
20 I found to be used by a single poison axe user, and 28 is almost every bow user in the game.
I may do some more testing on how 28 works (something to do with adjacent allies maybe?) if I do Iāll put my results here.
AI Byte 4
0x20 = āDonāt retreatā Makes the enemy unable to move and attack on the same turn.
Additionally, the units with this command will move next to the player unit in the following pattern:
1
2*3
4
(with the * being the the player unit.)
If there are 2 or more units available for the enemy to move towards, the enemy will move to the highest priority spot (aka ā1ā).
This habit overrides all logic and TP incentives (including terrain)
In Fe7, This behavior is ONLY given to units who
A. Do not move at all
and
B. are sitting on gates/seizepoints
This byte is set to keep stationary bosses from moving during their recovery status.
If this byte is set to 0, then a completly stationary enemy/boss will begin moving as soon as he wants to heal.
In short, only use this command on units which do not move at all.
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)