looking at hidden monsters

Sometimes you can see a hidden monster without bringing it out of
hiding (wand of probing, blessed potion of monster detection) but
look_at wasn't mentioning the fact that the monster was hidden and
probing described mimics accurately but lumped all hiders together
as "concealed".  Describe all hidden monsters more consistently.
This commit is contained in:
PatR
2016-02-16 17:36:51 -08:00
parent f5b2a8c373
commit f132a12a07
5 changed files with 79 additions and 30 deletions

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 pager.c $NHDT-Date: 1448482543 2015/11/25 20:15:43 $ $NHDT-Branch: master $:$NHDT-Revision: 1.86 $ */
/* NetHack 3.6 pager.c $NHDT-Date: 1455672994 2016/02/17 01:36:34 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.92 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */
@@ -77,6 +77,60 @@ char *outbuf;
return outbuf;
}
/* describe a hidden monster; used for look_at during extended monster
detection and for probing */
void
mhidden_description(mon, altmon, outbuf)
struct monst *mon;
boolean altmon; /* for probing: if mimicking a monster, say so */
char *outbuf;
{
struct obj *otmp;
boolean fakeobj;
int x = mon->mx, y = mon->my, glyph = levl[x][y].glyph;
*outbuf = '\0';
if (mon->m_ap_type == M_AP_FURNITURE
|| mon->m_ap_type == M_AP_OBJECT) {
Strcpy(outbuf, ", mimicking ");
if (mon->m_ap_type == M_AP_FURNITURE) {
Strcat(outbuf, an(defsyms[mon->mappearance].explanation));
} else if (mon->m_ap_type == M_AP_OBJECT
/* remembered glyph, not glyph_at() which is 'mon' */
&& glyph_is_object(glyph)) {
objfrommap:
otmp = (struct obj *) 0;
fakeobj = object_from_map(glyph, x, y, &otmp);
Strcat(outbuf, (otmp && otmp->otyp != STRANGE_OBJECT)
? ansimpleoname(otmp)
: an(obj_descr[STRANGE_OBJECT].oc_name));
if (fakeobj)
dealloc_obj(otmp);
} else if (mon->m_ap_type == M_AP_MONSTER && altmon) {
Strcat(outbuf, an(mons[mon->mappearance].mname));
} else {
Strcat(outbuf, something);
}
} else if (mon->mundetected) {
Strcpy(outbuf, ", hiding");
if (hides_under(mon->data)) {
Strcat(outbuf, " under ");
/* remembered glyph, not glyph_at() which is 'mon' */
if (glyph_is_object(glyph))
goto objfrommap;
Strcat(outbuf, something);
} else if (is_hider(mon->data)) {
Sprintf(eos(outbuf), " on the %s",
(is_flyer(mon->data) || mon->data->mlet == S_PIERCER)
? "ceiling"
: surface(x, y)); /* trapper */
} else {
if (mon->data->mlet == S_EEL && is_pool(x, y))
Strcat(outbuf, " in murky water");
}
}
}
/* extracted from lookat(); also used by namefloorobj() */
boolean
object_from_map(glyph, x, y, obj_p)
@@ -156,11 +210,9 @@ int x, y;
char *name, monnambuf[BUFSZ];
boolean accurate = !Hallucination;
if (mtmp->data == &mons[PM_COYOTE] && accurate)
name = coyotename(mtmp, monnambuf);
else
name = distant_monnam(mtmp, ARTICLE_NONE, monnambuf);
name = (mtmp->data == &mons[PM_COYOTE] && accurate)
? coyotename(mtmp, monnambuf)
: distant_monnam(mtmp, ARTICLE_NONE, monnambuf);
Sprintf(buf, "%s%s%s",
(mtmp->mx != x || mtmp->my != y)
? ((mtmp->isshk && accurate) ? "tail of " : "tail of a ")
@@ -187,6 +239,11 @@ int x, y;
an(defsyms[trap_to_defsym(tt)].explanation));
}
/* we know the hero sees a monster at this location, but if it's shown
due to persistant monster detection he might remember something else */
if (mtmp->mundetected || mtmp->m_ap_type)
mhidden_description(mtmp, FALSE, eos(buf));
if (monbuf) {
unsigned how_seen = howmonseen(mtmp);
@@ -479,7 +536,8 @@ boolean user_typed_name, without_asking;
impossible("can't read 'data' file");
(void) dlb_fclose(fp);
return;
} else if (sscanf(buf, "%8lx\n", &txt_offset) < 1 || txt_offset == 0L)
} else if (sscanf(buf, "%8lx\n", &txt_offset) < 1
|| txt_offset == 0L)
goto bad_data_file;
/* look for the appropriate entry */