Difference between revisions of "Critical Hit Calculation"

From Final Fantasy Hacktics Wiki
Jump to navigation Jump to search
(Fixing misread of a hex number)
m
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
  Critical Hit Calculation:
+
  No Parameters  - Returns nothing
  001864f8: 27bdffe0 addiu r29,r29,0xffe0
+
 
  001864fc: afbf0018 sw r31,0x0018(r29)
+
Roll critical Hit (4%)
  00186500: 34040064 ori r4,r0,0x0064 r4 = 100 (creates random number from 0-99)
+
  - If Successful : Increase XA (to a random from 100% to 200% of initial value)
  00186504: 0c063bb6 jal 0x0018eed8 [[Random Process]] (returns r2 = 0 or  1)
+
  - Knock Target back if possible
  00186508: 34050004 ori r5,r0,0x0004 r5 = 4 (critical hit chance of 4/100, or 4%)
+
--------------------------------------------------------------------------------------
  0018650c: 14400012 bne r2,r0,0x00186558 Branch if Critical did not occur
+
  001864f8: 27bdffe0 addiu r29,r29,-0x0020    |
  00186510: 34030001 ori r3,r0,0x0001 r3 = 1
+
  001864fc: afbf0018 sw r31,0x0018(r29)       |
  00186514: 3c028019 lui r2,0x8019
+
  00186500: 34040064 ori r4,r0,0x0064         |{{f/std|<nowiki>r4 = 0x64 (100)</nowiki>}}
  00186518: 8c422d90 lw r2,0x2d90(r2) Load Current Action Data Pointer
+
  00186504: 0c063bb6 jal 0x0018eed8           |{{f/jal|Random Process |Random Process }} Return r2 = 0x00 if Critical Hit
  0018651c: 0c063ba8 jal 0x0018eea0 [[Random Process, gives a number between 0-7fff]]
+
  00186508: 34050004 ori r5,r0,0x0004         |{{f/std|<nowiki>r5 = 0x04 </nowiki>}}
  00186520: a0430001 sb r3,0x0001(r2) Store Critical Hit Flag
+
  0018650c: 14400012 bne r2,r0,0x00186558     {{f/Cond|If Critical Hit}}
  00186524: 3c048019 lui r4,0x8019
+
  00186510: 34030001 ori r3,r0,0x0001         |{{f/std|<nowiki>r3 = 0x01</nowiki>}} {{f/std|<nowiki>r3 = 1</nowiki>}}
  00186528: 248438ce addiu r4,r4,0x38ce
+
  00186514: 3c028019 lui r2,0x8019               |
  0018652c: 84830000 lh r3,0x0000(r4) Load XA
+
  00186518: 8c422d90 lw r2,0x2d90(r2)             |{{f/adr|<nowiki>r2 = Target Current Action Data Pointer</nowiki>}}
  00186530: 00000000 nop
+
  0018651c: 0c063ba8 jal 0x0018eea0               |{{f/jal|Random Process, gives a number between 0-7fff|Random Process, gives a number between 0-7fff}} r2 = Value between 0x00 and 0x7fff
  00186534: 00430018 mult r2,r3 XA * Random
+
  00186520: a0430001 sb r3,0x0001(r2)             |{{f/store|Store Critical Hit Flag (TCA 0x01)}}
  00186538: 00001012 mflo r2 r2 = XA * Random
+
  00186524: 3c048019 lui r4,0x8019               |
  0018653c: 04410002 bgez r2,0x00186548 Branch if Random is >= 0
+
  00186528: 248438ce addiu r4,r4,0x38ce           |{{f/adr|<nowiki>r4 = Ability XA pointer</nowiki>}} {{f/std| 0x80198ce / 801938ce}}
  00186540: 00000000 nop
+
  0018652c: 84830000 lh r3,0x0000(r4)             |{{f/load|<nowiki>r3 = Ability XA</nowiki>}}
  00186544: 24427fff addiu r2,r2,0x7fff XA * Random + 7FFF
+
  00186530: 00000000 nop                         |
  00186548: 000213c3 sra r2,r2,0x0f XA * Random / 8000h
+
  00186534: 00430018 mult r2,r3                   |{{f/std|XA * Random}}
  0018654c: 00621021 addu r2,r3,r2 XA + XA * Random / 8000h (XA + Rand(0..(XA - 1)))
+
  00186538: 00001012 mflo r2                     |{{f/std|<nowiki>r2 = XA * Random</nowiki>}}
  00186550: 0c0610fb jal 0x001843ec [[Knockback Calculation]]
+
  0018653c: 04410002 bgez r2,0x00186548           {{f/Cond|If Random*XA < 0x00}}
  00186554: a4820000 sh r2,0x0000(r4) Store new XA
