]> granicus.if.org Git - nethack/commitdiff
fix #3120,#3122 - dwarf pass_wall without digging
authorPatR <rankin@nethack.org>
Mon, 7 Dec 2020 20:46:46 +0000 (12:46 -0800)
committerPatR <rankin@nethack.org>
Mon, 7 Dec 2020 20:46:46 +0000 (12:46 -0800)
I couldn't reproduce this so can't confirm that this fix works,
but inspection of the code reveals that something was missing
in the unified mon movement flags code.  I think what has been
happening is that a dwarf without a pick-axe might not bother
wielding that but movement behaved as if it had, then digging
decided it wasn't.

doc/fixes37.0
src/dogmove.c
src/mon.c

index 16a14abe6f19115320ca3d2aa2c4cd7156b16ffd..3194adae7ec1bdd59710e663be0f40225a197466 100644 (file)
@@ -1,4 +1,4 @@
-NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.376 $ $NHDT-Date: 1607252278 2020/12/06 10:57:58 $
+NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.377 $ $NHDT-Date: 1607373999 2020/12/07 20:46:39 $
 
 General Fixes and Modified Features
 -----------------------------------
@@ -411,6 +411,7 @@ options help ('? g') listed all boolean options, then repeated them among
        the compound options; on OSX they showed a description of "(null)"
        but for other sprintf implementations they might cause a crash
 change name of #wizlevelflip to #wizfliplevel
+dwarves could sometimes pass through walls without digging their way
 
 curses: 'msg_window' option wasn't functional for curses unless the binary
        also included tty support
index e4f8f4513c1d2d1d1a8c4c078dd102f9036f0e15..363bbcd5c6e899d983782b49c75ebd9297260b76 100644 (file)
@@ -1,4 +1,4 @@
-/* NetHack 3.7 dogmove.c       $NHDT-Date: 1596498159 2020/08/03 23:42:39 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.91 $ */
+/* NetHack 3.7 dogmove.c       $NHDT-Date: 1607374000 2020/12/07 20:46:40 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.94 $ */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /*-Copyright (c) Robert Patrick Rankin, 2012. */
 /* NetHack may be freely redistributed.  See license for details. */
@@ -1311,7 +1311,9 @@ xchar mx, my, fx, fy;
             if (dist2(i, j, fx, fy) >= dist)
                 continue;
             if (IS_ROCK(levl[i][j].typ) && !passes_walls(mon->data)
-                && (!may_dig(i, j) || !tunnels(mon->data)))
+                && (!may_dig(i, j) || !tunnels(mon->data)
+                    /* tunnelling monsters can't do that on the rogue level */
+                    || Is_rogue_level(&u.uz)))
                 continue;
             if (IS_DOOR(levl[i][j].typ)
                 && (levl[i][j].doormask & (D_CLOSED | D_LOCKED)))
index e203e71d73980a61834b60b611fb80982b3ad85c..06a00a4a38103c6c5aa8d200e154e48d993faf9d 100644 (file)
--- a/src/mon.c
+++ b/src/mon.c
@@ -1,4 +1,4 @@
-/* NetHack 3.7 mon.c   $NHDT-Date: 1606623308 2020/11/29 04:15:08 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.357 $ */
+/* NetHack 3.7 mon.c   $NHDT-Date: 1607374002 2020/12/07 20:46:42 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.359 $ */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /*-Copyright (c) Derek S. Ray, 2015. */
 /* NetHack may be freely redistributed.  See license for details. */
@@ -1551,6 +1551,14 @@ struct monst *mtmp;
     boolean can_unlock = ((can_open && monhaskey(mtmp, TRUE))
                           || mtmp->iswiz || is_rider(mtmp->data));
     boolean doorbuster = is_giant(mtmp->data);
+    /* don't tunnel if on rogue level or if hostile and close enough
+       to prefer a weapon; same criteria as in m_move() */
+    boolean can_tunnel = (tunnels(mtmp->data) && !Is_rogue_level(&u.uz));
+
+    if (can_tunnel && needspick(mtmp->data)
+        && ((!mtmp->mpeaceful || Conflict)
+            && dist2(mtmp->mx, mtmp->my, mtmp->mux, mtmp->muy) <= 8))
+        can_tunnel = FALSE;
 
     if (mtmp->mtame)
         allowflags |= ALLOW_M | ALLOW_TRAPS | ALLOW_SANCT | ALLOW_SSM;
@@ -1568,8 +1576,7 @@ struct monst *mtmp;
         allowflags |= (ALLOW_ROCK | ALLOW_WALL);
     if (throws_rocks(mtmp->data))
         allowflags |= ALLOW_ROCK;
-    if (tunnels(mtmp->data)
-        && !Is_rogue_level(&u.uz)) /* same restriction as m_move() */
+    if (can_tunnel)
         allowflags |= ALLOW_DIG;
     if (doorbuster)
         allowflags |= BUSTDOOR;