From 6561074d600b16232a65ca000b72554d5642f937 Mon Sep 17 00:00:00 2001 From: ImperialSympathizer Date: Tue, 17 Sep 2024 18:19:51 -0400 Subject: [PATCH] ME bug fix cleanup --- src/battle.ts | 2 +- .../utils/encounter-phase-utils.ts | 4 ++-- .../utils/encounter-pokemon-utils.ts | 6 +++--- src/overrides.ts | 2 +- src/phases/command-phase.ts | 13 +++++++------ src/phases/game-over-phase.ts | 2 +- 6 files changed, 15 insertions(+), 14 deletions(-) diff --git a/src/battle.ts b/src/battle.ts index 97a8a71c234..b857314b4bf 100644 --- a/src/battle.ts +++ b/src/battle.ts @@ -14,7 +14,7 @@ import { PlayerGender } from "#enums/player-gender"; import { Species } from "#enums/species"; import { TrainerType } from "#enums/trainer-type"; import i18next from "#app/plugins/i18n"; -import MysteryEncounter from "./data/mystery-encounters/mystery-encounter"; +import MysteryEncounter from "#app/data/mystery-encounters/mystery-encounter"; import { MysteryEncounterMode } from "#enums/mystery-encounter-mode"; export enum BattleType { diff --git a/src/data/mystery-encounters/utils/encounter-phase-utils.ts b/src/data/mystery-encounters/utils/encounter-phase-utils.ts index 53ab56dee2b..36ecef0435c 100644 --- a/src/data/mystery-encounters/utils/encounter-phase-utils.ts +++ b/src/data/mystery-encounters/utils/encounter-phase-utils.ts @@ -158,8 +158,8 @@ export async function initBattleWithEnemyConfig(scene: BattleScene, partyConfig: // ME levels are modified by an additive value that scales with wave index // Base scaling: Every 10 waves, modifier gets +1 level - // This can be amplified or counteracted by setting levelAdditiveMultiplier in config - // levelAdditiveMultiplier value of 0.5 will halve the modifier scaling, 2 will double it, etc. + // This can be amplified or counteracted by setting levelAdditiveModifier in config + // levelAdditiveModifier value of 0.5 will halve the modifier scaling, 2 will double it, etc. // Leaving null/undefined will disable level scaling const mult: number = !isNullOrUndefined(partyConfig.levelAdditiveModifier) ? partyConfig.levelAdditiveModifier! : 0; const additive = Math.max(Math.round((scene.currentBattle.waveIndex / 10) * mult), 0); diff --git a/src/data/mystery-encounters/utils/encounter-pokemon-utils.ts b/src/data/mystery-encounters/utils/encounter-pokemon-utils.ts index 54977435b2e..393ba5de26b 100644 --- a/src/data/mystery-encounters/utils/encounter-pokemon-utils.ts +++ b/src/data/mystery-encounters/utils/encounter-pokemon-utils.ts @@ -737,10 +737,10 @@ export function getGoldenBugNetSpecies(): PokemonSpecies { /** * Generates a Pokemon level for a given wave, with an option to increase/decrease by a scaling modifier */ -export function getEncounterPokemonLevelForWave(scene: BattleScene, levelAdditiveModifier: number = 0) { +export function getEncounterPokemonLevelForWave({currentBattle}: BattleScene, levelAdditiveModifier: number = 0) { // Default to use the first generated level from enemyLevels, or generate a new one if it DNE - const baseLevel = scene.currentBattle.enemyLevels && scene.currentBattle.enemyLevels?.length > 0 ? scene.currentBattle.enemyLevels[0] : scene.currentBattle.getLevelForWave(); + const baseLevel = currentBattle.enemyLevels && currentBattle.enemyLevels?.length > 0 ? currentBattle.enemyLevels[0] : currentBattle.getLevelForWave(); // Add a level scaling modifier that is (+1 level per 10 waves) * levelAdditiveModifier - return baseLevel + Math.max(Math.round((scene.currentBattle.waveIndex / 10) * levelAdditiveModifier), 0); + return baseLevel + Math.max(Math.round((currentBattle.waveIndex / 10) * levelAdditiveModifier), 0); } diff --git a/src/overrides.ts b/src/overrides.ts index 2b69e90ec40..ec0577ceb3d 100644 --- a/src/overrides.ts +++ b/src/overrides.ts @@ -145,7 +145,7 @@ class DefaultOverrides { /** 1 to 256, set to null to ignore */ readonly MYSTERY_ENCOUNTER_RATE_OVERRIDE: number | null = null; readonly MYSTERY_ENCOUNTER_TIER_OVERRIDE: MysteryEncounterTier | null = null; - readonly MYSTERY_ENCOUNTER_OVERRIDE: MysteryEncounterType | null = MysteryEncounterType.DELIBIRDY; + readonly MYSTERY_ENCOUNTER_OVERRIDE: MysteryEncounterType | null = null; // ------------------------- // MODIFIER / ITEM OVERRIDES diff --git a/src/phases/command-phase.ts b/src/phases/command-phase.ts index 7d2817abcc8..66e39cf98a5 100644 --- a/src/phases/command-phase.ts +++ b/src/phases/command-phase.ts @@ -180,15 +180,16 @@ export class CommandPhase extends FieldPhase { case Command.POKEMON: case Command.RUN: const isSwitch = command === Command.POKEMON; - const mysteryEncounterFleeAllowed = this.scene.currentBattle.mysteryEncounter?.fleeAllowed; - if (!isSwitch && (this.scene.arena.biomeType === Biome.END || (!isNullOrUndefined(mysteryEncounterFleeAllowed) && !mysteryEncounterFleeAllowed))) { + const { currentBattle, arena } = this.scene; + const mysteryEncounterFleeAllowed = currentBattle.mysteryEncounter?.fleeAllowed; + if (!isSwitch && (arena.biomeType === Biome.END || (!isNullOrUndefined(mysteryEncounterFleeAllowed) && !mysteryEncounterFleeAllowed))) { this.scene.ui.setMode(Mode.COMMAND, this.fieldIndex); this.scene.ui.setMode(Mode.MESSAGE); this.scene.ui.showText(i18next.t("battle:noEscapeForce"), null, () => { this.scene.ui.showText("", 0); this.scene.ui.setMode(Mode.COMMAND, this.fieldIndex); }, null, true); - } else if (!isSwitch && (this.scene.currentBattle.battleType === BattleType.TRAINER || this.scene.currentBattle.mysteryEncounter?.encounterMode === MysteryEncounterMode.TRAINER_BATTLE)) { + } else if (!isSwitch && (currentBattle.battleType === BattleType.TRAINER || currentBattle.mysteryEncounter?.encounterMode === MysteryEncounterMode.TRAINER_BATTLE)) { this.scene.ui.setMode(Mode.COMMAND, this.fieldIndex); this.scene.ui.setMode(Mode.MESSAGE); this.scene.ui.showText(i18next.t("battle:noEscapeTrainer"), null, () => { @@ -199,12 +200,12 @@ export class CommandPhase extends FieldPhase { const batonPass = isSwitch && args[0] as boolean; const trappedAbMessages: string[] = []; if (batonPass || !playerPokemon.isTrapped(trappedAbMessages)) { - this.scene.currentBattle.turnCommands[this.fieldIndex] = isSwitch + currentBattle.turnCommands[this.fieldIndex] = isSwitch ? { command: Command.POKEMON, cursor: cursor, args: args } : { command: Command.RUN }; success = true; if (!isSwitch && this.fieldIndex) { - this.scene.currentBattle.turnCommands[this.fieldIndex - 1]!.skip = true; + currentBattle.turnCommands[this.fieldIndex - 1]!.skip = true; } } else if (trappedAbMessages.length > 0) { if (!isSwitch) { @@ -221,7 +222,7 @@ export class CommandPhase extends FieldPhase { // trapTag should be defined at this point, but just in case... if (!trapTag) { - this.scene.currentBattle.turnCommands[this.fieldIndex] = isSwitch + currentBattle.turnCommands[this.fieldIndex] = isSwitch ? { command: Command.POKEMON, cursor: cursor, args: args } : { command: Command.RUN }; break; diff --git a/src/phases/game-over-phase.ts b/src/phases/game-over-phase.ts index a96844ed4bc..438ff1aecb0 100644 --- a/src/phases/game-over-phase.ts +++ b/src/phases/game-over-phase.ts @@ -62,7 +62,7 @@ export class GameOverPhase extends BattlePhase { this.scene.clearPhaseQueue(); // If this is a ME, clear any residual visual sprites before reloading const encounter = this.scene.currentBattle.mysteryEncounter; - if (encounter && encounter.introVisuals) { + if (encounter?.introVisuals) { this.scene.field.remove(encounter.introVisuals, true); } this.scene.gameData.loadSession(this.scene, this.scene.sessionSlotId).then(() => {