+
  00186540: 00000000 nop                             |
  00186558: 8fbf0018 lw r31,0x0018(r29)
+
  00186544: 24427fff addiu r2,r2,0x7fff               |{{f/std|<nowiki>r2 = Positive Random * XA</nowiki>}}
  0018655c: 27bd0020 addiu r29,r29,0x0020
+
  00186548: 000213c3 sra r2,r2,0x0f               |{{f/std|<nowiki>r2 = Random Between 0x00 and XA</nowiki>}} {{f/std| (XA * Random / Maximum possible random (0x8000))}}
  00186560: 03e00008 jr r31
+
  0018654c: 00621021 addu r2,r3,r2               |{{f/std|XA + Random (from 0x00 to XA)}}
 +
  00186550: 0c0610fb jal 0x001843ec               |{{f/jal|Knockback Calculation|Knockback Calculation}} Check Knockback usability - Set some flags if ok
 +
  00186554: a4820000 sh r2,0x0000(r4)             |{{f/store|Store new XA (100% to 200% of Initial XA)}}
 +
  00186558: 8fbf0018 lw r31,0x0018(r29)       END
 +
  0018655c: 27bd0020 addiu r29,r29,0x0020      
 +
  00186560: 03e00008 jr r31                    
 
  00186564: 00000000 nop
 
  00186564: 00000000 nop
 
+
=== Return location ===
 
+
'''Battle.bin'''
== Return Locations ==
+
  001886bc: [[Damage_Calculation]]
 
+
  00189d10: [[31 Dmg_((PA+Y)/2*PA)]]
*Battle.bin
+
  00189dac: [[32 Dmg_(Rdm(1…X)*(PA*3+Y))]]
  001886b4: [[Weapon Damage Calculation]]
 
  00189d08: [[31 Dmg_((PA+Y)/2*PA)]]
 
  00189da4: [[32 Dmg_(Rdm(1…X)*(PA*3+Y))]]
 

Latest revision as of 12:05, 3 April 2022

No Parameters  - Returns nothing
 
Roll critical Hit (4%)
  - If Successful : Increase XA (to a random from 100% to 200% of initial value)
  - Knock Target back if possible
--------------------------------------------------------------------------------------
001864f8: 27bdffe0 addiu r29,r29,-0x0020    |
001864fc: afbf0018 sw r31,0x0018(r29)       |
00186500: 34040064 ori r4,r0,0x0064         |r4 = 0x64 (100)
00186504: 0c063bb6 jal 0x0018eed8           |-->Random Process  Return r2 = 0x00 if Critical Hit
00186508: 34050004 ori r5,r0,0x0004         |r5 = 0x04 
0018650c: 14400012 bne r2,r0,0x00186558     #If Critical Hit
00186510: 34030001 ori r3,r0,0x0001         |r3 = 0x01 r3 = 1
00186514: 3c028019 lui r2,0x8019                |
00186518: 8c422d90 lw r2,0x2d90(r2)             |r2 = Target Current Action Data Pointer
0018651c: 0c063ba8 jal 0x0018eea0               |-->Random Process, gives a number between 0-7fff r2 = Value between 0x00 and 0x7fff
00186520: a0430001 sb r3,0x0001(r2)             |Store Critical Hit Flag (TCA 0x01)
00186524: 3c048019 lui r4,0x8019                |
00186528: 248438ce addiu r4,r4,0x38ce           |r4 = Ability XA pointer  0x80198ce / 801938ce
0018652c: 84830000 lh r3,0x0000(r4)             |r3 = Ability XA
00186530: 00000000 nop                          |
00186534: 00430018 mult r2,r3                   |XA * Random
00186538: 00001012 mflo r2                      |r2 = XA * Random
0018653c: 04410002 bgez r2,0x00186548           #If Random*XA < 0x00
00186540: 00000000 nop                              |
00186544: 24427fff addiu r2,r2,0x7fff               |r2 = Positive Random * XA
00186548: 000213c3 sra r2,r2,0x0f               |r2 = Random Between 0x00 and XA  (XA * Random / Maximum possible random (0x8000))
0018654c: 00621021 addu r2,r3,r2                |XA + Random (from 0x00 to XA)
00186550: 0c0610fb jal 0x001843ec               |-->Knockback Calculation Check Knockback usability - Set some flags if ok
00186554: a4820000 sh r2,0x0000(r4)             |Store new XA (100% to 200% of Initial XA)
00186558: 8fbf0018 lw r31,0x0018(r29)       END
0018655c: 27bd0020 addiu r29,r29,0x0020        
00186560: 03e00008 jr r31                      
00186564: 00000000 nop

Return location

Battle.bin
001886bc: Damage_Calculation
00189d10: 31 Dmg_((PA+Y)/2*PA)
00189dac: 32 Dmg_(Rdm(1…X)*(PA*3+Y))