From db4373ab4a4fb7ec98773a4b0cdcdb9eaa2b562a Mon Sep 17 00:00:00 2001 From: Benjamin Odom Date: Fri, 3 May 2024 13:12:23 -0500 Subject: [PATCH] Update Second Change Form Function and Fix Form Change on Refresh --- src/data/pokemon-forms.ts | 5 ++++- src/field/pokemon.ts | 9 ++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/data/pokemon-forms.ts b/src/data/pokemon-forms.ts index 55e21ae928b..a67a09df74a 100644 --- a/src/data/pokemon-forms.ts +++ b/src/data/pokemon-forms.ts @@ -115,7 +115,10 @@ export class SpeciesFormChange { formIndexes.push(pokemon.fusionFormIndex); } - const formMatch = [true, true]; + const formMatch = [true]; + if (pokemon.isFusion()) + formMatch.push(true); + for (let i = 0; i < speciesArray.length; ++i) { const species = speciesArray[i]; const formIndex = formIndexes[i]; diff --git a/src/field/pokemon.ts b/src/field/pokemon.ts index 2df8748a9fa..886e2f12f70 100644 --- a/src/field/pokemon.ts +++ b/src/field/pokemon.ts @@ -1660,8 +1660,15 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { } changeForm(formChange: SpeciesFormChange): Promise { + const matchesBase = this.species.speciesId == formChange.speciesId; + return new Promise(resolve => { - this.formIndex = Math.max(this.species.forms.findIndex(f => f.formKey === formChange.formKey), 0); + const newFormIndex = Math.max((matchesBase ? this.species : this.fusionSpecies).forms.findIndex(f => f.formKey === formChange.formKey), 0); + if (matchesBase) + this.formIndex = newFormIndex; + else + this.fusionFormIndex = newFormIndex; + this.generateName(); const abilityCount = this.getSpeciesForm().getAbilityCount(); if (this.abilityIndex >= abilityCount) // Shouldn't happen