ref: b232b4be5fd614fdb9b1c420ca260964b258ac33
parent: c4e3f2bbc23fe731deb177ed5743fdc6ac6572e0
author: vulcandth <[email protected]>
date: Thu Dec 1 10:54:01 EST 2022
Bug: PRZ and BRN stat reductions don't apply to switched Pokémon (#1021) Co-authored-by: Rangi <[email protected]>
--- a/docs/bugs_and_glitches.md
+++ b/docs/bugs_and_glitches.md
@@ -50,6 +50,7 @@
- [Love Ball boosts catch rate for the wrong gender](#love-ball-boosts-catch-rate-for-the-wrong-gender)
- [Fast Ball only boosts catch rate for three Pokémon](#fast-ball-only-boosts-catch-rate-for-three-pok%C3%A9mon)
- [Heavy Ball uses wrong weight value for three Pokémon](#heavy-ball-uses-wrong-weight-value-for-three-pok%C3%A9mon)
+ - [PRZ and BRN stat reductions don't apply to switched Pokémon](#prz-and-brn-stat-reductions-dont-apply-to-switched-pok%C3%A9mon)
- [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)
- ["Smart" AI encourages Mean Look if its own Pokémon is badly poisoned](#smart-ai-encourages-mean-look-if-its-own-pok%C3%A9mon-is-badly-poisoned)
- ["Smart" AI discourages Conversion2 after the first turn](#smart-ai-discourages-conversion2-after-the-first-turn)
@@ -1248,6 +1249,24 @@
db BANK("Pokedex Entries 065-128")
db BANK("Pokedex Entries 129-192")
db BANK("Pokedex Entries 193-251")
+```
+
+
+### PRZ and BRN stat reductions don't apply to switched Pokémon
+
+This does not affect link battles or Battle Tower battles because those jump from `LoadEnemyMon` to `InitEnemyMon`, which already calls `ApplyStatusEffectOnEnemyStats`.
+
+**Fix:** Edit `LoadEnemyMon` in [engine/battle/core.asm](https://github.com/pret/pokecrystal/blob/master/engine/battle/core.asm):
+
+```diff
+ ld hl, wEnemyMonStats
+ ld de, wEnemyStats
+ ld bc, NUM_EXP_STATS * 2
+ call CopyBytes
+
+-; BUG: PRZ and BRN stat reductions don't apply to switched Pokémon (see docs/bugs_and_glitches.md)
++ call ApplyStatusEffectOnEnemyStats
+ ret
```
--- a/engine/battle/core.asm
+++ b/engine/battle/core.asm
@@ -6407,6 +6407,7 @@
ld bc, NUM_EXP_STATS * 2
call CopyBytes
+; BUG: PRZ and BRN stat reductions don't apply to switched Pokémon (see docs/bugs_and_glitches.md)
ret
CheckSleepingTreeMon: