From bc9d07350135f66137d9af3e8cc1421e30571d3e Mon Sep 17 00:00:00 2001 From: ISSOtm Date: Sun, 3 Mar 2019 21:49:52 +0100 Subject: [PATCH 1/4] Add confusion + items/selfdestruct fix --- docs/bugs_and_glitches.md | 60 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 59 insertions(+), 1 deletion(-) diff --git a/docs/bugs_and_glitches.md b/docs/bugs_and_glitches.md index f58d2a06b..7b9caf084 100644 --- a/docs/bugs_and_glitches.md +++ b/docs/bugs_and_glitches.md @@ -231,7 +231,65 @@ This bug existed for all battles in Gold and Silver, and was only fixed for sing ([Video](https://twitter.com/crystal_rby/status/874626362287562752)) -*To do:* Identify specific code causing this bug and fix it. +**Fix:** Edit the end of [hram.asm](/hram.asm) to create a new temporary variable: + +```diff + hClockResetTrigger:: db ; ffeb ++hIsConfusionDamage:: db ; ffec +``` + +Then edit `HitSelfInConfusion` in [engine/battle/effect_commands.asm](/engine/battle/effect_commands.asm): + +```diff + pop af + ld e, a ++ ld a, 1 ++ ldh [hIsConfusionDamage], a + ret +``` + +Then, in the same file, edit `BattleCommand_DamageCalc`: + +```diff + .skip_zero_damage_check + ++ xor a ; Not confusion damage ++ ldh [hIsConfusionDamage], a ++ ++ConfusionDamageCalc: + ; Minimum defense value is 1. + ld a, c + and a + jr nz, .not_dividing_by_zero + ld c, 1 + .not_dividing_by_zero +``` + +```diff + ; Item boosts ++ ldh a, [hIsConfusionDamage] ++ and a ++ jr nz, .DoneItem ; Item boosts don't apply to confusion damage + call GetUserItem +``` + +Finally, replace the calls in `CheckEnemyTurn` and `HitConfusion`, still in the same file: + +```diff + ld hl, HurtItselfText + call StdBattleTextBox + call HitSelfInConfusion +- call BattleCommand_DamageCalc ++ call ConfusionDamageCalc + call BattleCommand_LowerSub +``` + +```diff + call HitSelfInConfusion +- call BattleCommand_DamageCalc ++ call ConfusionDamageCalc + call BattleCommand_LowerSub +``` ## Moves that lower Defense can do so after breaking a Substitute From c57ed5775cfe44e537d26797ed98b6467b4db478 Mon Sep 17 00:00:00 2001 From: ISSOtm Date: Sun, 3 Mar 2019 23:55:24 +0100 Subject: [PATCH 2/4] Rename PlayerMonFaintHappinessMod Seriously, mini-rant here: we were three to spend a couple hours trying to find something in this function that was completely unrelated to happiness... and apparently there's been far worse. :') Props to you guys for having been through this =D --- engine/battle/core.asm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/engine/battle/core.asm b/engine/battle/core.asm index 72e85f088..4e9d13f15 100644 --- a/engine/battle/core.asm +++ b/engine/battle/core.asm @@ -2131,7 +2131,7 @@ UpdateBattleStateAndExperienceAfterEnemyFaint: ld a, [wWhichMonFaintedFirst] and a jr nz, .player_mon_did_not_faint - call PlayerMonFaintHappinessMod + call UpdateFaintedPlayerMon .player_mon_did_not_faint call CheckPlayerPartyForFitMon @@ -2601,7 +2601,7 @@ HandlePlayerMonFaint: call z, FaintEnemyPokemon ld a, $1 ld [wWhichMonFaintedFirst], a - call PlayerMonFaintHappinessMod + call UpdateFaintedPlayerMon call CheckPlayerPartyForFitMon ld a, d and a @@ -2642,7 +2642,7 @@ HandlePlayerMonFaint: jp z, WildFled_EnemyFled_LinkBattleCanceled jp DoubleSwitch -PlayerMonFaintHappinessMod: +UpdateFaintedPlayerMon: ld a, [wCurBattleMon] ld c, a ld hl, wBattleParticipantsNotFainted From d79fca8c6e0c3da8782b9952740706bf73e97a17 Mon Sep 17 00:00:00 2001 From: ISSOtm Date: Mon, 4 Mar 2019 00:01:55 +0100 Subject: [PATCH 3/4] Add Pursuit-switching fainting no-status-clearing fix Ridiculously long and stupid name for a bug that took a ridiculous and stupid amount of time to track. :') --- docs/bugs_and_glitches.md | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/docs/bugs_and_glitches.md b/docs/bugs_and_glitches.md index 7b9caf084..10f405865 100644 --- a/docs/bugs_and_glitches.md +++ b/docs/bugs_and_glitches.md @@ -387,7 +387,28 @@ Add this to the end of each file: ([Video](https://www.youtube.com/watch?v=tiRvw-Nb2ME)) -*To do:* Identify specific code causing this bug and fix it. +**Fix:** Edit `PursuitSwitch` in [engine/battle/core.asm](/engine/battle/core.asm) + +```diff + ld a, $f0 + ld [wCryTracks], a + ld a, [wBattleMonSpecies] + call PlayStereoCry ++ ld a, [wCurBattleMon] ++ push af + ld a, [wLastPlayerMon] ++ ld [wCurBattleMon], a ++ call UpdateFaintedPlayerMon ++ pop af ++ ld [wCurBattleMon], a +- ld c, a +- ld hl, wBattleParticipantsNotFainted +- ld b, RESET_FLAG +- predef SmallFarFlagAction + call PlayerMonFaintedAnimation + ld hl, BattleText_MonFainted + jr .done_fainted +``` ## Lock-On and Mind Reader don't always bypass Fly and Dig From f6e94dfd7903578e39ef419f04303937bedf9628 Mon Sep 17 00:00:00 2001 From: ISSOtm Date: Mon, 4 Mar 2019 00:21:30 +0100 Subject: [PATCH 4/4] Fix spaces --- docs/bugs_and_glitches.md | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/docs/bugs_and_glitches.md b/docs/bugs_and_glitches.md index 10f405865..4f6871e5c 100644 --- a/docs/bugs_and_glitches.md +++ b/docs/bugs_and_glitches.md @@ -394,17 +394,17 @@ Add this to the end of each file: ld [wCryTracks], a ld a, [wBattleMonSpecies] call PlayStereoCry -+ ld a, [wCurBattleMon] -+ push af ++ ld a, [wCurBattleMon] ++ push af ld a, [wLastPlayerMon] -+ ld [wCurBattleMon], a -+ call UpdateFaintedPlayerMon -+ pop af -+ ld [wCurBattleMon], a -- ld c, a -- ld hl, wBattleParticipantsNotFainted -- ld b, RESET_FLAG -- predef SmallFarFlagAction ++ ld [wCurBattleMon], a ++ call UpdateFaintedPlayerMon ++ pop af ++ ld [wCurBattleMon], a +- ld c, a +- ld hl, wBattleParticipantsNotFainted +- ld b, RESET_FLAG +- predef SmallFarFlagAction call PlayerMonFaintedAnimation ld hl, BattleText_MonFainted jr .done_fainted