AI Critical or Run Like Rabbit

From Final Fantasy Hacktics Wiki
Revision as of 13:19, 10 June 2017 by Dokurider (talk | contribs) (Added Title and Notes)
Jump to navigation Jump to search

Critical AI Routine

00198e60: 3c02801a lui r2,0x801a
00198e64: 90420d7b lbu r2,0x0d7b(r2)			load usage type
00198e68: 27bdffd8 addiu r29,r29,0xffd8
00198e6c: afb20018 sw r18,0x0018(r29)
00198e70: 3c12801a lui r18,0x801a
00198e74: 2652f3c4 addiu r18,r18,0xf3c4
00198e78: afbf0024 sw r31,0x0024(r29)
00198e7c: afb40020 sw r20,0x0020(r29)
00198e80: afb3001c sw r19,0x001c(r29)
00198e84: afb10014 sw r17,0x0014(r29)
00198e88: 10400011 beq r2,r0,0x00198ed0		branch if none set
00198e8c: afb00010 sw r16,0x0010(r29)
00198e90: 3c03801a lui r3,0x801a
00198e94: 8c63f390 lw r3,-0x0c70(r3)
00198e98: 34020001 ori r2,r0,0x0001
00198e9c: 10620020 beq r3,r2,0x00198f20
00198ea0: 28620002 slti r2,r3,0x0002
00198ea4: 10400005 beq r2,r0,0x00198ebc
00198ea8: 00000000 nop
00198eac: 1060000c beq r3,r0,0x00198ee0
00198eb0: 00000000 nop
00198eb4: 080663fe j 0x00198ff8
00198eb8: 00000000 nop

00198ebc: 34020002 ori r2,r0,0x0002
00198ec0: 10620020 beq r3,r2,0x00198f44
00198ec4: 00000000 nop
00198ec8: 080663fe j 0x00198ff8
00198ecc: 00000000 nop
none set
00198ed0: 0c066449 jal 0x00199124			Calculate Physical? Target
00198ed4: 34040005 ori r4,r0,0x0005                    Find shortest distance to ally with HP recovery
00198ed8: 0c065243 jal 0x0019490c			Store main target ID and focus on target flag
00198edc: 00402021 addu r4,r2,r0
00198ee0: 0c066417 jal 0x0019905c			0019905c - 00199120
00198ee4: 00000000 nop
00198ee8: 2403ffff addiu r3,r0,0xffff
00198eec: 14430005 bne r2,r3,0x00198f04
00198ef0: 34020001 ori r2,r0,0x0001
00198ef4: 3c01801a lui r1,0x801a
00198ef8: ac20f390 sw r0,-0x0c70(r1)
00198efc: 0806640e j 0x00199038			jump to end, return 0xffff
00198f00: 2402ffff addiu r2,r0,0xffff

