Advertisement
Kaphotics

Gen7 Crit Rate

Jan 16th, 2018
3,062
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.63 KB | None | 0 0
  1. bool __fastcall calcIsCrit(unsigned int stage, int affectionAmp)
  2. {
  3.   unsigned int chance; // r1
  4.   bool isCrit; // r0
  5.  
  6.   if ( stage >= 4 ) // bad, out of range for table
  7.   {
  8.     (gfl2::debug::GFLassert)(0, 0, 0, 0);
  9.     isCrit = 0;
  10.   }
  11.   else // good
  12.   {
  13.     chance = (critChanceTable[stage] / affectionAmp);
  14.     if ( !chance ) // 0
  15.       chance = 1; // ensure >0 for so we don't % by 0 in the event of 255 affection
  16.     isCrit = gfl2::math::SFMTRandom::Next(dword_313B9C4, chance) == 0; // crit if (rand % n == 0)
  17.   }
  18.   return isCrit;
  19. }
  20.  
  21. // Battle.rodata:~~~ critChanceTable    DCB 24, 8, 2, 1 // with 0xFF affection, divide by 2
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement