• Welcome to Final Fantasy Hacktics. Please login or sign up.
 
April 27, 2024, 11:22:14 pm

News:

Please use .png instead of .bmp when uploading unfinished sprites to the forum!


Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Messages - Dokurider

21
Don't worry too much Rai, I'll keep looking into where the AI begins in proper.
22
Oops sorry about the delayed response, Raijinili.

Unfortunately, the complete work flow of the AI is still somewhat of a mystery to me. I've been focusing more on individual decision mechanics rather than the overall flow. It's something I'll get to eventually, but right now, I wouldn't know exactly where the AI decision hierarchy begins in earnest, and where a good entry would need to go. If you come to the arena discord or PM me though, I could give you a more detailed run down of what I do currently know.
23
PSX FFT Hacking / Re: Status Effects
March 09, 2017, 11:10:40 am
QuoteWall (Must be enemy-only.  The AI will always consider walled units to be not targetable, even if you unflag ignore attacks and change the relevant ASM bit from 40 to 42.  There's probably another behavior bit involved that we don't know yet.  Units with wall will not be targeted for damage or healing...though you can make them revivable if you have death cancel wall.)


This is confirmed. The AI will ignore walled units like they ignore Jumped units.


<If Wall>
0019e804: 8fa40010 lw r4,0x0010(r29)
0019e808: 0c067bc9 jal 0x0019ef2 Check if Status Should/Can be Added
0019e80c: 3406001f ori r6,r0,0x001f Check for Wall
0019e810: 1040000b beq r2,r0,0x0019e840 <Elemental Null> if unit doesn't have wall
0019e814: 00000000 nop
0019e818: 8fc2000c lw r2,0x000c(r30)
0019e81c: 00000000 nop
0019e820: 30420020 andi r2,r2,0x0020
0019e824: 104001b2 beq r2,r0,0x0019eef0           Ability doesn't cancel Wall, don't use
0019e828: 00001021 addu r2,r0,r0
0019e82c: 93c2000a lbu r2,0x000a(r30)             load status infliction 4
0019e830: 00000000 nop
0019e834: 30420001 andi r2,r2,0x0001
0019e838: 104001ad beq r2,r0,0x0019eef0           Ability doesn't cancel Wall, don't use
0019e83c: 00001021 addu r2,r0,r0



The AI hardcoding for Charm, Confuse, and DS is hard to bypass because they are in several places. Charging a spell, however, will supersede the ignore hardcoding.
24
PSX FFT Hacking / Re: Dokurider's Custom AoEs
March 08, 2017, 09:31:39 pm
So I just finished uploading every AI routine I've documented so far. Some are okay, but many of them are from my early research and thus are spotty and lacking in understanding like some of the later works. However, know this: I am no where near done working not just on AI research, but on formatting and notes. They will all look something like this when I'm finished.

Anyways, I hope you all take some time to look through what has been uploaded and I hope they help you all in your endeavors. As always, feel free to drop me any questions or concerns. Thank you.
25
PSX FFT Hacking / Re: Dokurider's Custom AoEs
February 28, 2017, 11:53:45 pm
New Movement: Range + 2

Replaces Jump + 3. This movement skill will increase the range (red squares) of any ability provided:


  • The Ability ID is less than 0x0170. This excludes Jump, Throw and Item.


  • The Ability is not using Weapon Range, so it does not increase the range of Attack, Charge or anything of the sort.


  • The Ability's range is 2 or greater.



This ability will not overflow. At 254 Range, it will add +1 Range instead and at 255 Range, it will do nothing.

The AI is aware of this change and should expand their target acquisitioning accordingly.

Oh and this hack does not come with any text changes. You have to do that yourselves.

Known Bugs: The game will still display Jump + 3 adding Jump while being selected to be added to a unit in the Formation Screen. The Unit Data Screen however wiil still correctly display that Jump + 3 did not add any Jump at all once added to the unit. It has no mechanical impact on the game.
lol idk where display code is.



Range + 2 (Normal Version)

Old:
0005c950: 10400002 beq r2,r0,0x0005c95c Branch if Unit doesn't have Jump + 3
0005c954: 30a2ffff andi r2,r5,0xffff
0005c958: 24630003 addiu r3,r3,0x0003 Jump += 3

0017a304: 90470001 lbu r7,0x0001(r2)        load AoE
0017a308: 90530000 lbu r19,0x0000(r2)       load Range
0017a30c: a3a70028 sb r7,0x0028(r29)        save AoE to stack

00195ce0: 90620000 lbu r2,0x0000(r3) Load Ability's Range
00195ce4: 00000000 nop
00195ce8: a2020004 sb r2,0x0004(r16) Store Range = Ability's Range


New:
0005c958: 00000000 nop [deleted Jump + 3]

0017a304: C04C050C jal 0x00153300 Range + 2
0017a308: 00000000 nop
0017a30c: 00000000 nop

00195ce0: D74C050C jal 0x0015335c AI Range + 2
00195ce4: 00000000 nop
00195ce8: 00000000 nop

00153300: 01004790 lbu r7,0x0001(r2)        load AoE
00153304: 00005390 lbu r19,0x0000(r2)       load Range
00153308: 2800A7A3 sb r7,0x0028(r29)        save AoE to stack
0015330c: 03004790 lbu r7,0x0003(r2)        load Ability Flags 1
00153310: 1200A387 lh r3,0x0012(r29)        Load Ability ID
00153314: 93009692 lbu r22,0x0093(r20) Load Movement 1
00153318: 7001632C sltiu r3,r3,0x0170
0015331c: 0D006010 beq r3,r0,0x00153354 Exit if Ability is 0x170 or greater (Throw, Jump and Item)
00153320: 2000E730 andi r7,r7,0x0020
00153324: 0B00E014 bne r7,r0,0x00153354 Exit if Weapon Range
00153328: 0400D632 andi r22,r22,0x0004
0015332c: 0900C012 beq r22,r0,0x00153354 Exit if no Range + 2 (Jump + 3)
00153330: 0200632E sltiu r3,r19,0x0002
00153334: 07006014 bne r3,r0,0x00153354 Exit if Range is less than 2
00153338: FF000334 ori r3,r0,0x00ff
0015333c: 05006312 beq r19,r3,0x00153354 Exit if Range is 255
00153340: FE000334 ori r3,r0,0x00fe
00153344: 02006312 beq r19,r3,0x00153350 Increase Range by 1 if 254 Range
00153348: 01000334 ori r3,r0,0x0001
0015334c: 02000334 ori r3,r0,0x0002
00153350: 21986302 addu r19,r19,r3 Range + 2
00153354: 0800E003 jr r31
00153358: 00000000 nop

0015335c: 03006290 lbu r2,0x0003(r3) Load Ability Flags
00153360: 00000000 nop
00153364: 20004230 andi r2,r2,0x0020
00153368: 04004014 bne r2,r0,0x0015337c Reload Ability Range if Weapon Range
0015336c: 00000234 ori r2,r0,0x0000 Makes branch always jump
00153370: 93004292 lbu r2,0x0093(r18) Load Unit's Movement 1
00153374: 00000000 nop
00153378: 04004230 andi r2,r2,0x0004
0015337c: 0B004010 beq r2,r0,0x001533ac Exit if no Range + 2 (Jump + 3)
00153380: 00006490 lbu r4,0x0000(r3) Load Ability's Range
00153384: 00000000 nop
00153388: 0200822C sltiu r2,r4,0x0002
0015338c: 07004014 bne r2,r0,0x001533ac Exit if Range is less than 2
00153390: 00000000 nop
00153394: FF000234 ori r2,r0,0x00ff
00153398: 04004410 beq r2,r4,0x001533ac Exit if Range is 255
0015339c: FE000234 ori r2,r0,0x00fe
001533a0: 02004410 beq r2,r4,0x001533ac
001533a4: 01008424 addiu r4,r4,0x0001 Range + 1 (Increases 254 to 255)
001533a8: 01008424 addiu r4,r4,0x0001 Range + 2 (1 + 1)
001533ac: 0800E003 jr r31
001533b0: 040004A2 sb r4,0x0004(r16) Store Range = Ability's Range



As always, let me know if you find anything glitches or bugs.
26
FFT Arena / Re: SCC Tournament, Season 3, Formal Thread
February 27, 2017, 04:33:33 am
Nothing for Round 1 because I already watched that when it came out.


Initial Impressions (Before watching the match proper):
Paladins
Being defensive is not a problem, but it has to be done properly and you do that by having good sandbag. Lay on Hands (and Reraise) is good, if reflectable, but Revive is...Revive.
Yeah the one unit with Reflect is going to be the last to go down, but that's about the opposite of what you want, you want the big balances, and you want them soon. Ancient Sword alone would have been sufficient; with Luck Up, dangerous. Two Swording the Sleeping Ancient on an average PA Paladin? Meh. Finger Guard, at the very least, ended up being a fortuitous pick up against a Mediator team ofc. Concentrated Chaos is underrated, and the Southern Cross pick up is some badly needed, but probably not enough in the end. Talk Skill Paladin would have liked to have been faster.
Overall, I don't see this team winning sandbag wars even with its sheer bulk.

Mediators
Bringing the guns as expected. Having both Stone and Faith gun makes provides good coverage barring Projectile Guard. Add Talk Skills to the mix and you have a SCC team that's always considered one of the teams to beat.

That being said, I think this team could have just relied on double item for revival and might have been just fine. Instead, having the Stone Gunner run Item might end up being a distraction. Lay on Hands is okay, but unBrave is just so unwieldy and I'm glad it's losing that aspect next patch. It's a real shame that the Pilgrimgunner isn't running Magic Attack Up or even Fire Strengthen, when I think just White Robe would have been acceptable vs enemy Pilgrims. A good offense is a good defense as they say.

Prediction:
Mediators have the speed, reach, sandbag, damage, and status advantage. Paladins have the...HP advantage? I don't really see these Paladins coming even close to grinding out a win here

Reaction:
Hmm, yeah even with that phenomenal opening for GB, his team still didn't have enough of a real offense to maintain a lead and it just ended up swinging right back to WKW. Come the big map, it wasn't even a contest. Kudos to GB for making a unit that can take two gunshots to the face and not get sent into critical, at least. Also Revive maintains it's record of being the shittiest revive in the game. Texan-Canadian Cabal, please.

On the flip side, the units that WKW needs to be on the offensive aren't being offensive consistently enough because they have too many skills they don't need in the end. Against a more aggressive and streamlined team, these mediators are going to find themselves on the backfoot more often then they should be.



Initial Impressions (Before watching the match proper):
Wizards
Sure I missed a tourney, or a bajillion, but this Wizard team is probably the most solid Wizard team one could create within the SCC restrictions. The first Wizard acting as a bumper unit to draw aggro, then the other wizards are free to drop spells everywhere, including Map Lores. This is actually a pretty scary team I think.

Chemists
I think that these Chemists are going to run into a similar problem WKW's mediator have in that the units that need to be on the offensive may go picking up units when they need to be attacking. Having both potions in play though, is the Chemist team's big strength in this tourney. Again we see the Magic/Stone combo to get around non Projectile Guard defenses. The surprise Ice Absorption is a nice touch, but understandably hard to pull off with the Item Highlander Rule. Again, Axel Rose is fierce, but him having the Phoenix Down is going to be a weakpoint in this team.

Prediction:
Too late, already watched, lopl.

Reaction:
I think Vigilante might have been able to take a fight off of Barren in a Medium Map, but yeah this Wizard team is working pretty well it seems. It's easy to call it decisive, but remember that Wizards will lose just as hard as they win.
But yeah, the Second Turn Wizards are real.



Initial Impressions (Before watching the match proper):
Ninjas
Nice solid aggressive team. The units that need to be aggressive will for the most part stay aggressive. My only concern is the reliance on White Magic. Trying to sandbag through item sucks these days, I know, but Ninjas are fast enough to do a decent job at it.

Monks
At least someone likes that show.This team is rather offbeat. Focusing on using Knight Swords can work, even within an SCC setting, but these units have way too many skills, Revive skills in particular. Secret Fist is always a bad mix with high damage team setups because those setups can kill faster than DS can. I think a more tried and true straightforward approach might work out better here.

Prediction:
These Ninjas are pretty efficient and hard hitting. I'm pretty sure they take apart these Monks no problem.

Reaction:
Uh.
Yeah.
Okay.



It might take a while, but I'll get around to everyone's vids.
27
I think we have a problem here.
28
Help! / Re: Elemental ability/Masshex weirdness
February 21, 2017, 04:32:29 pm
It's MassHex's fault, Xif.

And yeah, I'm using the latest version (v13).
29
The Lounge / Re: FFT Bad Gameplay Habits
February 07, 2017, 11:11:42 am
Leaving Help messages on lol. I still refuse to turn them off even after all these years. It's just a part of the game to me at this point.
30
Player: Dokurider
Team: Gossip Circle
Palettes: Blue/Green
Last Revision: 2016-08-08

================================

Big Fibber
Male
Serpentarius
70
45
Lancer
Talk Skill
Dragon Spirit
Defense Up
Jump + 1
Heavy Spear
Dewdrop Shield
Diamond Helmet
Crystal Armor
Sprint Shoes

Jump Range 4, Jump Vertical 7
Warn, Stall, Refute, Mimic Daravon

================================

Straight Story
Male
Serpentarius
45
45
Lancer
Item
Auto Potion
Throw Item
Move HP Up
Holy Lance
Crystal Shield
Diamond Helmet
Crystal Armor
Defense Ring

Hi-Potion, Antidote, Chrono's Tear, Echo Grass, Maiden's Kiss, Soft, Holy Water, Bandage, Phoenix Down

================================

Last Word
Female
Serpentarius
45
45
Chemist
Dance
Auto Potion
Equip Armor
Maintenance
Main Gauche

Gold Helmet
Diamond Armor
Wizard Mantle

Hi-Potion, Ether, Antidote, Chrono's Tear, Echo Grass, Maiden's Kiss, Soft, Holy Water, Bandage, Phoenix Down
Last Dance

================================

