From: Michael Meyer Date: Thu, 19 Nov 2020 17:42:09 +0000 (-0500) Subject: Add liquid flow to land mine explosions X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=2df4f08c0ba7a247e0d09efb19f592f69c93631c;p=nethack Add liquid flow to land mine explosions Land mine explosions did not call liquid_flow(dig.c), and as a result the pit created by an exploding land mine would never fill with adjacent water or lava, as pits created by other sources -- digging, breaking a wand, and earthquake -- can do. This commit adds the appropriate calls to liquid_flow and fillholetyp to blow_up_landmine so that land mine explosions may fill with water like other pits do. The call to losehp in dotrap had to be moved from after to before blow_up_landmine, since waiting to call losehp when the pit can fill with water could lead to silly messages (``That was a close one. You die...''). After this change, a land mine that killed a character would be retained unexploded in a bones file, because death would occur before the call to blow_up_landmine. To avoid this issue, the land mine is converted to a pit before calling losehp; blow_up_landmine does not check whether the target trap is in fact a landmine so works as usual even if the trap is converted to a pit, and will delete the pit in cases where it should not exist. --- diff --git a/src/trap.c b/src/trap.c index 6b20f2596..d922049db 100644 --- a/src/trap.c +++ b/src/trap.c @@ -2147,11 +2147,15 @@ unsigned trflags; set_wounded_legs(RIGHT_SIDE, rn1(35, 41)); exercise(A_DEX, FALSE); } + /* add a pit before calling losehp so bones won't keep the landmine; + * blow_up_landmine will remove the pit afterwards if inappropriate */ + trap->ttyp = PIT; + trap->madeby_u = FALSE; + losehp(Maybe_Half_Phys(rnd(16)), "land mine", KILLED_BY_AN); blow_up_landmine(trap); if (steed_mid && saddle && !u.usteed) (void) keep_saddle_with_steedcorpse(steed_mid, fobj, saddle); newsym(u.ux, u.uy); /* update trap symbol */ - losehp(Maybe_Half_Phys(rnd(16)), "land mine", KILLED_BY_AN); /* fall recursively into the pit... */ if ((trap = t_at(u.ux, u.uy)) != 0) dotrap(trap, RECURSIVETRAP); @@ -2552,6 +2556,7 @@ struct trap *trap; { int x = trap->tx, y = trap->ty, dbx, dby; struct rm *lev = &levl[x][y]; + schar typ; (void) scatter(x, y, 4, MAY_DESTROY | MAY_HIT | MAY_FRACTURE | VIS_EFFECTS, @@ -2574,9 +2579,18 @@ struct trap *trap; /* no pits here */ deltrap(trap); } else { - trap->ttyp = PIT; /* explosion creates a pit */ - trap->madeby_u = FALSE; /* resulting pit isn't yours */ - seetrap(trap); /* and it isn't concealed */ + /* fill pit with water, if applicable */ + typ = fillholetyp(x, y, FALSE); + if (typ != ROOM) { + lev->typ = typ; + liquid_flow(x, y, typ, trap, + cansee(x, y) ? "The hole fills with %s!" + : (char *) 0); + } else { + trap->ttyp = PIT; /* explosion creates a pit */ + trap->madeby_u = FALSE; /* resulting pit isn't yours */ + seetrap(trap); /* and it isn't concealed */ + } } } }