From 1f8db3a0f3ec5915b608c91fb58db63239eff0fd Mon Sep 17 00:00:00 2001 From: PatR Date: Sat, 27 Apr 2024 18:37:42 -0700 Subject: [PATCH] pull request #1238 - pit interaction when pool underneath gets boiled away Pull request by disperse: when a water walking hero zaps a wand of fire downward and it boils away the water, hero should fall into the resulting pit. The PR commit didn't handle monsters (who don't zap wands downward but could be on/in water that's boiled out from under them). And while testing it I noticed that the existing code had message sequencing issues (being enveloped in a cloud of steam before seeing the water evaporate). This ended up redoing the fix rather than using the commit. Fixes #1238 --- doc/fixes3-7-0.txt | 1 + include/flag.h | 1 + src/region.c | 4 +++- src/zap.c | 24 +++++++++++++++++++----- 4 files changed, 24 insertions(+), 6 deletions(-) diff --git a/doc/fixes3-7-0.txt b/doc/fixes3-7-0.txt index 9233a7751..9027250fa 100644 --- a/doc/fixes3-7-0.txt +++ b/doc/fixes3-7-0.txt @@ -1405,6 +1405,7 @@ when engraving with a stack of eligible weapons, split one off the stack and when engraving with a stack of cursed weapons, treat it differently if that stack is welded to hero's hand: write in dust and leave whole stack welded rather than split one off stack to engrave on floor +hero or monster didn't fall into pit if water at the location was boiled away Fixes to 3.7.0-x General Problems Exposed Via git Repository diff --git a/include/flag.h b/include/flag.h index c998b540b..616580265 100644 --- a/include/flag.h +++ b/include/flag.h @@ -496,6 +496,7 @@ enum plnmsg_types { PLNMSG_ONE_ITEM_HERE, /* "you see here" */ PLNMSG_TOWER_OF_FLAME, /* scroll of fire */ PLNMSG_CAUGHT_IN_EXPLOSION, /* explode() feedback */ + PLNMSG_ENVELOPED_IN_GAS, /* create_gas_cloud() feedback */ PLNMSG_OBJ_GLOWS, /* "the glows " */ PLNMSG_OBJNAM_ONLY, /* xname/doname only, for #tip */ PLNMSG_OK_DONT_DIE, /* overriding death in explore/wizard mode */ diff --git a/src/region.c b/src/region.c index bec949e99..a3d7b6526 100644 --- a/src/region.c +++ b/src/region.c @@ -1232,9 +1232,11 @@ create_gas_cloud(coordxy x, coordxy y, int cloudsize, int damage) cloud->glyph = cmap_to_glyph(damage ? S_poisoncloud : S_cloud); add_region(cloud); - if (!gi.in_mklev && !inside_cloud && is_hero_inside_gas_cloud()) + if (!gi.in_mklev && !inside_cloud && is_hero_inside_gas_cloud()) { You("are enveloped in a cloud of %s!", damage ? "noxious gas" : "steam"); + iflags.last_msg = PLNMSG_ENVELOPED_IN_GAS; + } return cloud; } diff --git a/src/zap.c b/src/zap.c index 759f32e6b..2bec3f75c 100644 --- a/src/zap.c +++ b/src/zap.c @@ -5036,14 +5036,14 @@ zap_over_floor( /* a burning web is too flimsy to notice if you can't see it */ if (see_it) Norep("A web bursts into flames!"); - (void) delfloortrap(t); + (void) delfloortrap(t), t = (struct trap *) 0; if (see_it) newsym(x, y); } if (is_ice(x, y)) { melt_ice(x, y, (char *) 0); } else if (is_pool(x, y)) { - boolean on_water_level = Is_waterlevel(&u.uz); + boolean on_water_level = Is_waterlevel(&u.uz), msggiven = FALSE; const char *msgtxt = (!Deaf) ? "You hear hissing gas." /* Deaf-aware */ : (type >= 0) @@ -5052,10 +5052,14 @@ zap_over_floor( /* don't create steam clouds on Plane of Water; air bubble movement and gas regions don't understand each other */ - if (!on_water_level) + if (!on_water_level) { create_gas_cloud(x, y, rnd(5), 0); /* 1..5, no damg */ + if (iflags.last_msg == PLNMSG_ENVELOPED_IN_GAS) + msggiven = TRUE; + } if (lev->typ != POOL) { /* MOAT or DRAWBRIDGE_UP or WATER */ + t = (struct trap *) 0; if (on_water_level) msgtxt = (see_it || !Deaf) ? "Some water boils." : 0; else if (see_it) @@ -5069,9 +5073,10 @@ zap_over_floor( if (see_it) msgtxt = "The water evaporates."; } - if (msgtxt) + if (msgtxt && !msggiven) Norep("%s", msgtxt); - if (lev->typ == ROOM) { + + if (lev->typ == ROOM) { /* POOL changed to ROOM above */ if ((mon = m_at(x, y)) != 0) { /* probably ought to do some hefty damage to any creature caught in boiling water; @@ -5081,6 +5086,15 @@ zap_over_floor( } } newsym(x, y); + if (t) { + /* if water walking/swimming/magical breathing, maybe fall + into the new pit (after the water evaporation message); + if flying or levitating, nothing will happen */ + if (u_at(x, y)) + dotrap(t, NO_TRAP_FLAGS); + else if (mon) + mintrap(mon, NO_TRAP_FLAGS); + } } } else if (IS_FOUNTAIN(lev->typ)) { create_gas_cloud(x, y, rnd(3), 0); /* 1..3, no damage */