add glyphs+tiles for door+chest traps

When trap detection finds trapped doors and trapped chests, it shows
those as bear traps.  When the hero comes within view, they revert to
normal and the detected trap is forgotten.  This doesn't change that,
it is just groundwork to be able to show them distinctly.  Like the
TT_BEARTRAP patch, it increments EDITLEVEL so this seemed like a good
time to put the groudwork in place.

There shouldn't be any visible changes even though internal glyph and
tile values have been renumbered after inserting two new entries.
Adding traps after S_vibrating_square was quite a hassle and suffered
though a couple of off-by-one errors that weren't trivial to find and
fix.
This commit is contained in:
PatR
2022-04-27 11:22:12 -07:00
parent d194459c7d
commit d1217b9f25
13 changed files with 294 additions and 225 deletions

View File

@@ -913,8 +913,7 @@ getpos(coord *ccp, boolean force, const char *goal)
|| c == (int) g.showsyms[sidx]
/* have '^' match webs and vibrating square or any
other trap that uses something other than '^' */
|| (c == '^' && (is_cmap_trap(sidx)
|| sidx == S_vibrating_square)))
|| (c == '^' && is_cmap_trap(sidx)))
matching[sidx] = (char) ++k;
}
if (k) {

View File

@@ -572,6 +572,8 @@ static NEARDATA const char *trap_engravings[TRAPNUM] = {
/* 14..16: trap door, teleport, level-teleport */
"Vlad was here", "ad aerarium", "ad aerarium", (char *) 0, (char *) 0,
(char *) 0, (char *) 0, (char *) 0, (char *) 0, (char *) 0,
/* 24..25 */
(char *) 0, (char *) 0,
};
static void
@@ -1367,7 +1369,7 @@ mktrap(
if (tm && is_pool(tm->x, tm->y))
return;
if (num > 0 && num < TRAPNUM) {
if (num > NO_TRAP && num < TRAPNUM) {
kind = num;
} else if (Is_rogue_level(&u.uz)) {
switch (rn2(7)) {
@@ -1401,6 +1403,14 @@ mktrap(
kind = rnd(TRAPNUM - 1);
/* reject "too hard" traps */
switch (kind) {
/* these are controlled by the feature or object they guard,
not by the map so mustn't be created on it */
case TRAPPED_DOOR:
case TRAPPED_CHEST:
kind = NO_TRAP;
break;
/* these can have a random location but can't be generated
randomly */
case MAGIC_PORTAL:
case VIBRATING_SQUARE:
kind = NO_TRAP;

View File

@@ -21,7 +21,9 @@ static boolean m_balks_at_approaching(struct monst *);
static boolean stuff_prevents_passage(struct monst *);
static int vamp_shift(struct monst *, struct permonst *, boolean);
/* True if mtmp died */
/* monster has triggered trapped door lock or was present when it got
triggered remotely (at door spot, door hit by zap);
returns True if mtmp dies */
boolean
mb_trapped(struct monst *mtmp, boolean canseeit)
{
@@ -42,6 +44,7 @@ mb_trapped(struct monst *mtmp, boolean canseeit)
return TRUE;
/* will get here if lifesaved */
}
mtmp->mtrapseen |= (1 << (TRAPPED_DOOR - 1));
return FALSE;
}

View File

@@ -1035,7 +1035,7 @@ add_cmap_descr(
if (!found) {
/* this is the first match */
if (is_cmap_trap(idx)) {
if (is_cmap_trap(idx) && idx != S_vibrating_square) {
Sprintf(out_str, "%sa trap", prefix);
*hit_trap = TRUE;
} else {
@@ -1056,7 +1056,7 @@ add_cmap_descr(
found += append_str(out_str, (article == 2) ? the(x_str)
: (article == 1) ? an(x_str)
: x_str);
if (is_cmap_trap(idx))
if (is_cmap_trap(idx) && idx != S_vibrating_square)
*hit_trap = TRUE;
}
return found;

View File

@@ -380,6 +380,9 @@ maketrap(int x, int y, int typ)
struct trap *ttmp;
struct rm *lev = &levl[x][y];
if (typ == TRAPPED_DOOR || typ == TRAPPED_CHEST)
return (struct trap *) 0;
if ((ttmp = t_at(x, y)) != 0) {
if (undestroyable_trap(ttmp->ttyp))
return (struct trap *) 0;