NPC walking behavior glitches

From Glitch City Wiki
Jump to navigation Jump to search

NPC walking behavior glitches are glitches in Pokémon Red and Blue that affect the behavior of NPCs that walk on their own (as opposed to during scripts) in the overworld.

Glitches related to NPC displacement

The game keeps track of the displacement of each NPC from its original position. Presumably, the intention is to keep an NPC from moving too far from its home location, but the actual execution (external link) makes little sense:

  • If the NPC is trying to move upwards, and it is already 8 steps above its initial position, then don't move.
  • If the NPC is not trying to move upwards, and it would be 4 or more steps above its initial position after finishing this step, then don't move.
  • If the NPC is trying to move left, and it is already 8 steps left of its initial position, then don't move.
  • If the NPC is not trying to move left, and it would be 4 or more steps left of its initial position after finishing this step, then do nothing (allow the move).

While the first and third clauses make sense, the second clause doesn't really make sense, and the last clause does literally nothing.

The consequences of the first two clauses are:

  • When an NPC is exactly 4 steps above its initial position, it cannot move horizontally, but it can move up or down (the latter bringing vertical displacement back to 3).
  • When an NPC is 5–7 steps above its initial position, it can only move up, not in any other direction.
  • When an NPC is 8 steps above its initial position, it cannot move at all.

To summarize the last two points, once an NPC moves 5 steps above its initial position, it can do nothing but move three more steps up (or less, if there is an impassable obstacle in its way), and then it gets completely stuck (until the player leaves the map to reset NPC positions).

This glitch can be easily observed because when an NPC fails to move, it will still turn to the direction it tries to move, just as if it tried to walk against an obstacle (the border of the screen counts as an obstacle). Notice that for walking NPCs, turning without moving doesn't happen in usual cases.

Notable consequences of this glitch include:

  • When trying to do the get stuck in a wall glitch, the girl must be guided to the desired horizontal position before allowed to move up the final three steps (the desired position is 7 steps above her initial position). Furthermore, if she moves one more step up, the player has to reset NPC positions and try again.
  • If the walking NPC in Cerulean City Pokémon Center walks through the Cable Club lady, he would be stuck in the tile behind her without going left or right, because that tile is exactly 4 steps above his initial position (and he cannot go up or down either).

In Japanese Pokémon Red, Green, and Pokémon Blue (Japanese), the last clause works just like the second clause, meaning that an NPC can get stuck by moving too far to the left as well as by moving too far upwards. The "left" version of this glitch is more dangerous, because there are five places (three Pokémon Centers and two Poké Marts) where a player can be trapped in a 1-tile wide aisle against an NPC that could only move left, resulting in a soft-lock. Perhaps this is the reason the English versions fixed the "left" part of this glitch, but kept the "up" part unchanged.

In Pokémon Yellow, this glitch has been fixed by making both the second clause and the last clause do nothing. Plus, (presumably as a failsafe) impassable obstacles are placed in the aisles that used to be possible to be trapped in.

Glitch related to the border of the screen

As mentioned above, the border of the screen is considered as an obstacle to walking NPCs. The way the game checks for this is by checking whether the coordinate of the NPC after walking a pixel would be on-screen (0x00 <= Y coordinate <= 0x80, 0x00 <= X coordinate <= 0x90). However, due to an off-by-one error, Y = 0x80 (the bottom row) and X = 0x90 (the rightmost column) are both considered off-screen in this check.

The consequence of this is the NPC cannot move along those two borders (i.e. move left or right on the bottom row, or move up or down on the rightmost column). Moving down onto the bottom row or right onto the rightmost column are still allowed, because after walking only one pixel, the relevant coordinates, Y = 0x71 or X = 0x81, are still considered on-screen. Moving up from the bottom row or left from the rightmost column are also allowed, because the relevant coordinates will then be Y = 0x7F or X = 0x8F.

This glitch still exists in Pokémon Yellow.

Movement delay oversight

Every NPC has a "movement delay", which is set to a random value between 0 and 127 whenever they finish walking a step, or fail to do so (e.g. because they would walk into an obstacle, or they don't walk at all). When an on-screen NPC is in the "waiting" state, the movement delay decreases every "overworld frame" (two frames), and when it decreases to 0, the NPC goes into the "ready" state, and will try to walk during the next overworld frame.

The intention is probably to make NPCs walk with a random interval of up to ~4.3 seconds. However, the keyword is "decreases to 0": If the movement delay is randomly set to 0, then the NPC will still enter the "waiting" state, and decrease the movement delay, causing it to underflow to 255. Therefore a movement delay of 0 essentially behaves like 256, giving the NPC a small chance (1/128) to wait ~8.6 seconds before the next movement.


Youtube Video

YouTube video by Crystal_

External links