You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Disable jumping over ledges onto obstacle tiles or NPCs
Ledges are always placed in maps so that you can safely jump over them, without landing on an obstacle tile (like a building, tree, or water) or an NPC. It's a common mistake for beginners to misplace ledges so that you might jump onto an obstacle and get stuck. But if for some reason you want to design your map that way, you can add a check in the ledge-hopping code to only jump when it's safe to do so.
+; d = x coordinate of tile across the ledge+ ld a, [wPlayerMapX]+ ld d, a+ ld a, [wWalkingX]+ add a+ add d+ ld d, a+; e = y coordinate of tile across the ledge+ ld a, [wPlayerMapY]+ ld e, a+ ld a, [wWalkingY]+ add a+ add e+ ld e, a+; make sure the tile across the ledge is walkable+ push de+ call GetCoordTileCollision+ call .CheckWalkable+ pop de+ jr c, .DontJump+; make sure there's no NPC across the ledge+ xor a+ ldh [hMapObjectIndex], a+ farcall IsNPCAtCoord+ jr c, .DontJump
ld de, SFX_JUMP_OVER_LEDGE
call PlaySFX
ld a, STEP_LEDGE
call .DoStep
ld a, PLAYERMOVEMENT_JUMP
scf
ret
.DontJump:
xor a
ret