ref: 3927bcdb9d0429b5ff303cb787e522878bd01749
parent: a91aa18daeb7fdd24fe512468d549ca49fe524fc
author: Rangi <remy.oukaour+rangi42@gmail.com>
date: Thu May 24 08:36:35 EDT 2018
Function6ec1 → CanObjectMoveInDirection
--- a/docs/bugs_and_glitches.md
+++ b/docs/bugs_and_glitches.md
@@ -44,7 +44,7 @@
- [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 @@
*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
--- a/engine/overworld/map_objects.asm
+++ b/engine/overworld/map_objects.asm
@@ -696,7 +696,7 @@
and %00000011
or 0
call InitStep
- call Function6ec1
+ call CanObjectMoveInDirection
jr c, .ok2
ld de, SFX_STRENGTH
call PlaySFX
@@ -1049,7 +1049,7 @@
.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
--- 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