From 909264b6c0604f6b080d5a27a17fd8579df3a7d8 Mon Sep 17 00:00:00 2001 From: Sean Mon Date: Fri, 4 Oct 2024 18:54:44 +0100 Subject: [PATCH] Fix for [Bug] Metal Burst causes game to crash if intended target faints #4575 --- src/phases/move-phase.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/phases/move-phase.ts b/src/phases/move-phase.ts index 807f194bad5..bc8d8c0dde6 100644 --- a/src/phases/move-phase.ts +++ b/src/phases/move-phase.ts @@ -376,7 +376,7 @@ export class MovePhase extends BattlePhase { // account for metal burst and comeuppance hitting remaining targets in double battles // counterattack will redirect to remaining ally if original attacker faints if (this.scene.currentBattle.double && this.move.getMove().hasFlag(MoveFlags.REDIRECT_COUNTER)) { - if (this.scene.getField()[this.targets[0]].hp === 0) { + if (attacker?.isActive(true) && this.scene.getField()[this.targets[0]].hp === 0) { const opposingField = this.pokemon.isPlayer() ? this.scene.getEnemyField() : this.scene.getPlayerField(); this.targets[0] = opposingField.find(p => p.hp > 0)?.getBattlerIndex() ?? BattlerIndex.ATTACKER; }