diff --git a/docs/bugs_and_glitches.md b/docs/bugs_and_glitches.md index b78244d4c..2b5a6a152 100644 --- a/docs/bugs_and_glitches.md +++ b/docs/bugs_and_glitches.md @@ -44,7 +44,7 @@ These are known bugs and glitches in the original Pokémon Crystal game: code th - [Two tiles in the `port` tileset are drawn incorrectly](#two-tiles-in-the-port-tileset-are-drawn-incorrectly) - [`LoadMetatiles` wraps around past 128 blocks](#loadmetatiles-wraps-around-past-128-blocks) - [Surfing directly across a map connection does not load the new map](#surfing-directly-across-a-map-connection-does-not-load-the-new-map) -- [`Function6ec1` does not correctly limit object movement](#function6ec1-does-not-correctly-limit-object-movement) +- [Swimming NPCs aren't limited by their movement radius](#swimming-npcs-arent-limited-by-their-movement-radius) - [`CheckOwnMon` only checks the first five letters of OT names](#checkownmon-only-checks-the-first-five-letters-of-ot-names) - [Catching a Transformed Pokémon always catches a Ditto](#catching-a-transformed-pokémon-always-catches-a-ditto) - [Using a Park Ball in normal battles has a corrupt animation](#using-a-park-ball-in-normal-battles-has-a-corrupt-animation) @@ -1185,11 +1185,11 @@ In [home/map.asm](/home/map.asm): *To do:* Identify specific code causing this bug and fix it. -## `Function6ec1` does not correctly limit object movement +## Swimming NPCs aren't limited by their movement radius This bug is why the Lapras in [maps/UnionCaveB2F.asm](/maps/UnionCaveB2F.asm), which uses `SPRITEMOVEDATA_SWIM_WANDER`, is not restricted by its `1, 1` movement radius. -In [engine/overworld/npc_movement.asm](/engine/overworld/npc_movement.asm): +This is a bug with `CanObjectMoveInDirection` in [engine/overworld/npc_movement.asm](/engine/overworld/npc_movement.asm): ```asm ld hl, OBJECT_FLAGS1 diff --git a/engine/overworld/map_objects.asm b/engine/overworld/map_objects.asm index e38112db9..6652beead 100644 --- a/engine/overworld/map_objects.asm +++ b/engine/overworld/map_objects.asm @@ -696,7 +696,7 @@ MapObjectMovementPattern: ; 47dd and %00000011 or 0 call InitStep - call Function6ec1 + call CanObjectMoveInDirection jr c, .ok2 ld de, SFX_STRENGTH call PlaySFX @@ -1049,7 +1049,7 @@ MapObjectMovementPattern: ; 47dd .RandomWalkContinue: call InitStep - call Function6ec1 ; check whether the object can move in that direction + call CanObjectMoveInDirection ; check whether the object can move in that direction jr c, .NewDuration call UpdateTallGrassFlags ld hl, OBJECT_ACTION diff --git a/engine/overworld/npc_movement.asm b/engine/overworld/npc_movement.asm index 66b64037c..40ced1a5f 100644 --- a/engine/overworld/npc_movement.asm +++ b/engine/overworld/npc_movement.asm @@ -1,4 +1,4 @@ -Function6ec1: ; 6ec1 +CanObjectMoveInDirection: ; 6ec1 ld hl, OBJECT_PALETTE add hl, bc