Created a new enum and functions for retrieving final bosses.

This commit is contained in:
frutescens 2024-11-12 16:01:06 -08:00
parent c983027adb
commit 8bd36a73fd
2 changed files with 38 additions and 5 deletions

View File

@ -2,7 +2,7 @@ import BattleScene from "./battle-scene";
import { Command } from "./ui/command-ui-handler"; import { Command } from "./ui/command-ui-handler";
import * as Utils from "./utils"; import * as Utils from "./utils";
import Trainer, { TrainerVariant } from "./field/trainer"; import Trainer, { TrainerVariant } from "./field/trainer";
import { GameMode } from "./game-mode"; import { GameMode, GameModes } from "./game-mode";
import { MoneyMultiplierModifier, PokemonHeldItemModifier } from "./modifier/modifier"; import { MoneyMultiplierModifier, PokemonHeldItemModifier } from "./modifier/modifier";
import { PokeballType } from "#enums/pokeball"; import { PokeballType } from "#enums/pokeball";
import { trainerConfigs } from "#app/data/trainer-config"; import { trainerConfigs } from "#app/data/trainer-config";
@ -28,6 +28,13 @@ export enum ClassicFixedBossWaves {
EVIL_BOSS_2 = 165, EVIL_BOSS_2 = 165,
} }
export enum EndlessBossType {
STANDARD = 50,
ETERNATUS = 250,
ETERNAMAX = 1000,
NONE
}
export enum BattleType { export enum BattleType {
WILD, WILD,
TRAINER, TRAINER,
@ -438,6 +445,32 @@ export default class Battle {
isBattleMysteryEncounter(): boolean { isBattleMysteryEncounter(): boolean {
return this.battleType === BattleType.MYSTERY_ENCOUNTER; return this.battleType === BattleType.MYSTERY_ENCOUNTER;
} }
/**
* @returns `true` if the current battle is against classic mode's final boss
*/
isBattleClassicFinalBoss(): boolean {
return (this.gameMode.modeId === GameModes.CLASSIC || this.gameMode.modeId === GameModes.CHALLENGE) && this.waveIndex === 200;
}
/**
* Uses modulos to determine what type of boss is faced by the player in Endless mode.
* @returns the type of Endless boss faced by the player {@linkcode EndlessBossType}
*/
getEndlessBossType(): EndlessBossType {
if (this.gameMode.modeId !== GameModes.ENDLESS && this.gameMode.modeId !== GameModes.SPLICED_ENDLESS) {
return EndlessBossType.NONE;
} else {
if (!(this.waveIndex % EndlessBossType.ETERNAMAX)) {
return EndlessBossType.ETERNAMAX;
} else if (!(this.waveIndex % EndlessBossType.ETERNATUS)) {
return EndlessBossType.ETERNATUS;
} else if (!(this.waveIndex % EndlessBossType.STANDARD)) {
return EndlessBossType.STANDARD;
}
return EndlessBossType.NONE;
}
}
} }
export class FixedBattle extends Battle { export class FixedBattle extends Battle {
@ -499,7 +532,7 @@ export class FixedBattleConfig {
* @param seedOffset the seed offset to use for the random generation of the trainer * @param seedOffset the seed offset to use for the random generation of the trainer
* @returns the generated trainer * @returns the generated trainer
*/ */
function getRandomTrainerFunc(trainerPool: (TrainerType | TrainerType[])[], randomGender: boolean = false, seedOffset: number = 0): GetTrainerFunc { function getRandomTrainerFunc(trainerPool: (TrainerType | TrainerType[])[], randomGender: boolean = false, seedOffset: number = 0): GetTrainerFunc {
return (scene: BattleScene) => { return (scene: BattleScene) => {
const rand = Utils.randSeedInt(trainerPool.length); const rand = Utils.randSeedInt(trainerPool.length);
const trainerTypes: TrainerType[] = []; const trainerTypes: TrainerType[] = [];
@ -531,7 +564,7 @@ function getRandomTrainerFunc(trainerPool: (TrainerType | TrainerType[])[], rand
} }
export interface FixedBattleConfigs { export interface FixedBattleConfigs {
[key: number]: FixedBattleConfig [key: number]: FixedBattleConfig
} }
/** /**
* Youngster/Lass on 5 * Youngster/Lass on 5

View File

@ -1,4 +1,4 @@
import { BattlerIndex, BattleType } from "#app/battle"; import { BattlerIndex, BattleType, EndlessBossType } from "#app/battle";
import BattleScene from "#app/battle-scene"; import BattleScene from "#app/battle-scene";
import { PLAYER_PARTY_MAX_SIZE } from "#app/constants"; import { PLAYER_PARTY_MAX_SIZE } from "#app/constants";
import { applyAbAttrs, SyncEncounterNatureAbAttr } from "#app/data/ability"; import { applyAbAttrs, SyncEncounterNatureAbAttr } from "#app/data/ability";
@ -217,7 +217,7 @@ export class EncounterPhase extends BattlePhase {
regenerateModifierPoolThresholds(this.scene.getEnemyField(), battle.battleType === BattleType.TRAINER ? ModifierPoolType.TRAINER : ModifierPoolType.WILD); regenerateModifierPoolThresholds(this.scene.getEnemyField(), battle.battleType === BattleType.TRAINER ? ModifierPoolType.TRAINER : ModifierPoolType.WILD);
this.scene.generateEnemyModifiers(); this.scene.generateEnemyModifiers();
// This checks if the current battle is an Endless E-Max battle/Classic final boss and sets the MBH held by the boss to untransferrable // This checks if the current battle is an Endless E-Max battle/Classic final boss and sets the MBH held by the boss to untransferrable
if (this.scene.currentBattle.waveIndex % 1000 || battle.battleSpec === BattleSpec.FINAL_BOSS) { if (this.scene.currentBattle.getEndlessBossType() === EndlessBossType.ETERNAMAX || battle.isBattleClassicFinalBoss()) {
const enemyPokemon = this.scene.getEnemyPokemon(); const enemyPokemon = this.scene.getEnemyPokemon();
if (enemyPokemon) { if (enemyPokemon) {
const bossMBH = this.scene.findModifier(m => m instanceof TurnHeldItemTransferModifier && m.pokemonId === enemyPokemon.id, false) as TurnHeldItemTransferModifier; const bossMBH = this.scene.findModifier(m => m instanceof TurnHeldItemTransferModifier && m.pokemonId === enemyPokemon.id, false) as TurnHeldItemTransferModifier;