fix #H3734 - "see an angry guard" when that guard

is invisible and hero can't see him/her.  Reported for 3.4.3 in
late 2014....
This commit is contained in:
PatR
2021-02-23 02:04:21 -08:00
parent ed349cd5fe
commit 27a0351cd2
2 changed files with 26 additions and 16 deletions
+3 -1
View File
@@ -1,4 +1,4 @@
NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.460 $ $NHDT-Date: 1613957400 2021/02/22 01:30:00 $ NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.461 $ $NHDT-Date: 1614074653 2021/02/23 10:04:13 $
General Fixes and Modified Features General Fixes and Modified Features
----------------------------------- -----------------------------------
@@ -384,6 +384,8 @@ curses interface failed to honor menu_xxx option settings for menu interaction
during engraving, spaces were counted instead of non-spaces during engraving, spaces were counted instead of non-spaces
when an explosion scatters objects, make any that fly over sinks stop there when an explosion scatters objects, make any that fly over sinks stop there
output message when changing fastmove mode while cursor targetting output message when changing fastmove mode while cursor targetting
messages when Minetown watchmen become angry could report "you see an angry
guard approaching" even if he was invisible and hero can't see invis
Fixes to 3.7.0-x Problems that Were Exposed Via git Repository Fixes to 3.7.0-x Problems that Were Exposed Via git Repository
+23 -15
View File
@@ -1,4 +1,4 @@
/* NetHack 3.7 mon.c $NHDT-Date: 1609281168 2020/12/29 22:32:48 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.364 $ */ /* NetHack 3.7 mon.c $NHDT-Date: 1614074654 2021/02/23 10:04:14 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.370 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Derek S. Ray, 2015. */ /*-Copyright (c) Derek S. Ray, 2015. */
/* NetHack may be freely redistributed. See license for details. */ /* NetHack may be freely redistributed. See license for details. */
@@ -4505,6 +4505,7 @@ golemeffects(register struct monst* mon, int damtype, int dam)
} }
} }
/* anger the Minetown watch */
boolean boolean
angry_guards(boolean silent) angry_guards(boolean silent)
{ {
@@ -4516,8 +4517,8 @@ angry_guards(boolean silent)
continue; continue;
if (is_watch(mtmp->data) && mtmp->mpeaceful) { if (is_watch(mtmp->data) && mtmp->mpeaceful) {
ct++; ct++;
if (cansee(mtmp->mx, mtmp->my) && mtmp->mcanmove) { if (canspotmon(mtmp) && mtmp->mcanmove) {
if (distu(mtmp->mx, mtmp->my) == 2) if (distu(mtmp->mx, mtmp->my) <= 2)
nct++; nct++;
else else
sct++; sct++;
@@ -4531,18 +4532,25 @@ angry_guards(boolean silent)
} }
if (ct) { if (ct) {
if (!silent) { /* do we want pline msgs? */ if (!silent) { /* do we want pline msgs? */
if (slct) char buf[BUFSZ];
pline_The("guard%s wake%s up!", slct > 1 ? "s" : "",
slct == 1 ? "s" : ""); if (slct) { /* sleeping guard(s) */
if (nct || sct) { Sprintf(buf, "guard%s", plur(slct));
if (nct) pline_The("%s %s up.", buf, vtense(buf, "wake"));
pline_The("guard%s get%s angry!", nct == 1 ? "" : "s", }
nct == 1 ? "s" : "");
else if (!Blind) if (nct) { /* seen/sensed adjacent guard(s) */
You_see("%sangry guard%s approaching!", Sprintf(buf, "guard%s", plur(nct));
sct == 1 ? "an " : "", sct > 1 ? "s" : ""); pline_The("%s %s angry!", buf, vtense(buf, "get"));
} else } else if (sct) { /* seen/sensed non-adjcent guard(s) */
You_hear("the shrill sound of a guard's whistle."); Sprintf(buf, "guard%s", plur(sct));
pline("%s %s %s approaching!",
(sct == 1) ? "An angry" : "Angry",
buf, vtense(buf, "are"));
} else {
Strcpy(buf, (ct == 1) ? "a guard's" : "guards'");
You_hear("the shrill sound of %s whistle%s.", buf, plur(ct));
}
} }
return TRUE; return TRUE;
} }