]> granicus.if.org Git - nethack/commitdiff
fix github issue #431 - failed displacing
authorPatR <rankin@nethack.org>
Thu, 31 Dec 2020 19:23:29 +0000 (11:23 -0800)
committerPatR <rankin@nethack.org>
Thu, 31 Dec 2020 19:23:29 +0000 (11:23 -0800)
Being able to swap places with peaceful monsters instead of just
with pets made it possible to cause them to flee. Shopkeepers
wouldn't abandon the shop door but temple priests would attack
if hero tried to chat while they were fleeing.

doc/fixes37.0
src/hack.c
src/uhitm.c

index 561b01e47cd8a4552bbe5c3250ad2e7525b88c8d..10eea91c555d990af5df46126b9ce93153b5b7ca 100644 (file)
@@ -1,4 +1,4 @@
-NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.410 $ $NHDT-Date: 1609281273 2020/12/29 22:34:33 $
+NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.413 $ $NHDT-Date: 1609442596 2020/12/31 19:23:16 $
 
 General Fixes and Modified Features
 -----------------------------------
@@ -469,6 +469,7 @@ wizard mode sanity check complained about Wizard's clone mimicking a monster
 new ^G gender-naming handling code required a guard against null permonst
        pointer which could occur under some circumstances
 replace some monster names in .lua files with their new equivalents
+attempting to swap places with a peaceful monster might cause it to flee
 
 curses: 'msg_window' option wasn't functional for curses unless the binary
        also included tty support
index 30ea83a96c556f2dca0b495be8c215e4113f2cca..e004caaedabfd4f9ebc542e3f5b74c58e14a24e1 100644 (file)
@@ -1,4 +1,4 @@
-/* NetHack 3.7 hack.c  $NHDT-Date: 1608673692 2020/12/22 21:48:12 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.274 $ */
+/* NetHack 3.7 hack.c  $NHDT-Date: 1609442596 2020/12/31 19:23:16 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.276 $ */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /*-Copyright (c) Derek S. Ray, 2015. */
 /* NetHack may be freely redistributed.  See license for details. */
@@ -1913,8 +1913,9 @@ domove_core()
             You("%s %s.", mtmp->mpeaceful ? "swap places with" : "frighten",
                 x_monnam(mtmp,
                          mtmp->mtame ? ARTICLE_YOUR
-                         : (!has_mgivenname(mtmp) && !type_is_pname(mtmp->data))
-                           ? ARTICLE_THE : ARTICLE_NONE,
+                         : (!has_mgivenname(mtmp)
+                            && !type_is_pname(mtmp->data)) ? ARTICLE_THE
+                           : ARTICLE_NONE,
                          (mtmp->mpeaceful && !mtmp->mtame) ? "peaceful" : 0,
                          has_mgivenname(mtmp) ? SUPPRESS_SADDLE : 0, FALSE));
 
index 34896bdd048fdf8b5cecf26a13a97357eb12f551..b3b09983a43f601a13dc7d52ed0b877edf4aab94 100644 (file)
@@ -1,4 +1,4 @@
-/* NetHack 3.7 uhitm.c $NHDT-Date: 1607076540 2020/12/04 10:09:00 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.288 $ */
+/* NetHack 3.7 uhitm.c $NHDT-Date: 1609442602 2020/12/31 19:23:22 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.292 $ */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /*-Copyright (c) Robert Patrick Rankin, 2012. */
 /* NetHack may be freely redistributed.  See license for details. */
@@ -346,9 +346,14 @@ register struct monst *mtmp;
              * if your pet is a long worm with a tail.
              * There's also a chance of displacing a "frozen" monster:
              * sleeping monsters might magically walk in their sleep.
+             * This block of code used to only be called for pets; now
+             * that it also applies to peacefuls, non-pets mustn't be
+             * forced to flee.
              */
             boolean foo = (Punished || !rn2(7)
-                           || (is_longworm(mtmp->data) && mtmp->wormno)),
+                           || (is_longworm(mtmp->data) && mtmp->wormno)
+                           || (IS_ROCK(levl[u.ux][u.uy].typ)
+                               && !passes_walls(mtmp->data))),
                     inshop = FALSE;
             char *p;
 
@@ -360,17 +365,17 @@ register struct monst *mtmp;
                         break;
                     }
             }
-            if (inshop || foo || (IS_ROCK(levl[u.ux][u.uy].typ)
-                                  && !passes_walls(mtmp->data))) {
+            if (inshop || foo) {
                 char buf[BUFSZ];
 
-                monflee(mtmp, rnd(6), FALSE, FALSE);
+                if (mtmp->mtame) /* see 'additional considerations' above */
+                    monflee(mtmp, rnd(6), FALSE, FALSE);
                 Strcpy(buf, y_monnam(mtmp));
                 buf[0] = highc(buf[0]);
                 You("stop.  %s is in the way!", buf);
                 end_running(TRUE);
                 return TRUE;
-            } else if (mtmp->mfrozen || mtmp->msleeping || (!mtmp->mcanmove)
+            } else if (mtmp->mfrozen || mtmp->msleeping || !mtmp->mcanmove
                        || (mtmp->data->mmove == 0 && rn2(6))) {
                 pline("%s doesn't seem to move!", Monnam(mtmp));
                 end_running(TRUE);