00198f04: 0c0658c3 jal 0x0019630c			0019630c - 00196388
00198f08: a2420e2d sb r2,0x0e2d(r18)
00198f0c: 92450e2e lbu r5,0x0e2e(r18)
00198f10: 0c065f43 jal 0x00197d0c			Find which units are active?
00198f14: 34040003 ori r4,r0,0x0003
00198f18: 10400006 beq r2,r0,0x00198f34
00198f1c: 00000000 nop
00198f20: 0c065f98 jal 0x00197e60			Chose Move from Move List?
00198f24: 00000000 nop
00198f28: 2403ffff addiu r3,r0,0xffff
00198f2c: 10430037 beq r2,r3,0x0019900c
00198f30: 34020001 ori r2,r0,0x0001
00198f34: 0c065c2f jal 0x001970bc			001970bc - 001971b4
00198f38: 00000000 nop
00198f3c: 1440003e bne r2,r0,0x00199038
00198f40: 00001021 addu r2,r0,r0
00198f44: 0c0657e3 jal 0x00195f8c			set current ability CT/status change
00198f48: 00000000 nop
00198f4c: 00401821 addu r3,r2,r0
00198f50: 2402ffff addiu r2,r0,0xffff
00198f54: 1062002d beq r3,r2,0x0019900c
00198f58: 34020002 ori r2,r0,0x0002
00198f5c: 34020001 ori r2,r0,0x0001
00198f60: 10620035 beq r3,r2,0x00199038
00198f64: 00001021 addu r2,r0,r0
00198f68: 00008821 addu r17,r0,r0
00198f6c: 341400ff ori r20,r0,0x00ff
00198f70: 3413000a ori r19,r0,0x000a
<loop> Set Charge abilities unusable?
00198f74: 92430e2f lbu r3,0x0e2f(r18)			load unit ID
00198f78: 00000000 nop
00198f7c: 00031100 sll r2,r3,0x04
00198f80: 00431021 addu r2,r2,r3
00198f84: 000210c0 sll r2,r2,0x03
00198f88: 24420ef0 addiu r2,r2,0x0ef0
00198f8c: 02421021 addu r2,r18,r2			AI data + ID pointer
00198f90: 00111880 sll r3,r17,0x02			counter*4
00198f94: 00438021 addu r16,r2,r3			r16 = units move list
00198f98: 92020002 lbu r2,0x0002(r16)			load skillset	
00198f9c: 00000000 nop
00198fa0: 10540011 beq r2,r20,0x00198fe8		branch if 0xff
00198fa4: 00002021 addu r4,r0,r0
00198fa8: 0c06561e jal 0x00195878			AI Ability Data Setting
00198fac: 02002021 addu r4,r16,r0
00198fb0: 92020002 lbu r2,0x0002(r16)			load skillset
00198fb4: 3c018006 lui r1,0x8006
00198fb8: 00220821 addu r1,r1,r2
00198fbc: 90225cb4 lbu r2,0x5cb4(r1)			load action menu byte
00198fc0: 00000000 nop
00198fc4: 14530005 bne r2,r19,0x00198fdc		branch if not charge?
00198fc8: 26310001 addiu r17,r17,0x0001
00198fcc: 96020002 lhu r2,0x0002(r16)			load skillset/usage type
00198fd0: 00000000 nop
00198fd4: 30427fff andi r2,r2,0x7fff			remove usable
00198fd8: a6020002 sh r2,0x0002(r16)			store new

00198fdc: 2a220022 slti r2,r17,0x0022
00198fe0: 1440ffe4 bne r2,r0,0x00198f74		do for all abilities
00198fe4: 00002021 addu r4,r0,r0

00198fe8: 0c065f43 jal 0x00197d0c			Find which units are active?
00198fec: 340500ff ori r5,r0,0x00ff
00198ff0: 1040000e beq r2,r0,0x0019902c
00198ff4: 00000000 nop
00198ff8: 0c065f98 jal 0x00197e60			Chose Move from Move List?
00198ffc: 00000000 nop
00199000: 2403ffff addiu r3,r0,0xffff
00199004: 14430005 bne r2,r3,0x0019901c
00199008: 34020003 ori r2,r0,0x0003
0019900c: 3c01801a lui r1,0x801a
00199010: ac22f390 sw r2,-0x0c70(r1)
00199014: 0806640e j 0x00199038
00199018: 2402ffff addiu r2,r0,0xffff

0019901c: 0c065c2f jal 0x001970bc			001970bc - 001971b4
00199020: 00000000 nop
00199024: 14400004 bne r2,r0,0x00199038
00199028: 00001021 addu r2,r0,r0
0019902c: 0c066526 jal 0x00199498			00199498 - 001994f4
00199030: 00000000 nop
00199034: 00001021 addu r2,r0,r0

00199038: 8fbf0024 lw r31,0x0024(r29)
0019903c: 8fb40020 lw r20,0x0020(r29)
00199040: 8fb3001c lw r19,0x001c(r29)
00199044: 8fb20018 lw r18,0x0018(r29)
00199048: 8fb10014 lw r17,0x0014(r29)
0019904c: 8fb00010 lw r16,0x0010(r29)
00199050: 27bd0028 addiu r29,r29,0x0028
00199054: 03e00008 jr r31
00199058: 00000000 nop

Notes:

This is the only autobattle routine that does not use the Ability Conditional Usage Routine, meaning it has no restrictions on what abilities it will use. 
This is why the AI will spam Accumulate and other rare usage abilities when in critical. It also means that the Critical AI cannot be normally prevented from using
whatever abilities on itself without modification.

The AI is prevented from using the Charge skillset while in Critical, probably because Critical's fleeing behavior would constantly break Charge. 

The unmodified AI will always prioritize running away from the enemy over moving closer to an allied healing target. Otherwise, it will make a genuine attempt to get
closer to healing allies.