From 89ea47f702af5abed19c8bf1826b866048772b74 Mon Sep 17 00:00:00 2001 From: Pasi Kallinen Date: Sat, 15 Jun 2024 18:44:25 +0300 Subject: [PATCH] Monsters can track hero through fixed teleport traps Also make fixed teleport traps always trigger when entered. --- include/extern.h | 1 + include/trap.h | 2 ++ src/mon.c | 5 ++++- src/teleport.c | 1 + src/track.c | 13 +++++++++++++ src/trap.c | 10 ++++++++++ 6 files changed, 31 insertions(+), 1 deletion(-) diff --git a/include/extern.h b/include/extern.h index b746f6d6b..5391be599 100644 --- a/include/extern.h +++ b/include/extern.h @@ -3144,6 +3144,7 @@ extern int tt_doppel(struct monst *) NONNULLARG1; extern void initrack(void); extern void settrack(void); extern coord *gettrack(coordxy, coordxy); +extern boolean hastrack(coordxy, coordxy); extern void save_track(NHFILE *) NONNULLARG1; extern void rest_track(NHFILE *) NONNULLARG1; diff --git a/include/trap.h b/include/trap.h index abfb0833f..0d786b550 100644 --- a/include/trap.h +++ b/include/trap.h @@ -122,5 +122,7 @@ enum trap_immunities { || (ttyp) == POLY_TRAP) /* "transportation" traps */ #define is_xport(ttyp) ((ttyp) >= TELEP_TRAP && (ttyp) <= MAGIC_PORTAL) +#define fixed_tele_trap(t) ((t)->ttyp == TELEP_TRAP \ + && isok((t)->teledest.x,(t)->teledest.x)) #endif /* TRAP_H */ diff --git a/src/mon.c b/src/mon.c index 8ccc581a8..a436dc897 100644 --- a/src/mon.c +++ b/src/mon.c @@ -2316,7 +2316,10 @@ mfndpos( ttmp->ttyp); continue; } - if (!m_harmless_trap(mon, ttmp)) { + /* fixed-destination teleport trap, was used by hero */ + if (fixed_tele_trap(ttmp) && hastrack(nx, ny)) + info[cnt] |= ALLOW_TRAPS; + else if (!m_harmless_trap(mon, ttmp)) { if (!(flag & ALLOW_TRAPS)) { if (mon_knows_traps(mon, ttmp->ttyp)) continue; diff --git a/src/teleport.c b/src/teleport.c index e50fb79aa..51fb281e7 100644 --- a/src/teleport.c +++ b/src/teleport.c @@ -1456,6 +1456,7 @@ tele_trap(struct trap *trap) coord cc; struct monst *mtmp = m_at(trap->teledest.x, trap->teledest.y); + settrack(); if (mtmp) { if (!enexto(&cc, mtmp->mx, mtmp->my, mtmp->data)) { /* could not find some other place to put mtmp; the level must diff --git a/src/track.c b/src/track.c index a04855c63..92a172a3b 100644 --- a/src/track.c +++ b/src/track.c @@ -52,6 +52,19 @@ gettrack(coordxy x, coordxy y) return (coord *) 0; } +/* return TRUE if x,y has hero tracks on it */ +boolean +hastrack(coordxy x, coordxy y) +{ + int i; + + for (i = 0; i < utcnt; i++) + if (utrack[i].x == x && utrack[i].y == y) + return TRUE; + + return FALSE; +} + /* save the hero tracking info */ void save_track(NHFILE *nhfp) diff --git a/src/trap.c b/src/trap.c index ab99adf5e..301d686ae 100644 --- a/src/trap.c +++ b/src/trap.c @@ -2897,6 +2897,11 @@ dotrap(struct trap *trap, unsigned trflags) nomul(0); + if (fixed_tele_trap(trap)) { + trflags |= FORCETRAP; + forcetrap = TRUE; + } + /* KMH -- You can't escape the Sokoban level traps */ if (Sokoban && (is_pit(ttype) || is_hole(ttype))) { /* The "air currents" message is still appropriate -- even when @@ -3654,6 +3659,11 @@ mintrap(struct monst *mtmp, unsigned mintrapflags) boolean already_seen = (mon_knows_traps(mtmp, tt) || (tt == HOLE && !mindless(mptr))); + if (fixed_tele_trap(trap)) { + mintrapflags |= FORCETRAP; + forcetrap = TRUE; + } + if (mtmp == u.usteed) { ; /* true when called from dotrap, inescapable is not an option */ } else if (Sokoban && (is_pit(tt) || is_hole(tt)) && !trap->madeby_u) {