minor trapped container changes
When probing a trapped container, report that it is trapped. Done with a one-line message in the zap code and also in the title of the contents display if it isn't empty. For wizard mode wishing, if both "trapped" and "broken" are specified, produce an untrapped container with a broken lock. Also for wizard mode wishing, ignore "trapped" if player wishes for "trapped secret door".
This commit is contained in:
72
src/invent.c
72
src/invent.c
@@ -1,4 +1,4 @@
|
||||
/* NetHack 3.7 invent.c $NHDT-Date: 1650875487 2022/04/25 08:31:27 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.385 $ */
|
||||
/* NetHack 3.7 invent.c $NHDT-Date: 1651868822 2022/05/06 20:27:02 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.386 $ */
|
||||
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
||||
/*-Copyright (c) Derek S. Ray, 2015. */
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
@@ -17,6 +17,8 @@ static struct obj *addinv_core0(struct obj *, struct obj *, boolean);
|
||||
static void noarmor(boolean);
|
||||
static void invdisp_nothing(const char *, const char *);
|
||||
static boolean worn_wield_only(struct obj *);
|
||||
static char *cinv_doname(struct obj *);
|
||||
static char *cinv_ansimpleoname(struct obj *);
|
||||
static boolean only_here(struct obj *);
|
||||
static void compactify(char *);
|
||||
static boolean taking_off(const char *);
|
||||
@@ -5169,10 +5171,63 @@ display_minventory(struct monst *mon, int dflags, char *title)
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
* Display the contents of a container in inventory style.
|
||||
* Currently, this is only used for statues, via wand of probing.
|
||||
*/
|
||||
/* format a container name for cinventory_display(), inserting "trapped"
|
||||
if that's appropriate */
|
||||
static char *
|
||||
cinv_doname(struct obj *obj)
|
||||
{
|
||||
char *result = doname(obj);
|
||||
|
||||
/*
|
||||
* If obj->tknown ever gets implemented, doname() will handle this.
|
||||
* Assumes that probing reveals the trap prior to calling us. Since
|
||||
* we lack that flag, hero forgets about it as soon as we're done....
|
||||
*/
|
||||
|
||||
/* 'result' is an obuf[] but might point into the middle (&buf[PREFIX])
|
||||
rather than the beginning and we don't have access to that;
|
||||
assume that there is at least QBUFSZ available when reusing it */
|
||||
if (obj->otrapped && strlen(result) + sizeof "trapped " <= QBUFSZ) {
|
||||
/* obj->lknown has been set before calling us so either "locked" or
|
||||
"unlocked" should always be present (for a trapped container) */
|
||||
char *p = strstri(result, " locked"),
|
||||
*q = strstri(result, " unlocked");
|
||||
|
||||
if (p && (!q || p < q))
|
||||
(void) strsubst(p, " locked ", " trapped locked ");
|
||||
else if (q)
|
||||
(void) strsubst(q, " unlocked ", " trapped unlocked ");
|
||||
/* might need to change "an" to "a"; when no BUC is present,
|
||||
"an unlocked" yielded "an trapped unlocked" above */
|
||||
(void) strsubst(result, "an trapped ", "a trapped ");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/* used by safe_qbuf() if the full doname() result is too long */
|
||||
static char *
|
||||
cinv_ansimpleoname(struct obj *obj)
|
||||
{
|
||||
char *result = ansimpleoname(obj);
|
||||
|
||||
/* result is an obuf[] so we know this will always fit */
|
||||
if (obj->otrapped) {
|
||||
if (strncmp(result, "a ", 2))
|
||||
(void) strsubst(result, "a ", "a trapped ");
|
||||
else if (strncmp(result, "an ", 3))
|
||||
(void) strsubst(result, "an ", "an trapped ");
|
||||
/* unique container? nethack doesn't have any */
|
||||
else if (strncmp(result, "the ", 4))
|
||||
(void) strsubst(result, "the ", "the trapped ");
|
||||
/* no leading article at all? shouldn't happen with ansimpleoname() */
|
||||
else
|
||||
(void) strsubst(result, "", "trapped "); /* insert at beginning */
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/* Display the contents of a container in inventory style.
|
||||
Used for wand of probing of non-empty containers and statues. */
|
||||
struct obj *
|
||||
display_cinventory(struct obj *obj)
|
||||
{
|
||||
@@ -5181,8 +5236,11 @@ display_cinventory(struct obj *obj)
|
||||
int n;
|
||||
menu_item *selected = 0;
|
||||
|
||||
(void) safe_qbuf(qbuf, "Contents of ", ":", obj, doname, ansimpleoname,
|
||||
"that");
|
||||
(void) safe_qbuf(qbuf, "Contents of ", ":", obj,
|
||||
/* custom formatting routines to insert "trapped"
|
||||
into the object's name when appropriate;
|
||||
last resort "that" won't ever get used */
|
||||
cinv_doname, cinv_ansimpleoname, "that");
|
||||
|
||||
if (obj->cobj) {
|
||||
n = query_objlist(qbuf, &(obj->cobj), INVORDER_SORT,
|
||||
|
||||
15
src/objnam.c
15
src/objnam.c
@@ -1,4 +1,4 @@
|
||||
/* NetHack 3.7 objnam.c $NHDT-Date: 1649529937 2022/04/09 18:45:37 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.359 $ */
|
||||
/* NetHack 3.7 objnam.c $NHDT-Date: 1651868823 2022/05/06 20:27:03 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.360 $ */
|
||||
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
||||
/*-Copyright (c) Robert Patrick Rankin, 2011. */
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
@@ -3370,14 +3370,15 @@ wizterrainwish(struct _readobjnam_data *d)
|
||||
lev->wall_info |= (old_wall_info & WM_MASK);
|
||||
/* set up trapped flag; open door states aren't eligible */
|
||||
if (d->trapped == 2 /* 2: wish includes explicit "untrapped" */
|
||||
|| (!secret && ((lev->doormask & (D_LOCKED | D_CLOSED)) == 0)))
|
||||
|| secret /* secret doors can't trapped due to their use
|
||||
* of both doormask and wall_info; those both
|
||||
* overlay rm->flags and partially conflict */
|
||||
|| (lev->doormask & (D_LOCKED | D_CLOSED)) == 0)
|
||||
d->trapped = 0;
|
||||
if (d->trapped)
|
||||
lev->doormask |= D_TRAPPED;
|
||||
/* feedback */
|
||||
dbuf[0] = '\0';
|
||||
/* locked state and trapped flag can augment secret doors; other
|
||||
states apply to normal doors only (see above about 'closed') */
|
||||
if (lev->doormask & D_TRAPPED)
|
||||
Strcat(dbuf, "trapped ");
|
||||
if (lev->doormask & D_LOCKED)
|
||||
@@ -3593,13 +3594,15 @@ readobjnam_preparse(struct _readobjnam_data *d)
|
||||
d->unlabeled = 1;
|
||||
} else if (!strncmpi(d->bp, "poisoned ", l = 9)) {
|
||||
d->ispoisoned = 1;
|
||||
/* "trapped" recognized but not honored outside wizard mode */
|
||||
|
||||
/* "trapped" recognized but not honored outside wizard mode */
|
||||
} else if (!strncmpi(d->bp, "trapped ", l = 8)) {
|
||||
d->trapped = 0; /* undo any previous "untrapped" */
|
||||
if (wizard)
|
||||
d->trapped = 1;
|
||||
} else if (!strncmpi(d->bp, "untrapped ", l = 10)) {
|
||||
d->trapped = 2; /* not trapped */
|
||||
|
||||
/* locked, unlocked, broken: box/chest lock states, also door states;
|
||||
open, closed, doorless: additional door states */
|
||||
} else if (!strncmpi(d->bp, "locked ", l = 7)) {
|
||||
@@ -4841,6 +4844,8 @@ readobjnam(char *bp, struct obj *no_wish)
|
||||
} else if (d.broken) {
|
||||
d.otmp->olocked = 0, d.otmp->obroken = 1;
|
||||
}
|
||||
if (d.otmp->obroken)
|
||||
d.otmp->otrapped = 0;
|
||||
}
|
||||
|
||||
if (d.isgreased)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* NetHack 3.7 zap.c $NHDT-Date: 1650838839 2022/04/24 22:20:39 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.408 $ */
|
||||
/* NetHack 3.7 zap.c $NHDT-Date: 1651868824 2022/05/06 20:27:04 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.410 $ */
|
||||
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
||||
/*-Copyright (c) Robert Patrick Rankin, 2013. */
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
@@ -2066,6 +2066,11 @@ 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 (!obj->cobj) {
|
||||
pline("%s empty.", Tobjnam(obj, "are"));
|
||||
} else if (SchroedingersBox(obj)) {
|
||||
|
||||
Reference in New Issue
Block a user