Here are some AI examples I've jotted down while creating enemies. Some is Norwegian but you should be able understand.
FORVOKSE FIENDER
12 60 20
11 [98 40]
80
02 60 20
01 [98 40]
80
60 0A
30
90
:::::Adresser:::::
ATTACK (str)
4068h
MATTACK
4070h
DEF
4100h
HP
4160h Current - 4180h Max
Physical Immunity
4028h
Magical Immunity
4029h
MDEF
4110h
EXP
4020h
Target able
4023h (01h = on, 00 = off)
h
AI Main
4024h (01h = on, 00h = off)
STATUS
4000h = death (60h 01h = true)
DEX
40A0h
Last attacker Mag
40F0h
Last att General
40D0h
MP
4041h
::::Skripter:::::
:::80 = (AND):::
RANDOM NUMBER (if XX MOD random nr 0-65535 == 0 GOTO ZZ ZZ)::::
81(random)| 60(byte 61 = WORD 62 = DWORD), XX| 34(MOD)| 52(NOT)| 70 ZZ ZZ|
END END END
Checks if Current Hp is under MAX HP/XX*YY. (if not GOTO ZZ ZZ)::::
02, 60 20| 03, 60 41| 80(AND)| 02, 60 20| 03, 80 41| 80| 60, XX| 33 (div)| 60, YY| 32 (mul)| 43(<=)| 70, ZZ ZZ|
END END END
Checks if Current Mp is enough to cast ID. (if not GOTO ZZ ZZ)::::
02, 60 20| 02, 40 41| 80| 60, ID (or 61 ID ID)| 86 (get mp cost of ID)| 42(>=)| 70, ZZ ZZ|
Execute ID on target::::
12, 70 20| 02, A0 20(20A0 = opponents)| 60, 20| 60, ID (or 61, ID ID)| 92(Run ID)| (often after an ID is executed it jumps to the end of the AI: |72, ZZ ZZ|)
Set target (1 or all) and execute ID and::::
12, 70 20| 02, A0 20| 82 (only if 1 target, if all; skip this)| 90| 60, 20| 60, ID (or 61, ID ID)| 92|
NOTE: Switching between 1 and all targets only works if Target byte in attack data is 0x0F. Default works as 1.
END END END
(counter) Attack the target's last attacker::::
02, 60 20| 02, D0 40| 80| 90| 60, 20| 60, ID (or 61, ID ID)| 92|-> set Row 12, 60 20| 10, 28 40| 80| 90|
END END END
Sets counter (Not as in counter attack) to address YY YY and counter = random(0.. (X - 1))::::
11(push value), YY YY| 81(random)| 60, XX| 34(MOD)| 90|
END END END
If counter (Not as in counter attack) from address YY YY isn't XX (XX) GOTO ZZ ZZ::::
01(load address), YY YY| 60, XX (or 61, XX XX)| 71 ZZ ZZ|
END END END
Checks if target got status 40 XX (where 00 is death etc) If not GOTO ZZ ZZ:::
02, 70 20 (if check is on self: 60 20)| 00, XX 40| 80| 60, 01 (00 if the check for which status it doesn't have)| 40(==)| 70 ZZ ZZ|
END END END
Checks if address XX XX is "checked/used". If not GOTO ZZ ZZ
00, XX XX| 52| 70, ZZ ZZ|
END END END
Self = 0000 Cloud = 0020
12,00 00| 02, 60 20| 90| 12, 20 00| 02, 50 20| 01, 60 40| 80| 60, 10| 40| 90|
END END END
Set Cloud as self use attack (0020 = CLoud (se '2050' over) 0000 = target)
12, 60 20| 02, 20 00| 90| 12, 70 20| 02, 00 00| 90| 60, 01| 60, 00| 92|
END END END
self immune to Phys (4029h Mag)
12, 60 20| 10, 28 40| 80| 60, 01| 90|
END END END
Target = 1 random opponent
If (Target Current HP == Target Max HP)
{
if(1/2)
PrintMessage("Estuans interius ira vehementi");
else
PrintMessage("Sors immanis Et inanis");
Target Current HP = 0;
}
Else
{
PrintMessage("Veni, veni, venias, Ne me mori facias");
Target Current HP = Target Max HP;
}
12, 00 00| 02, A0 20| 82| 90|
If: 02, 00 00| 03, 60 41| 80| 02, 00 00| 03, 80 41| 80| 40(==)| 70, YY YY(GOTO ElseY)|
If: 81| 60, 02| 34| 52| 70, XX XX(GOTO ElseYX)|
93 (Estuans interius ira vehementi) FF| 72, AA AA|
ElseX: 93 (Sors immanis Et inanis) FF|
AA AA: 12, 00 00| 13, 60 41| 80| 60, 00| 90| 72, ZZ ZZ(GOTO End)|
ElseY:
93 (Veni, veni, venias, Ne me mori facias) FF|
02, 00 00| 13 ,60 41| 80| 02, 00 00| 03, 80 41| 80| 90|
End: 73|
END END END END END END END END END END END END END END END
If(1/4)
Use Beak;
Else if (1/8)
Use Hell Charm;
Else if(1/16)
Use HC all;
Else
PrintMessage("Qwim's taking a break...");
81| 60, 04| 34| 52| 70, XX XX|
12, 70 20| 02, A0 20| 82| 90| 60, 20| 61, 01 01| 92| 72, ZZ ZZ|
81| 60, 08| 34| 52| 70, XX XX|
12, 70 20| 02, A0 20| 82| 90| 60, 20| 61, 02 01| 92| 72, ZZ ZZ|
81| 60, 0F| 34| 52| 70, XX XX|
12, 70 20| 02, A0 20| 90| 60, 20| 61, 02 01| 92| 72, ZZ ZZ|
93 (Qwim's taking a break...) FF| 73|
END END END END END END END END END END END END END END END END
SETUP:::::::::::::::::
Selve's 4278 = 150;
Count = 0;
END:::::::::::::::::::
MAIN:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
If(Self MP <= 1/4 AND Count < 3)
{
Use Hyper Ether on Self;
Count += 1;
}
Else If(Any ally have Reflect, Slow or Stop AND 1/4)
Use DeSpell on target(s);
Else If(Any opponent have either Shield, Regen, Barrier, Mbarrier or Haste AND 1/3)
Use DeSpell on Target(s)
Else If(Any ally have either Darkness, Mini, Confuse, Silence, Berserk, Paralyzed, Petrify or Slow-Numb AND 1/2)
Use Esuna on target(s);
Else If(Any ally have Poison Status AND 1/2)
Use Poisona on target(s);
Else If(1/2)
{
If(Self doesn't have Barrier, Mbarrier, Shield or Resist and 1/3)
{
if(1/2)
{
Use Wall on self;
Use Resist on self;
}
Else
{
Use Shield on Self;
Use Resist on self;
}
}
Else If(Self doesn't have Shield, Haste or Resist and 1/2)
{
Use Haste on self;
Use Resist on self;
}
Else If(Self doesn't have Shield, Regen or Resist)
{
Use Regen on self;
Use Resist on self;
}
Else
{
If(1/2)
Use Phy1 on random opponent;
Else
use Phy2 on random opponent;
}
}
Else If(Selve's HP <= 1/4 AND 1/2)
Use Fullcure on Self;
Else
Use Ultima on all opponents;
END::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
END END END END END END END END END END END END END END END END
IF self = self A, else GOTO XX XX and keep var X(the 1st in stack)
02, 60 20| 01, 60 40| 80| 60, 00 (00 = A, 01 = B etch)| 71, XX XX
END END END
If self != SHIELD cont Barrier
== GOTO ATTACK
If self != Barrier & MBarrier cont HASTE
== GOTO ATTACK
If self != HASTE cont Regen
== GOTO ATTACK
If self != Regen cont Resist
== GOTO ATTACK
If self != Resist GOTO rand Buffer
== GOTO ATTACK
If(1/4) Shield END != Next etc...