From 234bf7b1b6b55d6d4682678d8afdc38e69d349e8 Mon Sep 17 00:00:00 2001 From: PatR Date: Wed, 28 Nov 2018 17:43:53 -0800 Subject: [PATCH] fix #H7618 - gas cloud affects underwater monsters Stinking cloud placed near water or poison gas breathed across it would affect and potentially kill underwater monsters. Most swimmers are on the surface and should be affected, but eels and other fish shouldn't be. This also changes minliquid() to not treat flying and levitating as ways to survive water when on the Plane of Water. I think goodpos() needs to be taught about that Plane (where many ways of existing at a water location don't apply). This doesn't do that. --- doc/fixes36.2 | 1 + src/mon.c | 13 +++++++++---- src/region.c | 15 +++++++++++++-- 3 files changed, 23 insertions(+), 6 deletions(-) diff --git a/doc/fixes36.2 b/doc/fixes36.2 index aec56b39d..134a4e456 100644 --- a/doc/fixes36.2 +++ b/doc/fixes36.2 @@ -225,6 +225,7 @@ scattering of objects might leave source location with wrong thing displayed for configurations with 'long int' larger than 'int', lev_comp wrote some garbage into the *.lev files, but nethack seemed unaffected by that (at least on little-endian hardare) and loaded the levels successfully +stinking cloud placed near water could kill underwater creatures Fixes to Post-3.6.1 Problems that Were Exposed Via git Repository diff --git a/src/mon.c b/src/mon.c index 126f64f7b..a22db1a1a 100644 --- a/src/mon.c +++ b/src/mon.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 mon.c $NHDT-Date: 1543100460 2018/11/24 23:01:00 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.271 $ */ +/* NetHack 3.6 mon.c $NHDT-Date: 1543455827 2018/11/29 01:43:47 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.272 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /*-Copyright (c) Derek S. Ray, 2015. */ /* NetHack may be freely redistributed. See license for details. */ @@ -483,13 +483,18 @@ register struct monst *mtmp; /* [what about ceiling clingers?] */ inpool = (is_pool(mtmp->mx, mtmp->my) - && !(is_flyer(mtmp->data) || is_floater(mtmp->data))); + && (!(is_flyer(mtmp->data) || is_floater(mtmp->data)) + /* there's no "above the surface" on the plane of water */ + || Is_waterlevel(&u.uz))); inlava = (is_lava(mtmp->mx, mtmp->my) && !(is_flyer(mtmp->data) || is_floater(mtmp->data))); infountain = IS_FOUNTAIN(levl[mtmp->mx][mtmp->my].typ); - /* Flying and levitation keeps our steed out of the liquid */ - /* (but not water-walking or swimming) */ + /* Flying and levitation keeps our steed out of the liquid + (but not water-walking or swimming; note: if hero is in a + water location on the Plane of Water, flight and levitating + are blocked so this (Flying || Levitation) test fails there + and steed will be subject to water effects, as intended) */ if (mtmp == u.usteed && (Flying || Levitation)) return 0; diff --git a/src/region.c b/src/region.c index 526eae801..ad94426fa 100644 --- a/src/region.c +++ b/src/region.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 region.c $NHDT-Date: 1542765361 2018/11/21 01:56:01 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.42 $ */ +/* NetHack 3.6 region.c $NHDT-Date: 1543455828 2018/11/29 01:43:48 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.43 $ */ /* Copyright (c) 1996 by Jean-Christophe Collet */ /* NetHack may be freely redistributed. See license for details. */ @@ -947,10 +947,16 @@ genericptr_t p2; struct monst *mtmp; int dam; + /* + * Gas clouds can't be targetted at water locations, but they can + * start next to water and spread over it. + */ + reg = (NhRegion *) p1; dam = reg->arg.a_int; if (p2 == (genericptr_t) 0) { /* This means *YOU* Bozo! */ - if (u.uinvulnerable || nonliving(youmonst.data) || Breathless) + if (u.uinvulnerable || nonliving(youmonst.data) || Breathless + || Underwater) return FALSE; if (!Blind) { Your("%s sting.", makeplural(body_part(EYE))); @@ -973,6 +979,11 @@ genericptr_t p2; adult green dragon is not affected by gas cloud, baby one is */ if (!(nonliving(mtmp->data) || is_vampshifter(mtmp)) && !breathless(mtmp->data) + /* not is_swimmer(); assume that non-fish are swimming on + the surface and breathing the air above it periodically + unless located at water spot on plane of water */ + && !((mtmp->data->mlet == S_EEL || Is_waterlevel(&u.uz)) + && is_pool(mtmp->mx, mtmp->my)) /* exclude monsters with poison gas breath attack: adult green dragon and Chromatic Dragon (and iron golem, but nonliving() and breathless() tests also catch that) */