Tweak species evolution logic

pull/14/head
Flashfyre 2024-01-01 15:27:47 -05:00
parent cc5f15e00e
commit ae42dac370
4 changed files with 12 additions and 10 deletions

View File

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

View File

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

View File

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

View File

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