pull request #660 from NullCGT - sleeping monsters

Indicate to players that monsters are sleeping.

Closes #660
This commit is contained in:
Kestrel Gregorich-Trevor
2022-01-20 10:24:10 -06:00
committed by PatR
parent 462e13f07b
commit 355ed43a29
6 changed files with 21 additions and 1 deletions

View 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

View 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);

View 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;
}
}
}
}

View File

@@ -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' */

View 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;
}

View 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");