Modify Status Inflictions

From Final Fantasy Hacktics Wiki
Jump to navigation Jump to search
# ROUTINE: MODIFY STATUS INFLICTIONS Short summary                        Alternative rookie step by step annotation here : Validate_Status_Changes
#   Parameters:
#       r4: 0 signifies more strict status removal?
#   Returns:
#       r2 = {
#           0, If no status is being inflicted or removed by the current action
#           Non-zero, otherwise
#       }

00184b24: 00803821 addu r7,r4,r0
00184b28: 3c028019 lui r2,0x8019
00184b2c: 8c422d98 lw r2,0x2d98(r2)             #   Target
00184b30: 00005021 addu r10,r0,r0               #   Result = 0
00184b34: 90430005 lbu r3,0x0005(r2)            #   Target's ENTD flags
00184b38: 90420182 lbu r2,0x0182(r2)            #   Target's Mount information
00184b3c: 00000000 nop
00184b40: 30420080 andi r2,r2,0x0080            #   Whether or not Target is riding a unit (true=0x80, false=0)
00184b44: 1040000f beq r2,r0,0x00184b84         #   if (Target is riding a unit) {
00184b48: 30680004 andi r8,r3,0x0004            
00184b4c: 00003021 addu r6,r0,r0                #       Set statusByteIndex = 0
                                                #       do {
00184b50: 3c038019 lui r3,0x8019
00184b54: 8c632d90 lw r3,0x2d90(r3)             #           Action
00184b58: 3c018019 lui r1,0x8019
00184b5c: 00260821 addu r1,r1,r6
00184b60: 9024f60c lbu r4,-0x09f4(r1)           #           Rider-allowed status inflictions byte (#statusByteIndex)
00184b64: 00661821 addu r3,r3,r6
00184b68: 9062001b lbu r2,0x001b(r3)            #           Action's Status Infliction byte (#statusByteIndex)
00184b6c: 24c60001 addiu r6,r6,0x0001           #           Set statusByteIndex = statusByteIndex + 1
00184b70: 00441024 and r2,r2,r4                 #           Zero out statuses that aren't allowed on riders
00184b74: a062001b sb r2,0x001b(r3)             #           Store as Action's Status Infliction byte (#statusByteIndex)
00184b78: 28c20005 slti r2,r6,0x0005            
00184b7c: 1440fff4 bne r2,r0,0x00184b50         #       } while (statusByteIndex < 5)
00184b80: 00000000 nop
                                                #   }
00184b84: 3c048019 lui r4,0x8019
00184b88: 8c842d90 lw r4,0x2d90(r4)             #   Action
00184b8c: 00000000 nop
00184b90: 9083001d lbu r3,0x001d(r4)            #   Action's Status Infliction byte (#3)
00184b94: 00000000 nop
00184b98: 30620002 andi r2,r3,0x0002            #   Check for Frog
00184b9c: 10400013 beq r2,r0,0x00184bec         #   If (Action is inflicting Frog status) {
00184ba0: 00003021 addu r6,r0,r0
00184ba4: 3c028019 lui r2,0x8019
00184ba8: 8c422d98 lw r2,0x2d98(r2)             #       Target
00184bac: 00000000 nop
00184bb0: 9042005a lbu r2,0x005a(r2)            #       Target's current status byte (#3)
00184bb4: 00000000 nop
00184bb8: 30420002 andi r2,r2,0x0002            #       Check if Target is currently a Frog (in Frog status)
00184bbc: 1040000b beq r2,r0,0x00184bec         
00184bc0: 00000000 nop
00184bc4: 14e00009 bne r7,r0,0x00184bec         #       if ((Target is a Frog) && ([Input parameter] == 0)) {
00184bc8: 306200fd andi r2,r3,0x00fd            
00184bcc: a082001d sb r2,0x001d(r4)             #           Zero out Frog status from current action's inflicted status
00184bd0: 3c038019 lui r3,0x8019
00184bd4: 8c632d90 lw r3,0x2d90(r3)             #           Action
00184bd8: 00000000 nop
00184bdc: 90620022 lbu r2,0x0022(r3)            #           Action's Status Removal byte (#3)
00184be0: 00000000 nop
00184be4: 34420002 ori r2,r2,0x0002             #           Action removes Frog status
00184be8: a0620022 sb r2,0x0022(r3)             #           Save to Action's Status Removal byte (#3)
                                                #       }
                                                #   }
                                                #   do {
