Spear Trap
Verified against the spelunky.ai port v0.1.10 on .
The Spear Trap is a trap in Spelunky Classic, a two-block carved pillar in the Jungle and the Temple that thrusts spears at anything beside it, 4 hearts a step.
A Spear Trap is a pillar two blocks tall that rises from the floor, a carved face with a slot on each side. When the player, a monster or an item comes level with it, within 64 pixels, it thrusts a set of spears out into the block beside it on that side; they strike 20 steps later, taking 4 hearts from the player on each step he's in them. On a dark level its upper block is lit.
How it works
#Each of the trap's two blocks watches its own row, both ways. Each step, unless it has thrust in the last 50 steps (1.67 seconds), it checks the player, the nearest monster, the nearest pushable block and the nearest item: one level with it, within 4 pixels, and within 64 pixels of it on one side makes it thrust its spears out on that side [4] [5]. The lower block runs the same code, so it can thrust along the row below [6].
The spears fill the one block beside the trap, so the trap sees farther than it reaches. They come out over 31 steps, one frame of their animation a step, and are gone at its end; they only strike on frames 20 to 23, 4 steps that start 20 steps (0.67 seconds) after the trap sees something [7] [8]. Spears whose trap has been destroyed vanish [9].
The clip shows a player with eight hearts walking up to a trap: it thrusts as he comes within range, he walks into the spears' block, and when they strike they take 4 hearts on three steps running, 8 to 4 to 0 to -4.
Damage
#| Victim | Damage | |
|---|---|---|
| The player | 4 hearts on each step of the strike he's in the spears, which throw him up and away | [1] |
| Most monsters | 2 hit points on each step of the strike | [10] |
| A Caveman, Mantrap, Yeti, Hawkman or Shopkeeper | 2 hit points while it has hit points left, and stuns it, throwing it up and away | [11] |
Nothing spaces out the hits: there's no invincibility after one, so the player is hit again on every step of the strike he's still in the spears, and each hit he takes alive is counted in the end-of-game statistics' spear trap row, not only the one that kills him [12]. A monster a Spear Trap kills doesn't count as the player's kill [13] [14]. The monsters' check is in the code most monsters share, so those whose own step event replaces it, such as the Bat, aren't hurt.
Locations
#Level generation turns a floor block into a Spear Trap's lower half and puts its upper half on top. A block qualifies if it's at the edge of a drop (open on at least one side), has two open blocks above it and ground under it, isn't in a shop or in a column at the edge of a room, and is more than 64 pixels from the entrance:
| Area | Chance for each such block | |
|---|---|---|
| The Jungle | 1 in 12; on a dark level, once a 1 in 20 roll for a tiki torch fails | [15] |
| The Temple | 1 in 12, but not where the trap would block a passage of lava | [16] |
On a dark level the upper half is the lit kind, which glows and lights the darkness like a
lamp [17] [18]
[19]. Spear Traps
are also in the Sun challenge room, a bonus room [20], and in custom levels as the
level editor's tiles ] (the upper half) and [ (the lower)
[21].
Avoiding
#- Pass after the thrust. Once the spears have struck, the trap can't thrust again until 50 steps after the last thrust, so the player can set it off from out of reach and go past when the strike is over.
- Go over it. The trap only sees what's level with one of its blocks, so a player standing on top of it doesn't set it off. The second clip shows him standing on a lit trap unhurt.
- Set it off with something else. A monster or a thrown item level with it uses up a thrust too.
- Destroy it. A Bomb destroys it like a block, as the second clip shows, and a trap with nothing under it falls apart, on screen [22].
Interactions
#- Water. Destroying a Spear Trap lets water and lava flow into the space, as destroying a block does [23].
- Push blocks and ice blocks set it off as monsters do [24].
Trivia
#- Spear Traps were meant to fire arrows: both halves have an alarm, never set, that would fire one to the left at 5 pixels a step [3] [25].
- The spears' object is called
oSpearsLeftwhichever way they point: a trap thrusting right makes the same object and gives it the right-pointing sprite [26].
FAQ
#- How much damage does a Spear Trap do in Spelunky Classic?
4 hearts on each step its spears strike the player, and they strike for up to 4 steps. A player who stays in them can lose 12 or more hearts to one thrust.
- How do you get past a Spear Trap in Spelunky Classic?
Set it off and wait. Its spears strike 20 steps after they come out and are gone after 31, and the trap can't thrust again for 50 steps, so the player can pass once the thrust is over. Standing on top of the trap doesn't set it off.
- Can you destroy a Spear Trap in Spelunky Classic?
Yes, with a Bomb, like a block. It also falls apart when the ground under it is destroyed.
- Do Spear Traps hurt monsters?
Yes: 2 hit points on each step the spears strike them, and they stun a Caveman, a Mantrap, a Yeti, a Hawkman or a Shopkeeper. A monster a Spear Trap kills doesn't count as the player's kill.
See also
#- Related
References
#objects/oPlayer1/step.gml:1629-1647objects/oSpearTrapTop/step.gml:3-77objects/oSpearTrapTop/alarm_0.gml:1-2objects/oSpearTrapTop/step.gml:1-77objects/oSpearTrapTop/create.gml:3-5objects/oSpearTrapBottom/step.gml:1-89objects/oSpearsLeft/other_animation_end.gml:1objects/oPlayer1/step.gml:1632objects/oSpearsLeft/step.gml:1-8objects/oEnemy/step.gml:98-104objects/oEnemy/step.gml:76-97- Quirk 1 (docs/quirks.md)
objects/oEnemy/step.gml:87objects/oEnemy/step.gml:101scripts/scrEntityGen.gml:226-252scripts/scrEntityGen.gml:410-441scripts/scrEntityGen.gml:248scripts/scrEntityGen.gml:436objects/oPlayer1/step.gml:125-130- Room
rSun, as the room editor placed it scripts/scrCreateTileObj.gml:237-244objects/oSpearTrapTop/step.gml:79-86objects/oSpearTrapTop/destroy.gml:11objects/oSpearTrapTop/step.gml:21-28objects/oSpearTrapTop/create.gml:8objects/oSpearTrapTop/step.gml:41-47objects/oEnemy/step.gml:76-106
Source code
objects/oSpearTrapTop/create.gmlobjects/oSpearTrapTop/step.gmlobjects/oSpearTrapBottom/step.gmlobjects/oSpearsLeft/step.gmlobjects/oPlayer1/step.gmlobjects/oEnemy/step.gmlscripts/scrEntityGen.gml