Skip to content

Commit

Permalink
Fix: [Gen 1] Substitute + Confusion interaction
Browse files Browse the repository at this point in the history
  • Loading branch information
andrebastosdias authored Jan 7, 2025
1 parent 392ab2d commit b112873
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions sim/battle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit b112873

Please sign in to comment.