00184bec: 14e00023 bne r7,r0,0x00184c7c         #       if ([Input parameter] == 0) {
00184bf0: 28c20003 slti r2,r6,0x0003            
00184bf4: 1040000a beq r2,r0,0x00184c20         #           if (statusIndex < 3) {  // Status that doesn't expire
00184bf8: 00000000 nop
00184bfc: 3c058019 lui r5,0x8019
00184c00: 8ca52d90 lw r5,0x2d90(r5)             #               Action
00184c04: 3c028019 lui r2,0x8019
00184c08: 8c422d98 lw r2,0x2d98(r2)             #               Target
00184c0c: 00000000 nop
00184c10: 00461021 addu r2,r2,r6                
00184c14: 90430058 lbu r3,0x0058(r2)            #               [Status byte] = Target's Current Status Byte (#statusIndex)
00184c18: 0806130f j 0x00184c3c
00184c1c: 00a62821 addu r5,r5,r6
                                                #           } else {                // Status that does expire
00184c20: 3c058019 lui r5,0x8019
00184c24: 8ca52d90 lw r5,0x2d90(r5)             #               Action
00184c28: 3c028019 lui r2,0x8019
00184c2c: 8c422d98 lw r2,0x2d98(r2)             #               Target
00184c30: 00a62821 addu r5,r5,r6
00184c34: 00461021 addu r2,r2,r6
00184c38: 9043004e lbu r3,0x004e(r2)                            [Status byte] = Target's Innate Status Byte (#statusIndex)
                                                #           }
00184c3c: 90440053 lbu r4,0x0053(r2)            #           Target's Status Immunities Byte (#statusIndex)
00184c40: 90a2001b lbu r2,0x001b(r5)            #           Action's Status Infliction Byte (#statusIndex)
00184c44: 00641827 nor r3,r3,r4                 #           [Status byte] = [Statuses not in the status byte or the immunities]
00184c48: 00431024 and r2,r2,r3                 #           Zero out statuses that are already on the unit and don't expire (either because the status itself doesn't expire, 
                                                #               or because the unit has the status innately)
00184c4c: 1100000b beq r8,r0,0x00184c7c         #           Check whether or not Target is Immortal
00184c50: a0a2001b sb r2,0x001b(r5)             #           Save as statuses inflicted (#statusIndex)

                                                #           if (Target is Immortal) {
00184c54: 3c028019 lui r2,0x8019
00184c58: 8c422d90 lw r2,0x2d90(r2)             #               Action
00184c5c: 3c018006 lui r1,0x8006
00184c60: 00260821 addu r1,r1,r6
00184c64: 902362ee lbu r3,0x62ee(r1)            #               Immortal Immunities? (#statusIndex)
00184c68: 00461021 addu r2,r2,r6                #               
00184c6c: 9044001b lbu r4,0x001b(r2)            #               Action Status Infliction Byte (#statusIndex)
00184c70: 00031827 nor r3,r0,r3                 #               
00184c74: 00832024 and r4,r4,r3                 #               Zero out Immortal Immunities?
00184c78: a044001b sb r4,0x001b(r2)             #               Save as Action Status Infliction Byte (#statusIndex)
                                                #           }
                                                #       }
00184c7c: 3c058019 lui r5,0x8019
00184c80: 8ca52d90 lw r5,0x2d90(r5)             #       Action
00184c84: 3c048019 lui r4,0x8019
00184c88: 8c842d98 lw r4,0x2d98(r4)             #       Target
00184c8c: 00a62821 addu r5,r5,r6
00184c90: 00862021 addu r4,r4,r6                
00184c94: 24c60001 addiu r6,r6,0x0001           #       statusIndex = statusIndex + 1
00184c98: 9083004e lbu r3,0x004e(r4)            #       Target's Innate Status Byte (#[old statusIndex])
00184c9c: 90a20020 lbu r2,0x0020(r5)            #       Action's Status Removal Byte (#[old statusIndex])       
00184ca0: 908401bb lbu r4,0x01bb(r4)            #       Inflicted Status List Byte (#[old statusIndex])
00184ca4: 00031827 nor r3,r0,r3                 #       
00184ca8: 00431024 and r2,r2,r3                 #       Zero out Innate Statuses in Status Removal byte
00184cac: 00441024 and r2,r2,r4                 #       Zero out statuses not in Inflicted Status List Byte flags in Status Removal byte
00184cb0: a0a20020 sb r2,0x0020(r5)             #       Save as Status Removal byte
00184cb4: 28c20005 slti r2,r6,0x0005
00184cb8: 1440ffcc bne r2,r0,0x00184bec         #   } while (statusIndex < 5)
00184cbc: 00000000 nop
00184cc0: 14e00051 bne r7,r0,0x00184e08         #   if ([Input parameter] == 0) {
00184cc4: 00003021 addu r6,r0,r0                #       statusIndex = 0
00184cc8: 340b0080 ori r11,r0,0x0080
00184ccc: 3c098006 lui r9,0x8006
00184cd0: 25295def addiu r9,r9,0x5def           #       [Status Stack On pointer] = 0x80065def
                                                #       do {
