]> granicus.if.org Git - nethack/commitdiff
teleport feedback for STRAT_APPEARMSG mon
authorPatR <rankin@nethack.org>
Fri, 1 Jul 2022 22:53:53 +0000 (15:53 -0700)
committerPatR <rankin@nethack.org>
Fri, 1 Jul 2022 22:53:53 +0000 (15:53 -0700)
Reported by entrez:  if a monster with the STRAT_APPEARMSG flag is
seen to teleport away from its current position, an arrival message
would always be given too.  If you couldn't see that arrival, you'd
get nonsensical "It suddenly appears!".

Minor fix:  when a monster is seen to vanish at one spot and appear
at another, if it was not close you'd get either "appears closer to
you" or "appears farther from you" even if the new spot was the same
distance as the old spot.

doc/fixes3-7-0.txt
src/teleport.c

index 32223d94c2d55e196dd9e048fd8c0ee4eafb71f7..630ae1e6b315963e48b728f180db4b97705c9df9 100644 (file)
@@ -1280,6 +1280,8 @@ earlier fix for prices of unpaid objects going away in persistent inventory
        when inventory got updated to reflect transfer of hero's gold to shk
 save files created with SCORE_ON_BOTL disabled were erroneously being rejected
        if the program was rebuilt with it enabled and vice versa
+avoid "It suddenly appears!" if a monster with the STRAT_APPEARMSG attribute
+       is seen to teleport away then not seen at its destination
 
 curses: 'msg_window' option wasn't functional for curses unless the binary
        also included tty support
index 6ef02d1afd571d164a0936476640cf1d116f7d39..ac4c96510c58a9c08ba50c47a060ca2cb4294458 100644 (file)
@@ -1297,6 +1297,11 @@ rloc_to_core(
             } else {
                 pline("%s vanishes!", Monnam(mtmp));
             }
+            /* avoid "It suddenly appears!" for a STRAT_APPEARMSG monster
+               that has just teleported away if we won't see it after this
+               vanishing (the regular appears message will be given if we
+               do see it) */
+            appearmsg = FALSE;
         }
 
         if (mtmp->wormno) {
@@ -1327,22 +1332,25 @@ rloc_to_core(
     newsym(x, y);      /* update new location */
     set_apparxy(mtmp); /* orient monster */
     if (domsg && (canspotmon(mtmp) || appearmsg)) {
+        int du = distu(x, y), olddu;
+        const char *next = (du <= 2) ? " next to you" : 0, /* next2u() */
+                   *near = (du <= BOLT_LIM * BOLT_LIM) ? " close by" : 0;
+
         mtmp->mstrategy &= ~STRAT_APPEARMSG; /* one chance only */
         if (telemsg && (couldsee(x, y) || sensemon(mtmp))) {
             pline("%s vanishes and reappears%s.",
                   Monnam(mtmp),
-                  next2u(x, y) ? " next to you"
-                  : (distu(x, y) <= (BOLT_LIM * BOLT_LIM)) ? " close by"
-                    : (distu(x, y) < distu(oldx, oldy)) ? " closer to you"
-                      : " further away");
+                  next ? next
+                  : near ? near
+                    : ((olddu = distu(oldx, oldy)) == du) ? ""
+                      : (du < olddu) ? " closer to you"
+                        : " farther away");
         } else {
             pline("%s %s%s%s!",
                   appearmsg ? Amonnam(mtmp) : Monnam(mtmp),
                   appearmsg ? "suddenly " : "",
                   !Blind ? "appears" : "arrives",
-                  next2u(x, y) ? " next to you"
-                  : (distu(x, y) <= (BOLT_LIM * BOLT_LIM)) ? " close by"
-                    : "");
+                  next ? next : near ? near : "");
         }
     }