diff --git a/src/data/mystery-encounters/encounters/clowning-around-encounter.ts b/src/data/mystery-encounters/encounters/clowning-around-encounter.ts index f6700bb3716..35d8ef0396f 100644 --- a/src/data/mystery-encounters/encounters/clowning-around-encounter.ts +++ b/src/data/mystery-encounters/encounters/clowning-around-encounter.ts @@ -15,7 +15,7 @@ import { TrainerType } from "#enums/trainer-type"; import { getPokemonSpecies } from "#app/data/pokemon-species"; import { Abilities } from "#enums/abilities"; import { applyAbilityOverrideToPokemon, applyModifierTypeToPlayerPokemon } from "#app/data/mystery-encounters/utils/encounter-pokemon-utils"; -import type { Type } from "#enums/type"; +import { Type } from "#enums/type"; import { MysteryEncounterOptionBuilder } from "#app/data/mystery-encounters/mystery-encounter-option"; import { MysteryEncounterOptionMode } from "#enums/mystery-encounter-option-mode"; import { randSeedInt, randSeedShuffle } from "#app/utils"; @@ -347,7 +347,7 @@ export const ClowningAroundEncounter: MysteryEncounter = priorityTypes = randSeedShuffle(priorityTypes); } - const newTypes = [ originalTypes[0] ]; + const newTypes = [ Type.UNKNOWN ]; let secondType: Type | null = null; while (secondType === null || secondType === newTypes[0] || originalTypes.includes(secondType)) { if (priorityTypes.length > 0) { diff --git a/src/data/mystery-encounters/encounters/weird-dream-encounter.ts b/src/data/mystery-encounters/encounters/weird-dream-encounter.ts index e8a4c405d5f..e047a7a4f01 100644 --- a/src/data/mystery-encounters/encounters/weird-dream-encounter.ts +++ b/src/data/mystery-encounters/encounters/weird-dream-encounter.ts @@ -1,4 +1,4 @@ -import type { Type } from "#enums/type"; +import { Type } from "#enums/type"; import { MysteryEncounterType } from "#enums/mystery-encounter-type"; import { Species } from "#enums/species"; import { globalScene } from "#app/global-scene"; @@ -528,7 +528,7 @@ async function postProcessTransformedPokemon(previousPokemon: PlayerPokemon, new // Randomize the second type of the pokemon // If the pokemon does not normally have a second type, it will gain 1 - const newTypes = [ newPokemon.getTypes()[0] ]; + const newTypes = [ Type.UNKNOWN ]; let newType = randSeedInt(18) as Type; while (newType === newTypes[0]) { newType = randSeedInt(18) as Type; diff --git a/src/field/pokemon.ts b/src/field/pokemon.ts index 5b7cafeefb8..2f4cc89049d 100644 --- a/src/field/pokemon.ts +++ b/src/field/pokemon.ts @@ -1259,29 +1259,6 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { if (!types.length || !includeTeraType) { if (!ignoreOverride && this.summonData?.types && this.summonData.types.length > 0) { this.summonData.types.forEach(t => types.push(t)); - } else if (this.customPokemonData.types && this.customPokemonData.types.length > 0) { - // "Permanent" override for a Pokemon's normal types, currently only used by Mystery Encounters - types.push(this.customPokemonData.types[0]); - - // Fusing a Pokemon onto something with "permanently changed" types will still apply the fusion's types as normal - const fusionSpeciesForm = this.getFusionSpeciesForm(ignoreOverride); - if (fusionSpeciesForm) { - // Check if the fusion Pokemon also had "permanently changed" types - const fusionMETypes = this.fusionCustomPokemonData?.types; - if (fusionMETypes && fusionMETypes.length >= 2 && fusionMETypes[1] !== types[0]) { - types.push(fusionMETypes[1]); - } else if (fusionMETypes && fusionMETypes.length === 1 && fusionMETypes[0] !== types[0]) { - types.push(fusionMETypes[0]); - } else if (fusionSpeciesForm.type2 !== null && fusionSpeciesForm.type2 !== types[0]) { - types.push(fusionSpeciesForm.type2); - } else if (fusionSpeciesForm.type1 !== types[0]) { - types.push(fusionSpeciesForm.type1); - } - } - - if (types.length === 1 && this.customPokemonData.types.length >= 2) { - types.push(this.customPokemonData.types[1]); - } } else { const speciesForm = this.getSpeciesForm(ignoreOverride); @@ -1306,6 +1283,38 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { if (types.length === 1 && speciesForm.type2 !== null) { types.push(speciesForm.type2); } + + // "Permanent" override for a Pokemon's normal types, currently only used by Mystery Encounters + if (this.customPokemonData.types && this.customPokemonData.types.length > 0) { + + if (this.customPokemonData.types[0] !== Type.UNKNOWN) { + types[0] = this.customPokemonData.types[0]; + } + + // Fusing a Pokemon onto something with "permanently changed" types will still apply the fusion's types as normal + const fusionSpeciesForm = this.getFusionSpeciesForm(ignoreOverride); + if (fusionSpeciesForm) { + // Check if the fusion Pokemon also had "permanently changed" types + const fusionMETypes = this.fusionCustomPokemonData?.types; + if (fusionMETypes && fusionMETypes.length >= 2 && fusionMETypes[1] !== types[0] && fusionMETypes[1] !== Type.UNKNOWN) { + types.push(fusionMETypes[1]); + } else if (fusionMETypes && fusionMETypes.length === 1 && fusionMETypes[0] !== types[0] && fusionMETypes[0] !== Type.UNKNOWN) { + types.push(fusionMETypes[0]); + } else if (fusionSpeciesForm.type2 !== null && fusionSpeciesForm.type2 !== types[0]) { + types.push(fusionSpeciesForm.type2); + } else if (fusionSpeciesForm.type1 !== types[0]) { + types.push(fusionSpeciesForm.type1); + } + } + + if (this.customPokemonData.types.length >= 2 && this.customPokemonData.types[1] !== Type.UNKNOWN) { + if (types.length === 1) { + types.push(this.customPokemonData.types[1]); + } else { + types[1] = this.customPokemonData.types[1]; + } + } + } } } @@ -4564,7 +4573,6 @@ export class PlayerPokemon extends Pokemon { changeForm(formChange: SpeciesFormChange): Promise { return new Promise(resolve => { - const previousFormIndex = this.formIndex; this.formIndex = Math.max(this.species.forms.findIndex(f => f.formKey === formChange.formKey), 0); this.generateName(); const abilityCount = this.getSpeciesForm().getAbilityCount(); @@ -4572,25 +4580,6 @@ export class PlayerPokemon extends Pokemon { this.abilityIndex = abilityCount - 1; } - // In cases where a form change updates the type of a Pokemon from its previous form (Arceus, Silvally, Castform, etc.), - // persist that type change in customPokemonData if necessary - const baseForm = this.species.forms[previousFormIndex]; - const baseFormTypes = [ baseForm.type1, baseForm.type2 ]; - if (this.customPokemonData.types.length > 0) { - if (this.getSpeciesForm().type1 !== baseFormTypes[0]) { - this.customPokemonData.types[0] = this.getSpeciesForm().type1; - } - - const type2 = this.getSpeciesForm().type2; - if (!isNullOrUndefined(type2) && type2 !== baseFormTypes[1]) { - if (this.customPokemonData.types.length > 1) { - this.customPokemonData.types[1] = type2; - } else { - this.customPokemonData.types.push(type2); - } - } - } - this.compatibleTms.splice(0, this.compatibleTms.length); this.generateCompatibleTms(); const updateAndResolve = () => {