00184cd4: 04c10002 bgez r6,0x00184ce0
00184cd8: 00c01021 addu r2,r6,r0
00184cdc: 24c20007 addiu r2,r6,0x0007
00184ce0: 000238c3 sra r7,r2,0x03               #           statusIndex / 8 (integer division)
00184ce4: 3c028019 lui r2,0x8019
00184ce8: 8c422d90 lw r2,0x2d90(r2)             #           Action
00184cec: 30c30007 andi r3,r6,0x0007            #           statusIndex mod 8
00184cf0: 00471021 addu r2,r2,r7                
00184cf4: 9042001b lbu r2,0x001b(r2)            #           Action's Inflict Status byte for this status
00184cf8: 006b1807 srav r3,r11,r3               #           Current Status flag (0x80 >> (statusIndex mod 8)) 
00184cfc: 00431024 and r2,r2,r3                 #           Check if Current Status is being inflicted (#statusIndex)   
00184d00: 10400019 beq r2,r0,0x00184d68         #           if (Current Status is being inflicted) {
00184d04: 00000000 nop
00184d08: 00002821 addu r5,r0,r0                #               innerIndex = 0
00184d0c: 00034027 nor r8,r0,r3                 #               Bitmask with current status (#statusIndex) negated
00184d10: 01202021 addu r4,r9,r0                #               [Status Stack on pointer]
                                                #               do {
00184d14: 3c028019 lui r2,0x8019
00184d18: 8c422d98 lw r2,0x2d98(r2)             #                   Target
00184d1c: 90830000 lbu r3,0x0000(r4)            #                   Load Status Can't Stack On Byte (#innerIndex)
00184d20: 00451021 addu r2,r2,r5
00184d24: 90420058 lbu r2,0x0058(r2)            #                   Target Current Status Byte (#innerIndex)   
00184d28: 00000000 nop
00184d2c: 00431024 and r2,r2,r3                 #                   Statuses from Target Current Status Byte (#innerIndex) that are also in Can't Stack On Byte (#innerIndex)
00184d30: 10400009 beq r2,r0,0x00184d58         #                   if (Statuses exist in Target Current Status Byte (#innerIndex) that are also in Can't Stack On Byte (#innerIndex)) {
00184d34: 24840001 addiu r4,r4,0x0001
00184d38: 3c038019 lui r3,0x8019
00184d3c: 8c632d90 lw r3,0x2d90(r3)             #                       Action
00184d40: 00000000 nop
00184d44: 00671821 addu r3,r3,r7                
00184d48: 9062001b lbu r2,0x001b(r3)            #                       Load Action Inflict Status byte (based on statusIndex - outer loop's index)       
00184d4c: 00000000 nop
00184d50: 00481024 and r2,r2,r8                 #                       Zero out current status (outer loop, #statusIndex)
00184d54: a062001b sb r2,0x001b(r3)             #                       Save as Load Action Inflict Status byte (based on statusIndex)
                                                #                   }
00184d58: 24a50001 addiu r5,r5,0x0001           #                   innerIndex = innerIndex + 1
00184d5c: 28a20005 slti r2,r5,0x0005
00184d60: 1440ffec bne r2,r0,0x00184d14         #               } while (innerIndex < 5)
00184d64: 00000000 nop
                                                #           }
00184d68: 24c60001 addiu r6,r6,0x0001           #           Set statusIndex = statusIndex + 1
00184d6c: 28c20028 slti r2,r6,0x0028
00184d70: 1440ffd8 bne r2,r0,0x00184cd4         #       
00184d74: 25290010 addiu r9,r9,0x0010           #           [Status Stack on pointer] = [Status Stack on pointer] + sizeof(Status pointer data) (= 16)
                                                #       } while (statusIndex < 40)
00184d78: 00003021 addu r6,r0,r0                #       statusIndex = 0
00184d7c: 34090080 ori r9,r0,0x0080
00184d80: 3c088006 lui r8,0x8006
00184d84: 25085dea addiu r8,r8,0x5dea           #       [Status Cancels pointer] = 0x80065dea
                                                #       do {
00184d88: 04c10002 bgez r6,0x00184d94
00184d8c: 00c01021 addu r2,r6,r0
00184d90: 24c20007 addiu r2,r6,0x0007
00184d94: 000238c3 sra r7,r2,0x03               #           statusIndex / 8 (integer division)
00184d98: 3c028019 lui r2,0x8019
00184d9c: 8c422d90 lw r2,0x2d90(r2)             #           Action
00184da0: 30c30007 andi r3,r6,0x0007            #           statusIndex mod 8
00184da4: 00471021 addu r2,r2,r7
00184da8: 9042001b lbu r2,0x001b(r2)            #           Action's Current Inflict Status Byte (based on statusIndex)
00184dac: 00691807 srav r3,r9,r3                #           Current Status flag (0x80 >> (statusIndex mod 8))
00184db0: 00431024 and r2,r2,r3                 #           Check if Current Status is being inflicted (#statusIndex)
00184db4: 1040000f beq r2,r0,0x00184df4         #           if (Current Status is being inflicted) {
00184db8: 00000000 nop
00184dbc: 00002821 addu r5,r0,r0                #               innerIndex = 0
00184dc0: 01003821 addu r7,r8,r0                #               [Status Cancels pointer]
                                                #               do {
