diff --git a/src/field/pokemon.ts b/src/field/pokemon.ts index 3eb194d3966..0de3da949cf 100644 --- a/src/field/pokemon.ts +++ b/src/field/pokemon.ts @@ -3398,6 +3398,7 @@ export class EnemyPokemon extends Pokemon { public aiType: AiType; public bossSegments: integer; public bossSegmentIndex: integer; + /** To indicate of the instance was populated with a dataSource -> e.g. loaded & populated from session data */ public readonly isPopulatedFromDataSource: boolean; constructor(scene: BattleScene, species: PokemonSpecies, level: integer, trainerSlot: TrainerSlot, boss: boolean, dataSource: PokemonData) { @@ -3405,7 +3406,7 @@ export class EnemyPokemon extends Pokemon { dataSource?.gender, dataSource ? dataSource.shiny : false, dataSource ? dataSource.variant : undefined, null, dataSource ? dataSource.nature : undefined, dataSource); this.trainerSlot = trainerSlot; - this.isPopulatedFromDataSource = !!dataSource; + this.isPopulatedFromDataSource = !!dataSource; // if a dataSource is provided, then it was populated from dataSource if (boss) { this.setBoss(boss, dataSource?.bossSegments); } @@ -3455,6 +3456,13 @@ export class EnemyPokemon extends Pokemon { } } + /** + * Sets the pokemons boss status. If true initializes the boss segments either from the arguments + * or through the the Scene.getEncounterBossSegments function + * + * @param boss if the pokemon is a boss + * @param bossSegments amount of boss segments (health-bar segments) + */ setBoss(boss: boolean = true, bossSegments: integer = 0): void { if (boss) { this.bossSegments = bossSegments || this.scene.getEncounterBossSegments(this.scene.currentBattle.waveIndex, this.level, this.species, true); diff --git a/src/phases.ts b/src/phases.ts index 6865c030730..263a1673671 100644 --- a/src/phases.ts +++ b/src/phases.ts @@ -868,8 +868,10 @@ export class EncounterPhase extends BattlePhase { if (battle.battleType === BattleType.TRAINER) { loadEnemyAssets.push(battle.trainer.loadAssets().then(() => battle.trainer.initSprite())); } else { + // This block only applies for double battles to init the boss segments (idk why it's split up like this) if (battle.enemyParty.filter(p => p.isBoss()).length > 1) { for (const enemyPokemon of battle.enemyParty) { + // If the enemy pokemon is a boss and wasn't populated from data source, then set it up if (enemyPokemon.isBoss() && !enemyPokemon.isPopulatedFromDataSource) { enemyPokemon.setBoss(true, Math.ceil(enemyPokemon.bossSegments * (enemyPokemon.getSpeciesForm().baseTotal / totalBst))); enemyPokemon.initBattleInfo();