]> granicus.if.org Git - nethack/commitdiff
peacefuls witnessing attack against peaceful mon
authorPatR <rankin@nethack.org>
Thu, 24 Sep 2020 07:44:07 +0000 (00:44 -0700)
committerPatR <rankin@nethack.org>
Thu, 24 Sep 2020 07:44:07 +0000 (00:44 -0700)
The short exclamations ("Gasp!", "Why?", &c) led to ambiguity
about which monster was vocalizing them.  Use full sentences
which refer to the speaker.  It can become quite a bit more
verbose but is less likely to lead to confusion.  Perhaps it
should cut those off after a modest number of them have been
issued?

doc/fixes37.0
include/extern.h
include/flag.h
src/mon.c
src/sounds.c

index c0fc2b284d940fd81bcf5d10c8fe433b50d33d9c..ed3b14e1824bc3d9eec40991cd59ec5f5dd95f98 100644 (file)
@@ -1,4 +1,4 @@
-NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.308 $ $NHDT-Date: 1600909016 2020/09/24 00:56:56 $
+NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.309 $ $NHDT-Date: 1600933440 2020/09/24 07:44:00 $
 
 General Fixes and Modified Features
 -----------------------------------
@@ -254,6 +254,8 @@ handle being interrupted by approaching monsters more consistently
 if hero attacked a peaceful monster, some other peaceful monsters with humanoid
        shape (minotaur, zruty, perhaps others) that witnessed it but which
        shouldn't be capable of normal speech expressed their surprise audibly
+make gasp/exclamation message from peaceful monsters be more verbose to
+       indicate which monster is doing the gasping or exclaiming
 when make was invoked with -j makedefs instances could end up running in
        parallel and could trample on each other's temp files; default to
        using mkstemp(); allow a port runtime library implementation that lacks
index 0144874994034b2ba37fd7a5835ac045531c61cb..1366ec92ec3d1f026d9fcf99c5799cc580e74584 100644 (file)
@@ -1,4 +1,4 @@
-/* NetHack 3.7 extern.h        $NHDT-Date: 1600652305 2020/09/21 01:38:25 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.858 $ */
+/* NetHack 3.7 extern.h        $NHDT-Date: 1600933440 2020/09/24 07:44:00 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.859 $ */
 /* Copyright (c) Steve Creps, 1988.                              */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -2442,7 +2442,7 @@ E void FDECL(growl, (struct monst *));
 E void FDECL(yelp, (struct monst *));
 E void FDECL(whimper, (struct monst *));
 E void FDECL(beg, (struct monst *));
-E boolean FDECL(maybe_gasp, (struct monst *));
+E const char *FDECL(maybe_gasp, (struct monst *));
 E int NDECL(dotalk);
 E int NDECL(tiphat);
 #ifdef USER_SOUNDS
index 6750e336f6251c6f7facf4cfe067d4270938e0fb..ddb86720d4709cdf96569929bc14f5dc015c0e02 100644 (file)
@@ -1,4 +1,4 @@
-/* NetHack 3.7 flag.h  $NHDT-Date: 1593953335 2020/07/05 12:48:55 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.183 $ */
+/* NetHack 3.7 flag.h  $NHDT-Date: 1600933440 2020/09/24 07:44:00 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.185 $ */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /*-Copyright (c) Michael Allison, 2006. */
 /* NetHack may be freely redistributed.  See license for details. */
@@ -408,6 +408,7 @@ enum plnmsg_types {
     PLNMSG_OBJNAM_ONLY,         /* xname/doname only, for #tip */
     PLNMSG_OK_DONT_DIE,         /* overriding death in explore/wizard mode */
     PLNMSG_BACK_ON_GROUND,      /* leaving water */
+    PLNMSG_GROWL,               /* growl() gave some message */
     PLNMSG_enum /* allows inserting new entries with unconditional trailing comma */
 };
 
index e3d800b4c5cfd60f9df4c9c7add0bd4bfe91cdbf..c90ddcb2876e5a1ad3e39a0a7039f8da19d0706e 100644 (file)
--- a/src/mon.c
+++ b/src/mon.c
@@ -1,4 +1,4 @@
-/* NetHack 3.7 mon.c   $NHDT-Date: 1600652305 2020/09/21 01:38:25 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.347 $ */
+/* NetHack 3.7 mon.c   $NHDT-Date: 1600933441 2020/09/24 07:44:01 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.348 $ */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /*-Copyright (c) Derek S. Ray, 2015. */
 /* NetHack may be freely redistributed.  See license for details. */
@@ -3138,6 +3138,9 @@ boolean via_attack;
     mtmp->mstrategy &= ~STRAT_WAITMASK;
     if (!mtmp->mpeaceful)
         return;
+    /* [FIXME: this logic seems wrong; peaceful humanoids gasp or exclaim
+       when they see you attack a peaceful monster but they just casually
+       look the other way when you attack a pet?] */
     if (mtmp->mtame)
         return;
     mtmp->mpeaceful = 0;
