diff --git a/src/arena.ts b/src/arena.ts index 6987cfcdf..978abc147 100644 --- a/src/arena.ts +++ b/src/arena.ts @@ -116,7 +116,7 @@ export class Arena { return this.randomSpecies(waveIndex, level, (attempt || 0) + 1); } - const newSpeciesId = ret.getSpeciesForLevel(level, true); + const newSpeciesId = ret.getSpeciesForLevel(level, true, false, isBoss); if (newSpeciesId !== ret.speciesId) { console.log('Replaced', Species[ret.speciesId], 'with', Species[newSpeciesId]); ret = getPokemonSpecies(newSpeciesId); diff --git a/src/data/pokemon-species.ts b/src/data/pokemon-species.ts index 41c2758c8..b4d000e4d 100644 --- a/src/data/pokemon-species.ts +++ b/src/data/pokemon-species.ts @@ -344,7 +344,7 @@ export default class PokemonSpecies extends PokemonSpeciesForm { return this.name; } - getSpeciesForLevel(level: integer, allowEvolving?: boolean, forTrainer?: boolean): Species { + getSpeciesForLevel(level: integer, allowEvolving: boolean = false, forTrainer: boolean = false, isBoss: boolean = false): Species { const prevolutionLevels = this.getPrevolutionLevels(); if (prevolutionLevels.length) { @@ -379,9 +379,11 @@ export default class PokemonSpecies extends PokemonSpeciesForm { if (!forTrainer && isRegional) evolutionChance = 0; else if (ev.wildDelay === SpeciesWildEvolutionDelay.NONE) { - evolutionChance = Math.min(0.5 + easeInFunc(Math.min(level - ev.level, 40) / 40) / 2, 1); + const maxLevelDiff = forTrainer || isBoss ? forTrainer && isBoss ? 10 : 20 : 40; + const minChance = forTrainer ? 0.5 : 0.75; + evolutionChance = Math.min(minChance + easeInFunc(Math.min(level - ev.level, maxLevelDiff) / maxLevelDiff) * (1 - minChance), 1); } else { - let preferredMinLevel = (ev.level - 1) + ev.wildDelay * 10; + let preferredMinLevel = (ev.level - 1) + ev.wildDelay * (forTrainer || isBoss ? forTrainer && isBoss ? 5 : 10 : 20); let evolutionLevel = ev.level > 1 ? ev.level : Math.floor(preferredMinLevel / 2); if (ev.level <= 1 && pokemonPrevolutions.hasOwnProperty(this.speciesId)) { @@ -413,7 +415,7 @@ export default class PokemonSpecies extends PokemonSpeciesForm { for (let weight of evolutionPool.keys()) { if (randValue < weight) - return getPokemonSpecies(evolutionPool.get(weight)).getSpeciesForLevel(level, true); + return getPokemonSpecies(evolutionPool.get(weight)).getSpeciesForLevel(level, true, forTrainer, isBoss); } return this.speciesId; diff --git a/src/data/trainer-type.ts b/src/data/trainer-type.ts index f7ea4fe83..9bbd4b872 100644 --- a/src/data/trainer-type.ts +++ b/src/data/trainer-type.ts @@ -549,7 +549,7 @@ function getGymLeaderPartyTemplate(scene: BattleScene) { function getRandomPartyMemberFunc(speciesPool: Species[], postProcess?: (enemyPokemon: EnemyPokemon) => void): PartyMemberFunc { return (scene: BattleScene, level: integer) => { - const species = getPokemonSpecies(Phaser.Math.RND.pick(speciesPool)).getSpeciesForLevel(level, true, true); + const species = getPokemonSpecies(Phaser.Math.RND.pick(speciesPool)).getSpeciesForLevel(level, true, true, scene.currentBattle.trainer.config.isBoss); const ret = new EnemyPokemon(scene, getPokemonSpecies(species), level, true); if (postProcess) postProcess(ret); @@ -561,7 +561,7 @@ function getSpeciesFilterRandomPartyMemberFunc(speciesFilter: PokemonSpeciesFilt const originalSpeciesFilter = speciesFilter; speciesFilter = (species: PokemonSpecies) => allowLegendaries || (!species.legendary && !species.pseudoLegendary && !species.mythical) && originalSpeciesFilter(species); return (scene: BattleScene, level: integer) => { - const ret = new EnemyPokemon(scene, getPokemonSpecies(scene.randomSpecies(scene.currentBattle.waveIndex, level, false, speciesFilter).getSpeciesForLevel(level, true, true)), level, true); + const ret = new EnemyPokemon(scene, getPokemonSpecies(scene.randomSpecies(scene.currentBattle.waveIndex, level, false, speciesFilter).getSpeciesForLevel(level, true, true, scene.currentBattle.trainer.config.isBoss)), level, true); if (postProcess) postProcess(ret); return ret; diff --git a/src/trainer.ts b/src/trainer.ts index 0daddda59..1f46e9fdf 100644 --- a/src/trainer.ts +++ b/src/trainer.ts @@ -136,7 +136,7 @@ export default class Trainer extends Phaser.GameObjects.Container { } const species = template.isSameSpecies(index) && index > offset - ? getPokemonSpecies(battle.enemyParty[offset].species.getSpeciesForLevel(level, false, true)) + ? getPokemonSpecies(battle.enemyParty[offset].species.getSpeciesForLevel(level, false, true, this.config.isBoss)) : this.genNewPartyMemberSpecies(level); ret = new EnemyPokemon(this.scene, species, level, true); @@ -163,7 +163,7 @@ export default class Trainer extends Phaser.GameObjects.Container { } else species = this.scene.randomSpecies(battle.waveIndex, level, false, this.config.speciesFilter); - let ret = getPokemonSpecies(species.getSpeciesForLevel(level, true, true)); + let ret = getPokemonSpecies(species.getSpeciesForLevel(level, true, true, this.config.isBoss)); let retry = false; console.log(ret.getName()); @@ -181,7 +181,7 @@ export default class Trainer extends Phaser.GameObjects.Container { console.log('Attempting reroll of species evolution to fit specialty type...'); let evoAttempt = 0; while (retry && evoAttempt++ < 10) { - ret = getPokemonSpecies(species.getSpeciesForLevel(level, true, true)); + ret = getPokemonSpecies(species.getSpeciesForLevel(level, true, true, this.config.isBoss)); console.log(ret.name); if (this.config.specialtyTypes.find(t => ret.isOfType(t))) retry = false;