mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-02-07 08:37:41 +00:00
Simulate evolution chain when generating movesets
This commit is contained in:
parent
88e050581e
commit
6feef82fcf
@ -4474,7 +4474,6 @@ export const pokemonSpeciesLevelMoves: PokemonSpeciesLevelMoves = {
|
|||||||
],
|
],
|
||||||
[Species.SILCOON]: [
|
[Species.SILCOON]: [
|
||||||
[ 0, Moves.HARDEN ],
|
[ 0, Moves.HARDEN ],
|
||||||
[ 1, Moves.HARDEN ],
|
|
||||||
],
|
],
|
||||||
[Species.BEAUTIFLY]: [
|
[Species.BEAUTIFLY]: [
|
||||||
[ 0, Moves.GUST ],
|
[ 0, Moves.GUST ],
|
||||||
@ -4493,7 +4492,6 @@ export const pokemonSpeciesLevelMoves: PokemonSpeciesLevelMoves = {
|
|||||||
],
|
],
|
||||||
[Species.CASCOON]: [
|
[Species.CASCOON]: [
|
||||||
[ 0, Moves.HARDEN ],
|
[ 0, Moves.HARDEN ],
|
||||||
[ 1, Moves.HARDEN ],
|
|
||||||
],
|
],
|
||||||
[Species.DUSTOX]: [
|
[Species.DUSTOX]: [
|
||||||
[ 0, Moves.GUST ],
|
[ 0, Moves.GUST ],
|
||||||
|
@ -538,6 +538,27 @@ export default class PokemonSpecies extends PokemonSpeciesForm {
|
|||||||
return prevolutionLevels;
|
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 {
|
getCompatibleFusionSpeciesFilter(): PokemonSpeciesFilter {
|
||||||
const hasEvolution = pokemonEvolutions.hasOwnProperty(this.speciesId);
|
const hasEvolution = pokemonEvolutions.hasOwnProperty(this.speciesId);
|
||||||
const hasPrevolution = pokemonPrevolutions.hasOwnProperty(this.speciesId);
|
const hasPrevolution = pokemonPrevolutions.hasOwnProperty(this.speciesId);
|
||||||
|
@ -767,11 +767,19 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
getLevelMoves(startingLevel?: integer, includeEvolutionMoves?: boolean): LevelMoves {
|
getLevelMoves(startingLevel?: integer, includeEvolutionMoves: boolean = false, simulateEvolutionChain: boolean = false): LevelMoves {
|
||||||
const ret: LevelMoves = [];
|
const ret: LevelMoves = [];
|
||||||
let levelMoves = this.getSpeciesForm().getLevelMoves();
|
let levelMoves: LevelMoves = [];
|
||||||
if (!startingLevel)
|
if (!startingLevel)
|
||||||
startingLevel = this.level;
|
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) {
|
if (this.fusionSpecies) {
|
||||||
const evolutionLevelMoves = levelMoves.slice(0, Math.max(levelMoves.findIndex(lm => !!lm[0]), 0));
|
const evolutionLevelMoves = levelMoves.slice(0, Math.max(levelMoves.findIndex(lm => !!lm[0]), 0));
|
||||||
const fusionLevelMoves = this.getFusionSpeciesForm().getLevelMoves();
|
const fusionLevelMoves = this.getFusionSpeciesForm().getLevelMoves();
|
||||||
@ -896,7 +904,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
|
|||||||
generateAndPopulateMoveset(): void {
|
generateAndPopulateMoveset(): void {
|
||||||
this.moveset = [];
|
this.moveset = [];
|
||||||
const movePool = [];
|
const movePool = [];
|
||||||
const allLevelMoves = this.getLevelMoves(1);
|
const allLevelMoves = this.getLevelMoves(1, true, true);
|
||||||
if (!allLevelMoves) {
|
if (!allLevelMoves) {
|
||||||
console.log(this.species.speciesId, 'ERROR')
|
console.log(this.species.speciesId, 'ERROR')
|
||||||
return;
|
return;
|
||||||
|
@ -36,6 +36,8 @@ export function clampInt(value: integer, min: integer, max: integer): integer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function randGauss(stdev: number, mean: number = 0): number {
|
export function randGauss(stdev: number, mean: number = 0): number {
|
||||||
|
if (!stdev)
|
||||||
|
return 0;
|
||||||
const u = 1 - Math.random();
|
const u = 1 - Math.random();
|
||||||
const v = Math.random();
|
const v = Math.random();
|
||||||
const z = Math.sqrt(-2.0 * Math.log(u)) * Math.cos(2.0 * Math.PI * v);
|
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 {
|
export function randSeedGauss(stdev: number, mean: number = 0): number {
|
||||||
|
if (!stdev)
|
||||||
|
return 0;
|
||||||
const u = 1 - Phaser.Math.RND.realInRange(0, 1);
|
const u = 1 - Phaser.Math.RND.realInRange(0, 1);
|
||||||
const v = 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);
|
const z = Math.sqrt(-2.0 * Math.log(u)) * Math.cos(2.0 * Math.PI * v);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user