From f545ca8f223b96ea25fa5c6b638e8391774946df Mon Sep 17 00:00:00 2001 From: PatR Date: Sun, 7 Apr 2024 16:56:02 -0700 Subject: [PATCH] fix #K4138 - untrapping a monster while blind If a tame or peaceful monster was trapped and blind hero hadn't seen the trap yet, attempting to swap places would report that the monster couldn't "move out of that trap". And if the 'tips' option was True, the game would suggest attempting #untrap. But #untrap would report that the hero wasn't aware of any trap at the spot, and fail. Change the original message to "move out of that " and if hero hasn't seen it yet, map it and vary the wording slightly "... a|an ". If #untrap is attempted, it will now be dealing with a known trap. --- doc/fixes3-7-0.txt | 4 ++++ src/hack.c | 22 +++++++++++++++++----- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/doc/fixes3-7-0.txt b/doc/fixes3-7-0.txt index bdfea04d6..2e77d74cb 100644 --- a/doc/fixes3-7-0.txt +++ b/doc/fixes3-7-0.txt @@ -1921,6 +1921,10 @@ end-of-game attribute disclosure in wizard mode reported incorrect text for for apron/alchemy smock's conferral of poison+acid resistances (3.6.x was susceptible to this for T-shirt text but since T-shirts don't confer any attributes, it wasn't noticeable) +if a tame or peaceful monster was trapped and blind hero hadn't seen the trap + yet, attempting to swap places would report "You stop. can't + move out of that trap." and if the 'tips' option was On, #untrap would + be suggested; but #untrap would fail due "you know of no traps there" Fixes to 3.7.0-x Platform and/or Interface Problems Exposed Via git Repository diff --git a/src/hack.c b/src/hack.c index 59d126055..0930cdf3a 100644 --- a/src/hack.c +++ b/src/hack.c @@ -1763,6 +1763,7 @@ handle_tip(int tip) break; default: impossible("Unknown tip in handle_tip(%i)", tip); + break; } } } @@ -1997,8 +1998,11 @@ domove_swap_with_pet(struct monst *mtmp, coordxy x, coordxy y) seemimic(mtmp); u.ux = mtmp->mx, u.uy = mtmp->my; /* resume swapping positions */ - if (mtmp->mtrapped && (trap = t_at(mtmp->mx, mtmp->my)) != 0 - && is_pit(trap->ttyp) + trap = mtmp->mtrapped ? t_at(mtmp->mx, mtmp->my) : 0; + if (!trap) + mtmp->mtrapped = 0; + + if (mtmp->mtrapped && is_pit(trap->ttyp) && sobj_at(BOULDER, trap->tx, trap->ty)) { /* can't swap places with pet pinned in a pit by a boulder */ didnt_move = TRUE; @@ -2021,8 +2025,16 @@ domove_swap_with_pet(struct monst *mtmp, coordxy x, coordxy y) didnt_move = TRUE; } else if (mtmp->mpeaceful && mtmp->mtrapped) { /* all mtame are also mpeaceful, so this affects pets too */ - You("stop. %s can't move out of that trap.", - upstart(y_monnam(mtmp))); + assert(trap != NULL); /* implied by mtrapped */ + const char *what = trapname(trap->ttyp, FALSE), *which = "that "; + char anbuf[10]; + + if (!trap->tseen) { + feeltrap(trap); /* show on map once mtmp is out of the way */ + which = just_an(anbuf, what); /* "a " or "an " */ + } + You("stop. %s can't move out of %s%s.", + upstart(y_monnam(mtmp)), which, what); handle_tip(TIP_UNTRAP_MON); didnt_move = TRUE; } else if (mtmp->mpeaceful @@ -2030,7 +2042,7 @@ domove_swap_with_pet(struct monst *mtmp, coordxy x, coordxy y) || t_at(u.ux0, u.uy0) != NULL || mundisplaceable(mtmp))) { /* displacing peaceful into unsafe or trapped space, or trying to - * displace quest leader, Oracle, shopkeeper, or priest */ + displace quest leader, Oracle, shopkeeper, priest, or vault guard */ You("stop. %s doesn't want to swap places.", upstart(y_monnam(mtmp))); didnt_move = TRUE;