From 4bbf1acbd8385cdad5a76fc60b023b550b4136a6 Mon Sep 17 00:00:00 2001 From: Flashfyre Date: Tue, 9 Jan 2024 23:53:31 -0500 Subject: [PATCH] Fix crash on catching a Pokemon --- src/pokemon.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/pokemon.ts b/src/pokemon.ts index 7594b1424..faf57bbc8 100644 --- a/src/pokemon.ts +++ b/src/pokemon.ts @@ -34,7 +34,7 @@ import { DamageAchv, achvs } from './system/achv'; import { DexAttr } from './system/game-data'; import { QuantizerCelebi, argbFromRgba, rgbaFromArgb } from '@material/material-color-utilities'; import { Nature, getNatureStatMultiplier } from './data/nature'; -import { SpeciesFormChange, SpeciesFormChangeMoveUsedTrigger, SpeciesFormChangeStatusEffectTrigger } from './data/pokemon-forms'; +import { SpeciesFormChange, SpeciesFormChangeActiveTrigger, SpeciesFormChangeMoveUsedTrigger, SpeciesFormChangeStatusEffectTrigger } from './data/pokemon-forms'; export enum FieldPosition { CENTER, @@ -1491,7 +1491,8 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { this.battleSummonData = new PokemonBattleSummonData(); if (this.getTag(BattlerTagType.SEEDED)) this.lapseTag(BattlerTagType.SEEDED); - this.scene.triggerPokemonFormChange(this, SpeciesFormChangeMoveUsedTrigger, true); + if (this.scene) + this.scene.triggerPokemonFormChange(this, SpeciesFormChangeMoveUsedTrigger, true); } resetTurnData(): void { @@ -2313,6 +2314,7 @@ export class EnemyPokemon extends Pokemon { const newPokemon = this.scene.addPlayerPokemon(this.species, this.level, this.abilityIndex, this.formIndex, this.gender, this.shiny, this.ivs, this.nature, this); party.push(newPokemon); ret = newPokemon; + this.scene.triggerPokemonFormChange(newPokemon, SpeciesFormChangeActiveTrigger, true); } return ret;