From b0d56dff91a889eec27e9774abb19d9814aac565 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Linus=20Unneb=C3=A4ck?= Date: Sun, 3 Aug 2025 19:57:07 +0200 Subject: [PATCH] Document time of day bug in RandomUnseenWildMon (#1196) --- docs/bugs_and_glitches.md | 44 +++++++++++++++++++++++++---------- engine/overworld/wildmons.asm | 1 + 2 files changed, 33 insertions(+), 12 deletions(-) diff --git a/docs/bugs_and_glitches.md b/docs/bugs_and_glitches.md index 12947702d..ffb92b4e4 100644 --- a/docs/bugs_and_glitches.md +++ b/docs/bugs_and_glitches.md @@ -107,6 +107,7 @@ Fixes in the [multi-player battle engine](#multi-player-battle-engine) category - [`ScriptCall` can overflow `wScriptStack` and crash](#scriptcall-can-overflow-wscriptstack-and-crash) - [`LoadSpriteGFX` does not limit the capacity of `UsedSprites`](#loadspritegfx-does-not-limit-the-capacity-of-usedsprites) - [`ChooseWildEncounter` doesn't really validate the wild Pokémon species](#choosewildencounter-doesnt-really-validate-the-wild-pok%C3%A9mon-species) + - [`RandomUnseenWildMon` always picks a morning Pokémon species](#randomunseenwildmon-always-picks-a-morning-pok%C3%A9mon-species) - [`TryObjectEvent` arbitrary code execution](#tryobjectevent-arbitrary-code-execution) - [`ReadObjectEvents` overflows into `wObjectMasks`](#readobjectevents-overflows-into-wobjectmasks) - [`ClearWRAM` only clears WRAM bank 1](#clearwram-only-clears-wram-bank-1) @@ -2222,6 +2223,18 @@ The exact cause of this bug is unknown. ``` +### `SFX_RUN` does not play correctly when a wild Pokémon flees from battle + +**Fix:** Edit `WildFled_EnemyFled_LinkBattleCanceled` in [engine/battle/core.asm](https://github.com/pret/pokecrystal/blob/master/engine/battle/core.asm): + +```diff +-; BUG: SFX_RUN does not play correctly when a wild Pokemon flees from battle (see docs/bugs_and_glitches.md) + ld de, SFX_RUN +- call PlaySFX ++ call WaitPlaySFX +``` + + ## Text @@ -2677,6 +2690,25 @@ This allows Pokémon to be duplicated, among other effects. It does not have a s ``` +### `RandomUnseenWildMon` always picks a morning Pokémon species + +**Fix:** Edit `RandomUnseenWildMon` in [engine/overworld/wildmons.asm](https://github.com/pret/pokecrystal/blob/master/engine/overworld/wildmons.asm): + +```diff + .GetGrassmon: +-; BUG: RandomUnseenWildMon always picks a morning Pokémon species (see docs/bugs_and_glitches.md) ++ ld a, [wTimeOfDay] ++ ld bc, NUM_GRASSMON * 2 ++ call AddNTimes + push hl + ld bc, 5 + 4 * 2 ; Location of the level of the 5th wild Pokemon in that map + add hl, bc +- ld a, [wTimeOfDay] +- ld bc, NUM_GRASSMON * 2 +- call AddNTimes +``` + + ### `TryObjectEvent` arbitrary code execution If `IsInArray` returns `nc`, data at `bc` will be executed as code. @@ -2798,15 +2830,3 @@ This bug allows all the options to be updated at once if the left or right butto ld a, [hl] push af ``` - - -### `SFX_RUN` does not play correctly when a wild Pokémon flees from battle - -**Fix:** Edit `WildFled_EnemyFled_LinkBattleCanceled` in [engine/battle/core.asm](https://github.com/pret/pokecrystal/blob/master/engine/battle/core.asm): - -```diff --; BUG: SFX_RUN does not play correctly when a wild Pokemon flees from battle (see docs/bugs_and_glitches.md) - ld de, SFX_RUN -- call PlaySFX -+ call WaitPlaySFX -``` diff --git a/engine/overworld/wildmons.asm b/engine/overworld/wildmons.asm index 0e41bc14a..e36add328 100644 --- a/engine/overworld/wildmons.asm +++ b/engine/overworld/wildmons.asm @@ -781,6 +781,7 @@ RandomUnseenWildMon: jr nc, .done .GetGrassmon: +; BUG: RandomUnseenWildMon always picks a morning Pokémon species (see docs/bugs_and_glitches.md) push hl ld bc, 5 + 4 * 2 ; Location of the level of the 5th wild Pokemon in that map add hl, bc