Difference between revisions of "Usable Ability Setting/ENTD AI Calculations"
Jump to navigation
Jump to search
m (Return locations) |
|||
Line 1: | Line 1: | ||
Usable Ability Setting/ENTD AI Calculations | Usable Ability Setting/ENTD AI Calculations | ||
− | 00199ec8: 27bdffc0 addiu r29,r29, | + | Usable Ability Setting/ENTD AI Calculations |
− | 00199ecc: afb5002c sw r21,0x002c(r29) | + | |
− | 00199ed0: 0080a821 addu r21,r4,r0 | + | 00199ec8: 27bdffc0 addiu r29,r29,-0x0040 | |
− | 00199ed4: afb30024 sw r19,0x0024(r29) | + | 00199ecc: afb5002c sw r21,0x002c(r29) | |
− | 00199ed8: 3c13801a lui r19,0x801a | + | 00199ed0: 0080a821 addu r21,r4,r0 |{{f/std|<nowiki>r21 = Unit's ID</nowiki>}} |
− | 00199edc: 2673f3c4 addiu r19,r19,0xf3c4 | + | 00199ed4: afb30024 sw r19,0x0024(r29) | |
− | 00199ee0: 001510c0 sll r2,r21,0x03 | + | 00199ed8: 3c13801a lui r19,0x801a | |
− | 00199ee4: 00551023 subu r2,r2,r21 | + | 00199edc: 2673f3c4 addiu r19,r19,0xf3c4 |{{f/adr|<nowiki>r19 = Pointer to AI Data</nowiki>}} {{f/std|8019f3c4}} |
− | 00199ee8: 00021180 sll r2,r2,0x06 | + | 00199ee0: 001510c0 sll r2,r21,0x03 |{{f/std|ID * 8}} |
− | 00199eec: 3c038019 lui r3,0x8019 | + | 00199ee4: 00551023 subu r2,r2,r21 |{{f/std|ID * 7}} |
− | 00199ef0: 246308cc addiu r3,r3,0x08cc | + | 00199ee8: 00021180 sll r2,r2,0x06 |{{f/std|ID * 0x1c0 - Unit offset}} |
− | 00199ef4: afb60030 sw r22,0x0030(r29) | + | 00199eec: 3c038019 lui r3,0x8019 | |
− | 00199ef8: 0043b021 addu r22,r2,r3 | + | 00199ef0: 246308cc addiu r3,r3,0x08cc | |
− | 00199efc: afbf003c sw r31,0x003c(r29) | + | 00199ef4: afb60030 sw r22,0x0030(r29) | |
− | 00199f00: afbe0038 sw r30,0x0038(r29) | + | 00199ef8: 0043b021 addu r22,r2,r3 |{{f/adr|<nowiki>r22 = Pointer to Unit's Data</nowiki>}} |
− | 00199f04: afb70034 sw r23,0x0034(r29) | + | 00199efc: afbf003c sw r31,0x003c(r29) | |
− | 00199f08: afb40028 sw r20,0x0028(r29) | + | 00199f00: afbe0038 sw r30,0x0038(r29) | |
− | 00199f0c: afb20020 sw r18,0x0020(r29) | + | 00199f04: afb70034 sw r23,0x0034(r29) | |
− | 00199f10: afb1001c sw r17,0x001c(r29) | + | 00199f08: afb40028 sw r20,0x0028(r29) | |
− | 00199f14: afb00018 sw r16,0x0018(r29) | + | 00199f0c: afb20020 sw r18,0x0020(r29) | |
− | 00199f18: 92c30001 lbu r3,0x0001(r22) | + | 00199f10: afb1001c sw r17,0x001c(r29) | |
− | 00199f1c: 340200ff ori r2,r0,0x00ff | + | 00199f14: afb00018 sw r16,0x0018(r29) | |
− | 00199f20: 106200dd beq r3,r2, | + | 00199f18: 92c30001 lbu r3,0x0001(r22) |{{f/load|Load Unit's ID}} |
− | 00199f24: 02b31021 addu r2,r21,r19 | + | 00199f1c: 340200ff ori r2,r0,0x00ff |{{f/std|<nowiki>r2 = FF</nowiki>}} |
− | 00199f28: 9042198c lbu r2,0x198c(r2) | + | 00199f20: 106200dd beq r3,r2,0x0019a298 {{f/Cond|If Unit doesn't exist : Branch to}} {{f/loc|END}} |
− | 00199f2c: 00000000 nop | + | 00199f24: 02b31021 addu r2,r21,r19 |{{f/std|AI pointer + Unit offset (1 byte)}} |
− | 00199f30: 2c420010 sltiu r2,r2,0x0010 | + | 00199f28: 9042198c lbu r2,0x198c(r2) |{{f/load|Load Unit's Battle ID?}} |
− | 00199f34: 104000d8 beq r2,r0, | + | 00199f2c: 00000000 nop | |
− | 00199f38: 00000000 nop | + | 00199f30: 2c420010 sltiu r2,r2,0x0010 |{{f/std|Check if ID is valid (< 16)}} |
− | 00199f3c: 0c0668bc jal | + | 00199f34: 104000d8 beq r2,r0,0x0019a298 {{f/Cond|If Unit ID is invalid (>15) : Branch to}} {{f/loc|END}} |
− | 00199f40: 0000a021 addu r20,r0,r0 | + | 00199f38: 00000000 nop | |
− | 00199f44: 0000f021 addu r30,r0,r0 | + | 00199f3c: 0c0668bc jal 0x0019a2f0 |{{f/jal|Set AI Flags/Usable Abilities|Set AI Flags/Usable Abilities}} {{f/jal|Set Unit List of usable moves (0x8019f3c4 - 0x0ef0)|Set Unit List of usable moves (0x8019f3c4 - 0x0ef0)}} |
− | 00199f48: 0000b821 addu r23,r0,r0 | + | 00199f40: 0000a021 addu r20,r0,r0 |{{f/std|<nowiki>Number of Abilities = 0</nowiki>}} |
− | 00199f4c: 00009021 addu r18,r0,r0 | + | 00199f44: 0000f021 addu r30,r0,r0 |{{f/std|<nowiki>MP Using Abilities = 0</nowiki>}} |
− | 00199f50: 00151100 sll r2,r21,0x04 | + | 00199f48: 0000b821 addu r23,r0,r0 |{{f/std|<nowiki>Silence Blocked Abilities = 0</nowiki>}} |
− | 00199f54: 2442182c addiu r2,r2,0x182c | + | 00199f4c: 00009021 addu r18,r0,r0 |{{f/std|<nowiki>Counter = 0</nowiki>}} |
− | 00199f58: 00538821 addu r17,r2,r19 | + | 00199f50: 00151100 sll r2,r21,0x04 |{{f/std|Unit's ID * 16 (unit offset)}} |
− | 00199f5c: 340200ff ori r2,r0,0x00ff | + | 00199f54: 2442182c addiu r2,r2,0x182c |{{f/std|+ AI decision data offset}} |
− | 00199f60: afa00010 sw r0,0x0010(r29) | + | 00199f58: 00538821 addu r17,r2,r19 |{{f/adr|Unit's AI decision data pointer}} |
− | 00199f64: a2200009 sb r0,0x0009(r17) | + | 00199f5c: 340200ff ori r2,r0,0x00ff |{{f/std|<nowiki>r2 = 0x0ff</nowiki>}} |
− | 00199f68: a222000a sb r2,0x000a(r17) | + | 00199f60: afa00010 sw r0,0x0010(r29) |{{f/store|<nowiki>Store Evadeable Abilities = 0 </nowiki>}} {{f/std|On stack}} |
− | 00199f6c: 02751021 addu r2,r19,r21 | + | 00199f64: a2200009 sb r0,0x0009(r17) |{{f/store|<nowiki>Store Highest MP Cost = 0 </nowiki>}} {{f/std|AI decision data}} |
− | 00199f70: 9043198c lbu r3,0x198c(r2) | + | 00199f68: a222000a sb r2,0x000a(r17) |{{f/store|<nowiki>Store Lowest MP Cost = FF</nowiki>}} {{f/std|AI decision data}} |
− | 00199f74: 00000000 nop | + | 00199f6c: 02751021 addu r2,r19,r21 | |
− | 00199f78: 00031100 sll r2,r3,0x04 | + | {{f/bloop|LOOP through all abilities from unit list of usable moves (AI)}} |
− | 00199f7c: 00431021 addu r2,r2,r3 | + | 00199f70: 9043198c lbu r3,0x198c(r2) |{{f/load|Load Unit's Battle ID}} |
− | 00199f80: 000210c0 sll r2,r2,0x03 | + | 00199f74: 00000000 nop | |
− | 00199f84: 24420ef0 addiu r2,r2,0x0ef0 | + | 00199f78: 00031100 sll r2,r3,0x04 |{{f/std|ID * 16}} |
− | 00199f88: 02621021 addu r2,r19,r2 | + | 00199f7c: 00431021 addu r2,r2,r3 |{{f/std|ID * 17}} |
− | 00199f8c: 00121880 sll r3,r18,0x02 | + | 00199f80: 000210c0 sll r2,r2,0x03 |{{f/std|ID * 0x88 (Unit offset)}} |
− | 00199f90: 00438021 addu r16,r2,r3 | + | 00199f84: 24420ef0 addiu r2,r2,0x0ef0 |{{f/std|+ List of usable moves offset}} |
− | 00199f94: 92030002 lbu r3,0x0002(r16) | + | 00199f88: 02621021 addu r2,r19,r2 |{{f/adr|Pointer to unit list of usable moves}} |
− | 00199f98: 340200ff ori r2,r0,0x00ff | + | 00199f8c: 00121880 sll r3,r18,0x02 |{{f/std|Counter * 4}} |
− | 00199f9c: 1062006b beq r3,r2, | + | 00199f90: 00438021 addu r16,r2,r3 |{{f/adr|Pointer to this iteration Ability in unit list of usable moves}} |
− | 00199fa0: 02802021 addu r4,r20,r0 | + | 00199f94: 92030002 lbu r3,0x0002(r16) |{{f/load|Load Ability's Skillset}} |
− | 00199fa4: 0c06561e jal | + | 00199f98: 340200ff ori r2,r0,0x00ff |{{f/std|<nowiki>r2 = FF</nowiki>}} |
− | 00199fa8: 02002021 addu r4,r16,r0 | + | 00199f9c: 1062006b beq r3,r2,0x0019a14c {{f/Cond|If not at the end of the list}} {{f/std|Skillset 0xff is a end marker}} |
− | 00199fac: 96020002 lhu r2,0x0002(r16) | + | 00199fa0: 02802021 addu r4,r20,r0 |{{f/std|<nowiki>r4 = Number of Abilities</nowiki>}} |
− | 00199fb0: 00000000 nop | + | 00199fa4: 0c06561e jal 0x00195878 |{{f/jal|AI Ability Data Setting|AI Ability Data Setting}} {{f/std| Transfer data from r4 to AI used Ability data ( 8019f3c4 )}} |
− | 00199fb4: 30420800 andi r2,r2,0x0800 | + | 00199fa8: 02002021 addu r4,r16,r0 |{{f/std|Ability pointer}} |
− | 00199fb8: 14400022 bne r2,r0, | + | 00199fac: 96020002 lhu r2,0x0002(r16) |{{f/load|Load Ability's Skillset/Usage Type?}} {{f/std|From Move List 0x8019f3c4 + 0x0ef0}} |
− | 00199fbc: 26940001 addiu r20,r20,0x0001 | + | 00199fb0: 00000000 nop | |
− | 00199fc0: 8e63000c lw r3,0x000c(r19) | + | 00199fb4: 30420800 andi r2,r2,0x0800 |{{f/std|Check [Requires Monster Skill]}} |
− | 00199fc4: 00000000 nop | + | 00199fb8: 14400022 bne r2,r0,0x0019a044 {{f/Cond|If Monster skill is not needed}} |
− | 00199fc8: 30620100 andi r2,r3,0x0100 | + | 00199fbc: 26940001 addiu r20,r20,0x0001 |{{f/std|Total Abilities + 1}} |
− | 00199fcc: 10400002 beq r2,r0, | + | 00199fc0: 8e63000c lw r3,0x000c(r19) |{{f/load|Load AI Behavior Flags}} {{f/std| 8019f3c4 + 0x0c}} |
− | 00199fd0: 30620200 andi r2,r3,0x0200 | + | 00199fc4: 00000000 nop | |
− | 00199fd4: 26f70001 addiu r23,r23,0x0001 | + | 00199fc8: 30620100 andi r2,r3,0x0100 |{{f/std|Check [Ignore Silence]}} {{f/std|It is a reversed flag - 0 for ignoring silence, 1 for not ignoring}} |
− | 00199fd8: 10400005 beq r2,r0, | + | 00199fcc: 10400002 beq r2,r0,0x00199fd8 {{f/Cond|If Ability is affected by silence}} |
− | 00199fdc: 00000000 nop | + | 00199fd0: 30620200 andi r2,r3,0x0200 |{{f/std|Check [Evadable]}} |
− | 00199fe0: 8fa80010 lw r8,0x0010(r29) | + | 00199fd4: 26f70001 addiu r23,r23,0x0001 |{{f/std|Silencable Abilities + 1}} |
− | 00199fe4: 00000000 nop | + | 00199fd8: 10400005 beq r2,r0,0x00199ff0 {{f/Cond|If Ability is Evadable}} |
− | 00199fe8: 25080001 addiu r8,r8,0x0001 | + | 00199fdc: 00000000 nop | |
− | 00199fec: afa80010 sw r8,0x0010(r29) | + | 00199fe0: 8fa80010 lw r8,0x0010(r29) |{{f/load|Load Evadable abilities counter}} |
− | 00199ff0: 92630011 lbu r3,0x0011(r19) | + | 00199fe4: 00000000 nop | |
− | 00199ff4: 00000000 nop | + | 00199fe8: 25080001 addiu r8,r8,0x0001 |{{f/std|Counter + 1}} |
− | 00199ff8: 10600012 beq r3,r0, | + | 00199fec: afa80010 sw r8,0x0010(r29) |{{f/store|Store new Evadeable Abilities counter}} |
− | 00199ffc: 00000000 nop | + | 00199ff0: 92630011 lbu r3,0x0011(r19) |{{f/load|Load Ability's MP Cost}} {{f/std| 8019f3c4 + 0x11}} |
− | 0019a000: 92220009 lbu r2,0x0009(r17) | + | 00199ff4: 00000000 nop | |
− | 0019a004: 00000000 nop | + | 00199ff8: 10600012 beq r3,r0,0x0019a044 {{f/Cond|If Ability has a MP cost}} |
− | 0019a008: 0043102b sltu r2,r2,r3 | + | 00199ffc: 00000000 nop | |
− | 0019a00c: 10400004 beq r2,r0, | + | 0019a000: 92220009 lbu r2,0x0009(r17) |{{f/load|Load Highest MP Cost}} {{f/std|In AI decision data - 8019f3c4 + 0x182c + 0x09}} |
− | 0019a010: 27de0001 addiu r30,r30,0x0001 | + | 0019a004: 00000000 nop | |
− | 0019a014: 92620011 lbu r2,0x0011(r19) | + | 0019a008: 0043102b sltu r2,r2,r3 |{{f/std|Check MP cost vs Highest MP cost}} |
− | 0019a018: 00000000 nop | + | 0019a00c: 10400004 beq r2,r0,0x0019a020 {{f/Cond|If This iteration Ability has the highest MP cost}} |
− | 0019a01c: a2220009 sb r2,0x0009(r17) | + | 0019a010: 27de0001 addiu r30,r30,0x0001 |{{f/std|MP Using Abilities + 1}} |
− | 0019a020: 92620011 lbu r2,0x0011(r19) | + | 0019a014: 92620011 lbu r2,0x0011(r19) |{{f/load|Load Ability's MP Cost}} |
− | 0019a024: 9223000a lbu r3,0x000a(r17) | + | 0019a018: 00000000 nop | |
− | 0019a028: 00000000 nop | + | 0019a01c: a2220009 sb r2,0x0009(r17) |{{f/store|Store new Highest MP Cost}} {{f/std|In AI decision data - 8019f3c4 + 0x182c + 0x09}} |
− | 0019a02c: 0043102b sltu r2,r2,r3 | + | 0019a020: 92620011 lbu r2,0x0011(r19) |{{f/load|Load Ability's MP Cost}} |
− | 0019a030: 10400004 beq r2,r0, | + | 0019a024: 9223000a lbu r3,0x000a(r17) |{{f/load|Load Lowest MP Cost}} |
− | 0019a034: 00000000 nop | + | 0019a028: 00000000 nop | |
− | 0019a038: 92620011 lbu r2,0x0011(r19) | + | 0019a02c: 0043102b sltu r2,r2,r3 |{{f/std|Check if tAbility has the lowest MP cost}} |
− | 0019a03c: 00000000 nop | + | 0019a030: 10400004 beq r2,r0,0x0019a044 {{f/Cond|If This iteration Ability has the lowest MP cost}} |
− | 0019a040: a222000a sb r2,0x000a(r17) | + | 0019a034: 00000000 nop | |
− | 0019a044: 92020003 lbu r2,0x0003(r16) | + | 0019a038: 92620011 lbu r2,0x0011(r19) |{{f/load|Load Ability's MP Cost}} |
− | 0019a048: 00000000 nop | + | 0019a03c: 00000000 nop | |
− | 0019a04c: 304200f8 andi r2,r2,0x00f8 | + | 0019a040: a222000a sb r2,0x000a(r17) |{{f/store|Store new Lowest MP Cost}} {{f/std|In AI decision data - 8019f3c4 + 0x182c + 0x0a}} |
− | 0019a050: a2020003 sb r2,0x0003(r16) | + | 0019a044: 92020003 lbu r2,0x0003(r16) |{{f/load|Load Usage Type}} {{f/std|From Move List 0x8019f3c4 + 0x0ef0}} |
− | 0019a054: 8e62000c lw r2,0x000c(r19) | + | 0019a048: 00000000 nop | |
− | 0019a058: 3c0300c0 lui r3,0x00c0 | + | 0019a04c: 304200f8 andi r2,r2,0x00f8 |{{f/std|Disable 0x01 (Evade with motion) 0x02 (unknown) and 0x04 (Use weapon range)}} |
− | 0019a05c: 00431024 and r2,r2,r3 | + | 0019a050: a2020003 sb r2,0x0003(r16) |{{f/store|store new Usage type?}} |
− | 0019a060: 14400035 bne r2,r0, | + | 0019a054: 8e62000c lw r2,0x000c(r19) |{{f/load|Load Ability's AI Flags}} {{f/std| 8019f3c4 + 0x0c}} |
− | 0019a064: 00000000 nop | + | 0019a058: 3c0300c0 lui r3,0x00c0 | |
− | 0019a068: 9262000e lbu r2,0x000e(r19) | + | 0019a05c: 00431024 and r2,r2,r3 |{{f/std|Check [Longbow] and [Stop at Obstacle]}} |
− | 0019a06c: 00000000 nop | + | 0019a060: 14400035 bne r2,r0,0x0019a138 {{f/Cond|If Ability is not Arcing nor a direct attack}} {{f/std|/Else branc to }} {{f/loc|next loop iteration}} |
− | 0019a070: 3042003c andi r2,r2,0x003c | + | 0019a064: 00000000 nop | |
− | + | 0019a068: 9262000e lbu r2,0x000e(r19) |{{f/load|Load Ability's AI Flags 3}} | |
− | 0019a078: 00000000 nop | + | 0019a06c: 00000000 nop | |
− | 0019a07c: 96020002 lhu r2,0x0002(r16) | + | 0019a070: 3042003c andi r2,r2,0x003c |{{f/std|Check [Linear Attack] , [Non Spear], [3 direction melee], [3 Direction ranged]}} {{f/std| Non spear is a reverted flag (0x1 if unchecked)}} |
− | 0019a080: 0806684d j | + | 0019a074: 10400004 beq r2,r0,0x0019a088 {{f/Cond|If Ability is a Linear Attack, a spear attack or a 3 directional Attack}} |
− | 0019a084: 34420400 ori r2,r2,0x0400 | + | 0019a078: 00000000 nop | |
− | 0019a088: 86640002 lh r4,0x0002(r19) | + | 0019a07c: 96020002 lhu r2,0x0002(r16) |{{f/load|Load Ability's Skillset/Usage Type?}} {{f/std|From Move List 0x8019f3c4 + 0x0ef0}} |
− | 0019a08c: 00000000 nop | + | 0019a080: 0806684d j 0x0019a134 {{f/jump|Jump to next iteration (will store new usage byte)}} |
− | 0019a090: 28820170 slti r2,r4,0x0170 | + | 0019a084: 34420400 ori r2,r2,0x0400 |{{f/std|Enable 0x04 (Use Weapon range - Evadable flag ?)}} |
− | 0019a094: 10400020 beq r2,r0, | + | {{f/Cond|Ability is not a Linear attack, a spear attack nor a 3 directionnal attack}} |
− | 0019a098: 00000000 nop | + | 0019a088: 86640002 lh r4,0x0002(r19) |{{f/load|Load Ability ID}} {{f/std|From 0x80193fc4}} |
− | 0019a09c: 92620004 lbu r2,0x0004(r19) | + | 0019a08c: 00000000 nop | |
− | 0019a0a0: 92630005 lbu r3,0x0005(r19) | + | 0019a090: 28820170 slti r2,r4,0x0170 |{{f/std|Check if Ability has a second data table}} |
− | 0019a0a4: 00000000 nop | + | 0019a094: 10400020 beq r2,r0,0x0019a118 {{f/Cond|If Ability has a second data table}} |
− | 0019a0a8: 00431021 addu r2,r2,r3 | + | 0019a098: 00000000 nop | |
− | 0019a0ac: 28420003 slti r2,r2,0x0003 | + | 0019a09c: 92620004 lbu r2,0x0004(r19) |{{f/load|Load Ability's Range}} {{f/std|From 0x80193fc4}} |
− | 0019a0b0: 1040000d beq r2,r0, | + | 0019a0a0: 92630005 lbu r3,0x0005(r19) |{{f/load|Load Ability's AoE}} {{f/std|From 0x80193fc4}} |
− | 0019a0b4: 000410c0 sll r2,r4,0x03 | + | 0019a0a4: 00000000 nop | |
− | 0019a0b8: 00441023 subu r2,r2,r4 | + | 0019a0a8: 00431021 addu r2,r2,r3 |{{f/std|<nowiki>Max Range = Range + AoE</nowiki>}} |
− | 0019a0bc: 00021040 sll r2,r2,0x01 | + | 0019a0ac: 28420003 slti r2,r2,0x0003 |{{f/std|Check if max range is < 0x3}} |
− | 0019a0c0: 3c018006 lui r1,0x8006 | + | 0019a0b0: 1040000d beq r2,r0,0x0019a0e8 {{f/Cond|If Max range < 3}} |
− | 0019a0c4: 00220821 addu r1,r1,r2 | + | 0019a0b4: 000410c0 sll r2,r4,0x03 |{{f/std|Ability ID * 8}} |
− | 0019a0c8: 9022fbf6 lbu r2,-0x040a(r1) | + | 0019a0b8: 00441023 subu r2,r2,r4 |{{f/std|ID * 7}} |
− | 0019a0cc: 00000000 nop | + | 0019a0bc: 00021040 sll r2,r2,0x01 |{{f/std|ID * 14 (Ability offset)}} |
− | 0019a0d0: 30420002 andi r2,r2,0x0002 | + | 0019a0c0: 3c018006 lui r1,0x8006 | |
− | 0019a0d4: 10400004 beq r2,r0, | + | 0019a0c4: 00220821 addu r1,r1,r2 |{{f/adr|Part of pointer to Ability data 2}} |
− | 0019a0d8: 00000000 nop | + | 0019a0c8: 9022fbf6 lbu r2,-0x040a(r1) |{{f/load|Load Ability's Flags 4}} {{f/std|SCUS - 0x8005fbf0 + 0x06 + Ability offset}} |
− | 0019a0dc: 96020002 lhu r2,0x0002(r16) | + | 0019a0cc: 00000000 nop | |
− | 0019a0e0: 0806684d j | + | 0019a0d0: 30420002 andi r2,r2,0x0002 |{{f/std|Check [Evadable]}} |
− | 0019a0e4: 34420400 ori r2,r2,0x0400 | + | 0019a0d4: 10400004 beq r2,r0,0x0019a0e8 {{f/Cond|If Ability is evadable}} |
− | 0019a0e8: 86620002 lh r2,0x0002(r19) | + | 0019a0d8: 00000000 nop | |
− | 0019a0ec: 00000000 nop | + | 0019a0dc: 96020002 lhu r2,0x0002(r16) |{{f/load|Load Ability's Skillset/Usage Type?}} |
− | 0019a0f0: 000218c0 sll r3,r2,0x03 | + | 0019a0e0: 0806684d j 0x0019a134 {{f/jump|Jump to next iteration (will store new usage byte)}} |
− | 0019a0f4: 00621823 subu r3,r3,r2 | + | 0019a0e4: 34420400 ori r2,r2,0x0400 |{{f/std|Enable 0x04 (Use Weapon range - Evadable flag ?)}} |
− | 0019a0f8: 00031840 sll r3,r3,0x01 | + | {{f/Cond|Else : Range > 2 or Ability not Evadable}} |
− | 0019a0fc: 3c018006 lui r1,0x8006 | + | 0019a0e8: 86620002 lh r2,0x0002(r19) |{{f/load|Load Ability ID}} |
− | 0019a100: 00230821 addu r1,r1,r3 | + | 0019a0ec: 00000000 nop | |
− | 0019a104: 9022fbf4 lbu r2,-0x040c(r1) | + | 0019a0f0: 000218c0 sll r3,r2,0x03 |{{f/std|ID * 8}} |
− | 0019a108: 00000000 nop | + | 0019a0f4: 00621823 subu r3,r3,r2 |{{f/std|ID * 7}} |
− | 0019a10c: 30420041 andi r2,r2,0x0041 | + | 0019a0f8: 00031840 sll r3,r3,0x01 |{{f/std|ID * 14 (Ability offset)}} |
− | 0019a110: 14400005 bne r2,r0, | + | 0019a0fc: 3c018006 lui r1,0x8006 | |
− | 0019a114: 00000000 nop | + | 0019a100: 00230821 addu r1,r1,r3 |{{f/adr|Par of pointer to Ability data 2}} {{f/std|SCUS - 0x8005fbf0 + 0x04 + Ability offset}} |
− | 0019a118: 92620005 lbu r2,0x0005(r19) | + | 0019a104: 9022fbf4 lbu r2,-0x040c(r1) |{{f/load|Load Ability's Flags 2}} |
− | 0019a11c: 00000000 nop | + | 0019a108: 00000000 nop | |
− | 0019a120: 14400005 bne r2,r0, | + | 0019a10c: 30420041 andi r2,r2,0x0041 |{{f/std|Check [Hit Ally] and [Hit Caster]}} {{f/std| Two reverted flags (0 if can hit)}} |
− | 0019a124: 00000000 nop | + | 0019a110: 14400005 bne r2,r0,0x0019a128 {{f/Cond|If Ability can hit Caster team}} |
− | 0019a128: 96020002 lhu r2,0x0002(r16) | + | 0019a114: 00000000 nop | |
− | 0019a12c: 00000000 nop | + | 0019a118: 92620005 lbu r2,0x0005(r19) {{f/Cond|E }} |{{f/load|Load AoE}} {{f/std|From 0x80193fc4}} |
− | 0019a130: 34420200 ori r2,r2,0x0200 | + | 0019a11c: 00000000 nop | |
− | 0019a134: a6020002 sh r2,0x0002(r16) | + | 0019a120: 14400005 bne r2,r0,0x0019a138 {{f/Cond|<nowiki>If AoE = 0</nowiki>}} {{f/std|<nowiki>(Can Hit Allies but no AoE = no risk of collateral damage ?)</nowiki>}} |
− | 0019a138: 26520001 addiu r18,r18,0x0001 | + | 0019a124: 00000000 nop | |
− | 0019a13c: 2a420022 slti r2,r18,0x0022 | + | 0019a128: 96020002 lhu r2,0x0002(r16) {{f/Cond|E }} |{{f/load|Load Skillset/Usage Type?}} |
− | 0019a140: 1440ff8b bne r2,r0, | + | 0019a12c: 00000000 nop | |
− | 0019a144: 02751021 addu r2,r19,r21 | + | 0019a130: 34420200 ori r2,r2,0x0200 |{{f/std|Enable 0x02}} |
− | 0019a148: 02802021 addu r4,r20,r0 | + | 0019a134: a6020002 sh r2,0x0002(r16) {{f/Cond|E }} {{f/Cond|E }} |{{f/store|Store new Skillset/Usage Type?}} |
− | 0019a14c: 0c0668b3 jal | + | 0019a138: 26520001 addiu r18,r18,0x0001 |{{f/std|LOOP counter + 1}} |
− | + | 0019a13c: 2a420022 slti r2,r18,0x0022 |{{f/std|Check counter vs limit}} | |
− | 0019a154: 02802021 addu r4,r20,r0 | + | 0019a140: 1440ff8b bne r2,r0,0x00199f70 {{f/eloop|LOOP Branch if Counter < 34}} |
− | 0019a158: 03c02821 addu r5,r30,r0 | + | 0019a144: 02751021 addu r2,r19,r21 |{{f/std|<nowiki>r2 = AI Data Pointer + unit offset (load Battle ID at 0x198c when the loop starts)</nowiki>}} |
− | 0019a15c: 0c0668b3 jal | + | 0019a148: 02802021 addu r4,r20,r0 |{{f/std|<nowiki>Divisor = Number of Abilities</nowiki>}} |
− | 0019a160: a222000c sb r2,0x000c(r17) | + | 0019a14c: 0c0668b3 jal 0x0019a2cc |{{f/jal|Dividend * 4 / Divisor|Dividend * 4 / Divisor}} {{f/std|<nowiki>Returns r2 = r5*4/r4</nowiki>}} |
− | 0019a164: 8fa50010 lw r5,0x0010(r29) | + | 0019a150: 02e02821 addu r5,r23,r0 |{{f/std|<nowiki>Dividend = Nb Of Ability affected by silence</nowiki>}} |
− | 0019a168: 02802021 addu r4,r20,r0 | + | 0019a154: 02802021 addu r4,r20,r0 |{{f/std|<nowiki>Divisor = Number of Abilities</nowiki>}} |
− | 0019a16c: 0c0668b3 jal | + | 0019a158: 03c02821 addu r5,r30,r0 |{{f/std|<nowiki>Dividend = Nb Of Ability with a MP cost</nowiki>}} |
− | 0019a170: a222000b sb r2,0x000b(r17) | + | 0019a15c: 0c0668b3 jal 0x0019a2cc |{{f/jal|Dividend * 4 / Divisor|Dividend * 4 / Divisor}} |
− | 0019a174: 26240004 addiu r4,r17,0x0004 | + | 0019a160: a222000c sb r2,0x000c(r17) |{{f/store|Store Silence effectivness Mod}} |
− | 0019a178: 26c50167 addiu r5,r22,0x0167 | + | 0019a164: 8fa50010 lw r5,0x0010(r29) |{{f/load|Dividend - load Evadable Abilities}} |
− | 0019a17c: 34060005 ori r6,r0,0x0005 | + | 0019a168: 02802021 addu r4,r20,r0 |{{f/std|<nowiki>Divisor = Number of Abilities</nowiki>}} |
− | 0019a180: 0c066ad2 jal | + | 0019a16c: 0c0668b3 jal 0x0019a2cc |{{f/jal|Dividend * 4 / Divisor|Dividend * 4 / Divisor}} |
− | 0019a184: a222000d sb r2,0x000d(r17) | + | 0019a170: a222000b sb r2,0x000b(r17) |{{f/store|Store MP Using Mod}} |
− | 0019a188: 92c20165 lbu r2,0x0165(r22) | + | 0019a174: 26240004 addiu r4,r17,0x0004 |{{f/std|AI decision + 0x04 (ENTD - settings)}} |
− | 0019a18c: 92230004 lbu r3,0x0004(r17) | + | 0019a178: 26c50167 addiu r5,r22,0x0167 |{{f/std|<nowiki>r5 = Pointer to Unit's ENTD AI setting</nowiki>}} {{f/std|0x801908cc + 0x167}} |
− | 0019a190: a2220000 sb r2,0x0000(r17) | + | 0019a17c: 34060005 ori r6,r0,0x0005 |{{f/std|<nowiki>Limit = 5</nowiki>}} |
− | 0019a194: 92c20166 lbu r2,0x0166(r22) | + | 0019a180: 0c066ad2 jal 0x0019ab48 |{{f/jal|Transfer Byte Values|Transfer Byte Values}} {{f/std|Transfer Bytes from 0x167 to 16b to AI decision 0x04 to 0x8}} |
− | 0019a198: 00000000 nop | + | 0019a184: a222000d sb r2,0x000d(r17) |{{f/store|Store Evade Mod}} |
− | 0019a19c: a2220002 sb r2,0x0002(r17) | + | 0019a188: 92c20165 lbu r2,0x0165(r22) |{{f/load|Load AI X Location}} |
− | 0019a1a0: 92c20167 lbu r2,0x0167(r22) | + | 0019a18c: 92230004 lbu r3,0x0004(r17) |{{f/load|Load AI Setting - Behavior}} |
− | 0019a1a4: a2200003 sb r0,0x0003(r17) | + | 0019a190: a2220000 sb r2,0x0000(r17) |{{f/store|Store X Location to stay near}} |
− | 0019a1a8: 000211c2 srl r2,r2,0x07 | + | 0019a194: 92c20166 lbu r2,0x0166(r22) |{{f/load|Load AI Y Location}} |
− | 0019a1ac: a2220001 sb r2,0x0001(r17) | + | 0019a198: 00000000 nop | |
− | 0019a1b0: 30620008 andi r2,r3,0x0008 | + | 0019a19c: a2220002 sb r2,0x0002(r17) |{{f/store|Store Y Location to stay near}} |
− | 0019a1b4: 10400038 beq r2,r0, | + | 0019a1a0: 92c20167 lbu r2,0x0167(r22) |{{f/load|Load Unit 0x167 (elevation + behavior)}} |
− | 0019a1b8: 00000000 nop | + | 0019a1a4: a2200003 sb r0,0x0003(r17) |{{f/store|Nullify/Initialize AI decision 0x03}} |
− | 0019a1bc: 92220007 lbu r2,0x0007(r17) | + | 0019a1a8: 000211c2 srl r2,r2,0x07 |{{f/std|0x80 (if Higher Elevation)}} |
− | 0019a1c0: 00000000 nop | + | 0019a1ac: a2220001 sb r2,0x0001(r17) |{{f/store|Store Higher Elevation Flag}} |
− | 0019a1c4: 30420004 andi r2,r2,0x0004 | + | 0019a1b0: 30620008 andi r2,r3,0x0008 |{{f/std|Check [Defensive]}} {{f/std|Defensive in Patcher - Coward-like in Wiki}} |
− | 0019a1c8: 10400007 beq r2,r0, | + | 0019a1b4: 10400038 beq r2,r0,0x0019a298 {{f/Cond|If Unit Setting is Defensive}} /Else branch to {{f/loc|END}} |
− | 0019a1cc: 34020011 ori r2,r0,0x0011 | + | 0019a1b8: 00000000 nop | |
− | 0019a1d0: 02751821 addu r3,r19,r21 | + | 0019a1bc: 92220007 lbu r2,0x0007(r17) |{{f/load|Load AI Targeting flag (Copied from Unit battle 0x16a)}} |
− | 0019a1d4: 080668a6 j | + | 0019a1c0: 00000000 nop | |
− | 0019a1d8: a06219a1 sb r2,0x19a1(r3) | + | 0019a1c4: 30420004 andi r2,r2,0x0004 |{{f/std|Check [Save-CT Protect Self]}} |
− | + | 0019a1c8: 10400007 beq r2,r0,0x0019a1e8 {{f/Cond|If Unit setting is Conserve CT}} | |
− | 0019a1e0: 080668a6 j | + | 0019a1cc: 34020011 ori r2,r0,0x0011 |{{f/std|<nowiki>r2 = 0x11</nowiki>}} |
− | 0019a1e4: a06219a1 sb r2,0x19a1(r3) | + | 0019a1d0: 02751821 addu r3,r19,r21 |{{f/std|<nowiki>r2 = AI Data Pointer + unit offset </nowiki>}} |
− | + | 0019a1d4: 080668a6 j 0x0019a298 {{f/jump|Jump to}} {{f/loc|END}} | |
− | 0019a1ec: 1040002a beq r2,r0, | + | 0019a1d8: a06219a1 sb r2,0x19a1(r3) |{{f/store|Store 0x11 at 0x8019f34c4 + 0x19a1 + Unit offset (1 byte per unit)}} |
− | 0019a1f0: 00009021 addu r18,r0,r0 | + | |
− | 0019a1f4: 340600ff ori r6,r0,0x00ff | + | {{f/sec|Backward branch section - Focus On Enemy - Aggressive}} |
− | 0019a1f8: 02752821 addu r5,r19,r21 | + | 0019a1dc: 3402000c ori r2,r0,0x000c |{{f/std|<nowiki>r2 = 0x0c</nowiki>}} |
− | 0019a1fc: 3407000e ori r7,r0,0x000e | + | 0019a1e0: 080668a6 j 0x0019a298 {{f/jump|Jump to}} {{f/loc|END}} |
− | 0019a200: 00002021 addu r4,r0,r0 | + | 0019a1e4: a06219a1 sb r2,0x19a1(r3) |{{f/store|Store 0x0c at 0x8019f34c4 + 0x19a1 + Unit offset (1 byte per unit)}} |
− | 0019a204: 3c018019 lui r1,0x8019 | + | |
− | 0019a208: 00240821 addu r1,r1,r4 | + | {{f/Cond|Else - Unit will not preserve CT}} |
− | 0019a20c: 902208cd lbu r2,0x08cd(r1) | + | 0019a1e8: 30620040 andi r2,r3,0x0040 |{{f/std|check [Focus Unit]}} |
− | 0019a210: 00000000 nop | + | 0019a1ec: 1040002a beq r2,r0,0x0019a298 {{f/Cond|If Unit Setting is Focus Unit}} /Else branch to {{f/loc|END}} |
− | 0019a214: 10460018 beq r2,r6, | + | 0019a1f0: 00009021 addu r18,r0,r0 |{{f/std|<nowiki>Counter = 0</nowiki>}} |
− | 0019a218: 00000000 nop | + | 0019a1f4: 340600ff ori r6,r0,0x00ff |{{f/std|<nowiki>r6 = 0xff</nowiki>}} |
− | 0019a21c: 3c018019 lui r1,0x8019 | + | 0019a1f8: 02752821 addu r5,r19,r21 |{{f/std|<nowiki>r5 = AI Pointer + Unit's ID</nowiki>}} |
− | 0019a220: 00240821 addu r1,r1,r4 | + | 0019a1fc: 3407000e ori r7,r0,0x000e |{{f/std|<nowiki>r7 = 0x0e</nowiki>}} |
− | 0019a224: 90230a2d lbu r3,0x0a2d(r1) | + | 0019a200: 00002021 addu r4,r0,r0 |{{f/std|Unit Offset (+0x01c0 each iteration)}} |
− | 0019a228: 92220005 lbu r2,0x0005(r17) | + | 0019a204: 3c018019 lui r1,0x8019 {{f/bloop|LOOP through all units}} {{f/std|Looking for Unit AI target}} |
− | 0019a22c: 00000000 nop | + | 0019a208: 00240821 addu r1,r1,r4 |{{f/adr|Part of pointer to unit battle stats}} |
− | 0019a230: 14620011 bne r3,r2, | + | 0019a20c: 902208cd lbu r2,0x08cd(r1) |{{f/load|Load Unit's ID}} {{f/std| 0x801908cc + 0x01 + unit offset}} |
− | 0019a234: 00000000 nop | + | 0019a210: 00000000 nop | |
− | 0019a238: 92220004 lbu r2,0x0004(r17) | + | 0019a214: 10460018 beq r2,r6,0x0019a278 {{f/Cond|If Unit exists (<> 0xff)}} |
− | 0019a23c: 00000000 nop | + | 0019a218: 00000000 nop | |
− | 0019a240: 30420010 andi r2,r2,0x0010 | + | 0019a21c: 3c018019 lui r1,0x8019 | |
− | 0019a244: 10400014 beq r2,r0, | + | 0019a220: 00240821 addu r1,r1,r4 |{{f/adr|Part of pointer to unit battle stats}} |
− | 0019a248: a2320005 sb r18,0x0005(r17) | + | 0019a224: 90230a2d lbu r3,0x0a2d(r1) |{{f/load|Load this iteration Unit's ENTD ID}} |
− | 0019a24c: a2d201b9 sb r18,0x01b9(r22) | + | 0019a228: 92220005 lbu r2,0x0005(r17) |{{f/load|Load Acting Unit Main Target ID}} |
− | 0019a250: 3c018019 lui r1,0x8019 | + | 0019a22c: 00000000 nop | |
− | 0019a254: 00240821 addu r1,r1,r4 | + | 0019a230: 14620011 bne r3,r2,0x0019a278 {{f/Cond|If This iteration unit is the Targeted Unit}} |
− | 0019a258: 90230a86 lbu r3,0x0a86(r1) | + | 0019a234: 00000000 nop | |
− | 0019a25c: 92c201ba lbu r2,0x01ba(r22) | + | 0019a238: 92220004 lbu r2,0x0004(r17) |{{f/load|Load AI Behavior}} {{f/std|Copied from Unit 0x167}} |
− | 0019a260: 30630030 andi r3,r3,0x0030 | + | 0019a23c: 00000000 nop | |
− | 0019a264: 30420030 andi r2,r2,0x0030 | + | 0019a240: 30420010 andi r2,r2,0x0010 |{{f/std|Check [Aggressive]}} |
− | 0019a268: 1462ffdc bne r3,r2, | + | 0019a244: 10400014 beq r2,r0,0x0019a298 {{f/Cond|If Unit AI setting is Aggressive}} /Else Branch to {{f/loc|END}} |
− | 0019a26c: 02751821 addu r3,r19,r21 | + | 0019a248: a2320005 sb r18,0x0005(r17) |{{f/store|Store Unit as Main target}} {{f/std|It should be already the case no ? }} |
− | 0019a270: 080668a6 j | + | 0019a24c: a2d201b9 sb r18,0x01b9(r22) |{{f/store|Store Main Target ID in acting unit data (0x1b9)}} |
− | 0019a274: a0a719a1 sb r7,0x19a1(r5) | + | 0019a250: 3c018019 lui r1,0x8019 | |
− | 0019a278: 26520001 addiu r18,r18,0x0001 | + | 0019a254: 00240821 addu r1,r1,r4 |{{f/adr|Part of pointer to unit battle stats}} |
− | 0019a27c: 2a420015 slti r2,r18,0x0015 | + | 0019a258: 90230a86 lbu r3,0x0a86(r1) |{{f/load|LoadThis iteration Unit's Modified ENTD Flags}} |
− | 0019a280: 1440ffe0 bne r2,r0, | + | 0019a25c: 92c201ba lbu r2,0x01ba(r22) |{{f/load|Load Unit's Modified ENTD Flags}} |
− | 0019a284: 248401c0 addiu r4,r4,0x01c0 | + | 0019a260: 30630030 andi r3,r3,0x0030 |{{f/std|Check this iteration unit Team}} |
− | 0019a288: 92220004 lbu r2,0x0004(r17) | + | 0019a264: 30420030 andi r2,r2,0x0030 |{{f/std|Check Acting unit Team}} |
− | 0019a28c: 00000000 nop | + | 0019a268: 1462ffdc bne r3,r2,0x0019a1dc {{f/Cond|Acting Unit and Main Target are in the same Team}} |
− | 0019a290: 304200f7 andi r2,r2,0x00f7 | + | 0019a26c: 02751821 addu r3,r19,r21 |{{f/std|<nowiki>r3 = AI Pointer + Unit ID</nowiki>}} |
− | 0019a294: a2220004 sb r2,0x0004(r17) | + | 0019a270: 080668a6 j 0x0019a298 {{f/jump|Jump to }} {{f/loc|END}} |
− | 0019a298: 8fbf003c lw r31,0x003c(r29) | + | 0019a274: a0a719a1 sb r7,0x19a1(r5) |{{f/store|Store 0x0e at 0x8019f34c4 + 0x19a1 + Unit offset (1 byte per unit)}} |
+ | 0019a278: 26520001 addiu r18,r18,0x0001 |{{f/std|Unit ID + 1}} | ||
+ | 0019a27c: 2a420015 slti r2,r18,0x0015 |{{f/std|Check Unit ID vs Loop limit}} | ||
+ | 0019a280: 1440ffe0 bne r2,r0,0x0019a204 {{f/Cond|Branch if Counter < 21}} | ||
+ | 0019a284: 248401c0 addiu r4,r4,0x01c0 |{{f/std|Unit Data Offset (+0x01c0 each iteration)}} | ||
+ | '''The code ends here if ''': Unit has [Focus Unit] setting but no valid target | ||
+ | 0019a288: 92220004 lbu r2,0x0004(r17) |{{f/load|Load AI Behavior}} | ||
+ | 0019a28c: 00000000 nop | | ||
+ | 0019a290: 304200f7 andi r2,r2,0x00f7 |{{f/std|Disable [0x08] if No Target }} {{f/std|No peculiar behavior}} | ||
+ | 0019a294: a2220004 sb r2,0x0004(r17) |{{f/store|Store updated data}} | ||
+ | 0019a298: 8fbf003c lw r31,0x003c(r29) END | ||
0019a29c: 8fbe0038 lw r30,0x0038(r29) | 0019a29c: 8fbe0038 lw r30,0x0038(r29) | ||
0019a2a0: 8fb70034 lw r23,0x0034(r29) | 0019a2a0: 8fb70034 lw r23,0x0034(r29) | ||
Line 257: | Line 267: | ||
0019a2c4: 03e00008 jr r31 | 0019a2c4: 03e00008 jr r31 | ||
0019a2c8: 00000000 nop | 0019a2c8: 00000000 nop | ||
− | == Return locations == | + | === Notes === |
+ | === Return locations === | ||
'''Battle.bin''' | '''Battle.bin''' | ||
00068f3c: [[Special_Status_Flag_Enabling%3F|Special_Status_Flag_Enabling]] - Remove Frog | 00068f3c: [[Special_Status_Flag_Enabling%3F|Special_Status_Flag_Enabling]] - Remove Frog |
Revision as of 19:24, 30 April 2023
Usable Ability Setting/ENTD AI Calculations Usable Ability Setting/ENTD AI Calculations 00199ec8: 27bdffc0 addiu r29,r29,-0x0040 | 00199ecc: afb5002c sw r21,0x002c(r29) | 00199ed0: 0080a821 addu r21,r4,r0 |r21 = Unit's ID 00199ed4: afb30024 sw r19,0x0024(r29) | 00199ed8: 3c13801a lui r19,0x801a | 00199edc: 2673f3c4 addiu r19,r19,0xf3c4 |r19 = Pointer to AI Data 8019f3c4 00199ee0: 001510c0 sll r2,r21,0x03 |ID * 8 00199ee4: 00551023 subu r2,r2,r21 |ID * 7 00199ee8: 00021180 sll r2,r2,0x06 |ID * 0x1c0 - Unit offset 00199eec: 3c038019 lui r3,0x8019 | 00199ef0: 246308cc addiu r3,r3,0x08cc | 00199ef4: afb60030 sw r22,0x0030(r29) | 00199ef8: 0043b021 addu r22,r2,r3 |r22 = Pointer to Unit's Data 00199efc: afbf003c sw r31,0x003c(r29) | 00199f00: afbe0038 sw r30,0x0038(r29) | 00199f04: afb70034 sw r23,0x0034(r29) | 00199f08: afb40028 sw r20,0x0028(r29) | 00199f0c: afb20020 sw r18,0x0020(r29) | 00199f10: afb1001c sw r17,0x001c(r29) | 00199f14: afb00018 sw r16,0x0018(r29) | 00199f18: 92c30001 lbu r3,0x0001(r22) |Load Unit's ID 00199f1c: 340200ff ori r2,r0,0x00ff |r2 = FF 00199f20: 106200dd beq r3,r2,0x0019a298 #If Unit doesn't exist : Branch to END 00199f24: 02b31021 addu r2,r21,r19 |AI pointer + Unit offset (1 byte) 00199f28: 9042198c lbu r2,0x198c(r2) |Load Unit's Battle ID? 00199f2c: 00000000 nop | 00199f30: 2c420010 sltiu r2,r2,0x0010 |Check if ID is valid (< 16) 00199f34: 104000d8 beq r2,r0,0x0019a298 #If Unit ID is invalid (>15) : Branch to END 00199f38: 00000000 nop | 00199f3c: 0c0668bc jal 0x0019a2f0 |-->Set AI Flags/Usable Abilities -->Set Unit List of usable moves (0x8019f3c4 - 0x0ef0) 00199f40: 0000a021 addu r20,r0,r0 |Number of Abilities = 0 00199f44: 0000f021 addu r30,r0,r0 |MP Using Abilities = 0 00199f48: 0000b821 addu r23,r0,r0 |Silence Blocked Abilities = 0 00199f4c: 00009021 addu r18,r0,r0 |Counter = 0 00199f50: 00151100 sll r2,r21,0x04 |Unit's ID * 16 (unit offset) 00199f54: 2442182c addiu r2,r2,0x182c |+ AI decision data offset 00199f58: 00538821 addu r17,r2,r19 |Unit's AI decision data pointer 00199f5c: 340200ff ori r2,r0,0x00ff |r2 = 0x0ff 00199f60: afa00010 sw r0,0x0010(r29) |Store Evadeable Abilities = 0 On stack 00199f64: a2200009 sb r0,0x0009(r17) |Store Highest MP Cost = 0 AI decision data 00199f68: a222000a sb r2,0x000a(r17) |Store Lowest MP Cost = FF AI decision data 00199f6c: 02751021 addu r2,r19,r21 | @LOOP through all abilities from unit list of usable moves (AI) 00199f70: 9043198c lbu r3,0x198c(r2) |Load Unit's Battle ID 00199f74: 00000000 nop | 00199f78: 00031100 sll r2,r3,0x04 |ID * 16 00199f7c: 00431021 addu r2,r2,r3 |ID * 17 00199f80: 000210c0 sll r2,r2,0x03 |ID * 0x88 (Unit offset) 00199f84: 24420ef0 addiu r2,r2,0x0ef0 |+ List of usable moves offset 00199f88: 02621021 addu r2,r19,r2 |Pointer to unit list of usable moves 00199f8c: 00121880 sll r3,r18,0x02 |Counter * 4 00199f90: 00438021 addu r16,r2,r3 |Pointer to this iteration Ability in unit list of usable moves 00199f94: 92030002 lbu r3,0x0002(r16) |Load Ability's Skillset 00199f98: 340200ff ori r2,r0,0x00ff |r2 = FF 00199f9c: 1062006b beq r3,r2,0x0019a14c #If not at the end of the list Skillset 0xff is a end marker 00199fa0: 02802021 addu r4,r20,r0 |r4 = Number of Abilities 00199fa4: 0c06561e jal 0x00195878 |-->AI Ability Data Setting Transfer data from r4 to AI used Ability data ( 8019f3c4 ) 00199fa8: 02002021 addu r4,r16,r0 |Ability pointer 00199fac: 96020002 lhu r2,0x0002(r16) |Load Ability's Skillset/Usage Type? From Move List 0x8019f3c4 + 0x0ef0 00199fb0: 00000000 nop | 00199fb4: 30420800 andi r2,r2,0x0800 |Check [Requires Monster Skill] 00199fb8: 14400022 bne r2,r0,0x0019a044 #If Monster skill is not needed 00199fbc: 26940001 addiu r20,r20,0x0001 |Total Abilities + 1 00199fc0: 8e63000c lw r3,0x000c(r19) |Load AI Behavior Flags 8019f3c4 + 0x0c 00199fc4: 00000000 nop | 00199fc8: 30620100 andi r2,r3,0x0100 |Check [Ignore Silence] It is a reversed flag - 0 for ignoring silence, 1 for not ignoring 00199fcc: 10400002 beq r2,r0,0x00199fd8 #If Ability is affected by silence 00199fd0: 30620200 andi r2,r3,0x0200 |Check [Evadable] 00199fd4: 26f70001 addiu r23,r23,0x0001 |Silencable Abilities + 1 00199fd8: 10400005 beq r2,r0,0x00199ff0 #If Ability is Evadable 00199fdc: 00000000 nop | 00199fe0: 8fa80010 lw r8,0x0010(r29) |Load Evadable abilities counter 00199fe4: 00000000 nop | 00199fe8: 25080001 addiu r8,r8,0x0001 |Counter + 1 00199fec: afa80010 sw r8,0x0010(r29) |Store new Evadeable Abilities counter 00199ff0: 92630011 lbu r3,0x0011(r19) |Load Ability's MP Cost 8019f3c4 + 0x11 00199ff4: 00000000 nop | 00199ff8: 10600012 beq r3,r0,0x0019a044 #If Ability has a MP cost 00199ffc: 00000000 nop | 0019a000: 92220009 lbu r2,0x0009(r17) |Load Highest MP Cost In AI decision data - 8019f3c4 + 0x182c + 0x09 0019a004: 00000000 nop | 0019a008: 0043102b sltu r2,r2,r3 |Check MP cost vs Highest MP cost 0019a00c: 10400004 beq r2,r0,0x0019a020 #If This iteration Ability has the highest MP cost 0019a010: 27de0001 addiu r30,r30,0x0001 |MP Using Abilities + 1 0019a014: 92620011 lbu r2,0x0011(r19) |Load Ability's MP Cost 0019a018: 00000000 nop | 0019a01c: a2220009 sb r2,0x0009(r17) |Store new Highest MP Cost In AI decision data - 8019f3c4 + 0x182c + 0x09 0019a020: 92620011 lbu r2,0x0011(r19) |Load Ability's MP Cost 0019a024: 9223000a lbu r3,0x000a(r17) |Load Lowest MP Cost 0019a028: 00000000 nop | 0019a02c: 0043102b sltu r2,r2,r3 |Check if tAbility has the lowest MP cost 0019a030: 10400004 beq r2,r0,0x0019a044 #If This iteration Ability has the lowest MP cost 0019a034: 00000000 nop | 0019a038: 92620011 lbu r2,0x0011(r19) |Load Ability's MP Cost 0019a03c: 00000000 nop | 0019a040: a222000a sb r2,0x000a(r17) |Store new Lowest MP Cost In AI decision data - 8019f3c4 + 0x182c + 0x0a 0019a044: 92020003 lbu r2,0x0003(r16) |Load Usage Type From Move List 0x8019f3c4 + 0x0ef0 0019a048: 00000000 nop | 0019a04c: 304200f8 andi r2,r2,0x00f8 |Disable 0x01 (Evade with motion) 0x02 (unknown) and 0x04 (Use weapon range) 0019a050: a2020003 sb r2,0x0003(r16) |store new Usage type? 0019a054: 8e62000c lw r2,0x000c(r19) |Load Ability's AI Flags 8019f3c4 + 0x0c 0019a058: 3c0300c0 lui r3,0x00c0 | 0019a05c: 00431024 and r2,r2,r3 |Check [Longbow] and [Stop at Obstacle] 0019a060: 14400035 bne r2,r0,0x0019a138 #If Ability is not Arcing nor a direct attack /Else branc to next loop iteration 0019a064: 00000000 nop | 0019a068: 9262000e lbu r2,0x000e(r19) |Load Ability's AI Flags 3 0019a06c: 00000000 nop | 0019a070: 3042003c andi r2,r2,0x003c |Check [Linear Attack] , [Non Spear], [3 direction melee], [3 Direction ranged] Non spear is a reverted flag (0x1 if unchecked) 0019a074: 10400004 beq r2,r0,0x0019a088 #If Ability is a Linear Attack, a spear attack or a 3 directional Attack 0019a078: 00000000 nop | 0019a07c: 96020002 lhu r2,0x0002(r16) |Load Ability's Skillset/Usage Type? From Move List 0x8019f3c4 + 0x0ef0 0019a080: 0806684d j 0x0019a134 >>Jump to next iteration (will store new usage byte) 0019a084: 34420400 ori r2,r2,0x0400 |Enable 0x04 (Use Weapon range - Evadable flag ?) #Ability is not a Linear attack, a spear attack nor a 3 directionnal attack 0019a088: 86640002 lh r4,0x0002(r19) |Load Ability ID From 0x80193fc4 0019a08c: 00000000 nop | 0019a090: 28820170 slti r2,r4,0x0170 |Check if Ability has a second data table 0019a094: 10400020 beq r2,r0,0x0019a118 #If Ability has a second data table 0019a098: 00000000 nop | 0019a09c: 92620004 lbu r2,0x0004(r19) |Load Ability's Range From 0x80193fc4 0019a0a0: 92630005 lbu r3,0x0005(r19) |Load Ability's AoE From 0x80193fc4 0019a0a4: 00000000 nop | 0019a0a8: 00431021 addu r2,r2,r3 |Max Range = Range + AoE 0019a0ac: 28420003 slti r2,r2,0x0003 |Check if max range is < 0x3 0019a0b0: 1040000d beq r2,r0,0x0019a0e8 #If Max range < 3 0019a0b4: 000410c0 sll r2,r4,0x03 |Ability ID * 8 0019a0b8: 00441023 subu r2,r2,r4 |ID * 7 0019a0bc: 00021040 sll r2,r2,0x01 |ID * 14 (Ability offset) 0019a0c0: 3c018006 lui r1,0x8006 | 0019a0c4: 00220821 addu r1,r1,r2 |Part of pointer to Ability data 2 0019a0c8: 9022fbf6 lbu r2,-0x040a(r1) |Load Ability's Flags 4 SCUS - 0x8005fbf0 + 0x06 + Ability offset 0019a0cc: 00000000 nop | 0019a0d0: 30420002 andi r2,r2,0x0002 |Check [Evadable] 0019a0d4: 10400004 beq r2,r0,0x0019a0e8 #If Ability is evadable 0019a0d8: 00000000 nop | 0019a0dc: 96020002 lhu r2,0x0002(r16) |Load Ability's Skillset/Usage Type? 0019a0e0: 0806684d j 0x0019a134 >>Jump to next iteration (will store new usage byte) 0019a0e4: 34420400 ori r2,r2,0x0400 |Enable 0x04 (Use Weapon range - Evadable flag ?) #Else : Range > 2 or Ability not Evadable 0019a0e8: 86620002 lh r2,0x0002(r19) |Load Ability ID 0019a0ec: 00000000 nop | 0019a0f0: 000218c0 sll r3,r2,0x03 |ID * 8 0019a0f4: 00621823 subu r3,r3,r2 |ID * 7 0019a0f8: 00031840 sll r3,r3,0x01 |ID * 14 (Ability offset) 0019a0fc: 3c018006 lui r1,0x8006 | 0019a100: 00230821 addu r1,r1,r3 |Par of pointer to Ability data 2 SCUS - 0x8005fbf0 + 0x04 + Ability offset 0019a104: 9022fbf4 lbu r2,-0x040c(r1) |Load Ability's Flags 2 0019a108: 00000000 nop | 0019a10c: 30420041 andi r2,r2,0x0041 |Check [Hit Ally] and [Hit Caster] Two reverted flags (0 if can hit) 0019a110: 14400005 bne r2,r0,0x0019a128 #If Ability can hit Caster team 0019a114: 00000000 nop | 0019a118: 92620005 lbu r2,0x0005(r19) #E |Load AoE From 0x80193fc4 0019a11c: 00000000 nop | 0019a120: 14400005 bne r2,r0,0x0019a138 #If AoE = 0 (Can Hit Allies but no AoE = no risk of collateral damage ?) 0019a124: 00000000 nop | 0019a128: 96020002 lhu r2,0x0002(r16) #E |Load Skillset/Usage Type? 0019a12c: 00000000 nop | 0019a130: 34420200 ori r2,r2,0x0200 |Enable 0x02 0019a134: a6020002 sh r2,0x0002(r16) #E #E |Store new Skillset/Usage Type? 0019a138: 26520001 addiu r18,r18,0x0001 |LOOP counter + 1 0019a13c: 2a420022 slti r2,r18,0x0022 |Check counter vs limit 0019a140: 1440ff8b bne r2,r0,0x00199f70 Λ LOOP Branch if Counter < 34 0019a144: 02751021 addu r2,r19,r21 |r2 = AI Data Pointer + unit offset (load Battle ID at 0x198c when the loop starts) 0019a148: 02802021 addu r4,r20,r0 |Divisor = Number of Abilities 0019a14c: 0c0668b3 jal 0x0019a2cc |-->Dividend * 4 / Divisor Returns r2 = r5*4/r4 0019a150: 02e02821 addu r5,r23,r0 |Dividend = Nb Of Ability affected by silence 0019a154: 02802021 addu r4,r20,r0 |Divisor = Number of Abilities 0019a158: 03c02821 addu r5,r30,r0 |Dividend = Nb Of Ability with a MP cost 0019a15c: 0c0668b3 jal 0x0019a2cc |-->Dividend * 4 / Divisor 0019a160: a222000c sb r2,0x000c(r17) |Store Silence effectivness Mod 0019a164: 8fa50010 lw r5,0x0010(r29) |Dividend - load Evadable Abilities 0019a168: 02802021 addu r4,r20,r0 |Divisor = Number of Abilities 0019a16c: 0c0668b3 jal 0x0019a2cc |-->Dividend * 4 / Divisor 0019a170: a222000b sb r2,0x000b(r17) |Store MP Using Mod 0019a174: 26240004 addiu r4,r17,0x0004 |AI decision + 0x04 (ENTD - settings) 0019a178: 26c50167 addiu r5,r22,0x0167 |r5 = Pointer to Unit's ENTD AI setting 0x801908cc + 0x167 0019a17c: 34060005 ori r6,r0,0x0005 |Limit = 5 0019a180: 0c066ad2 jal 0x0019ab48 |-->Transfer Byte Values Transfer Bytes from 0x167 to 16b to AI decision 0x04 to 0x8 0019a184: a222000d sb r2,0x000d(r17) |Store Evade Mod 0019a188: 92c20165 lbu r2,0x0165(r22) |Load AI X Location 0019a18c: 92230004 lbu r3,0x0004(r17) |Load AI Setting - Behavior 0019a190: a2220000 sb r2,0x0000(r17) |Store X Location to stay near 0019a194: 92c20166 lbu r2,0x0166(r22) |Load AI Y Location 0019a198: 00000000 nop | 0019a19c: a2220002 sb r2,0x0002(r17) |Store Y Location to stay near 0019a1a0: 92c20167 lbu r2,0x0167(r22) |Load Unit 0x167 (elevation + behavior) 0019a1a4: a2200003 sb r0,0x0003(r17) |Nullify/Initialize AI decision 0x03 0019a1a8: 000211c2 srl r2,r2,0x07 |0x80 (if Higher Elevation) 0019a1ac: a2220001 sb r2,0x0001(r17) |Store Higher Elevation Flag 0019a1b0: 30620008 andi r2,r3,0x0008 |Check [Defensive] Defensive in Patcher - Coward-like in Wiki 0019a1b4: 10400038 beq r2,r0,0x0019a298 #If Unit Setting is Defensive /Else branch to END 0019a1b8: 00000000 nop | 0019a1bc: 92220007 lbu r2,0x0007(r17) |Load AI Targeting flag (Copied from Unit battle 0x16a) 0019a1c0: 00000000 nop | 0019a1c4: 30420004 andi r2,r2,0x0004 |Check [Save-CT Protect Self] 0019a1c8: 10400007 beq r2,r0,0x0019a1e8 #If Unit setting is Conserve CT 0019a1cc: 34020011 ori r2,r0,0x0011 |r2 = 0x11 0019a1d0: 02751821 addu r3,r19,r21 |r2 = AI Data Pointer + unit offset 0019a1d4: 080668a6 j 0x0019a298 >>Jump to END 0019a1d8: a06219a1 sb r2,0x19a1(r3) |Store 0x11 at 0x8019f34c4 + 0x19a1 + Unit offset (1 byte per unit) Backward branch section - Focus On Enemy - Aggressive 0019a1dc: 3402000c ori r2,r0,0x000c |r2 = 0x0c 0019a1e0: 080668a6 j 0x0019a298 >>Jump to END 0019a1e4: a06219a1 sb r2,0x19a1(r3) |Store 0x0c at 0x8019f34c4 + 0x19a1 + Unit offset (1 byte per unit) #Else - Unit will not preserve CT 0019a1e8: 30620040 andi r2,r3,0x0040 |check [Focus Unit] 0019a1ec: 1040002a beq r2,r0,0x0019a298 #If Unit Setting is Focus Unit /Else branch to END 0019a1f0: 00009021 addu r18,r0,r0 |Counter = 0 0019a1f4: 340600ff ori r6,r0,0x00ff |r6 = 0xff 0019a1f8: 02752821 addu r5,r19,r21 |r5 = AI Pointer + Unit's ID 0019a1fc: 3407000e ori r7,r0,0x000e |r7 = 0x0e 0019a200: 00002021 addu r4,r0,r0 |Unit Offset (+0x01c0 each iteration) 0019a204: 3c018019 lui r1,0x8019 @LOOP through all units Looking for Unit AI target 0019a208: 00240821 addu r1,r1,r4 |Part of pointer to unit battle stats 0019a20c: 902208cd lbu r2,0x08cd(r1) |Load Unit's ID 0x801908cc + 0x01 + unit offset 0019a210: 00000000 nop | 0019a214: 10460018 beq r2,r6,0x0019a278 #If Unit exists (<> 0xff) 0019a218: 00000000 nop | 0019a21c: 3c018019 lui r1,0x8019 | 0019a220: 00240821 addu r1,r1,r4 |Part of pointer to unit battle stats 0019a224: 90230a2d lbu r3,0x0a2d(r1) |Load this iteration Unit's ENTD ID 0019a228: 92220005 lbu r2,0x0005(r17) |Load Acting Unit Main Target ID 0019a22c: 00000000 nop | 0019a230: 14620011 bne r3,r2,0x0019a278 #If This iteration unit is the Targeted Unit 0019a234: 00000000 nop | 0019a238: 92220004 lbu r2,0x0004(r17) |Load AI Behavior Copied from Unit 0x167 0019a23c: 00000000 nop | 0019a240: 30420010 andi r2,r2,0x0010 |Check [Aggressive] 0019a244: 10400014 beq r2,r0,0x0019a298 #If Unit AI setting is Aggressive /Else Branch to END 0019a248: a2320005 sb r18,0x0005(r17) |Store Unit as Main target It should be already the case no ? 0019a24c: a2d201b9 sb r18,0x01b9(r22) |Store Main Target ID in acting unit data (0x1b9) 0019a250: 3c018019 lui r1,0x8019 | 0019a254: 00240821 addu r1,r1,r4 |Part of pointer to unit battle stats 0019a258: 90230a86 lbu r3,0x0a86(r1) |LoadThis iteration Unit's Modified ENTD Flags 0019a25c: 92c201ba lbu r2,0x01ba(r22) |Load Unit's Modified ENTD Flags 0019a260: 30630030 andi r3,r3,0x0030 |Check this iteration unit Team 0019a264: 30420030 andi r2,r2,0x0030 |Check Acting unit Team 0019a268: 1462ffdc bne r3,r2,0x0019a1dc #Acting Unit and Main Target are in the same Team 0019a26c: 02751821 addu r3,r19,r21 |r3 = AI Pointer + Unit ID 0019a270: 080668a6 j 0x0019a298 >>Jump to END 0019a274: a0a719a1 sb r7,0x19a1(r5) |Store 0x0e at 0x8019f34c4 + 0x19a1 + Unit offset (1 byte per unit) 0019a278: 26520001 addiu r18,r18,0x0001 |Unit ID + 1 0019a27c: 2a420015 slti r2,r18,0x0015 |Check Unit ID vs Loop limit 0019a280: 1440ffe0 bne r2,r0,0x0019a204 #Branch if Counter < 21 0019a284: 248401c0 addiu r4,r4,0x01c0 |Unit Data Offset (+0x01c0 each iteration) The code ends here if : Unit has [Focus Unit] setting but no valid target 0019a288: 92220004 lbu r2,0x0004(r17) |Load AI Behavior 0019a28c: 00000000 nop | 0019a290: 304200f7 andi r2,r2,0x00f7 |Disable [0x08] if No Target No peculiar behavior 0019a294: a2220004 sb r2,0x0004(r17) |Store updated data 0019a298: 8fbf003c lw r31,0x003c(r29) END 0019a29c: 8fbe0038 lw r30,0x0038(r29) 0019a2a0: 8fb70034 lw r23,0x0034(r29) 0019a2a4: 8fb60030 lw r22,0x0030(r29) 0019a2a8: 8fb5002c lw r21,0x002c(r29) 0019a2ac: 8fb40028 lw r20,0x0028(r29) 0019a2b0: 8fb30024 lw r19,0x0024(r29) 0019a2b4: 8fb20020 lw r18,0x0020(r29) 0019a2b8: 8fb1001c lw r17,0x001c(r29) 0019a2bc: 8fb00018 lw r16,0x0018(r29) 0019a2c0: 27bd0040 addiu r29,r29,0x0040 0019a2c4: 03e00008 jr r31 0019a2c8: 00000000 nop
Notes
Return locations
Battle.bin 00068f3c: Special_Status_Flag_Enabling - Remove Frog 00069040: Special_Status_Flag_Enabling - Inflict Frog 000751a8: Decide_what_to_do_based_on_skillset/ability_selections? 00075514: Set_move/act_based_on_skillset - Equip change 0008355c: Poach/Morbol_Transformation 00083bf8: Set_targets_animation_based_on_attack_type - Broken item 00083c20: Set_targets_animation_based_on_attack_type - Stolen item