Whip hits on every step
Verified against the spelunky.ai port v0.1.10 on .
Whip hits on every step are a quirk of Spelunky Classic in which a swing hurts a monster on every step it touches it, so one swing can take several hit points.
A Whip swing is two hits: the wind-up behind the player, then the crack in front of him. The code most monsters share takes a hit from each on every step it touches them, with no pause between hits. It matters for the few monsters with more than one hit point, and most for those whose own code limits the whip, which forgets the wind-up.
What happens
#The player whips a Megamouth three times as it charges. The second swing's crack stays on the fish for seven steps and takes a hit point on each, seven in all [1].
The wind-up behind the player
#A Giant Spider waits 10 steps between whip hits, by its own code. With his back to one, the player swings: the wind-up behind him takes 1 of its 10 hit points on each of three steps in a row, while that wait is still running [2].
The Tomb Lord can only be cracked level with its top 12 pixels, so a player on its own floor can't hurt it facing it. With his back to it, the wind-up takes three of its hit points a swing [3].
The Yeti King's own code makes the Whip's crack harmless. The wind-up takes three of its hit points each swing all the same, so the Whip kills it in 10 swings with the player's back to it [4].
Why
#The collision of most monsters (oEnemy) with the whip takes the swing's damage and nothing else: no wait,
no stun, no check of where the hit is. A collision event runs on every step two things overlap, so it hits
again on every step [5]:
hp -= other.damage;
countsAsKill = true;
if (bloodLeft > 0)
{
scrCreateBlood(x+sprite_width/2, y+sprite_height/2, 1);
if (hp < 0) bloodLeft -= 1;
}
playSound(global.sndHit);objects/oEnemy/collision_oWhip.gml:1-8, from spelunky.gmk, Spelunky Classic 1.1's source, © 2008, 2009 Derek Yu and Mossmouth, LLC (Spelunky User License v1.1b).Its collision with the wind-up (oWhipPre, which lasts 3 steps) is the same code
[6] [7]. A
Megamouth (40 hit points) and the Alien Boss (10 hit points) have
no whip code of their own, so they take every step's hit [8].
The monsters that limit the whip do it in their own collision with oWhip, the crack: the Giant Spider with
a wait (whipped) [9], the Tomb Lord with the wait
and a height test [10], the Yeti King with a test the
Whip never passes (only a hit that punctures hurts it, and the Whip's doesn't)
[11], and the Magma Man by only playing a
sound [12]. None of them has a collision with oWhipPre,
so the wind-up runs the shared code instead, with no wait and no test. A Magma Man's hit points are its life,
which runs out by itself, so the wind-up takes 3 steps off it [8].
The Machete and the Mattock swing kinds of whip (children of oWhip and oWhipPre),
so their slashes and wind-ups do the same, 2 a step; a Mattock swing makes its wind-up twice
[8].
Reproducing it
#Whip a Megamouth, or turn the player's back on a Giant Spider, a Tomb Lord, the Yeti King or a Magma Man and swing. The replays of the clips' staged scenes pin each case: three swings at a Megamouth taking 1, 7 and 3 of its hit points [13], a wind-up taking a Giant Spider from 10 to 7 inside its wait [14], a Tomb Lord from 20 to 17 from its own floor [15], and the Yeti King from 30 to 21 in three swings while the crack takes nothing [16].
In the port
#The spelunky.ai port reproduces all of it exactly: the four rows are in docs/quirks.md's list of the 1.1 source's bugs [8], and the oracle's fingerprints of the replays pin every hit. No option turns it off.
FAQ
#- How many times does one whip swing hit in Spelunky Classic?
Once a step for as long as it touches the monster. A crack that stays on a Megamouth for 7 steps takes 7 hit points, and the wind-up behind the player can hit as well.
- Can the Whip hurt the Yeti King in Spelunky Classic?
Only with its wind-up, behind the player's back. The crack in front does nothing to the Yeti King, but the wind-up takes 1 on each of its 3 steps, so a swing with the player's back to it takes 3.
- Why does the whip hurt the Tomb Lord when the player turns his back on it?
The Tomb Lord's own code only lets the crack hurt it level with its head and once every 10 steps, but it has no code for the wind-up, so it takes the shared code's, which has neither limit.
- Is hitting with the whip's wind-up a bug?
It's in the 1.1 source: the monsters that limit the whip have no code for the wind-up behind the player, so it hurts them as it hurts any monster. The spelunky.ai port keeps it.
See also
#References
#- Clip quirks/whip-hits-every-step
- Clip quirks/giant-spider-whip-wind-up
- Clip quirks/tomb-lord-whip-wind-up
- Clip quirks/yeti-king-whip-wind-up
objects/oEnemy/collision_oWhip.gml:1-8objects/oEnemy/collision_oWhipPre.gml:1-8objects/oWhipPre/create.gml:3-5- Quirk 1 (docs/quirks.md)
objects/oGiantSpider/collision_oWhip.gml:1-7objects/oTombLord/collision_oWhip.gml:1-8objects/oYetiKing/collision_oWhip.gml:1-16objects/oMagmaMan/collision_oWhip.gml:1-6- Replay
fidelity/replays/enemy-megamouth-whip-every-step.txt - Replay
fidelity/replays/enemy-giant-spider-whip-wind-up.txt - Replay
fidelity/replays/enemy-tomb-lord-whip-wind-up.txt - Replay
fidelity/replays/enemy-yeti-king-whip-wind-up.txt
Source code
objects/oEnemy/collision_oWhip.gmlobjects/oEnemy/collision_oWhipPre.gmlobjects/oGiantSpider/collision_oWhip.gmlobjects/oTombLord/collision_oWhip.gmlobjects/oYetiKing/collision_oWhip.gmlobjects/oMagmaMan/collision_oWhip.gml