From b1128738e5a7c1a73c86292ca2673a7c948f266e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Bastos=20Dias?= <80102738+andrebastosdias@users.noreply.github.com> Date: Tue, 7 Jan 2025 06:22:33 +0000 Subject: [PATCH] Fix: [Gen 1] Substitute + Confusion interaction --- sim/battle.ts | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/sim/battle.ts b/sim/battle.ts index dba8f006b52c..294a7113acbf 100644 --- a/sim/battle.ts +++ b/sim/battle.ts @@ -2043,13 +2043,15 @@ export class Battle { this.lastDamage = damage; if (target.volatiles['substitute']) { const hint = "In Gen 1, if a Pokemon with a Substitute hurts itself due to confusion or Jump Kick/Hi Jump Kick recoil and the target"; - if (source?.volatiles['substitute']) { - source.volatiles['substitute'].hp -= damage; - if (source.volatiles['substitute'].hp <= 0) { - source.removeVolatile('substitute'); - source.subFainted = true; + // if the move was a self-targeting move, the source is the same as the target. We need the check the opposing substitute + const foe = target.side.foe.active[0]; + if (foe?.volatiles['substitute']) { + foe.volatiles['substitute'].hp -= damage; + if (foe.volatiles['substitute'].hp <= 0) { + foe.removeVolatile('substitute'); + foe.subFainted = true; } else { - this.add('-activate', source, 'Substitute', '[damage]'); + this.add('-activate', foe, 'Substitute', '[damage]'); } this.hint(hint + " has a Substitute, the target's Substitute takes the damage."); return damage;