Difference between revisions of "0005e0cc"

From Final Fantasy Hacktics Wiki
Jump to navigation Jump to search
m (formatting and stuff)
m (rewrite)
Line 1: Line 1:
Checking if Attack Hits?
+
General random chance function. Randomly returns False r5/r4 of the time.
  
 
Args:
 
Args:
  
* r4: Base Hit%
+
* r4 = number of sides on the die
* r5: Evade%
+
* r5 = target to beat
  
 
  0005e0cc: 27bdffe0 addiu r29,r29,0xffe0
 
  0005e0cc: 27bdffe0 addiu r29,r29,0xffe0
 
  0005e0d0: afb00010 sw r16,0x0010(r29)
 
  0005e0d0: afb00010 sw r16,0x0010(r29)
  0005e0d4: 00808021 addu r16,r4,r0          r16 = Base Hit%
+
  0005e0d4: 00808021 addu r16,r4,r0          r16 = Sides
 
  0005e0d8: afb10014 sw r17,0x0014(r29)
 
  0005e0d8: afb10014 sw r17,0x0014(r29)
 
  0005e0dc: afbf0018 sw r31,0x0018(r29)
 
  0005e0dc: afbf0018 sw r31,0x0018(r29)
  0005e0e0: 0c0088c3 jal 0x[[0002230c]]          r2 = rand 0x0..0x7fff
+
  0005e0e0: 0c0088c3 jal 0x[[0002230c]]          r2 = 0..7fffh
  0005e0e4: 00a08821 addu r17,r5,r0          r17 = Evade%
+
  0005e0e4: 00a08821 addu r17,r5,r0          r17 = Target
  0005e0e8: 00500018 mult r2,r16              Random * Base Hit%
+
  0005e0e8: 00500018 mult r2,r16              r2 = Sides * 0..7fffh
  0005e0ec: 00001012 mflo r2
+
  0005e0ec: 00001012 mflo r2                 ^
  0005e0f0: 04410002 bgez r2,0x0005e0fc      if result <= 0:
+
  0005e0f0: 04410002 bgez r2,0x0005e0fc      if r2 < 0:
 
  0005e0f4: 00000000 nop
 
  0005e0f4: 00000000 nop
  0005e0f8: 24427fff addiu r2,r2,0x7fff          Make result positive
+
  0005e0f8: 24427fff addiu r2,r2,0x7fff          r2 += 7fffh    //make positive
  0005e0fc: 000213c3 sra r2,r2,0x0f          Result / 8000h   //r2 = floatrand 0...1
+
  0005e0fc: 000213c3 sra r2,r2,0x0f          r2 = r2 / 8000h     // = 0..(Sides - 1)
  0005e100: 0051102a slt r2,r2,r17
+
  0005e100: 0051102a slt r2,r2,r17           rv = 0..(Sides - 1) <  Target
  0005e104: 38420001 xori r2,r2,0x0001        r2 = 1 if Result >= Evade%
+
  0005e104: 38420001 xori r2,r2,0x0001        rv = 0..(Sides - 1) >= Target
Evade%
 
 
  0005e108: 8fbf0018 lw r31,0x0018(r29)
 
  0005e108: 8fbf0018 lw r31,0x0018(r29)
 
  0005e10c: 8fb10014 lw r17,0x0014(r29)
 
  0005e10c: 8fb10014 lw r17,0x0014(r29)
 
  0005e110: 8fb00010 lw r16,0x0010(r29)
 
  0005e110: 8fb00010 lw r16,0x0010(r29)
 
  0005e114: 27bd0020 addiu r29,r29,0x0020
 
  0005e114: 27bd0020 addiu r29,r29,0x0020
  0005e118: 03e00008 jr r31
+
  0005e118: 03e00008 jr r31                 return 0..(Sides - 1) >= Target
 
  0005e11c: 00000000 nop
 
  0005e11c: 00000000 nop

Revision as of 00:33, 8 February 2016

General random chance function. Randomly returns False r5/r4 of the time.

Args:

  • r4 = number of sides on the die
  • r5 = target to beat
0005e0cc: 27bdffe0 addiu r29,r29,0xffe0
0005e0d0: afb00010 sw r16,0x0010(r29)
0005e0d4: 00808021 addu r16,r4,r0           r16 = Sides
0005e0d8: afb10014 sw r17,0x0014(r29)
0005e0dc: afbf0018 sw r31,0x0018(r29)
0005e0e0: 0c0088c3 jal 0x0002230c           r2 = 0..7fffh
0005e0e4: 00a08821 addu r17,r5,r0           r17 = Target
0005e0e8: 00500018 mult r2,r16              r2 = Sides * 0..7fffh
0005e0ec: 00001012 mflo r2                  ^
0005e0f0: 04410002 bgez r2,0x0005e0fc       if r2 < 0:
0005e0f4: 00000000 nop
0005e0f8: 24427fff addiu r2,r2,0x7fff           r2 += 7fffh     //make positive
0005e0fc: 000213c3 sra r2,r2,0x0f           r2 = r2 / 8000h      // = 0..(Sides - 1)
0005e100: 0051102a slt r2,r2,r17            rv = 0..(Sides - 1) <  Target
0005e104: 38420001 xori r2,r2,0x0001        rv = 0..(Sides - 1) >= Target
0005e108: 8fbf0018 lw r31,0x0018(r29)
0005e10c: 8fb10014 lw r17,0x0014(r29)
0005e110: 8fb00010 lw r16,0x0010(r29)
0005e114: 27bd0020 addiu r29,r29,0x0020
0005e118: 03e00008 jr r31                  return 0..(Sides - 1) >= Target
0005e11c: 00000000 nop