Advertisement
Kaphotics

nest ball

Mar 2nd, 2018
968
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.29 KB | None | 0 0
  1. // switch case case 8: Nest Ball
  2. // moon: sub_701854
  3. // UM: sub_302DCEC
  4. // returns catch rate modifier value (x * 0x1000)
  5. int getRate(int v8)
  6. {
  7.     int v9;
  8.     float v10;
  9.     if ( v8 >= 30u ) // this results in level 30 being less than the calculated value
  10.         return 0x1000;
  11.     v9 = (41 - v8); // diff
  12.     if ( v9 <= 40 )
  13.     {
  14.         if ( v9 == 0 ) // only if lvl = 41, which is not realistically possible
  15.         {
  16.             v10 = -0.5f;
  17.             goto LABEL_30;
  18.         }
  19.     }
  20.     else
  21.     {
  22.         v9 = 40; // clamp to 40, this should never realistically happen, 41-[1,29] = [40-12]
  23.     }
  24.     v10 = (v9 << 12) + 0.5f; // v9*0x1000, add round-up bias
  25.     LABEL_30:
  26.     var result = (((long)(0x66666667L * v10) >> 32) >> 2) - (((long)(0x66666667L * v10) >> 32) >> 31); // divide by 10 with magic mult
  27.    
  28.     return (int)result;
  29. }
  30.  
  31. // Output all rates for all equations (code, bulba g6, bulba g7-sm)
  32. void Main()
  33. {
  34.     for (int i = 1; i <= 30; i++)
  35.     {
  36.         string g6 = $"{(41 - i)/10f:0.0}";
  37.         string g7 = $"{(8 - (i-1)*0.2d):0.0}";
  38.         int rate = getRate(i);
  39.         Console.WriteLine($"LVL {i:00} = 0x{rate:X4} = {rate/(float)0x1000:0.0} || {g6} | {g7}");
  40.     }
  41. }
  42.  
  43. =======================================================
  44.  
  45. LVL 01 = 0x4000 = 4.0 || 4.0 | 8.0
  46. LVL 02 = 0x3E66 = 3.9 || 3.9 | 7.8
  47. LVL 03 = 0x3CCC = 3.8 || 3.8 | 7.6
  48. LVL 04 = 0x3B33 = 3.7 || 3.7 | 7.4
  49. LVL 05 = 0x3999 = 3.6 || 3.6 | 7.2
  50. LVL 06 = 0x3800 = 3.5 || 3.5 | 7.0
  51. LVL 07 = 0x3666 = 3.4 || 3.4 | 6.8
  52. LVL 08 = 0x34CC = 3.3 || 3.3 | 6.6
  53. LVL 09 = 0x3333 = 3.2 || 3.2 | 6.4
  54. LVL 10 = 0x3199 = 3.1 || 3.1 | 6.2
  55. LVL 11 = 0x3000 = 3.0 || 3.0 | 6.0
  56. LVL 12 = 0x2E66 = 2.9 || 2.9 | 5.8
  57. LVL 13 = 0x2CCC = 2.8 || 2.8 | 5.6
  58. LVL 14 = 0x2B33 = 2.7 || 2.7 | 5.4
  59. LVL 15 = 0x2999 = 2.6 || 2.6 | 5.2
  60. LVL 16 = 0x2800 = 2.5 || 2.5 | 5.0
  61. LVL 17 = 0x2666 = 2.4 || 2.4 | 4.8
  62. LVL 18 = 0x24CC = 2.3 || 2.3 | 4.6
  63. LVL 19 = 0x2333 = 2.2 || 2.2 | 4.4
  64. LVL 20 = 0x2199 = 2.1 || 2.1 | 4.2
  65. LVL 21 = 0x2000 = 2.0 || 2.0 | 4.0
  66. LVL 22 = 0x1E66 = 1.9 || 1.9 | 3.8
  67. LVL 23 = 0x1CCC = 1.8 || 1.8 | 3.6
  68. LVL 24 = 0x1B33 = 1.7 || 1.7 | 3.4
  69. LVL 25 = 0x1999 = 1.6 || 1.6 | 3.2
  70. LVL 26 = 0x1800 = 1.5 || 1.5 | 3.0
  71. LVL 27 = 0x1666 = 1.4 || 1.4 | 2.8
  72. LVL 28 = 0x14CC = 1.3 || 1.3 | 2.6
  73. LVL 29 = 0x1333 = 1.2 || 1.2 | 2.4
  74. LVL 30 = 0x1000 = 1.0 || 1.1 | 2.2 // Due to the <= 30 check returning 0x1000, the is the only difference from the noted equation
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement