Difference between revisions of "Attack Evaded Calculations"

From Final Fantasy Hacktics Wiki
Jump to navigation Jump to search
(Created page with " Attack Evaded Calculations 001848d8: 27bdffe0 addiu r29,r29,0xffe0 001848dc: afb00010 sw r16,0x0010(r29) 001848e0: 00c08021 addu r16,r6,r0 r16 = Evade Type 001848e4: afb...")
 
m
 
(One intermediate revision by one other user not shown)
Line 1: Line 1:
  Attack Evaded Calculations
+
  '''Parameters''' : r4 = Item Evade value
  001848d8: 27bdffe0 addiu r29,r29,0xffe0
+
              r5 = Base Hit value
  001848dc: afb00010 sw r16,0x0010(r29)
+
              r6 = Input Value - If Attack is evaded,  will be stored as Evade Type in Target Current Action 0x02 (Evade Type)
  001848e0: 00c08021 addu r16,r6,r0 r16 = Evade Type
+
              r7 = Item ID - If Attack is evaded,  will be stored as Evade Type in Target Current Action 0x03 (Item to use/break)
  001848e4: afb10014 sw r17,0x0014(r29)
+
  001848e8: 00e08821 addu r17,r7,r0 r17 = Equipment ID
+
'''Returns''' : r2 = 0x00 If Attack Hits
  001848ec: 3082ffff andi r2,r4,0xffff r2 = Evade Type's Evade%
+
          r2 = 0x01 If Attack is Evaded
  001848f0: 30a4ffff andi r4,r5,0xffff r4 = Base Hit
+
  001848f4: afbf0018 sw r31,0x0018(r29)
+
Roll Evade chances (Random between 0 and r5 Vs r4)
  001848f8: 0c017833 jal 0x0005e0cc Check if Attack Hits?
+
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)
  001848fc: 00402821 addu r5,r2,r0 r5 = Evade Type's Evade
+
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  00184900: 14400012 bne r2,r0,0x0018494c Branch if Attack Hits?
+
  001848d8: 27bdffe0 addiu r29,r29,-0x0020    |
  00184904: 00001021 addu r2,r0,r0
+
  001848dc: afb00010 sw r16,0x0010(r29)       |
  00184908: 3c028019 lui r2,0x8019
+
  001848e0: 00c08021 addu r16,r6,r0           |{{f/std|<nowiki>r16 = Input Value</nowiki>}}
  0018490c: 8c42f5fc lw r2,-0x0a04(r2) Load ?
+
  001848e4: afb10014 sw r17,0x0014(r29)       |
  00184910: 00000000 nop
+
  001848e8: 00e08821 addu r17,r7,r0           |{{f/std|<nowiki>r17 = Equipment ID</nowiki>}}
  00184914: 1440000d bne r2,r0,0x0018494c Branch if ? != 0
+
  001848ec: 3082ffff andi r2,r4,0xffff       |{{f/std|<nowiki>r2 = Item Evasion (halfword)</nowiki>}}
  00184918: 00001021 addu r2,r0,r0
+
  001848f0: 30a4ffff andi r4,r5,0xffff       |{{f/std|<nowiki>r4 = Base Hit (halfword)</nowiki>}}
  0018491c: 3c028019 lui r2,0x8019
+
  001848f4: afbf0018 sw r31,0x0018(r29)       |
  00184920: 8c422d90 lw r2,0x2d90(r2) Load Current Action Data Pointer
+
  001848f8: 0c017833 jal 0x0005e0cc           |{{f/jal|Check_if_Random_is_greater/equal_to_Chance|Check_if_Random_is_greater/equal_to_Chance}} returns r2 = 0x01 if Random (From 0 to Base Hit)  is >= Evade data
  00184924: 00000000 nop
+
  001848fc: 00402821 addu r5,r2,r0           |{{f/std|<nowiki>r5 = Item Evasion</nowiki>}}
  00184928: a0400000 sb r0,0x0000(r2) Attack was Evaded
+
  00184900: 14400012 bne r2,r0,0x0018494c     {{f/Cond|If Random < Evasion : Attack misses}} /Else Attack Hits - Branch to END with r2 = 0x00
  0018492c: 3c028019 lui r2,0x8019
+
  00184904: 00001021 addu r2,r0,r0           |{{f/std|<nowiki>r2 = 0x00</nowiki>}}
  00184930: 8c422d90 lw r2,0x2d90(r2) Reload Current Action Data Pointer
+
  00184908: 3c028019 lui r2,0x8019               |
  00184934: 00000000 nop
+
  0018490c: 8c42f5fc lw r2,-0x0a04(r2)           |{{f/adr|<nowiki>r2 = Action State</nowiki>}}
  00184938: a0500002 sb r16,0x0002(r2) Store Evade Type?
+
  00184910: 00000000 nop                         |
  0018493c: 3c038019 lui r3,0x8019
+
  00184914: 1440000d bne r2,r0,0x0018494c         {{f/Cond|If Action is been executed}} /Else (preview - AI) Simulate a sucessful hit (r2 = 0x00)
  00184940: 8c632d90 lw r3,0x2d90(r3) Re-Reload Current Action Data Pointer
+
  00184918: 00001021 addu r2,r0,r0               |{{f/std|<nowiki>r2 = 0x00</nowiki>}}
  00184944: 34020001 ori r2,r0,0x0001 r2 = 1
+
  0018491c: 3c028019 lui r2,0x8019                   |{{f/std|}}
  00184948: a0710003 sb r17,0x0003(r3) ? = Equipment ID (maybe for evade  message/anim?
+
  00184920: 8c422d90 lw r2,0x2d90(r2)                 |{{f/adr|<nowiki>r2 = TCA data pointer</nowiki>}}
  0018494c: 8fbf0018 lw r31,0x0018(r29)
+
  00184924: 00000000 nop                             |
  00184950: 8fb10014 lw r17,0x0014(r29)
+
  00184928: a0400000 sb r0,0x0000(r2)                 |{{f/store|Store 0x00 in TCA hit flag (miss)}}
  00184954: 8fb00010 lw r16,0x0010(r29)
+
  0018492c: 3c028019 lui r2,0x8019                   |
  00184958: 27bd0020 addiu r29,r29,0x0020
+
  00184930: 8c422d90 lw r2,0x2d90(r2)                 |{{f/adr|<nowiki>r2 = TCA data pointer</nowiki>}}
  0018495c: 03e00008 jr r31
+
  00184934: 00000000 nop                             |
  00184960: 00000000 nop
+
  00184938: a0500002 sb r16,0x0002(r2)               |{{f/store|<nowiki>Store TCA Evade Type = Input Value</nowiki>}}
 +
  0018493c: 3c038019 lui r3,0x8019                   |
 +
  00184940: 8c632d90 lw r3,0x2d90(r3)                 |{{f/adr|<nowiki>r2 = TCA data pointer</nowiki>}}
 +
  00184944: 34020001 ori r2,r0,0x0001                 |{{f/std|<nowiki>r2 = 0x01 (returned)</nowiki>}}
 +
  00184948: a0710003 sb r17,0x0003(r3)               |{{f/store|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)

Latest revision as of 20:46, 24 March 2022

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)