From eea12a62f6fb939e3fd9f996e7764e7d016c5894 Mon Sep 17 00:00:00 2001 From: innerthunder <168692175+innerthunder@users.noreply.github.com> Date: Fri, 13 Sep 2024 19:15:12 -0700 Subject: [PATCH] [Bug][Beta] Fix bugs from Substitute implementation (#4226) * Fix animation issues with Substitute * Fix Spirit Shackle, etc. incorrectly being removed by Substitute * Fix sub tag unit tests --- src/data/battle-anims.ts | 2 +- src/data/battler-tags.ts | 4 ++-- src/phases/faint-phase.ts | 6 +++--- src/test/battlerTags/substitute.test.ts | 5 ++--- 4 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/data/battle-anims.ts b/src/data/battle-anims.ts index 64f7d85cae3..f07d6cb2409 100644 --- a/src/data/battle-anims.ts +++ b/src/data/battle-anims.ts @@ -910,7 +910,7 @@ export abstract class BattleAnim { const sprites = spriteCache[isUser ? AnimFrameTarget.USER : AnimFrameTarget.TARGET]; const spriteSource = isUser ? userSprite : targetSprite; if ((isUser ? u : t) === sprites.length) { - if (!isUser && !!targetSubstitute) { + if (isUser || !targetSubstitute) { const sprite = scene.addPokemonSprite(isUser ? user! : target, 0, 0, spriteSource!.texture, spriteSource!.frame.name, true); // TODO: are those bangs correct? [ "spriteColors", "fusionSpriteColors" ].map(k => sprite.pipelineData[k] = (isUser ? user! : target).getSprite().pipelineData[k]); // TODO: are those bangs correct? sprite.setPipelineData("spriteKey", (isUser ? user! : target).getBattleSpriteKey()); diff --git a/src/data/battler-tags.ts b/src/data/battler-tags.ts index 965da844121..e02cf205190 100644 --- a/src/data/battler-tags.ts +++ b/src/data/battler-tags.ts @@ -2238,8 +2238,8 @@ export class SubstituteTag extends BattlerTag { pokemon.scene.triggerPokemonBattleAnim(pokemon, PokemonAnimType.SUBSTITUTE_ADD); pokemon.scene.queueMessage(i18next.t("battlerTags:substituteOnAdd", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon) }), 1500); - // Remove any trapping effects from the user - pokemon.findAndRemoveTags(tag => tag instanceof TrappedTag); + // Remove any binding effects from the user + pokemon.findAndRemoveTags(tag => tag instanceof DamagingTrapTag); } /** Queues an on-remove battle animation that removes the Substitute's sprite. */ diff --git a/src/phases/faint-phase.ts b/src/phases/faint-phase.ts index ccb3262b1bb..41384e5e491 100644 --- a/src/phases/faint-phase.ts +++ b/src/phases/faint-phase.ts @@ -124,9 +124,6 @@ export class FaintPhase extends PokemonPhase { this.scene.redirectPokemonMoves(pokemon, allyPokemon); } - pokemon.lapseTags(BattlerTagLapseType.FAINT); - this.scene.getField(true).filter(p => p !== pokemon).forEach(p => p.removeTagsBySourceId(pokemon.id)); - pokemon.faintCry(() => { if (pokemon instanceof PlayerPokemon) { pokemon.addFriendship(-10); @@ -140,6 +137,9 @@ export class FaintPhase extends PokemonPhase { ease: "Sine.easeIn", onComplete: () => { pokemon.resetSprite(); + pokemon.lapseTags(BattlerTagLapseType.FAINT); + this.scene.getField(true).filter(p => p !== pokemon).forEach(p => p.removeTagsBySourceId(pokemon.id)); + pokemon.y -= 150; pokemon.trySetStatus(StatusEffect.FAINT); if (pokemon.isPlayer()) { diff --git a/src/test/battlerTags/substitute.test.ts b/src/test/battlerTags/substitute.test.ts index 1ce81850c13..12888daca50 100644 --- a/src/test/battlerTags/substitute.test.ts +++ b/src/test/battlerTags/substitute.test.ts @@ -1,8 +1,7 @@ import { beforeEach, describe, expect, it, vi } from "vitest"; import Pokemon, { MoveResult, PokemonTurnData, TurnMove, PokemonMove } from "#app/field/pokemon"; import BattleScene from "#app/battle-scene"; -import { BattlerTagLapseType, SubstituteTag, TrappedTag } from "#app/data/battler-tags"; -import { BattlerTagType } from "#app/enums/battler-tag-type"; +import { BattlerTagLapseType, BindTag, SubstituteTag } from "#app/data/battler-tags"; import { Moves } from "#app/enums/moves"; import { PokemonAnimType } from "#app/enums/pokemon-anim-type"; import * as messages from "#app/messages"; @@ -25,7 +24,7 @@ describe("BattlerTag - SubstituteTag", () => { getMaxHp: vi.fn().mockReturnValue(101) as Pokemon["getMaxHp"], findAndRemoveTags: vi.fn().mockImplementation((tagFilter) => { // simulate a Trapped tag set by another Pokemon, then expect the filter to catch it. - const trapTag = new TrappedTag(BattlerTagType.TRAPPED, BattlerTagLapseType.CUSTOM, 0, Moves.NONE, 1); + const trapTag = new BindTag(5, 0); expect(tagFilter(trapTag)).toBeTruthy(); return true; }) as Pokemon["findAndRemoveTags"]