Difference between revisions of "AI ability use control routine"

From Final Fantasy Hacktics Wiki
Jump to navigation Jump to search
m
 
(4 intermediate revisions by 2 users not shown)
Line 1: Line 1:
<font face='Courier New'>
+
Chose an Ability from the Unit's Skillsets      '''ALTERNATIVE VERSION''' [[AI_Ability_Outcome_Evaluation]]
AI ability use control routine
+
 
  <font face='Courier New'>
+
Evaluate an ability for and either selects it or rejects it.
 
+
  Sets a Decision Value to base the next ability evaluation.
  0019af18: 3c02801a lui r2,0x801a
+
  0019af1c: 90420d7b lbu r2,0x0d7b(r2)                 load ??
+
190c3c/19f3c4/1a0000
  0019af20: 27bdffd8 addiu r29,r29,0xffd8
+
 
  0019af24: afb20018 sw r18,0x0018(r29)
+
0019af18: 3c02801a lui r2,0x801a
  0019af28: 3c12801a lui r18,0x801a
+
0019af1c: 90420d7b lbu r2,0x0d7b(r2)                 Load Action Decided?
  0019af2c: 2652f3c4 addiu r18,r18,0xf3c4
+
0019af20: 27bdffd8 addiu r29,r29,0xffd8
  0019af30: afbf0020 sw r31,0x0020(r29)
+
0019af24: afb20018 sw r18,0x0018(r29)
  0019af34: afb3001c sw r19,0x001c(r29)
+
0019af28: 3c12801a lui r18,0x801a
  0019af38: afb10014 sw r17,0x0014(r29)
+
0019af2c: 2652f3c4 addiu r18,r18,0xf3c4 r18 = AI Data
  0019af3c: 1040000d beq r2,r0,0x0019af74
+
0019af30: afbf0020 sw r31,0x0020(r29)
  0019af40: afb00010 sw r16,0x0010(r29)
+
0019af34: afb3001c sw r19,0x001c(r29)
  0019af44: 3c03801a lui r3,0x801a
+
0019af38: afb10014 sw r17,0x0014(r29)
  0019af48: 90630034 lbu r3,0x0034(r3)
+
0019af3c: 1040000d beq r2,r0,0x0019af74 <1 - Frame RNG> if no action taken yet
  0019af4c: 00000000 nop
+
0019af40: afb00010 sw r16,0x0010(r29)
  0019af50: 2c620009 sltiu r2,r3,0x0009
+
0019af44: 3c03801a lui r3,0x801a
  0019af54: 104000da beq r2,r0,0x0019b2c0
+
0019af48: 90630034 lbu r3,0x0034(r3) Decision Byte
  0019af58: 00031080 sll r2,r3,0x02
+
0019af4c: 00000000 nop (This contains previous decisions made in this very routine. Is not reset when changing unit turns.
  0019af5c: 3c018019 lui r1,0x8019
+
0019af50: 2c620009 sltiu r2,r3,0x0009
  0019af60: 00220821 addu r1,r1,r2
+
0019af54: 104000da beq r2,r0,0x0019b2c0 Branch if Decision byte's too high (just a safe check)
  0019af64: 8c223db0 lw r2,0x3db0(r1)
+
0019af58: 00031080 sll r2,r3,0x02
  0019af68: 00000000 nop
+
0019af5c: 3c018019 lui r1,0x8019
  0019af6c: 00400008 jr r2
+
0019af60: 00220821 addu r1,r1,r2
  0019af70: 00000000 nop
+
0019af64: 8c223db0 lw r2,0x3db0(r1) Load Jump Addresses
 
+
0019af68: 00000000 nop
  0019af74: 0c0076ea jal 0x0001dba8 [[0001dba8 - 0001dcec]]
+
0019af6c: 00400008 jr r2
  0019af78: 34040001 ori r4,r0,0x0001
+
0019af70: 00000000 nop
  0019af7c: 284201b9 slti r2,r2,0x01b9
+
 
  0019af80: 104000d4 beq r2,r0,0x0019b2d4
+
8019b0b8 0 - Reflect and Ability Usage.
  0019af84: 34020007 ori r2,r0,0x0007
+
8019b100 1 - Unit Rangefinder. Will loop through all abilities until it finds an ability with targets in range. Merges into main routine when successful.
  0019af88: 8e42000c lw r2,0x000c(r18)
+
8019b160 2 - AoE Evaluation. After determining if there is an AoE, determines if it can hit any other unit in time.
  0019af8c: 00000000 nop
+
8019b1cc 3 - Spell CT vs Target CT. Evaluates all units for CT timings.
  0019af90: 044100d5 bgez r2,0x0019b2e8
+
8019b240 4 - Targetable Unit List.
  0019af94: a24019b7 sb r0,0x19b7(r18)
+
8019b2c0 5 - Simply finds the highest priority unit in range, compares to high score, then exits. Every other decision above 8 is also redirected here as well.
  0019af98: 30420800 andi r2,r2,0x0800
+
8019b068 6 - Math Skill Evaluation. Loops itself until the Math Skill Evaluation is complete. I do not know how it breaks out of this loop.
  0019af9c: 1040000e beq r2,r0,0x0019afd8
+
8019af74 7 - The Main Routine. Initialize Ability Data, then determines Random Use, Target Map, and Crystal/Treasure Check. Resets to itself or will go to 1 when it needs to rangefind units.
  0019afa0: 00000000 nop
+
8019b094 8 - Positioning Check. The final part of Target Map evaluation. Is the unit in the right place to correctly use this ability? Elemental/Monster Skill/Water Depth are checked in the subroutine. Compares ability priority to highest priority score then exits.
  0019afa4: 925019b8 lbu r16,0x19b8(r18)
+
 
  0019afa8: 0c0088c3 jal 0x0002230c [[Random Number Generator]]
+
<7 - Usable by AI, Random Usage, Ignore Range>
  0019afac: 00000000 nop
+
<Frame Cycle>
  0019afb0: 00401821 addu r3,r2,r0
+
0019af74: 0c0076ea jal 0x0001dba8 Get Frame Data
  0019afb4: 04610003 bgez r3,0x0019afc4
+
0019af78: 34040001 ori r4,r0,0x0001
  0019afb8: 000211c3 sra r2,r2,0x07
+
0019af7c: 284201b9 slti r2,r2,0x01b9
  0019afbc: 2462007f addiu r2,r3,0x007f
+
0019af80: 104000d4 beq r2,r0,0x0019b2d4 Exit if it's time to animate; Set next decision to 07
  0019afc0: 000211c3 sra r2,r2,0x07
+
0019af84: 34020007 ori r2,r0,0x0007
  0019afc4: 000211c0 sll r2,r2,0x07
+
 
  0019afc8: 00621023 subu r2,r3,r2
+
<Usable by AI>
  0019afcc: 0202102a slt r2,r16,r2
+
0019af88: 8e42000c lw r2,0x000c(r18) Load AI Flags
  0019afd0: 144000c6 bne r2,r0,0x0019b2ec
+
0019af8c: 00000000 nop
  0019afd4: 00001021 addu r2,r0,r0
+
0019af90: 044100d5 bgez r2,0x0019b2e8 Next Ability if not Usable by the AI (0x80000000 makes it negative)
  0019afd8: 92420000 lbu r2,0x0000(r18)
+
0019af94: a24019b7 sb r0,0x19b7(r18)
  0019afdc: 96430002 lhu r3,0x0002(r18)
+
 
  0019afe0: 92440006 lbu r4,0x0006(r18)
+
<Random Use Flag>
  0019afe4: 00008021 addu r16,r0,r0
+
0019af98: 30420800 andi r2,r2,0x0800
  0019afe8: a242001d sb r2,0x001d(r18)
+
0019af9c: 1040000e beq r2,r0,0x0019afd8 Branch if not Random Hits
  0019afec: a643001e sh r3,0x001e(r18)
+
0019afa0: 00000000 nop
  0019aff0: a2440024 sb r4,0x0024(r18)
+
0019afa4: 925019b8 lbu r16,0x19b8(r18) Load Random Ability Counter (# of random hits abilities*128 / number of usable abilities)
  0019aff4: 02501021 addu r2,r18,r16
+
0019afa8: 0c0088c3 jal 0x0002230c Random Number Generator
 
+
0019afac: 00000000 nop
  0019aff8: 90430c78 lbu r3,0x0c78(r2)
+
0019afb0: 00401821 addu r3,r2,r0
  0019affc: 26100001 addiu r16,r16,0x0001
+
0019afb4: 04610003 bgez r3,0x0019afc4 Process Random Number
  0019b000: a0430c8d sb r3,0x0c8d(r2)
+
0019afb8: 000211c3 sra r2,r2,0x07
  0019b004: 2a020015 slti r2,r16,0x0015
+
0019afbc: 2462007f addiu r2,r3,0x007f
  0019b008: 1440fffb bne r2,r0,0x0019aff8
+
0019afc0: 000211c3 sra r2,r2,0x07
  0019b00c: 02501021 addu r2,r18,r16
+
0019afc4: 000211c0 sll r2,r2,0x07
 
+
0019afc8: 00621023 subu r2,r3,r2
  0019b010: 8e43000c lw r3,0x000c(r18)
+
0019afcc: 0202102a slt r2,r16,r2
  0019b014: 00000000 nop
+
0019afd0: 144000c6 bne r2,r0,0x0019b2ec Randomly decide to not use a Random Hits ability (Good one, Square...)
  0019b018: 30628000 andi r2,r3,0x8000
+
0019afd4: 00001021 addu r2,r0,r0
  0019b01c: 10400024 beq r2,r0,0x0019b0b0
+
 
  0019b020: 30624000 andi r2,r3,0x4000
+
<Initialize Ability Data>
  0019b024: 92440e2e lbu r4,0x0e2e(r18)
+
0019afd8: 92420000 lbu r2,0x0000(r18) Load Skillset
  0019b028: 92420e2d lbu r2,0x0e2d(r18)
+
0019afdc: 96430002 lhu r3,0x0002(r18) Load Ability ID
  0019b02c: 34030006 ori r3,r0,0x0006
+
0019afe0: 92440006 lbu r4,0x0006(r18) Load Item ID
  0019b030: a2430026 sb r3,0x0026(r18)
+
0019afe4: 00008021 addu r16,r0,r0 Initialize Unit ID
  0019b034: 00021080 sll r2,r2,0x02
+
0019afe8: a242001d sb r2,0x001d(r18) Save as Last Skillset Used
  0019b038: 00521021 addu r2,r2,r18
+
0019afec: a643001e sh r3,0x001e(r18) Save as Last Ability Used
  0019b03c: a2440027 sb r4,0x0027(r18)
+
0019aff0: a2440024 sb r4,0x0024(r18) Save as Item Destroyed/Stolen
  0019b040: 8c420cc4 lw r2,0x0cc4(r2)
+
0019aff4: 02501021 addu r2,r18,r16 Load Current Unit AI Data
  0019b044: 0c066ec8 jal 0x0019bb20 [[0019bb20 - 0019bbb8]]
+
 
  0019b048: ae420018 sw r2,0x0018(r18)
+
0019aff8: 90430c78 lbu r3,0x0c78(r2) Load isTargetable list
  0019b04c: 92420000 lbu r2,0x0000(r18)
+
0019affc: 26100001 addiu r16,r16,0x0001
  0019b050: 3c018006 lui r1,0x8006
+
0019b000: a0430c8d sb r3,0x0c8d(r2) Save isTargetable list copy
  0019b054: 00220821 addu r1,r1,r2
+
0019b004: 2a020015 slti r2,r16,0x0015
  0019b058: 90235cb4 lbu r3,0x5cb4(r1)
+
0019b008: 1440fffb bne r2,r0,0x0019aff8 Do for all units
  0019b05c: 34020003 ori r2,r0,0x0003
+
0019b00c: 02501021 addu r2,r18,r16 Next Unit
  0019b060: 14620008 bne r3,r2,0x0019b084
+
 
  0019b064: 00000000 nop
+
<Target Map>
  0019b068: 0c066eef jal 0x0019bbbc [[0019bbbc - 0019bf28]]
+
0019b010: 8e43000c lw r3,0x000c(r18) Get AI Flags
  0019b06c: 00000000 nop
+
0019b014: 00000000 nop
  0019b070: 2403ffff addiu r3,r0,0xffff
+
0019b018: 30628000 andi r2,r3,0x8000
  0019b074: 1443009c bne r2,r3,0x0019b2e8
+
0019b01c: 10400024 beq r2,r0,0x0019b0b0 Branch if not Target Map
  0019b078: 34020006 ori r2,r0,0x0006
+
0019b020: 30624000 andi r2,r3,0x4000 Get Reflect Flag
  0019b07c: 08066cb6 j 0x0019b2d8
+
 
  0019b080: a2420c70 sb r2,0x0c70(r18)
+
<Check for Crystal/Treasure>
  0019b084: 0c067950 jal 0x0019e540 [[See if any unit decided to use an ability]]
+
0019b024: 92440e2e lbu r4,0x0e2e(r18) r4 = Acting Unit ID
  0019b088: 00000000 nop
+
0019b028: 92420e2d lbu r2,0x0e2d(r18) r2 = Targeted Unit ID?
  0019b08c: 10400097 beq r2,r0,0x0019b2ec
+
0019b02c: 34030006 ori r3,r0,0x0006
  0019b090: 00001021 addu r2,r0,r0
+
0019b030: a2430026 sb r3,0x0026(r18) 0x06 - Save Ignore range
  0019b094: 0c065bbd jal 0x00196ef4 [[00196ef4 - 00196fc0]]
+
0019b034: 00021080 sll r2,r2,0x02 ID * 4
  0019b098: 00000000 nop
+
0019b038: 00521021 addu r2,r2,r18
  0019b09c: 2403ffff addiu r3,r0,0xffff
+
0019b03c: a2440027 sb r4,0x0027(r18) Save Acting Unit ID
  0019b0a0: 1443008f bne r2,r3,0x0019b2e0
+
0019b040: 8c420cc4 lw r2,0x0cc4(r2) Load Target Unit AI Pointer
  0019b0a4: 34020008 ori r2,r0,0x0008
+
0019b044: 0c066ec8 jal 0x0019bb20 Check for Crystal/Treasure on map (saves to 0x0083/0xf447/0x0cbf)
  0019b0a8: 08066cb6 j 0x0019b2d8
+
0019b048: ae420018 sw r2,0x0018(r18) Save Target Unit AI Pointer
  0019b0ac: a2420c70 sb r2,0x0c70(r18)
+
0019b04c: 92420000 lbu r2,0x0000(r18) Load Skillset
  0019b0b0: 10400008 beq r2,r0,0x0019b0d4
+
0019b050: 3c018006 lui r1,0x8006
  0019b0b4: 00000000 nop
+
0019b054: 00220821 addu r1,r1,r2
  0019b0b8: 0c066dee jal 0x0019b7b8 [[0019b7b8 - 0019bb1c]]
+
0019b058: 90235cb4 lbu r3,0x5cb4(r1) Get Action Menu
  0019b0bc: 00000000 nop
+
0019b05c: 34020003 ori r2,r0,0x0003
  0019b0c0: 2403ffff addiu r3,r0,0xffff
+
0019b060: 14620008 bne r3,r2,0x0019b084 Branch if not Math Skill
  0019b0c4: 14430003 bne r2,r3,0x0019b0d4
+
0019b064: 00000000 nop
  0019b0c8: 2402ffff addiu r2,r0,0xffff
+
 
  0019b0cc: 08066cbb j 0x0019b2ec
+
<6> Math Skill
  0019b0d0: a2400c70 sb r0,0x0c70(r18)
+
0019b068: 0c066eef jal 0x0019bbbc Math Skill Targeting
  0019b0d4: 0c067950 jal 0x0019e540 [[See if any unit decided to use an ability]]
+
0019b06c: 00000000 nop
  0019b0d8: 00000000 nop
+
0019b070: 2403ffff addiu r3,r0,0xffff
  0019b0dc: 10400083 beq r2,r0,0x0019b2ec
+
0019b074: 1443009c bne r2,r3,0x0019b2e8 Next Ability if -1
  0019b0e0: 00001021 addu r2,r0,r0
+
0019b078: 34020006 ori r2,r0,0x0006
  0019b0e4: 92420e2e lbu r2,0x0e2e(r18)
+
0019b07c: 08066cb6 j 0x0019b2d8 Select ability and exit
  0019b0e8: 00000000 nop
+
0019b080: a2420c70 sb r2,0x0c70(r18) Set next decision to 6
  0019b0ec: 02421021 addu r2,r18,r2
+
 
  0019b0f0: 90420c8d lbu r2,0x0c8d(r2)
+
<Every other Ignore Range Ability>
  0019b0f4: 00000000 nop
+
0019b084: 0c067950 jal 0x0019e540 Check if ability can effect any units
  0019b0f8: 10400006 beq r2,r0,0x0019b114
+
0019b088: 00000000 nop
  0019b0fc: 00000000 nop
+
0019b08c: 10400097 beq r2,r0,0x0019b2ec Next move if Ability can't effect any units
  0019b100: 0c066cc3 jal 0x0019b30c [[0019b30c - 0019b4f0]]
+
0019b090: 00001021 addu r2,r0,r0
  0019b104: 00000000 nop
+
 
  0019b108: 2403ffff addiu r3,r0,0xffff
+
<8> Positioning Check
  0019b10c: 10430071 beq r2,r3,0x0019b2d4
+
0019b094: 0c065bbd jal 0x00196ef4 Monster Skill/Elemental/Water Depth/Mount?? Check
  0019b110: 34020001 ori r2,r0,0x0001
+
0019b098: 00000000 nop Otherwise it basically okays everything
  0019b114: 92440e2e lbu r4,0x0e2e(r18)
+
0019b09c: 2403ffff addiu r3,r0,0xffff
  0019b118: 0c067976 jal 0x0019e5d8 [[AI Abiltiy Use Decisions]]
+
0019b0a0: 1443008f bne r2,r3,0x0019b2e0 Go to routine, then exit to next ability if -1
  0019b11c: 34050001 ori r5,r0,0x0001
+
0019b0a4: 34020008 ori r2,r0,0x0008
  0019b120: 8e43000c lw r3,0x000c(r18)
+
0019b0a8: 08066cb6 j 0x0019b2d8 Jump to exit and choose ability
  0019b124: 00000000 nop
+
0019b0ac: a2420c70 sb r2,0x0c70(r18) Set next decision to 8
  0019b128: 30631000 andi r3,r3,0x1000
+
 
  0019b12c: 10600056 beq r3,r0,0x0019b288
+
  0019b130: a2420e4c sb r2,0x0e4c(r18)
+
0019b0b0: 10400008 beq r2,r0,0x0019b0d4 Branch if not Reflectable
  0019b134: 34020006 ori r2,r0,0x0006
+
0019b0b4: 00000000 nop
  0019b138: a2420026 sb r2,0x0026(r18)
+
<0>Reflect
  0019b13c: 8e42000c lw r2,0x000c(r18)
+
0019b0b8: 0c066dee jal 0x0019b7b8 Target Analysis Routine (Reflect Spell Banking behavior?)
  0019b140: 3c030100 lui r3,0x0100
+
0019b0bc: 00000000 nop
  0019b144: 00431024 and r2,r2,r3
+
0019b0c0: 2403ffff addiu r3,r0,0xffff
  0019b148: 1040000c beq r2,r0,0x0019b17c
+
0019b0c4: 14430003 bne r2,r3,0x0019b0d4 Branch if no unit can be hit with a reflected spell
  0019b14c: 3c030200 lui r3,0x0200
+
0019b0c8: 2402ffff addiu r2,r0,0xffff
  0019b150: 8e420cb4 lw r2,0x0cb4(r18)
+
0019b0cc: 08066cbb j 0x0019b2ec Choose ability and exit
  0019b154: 00000000 nop
+
0019b0d0: a2400c70 sb r0,0x0c70(r18) Set next decision to 0
  0019b158: 00431025 or r2,r2,r3
+
  0019b15c: ae420cb4 sw r2,0x0cb4(r18)
+
<Normal Spell>
  0019b160: 0c066fcb jal 0x0019bf2c [[0019bf2c - 0019c208]]
+
0019b0d4: 0c067950 jal 0x0019e540 See if ability can effect any unit
  0019b164: 00000000 nop
+
0019b0d8: 00000000 nop
  0019b168: 2403ffff addiu r3,r0,0xffff
+
0019b0dc: 10400083 beq r2,r0,0x0019b2ec Exit and don't chose this ability if it can't
  0019b16c: 14430042 bne r2,r3,0x0019b278
+
0019b0e0: 00001021 addu r2,r0,r0
  0019b170: 34020002 ori r2,r0,0x0002
+
0019b0e4: 92420e2e lbu r2,0x0e2e(r18) Load Acting Unit's ID
  0019b174: 08066cb6 j 0x0019b2d8
+
0019b0e8: 00000000 nop
  0019b178: a2420c70 sb r2,0x0c70(r18)
+
0019b0ec: 02421021 addu r2,r18,r2
  0019b17c: 00008021 addu r16,r0,r0
+
0019b0f0: 90420c8d lbu r2,0x0c8d(r2) Get isTargetable
  0019b180: 02508821 addu r17,r18,r16
+
0019b0f4: 00000000 nop
  0019b184: 92220c8d lbu r2,0x0c8d(r17)
+
0019b0f8: 10400006 beq r2,r0,0x0019b114 Branch if cannot target self?
  0019b188: 92230c8d lbu r3,0x0c8d(r17)
+
0019b0fc: 00000000 nop
  0019b18c: 00000000 nop
+
 
  0019b190: 10600006 beq r3,r0,0x0019b1ac
+
<1>(Ability Use) Follow Target and P-Ev check
  0019b194: a2220ca2 sb r2,0x0ca2(r17)
+
0019b100: 0c066cc3 jal 0x0019b30c Check if any units are in Range
  0019b198: 0c067c36 jal 0x0019f0d8 [[See if ability should be used based on CT]]
+
0019b104: 00000000 nop
  0019b19c: 02002021 addu r4,r16,r0
+
0019b108: 2403ffff addiu r3,r0,0xffff
  0019b1a0: 14400002 bne r2,r0,0x0019b1ac
+
0019b10c: 10430071 beq r2,r3,0x0019b2d4 Set Decision to 1 and choose ability if units are in range
  0019b1a4: 00000000 nop
+
0019b110: 34020001 ori r2,r0,0x0001
  0019b1a8: a2200c8d sb r0,0x0c8d(r17)
+
  0019b1ac: 26100001 addiu r16,r16,0x0001
+
<Can't Target Self>
  0019b1b0: 2a020015 slti r2,r16,0x0015
+
0019b114: 92440e2e lbu r4,0x0e2e(r18) r4 = Acting Unit's ID
  0019b1b4: 1440fff3 bne r2,r0,0x0019b184
+
0019b118: 0c067976 jal 0x0019e5d8 AI Ability Use
  0019b1b8: 02508821 addu r17,r18,r16
+
0019b11c: 34050001 ori r5,r0,0x0001
  0019b1bc: 8e420cb4 lw r2,0x0cb4(r18)
+
0019b120: 8e43000c lw r3,0x000c(r18) Load AI Flags
  0019b1c0: 3c030200 lui r3,0x0200
+
0019b124: 00000000 nop
  0019b1c4: 00431025 or r2,r2,r3
+
0019b128: 30631000 andi r3,r3,0x1000
  0019b1c8: ae420cb4 sw r2,0x0cb4(r18)
+
0019b12c: 10600056 beq r3,r0,0x0019b288 <Hit Panel> if not Follow Target
  0019b1cc: 0c066fcb jal 0x0019bf2c [[0019bf2c - 0019c208]]
+
0019b130: a2420e4c sb r2,0x0e4c(r18) Save Current Ability Decision (0 = Cannot Effect Unit, 1 = usable, 2 = Heals Target)
  0019b1d0: 00000000 nop
+
0019b134: 34020006 ori r2,r0,0x0006
  0019b1d4: 2403ffff addiu r3,r0,0xffff
+
0019b138: a2420026 sb r2,0x0026(r18) 06 = Ability Follows Unit (instead of Panel)
  0019b1d8: 14430003 bne r2,r3,0x0019b1e8
+
0019b13c: 8e42000c lw r2,0x000c(r18) Load AI Flags
  0019b1dc: 00008021 addu r16,r0,r0
+
0019b140: 3c030100 lui r3,0x0100
  0019b1e0: 08066cb5 j 0x0019b2d4
+
0019b144: 00431024 and r2,r2,r3
  0019b1e4: 34020003 ori r2,r0,0x0003
+
0019b148: 1040000c beq r2,r0,0x0019b17c <Target Unit without P-Ev) if not Physical Evadable
  0019b1e8: 34130001 ori r19,r0,0x0001
+
0019b14c: 3c030200 lui r3,0x0200
  0019b1ec: 02508821 addu r17,r18,r16
+
0019b150: 8e420cb4 lw r2,0x0cb4(r18) Load AI Flags Copy
  0019b1f0: 92220ca2 lbu r2,0x0ca2(r17)
+
0019b154: 00000000 nop
  0019b1f4: 00000000 nop
+
0019b158: 00431025 or r2,r2,r3
  0019b1f8: 10400008 beq r2,r0,0x0019b21c
+
0019b15c: ae420cb4 sw r2,0x0cb4(r18) Save as Target Unit with P-Ev (Get behind them behavior?) (1a0078)
  0019b1fc: 00000000 nop
+
 
  0019b200: 0c067c36 jal 0x0019f0d8 [[See if ability should be used based on CT]]
+
<2> Target Unit with P-Ev flag
  0019b204: 02002021 addu r4,r16,r0
+
0019b160: 0c066fcb jal 0x0019bf2c Find Highest Priority Unit in Range
  0019b208: 10400003 beq r2,r0,0x0019b218
+
0019b164: 00000000 nop
  0019b20c: 00000000 nop
+
0019b168: 2403ffff addiu r3,r0,0xffff
  0019b210: 08066c87 j 0x0019b21c
+
0019b16c: 14430042 bne r2,r3,0x0019b278 <Find AoE> if not -1
  0019b214: a2200c8d sb r0,0x0c8d(r17)
+
0019b170: 34020002 ori r2,r0,0x0002
  0019b218: a2330c8d sb r19,0x0c8d(r17)
+
0019b174: 08066cb6 j 0x0019b2d8 jump to exit and choose ability?
  0019b21c: 26100001 addiu r16,r16,0x0001
+
0019b178: a2420c70 sb r2,0x0c70(r18) Set next decision as 02
  0019b220: 2a020015 slti r2,r16,0x0015
+
 
  0019b224: 1440fff2 bne r2,r0,0x0019b1f0
+
(Target Unit without P-Ev)
  0019b228: 02508821 addu r17,r18,r16
+
0019b17c: 00008021 addu r16,r0,r0
  0019b22c: 3c03fdff lui r3,0xfdff
+
0019b180: 02508821 addu r17,r18,r16
  0019b230: 8e420cb4 lw r2,0x0cb4(r18)
+
0019b184: 92220c8d lbu r2,0x0c8d(r17) load isTargetable
  0019b234: 3463ffff ori r3,r3,0xffff
+
0019b188: 92230c8d lbu r3,0x0c8d(r17) load isTargetable
  0019b238: 00431024 and r2,r2,r3
+
0019b18c: 00000000 nop
  0019b23c: ae420cb4 sw r2,0x0cb4(r18)
+
0019b190: 10600006 beq r3,r0,0x0019b1ac Next Unit if current unit is untargetable
  0019b240: 0c066fcb jal 0x0019bf2c [[0019bf2c - 0019c208]]
+
0019b194: a2220ca2 sb r2,0x0ca2(r17) Save isTargetable
  0019b244: 00000000 nop
+
0019b198: 0c067c36 jal 0x0019f0d8 See if ability should be used based on CT
  0019b248: 2403ffff addiu r3,r0,0xffff
+
0019b19c: 02002021 addu r4,r16,r0
  0019b24c: 14430003 bne r2,r3,0x0019b25c
+
0019b1a0: 14400002 bne r2,r0,0x0019b1ac Branch if Ability can hit in time
  0019b250: 00008021 addu r16,r0,r0
+
0019b1a4: 00000000 nop
  0019b254: 08066cb5 j 0x0019b2d4
+
0019b1a8: a2200c8d sb r0,0x0c8d(r17) Unit is untargetable by this spell
  0019b258: 34020004 ori r2,r0,0x0004
+
0019b1ac: 26100001 addiu r16,r16,0x0001
  0019b25c: 02501021 addu r2,r18,r16
+
0019b1b0: 2a020015 slti r2,r16,0x0015
  0019b260: 90430ca2 lbu r3,0x0ca2(r2)
+
0019b1b4: 1440fff3 bne r2,r0,0x0019b184 Do for all units
  0019b264: 26100001 addiu r16,r16,0x0001
+
0019b1b8: 02508821 addu r17,r18,r16
  0019b268: a0430c8d sb r3,0x0c8d(r2)
+
 
  0019b26c: 2a020015 slti r2,r16,0x0015
+
0019b1bc: 8e420cb4 lw r2,0x0cb4(r18) Load AI Flags Copy
  0019b270: 1440fffb bne r2,r0,0x0019b260
+
0019b1c0: 3c030200 lui r3,0x0200
  0019b274: 02501021 addu r2,r18,r16
+
0019b1c4: 00431025 or r2,r2,r3
  0019b278: 92420005 lbu r2,0x0005(r18)
+
0019b1c8: ae420cb4 sw r2,0x0cb4(r18) Save as Target Unit with P-Ev (Get behind them behavior?) (1a0078)
  0019b27c: 00000000 nop
+
 
  0019b280: 10400017 beq r2,r0,0x0019b2e0
+
<3> (Spell that can't Follow Target?)
  0019b284: 00000000 nop
+
0019b1cc: 0c066fcb jal 0x0019bf2c Find Highest Priority Unit in Range
  0019b288: 0c067c07 jal 0x0019f01c [[Set unit untargetable based on 19f0d8 routine]]
+
0019b1d0: 00000000 nop
  0019b28c: 00000000 nop
+
0019b1d4: 2403ffff addiu r3,r0,0xffff
  0019b290: 10400013 beq r2,r0,0x0019b2e0
+
0019b1d8: 14430003 bne r2,r3,0x0019b1e8
  0019b294: 34020005 ori r2,r0,0x0005
+
0019b1dc: 00008021 addu r16,r0,r0
  0019b298: a2420026 sb r2,0x0026(r18)
+
0019b1e0: 08066cb5 j 0x0019b2d4 Chose ability and set decision to 3
  0019b29c: 8e42000c lw r2,0x000c(r18)
+
0019b1e4: 34020003 ori r2,r0,0x0003
  0019b2a0: 3c030100 lui r3,0x0100
+
  0019b2a4: 00431024 and r2,r2,r3
+
<Spell CT vs Target CT>
  0019b2a8: 10400005 beq r2,r0,0x0019b2c0
+
0019b1e8: 34130001 ori r19,r0,0x0001
  0019b2ac: 3c030200 lui r3,0x0200
+
0019b1ec: 02508821 addu r17,r18,r16
  0019b2b0: 8e420cb4 lw r2,0x0cb4(r18)
+
0019b1f0: 92220ca2 lbu r2,0x0ca2(r17) Load isTarget
  0019b2b4: 00000000 nop
+
0019b1f4: 00000000 nop
  0019b2b8: 00431025 or r2,r2,r3
+
0019b1f8: 10400008 beq r2,r0,0x0019b21c Next unit if unit can't be targeted
  0019b2bc: ae420cb4 sw r2,0x0cb4(r18)
+
0019b1fc: 00000000 nop
  0019b2c0: 0c066fcb jal 0x0019bf2c [[0019bf2c - 0019c208]]
+
0019b200: 0c067c36 jal 0x0019f0d8 See if ability should be used based on CT
  0019b2c4: 00000000 nop
+
0019b204: 02002021 addu r4,r16,r0
  0019b2c8: 2403ffff addiu r3,r0,0xffff
+
0019b208: 10400003 beq r2,r0,0x0019b218 Branch and mark unit as a target
  0019b2cc: 14430004 bne r2,r3,0x0019b2e0
+
0019b20c: 00000000 nop
  0019b2d0: 34020005 ori r2,r0,0x0005
+
0019b210: 08066c87 j 0x0019b21c
 
+
0019b214: a2200c8d sb r0,0x0c8d(r17) Do not target unit
  0019b2d4: a2420c70 sb r2,0x0c70(r18)
+
0019b218: a2330c8d sb r19,0x0c8d(r17) Target Unit
  0019b2d8: 08066cbb j 0x0019b2ec
+
0019b21c: 26100001 addiu r16,r16,0x0001 Unit Counter++
  0019b2dc: 2402ffff addiu r2,r0,0xffff
+
0019b220: 2a020015 slti r2,r16,0x0015
  0019b2e0: 0c065bf1 jal 0x00196fc4 [[00196fc4 - 001970b8]]
+
0019b224: 1440fff2 bne r2,r0,0x0019b1f0 Do for all units
  0019b2e4: 00000000 nop
+
0019b228: 02508821 addu r17,r18,r16
  0019b2e8: 00001021 addu r2,r0,r0
+
 
  0019b2ec: 8fbf0020 lw r31,0x0020(r29)
+
0019b22c: 3c03fdff lui r3,0xfdff
  0019b2f0: 8fb3001c lw r19,0x001c(r29)
+
0019b230: 8e420cb4 lw r2,0x0cb4(r18)
  0019b2f4: 8fb20018 lw r18,0x0018(r29)
+
0019b234: 3463ffff ori r3,r3,0xffff
  0019b2f8: 8fb10014 lw r17,0x0014(r29)
+
0019b238: 00431024 and r2,r2,r3
  0019b2fc: 8fb00010 lw r16,0x0010(r29)
+
0019b23c: ae420cb4 sw r2,0x0cb4(r18) Remove Target Unit with P-Ev (Get behind them behavior?) (1a0078)
  0019b300: 27bd0028 addiu r29,r29,0x0028
+
 
  0019b304: 03e00008 jr r31
+
<4> (Create Targetable Unit list)
  0019b308: 00000000 nop
+
0019b240: 0c066fcb jal 0x0019bf2c Find Highest Priority Unit in Range
</font></font>
+
0019b244: 00000000 nop
 +
0019b248: 2403ffff addiu r3,r0,0xffff
 +
0019b24c: 14430003 bne r2,r3,0x0019b25c
 +
0019b250: 00008021 addu r16,r0,r0
 +
0019b254: 08066cb5 j 0x0019b2d4 Set next decision to 04 and exit
 +
0019b258: 34020004 ori r2,r0,0x0004
 +
 
 +
0019b25c: 02501021 addu r2,r18,r16
 +
0019b260: 90430ca2 lbu r3,0x0ca2(r2) Load isTarget
 +
0019b264: 26100001 addiu r16,r16,0x0001
 +
0019b268: a0430c8d sb r3,0x0c8d(r2) Save isTarget
 +
0019b26c: 2a020015 slti r2,r16,0x0015
 +
0019b270: 1440fffb bne r2,r0,0x0019b260 Do for all units
 +
0019b274: 02501021 addu r2,r18,r16
 +
 +
Is AoE
 +
0019b278: 92420005 lbu r2,0x0005(r18) Load AoE
 +
0019b27c: 00000000 nop
 +
0019b280: 10400017 beq r2,r0,0x0019b2e0 Exit if no AoE
 +
0019b284: 00000000 nop
 +
 +
Can't follow target
 +
0019b288: 0c067c07 jal 0x0019f01c Check if any targetable units can be hit in time
 +
0019b28c: 00000000 nop
 +
0019b290: 10400013 beq r2,r0,0x0019b2e0 Exit if nothing can be hit in time
 +
0019b294: 34020005 ori r2,r0,0x0005
 +
0019b298: a2420026 sb r2,0x0026(r18) 0x05 - Target Panel
 +
0019b29c: 8e42000c lw r2,0x000c(r18) Load AI Flag
 +
0019b2a0: 3c030100 lui r3,0x0100
 +
0019b2a4: 00431024 and r2,r2,r3
 +
0019b2a8: 10400005 beq r2,r0,0x0019b2c0 Branch if not Physical
 +
0019b2ac: 3c030200 lui r3,0x0200
 +
0019b2b0: 8e420cb4 lw r2,0x0cb4(r18)
 +
0019b2b4: 00000000 nop
 +
0019b2b8: 00431025 or r2,r2,r3
 +
0019b2bc: ae420cb4 sw r2,0x0cb4(r18) Save as Target Unit with P-Ev (Get behind them behavior?) (1a0078)
 +
 
 +
<5 and 9+> (Everything else)
 +
0019b2c0: 0c066fcb jal 0x0019bf2c Find Highest Priority Unit in Range
 +
0019b2c4: 00000000 nop
 +
0019b2c8: 2403ffff addiu r3,r0,0xffff
 +
0019b2cc: 14430004 bne r2,r3,0x0019b2e0 Exit and go to next ability
 +
0019b2d0: 34020005 ori r2,r0,0x0005
 +
 
 +
0019b2d4: a2420c70 sb r2,0x0c70(r18) Set Next Decision to 5
 +
0019b2d8: 08066cbb j 0x0019b2ec Select Ability
 +
0019b2dc: 2402ffff addiu r2,r0,0xffff
 +
 
 +
0019b2e0: 0c065bf1 jal 0x00196fc4 Compare and Set Highest Unit Target Priority
 +
0019b2e4: 00000000 nop
 +
0019b2e8: 00001021 addu r2,r0,r0
 +
0019b2ec: 8fbf0020 lw r31,0x0020(r29)
 +
0019b2f0: 8fb3001c lw r19,0x001c(r29)
 +
0019b2f4: 8fb20018 lw r18,0x0018(r29)
 +
0019b2f8: 8fb10014 lw r17,0x0014(r29)
 +
0019b2fc: 8fb00010 lw r16,0x0010(r29)
 +
0019b300: 27bd0028 addiu r29,r29,0x0028
 +
0019b304: 03e00008 jr r31
 +
0019b308: 00000000 nop

Latest revision as of 19:41, 15 June 2024

Chose an Ability from the Unit's Skillsets       ALTERNATIVE VERSION AI_Ability_Outcome_Evaluation
Evaluate an ability for and either selects it or rejects it.
Sets a Decision Value to base the next ability evaluation.

190c3c/19f3c4/1a0000
0019af18: 3c02801a lui r2,0x801a
0019af1c: 90420d7b lbu r2,0x0d7b(r2)                 	Load Action Decided?
0019af20: 27bdffd8 addiu r29,r29,0xffd8
0019af24: afb20018 sw r18,0x0018(r29)
0019af28: 3c12801a lui r18,0x801a
0019af2c: 2652f3c4 addiu r18,r18,0xf3c4				r18 = AI Data
0019af30: afbf0020 sw r31,0x0020(r29)
0019af34: afb3001c sw r19,0x001c(r29)
0019af38: afb10014 sw r17,0x0014(r29)
0019af3c: 1040000d beq r2,r0,0x0019af74				<1 - Frame RNG> if no action taken yet
0019af40: afb00010 sw r16,0x0010(r29)
0019af44: 3c03801a lui r3,0x801a
0019af48: 90630034 lbu r3,0x0034(r3)					Decision Byte
0019af4c: 00000000 nop									(This contains previous decisions made in this very routine. Is not reset when changing unit turns.
0019af50: 2c620009 sltiu r2,r3,0x0009
0019af54: 104000da beq r2,r0,0x0019b2c0				Branch if Decision byte's too high (just a safe check)	
0019af58: 00031080 sll r2,r3,0x02
0019af5c: 3c018019 lui r1,0x8019
0019af60: 00220821 addu r1,r1,r2
0019af64: 8c223db0 lw r2,0x3db0(r1)					Load Jump Addresses
0019af68: 00000000 nop
0019af6c: 00400008 jr r2
0019af70: 00000000 nop
8019b0b8		0 - Reflect and Ability Usage. 
8019b100		1 - Unit Rangefinder. Will loop through all abilities until it finds an ability with targets in range. Merges into main routine when successful.
8019b160		2 - AoE Evaluation. After determining if there is an AoE, determines if it can hit any other unit in time.
8019b1cc		3 - Spell CT vs Target CT. Evaluates all units for CT timings.
8019b240		4 - Targetable Unit List. 
8019b2c0		5 - Simply finds the highest priority unit in range, compares to high score, then exits. Every other decision above 8 is also redirected here as well. 
8019b068		6 - Math Skill Evaluation. Loops itself until the Math Skill Evaluation is complete. I do not know how it breaks out of this loop.
8019af74		7 - The Main Routine. Initialize Ability Data, then determines Random Use, Target Map, and Crystal/Treasure Check. Resets to itself or will go to 1 when it needs to rangefind units.
8019b094		8 - Positioning Check. The final part of Target Map evaluation. Is the unit in the right place to correctly use this ability? Elemental/Monster Skill/Water Depth are checked in the subroutine. Compares ability priority to highest priority score then exits.

<7 - Usable by AI, Random Usage, Ignore Range> <Frame Cycle>

0019af74: 0c0076ea jal 0x0001dba8					Get Frame Data
0019af78: 34040001 ori r4,r0,0x0001	
0019af7c: 284201b9 slti r2,r2,0x01b9	
0019af80: 104000d4 beq r2,r0,0x0019b2d4			Exit if it's time to animate; Set next decision to 07	
0019af84: 34020007 ori r2,r0,0x0007	

<Usable by AI>

0019af88: 8e42000c lw r2,0x000c(r18)				Load AI Flags
0019af8c: 00000000 nop	
0019af90: 044100d5 bgez r2,0x0019b2e8				Next Ability if not Usable by the AI (0x80000000 makes it negative)
0019af94: a24019b7 sb r0,0x19b7(r18)

<Random Use Flag>

0019af98: 30420800 andi r2,r2,0x0800	
0019af9c: 1040000e beq r2,r0,0x0019afd8			Branch if not Random Hits
0019afa0: 00000000 nop	
0019afa4: 925019b8 lbu r16,0x19b8(r18)				Load Random Ability Counter (# of random hits abilities*128 / number of usable abilities)
0019afa8: 0c0088c3 jal 0x0002230c					Random Number Generator
0019afac: 00000000 nop
0019afb0: 00401821 addu r3,r2,r0
0019afb4: 04610003 bgez r3,0x0019afc4				Process Random Number
0019afb8: 000211c3 sra r2,r2,0x07
0019afbc: 2462007f addiu r2,r3,0x007f
0019afc0: 000211c3 sra r2,r2,0x07
0019afc4: 000211c0 sll r2,r2,0x07
0019afc8: 00621023 subu r2,r3,r2
0019afcc: 0202102a slt r2,r16,r2
0019afd0: 144000c6 bne r2,r0,0x0019b2ec			Randomly decide to not use a Random Hits ability (Good one, Square...)		
0019afd4: 00001021 addu r2,r0,r0

<Initialize Ability Data>

0019afd8: 92420000 lbu r2,0x0000(r18)				Load Skillset
0019afdc: 96430002 lhu r3,0x0002(r18)				Load Ability ID
0019afe0: 92440006 lbu r4,0x0006(r18)				Load Item ID
0019afe4: 00008021 addu r16,r0,r0					Initialize Unit ID
0019afe8: a242001d sb r2,0x001d(r18)				Save as Last Skillset Used
0019afec: a643001e sh r3,0x001e(r18)				Save as Last Ability Used
0019aff0: a2440024 sb r4,0x0024(r18)				Save as Item Destroyed/Stolen
0019aff4: 02501021 addu r2,r18,r16					Load Current Unit AI Data
0019aff8: 90430c78 lbu r3,0x0c78(r2)				Load isTargetable list
0019affc: 26100001 addiu r16,r16,0x0001
0019b000: a0430c8d sb r3,0x0c8d(r2)				Save isTargetable list copy
0019b004: 2a020015 slti r2,r16,0x0015
0019b008: 1440fffb bne r2,r0,0x0019aff8			Do for all units
0019b00c: 02501021 addu r2,r18,r16					Next Unit

<Target Map>

0019b010: 8e43000c lw r3,0x000c(r18)				Get AI Flags
0019b014: 00000000 nop
0019b018: 30628000 andi r2,r3,0x8000
0019b01c: 10400024 beq r2,r0,0x0019b0b0			Branch if not Target Map
0019b020: 30624000 andi r2,r3,0x4000				Get Reflect Flag

<Check for Crystal/Treasure>

0019b024: 92440e2e lbu r4,0x0e2e(r18)				r4 = Acting Unit ID
0019b028: 92420e2d lbu r2,0x0e2d(r18)				r2 = Targeted Unit ID?
0019b02c: 34030006 ori r3,r0,0x0006
0019b030: a2430026 sb r3,0x0026(r18)				0x06 - Save Ignore range
0019b034: 00021080 sll r2,r2,0x02					ID * 4
0019b038: 00521021 addu r2,r2,r18
0019b03c: a2440027 sb r4,0x0027(r18)				Save Acting Unit ID
0019b040: 8c420cc4 lw r2,0x0cc4(r2)				Load Target Unit AI Pointer
0019b044: 0c066ec8 jal 0x0019bb20					Check for Crystal/Treasure on map (saves to 0x0083/0xf447/0x0cbf)
0019b048: ae420018 sw r2,0x0018(r18)				Save Target Unit AI Pointer
0019b04c: 92420000 lbu r2,0x0000(r18)				Load Skillset
0019b050: 3c018006 lui r1,0x8006
0019b054: 00220821 addu r1,r1,r2
0019b058: 90235cb4 lbu r3,0x5cb4(r1)				Get Action Menu
0019b05c: 34020003 ori r2,r0,0x0003
0019b060: 14620008 bne r3,r2,0x0019b084			Branch if not Math Skill
0019b064: 00000000 nop

<6> Math Skill

0019b068: 0c066eef jal 0x0019bbbc					Math Skill Targeting
0019b06c: 00000000 nop	
0019b070: 2403ffff addiu r3,r0,0xffff	
0019b074: 1443009c bne r2,r3,0x0019b2e8			Next Ability if -1
0019b078: 34020006 ori r2,r0,0x0006	
0019b07c: 08066cb6 j 0x0019b2d8					Select ability and exit
0019b080: a2420c70 sb r2,0x0c70(r18)				Set next decision to 6

<Every other Ignore Range Ability>

0019b084: 0c067950 jal 0x0019e540					Check if ability can effect any units
0019b088: 00000000 nop	
0019b08c: 10400097 beq r2,r0,0x0019b2ec			Next move if Ability can't effect any units
0019b090: 00001021 addu r2,r0,r0

<8> Positioning Check

0019b094: 0c065bbd jal 0x00196ef4					Monster Skill/Elemental/Water Depth/Mount?? Check
0019b098: 00000000 nop								Otherwise it basically okays everything
0019b09c: 2403ffff addiu r3,r0,0xffff
0019b0a0: 1443008f bne r2,r3,0x0019b2e0			Go to routine, then exit to next ability if -1
0019b0a4: 34020008 ori r2,r0,0x0008
0019b0a8: 08066cb6 j 0x0019b2d8					Jump to exit and choose ability
0019b0ac: a2420c70 sb r2,0x0c70(r18)				Set next decision to 8


0019b0b0: 10400008 beq r2,r0,0x0019b0d4			Branch if not Reflectable
0019b0b4: 00000000 nop

<0>Reflect

0019b0b8: 0c066dee jal 0x0019b7b8					Target Analysis Routine (Reflect Spell Banking behavior?)
0019b0bc: 00000000 nop	
0019b0c0: 2403ffff addiu r3,r0,0xffff	
0019b0c4: 14430003 bne r2,r3,0x0019b0d4			Branch if no unit can be hit with a reflected spell
0019b0c8: 2402ffff addiu r2,r0,0xffff	
0019b0cc: 08066cbb j 0x0019b2ec					Choose ability and exit
0019b0d0: a2400c70 sb r0,0x0c70(r18)				Set next decision to 0

<Normal Spell>

0019b0d4: 0c067950 jal 0x0019e540					See if ability can effect any unit
0019b0d8: 00000000 nop
0019b0dc: 10400083 beq r2,r0,0x0019b2ec			Exit and don't chose this ability if it can't
0019b0e0: 00001021 addu r2,r0,r0
0019b0e4: 92420e2e lbu r2,0x0e2e(r18)				Load Acting Unit's ID
0019b0e8: 00000000 nop
0019b0ec: 02421021 addu r2,r18,r2
0019b0f0: 90420c8d lbu r2,0x0c8d(r2)				Get isTargetable
0019b0f4: 00000000 nop
0019b0f8: 10400006 beq r2,r0,0x0019b114			Branch if cannot target self?
0019b0fc: 00000000 nop

<1>(Ability Use) Follow Target and P-Ev check

0019b100: 0c066cc3 jal 0x0019b30c					Check if any units are in Range
0019b104: 00000000 nop	
0019b108: 2403ffff addiu r3,r0,0xffff	
0019b10c: 10430071 beq r2,r3,0x0019b2d4			Set Decision to 1 and choose ability if units are in range
0019b110: 34020001 ori r2,r0,0x0001

<Can't Target Self>

0019b114: 92440e2e lbu r4,0x0e2e(r18)				r4 = Acting Unit's ID
0019b118: 0c067976 jal 0x0019e5d8					AI Ability Use
0019b11c: 34050001 ori r5,r0,0x0001				
0019b120: 8e43000c lw r3,0x000c(r18)				Load AI Flags
0019b124: 00000000 nop
0019b128: 30631000 andi r3,r3,0x1000
0019b12c: 10600056 beq r3,r0,0x0019b288			<Hit Panel> if not Follow Target
0019b130: a2420e4c sb r2,0x0e4c(r18)				Save Current Ability Decision (0 = Cannot Effect Unit, 1 = usable, 2 = Heals Target)
0019b134: 34020006 ori r2,r0,0x0006
0019b138: a2420026 sb r2,0x0026(r18)				06 = Ability Follows Unit (instead of Panel)
0019b13c: 8e42000c lw r2,0x000c(r18)				Load AI Flags
0019b140: 3c030100 lui r3,0x0100
0019b144: 00431024 and r2,r2,r3
0019b148: 1040000c beq r2,r0,0x0019b17c			<Target Unit without P-Ev) if not Physical Evadable
0019b14c: 3c030200 lui r3,0x0200
0019b150: 8e420cb4 lw r2,0x0cb4(r18)				Load AI Flags Copy
0019b154: 00000000 nop
0019b158: 00431025 or r2,r2,r3
0019b15c: ae420cb4 sw r2,0x0cb4(r18)				Save as Target Unit with P-Ev (Get behind them behavior?) (1a0078)

<2> Target Unit with P-Ev flag

0019b160: 0c066fcb jal 0x0019bf2c					Find Highest Priority Unit in Range
0019b164: 00000000 nop	
0019b168: 2403ffff addiu r3,r0,0xffff	
0019b16c: 14430042 bne r2,r3,0x0019b278			<Find AoE> if not -1
0019b170: 34020002 ori r2,r0,0x0002	
0019b174: 08066cb6 j 0x0019b2d8					jump to exit and choose ability?
0019b178: a2420c70 sb r2,0x0c70(r18)				Set next decision as 02

(Target Unit without P-Ev)

0019b17c: 00008021 addu r16,r0,r0
0019b180: 02508821 addu r17,r18,r16
0019b184: 92220c8d lbu r2,0x0c8d(r17)				load isTargetable
0019b188: 92230c8d lbu r3,0x0c8d(r17)				load isTargetable
0019b18c: 00000000 nop
0019b190: 10600006 beq r3,r0,0x0019b1ac			Next Unit if current unit is untargetable
0019b194: a2220ca2 sb r2,0x0ca2(r17)				Save isTargetable
0019b198: 0c067c36 jal 0x0019f0d8					See if ability should be used based on CT
0019b19c: 02002021 addu r4,r16,r0
0019b1a0: 14400002 bne r2,r0,0x0019b1ac			Branch if Ability can hit in time
0019b1a4: 00000000 nop
0019b1a8: a2200c8d sb r0,0x0c8d(r17)				Unit is untargetable by this spell
0019b1ac: 26100001 addiu r16,r16,0x0001
0019b1b0: 2a020015 slti r2,r16,0x0015			
0019b1b4: 1440fff3 bne r2,r0,0x0019b184			Do for all units
0019b1b8: 02508821 addu r17,r18,r16
0019b1bc: 8e420cb4 lw r2,0x0cb4(r18)				Load AI Flags Copy
0019b1c0: 3c030200 lui r3,0x0200
0019b1c4: 00431025 or r2,r2,r3
0019b1c8: ae420cb4 sw r2,0x0cb4(r18)				Save as Target Unit with P-Ev (Get behind them behavior?) (1a0078)

<3> (Spell that can't Follow Target?)

0019b1cc: 0c066fcb jal 0x0019bf2c					Find Highest Priority Unit in Range
0019b1d0: 00000000 nop
0019b1d4: 2403ffff addiu r3,r0,0xffff
0019b1d8: 14430003 bne r2,r3,0x0019b1e8
0019b1dc: 00008021 addu r16,r0,r0
0019b1e0: 08066cb5 j 0x0019b2d4					Chose ability and set decision to 3
0019b1e4: 34020003 ori r2,r0,0x0003

<Spell CT vs Target CT>

0019b1e8: 34130001 ori r19,r0,0x0001
0019b1ec: 02508821 addu r17,r18,r16
0019b1f0: 92220ca2 lbu r2,0x0ca2(r17)				Load isTarget
0019b1f4: 00000000 nop
0019b1f8: 10400008 beq r2,r0,0x0019b21c			Next unit if unit can't be targeted
0019b1fc: 00000000 nop
0019b200: 0c067c36 jal 0x0019f0d8					See if ability should be used based on CT
0019b204: 02002021 addu r4,r16,r0
0019b208: 10400003 beq r2,r0,0x0019b218			Branch and mark unit as a target
0019b20c: 00000000 nop
0019b210: 08066c87 j 0x0019b21c
0019b214: a2200c8d sb r0,0x0c8d(r17)				Do not target unit
0019b218: a2330c8d sb r19,0x0c8d(r17)				Target Unit
0019b21c: 26100001 addiu r16,r16,0x0001			Unit Counter++
0019b220: 2a020015 slti r2,r16,0x0015
0019b224: 1440fff2 bne r2,r0,0x0019b1f0			Do for all units
0019b228: 02508821 addu r17,r18,r16
0019b22c: 3c03fdff lui r3,0xfdff
0019b230: 8e420cb4 lw r2,0x0cb4(r18)
0019b234: 3463ffff ori r3,r3,0xffff
0019b238: 00431024 and r2,r2,r3
0019b23c: ae420cb4 sw r2,0x0cb4(r18)				Remove Target Unit with P-Ev (Get behind them behavior?) (1a0078)

<4> (Create Targetable Unit list)

0019b240: 0c066fcb jal 0x0019bf2c					Find Highest Priority Unit in Range
0019b244: 00000000 nop
0019b248: 2403ffff addiu r3,r0,0xffff
0019b24c: 14430003 bne r2,r3,0x0019b25c
0019b250: 00008021 addu r16,r0,r0
0019b254: 08066cb5 j 0x0019b2d4					Set next decision to 04 and exit
0019b258: 34020004 ori r2,r0,0x0004	
0019b25c: 02501021 addu r2,r18,r16	
0019b260: 90430ca2 lbu r3,0x0ca2(r2)				Load isTarget
0019b264: 26100001 addiu r16,r16,0x0001
0019b268: a0430c8d sb r3,0x0c8d(r2)				Save isTarget
0019b26c: 2a020015 slti r2,r16,0x0015
0019b270: 1440fffb bne r2,r0,0x0019b260			Do for all units
0019b274: 02501021 addu r2,r18,r16

Is AoE

0019b278: 92420005 lbu r2,0x0005(r18)				Load AoE
0019b27c: 00000000 nop
0019b280: 10400017 beq r2,r0,0x0019b2e0			Exit if no AoE
0019b284: 00000000 nop

Can't follow target

0019b288: 0c067c07 jal 0x0019f01c					Check if any targetable units can be hit in time
0019b28c: 00000000 nop
0019b290: 10400013 beq r2,r0,0x0019b2e0			Exit if nothing can be hit in time
0019b294: 34020005 ori r2,r0,0x0005
0019b298: a2420026 sb r2,0x0026(r18)				0x05 - Target Panel
0019b29c: 8e42000c lw r2,0x000c(r18)				Load AI Flag
0019b2a0: 3c030100 lui r3,0x0100
0019b2a4: 00431024 and r2,r2,r3
0019b2a8: 10400005 beq r2,r0,0x0019b2c0			Branch if not Physical
0019b2ac: 3c030200 lui r3,0x0200
0019b2b0: 8e420cb4 lw r2,0x0cb4(r18)
0019b2b4: 00000000 nop
0019b2b8: 00431025 or r2,r2,r3
0019b2bc: ae420cb4 sw r2,0x0cb4(r18)				Save as Target Unit with P-Ev (Get behind them behavior?) (1a0078)

<5 and 9+> (Everything else)

0019b2c0: 0c066fcb jal 0x0019bf2c					Find Highest Priority Unit in Range
0019b2c4: 00000000 nop
0019b2c8: 2403ffff addiu r3,r0,0xffff
0019b2cc: 14430004 bne r2,r3,0x0019b2e0			Exit and go to next ability
0019b2d0: 34020005 ori r2,r0,0x0005			
0019b2d4: a2420c70 sb r2,0x0c70(r18)				Set Next Decision to 5
0019b2d8: 08066cbb j 0x0019b2ec					Select Ability
0019b2dc: 2402ffff addiu r2,r0,0xffff
0019b2e0: 0c065bf1 jal 0x00196fc4					Compare and Set Highest Unit Target Priority
0019b2e4: 00000000 nop
0019b2e8: 00001021 addu r2,r0,r0
0019b2ec: 8fbf0020 lw r31,0x0020(r29)
0019b2f0: 8fb3001c lw r19,0x001c(r29)
0019b2f4: 8fb20018 lw r18,0x0018(r29)
0019b2f8: 8fb10014 lw r17,0x0014(r29)
0019b2fc: 8fb00010 lw r16,0x0010(r29)
0019b300: 27bd0028 addiu r29,r29,0x0028
0019b304: 03e00008 jr r31
0019b308: 00000000 nop