Hero remembers trapped boxes

After finding a trap on a chest or a large box, remember it
as trapped: "You see here a trapped large box."
Randomly generated chests and boxes can be obviously trapped.
Allow defining obviously trapped containers via lua.

Invalidates saves and bones.
This commit is contained in:
Pasi Kallinen
2024-12-19 12:37:13 +02:00
parent 27a03ef75b
commit 87694e1a95
12 changed files with 75 additions and 36 deletions

View File

@@ -105,11 +105,12 @@ picklock(void)
: (gx.xlock.door->doormask & D_TRAPPED) != 0)
&& gx.xlock.magic_key) {
gx.xlock.chance += 20; /* less effort needed next time */
/* unfortunately we don't have a 'tknown' flag to record
"known to be trapped" so declining to disarm and then
retrying lock manipulation will find it all over again */
if (y_n("You find a trap! Do you want to try to disarm it?")
== 'y') {
if (!gx.xlock.door) {
if (!gx.xlock.box->tknown)
You("find a trap!");
gx.xlock.box->tknown = 1;
}
if (y_n("Do you want to try to disarm it?") == 'y') {
const char *what;
boolean alreadyunlocked;
@@ -120,6 +121,7 @@ picklock(void)
alreadyunlocked = !(gx.xlock.door->doormask & D_LOCKED);
} else {
gx.xlock.box->otrapped = 0;
gx.xlock.box->tknown = 0;
what = (gx.xlock.box->otyp == CHEST) ? "chest" : "box";
alreadyunlocked = !gx.xlock.box->olocked;
}