From 57fc81d44e1f26b8895d37c9d847400851a8f8b4 Mon Sep 17 00:00:00 2001 From: Hyperdriveguy Date: Fri, 20 Jul 2018 17:39:53 -0700 Subject: [PATCH] Add Counter and Mirror Coat bugfix --- docs/bugs_and_glitches.md | 30 +++++++++++++++++++++- engine/battle/move_effects/counter.asm | 1 + engine/battle/move_effects/mirror_coat.asm | 1 + 3 files changed, 31 insertions(+), 1 deletion(-) diff --git a/docs/bugs_and_glitches.md b/docs/bugs_and_glitches.md index f7675ae78..941b4bbac 100644 --- a/docs/bugs_and_glitches.md +++ b/docs/bugs_and_glitches.md @@ -246,7 +246,35 @@ DefenseDownHit: ([Video](https://www.youtube.com/watch?v=uRYyzKRatFk)) -*To do:* Identify specific code causing this bug and fix it. +This is a bug with `BattleCommand_Counter` in [engine/battle/move_effects/counter.asm](/engine/battle/move_effects/counter.asm) and `BattleCommand_MirrorCoat` in [engine/battle/move_effects/mirror_coat.asm](/engine/battle/move_effects/mirror_coat.asm): + +```asm + ; BUG: Move should fail with all non-damaging battle actions + ld hl, wCurDamage + ld a, [hli] + or [hl] + ret z +``` + +**Fix:** + +```diff + ld hl, wCurDamage + ld a, [hli] + or [hl] +- ret z ++ jp z, .failed +``` + +Add this to the end of each file: + +```diff ++.failed ++ ld a, 1 ++ ld [wEffectFailed], a ++ and a ++ ret +``` ## A Disabled but PP Up–enhanced move may not trigger Struggle diff --git a/engine/battle/move_effects/counter.asm b/engine/battle/move_effects/counter.asm index b811b293c..9948ebcbd 100644 --- a/engine/battle/move_effects/counter.asm +++ b/engine/battle/move_effects/counter.asm @@ -36,6 +36,7 @@ BattleCommand_Counter: ; 35813 cp SPECIAL ret nc + ; BUG: Move should fail with all non-damaging battle actions ld hl, wCurDamage ld a, [hli] or [hl] diff --git a/engine/battle/move_effects/mirror_coat.asm b/engine/battle/move_effects/mirror_coat.asm index 41e296108..dcdd9c2f3 100644 --- a/engine/battle/move_effects/mirror_coat.asm +++ b/engine/battle/move_effects/mirror_coat.asm @@ -37,6 +37,7 @@ BattleCommand_MirrorCoat: ; 37c95 cp SPECIAL ret c + ; BUG: Move should fail with all non-damaging battle actions ld hl, wCurDamage ld a, [hli] or [hl]