From 9e892597ea3fcb26efe033b752e0ef07b4985c59 Mon Sep 17 00:00:00 2001 From: jnotsknab Date: Wed, 18 Jun 2025 16:55:31 -0500 Subject: [PATCH] Fixed Transform and Imposter Bug --- src/data/abilities/ability.ts | 7 ++++++- src/data/battler-tags.ts | 11 +++++++++++ src/data/moves/move.ts | 1 - src/enums/battler-tag-type.ts | 1 + src/phases/move-phase.ts | 10 ++++++++++ src/phases/pokemon-transform-phase.ts | 2 ++ 6 files changed, 30 insertions(+), 2 deletions(-) diff --git a/src/data/abilities/ability.ts b/src/data/abilities/ability.ts index 70195d6a152..1e54c65f800 100644 --- a/src/data/abilities/ability.ts +++ b/src/data/abilities/ability.ts @@ -3909,8 +3909,13 @@ export class PostSummonTransformAbAttr extends PostSummonAbAttr { override canApplyPostSummon(pokemon: Pokemon, _passive: boolean, simulated: boolean, _args: any[]): boolean { const targets = pokemon.getOpponents(); const target = this.getTarget(targets); + const user = pokemon; - if (target.summonData.illusion) { + if (user?.getTag(BattlerTagType.TRANSFORM) || target?.getTag(BattlerTagType.TRANSFORM)) { + return false; + } + + if (target?.summonData?.illusion) { return false; } diff --git a/src/data/battler-tags.ts b/src/data/battler-tags.ts index 8405fd1dd4d..d49061a97f9 100644 --- a/src/data/battler-tags.ts +++ b/src/data/battler-tags.ts @@ -3221,6 +3221,15 @@ export class ImprisonTag extends MoveRestrictionBattlerTag { } } +export class TransformTag extends BattlerTag { + constructor(sourceId: number) { + super(BattlerTagType.TRANSFORM, BattlerTagLapseType.MOVE, Number.MAX_SAFE_INTEGER, MoveId.TRANSFORM, sourceId); + } + override onAdd(pokemon: Pokemon): void { + super.onAdd(pokemon); + } +} + /** * Battler Tag that applies the effects of Syrup Bomb to the target Pokemon. * For three turns, starting from the turn of hit, at the end of each turn, the target Pokemon's speed will decrease by 1. @@ -3629,6 +3638,8 @@ export function getBattlerTag( return new TauntTag(); case BattlerTagType.IMPRISON: return new ImprisonTag(sourceId); + case BattlerTagType.TRANSFORM: + return new TransformTag(sourceId); case BattlerTagType.SYRUP_BOMB: return new SyrupBombTag(sourceId); case BattlerTagType.TELEKINESIS: diff --git a/src/data/moves/move.ts b/src/data/moves/move.ts index f61e8debc9f..02a6f957f3e 100644 --- a/src/data/moves/move.ts +++ b/src/data/moves/move.ts @@ -7599,7 +7599,6 @@ export class TransformAttr extends MoveEffectAttr { globalScene.phaseManager.unshiftNew("PokemonTransformPhase", user.getBattlerIndex(), target.getBattlerIndex()); - globalScene.phaseManager.queueMessage(i18next.t("moveTriggers:transformedIntoTarget", { pokemonName: getPokemonNameWithAffix(user), targetName: getPokemonNameWithAffix(target) })); return true; } diff --git a/src/enums/battler-tag-type.ts b/src/enums/battler-tag-type.ts index 719b08c5b81..a19d81ba659 100644 --- a/src/enums/battler-tag-type.ts +++ b/src/enums/battler-tag-type.ts @@ -85,6 +85,7 @@ export enum BattlerTagType { HEAL_BLOCK = "HEAL_BLOCK", TORMENT = "TORMENT", TAUNT = "TAUNT", + TRANSFORM = "TRANSFORM", IMPRISON = "IMPRISON", SYRUP_BOMB = "SYRUP_BOMB", ELECTRIFIED = "ELECTRIFIED", diff --git a/src/phases/move-phase.ts b/src/phases/move-phase.ts index 41a1042387b..997fa5a4aa0 100644 --- a/src/phases/move-phase.ts +++ b/src/phases/move-phase.ts @@ -339,6 +339,16 @@ export class MovePhase extends BattlePhase { this.showMoveText(); } + if ( + this.move.getMove().id === MoveId.TRANSFORM && + (targets[0].getTag(BattlerTagType.TRANSFORM) || this.pokemon.getTag(BattlerTagType.TRANSFORM)) + ) { + this.showMoveText(); + this.showFailedText(); + this.end(); + return; + } + // Clear out any two turn moves once they've been used. // TODO: Refactor move queues and remove this assignment; // Move queues should be handled by the calling `CommandPhase` or a manager for it diff --git a/src/phases/pokemon-transform-phase.ts b/src/phases/pokemon-transform-phase.ts index 938915309d9..eacc4f58d5f 100644 --- a/src/phases/pokemon-transform-phase.ts +++ b/src/phases/pokemon-transform-phase.ts @@ -39,6 +39,8 @@ export class PokemonTransformPhase extends PokemonPhase { // Power Trick's effect is removed after using Transform user.removeTag(BattlerTagType.POWER_TRICK); + //Begin tracking Pokemon as transformed + user.addTag(BattlerTagType.TRANSFORM); // Copy all stats (except HP) for (const s of EFFECTIVE_STATS) {