@@ -3196,25 +3199,50 @@ boolean via_attack;
             if (!mindless(mon->data) && mon->mpeaceful
                 && couldsee(mon->mx, mon->my) && !mon->msleeping
                 && mon->mcansee && m_canseeu(mon)) {
-                boolean exclaimed = FALSE;
+                char buf[BUFSZ];
+                boolean exclaimed = FALSE, needpunct = FALSE, alreadyfleeing;
 
+                buf[0] = '\0';
                 if (humanoid(mon->data) || mon->isshk || mon->ispriest) {
                     if (is_watch(mon->data)) {
                         verbalize("Halt!  You're under arrest!");
                         (void) angry_guards(!!Deaf);
                     } else {
-                        if (!rn2(5)) {
-                            exclaimed = maybe_gasp(mon);
+                        if (!Deaf && !rn2(5)) {
+                            const char *gasp = maybe_gasp(mon);
+
+                            if (gasp) {
+                                if (!strncmpi(gasp, "gasp", 4)) {
+                                    Sprintf(buf, "%s gasps", Monnam(mon));
+                                    needpunct = TRUE;
+                                } else {
+                                    Sprintf(buf, "%s exclaims \"%s\"",
+                                            Monnam(mon), gasp);
+                                }
+                                exclaimed = TRUE;
+                            }
                         }
                         /* shopkeepers and temple priests might gasp in
                            surprise, but they won't become angry here */
-                        if (mon->isshk || mon->ispriest)
+                        if (mon->isshk || mon->ispriest) {
+                            if (exclaimed)
+                                pline("%s%s", buf, " then shrugs.");
                             continue;
+                        }
 
                         if (mon->data->mlevel < rn2(10)) {
+                            alreadyfleeing = (mon->mflee || mon->mfleetim);
                             monflee(mon, rn2(50) + 25, TRUE, !exclaimed);
-                            exclaimed = TRUE;
+                            if (exclaimed) {
+                                if (flags.verbose && !alreadyfleeing) {
+                                    Strcat(buf, " and then turns to flee.");
+                                    needpunct = FALSE;
+                                }
+                            } else
+                                exclaimed = TRUE; /* got msg from monflee() */
                         }
+                        if (*buf)
+                            pline("%s%s", buf, needpunct ? "." : "");
                         if (mon->mtame) {
                             ; /* mustn't set mpeaceful to 0 as below;
                                * perhaps reduce tameness? */
@@ -3228,12 +3256,18 @@ boolean via_attack;
                 } else if (mon->data->mlet == mtmp->data->mlet
                            && big_little_match(mndx, monsndx(mon->data))
                            && !rn2(3)) {
-                    if (!rn2(4)) {
+                    if (!Deaf && !rn2(4)) {
                         growl(mon);
-                        exclaimed = TRUE;
+                        exclaimed = (iflags.last_msg == PLNMSG_GROWL);
                     }
-                    if (rn2(6))
+                    if (rn2(6)) {
+                        alreadyfleeing = (mon->mflee || mon->mfleetim);
                         monflee(mon, rn2(25) + 15, TRUE, !exclaimed);
+                        if (exclaimed && !alreadyfleeing)
+                            /* word like a separate sentence so that we
+                               don't have to poke around inside growl() */
+                            pline("And then starts to flee.");
+                    }
                 }
             }
         }
index 0059743ce0963768e1464150693cd0860cf6db9b..75b0de790f3d3fe67d5811a659b11e07dc5f058b 100644 (file)
@@ -1,4 +1,4 @@
-/* NetHack 3.7 sounds.c        $NHDT-Date: 1600652306 2020/09/21 01:38:26 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.102 $ */
+/* NetHack 3.7 sounds.c        $NHDT-Date: 1600933442 2020/09/24 07:44:02 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.103 $ */
 /*      Copyright (c) 1989 Janet Walz, Mike Threepoint */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -369,6 +369,7 @@ register struct monst *mtmp;
         growl_verb = growl_sound(mtmp);
     if (growl_verb) {
         pline("%s %s!", Monnam(mtmp), vtense((char *) 0, growl_verb));
+        iflags.last_msg = PLNMSG_GROWL;
         if (g.context.run)
             nomul(0);
         wake_nearto(mtmp->mx, mtmp->my, mtmp->data->mlevel * 18);
@@ -480,7 +481,7 @@ register struct monst *mtmp;
 }
 
 /* hero has attacked a peaceful monster within 'mon's view */
-boolean
+const char *
 maybe_gasp(mon)
 struct monst *mon;
 {
@@ -542,10 +543,9 @@ struct monst *mon;
         break;
     }
     if (dogasp) {
-        verbalize("%s", Exclam[mon->m_id % SIZE(Exclam)]);
-        return TRUE;
+        return Exclam[rn2(SIZE(Exclam))]; /* [mon->m_id % SIZE(Exclam)]; */
     }
-    return FALSE;
+    return (const char *) 0;
 }
 
 /* return True if mon is a gecko or seems to look like one (hallucination) */