Phantom Jar
Verified against the spelunky.ai port v0.1.10 on .
The phantom Jar is a quirk of Spelunky Classic in which a Jar shot in the player's hands stays on the HUD, and switching items gives him a new one.
The player's hands and the item he's holding are two things to the game: the instance in his hands, and the kind of item it remembers he's holding, which the HUD shows and the item key gives back. A bullet that breaks a held Jar or Skull clears the first and, through a typo, not the second, so a new one comes back.
What happens
#An angry Shopkeeper's shot breaks the Jar the player is holding. His hands are empty, but the Jar stays on the HUD, and switching items gives him a Bomb, a Rope, and then a brand-new Jar [1].
Why
#A bullet's collision with a Jar only destroys it [2]. The Jar's destroy event then breaks it, and, if the player held it, empties his hands [3]:
if (held)
{
oPlayer1.holdItem = 0;
oPlayer1.pickupItem = "";
}objects/oJar/destroy.gml:30-34, from spelunky.gmk, Spelunky Classic 1.1's source, © 2008, 2009 Derek Yu and Mossmouth, LLC (Spelunky User License v1.1b).The variable the player's code reads for the kind of item he holds is pickupItemType; pickupItem is a
new variable that nothing reads. The Jar's whip code, which breaks a held Jar its own way, clears the right
one [4]. The Skull's destroy event has the same typo
[5].
So after the shot, pickupItemType is still "Jar": the HUD draws a Jar in the held item's box
[6], and the code that gives back the remembered item makes a new
one. The item key does, after a bomb and a rope, as it puts the rope away
[7], and so does losing a bomb or a rope from his hands, by
being stunned, killed or knocked [8].
Reproducing it
#Carry a Jar or a Skull where an angry Shopkeeper's Shotgun can hit it. Once a pellet breaks it, press the item key until a Jar comes round. The
replay of the clip's staged scene pins it: the shot breaks the Jar, pickupItemType stays "Jar", and the item
key gives a bomb, a rope and a new Jar [9].
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 [8], and the oracle's fingerprint of the replay pins the Jar's return. The Skull's version is read in the code and not yet in a replay. No option turns it off.
FAQ
#- Why does a Jar come back after it's shot in Spelunky Classic?
The code that tidies up after a broken Jar clears a misspelt variable, so the game still remembers a Jar as the item in the player's hands. Switching items gives him a new one after the bomb and the rope.
- Does the same happen with a Skull?
Yes. The Skull's code has the same misspelling, so a Skull shot in the player's hands comes back the same way.
- How do you get a phantom Jar in Spelunky Classic?
Hold a Jar while a Shopkeeper shoots at the player: when a pellet breaks the Jar in his hands, press the item key until it comes round again.
See also
#References
#- Clip quirks/jar-shot-in-hands
objects/oJar/collision_oBullet.gml:1objects/oJar/destroy.gml:30-34objects/oJar/collision_oWhip.gml:16-20objects/oSkull/destroy.gml:16-20scripts/scrDrawHUD.gml:79-83objects/oPlayer1/step.gml:983-991- Quirk 1 (docs/quirks.md)
- Replay
fidelity/replays/item-held-jar-shot.txt
Source code
objects/oJar/collision_oBullet.gmlobjects/oJar/destroy.gmlobjects/oSkull/destroy.gmlobjects/oPlayer1/step.gml