]> granicus.if.org Git - nethack/commitdiff
fix github issue #169 - monst vs vibrating square
authorPatR <rankin@nethack.org>
Wed, 19 Dec 2018 22:52:23 +0000 (14:52 -0800)
committerPatR <rankin@nethack.org>
Wed, 19 Dec 2018 22:52:23 +0000 (14:52 -0800)
Fixes #169

Monsters should not be afraid of stepping on the vibrating square
since it's only a trap for display purposes.  [Perhaps they should
deliberately avoid it if the hero hasn't seen it yet, but I didn't
implement that.]

"You see a strange vibration beneath <mon's> <parts>." was strange
when <parts> was a wolf's "rear paws" or horse's "rear hooves"--was
the vibration magically skipping the front ones?  And it sounded
naughty when it was a snake's "rear regions".  If the creature has no
limbs or is floating or flying, just say "beneath <mon>"; otherwise,
if the part is "rear <something>", omit "rear ".

The message was weird in another way.  Caller removes the monster
from it's old location and places it on the new one, calls newsym()
for the old location to show lack of monster, but then calls mintrap()
before newsym() for monster's new location (the trap's location).  If
pline messages cause buffered map output to be flushed, the monster
will be missing during the time the messages are delivered.  I fixed
that for vibrating square [seetrap()->newsym() before pline() rather
than after] but it should probably be fixed in the caller instead.

doc/fixes36.2
src/mon.c
src/trap.c

index d7348a2ee7789bb8ce8daf70034150f78bbcec7d..5985270475dead1768d2e36dede408cd79ba1fe2 100644 (file)
@@ -289,6 +289,7 @@ diluted potion of oil is less effective when filling lamps (adds less fuel)
 apply fix from grunthack to prevent panic "fakecorr overflow" when vault guard
        couldn't figure out how to lead the hero from vault to civilization;
        fixes longstanding bug C343-23
+vibrating square is not really a trap so monsters don't need to avoid it
 
 
 Fixes to Post-3.6.1 Problems that Were Exposed Via git Repository
index de037e42b8d66e9e12a96bead9476564a9111c66..88aaf3dce5a0fd5c7eca6a1e5c4c30eb5e0249d9 100644 (file)
--- a/src/mon.c
+++ b/src/mon.c
@@ -1,4 +1,4 @@
-/* NetHack 3.6 mon.c   $NHDT-Date: 1544658160 2018/12/12 23:42:40 $  $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.274 $ */
+/* NetHack 3.6 mon.c   $NHDT-Date: 1545259929 2018/12/19 22:52:09 $  $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.275 $ */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /*-Copyright (c) Derek S. Ray, 2015. */
 /* NetHack may be freely redistributed.  See license for details. */
@@ -1476,6 +1476,7 @@ nexttry: /* eels prefer the water, but if there is no water nearby,
                     if ((ttmp->ttyp != RUST_TRAP
                          || mdat == &mons[PM_IRON_GOLEM])
                         && ttmp->ttyp != STATUE_TRAP
+                        && ttmp->ttyp != VIBRATING_SQUARE
                         && ((!is_pit(ttmp->ttyp) && !is_hole(ttmp->ttyp))
                             || (!is_flyer(mdat) && !is_floater(mdat)
                                 && !is_clinger(mdat)) || Sokoban)
index d8d4018e7da9278a4950fe75e4371cc4a4f74301..965c9347ebb513a7c98cd9608a39e84171aac07a 100644 (file)
@@ -1,4 +1,4 @@
-/* NetHack 3.6 trap.c  $NHDT-Date: 1543515862 2018/11/29 18:24:22 $  $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.312 $ */
+/* NetHack 3.6 trap.c  $NHDT-Date: 1545259936 2018/12/19 22:52:16 $  $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.313 $ */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /*-Copyright (c) Robert Patrick Rankin, 2013. */
 /* NetHack may be freely redistributed.  See license for details. */
@@ -2691,13 +2691,29 @@ register struct monst *mtmp;
             break;
         case VIBRATING_SQUARE:
             if (see_it && !Blind) {
-                if (in_sight)
-                    pline("You see a strange vibration beneath %s %s.",
-                          s_suffix(mon_nam(mtmp)),
-                          makeplural(mbodypart(mtmp, FOOT)));
-                else
-                    pline("You see the ground vibrate in the distance.");
-                seetrap(trap);
+                seetrap(trap); /* before messages */
+                if (in_sight) {
+                    char buf[BUFSZ], *p, *monnm = mon_nam(mtmp);
+
+                    if (nolimbs(mtmp->data)
+                        || is_floater(mtmp->data) || is_flyer(mtmp->data)) {
+                        /* just "beneath <mon>" */
+                        Strcpy(buf, monnm);
+                    } else {
+                        Strcpy(buf, s_suffix(monnm));
+                        p = eos(strcat(buf, " "));
+                        Strcpy(p, makeplural(mbodypart(mtmp, FOOT)));
+                        /* avoid "beneath 'rear paws'" or 'rear hooves' */
+                        (void) strsubst(p, "rear ", "");
+                    }
+                    You_see("a strange vibration beneath %s.", buf);
+                } else {
+                    /* notice something (hearing uses a larger threshold
+                       for 'nearby') */
+                    You_see("the ground vibrate %s.",
+                            (distu(mtmp->mx, mtmp->my) <= 2 * 2)
+                               ? "nearby" : "in the distance");
+                }
             }
             break;
         default: