From b94215e3f66527fa9ea92ef56d129dc0ff1b137d Mon Sep 17 00:00:00 2001 From: Flashfyre Date: Wed, 27 Mar 2024 12:38:36 -0400 Subject: [PATCH] Attempt fixing issue with form-specific moves in learnset not being used --- src/data/pokemon-species.ts | 9 +++++++++ src/field/pokemon.ts | 7 ++++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/data/pokemon-species.ts b/src/data/pokemon-species.ts index 402c964e0..3e2bf2654 100644 --- a/src/data/pokemon-species.ts +++ b/src/data/pokemon-species.ts @@ -24,6 +24,15 @@ export function getPokemonSpecies(species: Species): PokemonSpecies { return allSpecies[species - 1]; } +export function getPokemonSpeciesForm(species: Species, formIndex: integer): PokemonSpeciesForm { + let retSpecies: PokemonSpecies = species >= 2000 + ? allSpecies.find(s => s.speciesId === species) + : allSpecies[species - 1]; + if (formIndex < retSpecies.forms?.length) + return retSpecies.forms[formIndex]; + return retSpecies; +} + export function getFusedSpeciesName(speciesAName: string, speciesBName: string): string { const fragAPattern = /([a-z]{2}.*?[aeiou(?:y$)\-\']+)(.*?)$/i; const fragBPattern = /([a-z]{2}.*?[aeiou(?:y$)\-\'])(.*?)$/i; diff --git a/src/field/pokemon.ts b/src/field/pokemon.ts index 3f1246e30..6c4e34ffa 100644 --- a/src/field/pokemon.ts +++ b/src/field/pokemon.ts @@ -3,7 +3,7 @@ import BattleScene, { AnySound } from '../battle-scene'; import BattleInfo, { PlayerBattleInfo, EnemyBattleInfo } from '../ui/battle-info'; import { Moves } from "../data/enums/moves"; import Move, { HighCritAttr, HitsTagAttr, applyMoveAttrs, FixedDamageAttr, VariableAtkAttr, VariablePowerAttr, allMoves, MoveCategory, TypelessAttr, CritOnlyAttr, getMoveTargets, OneHitKOAttr, MultiHitAttr, StatusMoveTypeImmunityAttr, MoveTarget, VariableDefAttr, AttackMove } from "../data/move"; -import { default as PokemonSpecies, PokemonSpeciesForm, SpeciesFormKey, getFusedSpeciesName, getPokemonSpecies } from '../data/pokemon-species'; +import { default as PokemonSpecies, PokemonSpeciesForm, SpeciesFormKey, getFusedSpeciesName, getPokemonSpecies, getPokemonSpeciesForm } from '../data/pokemon-species'; import * as Utils from '../utils'; import { Type, TypeDamageMultiplier, getTypeDamageMultiplier, getTypeRgb } from '../data/type'; import { getLevelTotalExp } from '../data/exp'; @@ -778,7 +778,8 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { 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(); + // TODO: Might need to pass specific form index in simulated evolution chain + const speciesLevelMoves = getPokemonSpeciesForm(evolutionChain[e][0] as Species, this.formIndex).getLevelMoves(); levelMoves.push(...speciesLevelMoves.filter(lm => (includeEvolutionMoves && !lm[0]) || (lm[0] >= evolutionChain[e][1] && (e === evolutionChain.length - 1 || lm[0] <= evolutionChain[e + 1][1])))); } const uniqueMoves: Moves[] = []; @@ -2074,7 +2075,7 @@ export class PlayerPokemon extends Pokemon { getPossibleEvolution(evolution: SpeciesFormEvolution): Promise { return new Promise(resolve => { const species = getPokemonSpecies(evolution.speciesId); - const formIndex = evolution.evoFormKey !== null ? Math.max(this.species.forms.findIndex(f => f.formKey === evolution.evoFormKey), 0) : this.formIndex; + const formIndex = evolution.evoFormKey !== null ? Math.max(species.forms.findIndex(f => f.formKey === evolution.evoFormKey), 0) : this.formIndex; const ret = this.scene.addPlayerPokemon(species, this.level, this.abilityIndex, formIndex, this.gender, this.shiny, this.ivs, this.nature, this); ret.loadAssets().then(() => resolve(ret)); });