From f0b00f9f27c483a779c844702f051d73b594189a Mon Sep 17 00:00:00 2001 From: Flashfyre Date: Thu, 28 Mar 2024 00:24:24 -0400 Subject: [PATCH] Add move target redirection --- src/phases.ts | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/phases.ts b/src/phases.ts index d2a4b0948..fe1c36caa 100644 --- a/src/phases.ts +++ b/src/phases.ts @@ -1954,7 +1954,7 @@ export class CommonAnimPhase extends PokemonPhase { export class MovePhase extends BattlePhase { public pokemon: Pokemon; public move: PokemonMove; - protected targets: BattlerIndex[]; + public targets: BattlerIndex[]; protected followUp: boolean; protected ignorePp: boolean; protected cancelled: boolean; @@ -2849,6 +2849,18 @@ export class FaintPhase extends PokemonPhase { } } + if (this.scene.currentBattle.double) { + const allyPokemon = pokemon.getAlly(); + if (allyPokemon?.isActive(true)) { + let targetingMovePhase: MovePhase; + do { + targetingMovePhase = this.scene.findPhase(mp => mp instanceof MovePhase && mp.targets.length === 1 && mp.targets[0] === pokemon.getBattlerIndex()) as MovePhase; + if (targetingMovePhase && targetingMovePhase.targets[0] !== allyPokemon.getBattlerIndex()) + targetingMovePhase.targets[0] = allyPokemon.getBattlerIndex(); + } while (targetingMovePhase); + } + } + pokemon.lapseTags(BattlerTagLapseType.FAINT); this.scene.getField(true).filter(p => p !== pokemon).forEach(p => p.removeTagsBySourceId(pokemon.id));