Spelunky is © 2008, 2009 Derek Yu and Mossmouth, LLC, and is used under the [Spelunky User License v1.1b](https://spelunky.ai/LICENSE.txt). spelunky.ai is an unofficial fan project, not affiliated with or endorsed by Mossmouth. The game and its assets may not be sold.

Music by George Buzinkai and Jonathan Perry; sound effects made in SFXR. From Spelunky Classic 1.1, © 2008, 2009 Derek Yu and Mossmouth, LLC.

# The Teleporter's old target

From the spelunky.ai wiki: <https://spelunky.ai/wiki/teleporter-old-target>. Verified against the spelunky.ai port [v0.1.11](https://github.com/851-labs/spelunky/releases/tag/v0.1.11) on 28 October 2026.

The Teleporter's old target is a quirk of Spelunky Classic in which a Teleporter used while a gun's shot waits takes the player back to an old spot.

| Quirk     |                                                                                                                                                                                                                                                                          |
| --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| Status    | GML + Oracle                                                                                                                                                                                                                                                             |
| Where     | [`scripts/scrUseItem.gml:426-458`](https://spelunky.ai/wiki/source/scripts/scrUseItem#L426-L458)                                                                                                                                                                         |
| Pinned by | `fidelity/replays/weapon-teleporter-old-target.txt`                                                                                                                                                                                                                      |
| Row       | [docs/quirks.md §1, Bugs and leftovers in the 1.1 source](https://github.com/851-labs/spelunky/blob/main/docs/quirks.md#1-bugs-and-leftovers-in-the-11-source): “The Teleporter keeps its last spot while another weapon's shot waits, and with none it stops the game.” |

The [Teleporter](https://spelunky.ai/wiki/teleporter) picks a spot 4 to 8 blocks away, up or ahead, and moves the player there. It has
no wait of its own between uses, but its sideways use checks the wait the guns and the [Bow](https://spelunky.ai/wiki/bow) set between
shots, and skips picking a spot while one runs. It moves the player all the same, to whatever spot was picked
last.

## What happens

The player teleports straight up and falls back. He fires a [Shotgun](https://spelunky.ai/wiki/shotgun), swaps it for the Teleporter and
uses it facing left, before the Shotgun's wait is over: it takes him straight up again, to the spot its last use
picked. Used once the wait is over, it takes him five blocks left[^1].

**Clip: The Teleporter goes back to its last spot.** The player teleports straight up and falls back. He fires a shotgun, swaps it for the teleporter and uses it facing left, before the shotgun's wait is over: it takes him straight up again, to the spot its last use picked. Used once the wait is over, it takes him five blocks left. ([video](https://spelunky.ai/wiki/media/clips/quirks/teleporter-old-target/clip.mp4))

## Why

The Teleporter's spot is `tx` and `ty`. With up held it always picks one; facing left or right, only `and
firing == 0`:

```gml scripts/scrUseItem.gml:427-447
                if (kUp)
                {
                    tx = x;
                    ty = y - (16*rand(4,8));
                    while (ty < 16) { ty += 16; }   
                }
                else if (not scrPlayerIsDucking())
                {
                    if (facing == LEFT and firing == 0)
                    {
                        tx = x - (16*rand(4,8));
                        ty = y;
                        if (tx < 8) tx = 8;
                    }
                    else if (facing == RIGHT and firing == 0)
                    {
                        tx = x + (16*rand(4,8));
                        ty = y;
                        if (tx > room_width - 8) tx = room_width - 8;
                    }
                }
```

[`scripts/scrUseItem.gml:427-447`](https://spelunky.ai/wiki/source/scripts/scrUseItem#L427-L447), from `spelunky.gmk`, Spelunky Classic 1.1's source, © 2008, 2009 Derek Yu and Mossmouth, LLC ([Spelunky User License v1.1b](https://spelunky.ai/LICENSE.txt)).

`firing` is the wait a shot starts, counted down by the player's step[^2]:
20 steps for the [Pistol](https://spelunky.ai/wiki/pistol), the [Web Cannon](https://spelunky.ai/wiki/web-cannon) and the [Sceptre](https://spelunky.ai/wiki/sceptre), 40 for the Shotgun,
10 for the Bow. The Teleporter starts none, so it only matters after a swap. Then the use moves the player to `tx`
and `ty` as they were[^3]. They're the player's own variables, which two
scripts besides write in his scope: checking whether a point is in a shop, and which room
it's in[^4][^5][^6]. His step asks them about where he is while he holds an unpaid ware or a
readied bomb arrow, and when he presses the pay key[^7][^8][^9]. So the spot is
the Teleporter's last, or where he last held an unpaid ware, say. If nothing has set them on the level, the use
reads an unset `tx`, an error that stops the game[^10].

## Reproducing it

Fire a gun, put it down, pick up a Teleporter and use it facing left or right, not crouching, before the gun's
wait is over. The replay of the clip's staged scene, on a custom level, uses the Teleporter with up held, which
moves the player 4 blocks up. He fires a Shotgun, swaps it for the Teleporter and uses it facing left with 6
steps of the wait to go: it moves him up there again. Used once the wait is over, it moves him 5 blocks left[^11]. The same scene without the first use stops
on the second, on the port and the original alike, and isn't kept as a replay, as a run that stops on an error
has no fingerprint.

## In the port

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

## FAQ

### Why does the Teleporter take you back where you were?

A sideways use of the [Teleporter](https://spelunky.ai/wiki/teleporter) only picks a new spot once a gun's wait between shots is over. Used within it, as after swapping a [Shotgun](https://spelunky.ai/wiki/shotgun) for it, it takes the player to the last spot picked, which is often where he last teleported to.

### Can the Teleporter crash Spelunky Classic?

Yes. Used sideways within a gun's wait before anything on the level has set its spot, it reads a variable that has never been set, an error that stops the game.

### Does teleporting straight up have the same problem?

No. A use with up held picks a new spot every time, wait or no wait.

## See also

- **Related:** [Teleporter](https://spelunky.ai/wiki/teleporter), [Pistol](https://spelunky.ai/wiki/pistol), [Shotgun](https://spelunky.ai/wiki/shotgun), [Web Cannon](https://spelunky.ai/wiki/web-cannon), [Sceptre](https://spelunky.ai/wiki/sceptre), [Bow](https://spelunky.ai/wiki/bow)

## References

[^1]: Clip quirks/teleporter-old-target

[^2]: [`objects/oPlayer1/step.gml:175`](https://spelunky.ai/wiki/source/objects/oPlayer1/step#L175)

[^3]: [`scripts/scrUseItem.gml:448-460`](https://spelunky.ai/wiki/source/scripts/scrUseItem#L448-L460)

[^4]: [`scripts/isInShop.gml:7-8`](https://spelunky.ai/wiki/source/scripts/isInShop#L7-L8)

[^5]: [`scripts/scrGetRoomX.gml:24`](https://spelunky.ai/wiki/source/scripts/scrGetRoomX#L24)

[^6]: [`scripts/scrGetRoomY.gml:24`](https://spelunky.ai/wiki/source/scripts/scrGetRoomY#L24)

[^7]: [`objects/oPlayer1/step.gml:43`](https://spelunky.ai/wiki/source/objects/oPlayer1/step#L43)

[^8]: [`objects/oPlayer1/step.gml:543-545`](https://spelunky.ai/wiki/source/objects/oPlayer1/step#L543-L545)

[^9]: [`objects/oPlayer1/step.gml:1359-1361`](https://spelunky.ai/wiki/source/objects/oPlayer1/step#L1359-L1361)

[^10]: Quirk 1 (docs/quirks.md)

[^11]: Replay `fidelity/replays/weapon-teleporter-old-target.txt`

### Source code

- [`scripts/scrUseItem.gml`](https://spelunky.ai/wiki/source/scripts/scrUseItem)
- [`objects/oPlayer1/step.gml`](https://spelunky.ai/wiki/source/objects/oPlayer1/step)
- [`scripts/isInShop.gml`](https://spelunky.ai/wiki/source/scripts/isInShop)
- [`scripts/scrGetRoomX.gml`](https://spelunky.ai/wiki/source/scripts/scrGetRoomX)
- [`scripts/scrGetRoomY.gml`](https://spelunky.ai/wiki/source/scripts/scrGetRoomY)
