trapped box->tknown

If 'autounlock' is set to test a chest for traps, skip "check for
traps?" when tknown is set; go directly to "disarm trap?" if the
chest is trapped, skip that too if it isn't.

If wand of probing hits a chest, set the tknown bit.
This commit is contained in:
PatR
2025-03-12 01:28:05 -07:00
parent 8f84f76f09
commit 31d86a8c41
2 changed files with 12 additions and 15 deletions

View File

@@ -1,4 +1,4 @@
/* NetHack 3.7 lock.c $NHDT-Date: 1718745135 2024/06/18 21:12:15 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.137 $ */
/* NetHack 3.7 lock.c $NHDT-Date: 1741793439 2025/03/12 07:30:39 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.145 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Robert Patrick Rankin, 2011. */
/* NetHack may be freely redistributed. See license for details. */
@@ -432,14 +432,6 @@ pick_lock(
boolean it;
int count;
/*
* FIXME:
* (chest->otrapped && chest->tknown) is handled, to skip
* checking for a trap and continue with asking about disarm;
* (chest->tknown && !chest->otrapped) ignores tknown and will
* ask about checking for non-existant trap.
*/
if (u.dz < 0 && !autounlock) { /* beware stale u.dz value */
There("isn't any sort of lock up %s.",
Levitation ? "here" : "there");
@@ -478,7 +470,8 @@ pick_lock(
if (autounlock && (flags.autounlock & AUTOUNLOCK_UNTRAP) != 0
&& could_untrap(FALSE, TRUE)
&& (c = ynq(safe_qbuf(qbuf, "Check ", " for a trap?",
&& (c = otmp->tknown ? (otmp->otrapped ? 'y' : 'n')
: ynq(safe_qbuf(qbuf, "Check ", " for a trap?",
otmp, yname, ysimple_name, "this")))
!= 'n') {
if (c == 'q')

View File

@@ -1,4 +1,4 @@
/* NetHack 3.7 zap.c $NHDT-Date: 1737344505 2025/01/19 19:41:45 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.562 $ */
/* NetHack 3.7 zap.c $NHDT-Date: 1741793439 2025/03/12 07:30:39 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.564 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Robert Patrick Rankin, 2013. */
/* NetHack may be freely redistributed. See license for details. */
@@ -2209,10 +2209,14 @@ bhito(struct obj *obj, struct obj *otmp)
obj->dknown = 1;
if (Is_container(obj) || obj->otyp == STATUE) {
obj->cknown = obj->lknown = 1;
/* plural handling here is superfluous because containers
and statues don't stack */
if (obj->otrapped)
pline("%s trapped!", Tobjnam(obj, "are"));
if (Is_box(obj) && !obj->tknown) {
/* obj->tknown applies to boxes and chests, not bags or
statues; plural handling here and the "empty" case
below are superfluous because containers don't stack */
if (obj->otrapped)
pline("%s trapped!", Tobjnam(obj, "are"));
obj->tknown = 1;
}
if (!obj->cobj) {
pline("%s empty.", Tobjnam(obj, "are"));