Attack Evaded Calculations

From Final Fantasy Hacktics Wiki
Revision as of 20:46, 24 March 2022 by Orkney (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
Parameters : r4 = Item Evade value
             r5 = Base Hit value
             r6 = Input Value - If Attack is evaded,  will be stored as Evade Type in Target Current Action 0x02 (Evade Type)
             r7 = Item ID - If Attack is evaded,  will be stored as Evade Type in Target Current Action 0x03 (Item to use/break)

Returns : r2 = 0x00 If Attack Hits
          r2 = 0x01 If Attack is Evaded

Roll Evade chances (Random between 0 and r5 Vs r4)
If Action is been executed (0x8018f5fc = 0x00) and Random fails : Attack is evaded - Set Action hit flag to Miss, store Item ID in action 0x03 and r6 Value in action 0x02 (Evade Type)
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
001848d8: 27bdffe0 addiu r29,r29,-0x0020    |
001848dc: afb00010 sw r16,0x0010(r29)       |
001848e0: 00c08021 addu r16,r6,r0           |r16 = Input Value
001848e4: afb10014 sw r17,0x0014(r29)       |
001848e8: 00e08821 addu r17,r7,r0           |r17 = Equipment ID
001848ec: 3082ffff andi r2,r4,0xffff        |r2 = Item Evasion (halfword)
001848f0: 30a4ffff andi r4,r5,0xffff        |r4 = Base Hit (halfword)
001848f4: afbf0018 sw r31,0x0018(r29)       |
001848f8: 0c017833 jal 0x0005e0cc           |-->Check_if_Random_is_greater/equal_to_Chance returns r2 = 0x01 if Random (From 0 to Base Hit)  is >= Evade data 
001848fc: 00402821 addu r5,r2,r0            |r5 = Item Evasion
00184900: 14400012 bne r2,r0,0x0018494c     #If Random < Evasion : Attack misses /Else Attack Hits - Branch to END with r2 = 0x00
00184904: 00001021 addu r2,r0,r0            |r2 = 0x00
00184908: 3c028019 lui r2,0x8019                |
0018490c: 8c42f5fc lw r2,-0x0a04(r2)            |r2 = Action State
00184910: 00000000 nop                          |
00184914: 1440000d bne r2,r0,0x0018494c         #If Action is been executed /Else (preview - AI) Simulate a sucessful hit (r2 = 0x00)
00184918: 00001021 addu r2,r0,r0                |r2 = 0x00
0018491c: 3c028019 lui r2,0x8019                    |
00184920: 8c422d90 lw r2,0x2d90(r2)                 |r2 = TCA data pointer
00184924: 00000000 nop                              |
00184928: a0400000 sb r0,0x0000(r2)                 |Store 0x00 in TCA hit flag (miss)
0018492c: 3c028019 lui r2,0x8019                    |
00184930: 8c422d90 lw r2,0x2d90(r2)                 |r2 = TCA data pointer
00184934: 00000000 nop                              |
00184938: a0500002 sb r16,0x0002(r2)                |Store TCA Evade Type = Input Value
0018493c: 3c038019 lui r3,0x8019                    |
00184940: 8c632d90 lw r3,0x2d90(r3)                 |r2 = TCA data pointer
00184944: 34020001 ori r2,r0,0x0001                 |r2 = 0x01 (returned)
00184948: a0710003 sb r17,0x0003(r3)                |Store Equipment ID in TCA item to use/break
0018494c: 8fbf0018 lw r31,0x0018(r29)       END
00184950: 8fb10014 lw r17,0x0014(r29)       
00184954: 8fb00010 lw r16,0x0010(r29)       
00184958: 27bd0020 addiu r29,r29,0x0020     
0018495c: 03e00008 jr r31                   
00184960: 00000000 nop                      

Return locations

Battle.bin
001859f4: Calculate Final Hit % r6 = 0x01 (Accessory Evade)
00185a30: Calculate Final Hit % r6 = 0x02 (Right Hand Evade)
00185a68: Calculate Final Hit % r6 = 0x03 (Left Hand Evade)
00185a84: Calculate Final Hit % r6 = 0x04 (Class Evade)  / r7 = 0x0ff (on Item ID)