From 9e892597ea3fcb26efe033b752e0ef07b4985c59 Mon Sep 17 00:00:00 2001 From: jnotsknab Date: Wed, 18 Jun 2025 16:55:31 -0500 Subject: [PATCH 1/6] 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) { From 0a2e6e1cec738c9032899cf703f46c66821e27f0 Mon Sep 17 00:00:00 2001 From: jnotsknab Date: Wed, 18 Jun 2025 18:03:02 -0500 Subject: [PATCH 2/6] Updated Comments --- src/data/battler-tags.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/data/battler-tags.ts b/src/data/battler-tags.ts index d49061a97f9..2b1f47d9757 100644 --- a/src/data/battler-tags.ts +++ b/src/data/battler-tags.ts @@ -3221,10 +3221,20 @@ export class ImprisonTag extends MoveRestrictionBattlerTag { } } +/** + * Battler Tag indicating that a Pokémon has used {@linkcode MoveId.TRANSFORM} + * + * The tag allows us to prevent certain actions such as using Transform on a Pokemon which has already transformed, + * and is used to ensure correct battle behavior after transformation. + */ export class TransformTag extends BattlerTag { constructor(sourceId: number) { super(BattlerTagType.TRANSFORM, BattlerTagLapseType.MOVE, Number.MAX_SAFE_INTEGER, MoveId.TRANSFORM, sourceId); } + /** + * Adds the Transform battler tag to the Pokemon transforming. + * @param pokemon - The {@linkcode Pokemon} transforming + */ override onAdd(pokemon: Pokemon): void { super.onAdd(pokemon); } From f80211406fce03a653006293da63e0b6c7f3f904 Mon Sep 17 00:00:00 2001 From: jnotsknab Date: Wed, 18 Jun 2025 18:15:53 -0500 Subject: [PATCH 3/6] Revised Comments --- src/data/abilities/ability.ts | 1 + src/phases/move-phase.ts | 1 + 2 files changed, 2 insertions(+) diff --git a/src/data/abilities/ability.ts b/src/data/abilities/ability.ts index 1e54c65f800..2c14b6ec795 100644 --- a/src/data/abilities/ability.ts +++ b/src/data/abilities/ability.ts @@ -3911,6 +3911,7 @@ export class PostSummonTransformAbAttr extends PostSummonAbAttr { const target = this.getTarget(targets); const user = pokemon; + //Prevents Imposter from triggering on a transformed target or if the user is already transformed if (user?.getTag(BattlerTagType.TRANSFORM) || target?.getTag(BattlerTagType.TRANSFORM)) { return false; } diff --git a/src/phases/move-phase.ts b/src/phases/move-phase.ts index 997fa5a4aa0..0feb3032b27 100644 --- a/src/phases/move-phase.ts +++ b/src/phases/move-phase.ts @@ -340,6 +340,7 @@ export class MovePhase extends BattlePhase { } if ( + //Prevent using Transform if either the user or target is already transformed this.move.getMove().id === MoveId.TRANSFORM && (targets[0].getTag(BattlerTagType.TRANSFORM) || this.pokemon.getTag(BattlerTagType.TRANSFORM)) ) { From c842f198f12ca54741840936584efae6730becbb Mon Sep 17 00:00:00 2001 From: jnotsknab Date: Thu, 19 Jun 2025 19:51:14 -0500 Subject: [PATCH 4/6] Revised Changes on how tranformed pokemon are referenced to align with reviewer's suggestions --- src/data/abilities/ability.ts | 3 +-- src/data/battler-tags.ts | 21 --------------------- src/field/pokemon.ts | 4 ++++ src/phases/move-phase.ts | 2 +- 4 files changed, 6 insertions(+), 24 deletions(-) diff --git a/src/data/abilities/ability.ts b/src/data/abilities/ability.ts index 2c14b6ec795..17c1e02d773 100644 --- a/src/data/abilities/ability.ts +++ b/src/data/abilities/ability.ts @@ -3909,10 +3909,9 @@ 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; //Prevents Imposter from triggering on a transformed target or if the user is already transformed - if (user?.getTag(BattlerTagType.TRANSFORM) || target?.getTag(BattlerTagType.TRANSFORM)) { + if (pokemon?.isTransformed() || target?.isTransformed()) { return false; } diff --git a/src/data/battler-tags.ts b/src/data/battler-tags.ts index 2b1f47d9757..8405fd1dd4d 100644 --- a/src/data/battler-tags.ts +++ b/src/data/battler-tags.ts @@ -3221,25 +3221,6 @@ export class ImprisonTag extends MoveRestrictionBattlerTag { } } -/** - * Battler Tag indicating that a Pokémon has used {@linkcode MoveId.TRANSFORM} - * - * The tag allows us to prevent certain actions such as using Transform on a Pokemon which has already transformed, - * and is used to ensure correct battle behavior after transformation. - */ -export class TransformTag extends BattlerTag { - constructor(sourceId: number) { - super(BattlerTagType.TRANSFORM, BattlerTagLapseType.MOVE, Number.MAX_SAFE_INTEGER, MoveId.TRANSFORM, sourceId); - } - /** - * Adds the Transform battler tag to the Pokemon transforming. - * @param pokemon - The {@linkcode Pokemon} transforming - */ - 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. @@ -3648,8 +3629,6 @@ 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/field/pokemon.ts b/src/field/pokemon.ts index e9cc4f70d70..deeffd736e8 100644 --- a/src/field/pokemon.ts +++ b/src/field/pokemon.ts @@ -1062,6 +1062,10 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { return species; } + isTransformed(): boolean { + return this.summonData.speciesForm !== null; + } + /** * @param {boolean} useIllusion - Whether we want the fusionSpeciesForm of the illusion or not. */ diff --git a/src/phases/move-phase.ts b/src/phases/move-phase.ts index 0feb3032b27..df2697f17a8 100644 --- a/src/phases/move-phase.ts +++ b/src/phases/move-phase.ts @@ -342,7 +342,7 @@ export class MovePhase extends BattlePhase { if ( //Prevent using Transform if either the user or target is already transformed this.move.getMove().id === MoveId.TRANSFORM && - (targets[0].getTag(BattlerTagType.TRANSFORM) || this.pokemon.getTag(BattlerTagType.TRANSFORM)) + (targets[0].isTransformed() || this.pokemon.isTransformed()) ) { this.showMoveText(); this.showFailedText(); From 53e67dbec13acb17ec014ad8e4c90bbe51cfd189 Mon Sep 17 00:00:00 2001 From: jnotsknab Date: Thu, 19 Jun 2025 19:56:14 -0500 Subject: [PATCH 5/6] Removed unused BattlerTag type for transform --- src/enums/battler-tag-type.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/enums/battler-tag-type.ts b/src/enums/battler-tag-type.ts index a19d81ba659..719b08c5b81 100644 --- a/src/enums/battler-tag-type.ts +++ b/src/enums/battler-tag-type.ts @@ -85,7 +85,6 @@ export enum BattlerTagType { HEAL_BLOCK = "HEAL_BLOCK", TORMENT = "TORMENT", TAUNT = "TAUNT", - TRANSFORM = "TRANSFORM", IMPRISON = "IMPRISON", SYRUP_BOMB = "SYRUP_BOMB", ELECTRIFIED = "ELECTRIFIED", From 9b305ca65d630a992bbe947dc61ab2bd07326bf4 Mon Sep 17 00:00:00 2001 From: jnotsknab Date: Thu, 19 Jun 2025 19:58:44 -0500 Subject: [PATCH 6/6] Removed addition of the transform tag to a pokemon in the PokemonTransformPhase --- src/phases/pokemon-transform-phase.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/phases/pokemon-transform-phase.ts b/src/phases/pokemon-transform-phase.ts index eacc4f58d5f..938915309d9 100644 --- a/src/phases/pokemon-transform-phase.ts +++ b/src/phases/pokemon-transform-phase.ts @@ -39,8 +39,6 @@ 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) {