From 3e932ce2d085238d45a536678d063cc82e353b83 Mon Sep 17 00:00:00 2001 From: Tempoanon <163687446+Tempo-anon@users.noreply.github.com> Date: Thu, 30 May 2024 16:20:27 -0400 Subject: [PATCH] Shinylock uncatchable Pokemon in endless mode (#1252) * Shinylock uncatchable Pokemon * Fix typos * Pass the linter vibe check * Remove 2 shinylock cases * refactor --- src/field/pokemon.ts | 34 ++++++++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 6 deletions(-) diff --git a/src/field/pokemon.ts b/src/field/pokemon.ts index 55a8091f857..37e8fcf9eca 100644 --- a/src/field/pokemon.ts +++ b/src/field/pokemon.ts @@ -1222,7 +1222,22 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { } } + /** + * Function that tries to set a Pokemon shiny based on the trainer's trainer ID and secret ID + * Endless Pokemon in the end biome are unable to be set to shiny + * + * The exact mechanic is that it calculates E as the XOR of the player's trainer ID and secret ID + * F is calculated as the XOR of the first 16 bits of the Pokemon's ID with the last 16 bits + * The XOR of E and F are then compared to the thresholdOverride (default case 32) to see whether or not to generate a shiny + * @param thresholdOverride number that is divided by 2^16 (65536) to get the shiny chance + * @returns true if the Pokemon has been set as a shiny, false otherwise + */ trySetShiny(thresholdOverride?: integer): boolean { + // Shiny Pokemon should not spawn in the end biome in endless + if (this.scene.gameMode.isEndless && this.scene.arena.biomeType === Biome.END) { + return false; + } + const rand1 = Utils.binToDec(Utils.decToBin(this.id).substring(0, 16)); const rand2 = Utils.binToDec(Utils.decToBin(this.id).substring(16, 32)); @@ -1250,18 +1265,25 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { return this.shiny; } + /** + * Generates a variant + * Has a 10% of returning 2 (epic variant) + * And a 20% of returning 1 (rare variant) + * Returns 0 (basic shiny) if there is no variant or 70% of the time otherwise + * @returns the shiny variant + */ generateVariant(): Variant { if (!this.shiny || !variantData.hasOwnProperty(this.species.speciesId)) { return 0; } const rand = Utils.randSeedInt(10); - if (rand > 3) { - return 0; + if (rand >= 3) { + return 0; // 7/10 + } else if (rand >= 1) { + return 1; // 2/10 + } else { + return 2; // 1/10 } - if (rand) { - return 1; - } - return 2; } generateFusionSpecies(forStarter?: boolean): void {