From 5c30f5cfdd2116d4bec2db16e65ee0b0e9a5a681 Mon Sep 17 00:00:00 2001 From: RedstonewolfX <108761527+RedstonewolfX@users.noreply.github.com> Date: Tue, 24 Sep 2024 18:37:51 -0400 Subject: [PATCH] Prevent shinies from altering runs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Places variant rolls inside of an ExecuteWithSeedOffset block, using the current floor's RNG seed as the seed and the Pokémon's ID as the offset. --- src/field/pokemon.ts | 9 ++++++--- src/modifier/modifier-type.ts | 4 ++-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/field/pokemon.ts b/src/field/pokemon.ts index 14f93809414..c58be8a23d6 100644 --- a/src/field/pokemon.ts +++ b/src/field/pokemon.ts @@ -1913,10 +1913,13 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { if (!this.shiny || (!variantData.hasOwnProperty(variantDataIndex) && !variantData.hasOwnProperty(this.species.speciesId))) { return 0; } - const rand = Utils.randSeedInt(10); - if (rand >= 4) { + const rand = new Utils.IntegerHolder(0); + this.scene.executeWithSeedOffset(() => { + rand.value = Utils.randSeedInt(10); + }, this.id, this.scene.waveSeed); + if (rand.value >= 4) { return 0; // 6/10 - } else if (rand >= 1) { + } else if (rand.value >= 1) { return 1; // 3/10 } else { return 2; // 1/10 diff --git a/src/modifier/modifier-type.ts b/src/modifier/modifier-type.ts index bf12b2fda27..20e1cadeb22 100644 --- a/src/modifier/modifier-type.ts +++ b/src/modifier/modifier-type.ts @@ -2448,9 +2448,9 @@ export class ModifierTypeOption { */ export function getPartyLuckValue(party: Pokemon[]): integer { if (party[0].scene.gameMode.isDaily) { - let DailyLuck: integer = 0; + const DailyLuck = new Utils.IntegerHolder(0); party[0].scene.executeWithSeedOffset(() => { - DailyLuck = Utils.randSeedInt(15); // Random number between 0 and 14 + DailyLuck.value = Utils.randSeedInt(15); // Random number between 0 and 14 }, 0, party[0].scene.seed); return DailyLuck; }