Difference between revisions of "Uses HP damage as Action hit%"

From Final Fantasy Hacktics Wiki
Jump to navigation Jump to search
m
 
(2 intermediate revisions by 2 users not shown)
Line 1: Line 1:
  Sets XA+YA as HitRate Routine
+
  No Parameters - Returns Nothing        '''Alternatives notes :''' [[Use_Specific_Action_Hit_Percentage]]
  00187510: 3c068019 lui r6,0x8019
+
  00187514: 8cc62d90 lw r6,0x2d90(r6) Load Current Action Data Pointer
+
Uses Target Current Action (TCA) HP damage as Ability Hit score (and clear HP damage in the process)
  00187518: 27bdffe8 addiu r29,r29,0xffe8
+
  - If TCA HP damage > 100 : skip the routine (Attack Hits)
  0018751c: afbf0010 sw r31,0x0010(r29)
+
  - Else
  00187520: 84c50004 lh r5,0x0004(r6) Load HitRate(r5) from "HP Damage" address
+
    - If Action state is not being executed (<> 0x00) : Modifiy TCA 0x2a (Hit%) to Hit score * Evasion% (Display Hit%)
  00187524: 00000000 nop
+
    - If Action is being executed : roll a random (0 to 100) against Hit score. If Attack miss, clear hit flag and set TCA evade type to 0x06
  00187528: 28a20064 slti r2,r5,0x0064 if HitRate < 100
+
Note : Evasion is ignored when rolling hit score vs random because Evasion roll is already done (sooner in formula)
  0018752c: 14400003 bne r2,r0,0x0018753c   then branch to 0x0018753c
+
-----------------------------------------------------------------------------
  00187530: 00000000 nop
+
  00187510: 3c068019 lui r6,0x8019           |
  00187534: 08061d6b j 0x001875ac
+
  00187514: 8cc62d90 lw r6,0x2d90(r6)         |{{f/adr|<nowiki>r6 = Target Current Action (TCA) data pointer</nowiki>}}
  00187538: a4c00004 sh r0,0x0004(r6) Store 0 in Action Data's HP Damage
+
  00187518: 27bdffe8 addiu r29,r29,-0x0018    |
  0018753c: 84c2002a lh r2,0x002a(r6) Load Action Data's "Hit % (Display data?)"(r2)
+
  0018751c: afbf0010 sw r31,0x0010(r29)       |
  00187540: 00000000 nop
+
  00187520: 84c50004 lh r5,0x0004(r6)         |{{f/load|<nowiki>r5 = TCA HP damage amount (will be used as Base Hit score)</nowiki>}}
  00187544: 00a20018 mult r5,r2 HitRate * r2
+
  00187524: 00000000 nop                     |
  00187548: 00001812 mflo r3   and store in r3
+
  00187528: 28a20064 slti r2,r5,0x0064       |{{f/std|<nowiki>r2 = 0x01 if HP damage < 100</nowiki>}}
  0018754c: 3c0251eb lui r2,0x51eb
+
  0018752c: 14400003 bne r2,r0,0x0018753c     {{f/Cond|<nowiki>If Hp damage >= 100</nowiki>}}
  00187550: 3442851f ori r2,r2,0x851f R2 = 51eb851f
+
  00187530: 00000000 nop                         |
  00187554: 00620018 mult r3,r2 R3 * .33333334
+
  00187534: 08061d6b j 0x001875ac                 {{f/jump|jump to END}} guaranteed Hit
  00187558: 3c048019 lui r4,0x8019
