]> granicus.if.org Git - nethack/commitdiff
fix U88 - invisible hero didn't sense self via ESP
authornethack.rankin <nethack.rankin>
Fri, 4 Oct 2002 02:46:02 +0000 (02:46 +0000)
committernethack.rankin <nethack.rankin>
Fri, 4 Oct 2002 02:46:02 +0000 (02:46 +0000)
     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.

doc/fixes34.1
include/display.h
src/display.c
src/pager.c

index c7f2079ac95654611ac98ce2e9e5c25bb5a3813e..055724da044782f59f1ce6fb360ceaafc15a6a51 100644 (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
index 7b75597267f80f5f4146a1bc86cd2fff8f39563b..b94d308bf9864ccbafb0222a74d3f3739c771768 100644 (file)
 
 /*
  * canseeself()
+ * senseself()
  *
  * This returns true if the hero can see her/himself.
  *
  * 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()
  * _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,
index 6f0811db5279caba391b7e46483dc0731001bb1d..e2f1b5eef33e8f2a8a1dd204169988f7b0a65367 100644 (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);
        }
+    }
 }
 
 /*
index 41b5bdf0e33e306c5b57723df6962aaf9a8be8f0..1de81ad4cbe504ac6a5c69b2ffac01720439f010 100644 (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",