Document Special Defense badge boost glitch (#651)

Document Special Defense badge boost glitch
This commit is contained in:
bbbbbbbbba 2019-10-20 18:25:34 -04:00 committed by Rangi
parent e3e0bcd653
commit 0d48d829d4
2 changed files with 34 additions and 3 deletions

View File

@ -18,6 +18,7 @@ Some fixes are mentioned as breaking compatibility with link battles. This can b
- [Thick Club and Light Ball can make (Special) Attack wrap around above 1024](#thick-club-and-light-ball-can-make-special-attack-wrap-around-above-1024)
- [Metal Powder can increase damage taken with boosted (Special) Defense](#metal-powder-can-increase-damage-taken-with-boosted-special-defense)
- [Reflect and Light Screen can make (Special) Defense wrap around above 1024](#reflect-and-light-screen-can-make-special-defense-wrap-around-above-1024)
- [Glacier Badge may not boost Special Defense depending on the value of Special Attack](#glacier-badge-may-not-boost-special-defense-depending-on-the-value-of-special-attack)
- [Moves with a 100% secondary effect chance will not trigger it in 1/256 uses](#moves-with-a-100-secondary-effect-chance-will-not-trigger-it-in-1256-uses)
- [Belly Drum sharply boosts Attack even with under 50% HP](#belly-drum-sharply-boosts-attack-even-with-under-50-hp)
- [Confusion damage is affected by type-boosting items and Explosion/Self-Destruct doubling](#confusion-damage-is-affected-by-type-boosting-items-and-explosionself-destruct-doubling)
@ -167,6 +168,34 @@ This bug existed for all battles in Gold and Silver, and was only fixed for sing
(This fix also affects Thick Club, Light Ball, and Metal Powder, as described above, but their specific fixes in the above bugs allow more accurate damage calculations.)
## Glacier Badge may not boost Special Defense depending on the value of Special Attack
As Pryce's dialog ("That BADGE will raise the SPECIAL stats of POKéMON.") implies, Glacier Badge is intended to boost both Special Attack and Special Defense. However, due to BoostStat overwriting `a` when boosting Special Attack, the Special Defense boost will not happen if the unboosted Special Attack stat is either 0-205 or 433-660.
**Fix:** Edit `BadgeStatBoosts.CheckBadge` in [engine/battle/core.asm](https://github.com/pret/pokecrystal/blob/master/engine/battle/core.asm):
```diff
.CheckBadge:
ld a, b
srl b
+ push af
call c, BoostStat
+ pop af
inc hl
inc hl
; Check every other badge.
srl b
dec c
jr nz, .CheckBadge
; Check GlacierBadge again for Special Defense.
-; This check is buggy because it assumes that a is set by the "ld a, b" in the above loop,
-; but it can actually be overwritten by the call to BoostStat.
srl a
call c, BoostStat
ret
```
## Moves with a 100% secondary effect chance will not trigger it in 1/256 uses
*Fixing this bug **may** break compatibility with standard Pokémon Crystal for link battles.*

View File

@ -6758,12 +6758,12 @@ BadgeStatBoosts:
; depending on which badges have been obtained.
; Every other badge boosts a stat, starting from the first.
; GlacierBadge also boosts Special Defense, although the relevant code is buggy (see below).
; ZephyrBadge: Attack
; PlainBadge: Speed
; MineralBadge: Defense
; GlacierBadge: Special Attack
; RisingBadge: Special Defense
; GlacierBadge: Special Attack and Special Defense
; The boosted stats are in order, except PlainBadge and MineralBadge's boosts are swapped.
@ -6806,7 +6806,9 @@ BadgeStatBoosts:
srl b
dec c
jr nz, .CheckBadge
; And the last one (RisingBadge) too.
; Check GlacierBadge again for Special Defense.
; This check is buggy because it assumes that a is set by the "ld a, b" in the above loop,
; but it can actually be overwritten by the call to BoostStat.
srl a
call c, BoostStat
ret