Usable Ability Setting/ENTD AI Calculations

From Final Fantasy Hacktics Wiki
Revision as of 09:04, 2 April 2023 by Orkney (talk | contribs) (Return locations)
Jump to navigation Jump to search
Usable Ability Setting/ENTD AI Calculations
00199ec8: 27bdffc0 addiu r29,r29,0xffc0
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?
00199ee0: 001510c0 sll r2,r21,0x03		ID * 8
00199ee4: 00551023 subu r2,r2,r21		ID * 7
00199ee8: 00021180 sll r2,r2,0x06		ID * 1c0
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,0x 0019a298		Branch if unit doesn't exist
00199f24: 02b31021 addu r2,r21,r19		AI Pointer? + Unit's ID
00199f28: 9042198c lbu r2,0x198c(r2)		Load Unit's Battle ID?
00199f2c: 00000000 nop
00199f30: 2c420010 sltiu r2,r2,0x0010
00199f34: 104000d8 beq r2,r0,0x 0019a298		Branch if ID is out of range
00199f38: 00000000 nop
00199f3c: 0c0668bc jal 0x 0019a2f0		Set AI Flags/Usable Abilities
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
00199f54: 2442182c addiu r2,r2,0x182c
00199f58: 00538821 addu r17,r2,r19
00199f5c: 340200ff ori r2,r0,0x00ff		r2 = FF
00199f60: afa00010 sw r0,0x0010(r29)		Store Evadeable Abilities = 0
00199f64: a2200009 sb r0,0x0009(r17)		Store Highest MP Cost = 0
00199f68: a222000a sb r2,0x000a(r17)		Store Lowest MP Cost = FF
00199f6c: 02751021 addu r2,r19,r21
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 * 136
00199f84: 24420ef0 addiu r2,r2,0x0ef0
00199f88: 02621021 addu r2,r19,r2
00199f8c: 00121880 sll r3,r18,0x02		Counter * 4
00199f90: 00438021 addu r16,r2,r3
00199f94: 92030002 lbu r3,0x0002(r16)		Load Ability's Skillset
00199f98: 340200ff ori r2,r0,0x00ff		r2 = FF
00199f9c: 1062006b beq r3,r2,0x 0019a14c		Branch if at end of skill list
00199fa0: 02802021 addu r4,r20,r0		r4 = Number of Abilities
00199fa4: 0c06561e jal 0x 00195878		AI Ability Data Setting
00199fa8: 02002021 addu r4,r16,r0		r4 = Usable Move List
00199fac: 96020002 lhu r2,0x0002(r16)		Load Ability's Skillset/Usage Type?
00199fb0: 00000000 nop
00199fb4: 30420800 andi r2,r2,0x0800
00199fb8: 14400022 bne r2,r0,0x 0019a044		Branch if Monster Skill is needed
00199fbc: 26940001 addiu r20,r20,0x0001		Number of Abilities ++
00199fc0: 8e63000c lw r3,0x000c(r19)		Load AI Behavior Flags
00199fc4: 00000000 nop
00199fc8: 30620100 andi r2,r3,0x0100
00199fcc: 10400002 beq r2,r0,0x 00199fd8		Branch if Ability doesn't check Silence
00199fd0: 30620200 andi r2,r3,0x0200
00199fd4: 26f70001 addiu r23,r23,0x0001		Silence Blocking Abilities ++
00199fd8: 10400005 beq r2,r0,0x 00199ff0		Branch if Ability doesn't have Evadeable
00199fdc: 00000000 nop
00199fe0: 8fa80010 lw r8,0x0010(r29)		Load Evadeable Abilities
00199fe4: 00000000 nop
00199fe8: 25080001 addiu r8,r8,0x0001		Evadeable Abilities ++
00199fec: afa80010 sw r8,0x0010(r29)		Store new Evadeable Abilities
00199ff0: 92630011 lbu r3,0x0011(r19)		Load Ability's MP Cost
00199ff4: 00000000 nop
00199ff8: 10600012 beq r3,r0,0x 0019a044		Branch if MP Cost = 0
00199ffc: 00000000 nop
0019a000: 92220009 lbu r2,0x0009(r17)		Load Highest MP Cost
0019a004: 00000000 nop
0019a008: 0043102b sltu r2,r2,r3
0019a00c: 10400004 beq r2,r0,0x 0019a020		Branch if Highest MP Cost >= MP Cost
0019a010: 27de0001 addiu r30,r30,0x0001		MP Using Abilities ++
0019a014: 92620011 lbu r2,0x0011(r19)		Load Ability's MP Cost
0019a018: 00000000 nop
0019a01c: a2220009 sb r2,0x0009(r17)		Store Highest MP Cost = MP Cost
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
0019a030: 10400004 beq r2,r0,0x 0019a044		Branch if MP Cost >= 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 Lowest MP Cost = MP Cost
0019a044: 92020003 lbu r2,0x0003(r16)		Load Usage Type?
0019a048: 00000000 nop
0019a04c: 304200f8 andi r2,r2,0x00f8		Disable 0x07
0019a050: a2020003 sb r2,0x0003(r16)		store new Usage type?
0019a054: 8e62000c lw r2,0x000c(r19)		Load Ability's AI Flags
0019a058: 3c0300c0 lui r3,0x00c0
0019a05c: 00431024 and r2,r2,r3
0019a060: 14400035 bne r2,r0,0x 0019a138		Branch if Ability is Arc?/Direct Attack
0019a064: 00000000 nop
0019a068: 9262000e lbu r2,0x000e(r19)		Load Ability's AI Flags 3
0019a06c: 00000000 nop
0019a070: 3042003c andi r2,r2,0x003c
0019a074: 10400004 beq r2,r0,0x 0019a088		Branch if not Linear/Vertical/Triple A/B
0019a078: 00000000 nop
0019a07c: 96020002 lhu r2,0x0002(r16)		Load Ability's Skillset/Usage Type?
0019a080: 0806684d j 0x 0019a134
0019a084: 34420400 ori r2,r2,0x0400		Enable 0x04
0019a088: 86640002 lh r4,0x0002(r19)		Load Ability ID
0019a08c: 00000000 nop
0019a090: 28820170 slti r2,r4,0x0170
0019a094: 10400020 beq r2,r0,0x 0019a118		Branch if it's not a normal Ability?
0019a098: 00000000 nop
0019a09c: 92620004 lbu r2,0x0004(r19)		Load Ability's Range
0019a0a0: 92630005 lbu r3,0x0005(r19)		Load Ability's AoE
0019a0a4: 00000000 nop
0019a0a8: 00431021 addu r2,r2,r3		Max Range = Range + AoE
0019a0ac: 28420003 slti r2,r2,0x0003
0019a0b0: 1040000d beq r2,r0,0x 0019a0e8		Branch 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
0019a0c0: 3c018006 lui r1,0x8006
0019a0c4: 00220821 addu r1,r1,r2
0019a0c8: 9022fbf6 lbu r2,-0x040a(r1)		Load Ability's Flags 4
0019a0cc: 00000000 nop
0019a0d0: 30420002 andi r2,r2,0x0002
0019a0d4: 10400004 beq r2,r0,0x 0019a0e8		Branch if not evadeable
0019a0d8: 00000000 nop
0019a0dc: 96020002 lhu r2,0x0002(r16)		Load Ability's Skillset/Usage Type?
0019a0e0: 0806684d j 0x 0019a134
0019a0e4: 34420400 ori r2,r2,0x0400		Enable 0x04
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
0019a0fc: 3c018006 lui r1,0x8006
0019a100: 00230821 addu r1,r1,r3
0019a104: 9022fbf4 lbu r2,-0x040c(r1)		Load Ability's Flags 2
0019a108: 00000000 nop
0019a10c: 30420041 andi r2,r2,0x0041
0019a110: 14400005 bne r2,r0,0x 0019a128		Branch if Can't Hit Allies/Self
0019a114: 00000000 nop
0019a118: 92620005 lbu r2,0x0005(r19)		Load AoE
0019a11c: 00000000 nop
0019a120: 14400005 bne r2,r0,0x 0019a138		Branch if AoE != 0
0019a124: 00000000 nop
0019a128: 96020002 lhu r2,0x0002(r16)		Load Skillset/Usage Type?
0019a12c: 00000000 nop
0019a130: 34420200 ori r2,r2,0x0200		Enable 0x02
0019a134: a6020002 sh r2,0x0002(r16)		Store new Skillset/Usage Type?
0019a138: 26520001 addiu r18,r18,0x0001		Counter ++
0019a13c: 2a420022 slti r2,r18,0x0022
0019a140: 1440ff8b bne r2,r0,0x 00199f70		Branch if Counter < 34
0019a144: 02751021 addu r2,r19,r21		r2 = AI Data Pointer? + Unit's ID
0019a148: 02802021 addu r4,r20,r0		Divisor = Number of Abilities
0019a14c: 0c0668b3 jal 0x 0019a2cc		Dividend * 4 / Divisor
0019a150: 02e02821 addu r5,r23,r0		Dividend = Silence Ignoring Abilities
0019a154: 02802021 addu r4,r20,r0		Divisor = Number of Abilities
0019a158: 03c02821 addu r5,r30,r0		Dividend = MP Using Abilities
0019a15c: 0c0668b3 jal 0x 0019a2cc		Dividend * 4 / Divisor
0019a160: a222000c sb r2,0x000c(r17)		Store MP Silence Blocking Mod
0019a164: 8fa50010 lw r5,0x0010(r29)		Load Evade ignoring Abilities
0019a168: 02802021 addu r4,r20,r0		Divisor = Number of Abilities
0019a16c: 0c0668b3 jal 0x 0019a2cc		Dividend * 4 / Divisor
0019a170: a222000b sb r2,0x000b(r17)		Store MP Using Mod
0019a174: 26240004 addiu r4,r17,0x0004		r4 = ? Pointer + 4
0019a178: 26c50167 addiu r5,r22,0x0167		r5 = Pointer to Unit's ENTD AI Data?
0019a17c: 34060005 ori r6,r0,0x0005		Limit = 5
0019a180: 0c066ad2 jal 0x 0019ab48		Transfer Byte Values
0019a184: a222000d sb r2,0x000d(r17)		Store Evade Ignoring Mod
0019a188: 92c20165 lbu r2,0x0165(r22)		Load X Location?
0019a18c: 92230004 lbu r3,0x0004(r17)		Load AI Behavior
0019a190: a2220000 sb r2,0x0000(r17)		Store X Location to stay near
0019a194: 92c20166 lbu r2,0x0166(r22)		Load Y Location?
0019a198: 00000000 nop
0019a19c: a2220002 sb r2,0x0002(r17)		Store Y Location to stay near
0019a1a0: 92c20167 lbu r2,0x0167(r22)		Load map level byte
0019a1a4: a2200003 sb r0,0x0003(r17)		Store ? = 0
0019a1a8: 000211c2 srl r2,r2,0x07		0x80 (Higher Elevation Flag)
0019a1ac: a2220001 sb r2,0x0001(r17)		Store Higher Elevation Flag
0019a1b0: 30620008 andi r2,r3,0x0008
0019a1b4: 10400038 beq r2,r0,0x 0019a298		Branch if not using coward AI?
0019a1b8: 00000000 nop
0019a1bc: 92220007 lbu r2,0x0007(r17)		Load ?
0019a1c0: 00000000 nop
0019a1c4: 30420004 andi r2,r2,0x0004
0019a1c8: 10400007 beq r2,r0,0x 0019a1e8		Branch if save CT/protect self
0019a1cc: 34020011 ori r2,r0,0x0011		r2 = 0x11
0019a1d0: 02751821 addu r3,r19,r21
0019a1d4: 080668a6 j 0x 0019a298
0019a1d8: a06219a1 sb r2,0x19a1(r3)		Store ? = 0x11
0019a1dc: 3402000c ori r2,r0,0x000c		r2 = 0x0c
0019a1e0: 080668a6 j 0x 0019a298
0019a1e4: a06219a1 sb r2,0x19a1(r3)		Store ? = 0x0c
0019a1e8: 30620040 andi r2,r3,0x0040
0019a1ec: 1040002a beq r2,r0,0x 0019a298		Branch if not dead? unit with reraise
0019a1f0: 00009021 addu r18,r0,r0		Counter = 0
0019a1f4: 340600ff ori r6,r0,0x00ff		r6 = FF
0019a1f8: 02752821 addu r5,r19,r21		r5 = AI Pointer + Unit's ID
0019a1fc: 3407000e ori r7,r0,0x000e		r7 = e
0019a200: 00002021 addu r4,r0,r0		unit Counter
0019a204: 3c018019 lui r1,0x8019
0019a208: 00240821 addu r1,r1,r4
0019a20c: 902208cd lbu r2,0x08cd(r1)		Load Unit's ID
0019a210: 00000000 nop
0019a214: 10460018 beq r2,r6,0x 0019a278		Branch if Unit doesn't exist
0019a218: 00000000 nop
0019a21c: 3c018019 lui r1,0x8019
0019a220: 00240821 addu r1,r1,r4
0019a224: 90230a2d lbu r3,0x0a2d(r1)		Load Considered Unit's ENTD ID
0019a228: 92220005 lbu r2,0x0005(r17)		Load Actors Main Target ID
0019a22c: 00000000 nop
0019a230: 14620011 bne r3,r2,0x 0019a278		Branch to next unit if Unit != Main Target
0019a234: 00000000 nop
0019a238: 92220004 lbu r2,0x0004(r17)		Load AI behavior
0019a23c: 00000000 nop
0019a240: 30420010 andi r2,r2,0x0010
0019a244: 10400014 beq r2,r0,0x 0019a298		Branch if AI isn't more aggressive?
0019a248: a2320005 sb r18,0x0005(r17)		Store Unit as Main target
0019a24c: a2d201b9 sb r18,0x01b9(r22)		Store Main Target ID in unit data
0019a250: 3c018019 lui r1,0x8019
0019a254: 00240821 addu r1,r1,r4
0019a258: 90230a86 lbu r3,0x0a86(r1)		Load Target's Modified ENTD Flags
0019a25c: 92c201ba lbu r2,0x01ba(r22)		Load Unit's Modified ENTD Flags
0019a260: 30630030 andi r3,r3,0x0030
0019a264: 30420030 andi r2,r2,0x0030
0019a268: 1462ffdc bne r3,r2,0x 0019a1dc		Branch if Teams Differ
0019a26c: 02751821 addu r3,r19,r21		r3 = AI Pointer + Unit ID
0019a270: 080668a6 j 0x 0019a298
0019a274: a0a719a1 sb r7,0x19a1(r5)		Store ? = 0xe
0019a278: 26520001 addiu r18,r18,0x0001		Counter ++
0019a27c: 2a420015 slti r2,r18,0x0015
0019a280: 1440ffe0 bne r2,r0,0x 0019a204		Branch if Counter < 21
0019a284: 248401c0 addiu r4,r4,0x01c0		Pointer Mod += 1c0
0019a288: 92220004 lbu r2,0x0004(r17)		Load AI Behavior
0019a28c: 00000000 nop
0019a290: 304200f7 andi r2,r2,0x00f7		Disable Coward-like if more aggressive
0019a294: a2220004 sb r2,0x0004(r17)		Store
0019a298: 8fbf003c lw r31,0x003c(r29)
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

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