Rerolling shiny also tries rerolling for better variant

This commit is contained in:
AJ Fontaine 2025-04-20 18:48:22 -04:00
parent 0108d011f8
commit 1f47aab8bb
4 changed files with 32 additions and 36 deletions

View File

@ -37,7 +37,6 @@ import {
PokemonHpRestoreModifier, PokemonHpRestoreModifier,
PokemonIncrementingStatModifier, PokemonIncrementingStatModifier,
RememberMoveModifier, RememberMoveModifier,
ShinyRateBoosterModifier,
} from "./modifier/modifier"; } from "./modifier/modifier";
import { PokeballType } from "#enums/pokeball"; import { PokeballType } from "#enums/pokeball";
import { 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[]) { getDoubleBattleChance(newWaveIndex: number, playerField: PlayerPokemon[]) {
const doubleChance = new NumberHolder(newWaveIndex % 10 === 0 ? 32 : 8); const doubleChance = new NumberHolder(newWaveIndex % 10 === 0 ? 32 : 8);
this.applyModifiers(DoubleBattleChanceBoosterModifier, true, doubleChance); this.applyModifiers(DoubleBattleChanceBoosterModifier, true, doubleChance);

View File

@ -3,7 +3,7 @@ import {
transitionMysteryEncounterIntroVisuals, transitionMysteryEncounterIntroVisuals,
updatePlayerMoney, updatePlayerMoney,
} from "#app/data/mystery-encounters/utils/encounter-phase-utils"; } 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 { MysteryEncounterType } from "#enums/mystery-encounter-type";
import { globalScene } from "#app/global-scene"; import { globalScene } from "#app/global-scene";
import type MysteryEncounter from "#app/data/mystery-encounters/mystery-encounter"; 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 { Abilities } from "#enums/abilities";
import { NON_LEGEND_PARADOX_POKEMON, NON_LEGEND_ULTRA_BEASTS } from "#app/data/balance/special-species-groups"; import { NON_LEGEND_PARADOX_POKEMON, NON_LEGEND_ULTRA_BEASTS } from "#app/data/balance/special-species-groups";
import { timedEventManager } from "#app/global-event-manager"; 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 */ /** the i18n namespace for this encounter */
const namespace = "mysteryEncounters/thePokemonSalesman"; 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 // If you roll 20%, give event encounter with 2 extra shiny rolls and its HA, if it has one
const enc = randSeedItem(validEventEncounters); 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); species = getPokemonSpecies(enc.species);
pokemon = new PlayerPokemon(species, 5, species.abilityHidden === Abilities.NONE ? undefined : 2, enc.formIndex); 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(threshold.value); // Apply event shiny boost even though it's a PlayerPokemon
pokemon.trySetShinySeed(thresh); pokemon.trySetShinySeed(threshold.value); // Try again
} else { } else {
pokemon = new PlayerPokemon(species, 5, 2, species.formIndex); pokemon = new PlayerPokemon(species, 5, 2, species.formIndex);
} }

View File

@ -1075,8 +1075,8 @@ export function getRandomEncounterSpecies(level: number, isBoss = false, rerollH
ret.formIndex = formIndex; ret.formIndex = formIndex;
} }
//Reroll shiny for event encounters //Reroll shiny or variant for event encounters
if (isEventEncounter && !ret.shiny) { if (isEventEncounter) {
ret.trySetShinySeed(); ret.trySetShinySeed();
} }
//Reroll hidden ability //Reroll hidden ability

View File

@ -3181,29 +3181,33 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
thresholdOverride?: number, thresholdOverride?: number,
applyModifiersToOverride?: boolean, applyModifiersToOverride?: boolean,
): boolean { ): boolean {
const shinyThreshold = new NumberHolder(BASE_SHINY_CHANCE); if (!this.shiny) {
if (thresholdOverride === undefined || applyModifiersToOverride) { const shinyThreshold = new NumberHolder(BASE_SHINY_CHANCE);
if (thresholdOverride !== undefined && applyModifiersToOverride) { 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; shinyThreshold.value = thresholdOverride;
} }
if (timedEventManager.isEventActive()) {
shinyThreshold.value *= timedEventManager.getShinyMultiplier(); this.shiny = randSeedInt(65536) < shinyThreshold.value;
}
if (!this.hasTrainer()) {
globalScene.applyModifiers(
ShinyRateBoosterModifier,
true,
shinyThreshold,
);
}
} else {
shinyThreshold.value = thresholdOverride;
} }
this.shiny = this.shiny || randSeedInt(65536) < shinyThreshold.value; // If it's already shiny, don't un-shiny it
if (this.shiny) { 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.luck =
this.variant + 1 + (this.fusionShiny ? this.fusionVariant + 1 : 0); this.variant + 1 + (this.fusionShiny ? this.fusionVariant + 1 : 0);
this.initShinySparkle(); this.initShinySparkle();