From f6a5236beb91912aad169d23818c8aa13c848c16 Mon Sep 17 00:00:00 2001 From: nhmall Date: Fri, 20 Dec 2024 15:30:37 -0500 Subject: [PATCH] follow-up to #1343 fix for telepathic hero telepathic hero can discern which particular monster just read a scroll, even though he cannot see the monster --- doc/fixes3-7-0.txt | 1 + include/extern.h | 1 + src/mon.c | 14 ++++++++++++++ src/muse.c | 18 ++++++++++++------ src/read.c | 12 ++---------- 5 files changed, 30 insertions(+), 16 deletions(-) diff --git a/doc/fixes3-7-0.txt b/doc/fixes3-7-0.txt index ab2e93f20..a9de275c9 100644 --- a/doc/fixes3-7-0.txt +++ b/doc/fixes3-7-0.txt @@ -2751,6 +2751,7 @@ tourists gain experience by seeing new types of creatures up close, and healers gain experience by healing pets blessed scroll of destroy armor asks which armor to destroy archeologists' fedora is lucky +telepathic hero can discern which particular monster just read a scroll Platform- and/or Interface-Specific New Features diff --git a/include/extern.h b/include/extern.h index 2b8bba295..35bb33138 100644 --- a/include/extern.h +++ b/include/extern.h @@ -1785,6 +1785,7 @@ extern void adj_erinys(unsigned); extern void see_monster_closeup(struct monst *) NONNULLARG1; extern void see_nearby_monsters(void); extern void shieldeff_mon(struct monst *) NONNULLARG1; +extern void flash_mon(struct monst *) NONNULLARG1; /* ### mondata.c ### */ diff --git a/src/mon.c b/src/mon.c index cda5f4b65..93aad677a 100644 --- a/src/mon.c +++ b/src/mon.c @@ -5848,4 +5848,18 @@ shieldeff_mon(struct monst *mtmp) pline_mon(mtmp, "%s resists!", Monnam(mtmp)); } +void +flash_mon(struct monst *mtmp) +{ + coordxy mx = mtmp->mx, my = mtmp->my; + int count = couldsee(mx, my) ? 8 : 4; + char saveviz = gv.viz_array[my][mx]; + + if (!flags.sparkle) + count /= 2; + gv.viz_array[my][mx] |= (IN_SIGHT | COULD_SEE); + flash_glyph_at(mx, my, mon_to_glyph(mtmp, newsym_rn2), count); + gv.viz_array[my][mx] = saveviz; + newsym(mx, my); +} /*mon.c*/ diff --git a/src/muse.c b/src/muse.c index f42a98f97..865ae5d05 100644 --- a/src/muse.c +++ b/src/muse.c @@ -236,7 +236,8 @@ staticfn void mreadmsg(struct monst *mtmp, struct obj *otmp) { char onambuf[BUFSZ]; - boolean vismon = canseemon(mtmp); + boolean vismon = canseemon(mtmp), + tpindicator = (!vismon && sensemon(mtmp)); if (!vismon && Deaf) return; /* no feedback */ @@ -262,12 +263,15 @@ mreadmsg(struct monst *mtmp, struct obj *otmp) int mflags = (SUPPRESS_INVISIBLE | SUPPRESS_SADDLE | (recognize ? SUPPRESS_IT : AUGMENT_IT)); - /* monster can't be seen; hero might be blind or monster might - be at a spot that isn't in view or might be invisible; remember - it if the spot is within line of sight and relatively close */ - if (!sensemon(mtmp) - && couldsee(mtmp->mx, mtmp->my) && mdistu(mtmp) <= 10 * 10) + if (sensemon(mtmp)) { + tpindicator = TRUE; + } else if (couldsee(mtmp->mx, mtmp->my) && mdistu(mtmp) <= 10 * 10) { + /* monster can't be seen or sensed; hero might be blind or monster + might be at a spot that isn't in view or might be invisible; + remember it if the spot is within line of sight and relatively + close */ map_invisible(mtmp->mx, mtmp->my); + } Snprintf(blindbuf, sizeof blindbuf, "reading %s", onambuf); strsubst(blindbuf, "reading a scroll labeled", @@ -275,6 +279,8 @@ mreadmsg(struct monst *mtmp, struct obj *otmp) You_hear("%s %s.", x_monnam(mtmp, ARTICLE_A, (char *) 0, mflags, FALSE), blindbuf); + if (tpindicator) + flash_mon(mtmp); } if (mtmp->mconf) /* (note: won't get if not seen and hero can't hear) */ pline("Being confused, %s mispronounces the magic words...", diff --git a/src/read.c b/src/read.c index b3c265d38..47c4d2594 100644 --- a/src/read.c +++ b/src/read.c @@ -3248,17 +3248,9 @@ create_particular_creation( /* if asking for 'hidden', show location of every created monster that can't be seen--whether that's due to successfully hiding or vision issues (line-of-sight, invisibility, blindness) */ - if ((d->hidden || d->invisible) && !canspotmon(mtmp)) { - int count = couldsee(mx, my) ? 8 : 4; - char saveviz = gv.viz_array[my][mx]; + if ((d->hidden || d->invisible) && !canspotmon(mtmp)) + flash_mon(mtmp); - if (!flags.sparkle) - count /= 2; - gv.viz_array[my][mx] |= (IN_SIGHT | COULD_SEE); - flash_glyph_at(mx, my, mon_to_glyph(mtmp, newsym_rn2), count); - gv.viz_array[my][mx] = saveviz; - newsym(mx, my); - } madeany = TRUE; /* in case we got a doppelganger instead of what was asked for, make it start out looking like what was asked for */