Set AI ability considerations for all units and self

From Final Fantasy Hacktics Wiki
Jump to navigation Jump to search
BATTLE.BIN :  - Set AI ability considerations for all units and self                        DUPLICATED HERE Units_action_parameter_checking
Set Data in 8019f3c4 + 0x182c for each Unit (from r4 unit perspective), and Set flags in r4 Unit 8019f3c4 + 0xef0 List of ability (from self targeting perspective)
------------------------------------------------------------------------------------------
Parameter : r4 =Active Unit Action Taken [Battle 0x188]
Return : Nothing
         
------------------------------------------------------------------------------------------
00194e58: 27bdff70 addiu r29,r29,-0x0090     |
00194e5c: 340800ff ori r8,r0,0x00ff          |
00194e60: 340700ff ori r7,r0,0x00ff          |
00194e64: afb60080 sw r22,0x0080(r29)        |
00194e68: 3c16801a lui r22,0x801a            |
00194e6c: 26d6f3c4 addiu r22,r22,-0x0c3c     |AI pointer 8019f3c4
00194e70: afb70084 sw r23,0x0084(r29)        |
00194e74: 0000b821 addu r23,r0,r0            |Initialize
00194e78: afbf008c sw r31,0x008c(r29)        |
00194e7c: afbe0088 sw r30,0x0088(r29)        |
00194e80: afb5007c sw r21,0x007c(r29)        |
00194e84: afb40078 sw r20,0x0078(r29)        |
00194e88: afb30074 sw r19,0x0074(r29)        |
00194e8c: afb20070 sw r18,0x0070(r29)        |
00194e90: afb1006c sw r17,0x006c(r29)        |
00194e94: afb00068 sw r16,0x0068(r29)        |
00194e98: afa40010 sw r4,0x0010(r29)         |Preserve Active Unit Action Taken byte [Battle 0x188]
00194e9c: afa00020 sw r0,0x0020(r29)         |Reset Enemy team Harmfull Ability counter
00194ea0: afa00028 sw r0,0x0028(r29)         |Reset Enemy team Magical Attack counter
00194ea4: afa00030 sw r0,0x0030(r29)         |Reset Enemy team Physical Attack counter
00194ea8: afa00038 sw r0,0x0038(r29)         |Reset Enemy Team Reflectable Attack counter
00194eac: afa00040 sw r0,0x0040(r29)         |Reset Enemy Team Earth Attack counter
00194eb0: afa80058 sw r8,0x0058(r29)         |Reset Nb of usable abilities for the unit with the fewest usable abilities
00194eb4: afa70060 sw r7,0x0060(r29)         |Unit ID of 0x58
                  TEST ALL UNITS and ALL ABILITIES and set some AI Unit flags for Acting Unit
                                            @Main  Unit Loop
00194eb8: 0c065b23 jal 0x00196c8c                |-->Check_target_type returns 0x00 if can/worth to be targeted
00194ebc: 02e02021 addu r4,r23,r0                |
00194ec0: 14400142 bne r2,r0,0x001953cc          #If Unit is not worth/able to be targeted : branch to  Next Unit
00194ec4: 00171100 sll r2,r23,0x04               |targets ID*16
00194ec8: 2442182c addiu r2,r2,0x182c            |
00194ecc: 3c08801a lui r8,0x801a                 |
00194ed0: 2508f3c4 addiu r8,r8,-0x0c3c           |
00194ed4: 0102a821 addu r21,r8,r2                |Dynamic pointer to this unit AI 0x182c
00194ed8: 001710c0 sll r2,r23,0x03               |
00194edc: 00571023 subu r2,r2,r23                |
00194ee0: 00021180 sll r2,r2,0x06                |ID * 0x1c0
00194ee4: 3c038019 lui r3,0x8019                 |
00194ee8: 246308cc addiu r3,r3,0x08cc            |
00194eec: 3c04801a lui r4,0x801a                 |
00194ef0: 908401f2 lbu r4,0x01f2(r4)             |Acting Unit ID  801a01f2
00194ef4: 0043a021 addu r20,r2,r3                |Dynamic pointer to Unit Battle data
00194ef8: afa00048 sw r0,0x0048(r29)             |Reset Unit Harmfull Ability counter
00194efc: 16e40003 bne r23,r4,0x00194f0c         #If This Iteration unit is the active Unit
00194f00: afa00050 sw r0,0x0050(r29)             |Reset Unit Helpfull Ability counter
00194f04: 080653c6 j 0x00194f18                      >>Avoid clockticks check
00194f08: afa00018 sw r0,0x0018(r29)                 |Set ClockTicks to 0x00
                                                Else : not active Unit
00194f0c: 0c0666e6 jal 0x00199b98                    |-->calculate clockticks till unit acts returns remaining ticks before next action
00194f10: 02802021 addu r4,r20,r0                    |Send Unit battle pointer
00194f14: afa20018 sw r2,0x0018(r29)                 |store clockticks till unit acts
00194f18: 92a20006 lbu r2,0x0006(r21)            |AI 0x182c - 0x06
00194f1c: 0000f021 addu r30,r0,r0                |reset below loop counter
00194f20: 304200fc andi r2,r2,0x00fc             |clear hp recovery on ally/not direct or arcing attack
00194f24: a2a20006 sb r2,0x0006(r21)             |Update AI 0x182c - 0x06 without flags 0x02 and 0x01
                                                @LOOP - 0x22 times (Each usable Abilities of this unit at 8019f3c4 + 0xef0)
