From: PatR Date: Fri, 1 Jul 2022 22:53:53 +0000 (-0700) Subject: teleport feedback for STRAT_APPEARMSG mon X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=0bd5b3d39eb3f65046a72fce015c4d427004b8d2;p=nethack teleport feedback for STRAT_APPEARMSG mon 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. --- diff --git a/doc/fixes3-7-0.txt b/doc/fixes3-7-0.txt index 32223d94c..630ae1e6b 100644 --- a/doc/fixes3-7-0.txt +++ b/doc/fixes3-7-0.txt @@ -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 diff --git a/src/teleport.c b/src/teleport.c index 6ef02d1af..ac4c96510 100644 --- a/src/teleport.c +++ b/src/teleport.c @@ -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 : ""); } }