ME bug fix cleanup

This commit is contained in:
ImperialSympathizer 2024-09-17 18:19:51 -04:00
parent ed1a34fa84
commit 6561074d60
6 changed files with 15 additions and 14 deletions

View File

@ -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 {

View File

@ -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);

View File

@ -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);
}

View File

@ -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

View File

@ -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;

View File

@ -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(() => {