]> granicus.if.org Git - nethack/commitdiff
land mine vs drawbridge
authornethack.rankin <nethack.rankin>
Thu, 17 Mar 2005 05:20:34 +0000 (05:20 +0000)
committernethack.rankin <nethack.rankin>
Thu, 17 Mar 2005 05:20:34 +0000 (05:20 +0000)
     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
src/trap.c

index b79d86872b948c8b5484710dc349108210598c81..76a22c198e8b92d47e0f61b158dab2ebe268732a 100644 (file)
@@ -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
index c5059094c641c163b42edd6a106c68221a13d572..a6b708020ee68516f9c231b34823dda5e54f7edc 100644 (file)
@@ -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 */