From 5883c2fafd77c3c35209a9dce5049762e6e36b6e Mon Sep 17 00:00:00 2001 From: Flashfyre Date: Wed, 20 Dec 2023 13:05:11 -0500 Subject: [PATCH] Calculate IVs twice for hatched Pokemon to improve overall IVs --- src/egg-hatch-phase.ts | 14 ++++++++++++++ src/system/voucher.ts | 18 +++++++++--------- 2 files changed, 23 insertions(+), 9 deletions(-) diff --git a/src/egg-hatch-phase.ts b/src/egg-hatch-phase.ts index 047eb5ed4..910528e65 100644 --- a/src/egg-hatch-phase.ts +++ b/src/egg-hatch-phase.ts @@ -402,6 +402,20 @@ export class EggHatchPhase extends BattlePhase { } ret.trySetShiny(this.egg.gachaType === GachaType.SHINY ? 1024 : 512); + + this.scene.executeWithSeedOffset(() => { + const secondaryId = Utils.randSeedInt(4294967295); + const secondaryIvs = [ + Utils.binToDec(Utils.decToBin(secondaryId).substring(0, 5)), + Utils.binToDec(Utils.decToBin(secondaryId).substring(5, 10)), + Utils.binToDec(Utils.decToBin(secondaryId).substring(10, 15)), + Utils.binToDec(Utils.decToBin(secondaryId).substring(15, 20)), + Utils.binToDec(Utils.decToBin(secondaryId).substring(20, 25)), + Utils.binToDec(Utils.decToBin(secondaryId).substring(25, 30)) + ]; + for (let s = 0; s < ret.ivs.length; s++) + ret.ivs[s] = Math.max(ret.ivs[s], secondaryIvs[s]); + }, ret.id, EGG_SEED.toString()); return ret; } diff --git a/src/system/voucher.ts b/src/system/voucher.ts index 007ca0493..5df9f84cf 100644 --- a/src/system/voucher.ts +++ b/src/system/voucher.ts @@ -79,6 +79,15 @@ const voucherAchvs: Achv[] = [ achvs.CLASSIC_VICTORY ]; { (function() { + for (let achv of voucherAchvs) { + const voucherType = achv.score >= 150 + ? VoucherType.PREMIUM + : achv.score >= 75 + ? VoucherType.PLUS + : VoucherType.REGULAR; + vouchers[achv.id] = new Voucher(voucherType, achv.description); + } + const bossTrainerTypes = Object.keys(trainerConfigs) .filter(tt => trainerConfigs[tt].isBoss && trainerConfigs[tt].getDerivedType() !== TrainerType.RIVAL); @@ -90,15 +99,6 @@ const voucherAchvs: Achv[] = [ achvs.CLASSIC_VICTORY ]; vouchers[key] = new Voucher(voucherType, `Defeat ${trainerConfigs[trainerType].name}`); } - for (let achv of voucherAchvs) { - const voucherType = achv.score >= 150 - ? VoucherType.PREMIUM - : achv.score >= 100 - ? VoucherType.PLUS - : VoucherType.REGULAR; - vouchers[achv.id] = new Voucher(voucherType, achv.description); - } - const voucherKeys = Object.keys(vouchers); for (let k of voucherKeys) vouchers[k].id = k;