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 */
| 3230 | leaving a pool of water/lava, and by moveloop to check for staying on one; |
| 3231 | returns true to skip rest of spoteffects */ |
| 3232 | boolean |
| 3233 | pooleffects( |
| 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 | } |
no test coverage detected