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

Function pooleffects

src/hack.c:3232–3309  ·  view source on GitHub ↗

extracted from spoteffects; called by spoteffects to check for entering or leaving a pool of water/lava, and by moveloop to check for staying on one; returns true to skip rest of spoteffects */

Source from the content-addressed store, hash-verified

3230 leaving a pool of water/lava, and by moveloop to check for staying on one;
3231 returns true to skip rest of spoteffects */
3232boolean
3233pooleffects(
3234 boolean newspot) /* true if called by spoteffects */
3235{
3236 /* check for leaving water */
3237 if (u.uinwater) {
3238 boolean still_inwater = FALSE; /* assume we're getting out */
3239
3240 if (!is_pool(u.ux, u.uy)) {
3241 if (Is_waterlevel(&u.uz)) {
3242 You("pop into an air bubble.");
3243 iflags.last_msg = PLNMSG_BACK_ON_GROUND;
3244 } else if (is_lava(u.ux, u.uy)) {
3245 You("leave the %s...", hliquid("water")); /* oops! */
3246 } else {
3247 back_on_ground(FALSE);
3248 }
3249 } else if (Is_waterlevel(&u.uz)) {
3250 still_inwater = TRUE;
3251 } else if (Levitation) {
3252 You("pop out of the %s like a cork!", hliquid("water"));
3253 } else if (Flying) {
3254 You("fly out of the %s.", hliquid("water"));
3255 } else if (Wwalking) {
3256 You("slowly rise above the surface.");
3257 } else {
3258 still_inwater = TRUE;
3259 }
3260 if (!still_inwater) {
3261 boolean was_underwater = (Underwater && !Is_waterlevel(&u.uz));
3262
3263 set_uinwater(0); /* u.uinwater = 0; leave the water */
3264 if (was_underwater) { /* restore vision */
3265 docrt();
3266 gv.vision_full_recalc = 1;
3267 }
3268 }
3269 }
3270
3271 /* check for entering water or lava */
3272 if (!u.ustuck && !Levitation && !Flying && is_pool_or_lava(u.ux, u.uy)) {
3273 if (u.usteed && !grounded(u.usteed->data)) {
3274 /* floating or clinging steed keeps hero safe (is_flyer() test
3275 is redundant; it can't be true since Flying yielded false) */
3276 return FALSE;
3277 } else if (u.usteed) {
3278 /* steed enters pool */
3279 dismount_steed(Underwater ? DISMOUNT_FELL : DISMOUNT_GENERIC);
3280 /* dismount_steed() -> float_down() -> pickup()
3281 (float_down doesn't do autopickup on Air or Water) */
3282 if (Is_airlevel(&u.uz) || Is_waterlevel(&u.uz))
3283 return FALSE;
3284 /* even if we actually end up at same location, float_down()
3285 has already done trap and pickup actions of spoteffects() */
3286 if (newspot)
3287 check_special_room(FALSE); /* spoteffects */
3288 return TRUE;
3289 }

Callers 6

allmain.cFile · 0.85
dodownFunction · 0.85
wizterrainwishFunction · 0.85
spoteffectsFunction · 0.85
liquid_flowFunction · 0.85
wiz_intrinsicFunction · 0.85

Calls 13

is_poolFunction · 0.85
YouFunction · 0.85
is_lavaFunction · 0.85
hliquidFunction · 0.85
back_on_groundFunction · 0.85
set_uinwaterFunction · 0.85
docrtFunction · 0.85
is_pool_or_lavaFunction · 0.85
dismount_steedFunction · 0.85
check_special_roomFunction · 0.85
lava_effectsFunction · 0.85
is_waterwallFunction · 0.85

Tested by

no test coverage detected