Whale of a Tale
Female
Serpentarius
70
45
Samurai
Steal
Projectile Guard
Equip Polearm
Move +1
Whale Whisker

Crystal Helmet
Platina Armor
Vanish Mantle

Bizen Boat, Muramasa, Kikuichimonji
Quickening, Steal Heart, Speed Ruin

================================

Player: Dokurider
Team: Make It Rain
Palettes: Blue/Black
Last Revision: 2016-08-02

================================

Water Hammer
Male
Serpentarius
70
40
Ninja
Snipe
Counter
Attack UP
Move-HP Up
Aspergillum
Aspergillum
Green Beret
Brigandine
Chantage

Tsumazuku, Fuuton, Suiton, Misogi
Seal Evil, Armor Break

================================

Current
Female
Serpentarius
45
70
Time Mage
Summon Magic
Caution
Short Charge
Pilgrimage
Healing Staff
Dewdrop Shield
Golden Hairpin
Silk Robe
Defense Ring

Stop, Comet, Sinkhole, Demi
Moogle, Fairy, Carbunkle, Lich

================================

Scald
Male
Serpentarius
70
55
Samurai
Chivalry
PA Save
Attack UP

Asura Knife

Gold Helmet
Black Robe
Chantage

Heaven's Cloud, Masamune
Iron Will, Grand Cross

================================

Rainmaker
Female
Serpentarius
45
70
Priest
Lore

Magic Attack UP
Move-MP Up
Wizard Staff

Black Hood
Rubber Costume
108 Gems

Raise, Raise 2, Esuna
Maelstrom, Bio 3

================================

Player: Dokurider
Team: Oregon Trail
Palettes: White/Yellow
Last Revision: 2016-08-02

================================

Wagoneer
Female
Serpentarius
45
70
Time Mage
White Magic
Piety
Short Charge
Move-MP Up
Healing Staff
Crystal Shield
Triangle Hat
Light Robe
Defense Ring

Slow 2, Comet, Sinkhole
Cure, Raise, Esuna

================================

Pilgrimgunner
Female
Serpentarius
45
70
Archer
Yin Yang Magic
Absorb MP
Magic Attack UP
Pilgrimage
Blast Gun

Thief Hat
Brigandine
108 Gems

Leg Aim, Seal Evil, Execute, Armor Break
Douse, Paralyze

================================

ShootMoreBuffalo
Female
Serpentarius
45
70
Archer
Yin Yang Magic
Absorb MP
Magic Attack UP
Pilgrimage
Blast Gun

Thief Hat
Brigandine
108 Gems

Arm Aim, Seal Evil, Execute, Shield Break
Douse, Beguile, Petrify

================================

Ford Or Caulk
Female
Serpentarius
45
70
Time Mage
White Magic
Piety
Short Charge
Move-MP Up
Healing Staff
Crystal Shield
Triangle Hat
Light Robe
Defense Ring

Haste 2, Comet, Sinkhole
Cure, Raise, Esuna

================================

Player: Dokurider
Team: Ultimate Magic
Palettes: White/Black
Last Revision: 2016-08-08

================================

Deathspell 2
Female
Serpentarius
45
70
Priest
Summon Magic
Dragon Spirit
Short Charge

Necronomicon

Golden Hairpin
Silk Robe
Defense Ring

Cure 2, Cure 4, Raise, Raise 2, Regen, Esuna, Dia
Odin

================================

Snake Carrier
Male
Serpentarius
45
45
Paladin
Sing
Absorb MP
1/3 of MP

Rune Blade
Ice Shield
Diamond Helmet
Crystal Armor
Defense Ring

Lay on Hands, Nurse, Consecration, Transfusion, Iron Will, Reraise
Magic Song

================================

Midgar Swarm
Female
Serpentarius
45
70
Mediator
Draw Out
Dragon Spirit
Magic Attack UP

Glacier Gun

Triangle Hat
Black Robe
Sprint Shoes

Blackmail, Warn, Stall, Refute
Asura, Masamune

================================

Ultima
Male
Serpentarius
45
45
Bard
Basic Skill
Finger Guard
Magic Attack UP
Move-MP Up
Ramia Harp

Holy Miter
Wizard Outfit
Magic Gauntlet

Alacrity, Throw Stone, Ultima

================================

Player: Dokurider
Team: Four Support One I
Palettes: Green/Red
Last Revision: 2016-08-24

================================

Emulsifier
Male
Serpentarius
55
40
Thief
Item
Auto Potion
Defense Up

Short Edge

Black Hood
Brigandine
Defense Ring

Quickening, Steal Heart
Hi-Potion, Hi-Ether, Antidote, Chrono's Tear, Echo Grass, Maiden's Kiss, Soft, Holy Water, Bandage, Phoenix Down

================================

Imp
Male
Serpentarius
45
45
Lancer
Item
Auto Potion
Throw Item
Jump + 1
Demon Spear
Swift Plate
Diamond Helmet
Diamond Armor
N-Kai Armlet

Jump Range 5, Jump Vertical 6
Hi-Potion, Hi-Ether, Antidote, Chrono's Tear, Echo Grass, Maiden's Kiss, Soft, Holy Water, Bandage, Phoenix Down

================================

Dark Lord
Female
Serpentarius
45
70
Time Mage
Lore
Regenerator
Magic Attack Up
Move MP Up
Black Staff
Diamond Shield
Golden Hairpin
White Robe
Reflect Ring

Stop, Comet, Sinkhole, Demi
Shadow Shade

================================

Weapon Master I
Male
Serpentarius
65
45
Squire
Punch Art
MP Switch
Martial Arts
Move + 1
Gambler's Axe
Swift Plate
Thief Hat
Secret Clothes
Cursed Ring

Accumulate, Heal, Wish
Stigma Magic, Chakra, Revive

================================




The following are ported teams from the past versions, with the intention of being tested against. If the original team maker does not want his team up, I will take it down immediately.

Player: DomieV
Team: Famous Knights
Palettes: Yellow/Red
Last Revision: 2017-02-02

================================

Arthur
Male
Libra
70
50
Paladin
Basic Skill
Abandon
Concentrate
Move-HP Up
Defender

Cross Helmet
Diamond Armor
Leather Mantle

Southern Cross
Accumulate, Heal, Wish

================================

George
Male
Gemini
40
70
Paladin
Time Magic
Damage Split
1/3 of MP
Move-MP Up
H Bag
Escutcheon II
Diamond Helmet
Linen Robe
Sprint Shoes

Sinkhole, Balance, Demi

================================

Lancelot
Male
Aquarius
40
70
Paladin
White Magic
Auto Potion
Magic Defense UP

Rune Blade
Escutcheon II
Cross Helmet
White Robe
Wizard Mantle

Nurse, Consecration, Transfusion, Reraise
Raise, Raise 2, Esuna

================================

Page
Male
Libra
70
50
Paladin
Item
Abandon
Throw Item
Move-HP Up
Ancient Sword
Crystal Shield
Diamond Helmet
White Robe
Wizard Mantle

Hi-Potion, Hi-Ether, Antidote, Maiden's Kiss, Soft, Bandage, Phoenix Down

================================


Player: FDC
Team: EXECUTE
Palettes: Red/White
Last Revision: 2017-02-02

================================

TONSPAMEXE
Male
Serpentarius
70
40
Monk
Ninjitsu
Absorb MP
Attack UP
Move-HP Up
FS Bag

Focus Band
Power Sleeve
108 Gems

Shuriken, Meiton, Fuuton, Suiton, Misogi

================================

KIKUCROSSEXE
Male
Serpentarius
70
40
Monk
Chivalry
Absorb MP
Equip Heavy Blade
Move-HP Up
Kikuichimonji

Focus Band
Earth Clothes
Bracer

Earth Slash
Nurse, Reraise, Grand Cross

================================

BATTLESONGEXE
Male
Serpentarius
70
40
Monk
Sing
HP Restore
Martial Arts
Warpath

Choice Band
Black Costume
Diamond Armlet

Spin Fist, Repeating Fist, Aurablast, Stigma Magic, Chakra, Revive
Battle Song

================================

ESLASHEXE
Male
Serpentarius
70
40
Monk
Basic Skill
Counter Tackle
Martial Arts

FS Bag

Chakra Band
Earth Clothes
Bracer

Spin Fist, Repeating Fist, Aurablast, Earth Slash, Stigma Magic, Chakra, Revive
Accumulate, Wish

================================


Player: Wiz
Team: {S1}
Palettes: Brown/Blue
Last Revision: 2017-02-02

================================

ILoveYouDissy
Female
Serpentarius
40
40
Mediator
Draw Out
Finger Guard
Defense UP
Move-HP Up
H Bag

Thief Hat
Brigandine
Setiemson

Insult
Murasame, Kiyomori, Masamune

================================

AndYouLoveThee
Female
Serpentarius
40
40
Mediator
Draw Out
Finger Guard
Defense UP
Move-HP Up
H Bag

Thief Hat
Brigandine
Setiemson

Insult
Murasame, Kiyomori, Masamune

================================

SoLetsGetItOn
Male
Serpentarius
40
40
Thief
Item
Auto Potion
Unyielding
Maintenance
Hidden Knife

Golden Hairpin
Black Costume
Angel Ring

Quickening, Steal Heart
X-Potion, Antidote, Chrono's Tear, Maiden's Kiss, Soft, Holy Water, Bandage, Phoenix Down

================================

MountainDewMe
Male
Serpentarius
40
40
Thief
Item
Auto Potion
Unyielding
Maintenance
Hidden Knife

Golden Hairpin
Santa Outfit
Angel Ring

Quickening, Steal Heart
X-Potion, Antidote, Chrono's Tear, Maiden's Kiss, Soft, Holy Water, Bandage, Phoenix Down

================================
31
Xifanie, I can't seem to import any .xml into the spreadsheet unless at least one hack contains an Variable line.
32
Hacking/Patching Tools / Re: Special Snowflakes v1.00
January 23, 2017, 11:45:28 am
With this, I'm soon to be poised to release my very own lol patch with the most bossest of slapped together ASM and imported anime characters.
33
Targeting Reflect Units


<Reflect Check>
0019e6cc: 10a0000b beq r5,r0,0x0019e6fc Bypass Reflect Check <Faith Check>
0019e6d0: 00000000 nop
0019e6d4: 8fc2000c lw r2,0x000c(r30) Load Usage
0019e6d8: 00000000 nop
0019e6dc: 30424000 andi r2,r2,0x4000
0019e6e0: 10400006 beq r2,r0,0x0019e6fc             <Faith Check> if not reflectable
0019e6e4: 02c02821 addu r5,r22,r0 Get Unit Data Pointer
0019e6e8: 8fa40010 lw r4,0x0010(r29) Get Clockticks
0019e6ec: 0c067bc9 jal 0x0019ef24 Check if Status Should/Can be Added
0019e6f0: 34060026 ori r6,r0,0x0026 Check for Reflect
0019e6f4: 144001fe bne r2,r0,0x0019eef0 Unit has Reflect, don't use
0019e6f8: 00001021 addu r2,r0,r0


I forgot to finish talking about this.

Apparently, the AI sets if it wants to bypass targeting Reflect units with Reflect or not. So why the hell would it try to target Reflectunits with a Reflectable spell? To use that unit to bounce Reflect off of course. This is merely the start of how the AI banks spells off of Reflect units.



How the AI mitigates Spells

<Faith Check>
0019e6fc: 8fc2000c lw r2,0x000c(r30) Load Usage
0019e700: 00000000 nop
0019e704: 30420400 andi r2,r2,0x0400
0019e708: 10400006 beq r2,r0,0x0019e724              <Jump Check> if not faith ability
0019e70c: 02c02821 addu r5,r22,r0
0019e710: 8fa40010 lw r4,0x0010(r29)
0019e714: 0c067bc9 jal 0x0019ef2 Check if Status Should/Can be Added
0019e718: 34060021 ori r6,r0,0x0021 Check for Innocent
0019e71c: 144001f4 bne r2,r0,0x0019eef0 Unit has Innocent, don't use
0019e720: 00001021 addu r2,r0,r0

<Jump Check>
0019e724: 8fa40010 lw r4,0x0010(r29)
0019e728: 02c02821 addu r5,r22,r0
0019e72c: 0c067bc9 jal 0x0019ef2 Check if Status Should/Can be Added
0019e730: 34060005 ori r6,r0,0x0005 Check for Jump
0019e734: 144001ee bne r2,r0,0x0019eef0 Unit is Jumping, don't use
0019e738: 00001021 addu r2,r0,r0

<If Wall>
0019e804: 8fa40010 lw r4,0x0010(r29)
0019e808: 0c067bc9 jal 0x0019ef2 Check if Status Should/Can be Added
0019e80c: 3406001f ori r6,r0,0x001f Check for Wall
0019e810: 1040000b beq r2,r0,0x0019e840 <Elemental Null> if unit doesn't have wall
0019e814: 00000000 nop
0019e818: 8fc2000c lw r2,0x000c(r30)
0019e81c: 00000000 nop
0019e820: 30420020 andi r2,r2,0x0020
0019e824: 104001b2 beq r2,r0,0x0019eef0           Ability doesn't cancel Wall, don't use
0019e828: 00001021 addu r2,r0,r0
0019e82c: 93c2000a lbu r2,0x000a(r30)             load status infliction 4
0019e830: 00000000 nop
0019e834: 30420001 andi r2,r2,0x0001
0019e838: 104001ad beq r2,r0,0x0019eef0           Ability doesn't cancel Wall, don't use
0019e83c: 00001021 addu r2,r0,r0

<Float>
0019e864: 16820008 bne r20,r2,0x0019e888 Skip Float Evaluation if not Earth Elemental
0019e868: 00000000 nop
0019e86c: 92c2005a lbu r2,0x005a(r22) Load Current Status 3
0019e870: 00000000 nop
0019e874: 30420040 andi r2,r2,0x0040
0019e878: 10400003 beq r2,r0,0x0019e888            <Undead Reverse> if not float
0019e87c: 00000000 nop
0019e880: 08067bbc j 0x0019eef0 Unit has float, don't use ability
0019e884: 00001021 addu r2,r0,r0


So how does the AI attempt to mitigate spells? If the unit can't midcharge the spell directly, it will then ask this question: "Hypothetically, if I had Innocent, Reflect, Jump, Wall or Float, would this ability I have null the spell being targeted on me?" And if this routine returns 0, "Yes, it will mitigate the spell." then it enables usage. It's a theory I have however. I have to actually see if the governing routines do this, but I think it's pretty likely it does.
34
Quote from: Eternal on January 21, 2017, 08:07:03 am
Great work as always. This topic is really fascinating. Thoughts on Float though: I know I've seen it use Float outside of Critical after seeing an Earth spell. Heck, I think I've seen it used before an Earth spell was used, but the AI still "saw" it in the party's skillset.

You're certainly right. I'm positive there's an auxiliary usage routine that enables usage to mitigate spells/the midcharge behavior. Adding Reflect, Innocent, interrupting a unit's spell, all very well documented behaviors. I'll certainly keep an eye out for them.

EDIT: Oh wait, duh, it's right there in my face. I'll explain in a minute, I forgot to talk about the Reflect Bypass anyways.
35
PSX FFT Hacking / Re: auto-battle ai brainstorming
January 21, 2017, 04:37:03 am
Oh hey there, you are just in luck. I just so happen to be working out how the AI works in this very topic, and I just made a new post about how the AI restricts ability use. It's by no means complete, because the AI is complex and wild beast, and it's not exactly exactly what you're looking for, but perhaps you'd be interested all the same? If nothing else, it's a nice read.

One of the things I am trying to do is stop the AI from fidgeting so much. The trick to figuring out how to stop the AI from moving all the time is to figure out when the AI won't move of their own free will. I have seen them decide to not move, but it's so rare for that to happen, I don't recall any of the details of when that happened.

I know a bit on AI movement, but not enough to really form a definitive, or even a coherent statement yet and it's also not my current priority. You can try to look through the routines on the wiki and try to decode them yourself if you're desperate and/or impatient. But for now, we're stuck with me working at a snail's pace.
36
Hey folks, got another section for you guys.

AI Ability Use (19e5d8) has been known about for a while, but only lightly documented until now. This routine doesn't really so much decide what abilities to use, so much as says what abilities to not use. Nevertheless what you're about to read will enlighten you.


AI Ability Use

r5 = 0 or 1 (bypass reflect)

Return r2:
0 = Unusable
1 = OK to use
2 = Not OK to use

0019e5d8: 27bdffc0 addiu r29,r29,0xffc0
0019e5dc: afbe0038 sw r30,0x0038(r29)
0019e5e0: 3c1e801a lui r30,0x801a
0019e5e4: 27def3c4 addiu r30,r30,0xf3c4              r30 = AI data
0019e5e8: 000410c0 sll r2,r4,0x03
0019e5ec: 00441023 subu r2,r2,r4
0019e5f0: 00021180 sll r2,r2,0x06
0019e5f4: 3c038019 lui r3,0x8019
0019e5f8: 246308cc addiu r3,r3,0x08cc                r3 = Unit Data
0019e5fc: afb60030 sw r22,0x0030(r29)
0019e600: 0043b021 addu r22,r2,r3
0019e604: 00041100 sll r2,r4,0x04
0019e608: 2442182c addiu r2,r2,0x182c                r2 = decision data
0019e60c: afb70034 sw r23,0x0034(r29)
0019e610: 005eb821 addu r23,r2,r30                   r23 = decision data
0019e614: 3c02801a lui r2,0x801a
0019e618: 8c42f3d0 lw r2,-0x0c30(r2) Load AI Ability Flags
0019e61c: 3c07801a lui r7,0x801a
0019e620: 90e7f3c5 lbu r7,-0x0c3b(r7)                Load Unit AI Pointer
0019e624: 3c032000 lui r3,0x2000
0019e628: afbf003c sw r31,0x003c(r29)
0019e62c: afb5002c sw r21,0x002c(r29)
0019e630: afb40028 sw r20,0x0028(r29)
0019e634: afb30024 sw r19,0x0024(r29)
0019e638: afb20020 sw r18,0x0020(r29)
0019e63c: afb1001c sw r17,0x001c(r29)
0019e640: afb00018 sw r16,0x0018(r29)

<Enemy/Ally Targeting>
0019e644: 00431024 and r2,r2,r3
0019e648: 10400005 beq r2,r0,0x0019e660 Branch if can target allies
0019e64c: afa70010 sw r7,0x0010(r29)
0019e650: 92e20008 lbu r2,0x0008(r23)                load enemy flag
0019e654: 00000000 nop
0019e658: 10400225 beq r2,r0,0x0019eef0              Don't use this skill on an Ally you can't hit anyways
0019e65c: 00001021 addu r2,r0,r0
0019e660: 8fc2000c lw r2,0x000c(r30)                 load ability AI behavior flags
0019e664: 3c034000 lui r3,0x4000
0019e668: 00431024 and r2,r2,r3
0019e66c: 10400005 beq r2,r0,0x0019e684              <Target Self> if can target enemies
0019e670: 00000000 nop
0019e674: 92e20008 lbu r2,0x0008(r23)                load enemy flag
0019e678: 00000000 nop
0019e67c: 1440021c bne r2,r0,0x0019eef0             Don't use this skill on an enemy you can't target anyways
0019e680: 00001021 addu r2,r0,r0

<Target Self>
0019e684: 93c20e2e lbu r2,0x0e2e(r30)                load acting unit id
0019e688: 00000000 nop
0019e68c: 1482000f bne r4,r2,0x0019e6cc              <Reflect Check> if unit is not self
0019e690: 00000000 nop
0019e694: 87c30002 lh r3,0x0002(r30)                 load ability ID
0019e698: 00000000 nop
0019e69c: 28620170 slti r2,r3,0x0170
0019e6a0: 1040000a beq r2,r0,0x0019e6cc <Reflect Check> if Ability is a normal skill
0019e6a4: 000310c0 sll r2,r3,0x03
0019e6a8: 00431023 subu r2,r2,r3
0019e6ac: 00021040 sll r2,r2,0x01
0019e6b0: 3c018006 lui r1,0x8006
0019e6b4: 00220821 addu r1,r1,r2
0019e6b8: 9022fbf4 lbu r2,-0x040c(r1)               load ability flags
0019e6bc: 00000000 nop
0019e6c0: 30420001 andi r2,r2,0x0001
0019e6c4: 1440020a bne r2,r0,0x0019eef0             Exit because you can't hit yourself with this spell
0019e6c8: 00001021 addu r2,r0,r0

<Reflect Check>
0019e6cc: 10a0000b beq r5,r0,0x0019e6fc Bypass Reflect Check <Faith Check>
0019e6d0: 00000000 nop
0019e6d4: 8fc2000c lw r2,0x000c(r30) Load Usage
0019e6d8: 00000000 nop
0019e6dc: 30424000 andi r2,r2,0x4000
0019e6e0: 10400006 beq r2,r0,0x0019e6fc             <Faith Check> if not reflectable
0019e6e4: 02c02821 addu r5,r22,r0 Get Unit Data Pointer
0019e6e8: 8fa40010 lw r4,0x0010(r29) Get Clockticks
0019e6ec: 0c067bc9 jal 0x0019ef24 Check if Status Should/Can be Added
0019e6f0: 34060026 ori r6,r0,0x0026 Check for Reflect
0019e6f4: 144001fe bne r2,r0,0x0019eef0 Unit has Reflect, don't use
0019e6f8: 00001021 addu r2,r0,r0

<Faith Check>
0019e6fc: 8fc2000c lw r2,0x000c(r30) Load Usage
0019e700: 00000000 nop
0019e704: 30420400 andi r2,r2,0x0400
0019e708: 10400006 beq r2,r0,0x0019e724              <Jump Check> if not faith ability
0019e70c: 02c02821 addu r5,r22,r0
0019e710: 8fa40010 lw r4,0x0010(r29)
0019e714: 0c067bc9 jal 0x0019ef2 Check if Status Should/Can be Added
0019e718: 34060021 ori r6,r0,0x0021 Check for Innocent
0019e71c: 144001f4 bne r2,r0,0x0019eef0 Unit has Innocent, don't use
0019e720: 00001021 addu r2,r0,r0

<Jump Check>
0019e724: 8fa40010 lw r4,0x0010(r29)
0019e728: 02c02821 addu r5,r22,r0
0019e72c: 0c067bc9 jal 0x0019ef2 Check if Status Should/Can be Added
0019e730: 34060005 ori r6,r0,0x0005 Check for Jump
0019e734: 144001ee bne r2,r0,0x0019eef0 Unit is Jumping, don't use
0019e738: 00001021 addu r2,r0,r0

<If Dead>
0019e73c: 8fc2000c lw r2,0x000c(r30) Load Usage
0019e740: 00000000 nop
0019e744: 30420020 andi r2,r2,0x0020
0019e748: 10400005 beq r2,r0,0x0019e760        <Dead with Reraise> if this ability doesn't cancel status
0019e74c: 0000a021 addu r20,r0,r0
0019e750: 93c20007 lbu r2,0x0007(r30)          load status infliction 1
0019e754: 00000000 nop
0019e758: 30420020 andi r2,r2,0x0020
0019e75c: 0002a02b sltu r20,r0,r2              r20 = Unit is dead or spell will add dead

<Dead with Reraise>
0019e760: 92e20007 lbu r2,0x0007(r23)          load type of target
0019e764: 00000000 nop
0019e768: 30420040 andi r2,r2,0x0040
0019e76c: 10400009 beq r2,r0,0x0019e794        <Dead> if unit doesn't have reraise as well
0019e770: 00000000 nop
0019e774: 93d00001 lbu r16,0x0001(r30)         load CT
0019e778: 0c0666e6 jal 0x00199b98 Calculate Clockticks Until Unit Acts
0019e77c: 02c02021 addu r4,r22,r0
0019e780: 0202802a slt r16,r16,r2
0019e784: 1600003e bne r16,r0,0x0019e880 Don't use this ability because unit will get up before then
0019e788: 00000000 nop
0019e78c: 168001d8 bne r20,r0,0x0019eef0 Unit is dead but has reraise, don't revive
0019e790: 00001021 addu r2,r0,r0

<Dead>
0019e794: 92e20007 lbu r2,0x0007(r23)
0019e798: 00000000 nop
0019e79c: 30420020 andi r2,r2,0x0020
0019e7a0: 10400009 beq r2,r0,0x0019e7c8        <If Petrified> if not even dead
0019e7a4: 00000000 nop
0019e7a8: 93d00001 lbu r16,0x0001(r30)
0019e7ac: 0c066722 jal 0x00199c88 Get number of clockticks till able to revive dead unit
0019e7b0: 02c02021 addu r4,r22,r0
0019e7b4: 0050102a slt r2,r2,r16
0019e7b8: 14400031 bne r2,r0,0x0019e880 It's too late to revive this unit (Won't be able to go off in time)
0019e7bc: 00000000 nop
0019e7c0: 128001cb beq r20,r0,0x0019eef0 Ability doesn't cure Dead, don't use
0019e7c4: 00001021 addu r2,r0,r0

<If Petrified>
0019e7c8: 92c20059 lbu r2,0x0059(r22) Load Current Status 2
0019e7cc: 00000000 nop
0019e7d0: 30420080 andi r2,r2,0x0080
0019e7d4: 1040000b beq r2,r0,0x0019e804        <If Wall> if not petrified
0019e7d8: 02c02821 addu r5,r22,r0
0019e7dc: 8fc2000c lw r2,0x000c(r30) Load AI Ability Flags
0019e7e0: 00000000 nop
0019e7e4: 30420020 andi r2,r2,0x0020
0019e7e8: 104001c1 beq r2,r0,0x0019eef0         Ability doesn't cure Petrify, don't use
0019e7ec: 00001021 addu r2,r0,r0
0019e7f0: 93c20008 lbu r2,0x0008(r30)           load status infliction 2
0019e7f4: 00000000 nop
0019e7f8: 30420080 andi r2,r2,0x0080
0019e7fc: 104001bc beq r2,r0,0x0019eef0         Ability doesn't use Petrify, don't use
0019e800: 00001021 addu r2,r0,r0

<If Wall>
0019e804: 8fa40010 lw r4,0x0010(r29)
0019e808: 0c067bc9 jal 0x0019ef2 Check if Status Should/Can be Added
0019e80c: 3406001f ori r6,r0,0x001f Check for Wall
0019e810: 1040000b beq r2,r0,0x0019e840 <Elemental Null> if unit doesn't have wall
0019e814: 00000000 nop
0019e818: 8fc2000c lw r2,0x000c(r30)
0019e81c: 00000000 nop
0019e820: 30420020 andi r2,r2,0x0020
0019e824: 104001b2 beq r2,r0,0x0019eef0           Ability doesn't cancel Wall, don't use
0019e828: 00001021 addu r2,r0,r0
0019e82c: 93c2000a lbu r2,0x000a(r30)             load status infliction 4
0019e830: 00000000 nop
0019e834: 30420001 andi r2,r2,0x0001
0019e838: 104001ad beq r2,r0,0x0019eef0           Ability doesn't cancel Wall, don't use
0019e83c: 00001021 addu r2,r0,r0

<Elemental Null>
0019e840: 93d40010 lbu r20,0x0010(r30)             load ability elements
0019e844: 00000000 nop
0019e848: 1280000f beq r20,r0,0x0019e888 <Undead Reverse> if no elements
0019e84c: 00000000 nop
0019e850: 92c2006e lbu r2,0x006e(r22)             Load target elemental nullification
0019e854: 00000000 nop
0019e858: 02821024 and r2,r20,r2
0019e85c: 12820008 beq r20,r2,0x0019e880 This unit blocks the element, don't use this ability
0019e860: 34020008 ori r2,r0,0x0008

<Float>
0019e864: 16820008 bne r20,r2,0x0019e888 Skip Float Evaluation if not Earth Elemental
0019e868: 00000000 nop
0019e86c: 92c2005a lbu r2,0x005a(r22) Load Current Status 3
0019e870: 00000000 nop
0019e874: 30420040 andi r2,r2,0x0040
0019e878: 10400003 beq r2,r0,0x0019e888            <Undead Reverse> if not float
0019e87c: 00000000 nop
0019e880: 08067bbc j 0x0019eef0 Unit has float, don't use ability
0019e884: 00001021 addu r2,r0,r0

<Target Enemies>
<Undead Reverse>
0019e888: 8fc3000c lw r3,0x000c(r30)
0019e88c: 00000000 nop
0019e890: 30620002 andi r2,r3,0x0002
0019e894: 10400074 beq r2,r0,0x0019ea68            <Target Allies> if not target enemies
0019e898: 30622000 andi r2,r3,0x2000
0019e89c: 1040000f beq r2,r0,0x0019e8dc            <Elemental Absorb> if this ability doesn't reverse on undead
0019e8a0: 00000000 nop
0019e8a4: 92e20008 lbu r2,0x0008(r23)
0019e8a8: 00000000 nop
0019e8ac: 10400004 beq r2,r0,0x0019e8c0            <Healing Undead Ally> if ally
0019e8b0: 00000000 nop
0019e8b4: 92c20058 lbu r2,0x0058(r22) Load Current Status 1
0019e8b8: 08067a3f j 0x0019e8fc
0019e8bc: 30420010 andi r2,r2,0x0010             r2 = undead check

<Healing Undead Ally>
0019e8c0: 92c20058 lbu r2,0x0058(r22) Current Status 1
0019e8c4: 00000000 nop
0019e8c8: 30420010 andi r2,r2,0x0010
0019e8cc: 14400050 bne r2,r0,0x0019ea10           <HP Ability> if ally = undead
0019e8d0: 00000000 nop
0019e8d4: 08067bbc j 0x0019eef0 Ally isn't Undead, this will hurt them
0019e8d8: 34020002 ori r2,r0,0x0002

<Elemental Absorb>
0019e8dc: 92e20008 lbu r2,0x0008(r23)         load enemy flag
0019e8e0: 00000000 nop
0019e8e4: 10400009 beq r2,r0,0x0019e90c       <Charmed Ally> if Ally
0019e8e8: 02c02821 addu r5,r22,r0
0019e8ec: 92c2006d lbu r2,0x006d(r22)        Elemental absorb
0019e8f0: 93c30010 lbu r3,0x0010(r30)         load ability elements
0019e8f4: 00000000 nop
0019e8f8: 00431024 and r2,r2,r3               absorbs & elements
0019e8fc: 10400044 beq r2,r0,0x0019ea10       <HP Ability> if no elements being absorbed by enemies/Enemy is undead
0019e900: 34020002 ori r2,r0,0x0002
0019e904: 08067bbc j 0x0019eef0 Don't use this ability because it'll heal them
0019e908: 00000000 nop

<Charmed Ally>
0019e90c: 8fa40010 lw r4,0x0010(r29)
0019e910: 0c067bc9 jal 0x0019ef2 Check if Status Should/Can be Added
0019e914: 34060022 ori r6,r0,0x0022 Check for Charm
0019e918: 10400005 beq r2,r0,0x0019e930 Branch if unit doesn't have any Charm
0019e91c: 02c02021 addu r4,r22,r0
0019e920: 0c067bec jal 0x0019efb0 Check if Charm, Don't Act or Move can be added before unit acts
0019e924: 34050022 ori r5,r0,0x0022 Check for Charm
0019e928: 14400002 bne r2,r0,0x0019e934 Branch if it can be removed in time
0019e92c: 34140001 ori r20,r0,0x0001 Charm is present
0019e930: 0000a021 addu r20,r0,r0 Target has no Charm

0019e934: 8fc2000c lw r2,0x000c(r30)        Load AI Flags   
0019e938: 00000000 nop
0019e93c: 30420080 andi r2,r2,0x0080
0019e940: 10400015 beq r2,r0,0x0019e998         <Elemental Healing> if not hp affecting ability (Why?)
0019e944: 00000000 nop
0019e948: 93c20000 lbu r2,0x0000(r30)           load skillset
0019e94c: 3c018006 lui r1,0x8006
0019e950: 00220821 addu r1,r1,r2
0019e954: 90235cb4 lbu r3,0x5cb4(r1)             load action byte
0019e958: 3402000a ori r2,r0,0x000a
0019e95c: 1062000e beq r3,r2,0x0019e998         <Elemental Healing> if Charge
0019e960: 00000000 nop

<Break Confuse>
0019e964: 92c20059 lbu r2,0x0059(r22) Load Current Status 2
0019e968: 00000000 nop
0019e96c: 30420010 andi r2,r2,0x0010
0019e970: 1440015f bne r2,r0,0x0019eef0         Break Confuse
0019e974: 34020001 ori r2,r0,0x0001
<Break Sleep>
0019e978: 8fa40010 lw r4,0x0010(r29)
0019e97c: 02c02821 addu r5,r22,r0
0019e980: 0c067bc9 jal 0x0019ef2 Check if Status Should/Can be Added
0019e984: 34060023 ori r6,r0,0x0023 Check for Sleep
0019e988: 14400046 bne r2,r0,0x0019eaa4 Break Sleep
0019e98c: 00000000 nop
<Break Charm>
0019e990: 16800157 bne r20,r0,0x0019eef0 Break Charm with this ability
0019e994: 34020001 ori r2,r0,0x0001

<Elemental Healing>
0019e998: 92c2006d lbu r2,0x006d(r22)           Elemental absorb
0019e99c: 93c30010 lbu r3,0x0010(r30)           load elements
0019e9a0: 00000000 nop
0019e9a4: 00431024 and r2,r2,r3                elements & absorbs
0019e9a8: 10400006 beq r2,r0,0x0019e9c4         <Don't Attack Ally> if unit doesn't absorb this element
0019e9ac: 00000000 nop
0019e9b0: 92e20007 lbu r2,0x0007(r23)           AI Decision Flag
0019e9b4: 00000000 nop
0019e9b8: 30420001 andi r2,r2,0x0001
0019e9bc: 1440014c bne r2,r0,0x0019eef0         Heal this unit if they have >50% HP
0019e9c0: 34020001 ori r2,r0,0x0001

<Don't Attack Ally>
0019e9c4: 92c20059 lbu r2,0x0059(r22) Load Current Status 2
0019e9c8: 00000000 nop
0019e9cc: 30420014 andi r2,r2,0x0014
0019e9d0: 14400003 bne r2,r0,0x0019e9e0         <Disable Ally> if confusion or blood suck
0019e9d4: 00000000 nop
0019e9d8: 12800145 beq r20,r0,0x0019eef0 No reason to attack an ally then
0019e9dc: 34020002 ori r2,r0,0x0002

<Disable Ally>
0019e9e0: 8fc2000c lw r2,0x000c(r30)       
0019e9e4: 00000000 nop
0019e9e8: 30420010 andi r2,r2,0x0010
0019e9ec: 1040ffb9 beq r2,r0,0x0019e8d4         Branch to Exit if no add status; No reason to use this on an ally (Why branch all the way up there?)
0019e9f0: 3c031c06 lui r3,0x1c06                 Sleep, Don't Move, Don't Act, Slow and Stop
0019e9f4: 8fc20008 lw r2,0x0008(r30)
0019e9f8: 00000000 nop
0019e9fc: 00431024 and r2,r2,r3
0019ea00: 1440013b bne r2,r0,0x0019eef0          Use only these statuses to deal with Confused/Blood Suck Allies
0019ea04: 34020001 ori r2,r0,0x0001
0019ea08: 08067bbc j 0x0019eef0 Don't use any other status
0019ea0c: 34020002 ori r2,r0,0x0002

<HP Ability>
0019ea10: 8fc2000c lw r2,0x000c(r30)
0019ea14: 00000000 nop
0019ea18: 30420080 andi r2,r2,0x0080
0019ea1c: 10400006 beq r2,r0,0x0019ea38          <MP Ability> if not HP affecting
0019ea20: 00000000 nop
0019ea24: 92c2005c lbu r2,0x005c(r22) Load Current Status 5
0019ea28: 00000000 nop
0019ea2c: 30420001 andi r2,r2,0x0001
0019ea30: 1040012f beq r2,r0,0x0019eef0         Attack Enemy unless Death Sentence
0019ea34: 34020001 ori r2,r0,0x0001

<MP Ability>
0019ea38: 8fc2000c lw r2,0x000c(r30)           
0019ea3c: 00000000 nop
0019ea40: 30420040 andi r2,r2,0x0040
0019ea44: 10400007 beq r2,r0,0x0019ea64          <Target Allies> if not MP affecting
0019ea48: 00000000 nop
0019ea4c: 96c3002c lhu r3,0x002c(r22)           Load mp
0019ea50: 92e2000a lbu r2,0x000a(r23)            load lowest mp cost
0019ea54: 00000000 nop
0019ea58: 0043102b sltu r2,r2,r3
0019ea5c: 14400124 bne r2,r0,0x0019eef0          This unit has enough MP to cast his lowest MP ability
0019ea60: 34020001 ori r2,r0,0x0001

<Target Allies>
0019ea64: 8fc3000c lw r3,0x000c(r30)
0019ea68: 00000000 nop
0019ea6c: 30620001 andi r2,r3,0x0001
0019ea70: 10400036 beq r2,r0,0x0019eb4c          <Target Ally and Enemy> if not target allies
0019ea74: 30622000 andi r2,r3,0x2000
0019ea78: 1040000f beq r2,r0,0x0019eab8          <Allied Ability> if no Undead Reverse
0019ea7c: 00000000 nop
0019ea80: 92e20008 lbu r2,0x0008(r23)            load enemy flag
0019ea84: 00000000 nop
0019ea88: 10400008 beq r2,r0,0x0019eaac          <Allied Ability> if Ally
0019ea8c: 00000000 nop
0019ea90: 92c30058 lbu r3,0x0058(r22) Load Current Status 1
0019ea94: 00000000 nop
0019ea98: 30630010 andi r3,r3,0x0010
0019ea9c: 10600114 beq r3,r0,0x0019eef0          This unit isn't undead, no reason to heal this enemy
0019eaa0: 34020002 ori r2,r0,0x0002
0019eaa4: 08067bbc j 0x0019eef0 Heal Undead for damage
0019eaa8: 34020001 ori r2,r0,0x0001

<Allied Ability>
0019eaac: 92c20058 lbu r2,0x0058(r22) Load Current Status 1
0019eab0: 08067aaf j 0x0019eabc Jump to check
0019eab4: 30420010 andi r2,r2,0x0010                undead check

0019eab8: 92e20008 lbu r2,0x0008(r23)
0019eabc: 00000000 nop
0019eac0: 1440010b bne r2,r0,0x0019eef0             Don't heal Enemy/Undead Ally
0019eac4: 34020002 ori r2,r0,0x0002
0019eac8: 92c2005c lbu r2,0x005c(r22) Load Current Status 5             
0019eacc: 00000000 nop
0019ead0: 30420001 andi r2,r2,0x0001
0019ead4: 10400009 beq r2,r0,0x0019eafc             <Heal HP> if not death sentence
0019ead8: 00000000 nop
0019eadc: 8fc3000c lw r3,0x000c(r30) Load AI Flags
0019eae0: 00000000 nop
0019eae4: 30630010 andi r3,r3,0x0010
0019eae8: 10600101 beq r3,r0,0x0019eef0            Don't use this ability because it doesn't add Reraise
0019eaec: 00001021 addu r2,r0,r0
0019eaf0: 93c20009 lbu r2,0x0009(r30) Load Inflicted Status 3
0019eaf4: 08067bbb j 0x0019eeec Check if Reraise before exiting
0019eaf8: 30420020 andi r2,r2,0x0020               

<Heal HP>
0019eafc: 8fc2000c lw r2,0x000c(r30)
0019eb00: 00000000 nop
0019eb04: 30420080 andi r2,r2,0x0080
0019eb08: 10400006 beq r2,r0,0x0019eb24              <Heal MP> if not HP ability
0019eb0c: 00000000 nop
0019eb10: 92e20007 lbu r2,0x0007(r23) Load AI Targeting
0019eb14: 00000000 nop
0019eb18: 30420001 andi r2,r2,0x0001
0019eb1c: 144000f4 bne r2,r0,0x0019eef0             Heal unit if low hp (less than 50%)
0019eb20: 34020001 ori r2,r0,0x0001

<Heal MP>
0019eb24: 8fc2000c lw r2,0x000c(r30)
0019eb28: 00000000 nop
0019eb2c: 30420040 andi r2,r2,0x0040
0019eb30: 10400006 beq r2,r0,0x0019eb4c            <Target Ally and Enemy> if ability doesn't affect MP
0019eb34: 00000000 nop
0019eb38: 92e20007 lbu r2,0x0007(r23)
0019eb3c: 00000000 nop
0019eb40: 30420002 andi r2,r2,0x0002
0019eb44: 144000ea bne r2,r0,0x0019eef0            Heal unit's MP if low mp (less than 50%)
0019eb48: 34020001 ori r2,r0,0x0001

<Target Ally and Enemy>
0019eb4c: 8fc3000c lw r3,0x000c(r30)
0019eb50: 00000000 nop
0019eb54: 30620003 andi r2,r3,0x0003
0019eb58: 14400006 bne r2,r0,0x0019eb74            <Adding Status> if target enemies or target allies
0019eb5c: 30620080 andi r2,r3,0x0080

0019eb60: 144000e3 bne r2,r0,0x0019eef0            This ability deals damage so it's fine to use
0019eb64: 34020001 ori r2,r0,0x0001
0019eb68: 30620040 andi r2,r3,0x0040
0019eb6c: 144000e0 bne r2,r0,0x0019eef0            This ability deals MP Damage so it's fine to use
0019eb70: 34020001 ori r2,r0,0x0001

<Adding status>
0019eb74: 8fc2000c lw r2,0x000c(r30)
0019eb78: 00000000 nop
0019eb7c: 30420010 andi r2,r2,0x0010
0019eb80: 10400073 beq r2,r0,0x0019ed50            <Cancel Status> if no add status
0019eb84: 00000000 nop
0019eb88: 0000a021 addu r20,r0,r0
0019eb8c: 03d41021 addu r2,r30,r20
0019eb90: 02d41821 addu r3,r22,r20
0019eb94: 90500007 lbu r16,0x0007(r2) Load Inflicted Status List
0019eb98: 90620058 lbu r2,0x0058(r3)              load Current status
0019eb9c: 00000000 nop
0019eba0: 02021024 and r2,r16,r2                 
0019eba4: 02028026 xor r16,r16,r2        Remove statuses already present         
0019eba8: 12000065 beq r16,r0,0x0019ed40          <Status++> if inflicting status that's already there/no status in that block
0019ebac: 00000000 nop
0019ebb0: 90620053 lbu r2,0x0053(r3)              load status immunity
0019ebb4: 00000000 nop
0019ebb8: 02021024 and r2,r16,r2
0019ebbc: 02028026 xor r16,r16,r2 Remove status immunities
0019ebc0: 1200005f beq r16,r0,0x0019ed40 <Status++> if unit is immune to status/no statuses in that block
0019ebc4: 34020002 ori r2,r0,0x0002
0019ebc8: 1282001f beq r20,r2,0x0019ec48 <Current Status 3>
0019ebcc: 2a820003 slti r2,r20,0x0003
0019ebd0: 10400005 beq r2,r0,0x0019ebe8 <Current Status 4 and 5>
0019ebd4: 34020001 ori r2,r0,0x0001
0019ebd8: 1282000a beq r20,r2,0x0019ec04 Go to <Current Status 2>
0019ebdc: 32020008 andi r2,r16,0x0008 Check for Silence
0019ebe0: 08067b4e j 0x0019ed38 <Confirm Status>
0019ebe4: 00000000 nop

<Current Status 4 and 5>
0019ebe8: 34020003 ori r2,r0,0x0003
0019ebec: 1282002e beq r20,r2,0x0019eca8 <Current Status 4>
0019ebf0: 34020004 ori r2,r0,0x0004
0019ebf4: 1282004a beq r20,r2,0x0019ed20 <Current Status 5>
0019ebf8: 00000000 nop
0019ebfc: 08067b4e j 0x0019ed38 <Confirm Status>
0019ec00: 00000000 nop

<Current Status 2>
<Silence>
0019ec04: 10400007 beq r2,r0,0x0019ec24 <Blind> if not Silenced
0019ec08: 32020020 andi r2,r16,0x0020 Check for Blind
0019ec0c: 92e2000c lbu r2,0x000c(r23)               Load Silenceable Abilities Modifier
0019ec10: 00000000 nop
0019ec14: 14400003 bne r2,r0,0x0019ec24             <Blind> if Target has any Silenceable ability (Silence Modifier)
0019ec18: 32020020 andi r2,r16,0x0020 Check for Blind
0019ec1c: 3a100008 xori r16,r16,0x0008 Remove Silence because unit doesn't have Silenceable abilities
0019ec20: 32020020 andi r2,r16,0x0020 Check for Blind
<Blind>
0019ec24: 10400044 beq r2,r0,0x0019ed38 <Confirm Status> if not adding Blind
0019ec28: 00000000 nop
0019ec2c: 92e2000d lbu r2,0x000d(r23)               load Evadable Abilities Modifier
0019ec30: 00000000 nop
0019ec34: 2c420002 sltiu r2,r2,0x0002               
0019ec38: 1040003f beq r2,r0,0x0019ed38             <Confirm Status> if Evade Mod > 1 (Greater than 25% of abilities learned)
0019ec3c: 00000000 nop
0019ec40: 08067b4e j 0x0019ed38 <Confirm Status>
0019ec44: 3a100020 xori r16,r16,0x0020 Remove Blind because Unit doesn't have enough Evadable abilities

