SpelunkyFan wiki

The Shopkeeper's one-step patrol

Verified against the spelunky.ai port v0.1.11 on .

The Shopkeeper's one-step patrol is a quirk of Spelunky Classic in which a patrolling Shopkeeper's every walk ends on its first step, so he shuffles about.

A Shopkeeper waiting for a thief is on patrol: he stands, walks a little way, and stands again. The test that ends his walk is the one an Alien turns at a ledge by, without its half that looks for a floor ahead, so out in the open no walk lasts more than a step: he shuffles rather than walks.

What happens

#

A Shopkeeper on patrol in open ground sets off walking, but his walk's check for a wall ahead sends him back to patrolling on the very next step. He coasts about 10 pixels to a stop, waits, and shuffles again, every second or so [1].

A patrolling Shopkeeper's walk lasts one step. A Shopkeeper on patrol in open ground sets off walking, but his walk's check for a wall ahead sends him back to patrolling on the very next step. He coasts a few pixels to a stop, waits, and shuffles again, every second or so.

Why

#

On patrol, a Shopkeeper counts down 20 to 50 steps on the ground, then sets off walking a random way [2]. His walk goes back to patrolling when there's no solid beside his head, a pixel to his left or right:

    if (facing == LEFT)
    {
        if (not collision_point(x-1, y, oSolid, -1, -1))
        {
            status = PATROL;
            counter = rand(20,50);
            xVel = 0;
        }
        xVel = -1.5;
    }
    else
    {
        if (not collision_point(x+16, y, oSolid, -1, -1))
        {
            status = PATROL;
            counter = rand(20,50);
            xVel = 0;
        }
        xVel = 1.5;
    }
objects/oShopkeeper/step.gml:309-328, from spelunky.gmk, Spelunky Classic 1.1's source, © 2008, 2009 Derek Yu and Mossmouth, LLC (Spelunky User License v1.1b).

The same lines in the Alien's and the Mantrap's walks also test the floor in front, y+16, where they turn at a ledge [3] [4]. Without it, in open ground nothing is beside his head, so every walk ends on its first step. That step still sets xVel to 1.5 after the test, and his friction takes 0.1 a step off it, so he coasts to a halt over about ten steps [5] [6].

Reproducing it

#

Steal from a shop, or kill a Shopkeeper, and go on to the next level: the Shopkeeper at its exit shuffles in place [7], and so does a shop's Shopkeeper there, who patrols rather than stands [8]. The level editor's ! is a Shopkeeper on patrol [9], and the replay of the clip's staged scene, on a custom level, puts one in a flat room. In 300 steps he sets off ten times, and every walk lasts one step; after one, his speed is 1.4, and it's gone ten steps later [10]. A thief's next level shows the same [11].

In the port

#

The spelunky.ai port reproduces it exactly: it's in docs/quirks.md's list of the 1.1 source's bugs [6], and the oracle's fingerprint of the replay pins every walk. No option turns it off.

FAQ

#
Why does the Shopkeeper shuffle back and forth at the exit?

A Shopkeeper on patrol stops walking wherever there's no wall beside his head. The same test in an Alien's walk also needs no floor ahead, so it turns only at a ledge; the Shopkeeper's has no such half, so in open ground every walk ends on its first step, and he coasts about 10 pixels to a halt.

When does a Shopkeeper patrol?

On the levels after a theft, or after the player has killed a Shopkeeper: one waits at the exit, and a shop's Shopkeeper patrols rather than stands. The level editor's Shopkeeper patrols too.

Do other monsters' walks stop like this?

No. The Alien's and the Mantrap's walks have the same test with the floor ahead added, and turn only at a ledge.

See also

#
Related

References

#
  1. Clip quirks/shopkeeper-patrol-one-step
  2. objects/oShopkeeper/step.gml:283-298
  3. objects/oAlien/step.gml:49-58
  4. objects/oManTrap/step.gml:60-69
  5. objects/oShopkeeper/step.gml:531-533
  6. Quirk 1 (docs/quirks.md)
  7. scripts/scrInitLevel.gml:245-255
  8. objects/oShopkeeper/step.gml:121-124
  9. scripts/scrCreateTileObj.gml:151-155
  10. Replay fidelity/replays/enemy-shopkeeper-patrol-one-step.txt
  11. Replay fidelity/replays/shop-seed-3-thief-next-level.txt

Source code

#