From: Kestrel Gregorich-Trevor Date: Thu, 20 Jan 2022 16:24:10 +0000 (-0600) Subject: pull request #660 from NullCGT - sleeping monsters X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=355ed43a29aebb10e3dd8a1794cfe7391d1f2f6d;p=nethack pull request #660 from NullCGT - sleeping monsters Indicate to players that monsters are sleeping. Closes #660 --- diff --git a/doc/fixes3-7-0.txt b/doc/fixes3-7-0.txt index 2fe92c56f..8f8e61952 100644 --- a/doc/fixes3-7-0.txt +++ b/doc/fixes3-7-0.txt @@ -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 diff --git a/include/extern.h b/include/extern.h index c5840eb45..ae78ddc8b 100644 --- a/include/extern.h +++ b/include/extern.h @@ -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); diff --git a/src/hack.c b/src/hack.c index 4ccf8d0a1..a59aedce9 100644 --- a/src/hack.c +++ b/src/hack.c @@ -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; + } } } } diff --git a/src/mon.c b/src/mon.c index ac59af910..825601b14 100644 --- 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' */ diff --git a/src/monmove.c b/src/monmove.c index eb6471857..1605f7c03 100644 --- a/src/monmove.c +++ b/src/monmove.c @@ -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; } diff --git a/src/pager.c b/src/pager.c index 3cd79f305..88f838883 100644 --- a/src/pager.c +++ b/src/pager.c @@ -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");