Piranha
Verified against the spelunky.ai port v0.1.10 on .
The Piranha is a small fish in Spelunky Classic that lives in the Jungle's water and swims at a player in the water, biting for 1 heart.
Level generation puts Piranhas in the water of the Jungle, from its pools to the lakes of flooded levels. A Piranha leaves a player on dry land alone, but once he's swimming near it, it swims straight at him and bites, and a pool may hold several. With 1 hit point, it dies to any damage, but a swimming player can't stomp it.
Behaviour
#A Piranha swims back and forth at 1 pixel per step, turning around where the water ends or a wall is in its way [6]. It starts out heading left or right at random [7], and lets off a bubble every 31–51 steps [8].
When the player is swimming within 90 pixels of it, and alive, it attacks: it swims straight at him at 1 pixel per step (30 per second), its heading wobbling by a degree each step, and moves only while the way ahead is water [9] [10]. The game moves it in whole pixels on each axis, so on a diagonal it covers 1 pixel across and 1 up or down in a step [11]. When he leaves the water or its range, it stops for 20–40 steps (0.67–1.33 seconds) and then patrols again [12] [13]. The clip shows the player dropping into a pool and two Piranhas closing in on him.
A Piranha also hunts other monsters in the water. It looks at the nearest living Caveman, or if there's none, the nearest Shopkeeper, then Hawkman, then Yeti, and if that one is swimming, swims at it and, within 4 pixels of it, bites it for 1 hit point at most once every 10 steps [14] [15] [16].
Out of the water. A Piranha whose middle isn't in water turns into a Fish Bone at once [17].
Off screen. Unlike most monsters, a Piranha has no check of its own for being on screen: it swims on wherever the game keeps it running, which is up to 96 pixels outside the view, past which the game freezes everything [18] [19].
Damage
#When the player touches a Piranha without stomping it, he loses 1 heart, is knocked away from it, and blinks, invincible, for 30 steps (1 second), and the bite draws blood [20] [21]. This is the touch code most monsters share. The clip shows two bites, a second apart, taking the player from four hearts to two.
Defeating
#A Piranha has 1 hit point, so any damage kills it [22]:
| Way | Damage | |
|---|---|---|
| Whip | 1 hit point | [23] |
| Machete | 2 hit points | [23] |
| Stomp (landing on it), except while the player is swimming | 1, plus 1 for every 16 steps of falling; three times that with Spike Shoes | [24] |
| A thrown item moving faster than 2 pixels per step, such as a Rock | 1 | [25] |
| A Shotgun or Pistol bullet | 4 hit points | [26] |
| A Bomb's explosion | 30 hit points | [27] |
| Being out of the water | Turns it into a Fish Bone | [17] |
The Piranha's own step event replaces the one most monsters share, which is where Spikes, Lava and Spear Traps hurt them, so none of those harm a Piranha [28].
Piranhas killed count toward the player's kills, and the screen between levels draws a Piranha icon for each [29] [30]. One that turns into a Fish Bone out of the water isn't killed, so it isn't counted.
Locations
#Level generation makes Piranhas only in the Jungle: each water block with no solid block in it has a 1 in 30 chance of one. That includes the lakes of flooded levels; on a graveyard level, the same roll makes a Dead Fish instead [31].
Custom levels can have them, as the level editor's tile p, a water block with a Piranha in
it [32].
Tips
#- A Piranha only chases a swimming player, so one crossing above the water isn't chased.
- Several Piranhas each bite as the player's invincibility runs out, so a pool with a few of them costs a heart a second until he gets out.
- The player can't stomp a Piranha while swimming; a thrown item or the Whip kills one.
Trivia
#- The Piranha's code names an attacking state for other monsters, Caveman, Shopkeeper, Hawkman and Yeti, as well as the player, and sets a bitten one's state to 2, which for a Caveman is charging [33] [34].
- On a graveyard level, the Piranha's place is taken by the Dead Fish, whose code is the
Piranha's without its hunting of other monsters. A Dead Fish killed is added to the Piranha's row of the
kills table the game writes to
stats.txt[35] [36].
FAQ
#- How much damage does a Piranha do in Spelunky Classic?
1 heart per bite. Each bite also knocks the player back and makes him invincible for 30 steps (1 second), so several Piranhas take a heart a second between them.
- Do Piranhas attack the player out of the water in Spelunky Classic?
No. A Piranha only goes for the player while he's swimming, within 90 pixels of it. One that leaves the water turns into a Fish Bone.
- How do you kill a Piranha in Spelunky Classic?
Hit it once with anything. A Piranha has 1 hit point, so a Whip hit, a thrown item, a bullet or a Bomb kills it. A swimming player can't stomp it.
- Where do Piranhas live in Spelunky Classic?
In the water of the Jungle, where level generation puts one in a water block with a 1 in 30 chance, including the lakes of flooded levels.
See also
#- Related
References
#objects/oPiranha/create.gml:16objects/oEnemy/collision_oCharacter.gml:25objects/oPiranha/step.gml:69objects/oPiranha/step.gml:100objects/oPiranha/step.gml:17-76objects/oPiranha/step.gml:17-30objects/oPiranha/create.gml:12-13objects/oPiranha/step.gml:123-128objects/oPiranha/step.gml:32-35objects/oPiranha/step.gml:63-70scripts/moveTo.gml:20-31objects/oPiranha/step.gml:53-62objects/oPiranha/step.gml:71-75objects/oPiranha/step.gml:37-51objects/oPiranha/step.gml:77-121objects/oPiranha/alarm_0.gml:1objects/oPiranha/step.gml:136-140objects/oPiranha/step.gml:1objects/oLevel/step.gml:64-77objects/oEnemy/collision_oCharacter.gml:14-25objects/oEnemy/collision_oCharacter.gml:55objects/oPiranha/step.gml:3-13objects/oEnemy/collision_oWhip.gml:1objects/oEnemy/collision_oCharacter.gml:6-10objects/oItem/step.gml:256-348objects/oBullet/collision_oEnemy.gml:16objects/oExplosion/collision_oEnemy.gml:14objects/oEnemy/step.gml:63-128objects/oPiranha/step.gml:6-11objects/oTransition/alarm_0.gml:149-154scripts/scrEntityGen.gml:326-336scripts/scrCreateTileObj.gml:172-176objects/oPiranha/create.gml:22-26objects/oPiranha/step.gml:110objects/oDeadFish/step.gml:10-15scripts/scrWriteStats.gml:198
Source code
objects/oPiranha/create.gmlobjects/oPiranha/step.gmlobjects/oPiranha/alarm_0.gmlobjects/oEnemy/create.gmlobjects/oEnemy/collision_oCharacter.gmlobjects/oEnemy/collision_oWhip.gmlobjects/oLevel/step.gmlscripts/scrEntityGen.gml