From 17232d73b077d3a1d3b29409ec5e680d66cbd51a Mon Sep 17 00:00:00 2001 From: Dean Date: Wed, 5 Feb 2025 02:09:17 -0800 Subject: [PATCH] Add canApply for imposter --- src/data/ability.ts | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/src/data/ability.ts b/src/data/ability.ts index ef948e8689d..979552fbd31 100644 --- a/src/data/ability.ts +++ b/src/data/ability.ts @@ -2498,18 +2498,7 @@ export class PostSummonTransformAbAttr extends PostSummonAbAttr { super(true); } - canApplyPostSummon(pokemon: Pokemon, passive: boolean, simulated: boolean, args: any[]): boolean { - // SUCCESS CHECK - return true; - } - - async applyPostSummon(pokemon: Pokemon, _passive: boolean, simulated: boolean, _args: any[]): Promise { - const targets = pokemon.getOpponents(); - if (simulated || !targets.length) { - return simulated; - } - const promises: Promise[] = []; - + getTarget(targets: Pokemon[]): Pokemon { let target: Pokemon; if (targets.length > 1) { globalScene.executeWithSeedOffset(() => { @@ -2529,11 +2518,29 @@ export class PostSummonTransformAbAttr extends PostSummonAbAttr { } target = target!; + return target; + } + + canApplyPostSummon(pokemon: Pokemon, passive: boolean, simulated: boolean, args: any[]): boolean { + const targets = pokemon.getOpponents(); + if (simulated || !targets.length) { + return simulated; + } + // transforming from or into fusion pokemon causes various problems (including crashes and save corruption) - if (target.fusionSpecies || pokemon.fusionSpecies) { + if (this.getTarget(targets).fusionSpecies || pokemon.fusionSpecies) { return false; } + return true; + } + + async applyPostSummon(pokemon: Pokemon, _passive: boolean, simulated: boolean, _args: any[]): Promise { + const targets = pokemon.getOpponents(); + const promises: Promise[] = []; + + const target = this.getTarget(targets); + pokemon.summonData.speciesForm = target.getSpeciesForm(); pokemon.summonData.ability = target.getAbility().id; pokemon.summonData.gender = target.getGender(); @@ -2559,7 +2566,6 @@ export class PostSummonTransformAbAttr extends PostSummonAbAttr { }); pokemon.summonData.types = target.getTypes(); promises.push(pokemon.updateInfo()); - globalScene.queueMessage(i18next.t("abilityTriggers:postSummonTransform", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), targetName: target.name, })); globalScene.playSound("battle_anims/PRSFX- Transform"); promises.push(pokemon.loadAssets(false).then(() => {