From acb416abccb49f19e4c64e7914c021c074dba7c6 Mon Sep 17 00:00:00 2001 From: "nethack.rankin" Date: Thu, 17 Mar 2005 05:20:34 +0000 Subject: [PATCH] land mine vs drawbridge Fix the reported problem that having a land mine explode on an open drawbridge or under its portcullis did not cause the bridge to be destroyed. --- doc/fixes34.4 | 1 + src/trap.c | 37 ++++++++++++++++++++++++++----------- 2 files changed, 27 insertions(+), 11 deletions(-) diff --git a/doc/fixes34.4 b/doc/fixes34.4 index b79d86872..76a22c198 100644 --- a/doc/fixes34.4 +++ b/doc/fixes34.4 @@ -95,6 +95,7 @@ mbodypart should return forehoof, not foreclaw, for horselike monsters further digging of an existing hole finishes in a single turn only prefix shopkeeper names with "Mr." or "Ms." when not a personal name green slime should not affect noncorporeal monsters +land mine explosion will destroy a drawbridge at same location Platform- and/or Interface-Specific Fixes diff --git a/src/trap.c b/src/trap.c index c5059094c..a6b708020 100644 --- a/src/trap.c +++ b/src/trap.c @@ -1,4 +1,4 @@ -/* SCCS Id: @(#)trap.c 3.5 2004/12/21 */ +/* SCCS Id: @(#)trap.c 3.5 2005/03/16 */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* NetHack may be freely redistributed. See license for details. */ @@ -1309,18 +1309,30 @@ void blow_up_landmine(trap) struct trap *trap; { - (void)scatter(trap->tx, trap->ty, 4, - MAY_DESTROY | MAY_HIT | MAY_FRACTURE | VIS_EFFECTS, - (struct obj *)0); - del_engr_at(trap->tx, trap->ty); - wake_nearto(trap->tx, trap->ty, 400); - if (IS_DOOR(levl[trap->tx][trap->ty].typ)) - levl[trap->tx][trap->ty].doormask = D_BROKEN; - /* TODO: destroy drawbridge if present */ - /* caller may subsequently fill pit, e.g. with a boulder */ + int x = trap->tx, y = trap->ty, dbx, dby; + struct rm *lev = &levl[x][y]; + + (void)scatter(x, y, 4, + MAY_DESTROY | MAY_HIT | MAY_FRACTURE | VIS_EFFECTS, + (struct obj *)0); + del_engr_at(x, y); + wake_nearto(x, y, 400); + if (IS_DOOR(lev->typ)) + lev->doormask = D_BROKEN; + /* destroy drawbridge if present */ + if (lev->typ == DRAWBRIDGE_DOWN || is_drawbridge_wall(x, y) >= 0) { + dbx = x, dby = y; + /* if under the portcullis, the bridge is adjacent */ + if (find_drawbridge(&dbx, &dby)) + destroy_drawbridge(dbx, dby); + trap = t_at(x, y); /* expected to be null after destruction */ + } + /* convert landmine into pit */ + if (trap) { trap->ttyp = PIT; /* explosion creates a pit */ trap->madeby_u = FALSE; /* resulting pit isn't yours */ seetrap(trap); /* and it isn't concealed */ + } } /* @@ -2183,7 +2195,10 @@ glovecheck: target = which_armor(mtmp, W_ARMG); if (!in_sight) pline("Kaablamm! You hear an explosion in the distance!"); blow_up_landmine(trap); - if (thitm(0, mtmp, (struct obj *)0, rnd(16), FALSE)) + /* explosion might have destroyed a drawbridge; don't + dish out more damage if monster is already dead */ + if (mtmp->mhp <= 0 || + thitm(0, mtmp, (struct obj *)0, rnd(16), FALSE)) trapkilled = TRUE; else { /* monsters recursively fall into new pit */