+
  00187538: a4c00004 sh r0,0x0004(r6)             |{{f/store|Nullify TCA's HP Damage}}
  0018755c: 8c84f5fc lw r4,0xf5fc(r4) Load 0xf5fc Action Flag(r4)
+
                                            {{f/Cond|Else (HP damage < 100)}}  Only for displaying a hit% taking evasion in account
  00187560: a4c00004 sh r0,0x0004(r6) Set "HP Damage" for this attack to 0
+
  0018753c: 84c2002a lh r2,0x002a(r6)         |{{f/load|<nowiki>r2 = TCA Hit% (for display, inherited from evades routines)</nowiki>}}
  00187564: 00031fc3 sra r3,r3,0x1f
+
  00187540: 00000000 nop                     |
  00187568: 00001010 mfhi r2
+
  00187544: 00a20018 mult r5,r2               |{{f/std|<nowiki>TCA Hit% * Base Hit score = TCA final Hit score</nowiki>}}
  0018756c: 00021143 sra r2,r2,0x05
+
  00187548: 00001812 mflo r3                 |{{f/std|<nowiki>r3 = TCA Final Hit score (Base Hit score and Evasion)</nowiki>}}
  00187570: 00431023 subu r2,r2,r3
+
  0018754c: 3c0251eb lui r2,0x51eb           |
  00187574: 10800003 beq r4,r0,0x00187584 Branch if Flag is not set
+
  00187550: 3442851f ori r2,r2,0x851f         |{{f/std|<nowiki>r2 = 0x51eb851f  (0,32*2^32)</nowiki>}}
  00187578: a4c2002a sh r2,0x002a(r6) store hit%
+
  00187554: 00620018 mult r3,r2               |{{f/std|TCA final Hit score * 0,32/2^32}}
  0018757c: 14a0000b bne r5,r0,0x001875ac
+
  00187558: 3c048019 lui r4,0x8019           |
  00187580: 00000000 nop
+
  0018755c: 8c84f5fc lw r4,-0x0a04(r4)       |{{f/adr|<nowiki>r4 = Action state (0x8018f5fc)</nowiki>}}
  00187584: 0c017833 jal 0x0005e0cc [[Check if Random is greater/equal to Chance|Set r2 if d100 gte r5]]
+
  00187560: a4c00004 sh r0,0x0004(r6)         |{{f/store|Nullify TCA Hp damage}}
  00187588: 34040064 ori r4,r0,0x0064   Delay slot. Set r4 to d100
+
  00187564: 00031fc3 sra r3,r3,0x1f           |{{f/std|<nowiki>r3 = Highest bit of TCA final Hit score (should be 0)</nowiki>}}
  0018758c: 10400007 beq r2,r0,0x001875ac attack hits?
+
  00187568: 00001010 mfhi r2                 |{{f/std|<nowiki>r2 = TCA final Hit score * 0,32</nowiki>}}
  00187590: 00000000 nop
+
  0018756c: 00021143 sra r2,r2,0x05           |{{f/std|<nowiki>r2 = TCA final Hit% (TCA final Hit score/100  (because Hit score is stored as 50 when 50%))</nowiki>}}
  00187594: 0c0610cf jal 0x0018433c Force Attack Miss routine?
+
  00187570: 00431023 subu r2,r2,r3           |{{f/std|<nowiki>r2 = TCA final Hit%</nowiki>}}
  00187598: 00000000 nop
+
  00187574: 10800003 beq r4,r0,0x00187584     {{f/Cond|If Action is not being executed }} (0x8018f5fc <>0x00)
  0018759c: 3c028019 lui r2,0x8019
+
  00187578: a4c2002a sh r2,0x002a(r6)             |{{f/store|Store TCA final hit% as TCA hit% (displayed data)}}
  001875a0: 8c422d90 lw r2,0x2d90(r2) Load Current Action Data Pointer
+
  0018757c: 14a0000b bne r5,r0,0x001875ac         {{f/Cond|<nowiki>If HP damage = 0x00 continues </nowiki>}} (to access force attack miss routine) / Else branch to END
  001875a4: 00000000 nop
+
  00187580: 00000000 nop                             |
  001875a8: a4400004 sh r0,0x0004(r2) Store 0 in Action Data's HP Damage
+
                                            {{f/Cond|Else (Action is being executed - or HP damage is 0)}}
  001875ac: 8fbf0010 lw r31,0x0010(r29)
+
  00187584: 0c017833 jal 0x0005e0cc           |{{f/jal|Check if Random is greater/equal to Chance|Check if Random is greater/equal to Chance}} Returns r2 = 0x00 if random between 0 and r4 is < r5 (Attack Hits)
  001875b0: 27bd0018 addiu r29,r29,0x0018
+
  00187588: 34040064 ori r4,r0,0x0064         |{{f/std|<nowiki>r4 = 100</nowiki>}}
  001875b4: 03e00008 jr r31
+
  0018758c: 10400007 beq r2,r0,0x001875ac     {{f/Cond|If Attack miss}}
 +
  00187590: 00000000 nop                         |
 +
  00187594: 0c0610cf jal 0x0018433c               |{{f/jal|Cause_Action_Miss|Cause_Action_Miss}} Set TCA hit flag to miss and TCA evade type = 0x06 (miss)
 +
  00187598: 00000000 nop                         |
 +
  0018759c: 3c028019 lui r2,0x8019               |
 +
  001875a0: 8c422d90 lw r2,0x2d90(r2)             |{{f/adr|<nowiki>r2 = TCA data pointer</nowiki>}}
 +
  001875a4: 00000000 nop                         |
 +
  001875a8: a4400004 sh r0,0x0004(r2)             |{{f/store|Nullify TCA's HP Damage}}
 +
  001875ac: 8fbf0010 lw r31,0x0010(r29)       END
 +
  001875b0: 27bd0018 addiu r29,r29,0x0018    
 +
  001875b4: 03e00008 jr r31                  
 
  001875b8: 00000000 nop
 
  001875b8: 00000000 nop
 +
=== Return locations ===
 +
'''Battle.bin'''
 +
001886f4: [[Routine_used_in_formula_2B]]
 +
00188830: [[MA_%2B_X]]
 +
0018893c: [[00188888_-_00188960|Golem Accuracy]]
 +
001889fc: [[Calculate_Accuracy_for_Magical_Spells]]
 +
00188a5c: [[Calculate_Accuracy_for_Magical]]
 +
00188ab4: [[MA_%2B_X_without_faith]]
 +
00188b3c: [[Physical_Routine_for_Hit_%25_abilities]]
 +
00189038: [[0E_Dmg_(Y)%25_Hit_F(MA%2BX)%25_100%25_Status_Hide_Status|Formula 0e : Dmg (Y)% Hit F(MA+X)% 100% Status Hide Status]]
 +
001892f4: [[1A_Hit_F(MA%2BY)%25_//_-PA/MA/SP_(X)]]
 +
001898c8: [[28_StealExp_(Lowest_of_TarCurExp_%26_SP%2BY)_Hit_(SP%2BX)%25|Formula 28 : StealExp (Lowest of TarCurExp & SP+Y) Hit (SP+X)%]]
 +
00189938: [[29_OppositeSex:_Hit_(MA%2BX)%25|Formula 29 : OppositeSex: Hit (MA+X)%]]
 +
00189a5c: [[2A_Hit_(MA%2BX)%25_//_AffectBraveOrFaith(Y)|Formula 2A : Hit (MA+X)% // AffectBraveOrFaith(Y)]]
 +
00189e60: [[33_Hit_(PA%2BX)%25|Formula 33 : Hit (PA+X)%]]
 +
00189f38: [[35_Heal_(Y)%25_Hit_(PA%2BX)%25|Formula 35 : Heal (Y)% Hit (PA+X)%]]
 +
0018a054: [[3F_Hit_(SP%2BX)%25|Formula 3f : Hit (SP+X)%]]
 +
0018a0b0: [[40_Undead:_Hit_(SP%2BX)%25|Formula 40 : Undead: Hit (SP+X)%]]
 +
0018a520: [[51_Hit_(MA%2BX)%25|Formula 51 : Hit (MA+X)%]]
 +
0018a85c: [[58_Generic:_Set_Morbol:_Hit(MA%2BX)%25|Formula 58 : Generic: Set Morbol: Hit(MA+X)%]]

Latest revision as of 19:00, 14 April 2022

No Parameters - Returns Nothing         Alternatives notes : Use_Specific_Action_Hit_Percentage

Uses Target Current Action (TCA) HP damage as Ability Hit score (and clear HP damage in the process)
 - If TCA HP damage > 100 : skip the routine (Attack Hits)
 - Else 
    - If Action state is not being executed (<> 0x00) : Modifiy TCA 0x2a (Hit%) to Hit score * Evasion% (Display Hit%)
    - If Action is being executed : roll a random (0 to 100) against Hit score. If Attack miss, clear hit flag and set TCA evade type to 0x06
Note : Evasion is ignored when rolling hit score vs random because Evasion roll is already done (sooner in formula)
-----------------------------------------------------------------------------
00187510: 3c068019 lui r6,0x8019            |
00187514: 8cc62d90 lw r6,0x2d90(r6)         |r6 = Target Current Action (TCA) data pointer
00187518: 27bdffe8 addiu r29,r29,-0x0018    |
0018751c: afbf0010 sw r31,0x0010(r29)       |
00187520: 84c50004 lh r5,0x0004(r6)         |r5 = TCA HP damage amount (will be used as Base Hit score)
00187524: 00000000 nop                      |
00187528: 28a20064 slti r2,r5,0x0064        |r2 = 0x01 if HP damage < 100
0018752c: 14400003 bne r2,r0,0x0018753c     #If Hp damage >= 100
00187530: 00000000 nop                          |
00187534: 08061d6b j 0x001875ac                 >>jump to END guaranteed Hit
00187538: a4c00004 sh r0,0x0004(r6)             |Nullify TCA's HP Damage
                                            #Else (HP damage < 100)  Only for displaying a hit% taking evasion in account
0018753c: 84c2002a lh r2,0x002a(r6)         |r2 = TCA Hit% (for display, inherited from evades routines)
00187540: 00000000 nop                      |
00187544: 00a20018 mult r5,r2               |TCA Hit% * Base Hit score = TCA final Hit score
00187548: 00001812 mflo r3                  |r3 = TCA Final Hit score (Base Hit score and Evasion)
0018754c: 3c0251eb lui r2,0x51eb            |
00187550: 3442851f ori r2,r2,0x851f         |r2 = 0x51eb851f  (0,32*2^32)
00187554: 00620018 mult r3,r2               |TCA final Hit score * 0,32/2^32
00187558: 3c048019 lui r4,0x8019            |
0018755c: 8c84f5fc lw r4,-0x0a04(r4)        |r4 = Action state (0x8018f5fc)
00187560: a4c00004 sh r0,0x0004(r6)         |Nullify TCA Hp damage
00187564: 00031fc3 sra r3,r3,0x1f           |r3 = Highest bit of TCA final Hit score (should be 0)
00187568: 00001010 mfhi r2                  |r2 = TCA final Hit score * 0,32
0018756c: 00021143 sra r2,r2,0x05           |r2 = TCA final Hit% (TCA final Hit score/100  (because Hit score is stored as 50 when 50%))
00187570: 00431023 subu r2,r2,r3            |r2 = TCA final Hit%
00187574: 10800003 beq r4,r0,0x00187584     #If Action is not being executed  (0x8018f5fc <>0x00)
00187578: a4c2002a sh r2,0x002a(r6)             |Store TCA final hit% as TCA hit% (displayed data)
0018757c: 14a0000b bne r5,r0,0x001875ac         #If HP damage = 0x00 continues  (to access force attack miss routine) / Else branch to END
00187580: 00000000 nop                              |
                                            #Else (Action is being executed - or HP damage is 0)
00187584: 0c017833 jal 0x0005e0cc           |-->Check if Random is greater/equal to Chance Returns r2 = 0x00 if random between 0 and r4 is < r5 (Attack Hits)
00187588: 34040064 ori r4,r0,0x0064         |r4 = 100
0018758c: 10400007 beq r2,r0,0x001875ac     #If Attack miss
00187590: 00000000 nop                          |
00187594: 0c0610cf jal 0x0018433c               |-->Cause_Action_Miss Set TCA hit flag to miss and TCA evade type = 0x06 (miss)
00187598: 00000000 nop                          |
0018759c: 3c028019 lui r2,0x8019                |
001875a0: 8c422d90 lw r2,0x2d90(r2)             |r2 = TCA data pointer
001875a4: 00000000 nop                          |
001875a8: a4400004 sh r0,0x0004(r2)             |Nullify TCA's HP Damage
001875ac: 8fbf0010 lw r31,0x0010(r29)       END
001875b0: 27bd0018 addiu r29,r29,0x0018     
001875b4: 03e00008 jr r31                   
001875b8: 00000000 nop

Return locations

Battle.bin
001886f4: Routine_used_in_formula_2B
00188830: MA_+_X
0018893c: Golem Accuracy
001889fc: Calculate_Accuracy_for_Magical_Spells
00188a5c: Calculate_Accuracy_for_Magical
00188ab4: MA_+_X_without_faith
00188b3c: Physical_Routine_for_Hit_%_abilities
00189038: Formula 0e : Dmg (Y)% Hit F(MA+X)% 100% Status Hide Status
001892f4: 1A_Hit_F(MA+Y)%_//_-PA/MA/SP_(X)
001898c8: Formula 28 : StealExp (Lowest of TarCurExp & SP+Y) Hit (SP+X)%
00189938: Formula 29 : OppositeSex: Hit (MA+X)%
00189a5c: Formula 2A : Hit (MA+X)% // AffectBraveOrFaith(Y)
00189e60: Formula 33 : Hit (PA+X)%
00189f38: Formula 35 : Heal (Y)% Hit (PA+X)%
0018a054: Formula 3f : Hit (SP+X)%
0018a0b0: Formula 40 : Undead: Hit (SP+X)%
0018a520: Formula 51 : Hit (MA+X)%
0018a85c: Formula 58 : Generic: Set Morbol: Hit(MA+X)%