]> granicus.if.org Git - nethack/commitdiff
pull request #660 from NullCGT - sleeping monsters
authorKestrel Gregorich-Trevor <kestrelg@kestrelscry.com>
Thu, 20 Jan 2022 16:24:10 +0000 (10:24 -0600)
committerPatR <rankin@nethack.org>
Tue, 22 Feb 2022 19:36:40 +0000 (11:36 -0800)
Indicate to players that monsters are sleeping.

Closes #660

doc/fixes3-7-0.txt
include/extern.h
src/hack.c
src/mon.c
src/monmove.c
src/pager.c

index 2fe92c56fdea13c36dd338caad51e71c5917c76b..8f8e61952943615cda74947f3fc2cc794d5e1e18 100644 (file)
@@ -1456,6 +1456,8 @@ reading a blessed scroll of light has a chance to improve bless/curse state
        those into holy water; cursed scroll has chance to worsen the state
 added a chronicle of major events, and optional live logging of those
 paranoid:swim to prevent accidental dunking into dangerous liquids
+looking at a monster will indicate whether it is asleep, and waking up a
+       monster yields a message
 
 
 Platform- and/or Interface-Specific New Features
index c5840eb45feb29054a37f2c4aa3567080f654e77..ae78ddc8b5bb678ca18d27a9684e7226b0fc609b 100644 (file)
@@ -1503,6 +1503,7 @@ extern void maybe_mnexto(struct monst *);
 extern int mnearto(struct monst *, xchar, xchar, boolean, unsigned);
 extern void m_respond(struct monst *);
 extern void setmangry(struct monst *, boolean);
+extern void wake_msg(struct monst *, boolean);
 extern void wakeup(struct monst *, boolean);
 extern void wake_nearby(void);
 extern void wake_nearto(int, int, int);
index 4ccf8d0a12d0084f59f99206f365cf46b90e60af..a59aedce9fe120707d9cf647009e7bd672c1b4eb 100644 (file)
@@ -2895,8 +2895,10 @@ check_special_room(boolean newlev)
                     if (!isok(mtmp->mx,mtmp->my)
                         || roomno != (int) levl[mtmp->mx][mtmp->my].roomno)
                         continue;
-                    if (!Stealth && !rn2(3))
+                    if (!Stealth && !rn2(3)) {
+                        wake_msg(mtmp, FALSE);
                         mtmp->msleeping = 0;
+                    }
                 }
         }
     }
index ac59af910d3d881ae5ffdb8e734927b6bd191173..825601b1450df1cb207fad4cf98f97a15cd2bf7a 100644 (file)
--- a/src/mon.c
+++ b/src/mon.c
@@ -3635,10 +3635,21 @@ setmangry(struct monst* mtmp, boolean via_attack)
     }
 }
 
+/* Indicate via message that a monster has awoken. */
+void
+wake_msg(struct monst *mtmp, boolean interesting)
+{
+    if (mtmp->msleeping && canseemon(mtmp)) {
+        pline("%s wakes up%s%s", Monnam(mtmp), interesting ? "!" : ".",
+              mtmp->data == &mons[PM_FLESH_GOLEM] ? " It's alive!" : "");
+    }
+}
+
 /* wake up a monster, possibly making it angry in the process */
 void
 wakeup(struct monst* mtmp, boolean via_attack)
 {
+    wake_msg(mtmp, via_attack);
     mtmp->msleeping = 0;
     if (M_AP_TYPE(mtmp) != M_AP_NOTHING) {
         /* mimics come out of hiding, but disguised Wizard doesn't
@@ -3674,6 +3685,7 @@ wake_nearto(int x, int y, int distance)
         if (distance == 0 || dist2(mtmp->mx, mtmp->my, x, y) < distance) {
             /* sleep for N turns uses mtmp->mfrozen, but so does paralysis
                so we leave mfrozen monsters alone */
+            wake_msg(mtmp, FALSE);
             mtmp->msleeping = 0; /* wake indeterminate sleep */
             if (!(mtmp->data->geno & G_UNIQ))
                 mtmp->mstrategy &= ~STRAT_WAITMASK; /* wake 'meditation' */
index eb64718579ba5a12499d69080097120dffd39287..1605f7c034d58196b7cbd4cea7f3663f84fb3784 100644 (file)
@@ -232,6 +232,7 @@ disturb(register struct monst* mtmp)
             || (mtmp->data->mlet == S_DOG || mtmp->data->mlet == S_HUMAN)
             || (!rn2(7) && M_AP_TYPE(mtmp) != M_AP_FURNITURE
                 && M_AP_TYPE(mtmp) != M_AP_OBJECT))) {
+        wake_msg(mtmp, !mtmp->mpeaceful);
         mtmp->msleeping = 0;
         return 1;
     }
index 3cd79f30575b01acc327421f8b465de5dec44cee..88f83888362eca2f0e2e550f2ae84ea7ba086f02 100644 (file)
@@ -359,6 +359,8 @@ look_at_monster(char *buf,
             Strcat(buf, (Upolyd && sticks(g.youmonst.data))
                           ? ", being held" : ", holding you");
     }
+    if (mtmp->msleeping)
+        Strcat(buf, ", asleep");
     if (mtmp->mleashed)
         Strcat(buf, ", leashed to you");