MCPcopy Index your code
hub / github.com/NetHack/NetHack / drown

Function drown

src/trap.c:5058–5199  ·  view source on GitHub ↗

return TRUE iff player relocated */

Source from the content-addressed store, hash-verified

5056
5057/* return TRUE iff player relocated */
5058boolean
5059drown(void)
5060{
5061 const char *pool_of_water;
5062 boolean inpool_ok = FALSE;
5063 int i;
5064 coordxy x, y;
5065 boolean is_solid = is_waterwall(u.ux, u.uy);
5066
5067 feel_newsym(u.ux, u.uy); /* in case Blind, map the water here */
5068 /* happily wading in the same contiguous pool */
5069 if (u.uinwater && is_pool(u.ux - u.dx, u.uy - u.dy)
5070 && (Swimming || Amphibious || Breathless)) {
5071 /* water effects on objects every now and then */
5072 if (!rn2(5))
5073 inpool_ok = TRUE;
5074 else
5075 return FALSE;
5076 }
5077
5078 if (!u.uinwater) {
5079 You("%s into the %s%c", is_solid ? "plunge" : "fall",
5080 waterbody_name(u.ux, u.uy),
5081 (Amphibious || Swimming || Breathless) ? '.' : '!');
5082 if (!Swimming && !is_solid)
5083 You("sink like %s.", Hallucination ? "the Titanic" : "a rock");
5084 }
5085
5086 water_damage_chain(gi.invent, FALSE);
5087
5088 if (u.umonnum == PM_GREMLIN && rn2(3)) {
5089 (void) split_mon(&gy.youmonst, (struct monst *) 0);
5090 } else if (u.umonnum == PM_IRON_GOLEM) {
5091 You("rust!");
5092 i = Maybe_Half_Phys(d(2, 6));
5093 if (u.mhmax > i)
5094 u.mhmax -= i;
5095 losehp(i, "rusting away", KILLED_BY);
5096 }
5097 if (inpool_ok)
5098 return FALSE;
5099
5100 if ((i = number_leashed()) > 0) {
5101 pline_The("leash%s slip%s loose.", (i > 1) ? "es" : "",
5102 (i > 1) ? "" : "s");
5103 unleash_all();
5104 }
5105
5106 if (Amphibious || Breathless || Swimming) {
5107 if (Amphibious || Breathless) {
5108 if (flags.verbose)
5109 pline("But you aren't drowning.");
5110 if (!Is_waterlevel(&u.uz)) {
5111 if (Hallucination)
5112 Your("keel hits the bottom.");
5113 else
5114 You("touch bottom.");
5115 }

Callers 5

Amulet_offFunction · 0.85
pooleffectsFunction · 0.85
hurtle_stepFunction · 0.85
float_downFunction · 0.85
e_diedFunction · 0.85

Calls 15

is_waterwallFunction · 0.85
feel_newsymFunction · 0.85
is_poolFunction · 0.85
rn2Function · 0.85
YouFunction · 0.85
waterbody_nameFunction · 0.85
water_damage_chainFunction · 0.85
split_monFunction · 0.85
dFunction · 0.85
losehpFunction · 0.85
number_leashedFunction · 0.85
pline_TheFunction · 0.85

Tested by

no test coverage detected