Fight for Life - Auto Battle (00197ff4)

From Final Fantasy Hacktics Wiki
(Redirected from 00197ff4 - 001982d4)
Jump to navigation Jump to search
*Note: 0x0032 and 0x0c6e are the same byte
00197ff4: 3c02801a lui r2,0x801a
00197ff8: 8c420bbc lw r2,0x0bbc(r2)				load acting unit data
00197ffc: 27bdffe0 addiu r29,r29,0xffe0
00198000: afbf0018 sw r31,0x0018(r29)
00198004: afb10014 sw r17,0x0014(r29)
00198008: afb00010 sw r16,0x0010(r29)
0019800c: 905001b9 lbu r16,0x01b9(r2)			Load Main Target ID
00198010: 3c02801a lui r2,0x801a
00198014: 90420d7b lbu r2,0x0d7b(r2)			load skillset/usage byte
00198018: 3c11801a lui r17,0x801a
0019801c: 2631f3c4 addiu r17,r17,0xf3c4			r17 = AI data
00198020: 10400013 beq r2,r0,0x00198070			branch if byte = 0
00198024: 34020001 ori r2,r0,0x0001
00198028: 3c03801a lui r3,0x801a
0019802c: 90630032 lbu r3,0x0032(r3)			Load Decision Byte
00198030: 00000000 nop
00198034: 1062006a beq r3,r2,0x001981e0			branch if byte = 01
00198038: 28620002 slti r2,r3,0x0002
0019803c: 10400005 beq r2,r0,0x00198054			branch if byte > 02
00198040: 00000000 nop
00198044: 1060005f beq r3,r0,0x001981c4			branch if byte = 0
00198048: 00000000 nop
0019804c: 080660a0 j 0x00198280					Else Safety Jump/negative byte?
00198050: 00000000 nop
00198054: 34020002 ori r2,r0,0x0002
00198058: 1062006a beq r3,r2,0x00198204			branch if byte = 2
0019805c: 34020003 ori r2,r0,0x0003
00198060: 10620077 beq r3,r2,0x00198240			branch if byte = 3
00198064: 00000000 nop
00198068: 080660a0 j 0x00198280					Else, <>
0019806c: 00000000 nop


<Usage/Skillset Not Set>
00198070: 0c065b23 jal 0x00196c8c				Find and Target Main Target 
00198074: 02002021 addu r4,r16,r0				r4 = Main Target ID
00198078: 14400006 bne r2,r0,0x00198094			branch if targeting unit found
<Main Target can't be found> (Because it's not targeted yet)
0019807c: 00101100 sll r2,r16,0x04				
00198080: 00511021 addu r2,r2,r17
00198084: 90421834 lbu r2,0x1834(r2)			load enemy flag
00198088: 00000000 nop
0019808c: 14400048 bne r2,r0,0x001981b0			Store unit data if enemy
00198090: 00000000 nop
<Not Enemy> (Remove Coward AI)
00198094: 3c03801a lui r3,0x801a
00198098: 8c6301f8 lw r3,0x01f8(r3)				acting units AI decision
0019809c: 00000000 nop
001980a0: 90620004 lbu r2,0x0004(r3)			load Type of AI?
001980a4: 00000000 nop
001980a8: 304200f7 andi r2,r2,0x00f7			remove coward-like AI
001980ac: a0620004 sb r2,0x0004(r3)
<If Being Ridden>
001980b0: 001010c0 sll r2,r16,0x03
001980b4: 00501023 subu r2,r2,r16
001980b8: 00021180 sll r2,r2,0x06
001980bc: 3c038019 lui r3,0x8019
001980c0: 246308cc addiu r3,r3,0x08cc
001980c4: 00431821 addu r3,r2,r3				get unit data
001980c8: 90640182 lbu r4,0x0182(r3)			load mount data
001980cc: 00000000 nop
001980d0: 30820040 andi r2,r4,0x0040			
001980d4: 10400014 beq r2,r0,0x00198128			branch if not being ridden
001980d8: 26220014 addiu r2,r17,0x0014
<Target Rider if Main Target is being ridden>
001980dc: 9062005a lbu r2,0x005a(r3)			Current Status 3
001980e0: 00000000 nop
001980e4: 30420010 andi r2,r2,0x0010
001980e8: 1040000b beq r2,r0,0x00198118			branch if not transparent
<Is Rider and Mount Invisible?>
001980ec: 3082001f andi r2,r4,0x001f
001980f0: 000218c0 sll r3,r2,0x03
001980f4: 00621823 subu r3,r3,r2
001980f8: 00031980 sll r3,r3,0x06
001980fc: 3c018019 lui r1,0x8019
00198100: 00230821 addu r1,r1,r3
00198104: 90220926 lbu r2,0x0926(r1)			Get Current Status 3
00198108: 00000000 nop
0019810c: 30420010 andi r2,r2,0x0010
00198110: 14400027 bne r2,r0,0x001981b0			Branch if both Rider and Mount are transparent
00198114: 00000000 nop
00198118: 0806606c j 0x001981b0					Store Target Data
0019811c: 3090001f andi r16,r4,0x001f			Remove Riding Flags from Rider ID
<If Unit = Transparent>
00198120: 0806606c j 0x001981b0
00198124: 00808021 addu r16,r4,r0
<Initialize Targeted List>
00198128: 34030001 ori r3,r0,0x0001
0019812c: 34040014 ori r4,r0,0x0014
00198130: a0430c8d sb r3,0x0c8d(r2)				Current Unit is on Targeted List = True
00198134: 2484ffff addiu r4,r4,0xffff			Unit Counter--
00198138: 0481fffd bgez r4,0x00198130			Store true to all listed units		
0019813c: 2442ffff addiu r2,r2,0xffff			Pointer--
00198140: 0c066449 jal 0x00199124				Determine nearest suitable target
00198144: 34040004 ori r4,r0,0x0004				Look for nearest Charging/Performing (Dead/Petrified) unit
00198148: 92230e2e lbu r3,0x0e2e(r17)			acting units ID
0019814c: 00408021 addu r16,r2,r0
00198150: 16030017 bne r16,r3,0x001981b0		<Store Data> if only Charging/Performing unit is self
00198154: 00002021 addu r4,r0,r0				Initialize Unit ID
00198158: 340600ff ori r6,r0,0x00ff
0019815c: 02202821 addu r5,r17,r0
00198160: 3c038019 lui r3,0x8019
00198164: 246308cc addiu r3,r3,0x08cc			r3 = Unit Data Pointer
<Transparent Loop>
00198168: 90620001 lbu r2,0x0001(r3)			load unit ID
0019816c: 00000000 nop
00198170: 1046000a beq r2,r6,0x0019819c			branch if FF
00198174: 00000000 nop
00198178: 90a21834 lbu r2,0x1834(r5)			load enemy flag
0019817c: 00000000 nop
00198180: 10400006 beq r2,r0,0x0019819c			branch if ally
00198184: 00000000 nop
00198188: 9062005a lbu r2,0x005a(r3)
0019818c: 00000000 nop
00198190: 30420010 andi r2,r2,0x0010
00198194: 1440ffe2 bne r2,r0,0x00198120			branch if transparent
00198198: 00000000 nop
0019819c: 24a50010 addiu r5,r5,0x0010
001981a0: 24840001 addiu r4,r4,0x0001
001981a4: 28820015 slti r2,r4,0x0015
001981a8: 1440ffef bne r2,r0,0x00198168                Do for all units
001981ac: 246301c0 addiu r3,r3,0x01c0
<Store Target Data>
001981b0: 8e2217f8 lw r2,0x17f8(r17)			load acting units data
001981b4: 02002021 addu r4,r16,r0
001981b8: 0c065243 jal 0x0019490c				Store main target ID and focus on target flag
001981bc: a05001b9 sb r16,0x01b9(r2)			store main target ID
001981c0: a2200e2d sb r0,0x0e2d(r17)			Ability Decided = False


<Decision = 0>
001981c4: 0c066672 jal 0x001999c8				Initialize Targeting Priorities of all units
001981c8: 00000000 nop
001981cc: 2403ffff addiu r3,r0,0xffff
001981d0: 14430003 bne r2,r3,0x001981e0		`	Next Decision if Frame RNG said so
001981d4: 2402ffff addiu r2,r0,0xffff			
001981d8: 080660b0 j 0x001982c0					Exit and return -1
001981dc: a2200c6e sb r0,0x0c6e(r17)			Next Decision = 0
<Decision = 1>
001981e0: 0c0660b6 jal 0x001982d8				Decide where to move to?
001981e4: 00000000 nop
001981e8: 2403ffff addiu r3,r0,0xffff
001981ec: 10430029 beq r2,r3,0x00198294			Jump to pre-exit if not going to move
001981f0: 34020001 ori r2,r0,0x0001
001981f4: 34020002 ori r2,r0,0x0002
001981f8: 0c0658c3 jal 0x0019630c				Find and Invert Target Priority
001981fc: a2220e2d sb r2,0x0e2d(r17)			store Action = Decided?
00198200: a2200e2d sb r0,0x0e2d(r17)			Action = Not Decided
<Decision = 2>
00198204: 0c0657e3 jal 0x00195f8c				set/remove charging
00198208: 00000000 nop
0019820c: 00401821 addu r3,r2,r0
00198210: 2402ffff addiu r2,r0,0xffff
00198214: 1062001f beq r3,r2,0x00198294			Jump to pre-exit if priorities were not set (because Frame RNG)
00198218: 34020002 ori r2,r0,0x0002
0019821c: 34020001 ori r2,r0,0x0001
00198220: 10620027 beq r3,r2,0x001982c0			Exit and return 0 if target is lower than the current highest unit
00198224: 00001021 addu r2,r0,r0
00198228: a2200e2d sb r0,0x0e2d(r17)			Action = Not Decided
0019822c: 34040003 ori r4,r0,0x0003				Look for specific unit
00198230: 0c065f43 jal 0x00197d0c				Find which units are active? (check if target unit is active)
00198234: 02002821 addu r5,r16,r0				Look for Target unit
00198238: 1040000b beq r2,r0,0x00198268			Branch if unit is not active
0019823c: 34020001 ori r2,r0,0x0001
<Decision = 3>
00198240: 0c065f98 jal 0x00197e60				Choose Ability from Skillset
00198244: 00000000 nop
00198248: 2403ffff addiu r3,r0,0xffff
0019824c: 10430011 beq r2,r3,0x00198294			Branch to pre-exit if an ability was chosen
00198250: 34020003 ori r2,r0,0x0003
00198254: 0c065c2f jal 0x001970bc				Transfer Data based on RNG
00198258: 00000000 nop
0019825c: 14400018 bne r2,r0,0x001982c0			Exit and return 0 if data was successfully transferred
00198260: 00001021 addu r2,r0,r0
00198264: 34020001 ori r2,r0,0x0001
00198268: a2220e2d sb r2,0x0e2d(r17)			Action = Decided
0019826c: 00002021 addu r4,r0,r0				Look for any unit
00198270: 0c065f43 jal 0x00197d0c				Find which units are active?
00198274: 00002821 addu r5,r0,r0				Ignore self
00198278: 1040000e beq r2,r0,0x001982b4			Last Routine if no units can be targeted
0019827c: 34020002 ori r2,r0,0x0002


<>
00198280: 0c065f98 jal 0x00197e60				Choose Ability from Skillset
00198284: 00000000 nop
00198288: 2403ffff addiu r3,r0,0xffff
0019828c: 14430004 bne r2,r3,0x001982a0			Branch if ability was chosen
00198290: 34020004 ori r2,r0,0x0004
<Pre-Exit>
00198294: a2220c6e sb r2,0x0c6e(r17)			(0x0032) Save Decision
00198298: 080660b0 j 0x001982c0					Exit and return -1
0019829c: 2402ffff addiu r2,r0,0xffff
001982a0: 0c065c2f jal 0x001970bc				Transfer Data based on RNG
001982a4: 00000000 nop
001982a8: 14400005 bne r2,r0,0x001982c0
001982ac: 00001021 addu r2,r0,r0
001982b0: 34020002 ori r2,r0,0x0002
001982b4: 0c066526 jal 0x00199498				Reset Ability Choice Data? (Target Flags?)
001982b8: a2220e2d sb r2,0x0e2d(r17)			Action = Decided
001982bc: 00001021 addu r2,r0,r0				Return 0
001982c0: 8fbf0018 lw r31,0x0018(r29)
001982c4: 8fb10014 lw r17,0x0014(r29)
001982c8: 8fb00010 lw r16,0x0010(r29)
001982cc: 27bd0020 addiu r29,r29,0x0020
001982d0: 03e00008 jr r31
001982d4: 00000000 nop