Advertisement
wartab

Untitled

Nov 21st, 2020 (edited)
1,072
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function powerOf2AndAHalf(value) {
  2.     value = Math.fround(value);
  3.     let F32 = new Float32Array(3);
  4.     const sqrt = 0;
  5.     const square = 1;
  6.     const result = 2;
  7.  
  8.     F32[sqrt] = Math.sqrt(value);
  9.     F32[square] = value * value;
  10.  
  11.     F32[result] = F32[square] * F32[sqrt];
  12.  
  13.     return F32[result];
  14. }
  15.  
  16. function scaleExp(baseExpInt, levelInt, foeLevelInt) {
  17.     let F32 = new Float32Array(7);
  18.     const baseExp = 0;
  19.     const level = 1;
  20.     const foeLevel = 2;
  21.     const numerator = 3;
  22.     const denominator = 4;
  23.     const ratio = 5;
  24.     const result = 6;
  25.  
  26.     F32[baseExp] = baseExpInt;
  27.     F32[level] = levelInt;
  28.     F32[foeLevel] = foeLevelInt;
  29.  
  30.     F32[foeLevel] = foeLevelInt;
  31.  
  32.  
  33.     F32[numerator] = F32[foeLevel] * Math.fround(2.0) + Math.fround(10.0);
  34.     F32[denominator] = F32[foeLevel] + F32[level] + Math.fround(10.0);
  35.  
  36.     F32[numerator] = powerOf2AndAHalf(F32[numerator]);
  37.     F32[denominator] = powerOf2AndAHalf(F32[denominator]);
  38.  
  39.     F32[ratio] = F32[numerator] / F32[denominator];
  40.     F32[result] = Math.fround(F32[baseExp] * F32[ratio]) + Math.fround(1);
  41.  
  42.     return Math.floor(F32[result]);
  43. }
  44.  
  45. function FX32(x) {
  46.     return Math.floor(x * (1 << 12) + 0.5);
  47. }
  48.  
  49. function mulRatio(a, b) {
  50.     return Math.floor((a * b + 0x800) >> 12);
  51. }
  52.  
  53. function getExperienceForKill(expYield, foeLevel, level, luckyEgg, affection, rotoExp, expShare, tradeExp, evolutionDue, expScaling, bonusForTrainer, wild) {
  54.  
  55.     let exp = 0;
  56.  
  57.     if (expScaling) {
  58.  
  59.         let baseExp = Math.floor(expYield * foeLevel / 5);
  60.         if (baseExp === 0) {
  61.             baseExp = 1;
  62.         }
  63.  
  64.         if (expShare) {
  65.             exp = Math.floor(baseExp / 2);
  66.             if (exp === 0) {
  67.                 exp = 1;
  68.             }
  69.         } else {
  70.             exp = baseExp;
  71.         }
  72.  
  73.  
  74.         exp = scaleExp(baseExp, level, foeLevel);
  75.  
  76.     } else {
  77.         exp = Math.floor(expYield * foeLevel / 7);
  78.     }
  79.  
  80.  
  81.     if (bonusForTrainer && !wild) {
  82.         exp = mulRatio(exp, FX32(1.5));
  83.     }
  84.  
  85.     if (tradeExp) {
  86.         exp = mulRatio(exp, FX32(1.5));
  87.     }
  88.  
  89.     if (luckyEgg) {
  90.         exp = mulRatio(exp, FX32(1.5));
  91.     }
  92.  
  93.     if (evolutionDue) {
  94.         exp = mulRatio(exp, FX32(1.2));
  95.     }
  96.  
  97.     if (affection) {
  98.         exp = mulRatio(exp, FX32(1.2));
  99.     }
  100.  
  101.     if (rotoExp) {
  102.         exp = Math.floor((exp * 150) / 100);
  103.     }
  104.  
  105.     return Math.floor(exp);
  106. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement