diff --git a/src/data/pokemon-level-moves.ts b/src/data/pokemon-level-moves.ts index f03198cd4..37af1eef7 100644 --- a/src/data/pokemon-level-moves.ts +++ b/src/data/pokemon-level-moves.ts @@ -4474,7 +4474,6 @@ export const pokemonSpeciesLevelMoves: PokemonSpeciesLevelMoves = { ], [Species.SILCOON]: [ [ 0, Moves.HARDEN ], - [ 1, Moves.HARDEN ], ], [Species.BEAUTIFLY]: [ [ 0, Moves.GUST ], @@ -4493,7 +4492,6 @@ export const pokemonSpeciesLevelMoves: PokemonSpeciesLevelMoves = { ], [Species.CASCOON]: [ [ 0, Moves.HARDEN ], - [ 1, Moves.HARDEN ], ], [Species.DUSTOX]: [ [ 0, Moves.GUST ], diff --git a/src/data/pokemon-species.ts b/src/data/pokemon-species.ts index aac158430..45b658aa4 100644 --- a/src/data/pokemon-species.ts +++ b/src/data/pokemon-species.ts @@ -538,6 +538,27 @@ export default class PokemonSpecies extends PokemonSpeciesForm { return prevolutionLevels; } + // This could definitely be written better and more accurate to the getSpeciesForLevel logic, but it is only for generating movesets for evolved Pokemon + getSimulatedEvolutionChain(currentLevel: integer, forTrainer: boolean = false, isBoss: boolean = false, player: boolean = false) { + const ret = []; + if (pokemonPrevolutions.hasOwnProperty(this.speciesId)) { + const prevolutionLevels = this.getPrevolutionLevels().reverse(); + const levelDiff = player ? 0 : forTrainer || isBoss ? forTrainer && isBoss ? 2.5 : 5 : 10; + ret.push([ prevolutionLevels[0][0], 1 ]); + for (let l = 1; l < prevolutionLevels.length; l++) { + const evolution = pokemonEvolutions[prevolutionLevels[l - 1][0]].find(e => e.speciesId === prevolutionLevels[l][0]); + ret.push([ prevolutionLevels[l][0], Math.min(Math.max(evolution.level + Math.round(Utils.randSeedGauss(0.5, 1 + levelDiff * 0.2) * Math.max(evolution.wildDelay, 0.5) * 5) - 1, 2, evolution.level), currentLevel - 1) ]); + } + const lastPrevolutionLevel = ret[prevolutionLevels.length - 1][1]; + const evolution = pokemonEvolutions[prevolutionLevels[prevolutionLevels.length - 1][0]].find(e => e.speciesId === this.speciesId); + ret.push([ this.speciesId, Math.min(Math.max(lastPrevolutionLevel + Math.round(Utils.randSeedGauss(0.5, 1 + levelDiff * 0.2) * Math.max(evolution.wildDelay, 0.5) * 5), lastPrevolutionLevel + 1, evolution.level), currentLevel) ]); + } else { + ret.push([ this.speciesId, 1 ]); + } + + return ret; + } + getCompatibleFusionSpeciesFilter(): PokemonSpeciesFilter { const hasEvolution = pokemonEvolutions.hasOwnProperty(this.speciesId); const hasPrevolution = pokemonPrevolutions.hasOwnProperty(this.speciesId); diff --git a/src/field/pokemon.ts b/src/field/pokemon.ts index 266f7155a..2d444b73d 100644 --- a/src/field/pokemon.ts +++ b/src/field/pokemon.ts @@ -767,11 +767,19 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { return null; } - getLevelMoves(startingLevel?: integer, includeEvolutionMoves?: boolean): LevelMoves { + getLevelMoves(startingLevel?: integer, includeEvolutionMoves: boolean = false, simulateEvolutionChain: boolean = false): LevelMoves { const ret: LevelMoves = []; - let levelMoves = this.getSpeciesForm().getLevelMoves(); + let levelMoves: LevelMoves = []; if (!startingLevel) startingLevel = this.level; + if (simulateEvolutionChain) { + const evolutionChain = this.species.getSimulatedEvolutionChain(this.level, this.hasTrainer(), this.isBoss(), this.isPlayer()); + for (let e = 0; e < evolutionChain.length; e++) { + const speciesLevelMoves = getPokemonSpecies(evolutionChain[e][0] as Species).getLevelMoves(); + levelMoves.push(...speciesLevelMoves.filter(lm => (includeEvolutionMoves && !lm[0]) || ((!e || lm[0] >= evolutionChain[e - 1][0]) && (e === evolutionChain.length - 1 || lm[0] < evolutionChain[e + 1][0])))); + } + } else + levelMoves = this.getSpeciesForm().getLevelMoves(); if (this.fusionSpecies) { const evolutionLevelMoves = levelMoves.slice(0, Math.max(levelMoves.findIndex(lm => !!lm[0]), 0)); const fusionLevelMoves = this.getFusionSpeciesForm().getLevelMoves(); @@ -896,7 +904,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { generateAndPopulateMoveset(): void { this.moveset = []; const movePool = []; - const allLevelMoves = this.getLevelMoves(1); + const allLevelMoves = this.getLevelMoves(1, true, true); if (!allLevelMoves) { console.log(this.species.speciesId, 'ERROR') return; diff --git a/src/utils.ts b/src/utils.ts index 44f6d6d27..4d1d087e7 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -36,6 +36,8 @@ export function clampInt(value: integer, min: integer, max: integer): integer { } export function randGauss(stdev: number, mean: number = 0): number { + if (!stdev) + return 0; const u = 1 - Math.random(); const v = Math.random(); const z = Math.sqrt(-2.0 * Math.log(u)) * Math.cos(2.0 * Math.PI * v); @@ -43,6 +45,8 @@ export function randGauss(stdev: number, mean: number = 0): number { } export function randSeedGauss(stdev: number, mean: number = 0): number { + if (!stdev) + return 0; const u = 1 - Phaser.Math.RND.realInRange(0, 1); const v = Phaser.Math.RND.realInRange(0, 1); const z = Math.sqrt(-2.0 * Math.log(u)) * Math.cos(2.0 * Math.PI * v);