From 5a88344173989b7e6b7b0e123c3757ab8adb76c0 Mon Sep 17 00:00:00 2001 From: Flashfyre Date: Thu, 9 Nov 2023 08:27:17 -0500 Subject: [PATCH] Fix trainer random Pokemon always first evolution --- src/data/trainer-type.ts | 4 ++-- src/trainer.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/data/trainer-type.ts b/src/data/trainer-type.ts index 8056f23ba..52ee8170e 100644 --- a/src/data/trainer-type.ts +++ b/src/data/trainer-type.ts @@ -1,4 +1,4 @@ -import BattleScene from "../battle-scene"; +import BattleScene, { startingWave } from "../battle-scene"; import { ModifierType, ModifierTypeFunc, modifierTypes } from "../modifier/modifier-type"; import { EnemyPokemon } from "../pokemon"; import * as Utils from "../utils"; @@ -510,7 +510,7 @@ interface TrainerConfigs { } function getWavePartyTemplate(scene: BattleScene, ...templates: TrainerPartyTemplate[]) { - return templates[Math.min(Math.max(Math.ceil((scene.currentBattle.waveIndex - 10) / 20) - 1, 0), templates.length - 1)]; + return templates[Math.min(Math.max(Math.ceil(((scene.currentBattle?.waveIndex || startingWave) - 10) / 20) - 1, 0), templates.length - 1)]; } function getGymLeaderPartyTemplate(scene: BattleScene) { diff --git a/src/trainer.ts b/src/trainer.ts index 9c1dc58eb..5feea41dd 100644 --- a/src/trainer.ts +++ b/src/trainer.ts @@ -153,7 +153,7 @@ export default class Trainer extends Phaser.GameObjects.Container { const tierPool = this.config.speciesPools[tier]; ret = getPokemonSpecies(getPokemonSpecies(Phaser.Math.RND.pick(tierPool)).getSpeciesForLevel(level, true)); } else - ret = getPokemonSpecies(this.scene.randomSpecies(battle.waveIndex, level, false, this.config.speciesFilter).getSpeciesForLevel(level)); + ret = getPokemonSpecies(this.scene.randomSpecies(battle.waveIndex, level, false, this.config.speciesFilter).getSpeciesForLevel(level, true)); if (template.isBalanced(battle.enemyParty.length)) { const partyMemberTypes = battle.enemyParty.map(p => p.getTypes()).flat();