diff --git a/src/battle-scene.ts b/src/battle-scene.ts index ee910bd9697..ecaffc5ed07 100644 --- a/src/battle-scene.ts +++ b/src/battle-scene.ts @@ -37,7 +37,6 @@ import { PokemonHpRestoreModifier, PokemonIncrementingStatModifier, RememberMoveModifier, - ShinyRateBoosterModifier, } from "./modifier/modifier"; import { PokeballType } from "#enums/pokeball"; import { @@ -1290,17 +1289,6 @@ export default class BattleScene extends SceneBase { } } - /** - * Applies Shiny Charms and other modifiers to check the general shiny rate - * @returns The chance out of 65536 to get a shiny - */ - getModifiedShinyThreshold(): number { - const threshold = new NumberHolder(BASE_SHINY_CHANCE); - this.applyModifiers(ShinyRateBoosterModifier, true, threshold); - threshold.value *= timedEventManager.getShinyMultiplier(); - return threshold.value; - } - getDoubleBattleChance(newWaveIndex: number, playerField: PlayerPokemon[]) { const doubleChance = new NumberHolder(newWaveIndex % 10 === 0 ? 32 : 8); this.applyModifiers(DoubleBattleChanceBoosterModifier, true, doubleChance); diff --git a/src/data/mystery-encounters/encounters/the-pokemon-salesman-encounter.ts b/src/data/mystery-encounters/encounters/the-pokemon-salesman-encounter.ts index 5cdab9569b5..99132e6aa5c 100644 --- a/src/data/mystery-encounters/encounters/the-pokemon-salesman-encounter.ts +++ b/src/data/mystery-encounters/encounters/the-pokemon-salesman-encounter.ts @@ -3,7 +3,7 @@ import { transitionMysteryEncounterIntroVisuals, updatePlayerMoney, } from "#app/data/mystery-encounters/utils/encounter-phase-utils"; -import { isNullOrUndefined, randSeedInt, randSeedItem } from "#app/utils/common"; +import { isNullOrUndefined, NumberHolder, randSeedInt, randSeedItem } from "#app/utils/common"; import { MysteryEncounterType } from "#enums/mystery-encounter-type"; import { globalScene } from "#app/global-scene"; import type MysteryEncounter from "#app/data/mystery-encounters/mystery-encounter"; @@ -30,6 +30,8 @@ import { CLASSIC_MODE_MYSTERY_ENCOUNTER_WAVES } from "#app/game-mode"; import { Abilities } from "#enums/abilities"; import { NON_LEGEND_PARADOX_POKEMON, NON_LEGEND_ULTRA_BEASTS } from "#app/data/balance/special-species-groups"; import { timedEventManager } from "#app/global-event-manager"; +import { BASE_SHINY_CHANCE } from "#app/data/balance/rates"; +import { ShinyRateBoosterModifier } from "#app/modifier/modifier"; /** the i18n namespace for this encounter */ const namespace = "mysteryEncounters/thePokemonSalesman"; @@ -122,11 +124,13 @@ export const ThePokemonSalesmanEncounter: MysteryEncounter = MysteryEncounterBui ) { // If you roll 20%, give event encounter with 2 extra shiny rolls and its HA, if it has one const enc = randSeedItem(validEventEncounters); - const thresh = globalScene.getModifiedShinyThreshold(); + const threshold = new NumberHolder(BASE_SHINY_CHANCE); + globalScene.applyModifiers(ShinyRateBoosterModifier, true, threshold); + threshold.value *= timedEventManager.getShinyMultiplier(); species = getPokemonSpecies(enc.species); pokemon = new PlayerPokemon(species, 5, species.abilityHidden === Abilities.NONE ? undefined : 2, enc.formIndex); - pokemon.trySetShinySeed(thresh); // Apply event shiny boost even though it's a PlayerPokemon - pokemon.trySetShinySeed(thresh); + pokemon.trySetShinySeed(threshold.value); // Apply event shiny boost even though it's a PlayerPokemon + pokemon.trySetShinySeed(threshold.value); // Try again } else { pokemon = new PlayerPokemon(species, 5, 2, species.formIndex); } diff --git a/src/data/mystery-encounters/utils/encounter-phase-utils.ts b/src/data/mystery-encounters/utils/encounter-phase-utils.ts index d77b70caa31..65051b937f8 100644 --- a/src/data/mystery-encounters/utils/encounter-phase-utils.ts +++ b/src/data/mystery-encounters/utils/encounter-phase-utils.ts @@ -1075,8 +1075,8 @@ export function getRandomEncounterSpecies(level: number, isBoss = false, rerollH ret.formIndex = formIndex; } - //Reroll shiny for event encounters - if (isEventEncounter && !ret.shiny) { + //Reroll shiny or variant for event encounters + if (isEventEncounter) { ret.trySetShinySeed(); } //Reroll hidden ability diff --git a/src/field/pokemon.ts b/src/field/pokemon.ts index 233df05b8b3..cebc08502eb 100644 --- a/src/field/pokemon.ts +++ b/src/field/pokemon.ts @@ -3181,29 +3181,33 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { thresholdOverride?: number, applyModifiersToOverride?: boolean, ): boolean { - const shinyThreshold = new NumberHolder(BASE_SHINY_CHANCE); - if (thresholdOverride === undefined || applyModifiersToOverride) { - if (thresholdOverride !== undefined && applyModifiersToOverride) { + if (!this.shiny) { + const shinyThreshold = new NumberHolder(BASE_SHINY_CHANCE); + if (thresholdOverride === undefined || applyModifiersToOverride) { + if (thresholdOverride !== undefined && applyModifiersToOverride) { + shinyThreshold.value = thresholdOverride; + } + if (timedEventManager.isEventActive()) { + shinyThreshold.value *= timedEventManager.getShinyMultiplier(); + } + if (!this.hasTrainer()) { + globalScene.applyModifiers( + ShinyRateBoosterModifier, + true, + shinyThreshold, + ); + } + } + else { shinyThreshold.value = thresholdOverride; } - if (timedEventManager.isEventActive()) { - shinyThreshold.value *= timedEventManager.getShinyMultiplier(); - } - if (!this.hasTrainer()) { - globalScene.applyModifiers( - ShinyRateBoosterModifier, - true, - shinyThreshold, - ); - } - } else { - shinyThreshold.value = thresholdOverride; + + this.shiny = randSeedInt(65536) < shinyThreshold.value; } - this.shiny = this.shiny || randSeedInt(65536) < shinyThreshold.value; // If it's already shiny, don't un-shiny it - if (this.shiny) { - this.variant = this.generateShinyVariant(); + this.variant = this.variant ?? 0; + this.variant = Math.max(this.generateShinyVariant(), this.variant) as Variant; // Don't set a variant lower than the current one this.luck = this.variant + 1 + (this.fusionShiny ? this.fusionVariant + 1 : 0); this.initShinySparkle();