show trapped doors,chests as themselves \

instead of as fake bear traps

Use the new traps and their tiles when confused gold detection finds
trapped doors and trapped chests.  (Large boxes can be trapped too;
they use the trapped chest trap and corresponding tile rather than
have their own.)

Usually these pseudo-traps go away when as soon as they are within
line of sight.  (While testing, I noticed that seeing a trapped door
from outside its room rather than inside didn't behave that way.
The door was created by wizard mode wishing; I don't know whether
that was a factor.)

I also discovered that secret doors weren't being handled correctly.
They can't be trapped because of their use of both the doormask and
wall_info overlays of levl[][].flags, but I had a secret door be
falsely displayed as a trap.  This fixes that.

We should have obj->tknown and rm->D_TRAPKNOWN so that the hero won't
forget about these traps after declining to attempt to untrap them.
But that's more work than I care to tackle.
This commit is contained in:
PatR
2022-04-27 17:16:23 -07:00
parent 281d959b8b
commit 4ab68767bf
3 changed files with 56 additions and 23 deletions

View File

@@ -145,11 +145,10 @@ monhealthdescr(struct monst *mon, boolean addspace, char *outbuf)
static void
trap_description(char *outbuf, int tnum, int x, int y)
{
/* Trap detection displays a bear trap at locations having
* a trapped door or trapped container or both.
*
* TODO: we should create actual trap types for doors and
* chests so that they can have their own glyphs and tiles.
/*
* Trap detection used to display a bear trap at locations having
* a trapped door or trapped container or both. They're semi-real
* traps now (defined trap types but not part of ftrap chain).
*/
if (trapped_chest_at(tnum, x, y))
Strcpy(outbuf, "trapped chest"); /* might actually be a large box */
@@ -1908,9 +1907,14 @@ doidtrap(void)
x = u.ux + u.dx;
y = u.uy + u.dy;
/* check fake bear trap from confused gold detection */
/* trapped doors and chests used to be shown as fake bear traps;
they have their own trap types now but aren't part of the ftrap
chain; usually they revert to normal door or chest when the hero
sees them but player might be using '^' while the hero is blind */
glyph = glyph_at(x, y);
if (glyph_is_trap(glyph) && (tt = glyph_to_trap(glyph)) == BEAR_TRAP) {
if (glyph_is_trap(glyph)
&& ((tt = glyph_to_trap(glyph)) == BEAR_TRAP
|| tt == TRAPPED_DOOR || tt == TRAPPED_CHEST)) {
boolean chesttrap = trapped_chest_at(tt, x, y);
if (chesttrap || trapped_door_at(tt, x, y)) {