<Current Status 3>
<Reraise>
0019ec48: 32020020 andi r2,r16,0x0020
0019ec4c: 10400008 beq r2,r0,0x0019ec70 <Frog> if not adding Reraise
0019ec50: 32020002 andi r2,r16,0x0002
0019ec54: 92e20007 lbu r2,0x0007(r23) Load AI Targeting
0019ec58: 00000000 nop
0019ec5c: 30420001 andi r2,r2,0x0001
0019ec60: 14400003 bne r2,r0,0x0019ec70              <Frog> if low hp (>50%) unit
0019ec64: 32020002 andi r2,r16,0x0002 Check for Frog
0019ec68: 3a100020 xori r16,r16,0x0020 Don't add Reraise if not at 50% HP or less
0019ec6c: 32020002 andi r2,r16,0x0002 Check for Frog
<Frog>
0019ec70: 10400006 beq r2,r0,0x0019ec8c <Float> if not adding Frog
0019ec74: 00000000 nop
0019ec78: 92e20008 lbu r2,0x0008(r23)                load enemy flag
0019ec7c: 00000000 nop
0019ec80: 14400002 bne r2,r0,0x0019ec8c              <Float> if enemy
0019ec84: 00000000 nop
0019ec88: 3a100002 xori r16,r16,0x0002 Remove Frog (don't turn your allies into frogs I guess)
<Float>
0019ec8c: 92e20007 lbu r2,0x0007(r23)                 
0019ec90: 00000000 nop
0019ec94: 30420080 andi r2,r2,0x0080
0019ec98: 14400027 bne r2,r0,0x0019ed38              <Confirm Status> if critical hp unit
0019ec9c: 00000000 nop
0019eca0: 08067b4e j 0x0019ed38 <Confirm Status>
0019eca4: 321000bf andi r16,r16,0x00bf Don't add Float unless critical (lol)

<Current Status 4>
<Regen>
0019eca8: 32020040 andi r2,r16,0x0040
0019ecac: 10400007 beq r2,r0,0x0019eccc <Protect/Shell/Wall> if not adding Regen
0019ecb0: 00000000 nop
0019ecb4: 92e20007 lbu r2,0x0007(r23)               
0019ecb8: 00000000 nop
0019ecbc: 30420001 andi r2,r2,0x0001
0019ecc0: 14400002 bne r2,r0,0x0019eccc              <Protect/Shell/Wall> if low hp unit
0019ecc4: 00000000 nop
0019ecc8: 3a100040 xori r16,r16,0x0040 Remove Regen (Don't add Regen unless at 50% or less HP)
<Protect/Shell/Wall>
0019eccc: 92e20007 lbu r2,0x0007(r23)
0019ecd0: 00000000 nop
0019ecd4: 30420080 andi r2,r2,0x0080
0019ecd8: 14400003 bne r2,r0,0x0019ece8             <Haste/Slow> if critical hp unit
0019ecdc: 3202000c andi r2,r16,0x000c Check for Haste/Slow
0019ece0: 321000ce andi r16,r16,0x00ce Remove Protect/Shell/Wall (Don't add Protect/Shell/Wall unless Critical)
0019ece4: 3202000c andi r2,r16,0x000c Check for Haste/Slow
<Haste/Slow>
0019ece8: 10400013 beq r2,r0,0x0019ed38 <Confirm Status> if not adding Haste/Slow
0019ecec: 00000000 nop
0019ecf0: 92c2005b lbu r2,0x005b(r22)        Load Current Status 4
0019ecf4: 00000000 nop
0019ecf8: 30420002 andi r2,r2,0x0002
0019ecfc: 14400006 bne r2,r0,0x0019ed18          Branch to remove/not add Haste/Slow if Stop
0019ed00: 00000000 nop
0019ed04: 92c2005c lbu r2,0x005c(r22) Load Current Status 5
0019ed08: 00000000 nop
0019ed0c: 30420010 andi r2,r2,0x0010
0019ed10: 10400009 beq r2,r0,0x0019ed38          <Confirm Status> if not sleep
0019ed14: 00000000 nop
0019ed18: 08067b4e j 0x0019ed38 <Confirm Status>
0019ed1c: 321000f3 andi r16,r16,0x00f3 Remove Haste/Slow

<Current Status 5>
<Faith/Reflect>
0019ed20: 92e20007 lbu r2,0x0007(r23)
0019ed24: 00000000 nop
0019ed28: 30420080 andi r2,r2,0x0080
0019ed2c: 14400002 bne r2,r0,0x0019ed38             <Confirm Status> if critical hp unit
0019ed30: 00000000 nop
0019ed34: 3210007d andi r16,r16,0x007d Remove Faith and Reflect (Don't add Faith/Reflect unless critical)

<Confirm Status>
0019ed38: 1600006d bne r16,r0,0x0019eef0 Ability is adding a status
0019ed3c: 34020001 ori r2,r0,0x0001

<Status++>
0019ed40: 26940001 addiu r20,r20,0x0001 Next Status Block
0019ed44: 2a820005 slti r2,r20,0x0005
0019ed48: 1440ff91 bne r2,r0,0x0019eb90 Loop until Current Status 5
0019ed4c: 03d41021 addu r2,r30,r20
</Add Status>

<Cancel Status>
0019ed50: 8fc2000c lw r2,0x000c(r30)
0019ed54: 00000000 nop
0019ed58: 30420020 andi r2,r2,0x0020
0019ed5c: 1040004e beq r2,r0,0x0019ee98          <Affect Stats> if not cancel status
0019ed60: 00000000 nop
0019ed64: 0000a021 addu r20,r0,r0
0019ed68: 03d41021 addu r2,r30,r20
0019ed6c: 02d41821 addu r3,r22,r20
0019ed70: 90500007 lbu r16,0x0007(r2)            load status infliction
0019ed74: 90620058 lbu r2,0x0058(r3)             load current status
0019ed78: 00000000 nop
0019ed7c: 02028024 and r16,r16,r2
0019ed80: 12000041 beq r16,r0,0x0019ee88         <Cancel++> if unit doesn't have statuses to be removed
0019ed84: 00000000 nop
0019ed88: 9062004e lbu r2,0x004e(r3)             load innate status
0019ed8c: 00000000 nop
0019ed90: 02021024 and r2,r16,r2
0019ed94: 02028026 xor r16,r16,r2
0019ed98: 1200003b beq r16,r0,0x0019ee88        <Cancel++> if unit's status is innate and cannot be removed
0019ed9c: 2a820003 slti r2,r20,0x0003
0019eda0: 14400019 bne r2,r0,0x0019ee08 <Cancel Status 1 - 3>
0019eda4: 34020001 ori r2,r0,0x0001

<Cancel Status 4 and 5>
0019eda8: 00009021 addu r18,r0,r0
0019edac: 0014a8c0 sll r21,r20,0x03 r21 = Cancel Status
0019edb0: 34070080 ori r7,r0,0x0080 r7 = 0x0080
0019edb4: 02479807 srav r19,r7,r18 r19 = 80 >> Current Status (0 - 4)
0019edb8: 02131024 and r2,r16,r19
0019edbc: 1040000d beq r2,r0,0x0019edf4 <Next Status> if not Canceling that status
0019edc0: 00000000 nop
0019edc4: 8fa40010 lw r4,0x0010(r29)
0019edc8: 02c02821 addu r5,r22,r0
0019edcc: 02b28821 addu r17,r21,r18
0019edd0: 0c067bc9 jal 0x0019ef2 Check if Status Should/Can be Added
0019edd4: 02203021 addu r6,r17,r0 Check for [current status]
0019edd8: 10400005 beq r2,r0,0x0019edf0 Remove Cancel Status if status can't be removed/isn't there
0019eddc: 02c02021 addu r4,r22,r0
0019ede0: 0c067bec jal 0x0019efb0 Check if Charm, Don't Act or Don't Move can be added/removed? before unit acts
0019ede4: 02202821 addu r5,r17,r0
0019ede8: 14400002 bne r2,r0,0x0019edf4 <Next Status> if all statuses, but especially Charm/Don't Act/Don't Move can be removed in time
0019edec: 00000000 nop
0019edf0: 02138026 xor r16,r16,r19 Remove Cancel Status if status can't be removed/isn't there/Can't be removed in time
<Next Status>
0019edf4: 26520001 addiu r18,r18,0x0001
0019edf8: 2a420008 slti r2,r18,0x0008
0019edfc: 1440ffed bne r2,r0,0x0019edb4 Go through all statuses
0019ee00: 34070080 ori r7,r0,0x0080
0019ee04: 34020001 ori r2,r0,0x0001

<Cancel Status 1 - 3>
0019ee08: 12820005 beq r20,r2,0x0019ee20 <Cancel Status 2>
0019ee0c: 34020002 ori r2,r0,0x0002
0019ee10: 12820014 beq r20,r2,0x0019ee64 <Cancel Status 3>
0019ee14: 32020002 andi r2,r16,0x0002
0019ee18: 08067ba0 j 0x0019ee80 <Confirm Cancel> (Nothing special for Cancel Status 1)
0019ee1c: 00000000 nop

<Cancel Status 2>
<Silence>
0019ee20: 32020008 andi r2,r16,0x0008
0019ee24: 10400007 beq r2,r0,0x0019ee44 <Blind> if ability doesn't cancel Silence
0019ee28: 32020020 andi r2,r16,0x0020 Check for Blind
0019ee2c: 92e2000c lbu r2,0x000c(r23) Load Silenceable Ability Mod
0019ee30: 00000000 nop
0019ee34: 14400003 bne r2,r0,0x0019ee44             <Blind> if unit has any silenceable abilities
0019ee38: 32020020 andi r2,r16,0x0020 Check for Blind
0019ee3c: 3a100008 xori r16,r16,0x0008 Remove Silence
0019ee40: 32020020 andi r2,r16,0x0020 Check for Blind
<Blind>
0019ee44: 1040000e beq r2,r0,0x0019ee80 <Confirm Cancel> if not cancel Blind
0019ee48: 00000000 nop
0019ee4c: 92e2000d lbu r2,0x000d(r23) Load Evadable Ability Mod
0019ee50: 00000000 nop
0019ee54: 1440000a bne r2,r0,0x0019ee80             <Confirm Cancel> if unit has any evadeable abilities
0019ee58: 00000000 nop
0019ee5c: 08067ba0 j 0x0019ee80 <Confirm Cancel>
0019ee60: 3a100020 xori r16,r16,0x0020 Remove Blind

<Cancel Status 3>
0019ee64: 10400006 beq r2,r0,0x0019ee80 <Confirm Cancel> if no cancel Frog
0019ee68: 00000000 nop
0019ee6c: 92e20008 lbu r2,0x0008(r23)          Load Enemy Flag     
0019ee70: 00000000 nop
0019ee74: 10400002 beq r2,r0,0x0019ee80             <Confirm Cancel> if ally
0019ee78: 00000000 nop
0019ee7c: 3a100002 xori r16,r16,0x0002 Remove Frog (Don't want to undo frog, now do we?)

<Confirm Cancel>
0019ee80: 1600001b bne r16,r0,0x0019eef0 Ability is canceling a status
0019ee84: 34020001 ori r2,r0,0x0001

<Cancel++>
0019ee88: 26940001 addiu r20,r20,0x0001 Next Cancel Status block
0019ee8c: 2a820005 slti r2,r20,0x0005
0019ee90: 1440ffb6 bne r2,r0,0x0019ed6c Branch if Cancel Status 5
0019ee94: 03d41021 addu r2,r30,r20
</Cancel Status>

<Affect Stats>
0019ee98: 8fc2000c lw r2,0x000c(r30)                load usage flags
0019ee9c: 00000000 nop
0019eea0: 30420008 andi r2,r2,0x0008
0019eea4: 1040000e beq r2,r0,0x0019eee0             <Unequip> if not affecting stats
0019eea8: 34020076 ori r2,r0,0x0076
0019eeac: 87c30002 lh r3,0x0002(r30)                load ability ID
0019eeb0: 00000000 nop
0019eeb4: 10620005 beq r3,r2,0x0019eecc             Skip RNG if Praise
0019eeb8: 34020092 ori r2,r0,0x0092
0019eebc: 10620003 beq r3,r2,0x0019eecc             Skip RNG if Accumulate
0019eec0: 34020096 ori r2,r0,0x0096
0019eec4: 1462000a bne r3,r2,0x0019eef0             Roll the dice on any other stat ability besides Yell
0019eec8: 34020001 ori r2,r0,0x0001
0019eecc: 0c0088c3 jal 0x0002230 Random Number Generator
0019eed0: 00000000 nop
0019eed4: 30420001 andi r2,r2,0x0001
0019eed8: 10400005 beq r2,r0,0x0019eef0            Use stat abilities randomly (!)
0019eedc: 34020001 ori r2,r0,0x0001

<Unequip>
0019eee0: 8fc2000c lw r2,0x000c(r30)             
0019eee4: 00000000 nop
0019eee8: 30420004 andi r2,r2,0x0004              Check if ability is Unequip
0019eeec: 0002102b sltu r2,r0,r2                  Use Ability if true

<Exit>
0019eef0: 8fbf003c lw r31,0x003c(r29)
0019eef4: 8fbe0038 lw r30,0x0038(r29)
0019eef8: 8fb70034 lw r23,0x0034(r29)
0019eefc: 8fb60030 lw r22,0x0030(r29)
0019ef00: 8fb5002c lw r21,0x002c(r29)
0019ef04: 8fb40028 lw r20,0x0028(r29)
0019ef08: 8fb30024 lw r19,0x0024(r29)
0019ef0c: 8fb20020 lw r18,0x0020(r29)
0019ef10: 8fb1001c lw r17,0x001c(r29)
0019ef14: 8fb00018 lw r16,0x0018(r29)
0019ef18: 27bd0040 addiu r29,r29,0x0040
0019ef1c: 03e00008 jr r31
0019ef20: 00000000 nop



Comments and Observations


How Wall was supposed to be used - Part 1


<If Wall>
0019e804: 8fa40010 lw r4,0x0010(r29)
0019e808: 0c067bc9 jal 0x0019ef2 Check if Status Should/Can be Added
0019e80c: 3406001f ori r6,r0,0x001f Check for Wall
0019e810: 1040000b beq r2,r0,0x0019e840 <Elemental Null> if unit doesn't have wall
0019e814: 00000000 nop
0019e818: 8fc2000c lw r2,0x000c(r30)
0019e81c: 00000000 nop
0019e820: 30420020 andi r2,r2,0x0020
0019e824: 104001b2 beq r2,r0,0x0019eef0           Ability doesn't cancel Wall, don't use
0019e828: 00001021 addu r2,r0,r0
0019e82c: 93c2000a lbu r2,0x000a(r30)             load status infliction 4
0019e830: 00000000 nop
0019e834: 30420001 andi r2,r2,0x0001
0019e838: 104001ad beq r2,r0,0x0019eef0           Ability doesn't cancel Wall, don't use
0019e83c: 00001021 addu r2,r0,r0


So far, this routine prevents the AI from targeting Enemies with Ally Only spells (and vice versa), targeting itself if the spell can't target caster, targeting units with Reflect if spell is reflectable (there is a bypass option, more on this later), targeting Innocent units if a Faith spell, Petrified units unless the ability cures it, and Jumping units. Don't target enemy units that null/absorb your element or are undead and will absorb your damage. Don't revive units with Reraise. They can even tell when it's too late to revive a unit and their spell won't go off in time. Most of this is expected and surprises no one. What might though is that Wall actually has code here.

This is about what you'd expect: Don't target units with Wall, duh. That is, unless you can cancel the status. It's interesting that Wall was far enough along in development that it has it's own processing in this routine. I wasn't really expecting the AI to know how to handle Wall at all. Wall must have been removed from the game rather late in the game's development then. Maybe they realized that becoming invincible on command for 32 CT and still being able to act was kinda broken even for FFT? Even if you could dispel it?



How the AI breaks Charm/Confuse/Sleep with damage


<Charmed Ally>
0019e90c: 8fa40010 lw r4,0x0010(r29)
0019e910: 0c067bc9 jal 0x0019ef2 Check if Status Should/Can be Added
0019e914: 34060022 ori r6,r0,0x0022 Check for Charm
0019e918: 10400005 beq r2,r0,0x0019e930 Branch if unit doesn't have any Charm
0019e91c: 02c02021 addu r4,r22,r0
0019e920: 0c067bec jal 0x0019efb0 Check if Charm, Don't Act or Move can be added before unit acts
0019e924: 34050022 ori r5,r0,0x0022 Check for Charm
0019e928: 14400002 bne r2,r0,0x0019e934 Branch if it can be removed in time
0019e92c: 34140001 ori r20,r0,0x0001 Charm is present
0019e930: 0000a021 addu r20,r0,r0 Target has no Charm

0019e934: 8fc2000c lw r2,0x000c(r30)        Load AI Flags   
0019e938: 00000000 nop
0019e93c: 30420080 andi r2,r2,0x0080
0019e940: 10400015 beq r2,r0,0x0019e998         <Elemental Healing> if not hp affecting ability (Why?)
0019e944: 00000000 nop
0019e948: 93c20000 lbu r2,0x0000(r30)           load skillset
0019e94c: 3c018006 lui r1,0x8006
0019e950: 00220821 addu r1,r1,r2
0019e954: 90235cb4 lbu r3,0x5cb4(r1)             load action byte
0019e958: 3402000a ori r2,r0,0x000a
0019e95c: 1062000e beq r3,r2,0x0019e998         <Elemental Healing> if Charge
0019e960: 00000000 nop

<Break Confuse>
0019e964: 92c20059 lbu r2,0x0059(r22) Load Current Status 2
0019e968: 00000000 nop
0019e96c: 30420010 andi r2,r2,0x0010
0019e970: 1440015f bne r2,r0,0x0019eef0         Break Confuse
0019e974: 34020001 ori r2,r0,0x0001
<Break Sleep>
0019e978: 8fa40010 lw r4,0x0010(r29)
0019e97c: 02c02821 addu r5,r22,r0
0019e980: 0c067bc9 jal 0x0019ef2 Check if Status Should/Can be Added
0019e984: 34060023 ori r6,r0,0x0023 Check for Sleep
0019e988: 14400046 bne r2,r0,0x0019eaa4 Break Sleep
0019e98c: 00000000 nop
<Break Charm>
0019e990: 16800157 bne r20,r0,0x0019eef0 Break Charm with this ability
0019e994: 34020001 ori r2,r0,0x0001

<Elemental Healing>
0019e998: 92c2006d lbu r2,0x006d(r22)           Elemental absorb
0019e99c: 93c30010 lbu r3,0x0010(r30)           load elements
0019e9a0: 00000000 nop
0019e9a4: 00431024 and r2,r2,r3                elements & absorbs
0019e9a8: 10400006 beq r2,r0,0x0019e9c4         <Don't Attack Ally> if unit doesn't absorb this element
0019e9ac: 00000000 nop
0019e9b0: 92e20007 lbu r2,0x0007(r23)           AI Decision Flag
0019e9b4: 00000000 nop
0019e9b8: 30420001 andi r2,r2,0x0001
0019e9bc: 1440014c bne r2,r0,0x0019eef0         Heal this unit if they have >50% HP
0019e9c0: 34020001 ori r2,r0,0x0001

<Don't Attack Ally>
0019e9c4: 92c20059 lbu r2,0x0059(r22) Load Current Status 2
0019e9c8: 00000000 nop
0019e9cc: 30420014 andi r2,r2,0x0014
0019e9d0: 14400003 bne r2,r0,0x0019e9e0         <Disable Ally> if confusion or blood suck
0019e9d4: 00000000 nop
0019e9d8: 12800145 beq r20,r0,0x0019eef0 No reason to attack an ally then
0019e9dc: 34020002 ori r2,r0,0x0002


This is how the AI is allowed to target it's allies with damage abilities to break Charm/Confuse/Sleep. The AI is finnicky in removing Charm somewhat. It won't remove Charm if it can't get the spell off before the unit acts. It shouldn't matter for Throw Stone, but it might for everything else with a charge.

Speaking of Charge, the AI won't use Charge to break these statuses. Of course that leaves Jump on the table. This can be fixed to check for Charge and Jump, but it requires extra space to do so because of all the load delays. But since Arena doesn't use Charge, you could just have the game check for Jump instead. Then you should have no more Jumping on sleeping units.

There is also Elemental Healing here as well. It works the same way normal healing does (more on that later). What's really odd about it, is that if an ability has an Element, but doesn't deal HP damage, the AI thinks it's blocked by Absorption and won't use it! That is absolutely not the case for any non damage formula, most of which can't even accept/don't check for Elements in their spells, and there are no non damage spells in Vanilla that even have Elements. I actually think this might just be an oversight because it could have just branched to the very next section and it would have been very relevant for it to do so.

Also in theory, the AI, if you made a unit Always: Confused, should constantly attempt to break a unit's Confusion because it doesn't check if it's an innate like it does Sleep and Charm.



How the AI deals with Blood Suck units (and Confusion as well)

<Don't Attack Ally>
0019e9c4: 92c20059 lbu r2,0x0059(r22) Load Current Status 2
0019e9c8: 00000000 nop
0019e9cc: 30420014 andi r2,r2,0x0014
0019e9d0: 14400003 bne r2,r0,0x0019e9e0         <Disable Ally> if confusion or blood suck
0019e9d4: 00000000 nop
0019e9d8: 12800145 beq r20,r0,0x0019eef0 No reason to attack an ally then
0019e9dc: 34020002 ori r2,r0,0x0002

<Disable Ally>
0019e9e0: 8fc2000c lw r2,0x000c(r30)       
0019e9e4: 00000000 nop
0019e9e8: 30420010 andi r2,r2,0x0010
0019e9ec: 1040ffb9 beq r2,r0,0x0019e8d4         Branch to Exit if no add status; No reason to use this on an ally (Why branch all the way up there?)
0019e9f0: 3c031c06 lui r3,0x1c06                 Sleep, Don't Move, Don't Act, Slow and Stop
0019e9f4: 8fc20008 lw r2,0x0008(r30)
0019e9f8: 00000000 nop
0019e9fc: 00431024 and r2,r2,r3
0019ea00: 1440013b bne r2,r0,0x0019eef0          Use only these statuses to deal with Confused/Blood Suck Allies
0019ea04: 34020001 ori r2,r0,0x0001
0019ea08: 08067bbc j 0x0019eef0 Don't use any other status
0019ea0c: 34020002 ori r2,r0,0x0002


Another way that the AI deals with Blood Suck and Confused units (besides curing it), is to disable them with statuses. The AI will only use Sleep, Don't Move, Don't Act, Slow and Stop on Blood Suck and Confused units.

I have to disagree with having Confusion here at all. It's easy enough to cure, so a Confused Unit shouldn't be getting disabled by it's own units. Meanwhile, Blood Suck need harsher statuses to be dealt with. I used to just straight up kill Blood Sucked units when I couldn't heal them because it was easier to just remove BS that way and I think the AI should think this as well.



HP and MP Damage and Death Sentence

<HP Ability>
0019ea10: 8fc2000c lw r2,0x000c(r30)
0019ea14: 00000000 nop
0019ea18: 30420080 andi r2,r2,0x0080
0019ea1c: 10400006 beq r2,r0,0x0019ea38          <MP Ability> if not HP affecting
0019ea20: 00000000 nop
0019ea24: 92c2005c lbu r2,0x005c(r22) Load Current Status 5
0019ea28: 00000000 nop
0019ea2c: 30420001 andi r2,r2,0x0001
0019ea30: 1040012f beq r2,r0,0x0019eef0         Attack Enemy unless Death Sentence
0019ea34: 34020001 ori r2,r0,0x0001

<MP Ability>
0019ea38: 8fc2000c lw r2,0x000c(r30)           
0019ea3c: 00000000 nop
0019ea40: 30420040 andi r2,r2,0x0040
0019ea44: 10400007 beq r2,r0,0x0019ea64          <Target Allies> if not MP affecting
0019ea48: 00000000 nop
0019ea4c: 96c3002c lhu r3,0x002c(r22)           Load mp
0019ea50: 92e2000a lbu r2,0x000a(r23)            load lowest mp cost
0019ea54: 00000000 nop
0019ea58: 0043102b sltu r2,r2,r3
0019ea5c: 14400124 bne r2,r0,0x0019eef0          This unit has enough MP to cast his lowest MP ability
0019ea60: 34020001 ori r2,r0,0x0001

...

<Allied Ability>
0019eaac: 92c20058 lbu r2,0x0058(r22) Load Current Status 1
0019eab0: 08067aaf j 0x0019eabc Jump to check
0019eab4: 30420010 andi r2,r2,0x0010                undead check

0019eab8: 92e20008 lbu r2,0x0008(r23)
0019eabc: 00000000 nop
0019eac0: 1440010b bne r2,r0,0x0019eef0             Don't heal Enemy/Undead Ally
0019eac4: 34020002 ori r2,r0,0x0002
0019eac8: 92c2005c lbu r2,0x005c(r22) Load Current Status 5             
0019eacc: 00000000 nop
0019ead0: 30420001 andi r2,r2,0x0001
0019ead4: 10400009 beq r2,r0,0x0019eafc             <Heal HP> if not death sentence
0019ead8: 00000000 nop
0019eadc: 8fc3000c lw r3,0x000c(r30) Load AI Flags
0019eae0: 00000000 nop
0019eae4: 30630010 andi r3,r3,0x0010
0019eae8: 10600101 beq r3,r0,0x0019eef0            Don't use this ability because it doesn't add Reraise
0019eaec: 00001021 addu r2,r0,r0
0019eaf0: 93c20009 lbu r2,0x0009(r30) Load Inflicted Status 3
0019eaf4: 08067bbb j 0x0019eeec Check if Reraise before exiting
0019eaf8: 30420020 andi r2,r2,0x0020               



AI will not deal HP damage to Death Sentence. They will also use MP Damage until the unit can't cast anymore spells. This is not a surprise. What might be a surprise is that the AI won't use Ally Spells that don't add Reraise on them either...even if the spell in question would heal Death Sentence.
QuoteBut the AI cures Death Sentence all the time with Refute

That's actually because Refute is not an Ally or an Enemy spell. Ignoring Death Sentence units only applies when the spell in question is either an Ally or Enemy spell. Not being either bypasses this behavior, allowing for curing or attacking.



Healing HP and MP

<Heal HP>
0019eafc: 8fc2000c lw r2,0x000c(r30)
0019eb00: 00000000 nop
0019eb04: 30420080 andi r2,r2,0x0080
0019eb08: 10400006 beq r2,r0,0x0019eb24              <Heal MP> if not HP ability
0019eb0c: 00000000 nop
0019eb10: 92e20007 lbu r2,0x0007(r23) Load AI Targeting
0019eb14: 00000000 nop
0019eb18: 30420001 andi r2,r2,0x0001
0019eb1c: 144000f4 bne r2,r0,0x0019eef0             Heal unit if low hp (less than 50%)
0019eb20: 34020001 ori r2,r0,0x0001

<Heal MP>
0019eb24: 8fc2000c lw r2,0x000c(r30)
0019eb28: 00000000 nop
0019eb2c: 30420040 andi r2,r2,0x0040
0019eb30: 10400006 beq r2,r0,0x0019eb4c            <Target Ally and Enemy> if ability doesn't affect MP
0019eb34: 00000000 nop
0019eb38: 92e20007 lbu r2,0x0007(r23)
0019eb3c: 00000000 nop
0019eb40: 30420002 andi r2,r2,0x0002
0019eb44: 144000ea bne r2,r0,0x0019eef0            Heal unit's MP if low mp (less than 50%)
0019eb48: 34020001 ori r2,r0,0x0001


The AI will only heal HP and MP if the unit is under 50% of their respective stat. This is fine for HP, but it's very noticeable when attempting to heal MP. It's a hard 50% too.



How the AI adds statuses - Adding Blind and Silence

<Current Status 2>
<Silence>
0019ec04: 10400007 beq r2,r0,0x0019ec24 <Blind> if not Silenced
0019ec08: 32020020 andi r2,r16,0x0020 Check for Blind
0019ec0c: 92e2000c lbu r2,0x000c(r23)               Load Silenceable Abilities Modifier
0019ec10: 00000000 nop
0019ec14: 14400003 bne r2,r0,0x0019ec24             <Blind> if Target has any Silenceable ability (Silence Modifier)
0019ec18: 32020020 andi r2,r16,0x0020 Check for Blind
0019ec1c: 3a100008 xori r16,r16,0x0008 Remove Silence because unit doesn't have Silenceable abilities
0019ec20: 32020020 andi r2,r16,0x0020 Check for Blind
<Blind>
0019ec24: 10400044 beq r2,r0,0x0019ed38 <Confirm Status> if not adding Blind
0019ec28: 00000000 nop
0019ec2c: 92e2000d lbu r2,0x000d(r23)               load Evadable Abilities Modifier
0019ec30: 00000000 nop
0019ec34: 2c420002 sltiu r2,r2,0x0002               
0019ec38: 1040003f beq r2,r0,0x0019ed38             <Confirm Status> if Evade Mod > 1 (Greater than 50% of abilities learned)
0019ec3c: 00000000 nop
0019ec40: 08067b4e j 0x0019ed38 <Confirm Status>
0019ec44: 3a100020 xori r16,r16,0x0020 Remove Blind because Unit doesn't have enough Evadable abilities


First off, the routine checks if the status in question is already present or the target is immune to it, no surprises there.

The AI will only consider adding Blind and Silence if the respective modifiers are high enough. Recall that the AI keeps track of how many Silenceable and Blindable moves you know and it saves this value as 0-4, with 4 being 100% and 0 being less than 25%.

The AI will not even entertain adding Silence to a unit that has no silenceable statuses learned. Reasonable. However, the AI will not consider adding Blind if you have less than 50% P-Ev skills learned. This includes Attack and Frog Attack. This could probably be lowered to 25%.



How the AI adds statuses - Adding Reraise, Frog and Float


<Current Status 3>
<Reraise>
0019ec48: 32020020 andi r2,r16,0x0020
0019ec4c: 10400008 beq r2,r0,0x0019ec70 <Frog> if not adding Reraise
0019ec50: 32020002 andi r2,r16,0x0002
0019ec54: 92e20007 lbu r2,0x0007(r23) Load AI Targeting
0019ec58: 00000000 nop
0019ec5c: 30420001 andi r2,r2,0x0001
0019ec60: 14400003 bne r2,r0,0x0019ec70              <Frog> if low hp (>50%) unit
0019ec64: 32020002 andi r2,r16,0x0002 Check for Frog
0019ec68: 3a100020 xori r16,r16,0x0020 Don't add Reraise if not at 50% HP or less
0019ec6c: 32020002 andi r2,r16,0x0002 Check for Frog
<Frog>
0019ec70: 10400006 beq r2,r0,0x0019ec8c <Float> if not adding Frog
0019ec74: 00000000 nop
0019ec78: 92e20008 lbu r2,0x0008(r23)                load enemy flag
0019ec7c: 00000000 nop
0019ec80: 14400002 bne r2,r0,0x0019ec8c              <Float> if enemy
0019ec84: 00000000 nop
0019ec88: 3a100002 xori r16,r16,0x0002 Remove Frog (don't turn your allies into frogs I guess)
<Float>
0019ec8c: 92e20007 lbu r2,0x0007(r23)                 
0019ec90: 00000000 nop
0019ec94: 30420080 andi r2,r2,0x0080
0019ec98: 14400027 bne r2,r0,0x0019ed38              <Confirm Status> if critical hp unit
0019ec9c: 00000000 nop
0019eca0: 08067b4e j 0x0019ed38 <Confirm Status>
0019eca4: 321000bf andi r16,r16,0x00bf Don't add Float unless critical (lol)


The AI will not add Reraise on a unit unless they are under 50% HP. They also will not try to turn their allies into frogs. Finally, the AI will never use Float on itself unless it's in critical. Yes, you read that correctly. In critical. More on this in the next section.



]How the AI adds statuses - Adding Regen, Protect, Shell, Haste, Slow, and Wall (Part 2)
Alternate Title: How to Train Your AI to Preemptively Buff
<Current Status 4>
<Regen>
0019eca8: 32020040 andi r2,r16,0x0040
0019ecac: 10400007 beq r2,r0,0x0019eccc <Protect/Shell/Wall> if not adding Regen
0019ecb0: 00000000 nop
0019ecb4: 92e20007 lbu r2,0x0007(r23)               
0019ecb8: 00000000 nop
0019ecbc: 30420001 andi r2,r2,0x0001
0019ecc0: 14400002 bne r2,r0,0x0019eccc              <Protect/Shell/Wall> if low hp unit
0019ecc4: 00000000 nop
0019ecc8: 3a100040 xori r16,r16,0x0040 Remove Regen (Don't add Regen unless at 50% or less HP)
<Protect/Shell/Wall>
0019eccc: 92e20007 lbu r2,0x0007(r23)
0019ecd0: 00000000 nop
0019ecd4: 30420080 andi r2,r2,0x0080
0019ecd8: 14400003 bne r2,r0,0x0019ece8             <Haste/Slow> if critical hp unit
0019ecdc: 3202000c andi r2,r16,0x000c Check for Haste/Slow
0019ece0: 321000ce andi r16,r16,0x00ce Remove Protect/Shell/Wall (Don't add Protect/Shell/Wall unless Critical)
0019ece4: 3202000c andi r2,r16,0x000c Check for Haste/Slow
<Haste/Slow>
0019ece8: 10400013 beq r2,r0,0x0019ed38 <Confirm Status> if not adding Haste/Slow
0019ecec: 00000000 nop
0019ecf0: 92c2005b lbu r2,0x005b(r22)        Load Current Status 4
0019ecf4: 00000000 nop
0019ecf8: 30420002 andi r2,r2,0x0002
0019ecfc: 14400006 bne r2,r0,0x0019ed18          Branch to remove/not add Haste/Slow if Stop
0019ed00: 00000000 nop
0019ed04: 92c2005c lbu r2,0x005c(r22) Load Current Status 5
0019ed08: 00000000 nop
0019ed0c: 30420010 andi r2,r2,0x0010
0019ed10: 10400009 beq r2,r0,0x0019ed38          <Confirm Status> if not sleep
0019ed14: 00000000 nop
0019ed18: 08067b4e j 0x0019ed38 <Confirm Status>
0019ed1c: 321000f3 andi r16,r16,0x00f3 Remove Haste/Slow


Here you go. So why won't the AI preemptively buff themselves with any positive statuses besides Haste? Because it's not so much Haste is special or anything, but because Haste is the only positive status that doesn't have a restriction. Yeah don't use Haste/Slow on Stop/Sleeping units, but that's besides the point.

Protect, Shell, (and Wall) will not be used unless the unit in question is in Critical. Why Critical instead of 50% HP like Regen is beyond me but it makes it kinda useless for the AI. It makes sense that these status aren't usable at full HP in Vanilla because you don't have any skill restrictions and the developers probably got pissed at the AI constantly buffing itself instead of fighting.

At the very least, Protect and Shell should be used like Haste. In fact, make it so that the AI will only use Protect/Shell/Haste if they are above 50% HP. That way, they aren't using these statuses when they just got revived.

The AI adds Regen when it's Poisoned. I think why this is, is because the AI isn't adding Regen in it's mind, it's canceling Poison.

Interesting that Wall also got this treatment as well. This means that the developers really played around with Wall long enough to try to curb it's usage.



How the AI adds statuses - Faith and Reflect

<Current Status 5>
<Faith/Reflect>
0019ed20: 92e20007 lbu r2,0x0007(r23)
0019ed24: 00000000 nop
0019ed28: 30420080 andi r2,r2,0x0080
0019ed2c: 14400002 bne r2,r0,0x0019ed38             <Confirm Status> if critical hp unit
0019ed30: 00000000 nop
0019ed34: 3210007d andi r16,r16,0x007d Remove Faith and Reflect (Don't add Faith/Reflect unless critical)


More usage nerfs to positive statuses. This is why sometimes you see the AI use Faith and Reflect on itself when it's in critical, recalling that Faith and Reflect have slightly positive priorities and are kinda seen as gaining HP. Making the AI add Faith in a smart way is going to require some space to do, but it can be done. Same goes for Reflect. Death Sentence could probably be restricted to use on units with 50% or greater as well.



How the AI Removes Status - Charm, Don't Act and Don't Move


<Cancel Status 4 and 5>
0019eda8: 00009021 addu r18,r0,r0
0019edac: 0014a8c0 sll r21,r20,0x03 r21 = Cancel Status
0019edb0: 34070080 ori r7,r0,0x0080 r7 = 0x0080
0019edb4: 02479807 srav r19,r7,r18 r19 = 80 >> Current Status (0 - 4)
0019edb8: 02131024 and r2,r16,r19
0019edbc: 1040000d beq r2,r0,0x0019edf4 <Next Status> if not Canceling that status
0019edc0: 00000000 nop
0019edc4: 8fa40010 lw r4,0x0010(r29)
0019edc8: 02c02821 addu r5,r22,r0
0019edcc: 02b28821 addu r17,r21,r18
0019edd0: 0c067bc9 jal 0x0019ef2 Check if Status Should/Can be Added
0019edd4: 02203021 addu r6,r17,r0 Check for [current status]
0019edd8: 10400005 beq r2,r0,0x0019edf0 Remove Cancel Status if status can't be removed/isn't there
0019eddc: 02c02021 addu r4,r22,r0
0019ede0: 0c067bec jal 0x0019efb0 Check if Charm, Don't Act or Don't Move can be added/removed? before unit acts
0019ede4: 02202821 addu r5,r17,r0
0019ede8: 14400002 bne r2,r0,0x0019edf4 <Next Status> if all statuses, but especially Charm/Don't Act/Don't Move can be removed in time
0019edec: 00000000 nop
0019edf0: 02138026 xor r16,r16,r19 Remove Cancel Status if status can't be removed/isn't there/Can't be removed in time
<Next Status>
0019edf4: 26520001 addiu r18,r18,0x0001
0019edf8: 2a420008 slti r2,r18,0x0008
0019edfc: 1440ffed bne r2,r0,0x0019edb4 Go through all statuses
0019ee00: 34070080 ori r7,r0,0x0080
0019ee04: 34020001 ori r2,r0,0x0001


The AI checks to see if the unit doesn't have the status or it's innate. No surprises there.

The AI will only remove Charm, Don't Act and Don't Move before a unit's turn. If the Ability CT is too high to do this, then it won't remove them.



How the AI Removes Status - Blind/Silence and Frog


<Cancel Status 2>
<Silence>
0019ee20: 32020008 andi r2,r16,0x0008
0019ee24: 10400007 beq r2,r0,0x0019ee44 <Blind> if ability doesn't cancel Silence
0019ee28: 32020020 andi r2,r16,0x0020 Check for Blind
0019ee2c: 92e2000c lbu r2,0x000c(r23) Load Silenceable Ability Mod
0019ee30: 00000000 nop
0019ee34: 14400003 bne r2,r0,0x0019ee44             <Blind> if unit has any silenceable abilities
0019ee38: 32020020 andi r2,r16,0x0020 Check for Blind
0019ee3c: 3a100008 xori r16,r16,0x0008 Remove Silence
0019ee40: 32020020 andi r2,r16,0x0020 Check for Blind
<Blind>
0019ee44: 1040000e beq r2,r0,0x0019ee80 <Confirm Cancel> if not cancel Blind
0019ee48: 00000000 nop
0019ee4c: 92e2000d lbu r2,0x000d(r23) Load Evadable Ability Mod
0019ee50: 00000000 nop
0019ee54: 1440000a bne r2,r0,0x0019ee80             <Confirm Cancel> if unit has any evadeable abilities
0019ee58: 00000000 nop
0019ee5c: 08067ba0 j 0x0019ee80 <Confirm Cancel>
0019ee60: 3a100020 xori r16,r16,0x0020 Remove Blind



<Cancel Status 3>
0019ee64: 10400006 beq r2,r0,0x0019ee80 <Confirm Cancel> if no cancel Frog
0019ee68: 00000000 nop
0019ee6c: 92e20008 lbu r2,0x0008(r23)          Load Enemy Flag     
0019ee70: 00000000 nop
0019ee74: 10400002 beq r2,r0,0x0019ee80             <Confirm Cancel> if ally
0019ee78: 00000000 nop
0019ee7c: 3a100002 xori r16,r16,0x0002 Remove Frog (Don't want to undo frog, now do we?)


The only difference from adding Blind/Silence is that the AI will cure Blind as long as you have any Evadable abilities. Since all units have Attack, that should be all the time, right? Also don't remove Frog from your enemies, k thanks.



The AI uses Stat Abilities randomly.


<Affect Stats>
0019ee98: 8fc2000c lw r2,0x000c(r30)                load usage flags
0019ee9c: 00000000 nop
0019eea0: 30420008 andi r2,r2,0x0008
0019eea4: 1040000e beq r2,r0,0x0019eee0             <Unequip> if not affecting stats
0019eea8: 34020076 ori r2,r0,0x0076
0019eeac: 87c30002 lh r3,0x0002(r30)                load ability ID
0019eeb0: 00000000 nop
0019eeb4: 10620005 beq r3,r2,0x0019eecc             Skip RNG if Praise
0019eeb8: 34020092 ori r2,r0,0x0092
0019eebc: 10620003 beq r3,r2,0x0019eecc             Skip RNG if Accumulate
0019eec0: 34020096 ori r2,r0,0x0096
0019eec4: 1462000a bne r3,r2,0x0019eef0             Roll the dice on any other stat ability besides Yell
0019eec8: 34020001 ori r2,r0,0x0001
0019eecc: 0c0088c3 jal 0x0002230 Random Number Generator
0019eed0: 00000000 nop
0019eed4: 30420001 andi r2,r2,0x0001
0019eed8: 10400005 beq r2,r0,0x0019eef0            Use stat abilities randomly (!)
0019eedc: 34020001 ori r2,r0,0x0001


This is a bit of a shocker. If it's not Praise, Accumulate, or Yell, the AI's gotta roll the dice. This is why the AI doesn't use Stat abilities that much. There's probably a better way of doing this, perhaps only use on <50% HP units? Actually fucking look at their stats?



How the AI uses Break/Steal
<Unequip>
0019eee0: 8fc2000c lw r2,0x000c(r30)             
0019eee4: 00000000 nop
0019eee8: 30420004 andi r2,r2,0x0004              Check if ability is Unequip
0019eeec: 0002102b sltu r2,r0,r2                  Use Ability if true


Okay then.




So there you guys have it. This routine doesn't so much tell the AI what to select, so much as it tells the AI what not to select. There is some for improvement, so go ahead and leave some thoughts on how to improve this routine.
37
PSX FFT Hacking / Re: Dokurider's Custom AoEs
January 14, 2017, 04:42:32 pm
AI Two Swords Range Fix

If your patch uses Two Swordable weapons of differing ranges, then you want this hack. Current in Vanilla, the AI will overwrite the top weapon range with the bottom weapon range. Not a problem at all in Vanilla, but is a problem if your weapon on the top hand is longer than the one in the bottom hand.
What you'll end up seeing, if you are using a ranged weapon with a melee weapon, is that the AI will think their range is that of the bottom weapon range and attempt to get in range and move right next to the guy, realize they aren't in range anymore, and are forced to find a target they can attack instead or use an ability.

This hack swaps the top and bottom weapon processing order around so that the bottom range is overwritten by the top weapon range, thus knowing the correct attack range.

Original Code:
0019a3c4: 9245001d lbu r5,0x001d(r18) Load Unit's RH Weapon
0019a3c8: 0c06694b jal 0x 0019a52c Store Weapon? Attack Data
0019a3cc: 27a60010 addiu r6,r29,0x0010 r6 = Pointer to stack
0019a3d0: 02002021 addu r4,r16,r0 r4 = ? AI Pointer
0019a3d4: 9245001f lbu r5,0x001f(r18) Load Unit's LH Weapon
0019a3d8: 0c06694b jal 0x 0019a52c Store Weapon? Attack Data
0019a3dc: 27a60010 addiu r6,r29,0x0010 r6 = Pointer to stack


New Code:

0019a3c4: 9245001f lbu r5,0x001f(r18) Load Unit's LH Weapon
0019a3c8: 0c06694b jal 0x 0019a52c Store Weapon? Attack Data
0019a3cc: 27a60010 addiu r6,r29,0x0010 r6 = Pointer to stack
0019a3d0: 02002021 addu r4,r16,r0 r4 = ? AI Pointer
0019a3d4: 9245001d lbu r5,0x001d(r18) Load Unit's RH Weapon
0019a3d8: 0c06694b jal 0x 0019a52c Store Weapon? Attack Data
0019a3dc: 27a60010 addiu r6,r29,0x0010 r6 = Pointer to stack


Not much to it, really. With this hack you can make whatever weapon Two Swordable to your heart's content and the AI will use it correctly provided you are putting the range most weapon in your top hand.
38
FFT Arena / Re: SCC Tournament Round 3
January 11, 2017, 04:31:53 pm
1. Thief
2. Ninja Wizards
3. Squire Ninja
39
Okay before I get into my next deal, a few clarifications and corrections:

The AI does not care how much MP you have, only the current percentage and if you have enough to cast your Lowest MP cost spell.

In fact, as you'll soon see, the AI puts far more stock into your spells than your curMP.

Shout out to Choto for uploading the routine I'm basing this all of on and I presume documenting this routine and pretty much every other routine in the wiki lol.

I'll keep the code down to a minimum this time because the code is already documented.

How the AI calculates it's Blind/Silence/Caster factor


Step 1: Usable Abilites

The AI starts by figuring out what abilities it has is usable. It starts off with Attack, then it starts going into it's skillsets. While it processes Throw, Math, Charge and Jump a little differently, it's nothing really eyebrow raising except perhaps the way Charging with Guns is treated (refuses to use Charge for guns it seems?) In any case, it first checks to see if the skill is flagged as Usable by the AI. It then checks to see if the ability in question uses MP and if it does, do you even have the Max MP to even cast it?

Yes it does reduce the MP Cost by Half of MP, but the 1/3 of MP did not update the AI to reflect this. A fix is in the works, so don't fret too much.

Then it renders abilities unusable if the ability is a faith spell on a unit with innate Innocent, or the unit doesn't have the requred Sword/Materia Blade to use said ability. You can't know a skill that requires Monster Skill without...Monster Skill, and more importantly, if you are not in fact a monster yourself. If the ability in question is 0x170 (Potion and other special abilities) or higher, it will skip all of that and go to the final step. Keep that in mind if you're trying to make those skills normal.

And finally, of course, it has to have actually learned the ability in the first place. Once it has cleared all of that and the skillset in question is not Jump, it will trot out the list of known abilities for that skillset. Repeat for the other skillset. Finally it will save all of this, plus Frog Attack. Yes, the AI always knows Frog Attack as well as Attack. I suppose you can think of it as the Struggle of FFT. It's also what Monster units use when Berserked. The AI always counting Attack and Frog Attack in it's skill counting is very important to remember for later.


Step 2: Deriving Silence/P-Ev/MP skill counts and some small usage flagging

Now that we have our list of Usable abilities, we can derive our Silence/Blind/Caster mods from them. It's about what you'd expect. Add up all abilities that are physically evadable (aka evade with motion), silenceable, and uses MP. There are no restrictions against any of them other than being flagged as such.

It stores the Lowest and Highest MP costs that unit has. It flags Linear/Vertical/Triple Bracelet|Attack, and any attack over 3 range + AoE as 0x0400. It flags Reflect/Silencable or has an AoE of 0 as 0x0200.


Step 3: How to get your Blind/Silence/Caster values and how to game the system.
0019a148: 02802021 addu r4,r20,r0        Divisor = Number of Abilities
0019a14c: 0c0668b3 jal 0x 0019a2cc        Dividend * 4 / Divisor
0019a150: 02e02821 addu r5,r23,r0        Dividend = Silence Ignoring Abilities
0019a154: 02802021 addu r4,r20,r0        Divisor = Number of Abilities
0019a158: 03c02821 addu r5,r30,r0        Dividend = MP Using Abilities
0019a15c: 0c0668b3 jal 0x 0019a2cc        Dividend * 4 / Divisor
0019a160: a222000c sb r2,0x000c(r17)        Store MP Silence Blocking Mod
0019a164: 8fa50010 lw r5,0x0010(r29)        Load Evade ignoring Abilities
0019a168: 02802021 addu r4,r20,r0        Divisor = Number of Abilities
0019a16c: 0c0668b3 jal 0x 0019a2cc        Dividend * 4 / Divisor
0019a170: a222000b sb r2,0x000b(r17)        Store MP Using Mod
0019a174: 26240004 addiu r4,r17,0x0004        r4 = ? Pointer + 4
0019a178: 26c50167 addiu r5,r22,0x0167        r5 = Pointer to Unit's ENTD AI Data?
0019a17c: 34060005 ori r6,r0,0x0005        Limit = 5
0019a180: 0c066ad2 jal 0x 0019ab48        Transfer Byte Values
0019a184: a222000d sb r2,0x000d(r17)        Store Evade Ignoring Mod


So the basic formula for determine your unit's Blind/Silence/Caster factor is:
Quote(# of effected spells * 4) / Total Usable spells

This will get you a number between 0-4, with 0 being less than 25% and 4 being 100%. Remember that you must always factor in both Attack and Frog Attack into your calculations.

For an example, a unit that has no skills learned, will only know Attack and Frog Attack. He has a Silence and Caster factor of 0, but a Blind factor of 4, because:
Quote[# of P-EV abilities=2] * 4 / [# of total abilities=2] = 4

So he would be a prime Blind target, assuming he was vulnerable to Blind. But if he learned any one (1) non P-Ev ability, his Blind factor would drop dramatically to 2. Picking up two more non P-Ev skills would bump his total skills usable to 5 and his Blind factor to 1. He might as well be a mage with a Healing Staff.

So I wasn't completely accurate when I said the AI can't "tell the immediate difference between a White Mage with Healing Staff and a Berserk Cursed Ring Two Handed Main Gauche killer", because it kinda can. But it can be easily gamed to duck being targeted.

So if you want your Casters to duck being targeted, remember you always have two non MP using skills to balance against, thus you will never have a max Silence/Caster factor of 4.

Can I simply have a Summon Magic secondary on my Male Lancer, learn as many Summons as feasible and then never get targeted by Blind ever?
Not exactly. Remember that the AI kicks out any skill from it's usable pool if it has an MP cost exceeding it's Max MP. But if you have enough MP to cast any of them even once, then yes, you can grab that cheap caster aggro and be a taunt tank...exactly once before the AI casts a spell, and then you're completely out of MP and the game yanks your aggro license.




That's about everything for today. It's not a major revelation today, sorry, but I'm a little overdue. I made a few edits to the original post to fix some mistakes in my original analysis. I don't have too many complaints about how the AI calculates the factors, except the caster value. It should compensate for Attack/Frog Attack.
40
A few more comments:

Remember that for certain skillsets, the abilities in them only ever count as one skill. For an example, Jump is only ever counted as 0x018a, Level Jump 2 and only that, no matter how many other jumps you've learned. Same goes for Elemental, and I believe Throw as well.

Oil has a very low priority value (-5.5%), which was why it had to be constantly bundled with other statuses and effects to be used by the AI. Makes a bit of sense seeing that in Vanilla, Oil didn't work at all.

Blind is -12.5% for each P-Ev skill known, including Attack. Silence is -17.5% for each silenceable ability known.

Transparent and Reraise have very high positive values, which might be why the AI gets so aggressive when they have them.

Anything that drops the target's priority to -50% might trigger the 'ignore completely' routine, which includes Confuse, Charm, and Blood Suck (Death Sentence gets it's own special flag and gets skipped in this routine). We could experiment and lower them to see if the AI continues to ignore confused/charmed lone targets.