summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorISSOtm <eldredhabert0@gmail.com>2019-03-03 21:49:52 +0100
committerISSOtm <eldredhabert0@gmail.com>2019-03-03 21:49:52 +0100
commitbc9d07350135f66137d9af3e8cc1421e30571d3e (patch)
treede2b67fa1cf19967207bb9cd2980cb0f0a1ade19
parentae319020740918973849652a5d0ab8ff7f8dbbd7 (diff)
Add confusion + items/selfdestruct fix
-rw-r--r--docs/bugs_and_glitches.md60
1 files changed, 59 insertions, 1 deletions
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