Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function powerOf2AndAHalf(value) {
- value = Math.fround(value);
- let F32 = new Float32Array(3);
- const sqrt = 0;
- const square = 1;
- const result = 2;
- F32[sqrt] = Math.sqrt(value);
- F32[square] = value * value;
- F32[result] = F32[square] * F32[sqrt];
- return F32[result];
- }
- function scaleExp(baseExpInt, levelInt, foeLevelInt) {
- let F32 = new Float32Array(7);
- const baseExp = 0;
- const level = 1;
- const foeLevel = 2;
- const numerator = 3;
- const denominator = 4;
- const ratio = 5;
- const result = 6;
- F32[baseExp] = baseExpInt;
- F32[level] = levelInt;
- F32[foeLevel] = foeLevelInt;
- F32[foeLevel] = foeLevelInt;
- F32[numerator] = F32[foeLevel] * Math.fround(2.0) + Math.fround(10.0);
- F32[denominator] = F32[foeLevel] + F32[level] + Math.fround(10.0);
- F32[numerator] = powerOf2AndAHalf(F32[numerator]);
- F32[denominator] = powerOf2AndAHalf(F32[denominator]);
- F32[ratio] = F32[numerator] / F32[denominator];
- F32[result] = Math.fround(F32[baseExp] * F32[ratio]) + Math.fround(1);
- return Math.floor(F32[result]);
- }
- function FX32(x) {
- return Math.floor(x * (1 << 12) + 0.5);
- }
- function mulRatio(a, b) {
- return Math.floor((a * b + 0x800) >> 12);
- }
- function getExperienceForKill(expYield, foeLevel, level, luckyEgg, affection, rotoExp, expShare, tradeExp, evolutionDue, expScaling, bonusForTrainer, wild) {
- let exp = 0;
- if (expScaling) {
- let baseExp = Math.floor(expYield * foeLevel / 5);
- if (baseExp === 0) {
- baseExp = 1;
- }
- if (expShare) {
- exp = Math.floor(baseExp / 2);
- if (exp === 0) {
- exp = 1;
- }
- } else {
- exp = baseExp;
- }
- exp = scaleExp(baseExp, level, foeLevel);
- } else {
- exp = Math.floor(expYield * foeLevel / 7);
- }
- if (bonusForTrainer && !wild) {
- exp = mulRatio(exp, FX32(1.5));
- }
- if (tradeExp) {
- exp = mulRatio(exp, FX32(1.5));
- }
- if (luckyEgg) {
- exp = mulRatio(exp, FX32(1.5));
- }
- if (evolutionDue) {
- exp = mulRatio(exp, FX32(1.2));
- }
- if (affection) {
- exp = mulRatio(exp, FX32(1.2));
- }
- if (rotoExp) {
- exp = Math.floor((exp * 150) / 100);
- }
- return Math.floor(exp);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement