AI Ability Data Setting

From Final Fantasy Hacktics Wiki
Jump to navigation Jump to search
AI Ability Data Setting : reset and set some data in 0x8019f3c4 section. Bugs and hard coded things (see notes)
----------------------------------------------------------------------------------------------------------------
Parameters : r4 - Ability data pointer (used to load data)

Returns nothing
----------------------------------------------------------------------------------------
00195878: 27bdffc8 addiu r29,r29,-0x0038    |
0019587c: afb40020 sw r20,0x0020(r29)       |
00195880: 0080a021 addu r20,r4,r0           |r20 = Pointer to Unit AI 0xef0 Table (usable abilities)  801a02b4
00195884: afb00010 sw r16,0x0010(r29)       |
00195888: 3c10801a lui r16,0x801a           |
0019588c: 2610f3c4 addiu r16,r16,-0xc3c     |Start of AI Used/processed Ability Data pointer 0x8019f3c4 - 8019f3c4
00195890: 02002021 addu r4,r16,r0           |
00195894: 34050014 ori r5,r0,0x0014         |Nb of byte to delete in routine below
00195898: afbf0030 sw r31,0x0030(r29)       |
0019589c: afb7002c sw r23,0x002c(r29)       |
001958a0: afb60028 sw r22,0x0028(r29)       |
001958a4: afb50024 sw r21,0x0024(r29)       |
001958a8: afb3001c sw r19,0x001c(r29)       |
001958ac: afb20018 sw r18,0x0018(r29)       |
001958b0: 0c066ade jal 0x0019ab78           |-->Word_Nulling Nullify 5 Words from 0x8019f3c4 to 0x8019f3d7  (Some ability data - see notes)
001958b4: afb10014 sw r17,0x0014(r29)       |
001958b8: 26040020 addiu r4,r16,0x0020      |Calculator Type Ability ID
001958bc: 0c066ade jal 0x0019ab78           |-->Word_Nulling Nullify calculator related data
001958c0: 34050004 ori r5,r0,0x0004         |
001958c4: 92820002 lbu r2,0x0002(r20)       |Load Ability skillset ID
001958c8: 00000000 nop                      |
001958cc: a2020000 sb r2,0x0000(r16)        |Store Skillset ID
001958d0: 96830000 lhu r3,0x0000(r20)       |Byte 00 and 01 (both needed to find Ability ID)
001958d4: 3c048019 lui r4,0x8019            |
001958d8: 248408cc addiu r4,r4,0x08cc       |Start of unit data
001958dc: 306303ff andi r3,r3,0x03ff        |Ability ID mask  (+flag 0x2 of byte 0x00 ?)
001958e0: 00608821 addu r17,r3,r0           |/r17 = Ability ID 
001958e4: 3c01801a lui r1,0x801a            |
001958e8: a423f3c6 sh r3,-0x0c3a(r1)        |Store Ability ID at 0x8019f3c6  0x8019f3c4 - 0x02
001958ec: 96820000 lhu r2,0x0000(r20)       |Byte 00 and 01 (both needed to find Ability ID)
001958f0: 92830002 lbu r3,0x0002(r20)       |Load Ability skillset ID
001958f4: 00021400 sll r2,r2,0x10           |Pass halfword in upper registery
001958f8: 0002ae83 sra r21,r2,0x1a          |/Unit ID (from 0x801a02b4) Right shift destroying low byte and 2nd byte flag 0x1 and 0x2 (keep just Unit ID)
001958fc: 001510c0 sll r2,r21,0x03          |Unit ID * 8
00195900: 00551023 subu r2,r2,r21           |Unit ID * 7
00195904: 00021180 sll r2,r2,0x06           |Unid ID * 0x1c0 
00195908: 3c018006 lui r1,0x8006            |
0019590c: 00230821 addu r1,r1,r3            |0x80060000 + Ability's skillset ID
00195910: 90375cb4 lbu r23,0x5cb4(r1)       |r23 = Ability's Skillset's Action menu
00195914: 00449021 addu r18,r2,r4           |r18 = Unit Battle Data Pointer
00195918: 26e3ffff addiu r3,r23,-0x0001     |
0019591c: 2c62000a sltiu r2,r3,0x000a       |r2 = 0x1 if Action menu is between 0x1 and 0xa    (not default, defend, equip change, unknown nor blank)
00195920: 104000b7 beq r2,r0,0x00195c00     #Branch to   Default section  if the action menu don't have a jump pointer address
00195924: 0000b021 addu r22,r0,r0           |r22 = 0x00 (will be used to store inflicted status in some section)
00195928: 00031080 sll r2,r3,0x02               |Action menu offset (word)
0019592c: 3c018019 lui r1,0x8019                |
00195930: 00220821 addu r1,r1,r2                |
00195934: 8c223d48 lw r2,0x3d48(r1)             |Load Action menu jump Adress (Table details)
00195938: 00000000 nop                          |
0019593c: 00400008 jr r2                        |jump to specific action menu section
00195940: 00000000 nop                          |

    ----Attack / Charge ---- Code jumps backward from charge section after setting CT
00195944: 02151021 addu r2,r16,r21          |8019f3c4 + Unit ID
00195948: 9042198c lbu r2,0x198c(r2)        |Load Unit Battle ID   0x801a0d50
0019594c: 00000000 nop                      |
00195950: 000210c0 sll r2,r2,0x03           |Unit ID * 8
00195954: 24421778 addiu r2,r2,0x1778       |
00195958: 02021821 addu r3,r16,r2           |Unit AI Weapon Attack data pointer  0x801a0b3c (AI 0x1778) + Unit ID *8  
0019595c: 90620000 lbu r2,0x0000(r3)        |Load Unit Attack range
00195960: 00000000 nop                      |
00195964: a2020004 sb r2,0x0004(r16)        |Store attack range in AI used ability data  8019f3c4 - 0x04
00195968: 90620005 lbu r2,0x0005(r3)        |Load unit Attack's element  (weapon elements ? combined if dual)
0019596c: 00000000 nop                      |
00195970: a2020010 sb r2,0x0010(r16)        |Store Element in AI used ability data
    ----Attack / Charge / Jump---- Code jumps backward from jump section after setting CT and range
00195974: 90620004 lbu r2,0x0004(r3)        |Load Unit's Weapon ID
00195978: 00000000 nop                      |
0019597c: a2020006 sb r2,0x0006(r16)        |Store Weapon ID in AI used ability data (Item considered)  8019f3c4 - 0x06
00195980: 90620001 lbu r2,0x0001(r3)        |Load Weapon 0x01 (AI 0x1778 + 0x01 (like Ability AI flags 1)
00195984: 00000000 nop                      |
00195988: a202000c sb r2,0x000c(r16)        |Store Weapon AI flags 1 in considered ability data   8019f3c4 - 0x0c
0019598c: 90620002 lbu r2,0x0002(r3)        |Load Weapon AI flags 2
00195990: 00000000 nop                      |
00195994: a202000d sb r2,0x000d(r16)        |Store weapon AI flags 2 in considered ability data    8019f3c4 - 0x0d
00195998: 90620003 lbu r2,0x0003(r3)        |Load Ability AI behavior flags 3
0019599c: 00000000 nop                      |
001959a0: a202000e sb r2,0x000e(r16)        |Store weapon AI flags 3 in considered ability data  8019f3c4 - 0x0e
001959a4: 92820003 lbu r2,0x0003(r20)       |Load Ability AI 0xef0 + 0x03
001959a8: 00000000 nop                      |
001959ac: a202000f sb r2,0x000f(r16)        |Store Ability AI 0xef0 + 0x03 in AI considered ability data  related to  AI flags 0x4 ? Action menu specific ?
001959b0: 34020009 ori r2,r0,0x0009         |
001959b4: 16e200eb bne r23,r2,0x00195d64    #If Action menu is Jump  / Else jump to  END
001959b8: 2403fffe addiu r3,r0,-0x0002          |r3 = 0xfffffffe
001959bc: 8e02000c lw r2,0x000c(r16)            |Load AI used ability data AI flags 1
001959c0: 00000000 nop                          |
001959c4: 34420002 ori r2,r2,0x0002             |Enable Target enemy flag (flag 0x02)
001959c8: 00431024 and r2,r2,r3                 |Cancel Target Allies (flag 0x01)
001959cc: 08065759 j 0x00195d64                 >>Jump to  END
001959d0: ae02000c sw r2,0x000c(r16)            |Store AI behavior flags 13 in AI used abilty data 0x0c with Target enemy flag ON

    ----Item inventory ---- 
001959d4: 2622fe90 addiu r2,r17,-0x0170     |Item ID (Ability ID - 0x170 (Potion = 0x00))  Hard coded
001959d8: 00021840 sll r3,r2,0x01           |Item ID * 2
001959dc: 00621821 addu r3,r3,r2            |Item ID * 3
001959e0: 92420091 lbu r2,0x0091(r18)       |Load Unit 3rd Support set
001959e4: 3c018006 lui r1,0x8006            |
001959e8: 00230821 addu r1,r1,r3            |
001959ec: 90363f9a lbu r22,0x3f9a(r1)       |Load Item Inflicted status  0x80063f98 - 0x02 + Item offset
001959f0: 30420008 andi r2,r2,0x0008        |Check for throw item in 3rd set of support
001959f4: 10400004 beq r2,r0,0x00195a08     #If Unit uses throw item
001959f8: 34020001 ori r2,r0,0x0001             |
001959fc: 9242003a lbu r2,0x003a(r18)           |Load Unit's Move stat / BUG : should be 0x4
00195a00: 08065683 j 0x00195a0c                 >>Jump to preserve range value
00195a04: a2020004 sb r2,0x0004(r16)            |Store it as range in AI used ability data
                                            #Else : Unit do not use throw item
00195a08: a2020004 sb r2,0x0004(r16)            |Force range to 0x1 in AI used ability data
00195a0c: a2000005 sb r0,0x0005(r16)        |Nullify AoE 
00195a10: 3c018006 lui r1,0x8006            |
00195a14: 00310821 addu r1,r1,r17           |
00195a18: 90220ea0 lbu r2,0x0ea0(r1)        |Load Ability's used item  (0x80061010 +for potion(ID is 0x170))
00195a1c: 08065700 j 0x00195c00             >>Jump to default section
00195a20: a2020006 sb r2,0x0006(r16)        |Store used item ID in AI used ability data (as item considered)

    ----Katana inventory ---- 
00195a24: 2622ffda addiu r2,r17,-0x0026     |r2 = Katana ID (Ability ID - 0x26) Hardcoded - 0x26 if the gap between first draw out Ability ID and first katana ID
00195a28: 08065700 j 0x00195c00             >>Jump to default section
00195a2c: a2020006 sb r2,0x0006(r16)        |Store used katana ID in AI used ability data (as item considered)

    ----Weapon inventory ----  For throw r17 is Threw Weapon ID ? 
00195a30: 2622ff86 addiu r2,r17,0xff86      |Used Weapon ID - 0x7A
00195a34: 2c420003 sltiu r2,r2,0x0003       |Check if Weapon ID is between 0x7A and 0x7C (shurikens)
00195a38: 14400005 bne r2,r0,0x00195a50     #If Not a Shuriken
00195a3c: 3402017e ori r2,r0,0x017e         |r2 = 0x17e (Throw shuriken ability ID)
00195a40: 2622ff83 addiu r2,r17,0xff83          |Used weapon ID - 0x7D
00195a44: 2c420003 sltiu r2,r2,0x0003           |Check if used weapon ID is between 0x7D and 0x7F (Ball)
00195a48: 10400009 beq r2,r0,0x00195a70         #If Used Weapon is a Ball
00195a4c: 34020189 ori r2,r0,0x0189                 |Set Ability ID to 0x189
00195a50: a6020002 sh r2,0x0002(r16)        #E      | Store Ability ID in AI used ability Data 0x02 (Ability ID)
00195a54: 001110c0 sll r2,r17,0x03                  |Used weapon ID * 8
00195a58: a2110006 sb r17,0x0006(r16)               |Store Used Weapon ID as item considered
00195a5c: 3c018006 lui r1,0x8006                    |
00195a60: 00220821 addu r1,r1,r2                    |0x80060000 + Item offset (8 bytes per item)
00195a64: 90223abe lbu r2,0x3abe(r1)                |Load Weapon Element (0x80063ab8 - 0x06)
00195a68: 080656a0 j 0x00195a80                     >>Jump - Avoid normal weapon section
00195a6c: a2020010 sb r2,0x0010(r16)                |
                                                #Else - Not a Shuriken nor a ball
00195a70: 96020e14 lhu r2,0x0e14(r16)               |Load chosen Throw ability ID
00195a74: 92030e16 lbu r3,0x0e16(r16)               |Load chosen Weapon ID
00195a78: a6020002 sh r2,0x0002(r16)                |Store Ability ID in AI used ability data 0x02
00195a7c: a2030006 sb r3,0x0006(r16)                |Store Weapon ID in AI used ability
00195a80: 9242003a lbu r2,0x003a(r18)       |Load unit's move
00195a84: 86110002 lh r17,0x0002(r16)       |Load Ability ID (from AI data) in r17
00195a88: 08065700 j 0x00195c00             >>Jump to default section
00195a8c: a2020004 sb r2,0x0004(r16)        |Store Unit's move as Ability range

    ----Jump ---- 
00195a90: 92020e2e lbu r2,0x0e2e(r16)       |Load acting unit ID
00195a94: 00000000 nop                      |
00195a98: 16a2000e bne r21,r2,0x00195ad4    #If Acting unit ID = Unit ID (AI data 0xe2e Vs ID from AI move list)
00195a9c: 34020064 ori r2,r0,0x0064             |100
00195aa0: 8e0317f8 lw r3,0x17f8(r16)            |Load acting unit data pointer
00195aa4: 00000000 nop                          |
00195aa8: 90640039 lbu r4,0x0039(r3)            |Load Acting unit CT
00195aac: 90630038 lbu r3,0x0038(r3)            |Load Acting unit Speed
00195ab0: 00441023 subu r2,r2,r4                |100 - Acting unit CT
00195ab4: 0043001a div r2,r3                    |(100-CT)/Speed
00195ab8: 00001012 mflo r2                      |
00195abc: 00000000 nop                          |
00195ac0: 00021fc2 srl r3,r2,0x1f               |
00195ac4: 00431021 addu r2,r2,r3                |rounded up if needed
00195ac8: 00021043 sra r2,r2,0x01               |((100 - CT) / Speed) / 2
00195acc: 080656d7 j 0x00195b5c                 |
00195ad0: a2020001 sb r2,0x0001(r16)            |Store (100-CT/Speed)/2 in AI used Ability CT
                                            #Else : Unit is not acting unit (?)
00195ad4: 92450039 lbu r5,0x0039(r18)           |Unit CT (ID from Move list)
00195ad8: 00000000 nop                          |
00195adc: 2ca20065 sltiu r2,r5,0x0065           |
00195ae0: 14400005 bne r2,r0,0x00195af8         #If unit CT > 100
00195ae4: 34040064 ori r4,r0,0x0064             |100
00195ae8: a2000001 sb r0,0x0001(r16)                |Nullify AI used Ability CT
00195aec: 92420039 lbu r2,0x0039(r18)               |Load unit's CT
00195af0: 080656cb j 0x00195b2c                     >>Jump after the other CT section
00195af4: 2444ff9c addiu r4,r2,-0x0064              |r4 = Unit CT - 100
                                                #Else CT < 100
00195af8: 92430038 lbu r3,0x0038(r18)               |Load unit's speed
00195afc: 00851023 subu r2,r4,r5                    |100 - CT
00195b00: 0043001a div r2,r3                        |(100-CT)/Speed Nb of turn before acting ?
00195b04: 00001012 mflo r2                          |
00195b08: 00000000 nop                              |
00195b0c: a2020001 sb r2,0x0001(r16)                |Store (100-CT)/Speed As Ability CT
00195b10: 92430039 lbu r3,0x0039(r18)               |Unit's CT
00195b14: 92420038 lbu r2,0x0038(r18)               |Unit's Speed
00195b18: 00832023 subu r4,r4,r3                    |100 - CT
00195b1c: 0082001a div r4,r2                        |(100-CT)/Speed Nb of turn before acting ?
00195b20: 00001810 mfhi r3                          |remainder 
00195b24: 00000000 nop                              |
00195b28: 00432023 subu r4,r2,r3                    |Speed - Remainder CT above 100 when acting ? 
00195b2c: 34020064 ori r2,r0,0x0064                 |100
00195b30: 92430038 lbu r3,0x0038(r18)               |Unit's speed
00195b34: 00441023 subu r2,r2,r4                    |100 * Extra CT Remaining CT before next turn
00195b38: 0043001a div r2,r3                        |Remaing CT / Speed
00195b3c: 00001012 mflo r2                          |
00195b40: 00000000 nop                              |
00195b44: 00021fc2 srl r3,r2,0x1f                   |
00195b48: 00431021 addu r2,r2,r3                    |rounded up  if needed
00195b4c: 92030001 lbu r3,0x0001(r16)               |Load Nb of turn before acting
00195b50: 00021043 sra r2,r2,0x01                   |
00195b54: 00621821 addu r3,r3,r2                    |Nb of turns before second turn ? 
00195b58: a2030001 sb r3,0x0001(r16)                |Store Nb of turns before second turn as AI used Ability CT
00195b5c: 16200003 bne r17,r0,0x00195b6c    #If Ability ID = 0x00 ?
00195b60: 2622fe76 addiu r2,r17,-0x018a     |r2 = Ability ID - 0x18A (jump2 = 0)
00195b64: 080656df j 0x00195b7c                 >>Jump and force range to 0x01
00195b68: 34020001 ori r2,r0,0x0001             |r2 = 0x01
                                            #Else : Ability ID <> 0x00
00195b6c: 00021040 sll r2,r2,0x01               |Jump Ability ID*2
00195b70: 3c018006 lui r1,0x8006                |
00195b74: 00220821 addu r1,r1,r2                |
00195b78: 9022102c lbu r2,0x102c(r1)            |Load Jump Ability Range
00195b7c: 00000000 nop                      |
00195b80: a2020004 sb r2,0x0004(r16)        |Store Range
00195b84: 02151021 addu r2,r16,r21          |0x8019f3c4 + Unit ID
00195b88: 9042198c lbu r2,0x198c(r2)        |Load Unit's Battle ID (0xff if not used)
00195b8c: 00000000 nop                      |
00195b90: 000210c0 sll r2,r2,0x03           |Unit ID*8
00195b94: 24421778 addiu r2,r2,0x1778       |
00195b98: 0806565d j 0x00195974             >>Jump at the end of the default attack section
00195b9c: 02021821 addu r3,r16,r2           |Unit Weapon flag (in AI table) 0x8019f3c4 + 0x1778 + Unit battle ID * 8

    ---- Charge ---- 
00195ba0: 2622fe6a addiu r2,r17,-0x0196     |Ability ID - 0x196 (Charge +1 = 0)
00195ba4: 00021040 sll r2,r2,0x01           |Charge ID * 2
00195ba8: 3c018006 lui r1,0x8006            |
00195bac: 00220821 addu r1,r1,r2            |
00195bb0: 90221044 lbu r2,0x1044(r1)        |Load Charge's ability CT
00195bb4: 08065651 j 0x00195944             >>Jump to Attack section
00195bb8: a2020001 sb r2,0x0001(r16)        |Store Charge's CT as AI used ability CT 

    ---- Arithmeticks ---- 
00195bbc: 340300ff ori r3,r0,0x00ff         |
00195bc0: 34040004 ori r4,r0,0x0004         |Counter set for 5 loops
00195bc4: 26020004 addiu r2,r16,0x0004      |Pointer to AI used ability 5th set of status infliction 
                                            @LOOP - Enables all status infliction flags
00195bc8: a0430007 sb r3,0x0007(r2)             |Store 0xff in AI used ability Status infliction (all statuses ON)
00195bcc: 2484ffff addiu r4,r4,-0x0001          |counter -1
00195bd0: 0481fffd bgez r4,0x00195bc8       Λ Loop while counter >= 0
00195bd4: 2442ffff addiu r2,r2,-0x0001          |pointer -1
00195bd8: 340200fc ori r2,r0,0x00fc             |
00195bdc: a202000c sb r2,0x000c(r16)        |Store 0xfc in AI behavior 1  (everything but target allies / enemies)
00195be0: 92820003 lbu r2,0x0003(r20)       |Load Ability usage type (from AI moves list)  801a02b4 - 0x03
00195be4: 00000000 nop                      |
00195be8: a202000f sb r2,0x000f(r16)        |Store usage as AI used ability extra behaviors flags
00195bec: 8e02000c lw r2,0x000c(r16)        |Load All AI behaviors flags
00195bf0: 00000000 nop                      |
00195bf4: 34428000 ori r2,r2,0x8000         |Enable Ignore range
00195bf8: 08065759 j 0x00195d64             >>Jump to  >>!!END!!
00195bfc: ae02000c sw r2,0x000c(r16)        |Update AI behavior flags (ignore range)

    ----Default (direct) and  Weapon Katana Item----
00195c00: 2604000c addiu r4,r16,0x000c      |Pointer to AI used ability behaviors flags 1
00195c04: 001198c0 sll r19,r17,0x03         |Ability ID * 8
00195c08: 3c058006 lui r5,0x8006            |
00195c0c: 24a5ebf4 addiu r5,r5,0xebf4       |
00195c10: 02652821 addu r5,r19,r5           |Pointer to Ability behaviors flags 1 0x8006ebf0 - 0x04 + Ability offset (8 bytes)
00195c14: 0c066ac2 jal 0x0019ab08           |-->Transfer_Halfword_Values Transfer AI behavior flags 1,2,3,4 from SCUS Ability Table to AI used Ability Behaviors flags
00195c18: 34060004 ori r6,r0,0x0004         |Limit for routine 
00195c1c: 26e2ffff addiu r2,r23,-0x0001     |Action menu -0x1
00195c20: 2c420002 sltiu r2,r2,0x0002       |Check for  Item or Weapon inventory
00195c24: 10400005 beq r2,r0,0x00195c3c     #If Action menu is Item or weapon inventory
00195c28: 3c030040 lui r3,0x0040                |
00195c2c: 8e02000c lw r2,0x000c(r16)            |Load All AI used ability behaviors flags
00195c30: 00000000 nop                          |
00195c34: 00431025 or r2,r2,r3                  |Enable Direct attack flag
00195c38: ae02000c sw r2,0x000c(r16)            |Store updated behavior flags
00195c3c: 92820003 lbu r2,0x0003(r20)       |Load Usage flags from AI moves list
00195c40: 00000000 nop                      |
00195c44: a202000f sb r2,0x000f(r16)        |Store Usage flags as extra behavior flags
00195c48: 2a220170 slti r2,r17,0x0170       |Check if Ability has a second table (Before potion)
00195c4c: 1040002f beq r2,r0,0x00195d0c     #If Ability has a second table
00195c50: 02711023 subu r2,r19,r17              |Ability ID*7
00195c54: 00021040 sll r2,r2,0x01               |ID*14
00195c58: 3c038006 lui r3,0x8006                |
00195c5c: 2463fbf0 addiu r3,r3,0xfbf0           |
00195c60: 00431821 addu r3,r2,r3                |Ability Table 2 pointer (SCUS) 8006fbf0 + Ability offset (14 bytes)
00195c64: 9062000c lbu r2,0x000c(r3)            |Load Ability CT
00195c68: 9076000b lbu r22,0x000b(r3)           |Load Ability Inflict status
00195c6c: a2020001 sb r2,0x0001(r16)            |Store CT in AI used ability data
00195c70: 90620007 lbu r2,0x0007(r3)            |Load Ability Element
00195c74: 00000000 nop                          |
00195c78: a2020010 sb r2,0x0010(r16)            |Store ability element in AI data
00195c7c: 9062000d lbu r2,0x000d(r3)            |Load Ability MP cost
00195c80: 00000000 nop                          |
00195c84: a2020011 sb r2,0x0011(r16)            |Store MP cost in AI data
00195c88: 92420090 lbu r2,0x0090(r18)           |Load Unit 2nd set of Support 
00195c8c: 00000000 nop                          |
00195c90: 30420080 andi r2,r2,0x0080            |Check for Half of MP
00195c94: 10400005 beq r2,r0,0x00195cac         #If Unit has Half of MP
00195c98: 00000000 nop                              |
00195c9c: 92020011 lbu r2,0x0011(r16)               |Load MP cost from AI data
00195ca0: 00000000 nop                              |
00195ca4: 00021042 srl r2,r2,0x01                   |MP Cost/2
00195ca8: a2020011 sb r2,0x0011(r16)                |Store updated MP cost
00195cac: 90620003 lbu r2,0x0003(r3)            |Load Ability Flags 1
00195cb0: 00000000 nop                          |
00195cb4: 30420020 andi r2,r2,0x0020            |check for Weapon range
00195cb8: 10400009 beq r2,r0,0x00195ce0         #If Ability is weapon ranged
00195cbc: 02151021 addu r2,r16,r21                  |0x8019f3c4 + Unit ID
00195cc0: 9042198c lbu r2,0x198c(r2)                |Load Unit's battle ID  801a0d50 + Unit offset
00195cc4: 00000000 nop                              |
00195cc8: 000210c0 sll r2,r2,0x03                   |Unit ID*8
00195ccc: 02021021 addu r2,r16,r2                   |
00195cd0: 90421778 lbu r2,0x1778(r2)                |Load Weapon range from  AI Weapon data  801a0b3c + Unit offset (8 bytes)
00195cd4: a2000005 sb r0,0x0005(r16)                |Nullify AoE in AI data
00195cd8: 0806573e j 0x00195cf8                     >>Avoid the not weapon ranged section
00195cdc: a2020004 sb r2,0x0004(r16)                |Store Weapon range 
                                                 #Else : Ability is not weapon ranged                                          
00195ce0: 90620000 lbu r2,0x0000(r3)                |Load Ability range (SCUS)
00195ce4: 00000000 nop                              |
00195ce8: a2020004 sb r2,0x0004(r16)                |Store ability range in AI data
00195cec: 90620001 lbu r2,0x0001(r3)                |Load AoE
00195cf0: 00000000 nop                              |
00195cf4: a2020005 sb r2,0x0005(r16)                |Store AoE
00195cf8: 90620005 lbu r2,0x0005(r3)            |Load Flags 3
00195cfc: 00000000 nop                          |
00195d00: 30420004 andi r2,r2,0x0004            |Check for persevere
00195d04: 1440000f bne r2,r0,0x00195d44         #If persevere flag is OFF
00195d08: 26040007 addiu r4,r16,0x0007          |pointer to AI used ability status infliction 1
00195d0c: 92430092 lbu r3,0x0092(r18)       #E      | Load Unit Support 4
00195d10: 00000000 nop                              |
00195d14: 30620080 andi r2,r3,0x0080                |Check for Monster skill / BUG : Should be 0x08 (short charge)
00195d18: 10400006 beq r2,r0,0x00195d34             #If Unit has Monster skill (Instead of short charge)
00195d1c: 30620040 andi r2,r3,0x0040                |Check for Defend / BUG : Should be 0x04 (Non-Charge)
00195d20: 92020001 lbu r2,0x0001(r16)                   |Load AI used Ability CT
00195d24: 00000000 nop                                  |
00195d28: 00021042 srl r2,r2,0x01                       |CT/2
00195d2c: 08065750 j 0x00195d40                         >>Avoid the intended Non-Charge section 
00195d30: a2020001 sb r2,0x0001(r16)                    |Store New CT
00195d34: 10400003 beq r2,r0,0x00195d44             #Else : if Unit Has Defend (instead of Non-Charge)
00195d38: 26040007 addiu r4,r16,0x0007              |pointer to AI used ability status infliction 1
00195d3c: a2000001 sb r0,0x0001(r16)                    |Nullify Ability CT
00195d40: 26040007 addiu r4,r16,0x0007                  |pointer to AI used ability status infliction 1
00195d44: 00162840 sll r5,r22,0x01          |Inflict status ID * 2 (from item or ability)
00195d48: 00b62821 addu r5,r5,r22           |ID*3
00195d4c: 00052840 sll r5,r5,0x01           |Status ID * 6
00195d50: 3c028006 lui r2,0x8006            |
00195d54: 24423fc5 addiu r2,r2,0x3fc5       |
00195d58: 00a22821 addu r5,r5,r2            |Pointer to Inflicted Status ID 1st set of status
00195d5c: 0c066ad2 jal 0x0019ab48           |-->Transfer_Byte_Values Transfer 5 set of status infliction form SCUS status table to AI used ability data
00195d60: 34060005 ori r6,r0,0x0005         |Limit (5 set of status)
00195d64: 8fbf0030 lw r31,0x0030(r29)       END
00195d68: 8fb7002c lw r23,0x002c(r29)
00195d6c: 8fb60028 lw r22,0x0028(r29)
00195d70: 8fb50024 lw r21,0x0024(r29)
00195d74: 8fb40020 lw r20,0x0020(r29)
00195d78: 8fb3001c lw r19,0x001c(r29)
00195d7c: 8fb20018 lw r18,0x0018(r29)
00195d80: 8fb10014 lw r17,0x0014(r29)
00195d84: 8fb00010 lw r16,0x0010(r29)
00195d88: 27bd0038 addiu r29,r29,0x0038
00195d8c: 03e00008 jr r31
00195d90: 00000000 nop

Notes

Used AI section
 - Fill 0x8019f3c4                 8019f3c4 
 - Load data from 0x801a0b3c       801a0b3c / 8019f3c4 + 0x1778
 - Load data from 0x801a02b4       801a02b4 / 8019f3c4 + 0x0ef0
 - Load ID from 0x801a0d50         801a0d50 / 8019f3c4 + 0x198c
 - Load ID from 0x801a0e2e         801a01f0 / 8019f3c4 + 0x0e2e

Hard-coded mechanics
 - Item invetory : Link between Ability ID and item
 - Katana inventory : Link Between Ability ID and katanas
 - Weapon inventory : shurikens and ball (? to be confirmed)
 - Jump is forced as hostile
 - AoE nullified for Item inventory, default section is ability is weapon ranged, Left to 0x00 for Jump/Charge/Attack
 - Item inventory and weapon inventory direct flag is forced ON
 
BUGS 
 - Throw item is move instead of 4
 - Short CT is not correctly checked (0x80 instead of 0x08)
 - No CT is not correctly checked (0x40 instead of 0x04)

Return location

Battle.bin
00194f80: Set_AI_ability_considerations_for_all_units_and_self
001954c0: Set_AI_ability_considerations_for_all_units_and_self
001972a8: Set_chosen_ability/target_for_AI_status
0019745c: Set_chosen_ability/target_for_AI_status
00197ec8: Chose_Move_from_Move_List?
0019894c: Evaluate_Cancel_Status_Ability_(0019881c)
00198fb0: 00198e60_-_00199058
00199fac: Usable_Ability_Setting/ENTD_AI_Calculations