diff --git a/src/field/pokemon.ts b/src/field/pokemon.ts index c970c99e7d3..8594d5b769b 100644 --- a/src/field/pokemon.ts +++ b/src/field/pokemon.ts @@ -1527,13 +1527,14 @@ 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 + * 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 + * 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 {@linkcode shinyThreshold} (or {@linkcode thresholdOverride} if set) to see whether or not to generate a shiny. + * The base shiny odds are {@linkcode baseShinyChance} / 65536 + * @param thresholdOverride number that is divided by 2^16 (65536) to get the shiny chance, overrides {@linkcode shinyThreshold} if set (bypassing shiny rate modifiers such as Shiny Charm) * @returns true if the Pokemon has been set as a shiny, false otherwise */ trySetShiny(thresholdOverride?: integer): boolean { @@ -1548,7 +1549,9 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { const E = this.scene.gameData.trainerId ^ this.scene.gameData.secretId; const F = rand1 ^ rand2; - const shinyThreshold = new Utils.IntegerHolder(32); + /** `64/65536 -> 1/1024` */ + const baseShinyChance = 64; + const shinyThreshold = new Utils.IntegerHolder(baseShinyChance); if (thresholdOverride === undefined) { if (this.scene.eventManager.isEventActive()) { shinyThreshold.value *= this.scene.eventManager.getShinyMultiplier(); @@ -1561,9 +1564,6 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { } this.shiny = (E ^ F) < shinyThreshold.value; - if ((E ^ F) < 32) { - console.log("REAL SHINY!!"); - } if (this.shiny) { this.initShinySparkle(); diff --git a/src/modifier/modifier.ts b/src/modifier/modifier.ts index 99f4540f493..ca0b18ce18b 100644 --- a/src/modifier/modifier.ts +++ b/src/modifier/modifier.ts @@ -12,7 +12,7 @@ import { getPokemonNameWithAffix } from "../messages"; import * as Utils from "../utils"; import { TempBattleStat } from "../data/temp-battle-stat"; import { getBerryEffectFunc, getBerryPredicate } from "../data/berry"; -import { BattlerTagType} from "#enums/battler-tag-type"; +import { BattlerTagType } from "#enums/battler-tag-type"; import { BerryType } from "#enums/berry-type"; import { StatusEffect, getStatusEffectHealText } from "../data/status-effect"; import { achvs } from "../system/achv"; @@ -2193,7 +2193,7 @@ export class ShinyRateBoosterModifier extends PersistentModifier { } apply(args: any[]): boolean { - (args[0] as Utils.IntegerHolder).value *= Math.pow(2, 2 + this.getStackCount()); + (args[0] as Utils.IntegerHolder).value *= Math.pow(2, 1 + this.getStackCount()); return true; }