00184dc4: 3c048019 lui r4,0x8019
00184dc8: 8c842d90 lw r4,0x2d90(r4)             #                   Action
00184dcc: 90e30000 lbu r3,0x0000(r7)            #                   Status Cancels pointer (#innerIndex)
00184dd0: 00852021 addu r4,r4,r5
00184dd4: 24a50001 addiu r5,r5,0x0001           #                   innerIndex = innerIndex + 1
00184dd8: 9082001b lbu r2,0x001b(r4)            #                   Action's Status Infliction Byte (#innerIndex)
00184ddc: 00031827 nor r3,r0,r3
00184de0: 00431024 and r2,r2,r3                 #                   Zero out any statuses that this status cancels
00184de4: a082001b sb r2,0x001b(r4)             #                   Save as Action's Status Infliction Byte (#innerIndex)
00184de8: 28a20005 slti r2,r5,0x0005                   
00184dec: 1440fff5 bne r2,r0,0x00184dc4
00184df0: 24e70001 addiu r7,r7,0x0001           #      
                                                #               } while (innerIndex < 5)

00184df4: 24c60001 addiu r6,r6,0x0001           #           statusIndex = statusIndex + 1
00184df8: 28c20028 slti r2,r6,0x0028
00184dfc: 1440ffe2 bne r2,r0,0x00184d88
00184e00: 25080010 addiu r8,r8,0x0010           #           [Status Cancels pointer] = [Status Cancels pointer] + sizeof(Status pointer data) (= 16)
                                                #       } while (statusIndex < 40)
00184e04: 00003021 addu r6,r0,r0
                                                #   }
                                                #   statusByteIndex = 0
00184e08: 3c048019 lui r4,0x8019
00184e0c: 8c842d90 lw r4,0x2d90(r4)             #   Action
00184e10: 00000000 nop                          #   do {
00184e14: 00861821 addu r3,r4,r6
00184e18: 24c60001 addiu r6,r6,0x0001           #       statusByteIndex = statusByteIndex + 1
00184e1c: 9062001b lbu r2,0x001b(r3)            #       Action's Inflict Status Byte (#[old statusByteIndex])
00184e20: 90630020 lbu r3,0x0020(r3)            #       Action's Remove Status Byte (#[old statusByteIndex])
00184e24: 01421021 addu r2,r10,r2
00184e28: 00435021 addu r10,r2,r3               #       Result = Result + Action's Inflict Status Byte + Action's Remove Status Byte
00184e2c: 28c20005 slti r2,r6,0x0005
00184e30: 1440fff7 bne r2,r0,0x00184e10
00184e34: 00000000 nop                          #   } while (statusByteIndex < 5)
00184e38: 03e00008 jr r31                       #   Return Result (Non-zero if at least one status is being inflicted or removed, zero otherwise)
00184e3c: 01401021 addu r2,r10,r0


Return Locations

Battle.bin
00180078: Set target for mounted unit, move find item/trap
0018705c: Ability Elemental?
00187e6c: Formula 01 - 06 Aftermath
00188204: 38 (100%)
0018b078: Perform reaction abilities
0018c4d0: Main Reaction Routine - performs ability effects
0018d9dc: Process Expiring Statuses
0018db78: Poison Marsh Routine
0018dcac: Traps Routine
0018dcd4: Traps Routine
0018e10c: Post Ability Hardcoding?
0018e43c: Store status,modified ENTD for current attack

Short summary

If Unit is ridding : remove incompatible statuses from TCA infliction list

Handles Frog toggle mechanics (frog units or unfrog frogs)

Update TCA status infliction list removing :
  - Target Innates status (no need to inflict)
  - Target current status that never ends (sets 1,2 and 3)  (no need to inflict)
  - Target Immunity (can't be inflicted)
  - If Target is immortal, removes incompatible status
 
Update TCA status removal list removing :
  - Target Innate status (cannot be removed)
  - Status that are not on target (no need to remove)

Update TCA status infliction list (again) removing
  - Every status that can not stack on a status present on the target
  - Every status that should ben canceled by another status in the infliction list
  (done in the Status order from set - 1st is crystal last is death sentence )
  
Returns r2 <> 0x00 if something is inflicted/removed