00194f28: 3c07801a lui r7,0x801a                     |
00194f2c: 24e7f3c4 addiu r7,r7,-0x0c3c               |
00194f30: 00f71021 addu r2,r7,r23                    |Dynamic Pointer to AI DATA (1byte per unit)
00194f34: 9043198c lbu r3,0x198c(r2)                 |Load This unit battle ID
00194f38: 00000000 nop                               |
00194f3c: 00031100 sll r2,r3,0x04                    |ID*16
00194f40: 00431021 addu r2,r2,r3                     |ID*17
00194f44: 000210c0 sll r2,r2,0x03                    |ID*136 (0x88)
00194f48: 24420ef0 addiu r2,r2,0x0ef0                |
00194f4c: 00e21021 addu r2,r7,r2                     |Dynamic Pointer to AI Data 0x0ef0 (0x88 bytes) List of usable abilities
00194f50: 001e1880 sll r3,r30,0x02                   |This loop counter *4
00194f54: 00439821 addu r19,r2,r3                    |Dynamic Pointer to AI Data 0x0ef0 (0x88 bytes)  +0x04 Per iteration  (0x22 Iteration per unit)
00194f58: 96620002 lhu r2,0x0002(r19)                |Load skillset and usage
00194f5c: 00000000 nop                               |
00194f60: 30427fff andi r2,r2,0x7fff                 |remove usage flag
00194f64: a6620002 sh r2,0x0002(r19)                 |Update 0x03 =without flag 0x80 (no usage by default)
00194f68: 92630002 lbu r3,0x0002(r19)                |load skillset
00194f6c: 340200ff ori r2,r0,0x00ff                  |
00194f70: 106200f3 beq r3,r2,0x00195340              #If  the code reach the end of the list : Exit loop
00194f74: 00000000 nop                                   |
00194f78: 0c06561e jal 0x00195878                    |-->AI ability data setting Transfer Ability data to 8019f3c4 section
00194f7c: 02602021 addu r4,r19,r0                    |Send Pointer
00194f80: 92c30001 lbu r3,0x0001(r22)                |load CT of ability
00194f84: 9282005a lbu r2,0x005a(r20)                |load target status 3
00194f88: 8fa80018 lw r8,0x0018(r29)                 |load clockticks till unit acts
00194f8c: 86d00002 lh r16,0x0002(r22)                |load ability ID
00194f90: 30420002 andi r2,r2,0x0002                 |
                                            FROG RESTRICTION SECTION - ( Allow only Frog spell and frog Attack if Frog // Disallow Frog Attack if not Frog)
00194f94: 10400008 beq r2,r0,0x00194fb8              #If Considered Target has Frog status
00194f98: 01038821 addu r17,r8,r3                    |r17 = ability CT + clockticks till unit acts
00194f9c: 3402001d ori r2,r0,0x001d                      |
00194fa0: 12020008 beq r16,r2,0x00194fc4                 #If Frog Spell : branch to  Frog test is OK
00194fa4: 3402016f ori r2,r0,0x016f                          |
00194fa8: 12020006 beq r16,r2,0x00194fc4                 #If Frog Attack : branch to Frog test is OK
00194fac: 00000000 nop                                       |
00194fb0: 080654cd j 0x00195334                          >>Since this ability is not ok for Frog  : jump to  Next Ability
00194fb4: 27de0001 addiu r30,r30,0x0001                      |Loop counter +1
                                                    Else : not Frog Target
00194fb8: 3402016f ori r2,r0,0x016f                      |
00194fbc: 120200dc beq r16,r2,0x00195330                 #If This Ability is [Frog Attack] branch to Next Ability
00194fc0: 00000000 nop                                   |
                                            FROG TEST PASSED
00194fc4: 8fa40018 lw r4,0x0018(r29)                 |load clockticks till unit acts
00194fc8: 02802821 addu r5,r20,r0                    |Unit battle data pointer
00194fcc: 0c067bc9 jal 0x0019ef24                    |-->check if status should/can be applied returns r2 = 0x01 if unit has don't act
00194fd0: 34060025 ori r6,r0,0x0025                  |Check don't act
00194fd4: 144000d6 bne r2,r0,0x00195330              #If Unit already has don't act : branch to  Next Ability
00194fd8: 00000000 nop                                   |
00194fdc: 96c2000c lhu r2,0x000c(r22)                |Load this Ability AI flags 1 and 2
00194fe0: 00000000 nop                               |
00194fe4: 30420100 andi r2,r2,0x0100                 |Check [Ignore Silence] Incverted flag in Patcher, it's more likely [silencable]
00194fe8: 10400006 beq r2,r0,0x00195004              #If this Ability is silencable
00194fec: 02202021 addu r4,r17,r0                        |Ability CT + clockticks till unit acts
00194ff0: 02802821 addu r5,r20,r0                        |Unit battle data pointer
00194ff4: 0c067bc9 jal 0x0019ef24                        |-->check if status should/can be applied returns r2 = 0x01 if unit has don't act
00194ff8: 3406000c ori r6,r0,0x000c                      |check if unit has silence
00194ffc: 144000cc bne r2,r0,0x00195330                  #If Unit has silence : branch to  Next Ability This ability is not an issue anymore
00195000: 00000000 nop                                       |
00195004: 96c2000c lhu r2,0x000c(r22)                |Load this Ability AI flags 1 and 2
00195008: 00000000 nop                               |
0019500c: 30420400 andi r2,r2,0x0400                 |Check [Affected by faith]
00195010: 10400006 beq r2,r0,0x0019502c              #If Ability is affected by Faith
00195014: 02202021 addu r4,r17,r0                        |Ability CT + clockticks till unit acts
00195018: 02802821 addu r5,r20,r0                        |Unit battle data pointer
0019501c: 0c067bc9 jal 0x0019ef24                        |-->check if status should/can be applied
00195020: 34060021 ori r6,r0,0x0021                      |check for innocent
00195024: 144000c2 bne r2,r0,0x00195330                  #If Unit has innocent : branch to  Next Ability This ability is not an issue anymore
00195028: 00000000 nop                                   |
0019502c: 92c30011 lbu r3,0x0011(r22)                |Ability MP cost
00195030: 9682002c lhu r2,0x002c(r20)                |Targeted Unit MP
00195034: 00000000 nop                               |
00195038: 0043102b sltu r2,r2,r3                     |
0019503c: 144000bc bne r2,r0,0x00195330              #If Unit has not enough MP to cast this ability : branch to  Next Ability
00195040: 00000000 nop                                   |
00195044: 92620002 lbu r2,0x0002(r19)                |This Ability's skillset
00195048: 3c018006 lui r1,0x8006                     |
0019504c: 00220821 addu r1,r1,r2                     |
00195050: 90235cb4 lbu r3,0x5cb4(r1)                 |This Skillset action menu byte
00195054: 34020001 ori r2,r0,0x0001                  |
00195058: 10620007 beq r3,r2,0x00195078              #If Action Menu is Item iventory : branch to  Inventory section
0019505c: 34020007 ori r2,r0,0x0007                  |
00195060: 10620005 beq r3,r2,0x00195078              #If Action Menu is katana iventory : branch to  Inventory section
00195064: 3402017e ori r2,r0,0x017e                  |
00195068: 12020003 beq r16,r2,0x00195078             #If Ability is Shuriken : branch to  Inventory section
0019506c: 34020189 ori r2,r0,0x0189                  |
00195070: 1602001e bne r16,r2,0x001950ec             #If Ability is Not Ball :   Jump to weapon inventory section
00195074: 34020002 ori r2,r0,0x0002                  |
                                            Item inventory / Katana  / Shuriken / Ball (1 Item ID for 1 ability ID)
00195078: 928201ba lbu r2,0x01ba(r20)                    |Targeted Unit modified ENTD
0019507c: 00000000 nop                                   |
00195080: 30420030 andi r2,r2,0x0030                     |Check Team
00195084: 1440000a bne r2,r0,0x001950b0                  #If Unit is in player Team
00195088: 00000000 nop                                       |
0019508c: 92c20006 lbu r2,0x0006(r22)                        |Load item considered
00195090: 3c018006 lui r1,0x8006                             |
00195094: 00220821 addu r1,r1,r2                             |Part of inventory Pointer
00195098: 902296e0 lbu r2,-0x6920(r1)                        |load item quantity  800596e0 + item ID
0019509c: 00000000 nop                                       |
001950a0: 14400052 bne r2,r0,0x001951ec                      #If item is in inventory : branch to set usage Flag
001950a4: 00000000 nop                                           |
001950a8: 080654cd j 0x00195334                              >>Else (no item)  Jump to  Next Ability
001950ac: 27de0001 addiu r30,r30,0x0001                          |
                                                        Else : Unit  is in AI team
001950b0: 92c30006 lbu r3,0x0006(r22)                        |Load item considered
001950b4: 00000000 nop                                       |
001950b8: 00031040 sll r2,r3,0x01                            |item*2
001950bc: 00431021 addu r2,r2,r3                             |item*3
001950c0: 00021080 sll r2,r2,0x02                            |item*12
001950c4: 3c018006 lui r1,0x8006                             |
001950c8: 00220821 addu r1,r1,r2                             |
001950cc: 90232eba lbu r3,0x2eba(r1)                         |load item required level
001950d0: 92820022 lbu r2,0x0022(r20)                        |load Unit Level
001950d4: 00000000 nop                                       |
001950d8: 0043102b sltu r2,r2,r3                             |
001950dc: 10400043 beq r2,r0,0x001951ec                      #If Unit Lv >= Item Lv : Branch to  set usage Flag
001950e0: 00000000 nop                                           |
001950e4: 080654cd j 0x00195334                              >>If Unit Lv < Item Lv : jump to  Next Ability
001950e8: 27de0001 addiu r30,r30,0x0001                          |
                                            WEAPON INVENTORY (1 Ability for several items)
001950ec: 1462003f bne r3,r2,0x001951ec              #If Action menu is weapon inventory
001950f0: 00000000 nop                                   |
001950f4: 3c02801a lui r2,0x801a                         |
001950f8: 904201f2 lbu r2,0x01f2(r2)                     |load acting unit ID
001950fc: 00000000 nop                                   |
00195100: 16e2008b bne r23,r2,0x00195330                 #If Considered Unit is not the acting Unit : branch to  Next Ability
00195104: 2411ffff addiu r17,r0,0xffff                   |Reset Best Level Value
00195108: 3410017f ori r16,r0,0x017f                     |Loop Counter - Start as Knife Ability ID
0019510c: 34120001 ori r18,r0,0x0001                     |
                                                        @LOOP - Check all Throw Abilities (Find Higher Lv to throw)
00195110: 02e02021 addu r4,r23,r0                            |Send Unit ID
00195114: 92c50000 lbu r5,0x0000(r22)                        |Send Skillset ID
00195118: 0c066a94 jal 0x0019aa50                            |-->load known ability flag
0019511c: 2606fe83 addiu r6,r16,-0x017D                      |Send Ability position in Skillset
00195120: 1040002b beq r2,r0,0x001951d0                      #If Ability is not known : branch to Next Ability
00195124: 00000000 nop                                           |
00195128: 3c018006 lui r1,0x8006                             |
0019512c: 00320821 addu r1,r1,r18                            |Part of Dynamic pointer
00195130: 90261020 lbu r6,0x1020(r1)                         |load throw ability item type 80061020
00195134: 00002021 addu r4,r0,r0                             |
00195138: 00002821 addu r5,r0,r0                             |Loop counter
                                                            @LOOP - Seek best item (on Lv) matching Ability Type
0019513c: 3c018006 lui r1,0x8006                                 |
00195140: 00250821 addu r1,r1,r5                                 |Part of dynamic pointer to item data
00195144: 90222ebd lbu r2,0x2ebd(r1)                             |Load item type 80062eb8 + 0x05
00195148: 00000000 nop                                           |
0019514c: 1446001c bne r2,r6,0x001951c0                          #If this item is not from Ability's item type : branch to  Next Item
00195150: 00000000 nop                                               |
00195154: 3c018006 lui r1,0x8006                                 |
00195158: 00250821 addu r1,r1,r5                                 |Part of dynamic pointer to item data
0019515c: 90232eba lbu r3,0x2eba(r1)                             |This Weapon required level
00195160: 00000000 nop                                           |
00195164: 0071102a slt r2,r3,r17                                 |
00195168: 14400015 bne r2,r0,0x001951c0                          #If This weapon Lv is not the best lv so far : branch to  Next Item
0019516c: 00000000 nop                                               |
00195170: 928201ba lbu r2,0x01ba(r20)                            |Acting Unit modified ETND flags
00195174: 00000000 nop                                           |
00195178: 30420030 andi r2,r2,0x0030                             |
0019517c: 14400006 bne r2,r0,0x00195198                          #If Acting unit is in player Team
00195180: 00000000 nop                                               |
00195184: 3c018006 lui r1,0x8006                                     |
00195188: 00240821 addu r1,r1,r4                                     |Part of pointer to inventory
0019518c: 902296e0 lbu r2,-0x6920(r1)                                |load quantity
00195190: 08065469 j 0x001951a4                                      >>Avoid AI Team section
00195194: 2c420005 sltiu r2,r2,0x0005                                |set if quantity is less than 05
                                                                Else : Acting unit is in AI team
00195198: 92820022 lbu r2,0x0022(r20)                                |Load Acting Unit Level
0019519c: 00000000 nop                                               |
001951a0: 0043102a slt r2,r2,r3                                      |
001951a4: 14400006 bne r2,r0,0x001951c0                          #If [AI Unit Lv is too low] or [Less than 5 items in inventory] : branch to  Next Item
001951a8: 00000000 nop                                               |
001951ac: 00608821 addu r17,r3,r0                                |Preserves this Item Level
001951b0: 3c01801a lui r1,0x801a                                 |
001951b4: a43001d8 sh r16,0x01d8(r1)                             |store chosen ability ID
001951b8: 3c01801a lui r1,0x801a                                 |
001951bc: a02401da sb r4,0x01da(r1)                              |store chosen weapon ID
001951c0: 24840001 addiu r4,r4,0x0001                            |counter + 1
001951c4: 28820100 slti r2,r4,0x0100                             |
001951c8: 1440ffdc bne r2,r0,0x0019513c                      Λ Loop 0x100 times ??  (all items !)
001951cc: 24a5000c addiu r5,r5,0x000c                            |Item data offset
001951d0: 26100001 addiu r16,r16,0x0001                      |Ability ID + 1
001951d4: 2a020189 slti r2,r16,0x0189                        |Loop limit is Ball Ability
001951d8: 1440ffcd bne r2,r0,0x00195110                  Λ check for next ability
001951dc: 26520001 addiu r18,r18,0x0001                      |Offset For Ability data at 80061020
001951e0: 2402ffff addiu r2,r0,0xffff                        |
001951e4: 12220052 beq r17,r2,0x00195330                 #if there is no throwable items : branch to  Next Ability
001951e8: 00000000 nop                                       |
                                            ALL ABILITIES
001951ec: 96620002 lhu r2,0x0002(r19)                |load skillset and usage type
001951f0: 00000000 nop                               |
001951f4: 34428000 ori r2,r2,0x8000                  |
001951f8: a6620002 sh r2,0x0002(r19)                 |Enable flag 0x80 on AI Tableof usable Abilities (0xef0 - 0x03) Can be used
001951fc: 30420800 andi r2,r2,0x0800                 |
00195200: 1440004b bne r2,r0,0x00195330              #If This ability requires monster skill : branch to  Next Ability
00195204: 00000000 nop                                   |
00195208: 92a20008 lbu r2,0x0008(r21)                |Load enemy flag of considered target
0019520c: 00000000 nop                               |
00195210: 10400026 beq r2,r0,0x001952ac              #If Target and Acting Unit are in same Team branch to   Avoid Enemy team section
00195214: 00000000 nop                                   |
00195218: 96c4000c lhu r4,0x000c(r22)                |This Ability AI Flags 1
0019521c: 00000000 nop                               |
00195220: 30820002 andi r2,r4,0x0002                 |
                                            Enemy Team  Harmfull Ability section
00195224: 10400021 beq r2,r0,0x001952ac              #If This Ability has [Target Ennemies] 
00195228: 00000000 nop                                   |
0019522c: 8fa70020 lw r7,0x0020(r29)                     |Enemy team harmfull ability counter
00195230: 96c3000e lhu r3,0x000e(r22)                    |This Ability AI Flags 3
00195234: 24e70001 addiu r7,r7,0x0001                    |
00195238: 30620002 andi r2,r3,0x0002                     |
0019523c: 10400005 beq r2,r0,0x00195254                  #If This Ability is a magic attack
00195240: afa70020 sw r7,0x0020(r29)                     |Increase Enemy team harmfull ability counter
00195244: 8fa80028 lw r8,0x0028(r29)                         |Load Enemy Magical attack counter
00195248: 00000000 nop                                       |
0019524c: 25080001 addiu r8,r8,0x0001                        |
00195250: afa80028 sw r8,0x0028(r29)                         |increase Enemy magic attack counter
00195254: 30620001 andi r2,r3,0x0001                     |
00195258: 10400005 beq r2,r0,0x00195270                  #If This Ability is a physical attack
0019525c: 30824000 andi r2,r4,0x4000                     |r2 = reflectable check
00195260: 8fa70030 lw r7,0x0030(r29)                         |Load Enemy Physical Attack counter
00195264: 00000000 nop                                       |
00195268: 24e70001 addiu r7,r7,0x0001                        |
0019526c: afa70030 sw r7,0x0030(r29)                         |increase Enemy Physical Attack counter physical attack counter
00195270: 10400005 beq r2,r0,0x00195288                  #If This Ability is reflectable
00195274: 00000000 nop                                       |
00195278: 8fa80038 lw r8,0x0038(r29)                         |load reflectable counter
0019527c: 00000000 nop                                       |
00195280: 25080001 addiu r8,r8,0x0001                        |
00195284: afa80038 sw r8,0x0038(r29)                         |Increase Enemy Team reflectable counter
00195288: 92c20010 lbu r2,0x0010(r22)                    |This Ability Elements
0019528c: 00000000 nop                                   |
00195290: 30420008 andi r2,r2,0x0008                     |
00195294: 10400005 beq r2,r0,0x001952ac                  #If This ability has Earth element
00195298: 00000000 nop                                       |
0019529c: 8fa70040 lw r7,0x0040(r29)                         |Load earth element counter
001952a0: 00000000 nop                                       |
001952a4: 24e70001 addiu r7,r7,0x0001                        |
001952a8: afa70040 sw r7,0x0040(r29)                         |Increase enemy Team earth element counter
                                            BOTH TEAM  Section
001952ac: 96c2000c lhu r2,0x000c(r22)                |This Ability AI Flags 1   8019f3c4 - 0x0c
001952b0: 34030081 ori r3,r0,0x0081                  |
001952b4: 30420081 andi r2,r2,0x0081                 |[Target Allies] and [Affect HP]
001952b8: 14430005 bne r2,r3,0x001952d0              #If This Ability is meant to Affect allies HP
001952bc: 00000000 nop                                   |
001952c0: 92a20006 lbu r2,0x0006(r21)                    |Load AI decision data (Table at 0x182c) byte 0x06 (Unit Battle 0x169)
001952c4: 00000000 nop                                   |
001952c8: 34420002 ori r2,r2,0x0002                      |Enable 0x02 Flag
001952cc: a2a20006 sb r2,0x0006(r21)                     |store HP recovery on ally flag
001952d0: 96c2000e lhu r2,0x000e(r22)                |This Ability AI Flags 3  8019f3c4 - 0x0e
001952d4: 00000000 nop                               |
001952d8: 304200c0 andi r2,r2,0x00c0                 |
001952dc: 10400005 beq r2,r0,0x001952f4              #If Ability has [Longbow] or [Stop at obstacle] flag
001952e0: 00000000 nop                                   |
001952e4: 92a20006 lbu r2,0x0006(r21)                    |Load AI decision data 0x06   (8019f3c4 -  0x182c) byte 0x06 (Unit Battle 0x169)
001952e8: 00000000 nop                                   |
001952ec: 34420001 ori r2,r2,0x0001                      |
001952f0: a2a20006 sb r2,0x0006(r21)                     |store abnormal trajectory ability flag
001952f4: 96c3000c lhu r3,0x000c(r22)                |This Ability AI Flags 1 
001952f8: 00000000 nop                               |
001952fc: 30620002 andi r2,r3,0x0002                 |
00195300: 10400005 beq r2,r0,0x00195318              #If This Ability is meant to target Ennemies
00195304: 30620001 andi r2,r3,0x0001                     |
00195308: 8fa80048 lw r8,0x0048(r29)                     |Load Harmfull ability counter
0019530c: 00000000 nop                                   |
00195310: 25080001 addiu r8,r8,0x0001                    |target enemies counter++
00195314: afa80048 sw r8,0x0048(r29)                     |Increase Unit Harmfull Ability counter
00195318: 10400005 beq r2,r0,0x00195330              #If This ability is meant to target Allies
0019531c: 00000000 nop                                   |
00195320: 8fa70050 lw r7,0x0050(r29)                     |Load Helpfull Ability counter
00195324: 00000000 nop                                   |
00195328: 24e70001 addiu r7,r7,0x0001                    |
0019532c: afa70050 sw r7,0x0050(r29)                     |Increase Unit Helpfull ability counter
00195330: 27de0001 addiu r30,r30,0x0001              |Ability  counter++
00195334: 2bc20022 slti r2,r30,0x0022                |Check limit
00195338: 1440fefb bne r2,r0,0x00194f28          Λ Loop through all the Ability list (0x22)
0019533c: 00000000 nop                               |
00195340: 92a20008 lbu r2,0x0008(r21)            |Enemy flag  AI 0x182c - 0x08
00195344: 00000000 nop                           |
                                            ACTING UNIT TEAMMATE
00195348: 14400020 bne r2,r0,0x001953cc          #If Unit is in Acting Unit Team
0019534c: 00000000 nop                               |
00195350: 8fa80050 lw r8,0x0050(r29)                 |Unit Helpfull Abilities counter
00195354: 8fa70048 lw r7,0x0048(r29)                 |Unit Harmfull Abilities counter
00195358: 00000000 nop                               |
0019535c: 01071821 addu r3,r8,r7                     |r3 = sum of abilities with target enemy/ally
00195360: 14600006 bne r3,r0,0x0019537c              #If no Helpfull nor Harmfull abilities
00195364: 000811c0 sll r2,r8,0x07                    |Pass Helpfull counter in upper byte
00195368: 92a20006 lbu r2,0x0006(r21)                    |Load AI Decision 0x06  AI 182c - 0x06 (From Battle 0x169)
0019536c: 00000000 nop                                   |
00195370: 304200fb andi r2,r2,0x00fb                     |remove 0x04 flag
00195374: 080654f3 j 0x001953cc                          >>go to next unit
00195378: a2a20006 sb r2,0x0006(r21)                     |Update AI Decision 0x06 without flag 0x04
                                                    Else : This Ally Unit has some Helpfull or Harmfull usable abilities
0019537c: 0043001a div r2,r3                             |
00195380: 00001812 mflo r3                               |Helpfull abilities * 128 / (Helpfull + Harmfull abilities)
00195384: 00000000 nop                                   |
00195388: 2862004d slti r2,r3,0x004d                     |set if less than 77
0019538c: 14400004 bne r2,r0,0x001953a0                  #If more than 60% of unit's abilities are helpfull
00195390: 00000000 nop                                       |
00195394: 92a20006 lbu r2,0x0006(r21)                        |Load AI Decision 0x06  AI 182c - 0x06 (From Battle 0x169)
00195398: 080654eb j 0x001953ac                              >>Avoid opposite section
0019539c: 34420004 ori r2,r2,0x0004                          |Enable 0x04 flag
                                                        Else : less than 60% of unit abilities are helpfull
001953a0: 92a20006 lbu r2,0x0006(r21)                        |Load AI Decision 0x06  AI 182c - 0x06 (From Battle 0x169)
001953a4: 00000000 nop                                       |
001953a8: 304200fb andi r2,r2,0x00fb                         |remove 0x04 flag
001953ac: a2a20006 sb r2,0x0006(r21)                     |Update AI decision 0x06 with or without flag 0x04 (based on ratio of helpfull abilities)
001953b0: 8fa70058 lw r7,0x0058(r29)                     |Load Abilty counter of unit with the fewest abilities
001953b4: 00000000 nop                                   |
001953b8: 0067102a slt r2,r3,r7                          |set if # of abilities < previous number
001953bc: 10400003 beq r2,r0,0x001953cc                  #If[Helpfull + Harmfull] < Previous entry
001953c0: 00000000 nop                                       |
001953c4: afb70060 sw r23,0x0060(r29)                        |store ID of Unit with the fewest Abilities
001953c8: afa30058 sw r3,0x0058(r29)                         |Store Nb of Abilities of this Unit
001953cc: 26f70001 addiu r23,r23,0x0001          |Loop counter + 1 and dynamic unit counter
001953d0: 2ae20015 slti r2,r23,0x0015            |
001953d4: 1440feb8 bne r2,r0,0x00194eb8      #Do for all units
001953d8: 340200ff ori r2,r0,0x00ff          |

                  SET SOME ACTING UNIT DATA - DISABLE useless Abilities
001953dc: 8fa80060 lw r8,0x0060(r29)         |Load ID of unit with the fewest usable abilities (helpfull and harmfull)
001953e0: 00000000 nop                       |
001953e4: 11020009 beq r8,r2,0x0019540c      #If this is a valid unit ID  Disable AI Decision 0x06 flag 0x04
001953e8: 00009021 addu r18,r0,r0            |reset next loop ability counter
001953ec: 00081900 sll r3,r8,0x04                |ID * 16
001953f0: 3c07801a lui r7,0x801a                 |
001953f4: 24e7f3c4 addiu r7,r7,0xf3c4            |
001953f8: 00e31821 addu r3,r7,r3                 |Part of Pointer to this unit AI Decision data ( AI 0x182c)
001953fc: 90621832 lbu r2,0x1832(r3)             |AI decision data  0x06
00195400: 00000000 nop                           |
00195404: 304200fb andi r2,r2,0x00fb             |remove 0x04 flag
00195408: a0621832 sb r2,0x1832(r3)              |Disable AI decision 0x06 flag 0x04
0019540c: 0000a021 addu r20,r0,r0            |reset next loop counter (Rdm ability)
00195410: 3c02dfff lui r2,0xdfff             |
00195414: 3c15801a lui r21,0x801a            |
00195418: 8eb501f8 lw r21,0x01f8(r21)        |Acting units AI decision pointer  AI 0x0e34
0019541c: 3c03801a lui r3,0x801a             |
00195420: 8c630078 lw r3,0x0078(r3)          |AI 0xcb4 flags (AI processing order ?)
00195424: 8fa40020 lw r4,0x0020(r29)         |Enemy team harmfull abilities counter
00195428: 3442ffff ori r2,r2,0xffff          |r2 = 0xdfffffff
0019542c: 3c01801a lui r1,0x801a             |
00195430: a0200082 sb r0,0x0082(r1)          |Nullifiy 801a0082 AI 0x0cbe
00195434: 00621824 and r3,r3,r2              |remove 0x20000000 flag
00195438: 340200ff ori r2,r0,0x00ff          |
0019543c: 3c01801a lui r1,0x801a             |
00195440: ac230078 sw r3,0x0078(r1)          |Remove 0x20000000 flag from AI 0x0cb4
00195444: a2a2000f sb r2,0x000f(r21)         |store 0xff in closest helpfull ability range
00195448: 04810002 bgez r4,0x00195454        #If Ability counter < 0  security ? 
0019544c: a2a2000e sb r2,0x000e(r21)         |store 0xff in closest harmfull ability range
00195450: 24840007 addiu r4,r4,0x0007                |Forces counter to 0x07
00195454: 000488c3 sra r17,r4,0x03           |Nb of Harmfull abilities / 8 Enemy team counter
00195458: 341e0004 ori r30,r0,0x0004         |Initialize loop counter
0019545c: 3c08801a lui r8,0x801a             |
00195460: 2508f3c4 addiu r8,r8,-0x0c3c       |0x8019f3c4
00195464: 25020004 addiu r2,r8,0x0004        |Part of Dynamic pointer to AI 0x0e44  Status to cancel
                                            @LOOP - reset 5 bytes (will host status to cancel)
00195468: a0400e44 sb r0,0x0e44(r2)              |reset this set of status
0019546c: 27deffff addiu r30,r30,-0x0001         |Counter -1
00195470: 07c1fffd bgez r30,0x00195468       Λ loop backward 4 times
00195474: 2442ffff addiu r2,r2,0xffff            |Pointer offset (-1 each oteration)
00195478: 0000f021 addu r30,r0,r0            |Reset counter
                                            @LOOP - Test All Abilities in 0xfe0 list on acting unit (self targeting)
0019547c: 3c03801a lui r3,0x801a                 |
00195480: 906301f3 lbu r3,0x01f3(r3)             |Acting units battle ID AI 0xe2f
00195484: 3c07801a lui r7,0x801a                 |
00195488: 24e7f3c4 addiu r7,r7,0xf3c4            |
0019548c: 00031100 sll r2,r3,0x04                |ID*16
00195490: 00431021 addu r2,r2,r3                 |ID*17
00195494: 000210c0 sll r2,r2,0x03                |ID*0x88
00195498: 24420ef0 addiu r2,r2,0x0ef0            |
0019549c: 00e21021 addu r2,r7,r2                 |Pointer to Acting Unit list of usable abilities
001954a0: 001e1880 sll r3,r30,0x02               |move list + move counter
001954a4: 00439821 addu r19,r2,r3                |Dynamic pointer to this iteration usable Ability (in Acting unit list)
001954a8: 92630002 lbu r3,0x0002(r19)            |Usable Ability skillset ID
001954ac: 340200ff ori r2,r0,0x00ff              |
001954b0: 1062009b beq r3,r2,0x00195720          #If Loop has reached the end of the list :  Exit loop
001954b4: 00000000 nop                               |
001954b8: 0c06561e jal 0x00195878                |-->AI_Ability_Data_Setting Transfer some data from r4 to 8019f3c4 table
001954bc: 02602021 addu r4,r19,r0                |Send This ability pointer
001954c0: 96620002 lhu r2,0x0002(r19)            |load skillset/usage type
001954c4: 00000000 nop                           |
001954c8: 30428000 andi r2,r2,0x8000             |Test Flag [0x8000]
001954cc: 10400090 beq r2,r0,0x00195710          #If This ability is not usable : branch to  Next Ability Disabled by MP lacking, silence etc…
001954d0: 00000000 nop                               |
001954d4: 8fa80028 lw r8,0x0028(r29)             |Ennemy magic attack counter
001954d8: 00000000 nop                           |
001954dc: 0228102a slt r2,r17,r8                 |True if Ennemy Magical Attack represent at least 12,5% of Attacks  Total/8 < Magical
001954e0: 14400003 bne r2,r0,0x001954f0          #If enemy Harmfull Abilities are mostly physical 
001954e4: 02602021 addu r4,r19,r0                    |Send Ability pointer
001954e8: 0c0655f0 jal 0x001957c0                    |-->Some_type_of_checking_algorithm  If ability only adds shell set it as unusable
001954ec: 3405001b ori r5,r0,0x001b                  |Send Shell ID
001954f0: 8fa70030 lw r7,0x0030(r29)             |load physical attack counter
001954f4: 00000000 nop                           |
001954f8: 0227102a slt r2,r17,r7                 |True if Ennemy Physical Attack represent at least 12,5% of Attacks  Total/8 < Magical
001954fc: 14400003 bne r2,r0,0x0019550c          #If ennemy Harmfull Abilities are mostly magical
00195500: 02602021 addu r4,r19,r0                    |Send Ability pointer
00195504: 0c0655f0 jal 0x001957c0                    |-->Some_type_of_checking_algorithm  If ability only adds protect set it as unusable
00195508: 3405001a ori r5,r0,0x001a                  |Send Protect ID
0019550c: 8fa80038 lw r8,0x0038(r29)             |load reflectable ability counter
00195510: 00000000 nop                           |
00195514: 0228102a slt r2,r17,r8                 |True if Ennemy Reflectable abilities represent at least 12,5% of Abilities  Total/8 < Reflectable
00195518: 14400003 bne r2,r0,0x00195528          #If ennemy Harmfull Abilities are mostly unreflectable
0019551c: 02602021 addu r4,r19,r0                    |Send Ability pointer
00195520: 0c0655f0 jal 0x001957c0                    |-->Some_type_of_checking_algorithm  If ability only adds reflect set it as unusable
00195524: 34050026 ori r5,r0,0x0026                  |Send Reflect ID
00195528: 8fa70040 lw r7,0x0040(r29)             |load earth element ability counter
0019552c: 00000000 nop                           |
00195530: 1ce00003 bgtz r7,0x00195540            #If Ennemy do not use any harmull ability with Earth element
00195534: 02602021 addu r4,r19,r0                    |Send Ability pointer
00195538: 0c0655f0 jal 0x001957c0                    |-->Some_type_of_checking_algorithm  If ability only adds Float set it as unusable
0019553c: 34050011 ori r5,r0,0x0011                  |Send Reflect ID
00195540: 96620002 lhu r2,0x0002(r19)            |load skillset/usage type AI 0xef0 table
00195544: 00000000 nop                           |
00195548: 30428000 andi r2,r2,0x8000             |
0019554c: 10400070 beq r2,r0,0x00195710          #If Flag 0x8000 is OFF (Ability is unusable) : branch to  Next Ability
00195550: 00000000 nop                               |
00195554: 96c2000c lhu r2,0x000c(r22)            |This Ability AI flags 1 and 2 8019f3c4 - 0x0c
00195558: 00000000 nop                           |
0019555c: 30420800 andi r2,r2,0x0800             |
00195560: 10400002 beq r2,r0,0x0019556c          #If This Ability has [Random use]
00195564: 26520001 addiu r18,r18,0x0001          |Usable ability counter?
00195568: 26940001 addiu r20,r20,0x0001              |random hits counter
0019556c: 86c30002 lh r3,0x0002(r22)             |Ability ID
00195570: 3402017b ori r2,r0,0x017b              |
00195574: 14620007 bne r3,r2,0x00195594          #If This Ability is 0x17b (Holy Water)
00195578: 3c032000 lui r3,0x2000                     |
0019557c: 3c02801a lui r2,0x801a                     |
00195580: 8c420078 lw r2,0x0078(r2)                  |Load 0x801a0078 (AI Processing order ?) AI 0xcb4
00195584: 00000000 nop                               |
00195588: 00431025 or r2,r2,r3                       |
0019558c: 3c01801a lui r1,0x801a                     |
00195590: ac220078 sw r2,0x0078(r1)                  |Enable Flag 0x20000000 at 801a0078
00195594: 96c2000c lhu r2,0x000c(r22)            |This Ability AI flags 1 and 2
00195598: 00000000 nop                           |
0019559c: 30420020 andi r2,r2,0x0020             |
001955a0: 1040000e beq r2,r0,0x001955dc          #If This ability has [Cancel status]
001955a4: 00000000 nop                               |
001955a8: 00008021 addu r16,r0,r0                    |Initialize status set counter
001955ac: 3c08801a lui r8,0x801a                     |
001955b0: 2508f3c4 addiu r8,r8,0xf3c4                |
001955b4: 01102021 addu r4,r8,r16                    |Part of Dynamic pointer to 8019f3c4 - 0xe44
                                                    @LOOP through all status sets - transfer status data from AI 0x07 to AI 0xe44
001955b8: 02d01821 addu r3,r22,r16                       |Part of Dynamic pointer to 8019f3c4 
001955bc: 90820e44 lbu r2,0x0e44(r4)                     |Load Status to Cancel  AI 0xe44
001955c0: 90630007 lbu r3,0x0007(r3)                     |Load Ability Status infliction AI 0x007
001955c4: 26100001 addiu r16,r16,0x0001                  |Loop counter + 1
001955c8: 00431025 or r2,r2,r3                           |
001955cc: a0820e44 sb r2,0x0e44(r4)                      |Update status to cancel
001955d0: 2a020005 slti r2,r16,0x0005                    |
001955d4: 1440fff8 bne r2,r0,0x001955b8              Λ Loop   5 times
001955d8: 01102021 addu r4,r8,r16                        |Pointer offset (+1 each iteration)
001955dc: 96c2000c lhu r2,0x000c(r22)            |This Ability AI flags 1 and 2
001955e0: 34030040 ori r3,r0,0x0040              |
001955e4: 30420042 andi r2,r2,0x0042             |
001955e8: 14430003 bne r2,r3,0x001955f8          #If This Ability has [Affect MP] and not [Target enemy]
001955ec: 34020001 ori r2,r0,0x0001                  |
001955f0: 3c01801a lui r1,0x801a                     |
001955f4: a0220082 sb r2,0x0082(r1)                  |store 0x01 at AI 0xcbe  801a0082
001955f8: 92c40004 lbu r4,0x0004(r22)            |This Ability Range 8019f3c4  0x04
001955fc: 92c30005 lbu r3,0x0005(r22)            |This Ability AoE 8019f3c4  0x05
00195600: 96c2000c lhu r2,0x000c(r22)            |This Ability AI flags 1 and 2 8019f3c4  0x0c
00195604: 00000000 nop                           |
00195608: 30420002 andi r2,r2,0x0002             |
0019560c: 10400007 beq r2,r0,0x0019562c          #If this Ability has [Target enemies]
00195610: 00832021 addu r4,r4,r3                 |Range + AoE
00195614: 92a2000e lbu r2,0x000e(r21)                |Load closest range so far Acting Unit 0x182c 0x0e
00195618: 00000000 nop                               |
0019561c: 0082102a slt r2,r4,r2                      |set if ability range < stored Min range
00195620: 10400002 beq r2,r0,0x0019562c              #If this ability has a lower range than previous record
00195624: 00000000 nop                                   |
00195628: a2a4000e sb r4,0x000e(r21)                     |Update closest Harmfull Ability range
0019562c: 96c2000c lhu r2,0x000c(r22)            |This Ability AI flags 1 and 2 8019f3c4  0x0c
00195630: 00000000 nop                           |
00195634: 30420001 andi r2,r2,0x0001             |
00195638: 10400011 beq r2,r0,0x00195680          #If This ability has [Target Allies]
0019563c: 00000000 nop                               |
00195640: 92c20000 lbu r2,0x0000(r22)                |This ability Skillset 8019f3c4
00195644: 3c018006 lui r1,0x8006                     |
00195648: 00220821 addu r1,r1,r2                     |
0019564c: 90235cb4 lbu r3,0x5cb4(r1)                 |This Ability action menu
00195650: 34020001 ori r2,r0,0x0001                  |
00195654: 14620004 bne r3,r2,0x00195668              #If Action menu is [item inventory]   (halve total range)
00195658: 24820001 addiu r2,r4,0x0001                    |r2 = range + 1?
0019565c: 00021fc2 srl r3,r2,0x1f                        |0  range / 2^31..
00195660: 00431021 addu r2,r2,r3                         |
00195664: 00022043 sra r4,r2,0x01                        |Range/2 (rounded up)
00195668: 92a2000f lbu r2,0x000f(r21)                |Load Closest Helpfull Ability range Acting Unit 0x182c 0x0f
0019566c: 00000000 nop                               |
00195670: 0082102a slt r2,r4,r2                      |0x1 if This Helpfull Ability range < Previous entry
00195674: 10400002 beq r2,r0,0x00195680              #If This ability total range exceed previous record
00195678: 00000000 nop                                   |
0019567c: a2a4000f sb r4,0x000f(r21)                     |Store new closest Helpfull Ability range
00195680: 96630002 lhu r3,0x0002(r19)            |This Ability Skillset and usage This Ability AI 0xef0 - 0x02
00195684: 00000000 nop                           |
00195688: 30620200 andi r2,r3,0x0200             |
0019568c: 14400017 bne r2,r0,0x001956ec          #If Usage flag 0x02 is Enabled Forces ability as unusable  Allies are not targeted flag ?
00195690: 34620100 ori r2,r3,0x0100                  |Enable Usage 0x01
00195694: 30620400 andi r2,r3,0x0400                 |
00195698: 14400015 bne r2,r0,0x001956f0          #If Usage 0x04 is Enabled : branch Skip - Do not Update usage flag Weapon ranged ?
0019569c: 00000000 nop                               |
                                                Else Usage 0x02 and 0x04 flags are OFF
001956a0: 92c20001 lbu r2,0x0001(r22)            |This Ability CT
001956a4: 3c03801a lui r3,0x801a                 |
001956a8: 90630213 lbu r3,0x0213(r3)             |Remaining clockticks until next turn
001956ac: 00000000 nop                           |
001956b0: 0043102b sltu r2,r2,r3                 |set if ability CT < remaining clockticks
001956b4: 10400007 beq r2,r0,0x001956d4          #If This Ability CT will end before next unit turn
001956b8: 00000000 nop                               |
001956bc: 3c04801a lui r4,0x801a                     |
001956c0: 908401f2 lbu r4,0x01f2(r4)                 |Load and send Acting Unit ID
001956c4: 0c067976 jal 0x0019e5d8                    |-->AI_Ability_Use_Decisions Check this ability on Acting Unit
001956c8: 34050001 ori r5,r0,0x0001                  |Send 1 (test reflect)
001956cc: 14400004 bne r2,r0,0x001956e0              #If returned value is 0x00 (Unusable ?)
001956d0: 00000000 nop                                   |
001956d4: 96620002 lhu r2,0x0002(r19)                    |load skillset/usage
001956d8: 080655bb j 0x001956ec                          >>Avoid opposite section
001956dc: 34420100 ori r2,r2,0x0100                      |set 0x0100 flag
                                                    Else : r2 != 0x00
001956e0: 96620002 lhu r2,0x0002(r19)                    |load usage flags
001956e4: 00000000 nop                                   |
001956e8: 3042feff andi r2,r2,0xfeff                     |remove 0x0100 flag
001956ec: a6620002 sh r2,0x0002(r19)             |Update flags This ability 8019f3c4 + 0xef0 + 0x02
001956f0: 8fa70010 lw r7,0x0010(r29)             |Load Acting Unit Action Taken byte (Battle 0x188)
001956f4: 00000000 nop                           |
001956f8: 10e00005 beq r7,r0,0x00195710          #If Action is Taken
001956fc: 00000000 nop                               |
00195700: 96620002 lhu r2,0x0002(r19)                |Load Skillset and Usage This ability 8019f3c4 + 0xef0 + 0x02
00195704: 00000000 nop                               |
00195708: 30427fff andi r2,r2,0x7fff                 |remove 0x8000 flag
0019570c: a6620002 sh r2,0x0002(r19)                 |Update flags This ability 8019f3c4 + 0xef0 + 0x02
00195710: 27de0001 addiu r30,r30,0x0001          |Ability counter +1
00195714: 2bc20022 slti r2,r30,0x0022            |check list's limit (0x22 entries)
00195718: 1440ff58 bne r2,r0,0x0019547c      Λ Loop throught all Abilities in list
0019571c: 00000000 nop                       |
00195720: 92a2000e lbu r2,0x000e(r21)        |Closest Harmfull Ability range Acting Unit 8019f3c4 + 0x182c + 0x0e
00195724: 340400ff ori r4,r0,0x00ff          |
00195728: 10440007 beq r2,r4,0x00195748      #If there is an entry (not 0xff)
0019572c: 00000000 nop                           |
00195730: 92a2000e lbu r2,0x000e(r21)            |load lowest range
00195734: 3c03801a lui r3,0x801a                 |
00195738: 906301fc lbu r3,0x01fc(r3)             |load acting units move 8019f3c4 + 0x0e38
0019573c: 00000000 nop                           |
00195740: 00431021 addu r2,r2,r3                 |move + lowest range (max range)
00195744: a2a2000e sb r2,0x000e(r21)             |store Acting Unit move range + closest harmfull ability range + AoE
00195748: 92a2000f lbu r2,0x000f(r21)        |Closest helpfull ability range Acting Unit 8019f3c4 + 0x182c + 0x0f
0019574c: 00000000 nop                       |
00195750: 14440002 bne r2,r4,0x0019575c      #If there is no entry (0xff)
00195754: 00000000 nop                           |
00195758: a2a0000f sb r0,0x000f(r21)             |clear highest range ability
0019575c: 92a2000f lbu r2,0x000f(r21)        |load highest range
00195760: 3c03801a lui r3,0x801a             |
00195764: 906301fc lbu r3,0x01fc(r3)         |load acting units move 8019f3c4 + 0x0e38
00195768: 00000000 nop                       |
0019576c: 00431021 addu r2,r2,r3             |add move to range
00195770: 12400006 beq r18,r0,0x0019578c     #If there is at least one usable ability
00195774: a2a2000f sb r2,0x000f(r21)         |Update highest max range
00195778: 001411c0 sll r2,r20,0x07               |random use ability counter*128
0019577c: 0052001a div r2,r18                    |
00195780: 00001012 mflo r2                       |(Random Ability * 0x80)Nb of usable Abilities
00195784: 3c01801a lui r1,0x801a                 |
00195788: a0220d7c sb r2,0x0d7c(r1)              |store random Ability mod
0019578c: 8fbf008c lw r31,0x008c(r29)
00195790: 8fbe0088 lw r30,0x0088(r29)
00195794: 8fb70084 lw r23,0x0084(r29)
00195798: 8fb60080 lw r22,0x0080(r29)
0019579c: 8fb5007c lw r21,0x007c(r29)
001957a0: 8fb40078 lw r20,0x0078(r29)
001957a4: 8fb30074 lw r19,0x0074(r29)
001957a8: 8fb20070 lw r18,0x0070(r29)
001957ac: 8fb1006c lw r17,0x006c(r29)
001957b0: 8fb00068 lw r16,0x0068(r29)
001957b4: 27bd0090 addiu r29,r29,0x0090
001957b8: 03e00008 jr r31
001957bc: 00000000 nop

Return locations

BATTLE.BIN
 00194028:  Main AI action setup