fix U88 - invisible hero didn't sense self via ESP

If the character was invisible without being able to see invisible,
his location on the map showed any object there or underlying topology
instead of the hero even when monsters could be seen with infravision,
ESP, or sustained monster detection.  The ESP case required an amulet
or helm or quest artifact to be noticeable because being blind overrides
being unable to see invisible, so the more common form of telepathy
didn't exhibit this behavior.
This commit is contained in:
nethack.rankin
2002-10-04 02:46:02 +00:00
parent 4430f8f652
commit cd62daa465
4 changed files with 49 additions and 22 deletions

View File

@@ -265,6 +265,7 @@ prevent mbodypart() from returning animal parts for lights
removing a ring might relearn what it is after amnesia
sleeping shopkeeper shouldn't talk to digging player
give more specific feedback when dipping unicorn horns into potions
can see self via infravision or ESP or monster detection when invisible
Platform- and/or Interface-Specific Fixes

View File

@@ -125,6 +125,7 @@
/*
* canseeself()
* senseself()
*
* This returns true if the hero can see her/himself.
*
@@ -132,7 +133,8 @@
* invisible. If not, then we don't need the check.
*/
#define canseeself() (Blind || u.uswallow || (!Invisible && !u.uundetected))
#define senseself() (canseeself() || Infravision || Unblind_telepat || \
Detect_monsters)
/*
* random_monster()
@@ -192,28 +194,22 @@
* _if_ the hero can be seen have already been done.
*/
#ifdef STEED
#define display_self() \
show_glyph(u.ux, u.uy, \
(u.usteed && mon_visible(u.usteed)) ? \
ridden_mon_to_glyph(u.usteed) : \
youmonst.m_ap_type == M_AP_NOTHING ? \
hero_glyph : \
youmonst.m_ap_type == M_AP_FURNITURE ? \
cmap_to_glyph(youmonst.mappearance) : \
youmonst.m_ap_type == M_AP_OBJECT ? \
objnum_to_glyph(youmonst.mappearance) : \
/* else M_AP_MONSTER */ monnum_to_glyph(youmonst.mappearance))
#define maybe_display_usteed (u.usteed && mon_visible(u.usteed)) ? \
ridden_mon_to_glyph(u.usteed) :
#else
#define maybe_display_usteed /* empty */
#endif
#define display_self() \
show_glyph(u.ux, u.uy, \
maybe_display_usteed /* else */ \
youmonst.m_ap_type == M_AP_NOTHING ? \
hero_glyph : \
hero_glyph : \
youmonst.m_ap_type == M_AP_FURNITURE ? \
cmap_to_glyph(youmonst.mappearance) : \
youmonst.m_ap_type == M_AP_OBJECT ? \
objnum_to_glyph(youmonst.mappearance) : \
/* else M_AP_MONSTER */ monnum_to_glyph(youmonst.mappearance))
#endif
/*
* A glyph is an abstraction that represents a _unique_ monster, object,

View File

@@ -1,4 +1,4 @@
/* SCCS Id: @(#)display.c 3.4 2000/07/27 */
/* SCCS Id: @(#)display.c 3.4 2002/10/03 */
/* Copyright (c) Dean Luick, with acknowledgements to Kevin Darcy */
/* and Dave Cohrs, 1990. */
/* NetHack may be freely redistributed. See license for details. */
@@ -667,7 +667,7 @@ newsym(x,y)
return;
}
if (x == u.ux && y == u.uy) {
if (canseeself()) {
if (senseself()) {
_map_location(x,y,0); /* map *under* self */
display_self();
} else
@@ -709,7 +709,7 @@ newsym(x,y)
if (x == u.ux && y == u.uy) {
feel_location(u.ux, u.uy); /* forces an update */
if (canseeself()) display_self();
if (senseself()) display_self();
}
else if ((mon = m_at(x,y))
&& ((see_it = (tp_sensemon(mon) || MATCH_WARN_OF_MON(mon)
@@ -1060,11 +1060,17 @@ void
see_monsters()
{
register struct monst *mon;
for (mon = fmon; mon; mon = mon->nmon) {
if (DEADMONSTER(mon)) continue;
newsym(mon->mx,mon->my);
if (mon->wormno) see_wsegs(mon);
}
#ifdef STEED
/* when mounted, hero's location gets caught by monster loop */
if (!u.usteed)
#endif
newsym(u.ux, u.uy);
}
/*
@@ -1076,16 +1082,19 @@ void
set_mimic_blocking()
{
register struct monst *mon;
for (mon = fmon; mon; mon = mon->nmon)
if(!DEADMONSTER(mon) && mon->minvis &&
for (mon = fmon; mon; mon = mon->nmon) {
if (DEADMONSTER(mon)) continue;
if (mon->minvis &&
((mon->m_ap_type == M_AP_FURNITURE &&
(mon->mappearance == S_vcdoor || mon->mappearance == S_hcdoor))||
(mon->mappearance == S_vcdoor || mon->mappearance == S_hcdoor)) ||
(mon->m_ap_type == M_AP_OBJECT && mon->mappearance == BOULDER))) {
if(See_invisible)
block_point(mon->mx, mon->my);
else
unblock_point(mon->mx, mon->my);
}
}
}
/*

View File

@@ -1,4 +1,4 @@
/* SCCS Id: @(#)pager.c 3.4 2002/07/25 */
/* SCCS Id: @(#)pager.c 3.4 2002/10/03 */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */
@@ -65,7 +65,7 @@ lookat(x, y, buf, monbuf)
buf[0] = monbuf[0] = 0;
glyph = glyph_at(x,y);
if (u.ux == x && u.uy == y && canseeself()) {
if (u.ux == x && u.uy == y && senseself()) {
char race[QBUFSZ];
/* if not polymorphed, show both the role and the race */
@@ -89,6 +89,27 @@ lookat(x, y, buf, monbuf)
Strcat(buf, steedbuf);
}
#endif
/* When you see yourself normally, no explanation is appended
(even if you could also see yourself via other means).
Sensing self while blind or swallowed is treated as if it
were by normal vision (cf canseeself()). */
if ((Invisible || u.uundetected) && !Blind && !u.uswallow) {
unsigned how = 0;
if (Infravision) how |= 1;
if (Unblind_telepat) how |= 2;
if (Detect_monsters) how |= 4;
if (how)
Sprintf(eos(buf), " [seen: %s%s%s%s%s]",
(how & 1) ? "infravision" : "",
/* add comma if telep and infrav */
((how & 3) > 2) ? ", " : "",
(how & 2) ? "telepathy" : "",
/* add comma if detect and (infrav or telep or both) */
((how & 7) > 4) ? ", " : "",
(how & 4) ? "monster detection" : "");
}
} else if (u.uswallow) {
/* all locations when swallowed other than the hero are the monster */
Sprintf(buf, "interior of %s",