From cfca15d02c778540e06f0f51aff0b358d6c55786 Mon Sep 17 00:00:00 2001 From: PatR Date: Mon, 8 Jul 2019 16:57:52 -0700 Subject: [PATCH 1/2] finding hidden monsters Wizard mode ^E and any mode spell of detect unseen or wand of secret door detection failed to find mon->mundetected monsters if they were hiding under objects, and failed to find those or other hiders or mimics when the hidden monster was at a trap location. The fix for the latter initially only worked if the trap was known, so took two tries when a monster hid at the location of an unseen trap. So this makes the additional change to find both things at the same time; it isn't manual searching that stops as soon as something is found. --- doc/fixes36.3 | 4 +++- src/detect.c | 56 ++++++++++++++++++++++++++++++++++----------------- 2 files changed, 40 insertions(+), 20 deletions(-) diff --git a/doc/fixes36.3 b/doc/fixes36.3 index 904db232c..c40383917 100644 --- a/doc/fixes36.3 +++ b/doc/fixes36.3 @@ -1,4 +1,4 @@ -$NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.87 $ $NHDT-Date: 1562532730 2019/07/07 20:52:10 $ +$NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.88 $ $NHDT-Date: 1562630265 2019/07/08 23:57:45 $ This fixes36.3 file is here to capture information about updates in the 3.6.x lineage following the release of 3.6.2 in May 2019. Please note, however, @@ -99,6 +99,8 @@ if an engulfer has any worn items, hero could pick them up from inside and worse (Juiblex will wear an amulet if created with one; a shapechanger might wear one and then turn into an engulfer) kicking an altar ignored god's wrath if hero injured himself during the kick +detect unseen/secret door detection/^E failed to find monsters hiding under + objects and failed to find monsters hiding at trap locations Fixes to Post-3.6.2 Problems that Were Exposed Via git Repository diff --git a/src/detect.c b/src/detect.c index 45271687d..e7da0f85a 100644 --- a/src/detect.c +++ b/src/detect.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 detect.c $NHDT-Date: 1544437284 2018/12/10 10:21:24 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.91 $ */ +/* NetHack 3.6 detect.c $NHDT-Date: 1562630266 2019/07/08 23:57:46 $ $NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.96 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /*-Copyright (c) Robert Patrick Rankin, 2018. */ /* NetHack may be freely redistributed. See license for details. */ @@ -381,7 +381,7 @@ register struct obj *sobj; You("notice some gold between your %s.", makeplural(body_part(FOOT))); return 0; -outgoldmap: + outgoldmap: cls(); (void) unconstrain_map(); @@ -995,7 +995,7 @@ struct obj *sobj; /* null if crystal ball, *scroll if gold detection scroll */ Your("%s itch.", makeplural(body_part(TOE))); return 0; -outtrapmap: + outtrapmap: cls(); (void) unconstrain_map(); @@ -1443,6 +1443,8 @@ struct rm *lev; lev->doormask = newmask; } +/* find something at one location; it should find all somethings there + since it is used for magical detection rather than physical searching */ STATIC_PTR void findone(zx, zy, num) int zx, zy; @@ -1451,6 +1453,13 @@ genericptr_t num; register struct trap *ttmp; register struct monst *mtmp; + /* + * This used to use if/else-if/else-if/else/end-if but that only + * found the first hidden thing at the location. Two hidden things + * at the same spot is uncommon, but it's possible for an undetected + * monster to be hiding at the location of an unseen trap. + */ + if (levl[zx][zy].typ == SDOOR) { cvt_sdoor_to_door(&levl[zx][zy]); /* .typ = DOOR */ magic_map_background(zx, zy, 0); @@ -1462,19 +1471,25 @@ genericptr_t num; magic_map_background(zx, zy, 0); newsym(zx, zy); (*(int *) num)++; - } else if ((ttmp = t_at(zx, zy)) != 0) { - if (!ttmp->tseen && ttmp->ttyp != STATUE_TRAP) { - ttmp->tseen = 1; - newsym(zx, zy); - (*(int *) num)++; - } - } else if ((mtmp = m_at(zx, zy)) != 0) { + } + + if ((ttmp = t_at(zx, zy)) != 0 && !ttmp->tseen + /* [shouldn't successful 'find' reveal and activate statue traps?] */ + && ttmp->ttyp != STATUE_TRAP) { + ttmp->tseen = 1; + newsym(zx, zy); + (*(int *) num)++; + } + + if ((mtmp = m_at(zx, zy)) != 0 + /* brings hidden monster out of hiding even if already sensed */ + && (!canspotmon(mtmp) || mtmp->mundetected || M_AP_TYPE(mtmp))) { if (M_AP_TYPE(mtmp)) { seemimic(mtmp); (*(int *) num)++; - } - if (mtmp->mundetected - && (is_hider(mtmp->data) || mtmp->data->mlet == S_EEL)) { + } else if (mtmp->mundetected && (is_hider(mtmp->data) + || hides_under(mtmp->data) + || mtmp->data->mlet == S_EEL)) { mtmp->mundetected = 0; newsym(zx, zy); (*(int *) num)++; @@ -1602,8 +1617,7 @@ struct trap *trap; /* The "Hallucination ||" is to preserve 3.6.1 behaviour, but this behaviour might need a rework in the hallucination case - (e.g. to not prompt if any trap glyph appears on the - square). */ + (e.g. to not prompt if any trap glyph appears on the square). */ if (Hallucination || levl[trap->tx][trap->ty].glyph != trap_to_glyph(trap, rn2_on_display_rng)) { @@ -1636,18 +1650,22 @@ boolean via_warning; if (M_AP_TYPE(mtmp)) { seemimic(mtmp); found_something = TRUE; - } else if (!canspotmon(mtmp)) { - if (mtmp->mundetected - && (is_hider(mtmp->data) || mtmp->data->mlet == S_EEL)) { + } else { + /* this used to only be executed if a !canspotmon() test passed + but that failed to bring sensed monsters out of hiding */ + found_something = !canspotmon(mtmp); + if (mtmp->mundetected && (is_hider(mtmp->data) + || hides_under(mtmp->data) + || mtmp->data->mlet == S_EEL)) { if (via_warning) { Your("warning senses cause you to take a second %s.", Blind ? "to check nearby" : "look close by"); display_nhwindow(WIN_MESSAGE, FALSE); /* flush messages */ } mtmp->mundetected = 0; + found_something = TRUE; } newsym(x, y); - found_something = TRUE; } if (found_something) { From 77aa61a59bb2a1180767412a82a6c1399df7fe8d Mon Sep 17 00:00:00 2001 From: PatR Date: Mon, 8 Jul 2019 17:38:00 -0700 Subject: [PATCH 2/2] looking at a trapped monster would describe it as trapped if you could see its location, but if the trap was unseen that trap would remain unseen, at least in some circumstances. Mark the trap as seen. --- doc/fixes36.3 | 3 ++- src/pager.c | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/doc/fixes36.3 b/doc/fixes36.3 index c40383917..b7f2c43bb 100644 --- a/doc/fixes36.3 +++ b/doc/fixes36.3 @@ -1,4 +1,4 @@ -$NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.88 $ $NHDT-Date: 1562630265 2019/07/08 23:57:45 $ +$NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.89 $ $NHDT-Date: 1562632673 2019/07/09 00:37:53 $ This fixes36.3 file is here to capture information about updates in the 3.6.x lineage following the release of 3.6.2 in May 2019. Please note, however, @@ -101,6 +101,7 @@ if an engulfer has any worn items, hero could pick them up from inside and kicking an altar ignored god's wrath if hero injured himself during the kick detect unseen/secret door detection/^E failed to find monsters hiding under objects and failed to find monsters hiding at trap locations +when farlook describes a monster at a visible spot as trapped, reveal the trap Fixes to Post-3.6.2 Problems that Were Exposed Via git Repository diff --git a/src/pager.c b/src/pager.c index ce1aae41b..02c61f966 100644 --- a/src/pager.c +++ b/src/pager.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 pager.c $NHDT-Date: 1558045586 2019/05/16 22:26:26 $ $NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.153 $ */ +/* NetHack 3.6 pager.c $NHDT-Date: 1562632673 2019/07/09 00:37:53 $ $NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.154 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /*-Copyright (c) Robert Patrick Rankin, 2018. */ /* NetHack may be freely redistributed. See license for details. */ @@ -297,9 +297,11 @@ int x, y; int tt = t ? t->ttyp : NO_TRAP; /* newsym lets you know of the trap, so mention it here */ - if (tt == BEAR_TRAP || is_pit(tt) || tt == WEB) + if (tt == BEAR_TRAP || is_pit(tt) || tt == WEB) { Sprintf(eos(buf), ", trapped in %s", an(defsyms[trap_to_defsym(tt)].explanation)); + t->tseen = 1; + } } /* we know the hero sees a monster at this location, but if it's shown