Post Ability Hardcoding?

From Final Fantasy Hacktics Wiki
(Redirected from Some status hardcoding)
Jump to navigation Jump to search
0018e07c - 0018e1ac

Parameters : r4 = Targeted unit data pointer
             r5 = Input Value (used for Validate_Status_Changes)

Returns : r2 = -0x01 If Invalid Unit
          r2 = 0x00 if Ok

Deals with status infliction and removal. At the end, Targeted unit inflicted status (0x1bb) and current status are updated.
Updated is based on Ridding status, immortal, frog, Immunities, Innate status, Status incompatibility (can't stack / cancels)
Set HP to 0x00 if unit is dead
Deals with clearing/restoring unit control or team (berserk, confusion, blood suck, chicken, charm)

At the very end Target current action infliction and removal bytes are restored as they were at the start (but unit statuses are updated) 
----------------------------------------------------------------------------------------------------------------
0018e07c: 27bdffd0 addiu r29,r29,-0x0030    |
0018e080: afb00020 sw r16,0x0020(r29)       |
0018e084: 00808021 addu r16,r4,r0           |r16 = Targeted Unit ID
0018e088: afb20028 sw r18,0x0028(r29)       |
0018e08c: 001010c0 sll r2,r16,0x03          |r2 = Targeted Unit ID * 8
0018e090: 00501023 subu r2,r2,r16           |r2 = Targeted Unit ID * 7
0018e094: afb10024 sw r17,0x0024(r29)       |
0018e098: 00028980 sll r17,r2,0x06          |r17 = Targeted Unit ID * 0x1c0 (size of unit Data * Unit ID)
0018e09c: afbf002c sw r31,0x002c(r29)       |
0018e0a0: 3c018019 lui r1,0x8019            |
0018e0a4: 00310821 addu r1,r1,r17           |
0018e0a8: 902308cd lbu r3,0x08cd(r1)        |r3 = Unit ID (This ID is 0x0ff if unit doesn't exists) 0x801908cc + Unit Offset + 0x01
0018e0ac: 340200ff ori r2,r0,0x00ff         |r2 = 0x0ff
0018e0b0: 14620003 bne r3,r2,0x0018e0c0     #If Targeted Unit Exists
0018e0b4: 00a09021 addu r18,r5,r0           |r18 = Input Value
0018e0b8: 08063865 j 0x0018e194                 >>Jump to  END (r2 = -0x01)
0018e0bc: 2402ffff addiu r2,r0,-0x0001          |r2 = -0x01
0018e0c0: 27a50010 addiu r5,r29,0x0010      #Else (Unit exists) r5 = Stack 0x10
0018e0c4: 3c048019 lui r4,0x8019            |
0018e0c8: 8c842d90 lw r4,0x2d90(r4)         |r4 = Target Current action data pointer 
0018e0cc: 3406000a ori r6,r0,0x000a         |r6 = 0x0a
0018e0d0: 0c017895 jal 0x0005e254           |-->Store_X_Byte_into_Y Store TCA's all status infliction and removal byte to Stack 0x10 - 0x19
0018e0d4: 2484001b addiu r4,r4,0x001b       |r4 = TCA status infliction 1
0018e0d8: 3c028019 lui r2,0x8019            |
0018e0dc: 244208cc addiu r2,r2,0x08cc       |r2 = 0x801908cc
0018e0e0: 02221821 addu r3,r17,r2           |r3 = Targeted Unit data pointer
0018e0e4: 2442018c addiu r2,r2,0x018c       |r2 = 0x801908cc + 0x18c
0018e0e8: 02221021 addu r2,r17,r2           |r2 = TCA data pointer
0018e0ec: 3c018019 lui r1,0x8019            |
0018e0f0: a03038c1 sb r16,0x38c1(r1)        |Store Targeted Unit ID at current ability 0x801938c1 (Target Unit ID)
0018e0f4: 3c018019 lui r1,0x8019            |
0018e0f8: ac232d98 sw r3,0x2d98(r1)         |Store Targeted Unit data pointer at 0x80192d98
0018e0fc: 3c018019 lui r1,0x8019            |
0018e100: ac222d90 sw r2,0x2d90(r1)         |Store Targeted Unit Current action data pointer at 0x80192d90
0018e104: 0c0612c9 jal 0x00184b24           |-->Validate_Status_Changes Might remove some status infliction/removal from TCA
0018e108: 02402021 addu r4,r18,r0           |r4 = Input value
0018e10c: 0c063892 jal 0x0018e248           |-->Inflicted_status_CT_setting,_xfer_last_used_CT Remove status from Target inflicted status
0018e110: 02002021 addu r4,r16,r0           |r4 = Targeted Unit ID
0018e114: 02002021 addu r4,r16,r0           |r4 = Targeted Unit ID
0018e118: 0c0638c4 jal 0x0018e310           |-->Store_status,modified_ENTD_for_current_attack Add Status to Target and Remove status canceled by inflicted status
0018e11c: 02402821 addu r5,r18,r0           |r5 = Input Value
0018e120: 3c038019 lui r3,0x8019            |
0018e124: 8c632d98 lw r3,0x2d98(r3)         |r3 = Targeted Unit data pointer
0018e128: 00000000 nop                      |
0018e12c: 90620058 lbu r2,0x0058(r3)        |r2 = Targeted Unit current status 1
0018e130: 00000000 nop                      |
0018e134: 30420020 andi r2,r2,0x0020        |r2 = 0x20 if Target is dead
0018e138: 10400004 beq r2,r0,0x0018e14c     #If Targeted Unit is Dead
0018e13c: 00000000 nop                          |
0018e140: a4600028 sh r0,0x0028(r3)             |Set Targeted Unit current HP = 0x00
0018e144: 3c038019 lui r3,0x8019                |
0018e148: 8c632d98 lw r3,0x2d98(r3)             |r3 = Targeted Unit data pointer
0018e14c: 00000000 nop                          |
0018e150: 90620058 lbu r2,0x0058(r3)        |r2 = Targeted Unit current status 1
0018e154: 00000000 nop                      |
0018e158: 3042000d andi r2,r2,0x000d        |r2 <> 0x00 If Targeted Unit if charging/jumping/performing
0018e15c: 14400002 bne r2,r0,0x0018e168     #If Targeted Unit is not charging/jumping nor performing
0018e160: 340200ff ori r2,r0,0x00ff         |r2 = 0x0ff
0018e164: a062015d sb r2,0x015d(r3)             |Store Targeted Unit current ability CT = 0x0ff
0018e168: 3c048019 lui r4,0x8019            |r4 = 0x80190000
0018e16c: 8c842d98 lw r4,0x2d98(r4)         |r4 = Targeted Unit data pointer
0018e170: 0c06386c jal 0x0018e1b0           |-->Remove_control_based_on_status Remove or restore control/Team (based on unit statuses)
0018e174: 00000000 nop                      |
0018e178: 27a40010 addiu r4,r29,0x0010      |r4 = Stack 0x10
0018e17c: 3c058019 lui r5,0x8019            |
0018e180: 8ca52d90 lw r5,0x2d90(r5)         |r5 = TCA data pointer
0018e184: 3406000a ori r6,r0,0x000a         |r6 = 0x0a
0018e188: 0c017895 jal 0x0005e254           |-->Store_X_Byte_into_Y Restore TCA infliction/removal value from stack (?)
0018e18c: 24a5001b addiu r5,r5,0x001b       |r5 = TCA status infliction data pointer
0018e190: 00001021 addu r2,r0,r0            |r2 = 0x00
0018e194: 8fbf002c lw r31,0x002c(r29)       
0018e198: 8fb20028 lw r18,0x0028(r29)       
0018e19c: 8fb10024 lw r17,0x0024(r29)       
0018e1a0: 8fb00020 lw r16,0x0020(r29)       
0018e1a4: 27bd0030 addiu r29,r29,0x0030     
0018e1a8: 03e00008 jr r31                   
0018e1ac: 00000000 nop

Return locations

0018009c: Set_target_for_mounted_unit,_move_find_item/trap
0018bec0: Attack_Finalisation_&_Reaction_Flagging
0018c2e4: Attack_Finalisation_&_Reaction_Flagging
0018c53c: Attack_Finalisation_&_Reaction_Flagging
0018ec2c: More_status_infliction/removal