Difference between revisions of "Use Specific Action Hit Percentage"

From Final Fantasy Hacktics Wiki
Jump to navigation Jump to search
m
m
Line 26: Line 26:
 
  80187564: 00031fc3 sra r3,r3,0x1f       
 
  80187564: 00031fc3 sra r3,r3,0x1f       
 
  80187568: 00001010 mfhi r2                    #  action.HPDamage * action.HitPercentage * 0.32
 
  80187568: 00001010 mfhi r2                    #  action.HPDamage * action.HitPercentage * 0.32
  8018756c: 00021143 sra r2,r2,0x05              #  action.HPDamage * action.HitPercentage / 100   (action.HPDamage * action.HitPercentage * 0.32 / 32)
+
  8018756c: 00021143 sra r2,r2,0x05              #  action.HPDamage * action.HitPercentage / 100 (See Notes)
 
  80187570: 00431023 subu r2,r2,r3       
 
  80187570: 00431023 subu r2,r2,r3       
 
  80187574: 10800003 beq r4,r0,0x80187584         
 
  80187574: 10800003 beq r4,r0,0x80187584         
Line 46: Line 46:
 
  801875b4: 03e00008 jr r31
 
  801875b4: 03e00008 jr r31
 
  801875b8: 00000000 nop
 
  801875b8: 00000000 nop
 +
 +
==Notes==
 +
Rather than using a div op, the code is actually doing
 +
HPDamage * HitPercentage * 0.32 / 32

Revision as of 05:44, 4 January 2021

ROUTINE: USE SPECIFIC ACTION HIT PERCENTAGE

This routine uses the value in the HP Damage field of the Action struct as a temporary Hit percentage value input and sets the Action to miss if it fails a random roll against the input percentage value. It also multiplies the input Hit percentage value into the Action's already calculated Hit Percentage (from evasion) to get an accurate displayed Hit % value.

80187510: 3c068019 lui r6,0x8019       
80187514: 8cc62d90 lw r6,0x2d90(r6)            #   action
80187518: 27bdffe8 addiu r29,r29,-0x0018        
8018751c: afbf0010 sw r31,0x0010(r29)      
80187520: 84c50004 lh r5,0x0004(r6)            #   action.HPDamage
80187524: 00000000 nop         
80187528: 28a20064 slti r2,r5,0x0064       
8018752c: 14400003 bne r2,r0,0x8018753c        #   if (action.HPDamage >= 100)
80187530: 00000000 nop             
80187534: 08061d6b j 0x801875ac            
80187538: a4c00004 sh r0,0x0004(r6)            #       action.HPDamage = 0
8018753c: 84c2002a lh r2,0x002a(r6)            #   action.HitPercentage
80187540: 00000000 nop             
80187544: 00a20018 mult r5,r2              
80187548: 00001812 mflo r3                     #   action.HPDamage * action.HitPercentage
8018754c: 3c0251eb lui r2,0x51eb       
80187550: 3442851f ori r2,r2,0x851f            #   0.32
80187554: 00620018 mult r3,r2                  #   action.HPDamage * action.HitPercentage * 0.32
80187558: 3c048019 lui r4,0x8019       
8018755c: 8c84f5fc lw r4,-0x0a04(r4)           #   actionConsiderationStatus
80187560: a4c00004 sh r0,0x0004(r6)            #   action.HPDamage = 0
80187564: 00031fc3 sra r3,r3,0x1f      
80187568: 00001010 mfhi r2                     #   action.HPDamage * action.HitPercentage * 0.32
8018756c: 00021143 sra r2,r2,0x05              #   action.HPDamage * action.HitPercentage / 100 (See Notes)
80187570: 00431023 subu r2,r2,r3       
80187574: 10800003 beq r4,r0,0x80187584        
80187578: a4c2002a sh r2,0x002a(r6)            #   action.HitPercentage = action.HPDamage * action.HitPercentage / 100
8018757c: 14a0000b bne r5,r0,0x801875ac        #   if ((actionConsiderationStatus == ACTION_EXECUTING) or (action.HPDamage >= 0))
80187580: 00000000 nop             
80187584: 0c017833 jal 0x0005e0cc              #       rollResult = Pass/Fail Roll (100, action.HPDamage);
80187588: 34040064 ori r4,r0,0x0064                   
8018758c: 10400007 beq r2,r0,0x801875ac        #       if (rollResult != 0)               // Action fails roll
80187590: 00000000 nop             
80187594: 0c0610cf jal 0x0018433c              #           Cause Action Miss ();
80187598: 00000000 nop             
8018759c: 3c028019 lui r2,0x8019       
801875a0: 8c422d90 lw r2,0x2d90(r2)            #           action
801875a4: 00000000 nop             
801875a8: a4400004 sh r0,0x0004(r2)            #           action.HPDamage = 0
801875ac: 8fbf0010 lw r31,0x0010(r29)
801875b0: 27bd0018 addiu r29,r29,0x0018
801875b4: 03e00008 jr r31
801875b8: 00000000 nop

Notes

Rather than using a div op, the code is actually doing

HPDamage * HitPercentage * 0.32 / 32