Monsters can track hero through fixed teleport traps

Also make fixed teleport traps always trigger when entered.
This commit is contained in:
Pasi Kallinen
2024-06-15 18:44:30 +03:00
parent 4e1b6411bf
commit 89ea47f702
6 changed files with 31 additions and 1 deletions
+1
View File
@@ -3144,6 +3144,7 @@ extern int tt_doppel(struct monst *) NONNULLARG1;
extern void initrack(void); extern void initrack(void);
extern void settrack(void); extern void settrack(void);
extern coord *gettrack(coordxy, coordxy); extern coord *gettrack(coordxy, coordxy);
extern boolean hastrack(coordxy, coordxy);
extern void save_track(NHFILE *) NONNULLARG1; extern void save_track(NHFILE *) NONNULLARG1;
extern void rest_track(NHFILE *) NONNULLARG1; extern void rest_track(NHFILE *) NONNULLARG1;
+2
View File
@@ -122,5 +122,7 @@ enum trap_immunities {
|| (ttyp) == POLY_TRAP) || (ttyp) == POLY_TRAP)
/* "transportation" traps */ /* "transportation" traps */
#define is_xport(ttyp) ((ttyp) >= TELEP_TRAP && (ttyp) <= MAGIC_PORTAL) #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 */ #endif /* TRAP_H */
+4 -1
View File
@@ -2316,7 +2316,10 @@ mfndpos(
ttmp->ttyp); ttmp->ttyp);
continue; 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 (!(flag & ALLOW_TRAPS)) {
if (mon_knows_traps(mon, ttmp->ttyp)) if (mon_knows_traps(mon, ttmp->ttyp))
continue; continue;
+1
View File
@@ -1456,6 +1456,7 @@ tele_trap(struct trap *trap)
coord cc; coord cc;
struct monst *mtmp = m_at(trap->teledest.x, trap->teledest.y); struct monst *mtmp = m_at(trap->teledest.x, trap->teledest.y);
settrack();
if (mtmp) { if (mtmp) {
if (!enexto(&cc, mtmp->mx, mtmp->my, mtmp->data)) { if (!enexto(&cc, mtmp->mx, mtmp->my, mtmp->data)) {
/* could not find some other place to put mtmp; the level must /* could not find some other place to put mtmp; the level must
+13
View File
@@ -52,6 +52,19 @@ gettrack(coordxy x, coordxy y)
return (coord *) 0; 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 */ /* save the hero tracking info */
void void
save_track(NHFILE *nhfp) save_track(NHFILE *nhfp)
+10
View File
@@ -2897,6 +2897,11 @@ dotrap(struct trap *trap, unsigned trflags)
nomul(0); nomul(0);
if (fixed_tele_trap(trap)) {
trflags |= FORCETRAP;
forcetrap = TRUE;
}
/* KMH -- You can't escape the Sokoban level traps */ /* KMH -- You can't escape the Sokoban level traps */
if (Sokoban && (is_pit(ttype) || is_hole(ttype))) { if (Sokoban && (is_pit(ttype) || is_hole(ttype))) {
/* The "air currents" message is still appropriate -- even when /* 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) boolean already_seen = (mon_knows_traps(mtmp, tt)
|| (tt == HOLE && !mindless(mptr))); || (tt == HOLE && !mindless(mptr)));
if (fixed_tele_trap(trap)) {
mintrapflags |= FORCETRAP;
forcetrap = TRUE;
}
if (mtmp == u.usteed) { if (mtmp == u.usteed) {
; /* true when called from dotrap, inescapable is not an option */ ; /* true when called from dotrap, inescapable is not an option */
} else if (Sokoban && (is_pit(tt) || is_hole(tt)) && !trap->madeby_u) { } else if (Sokoban && (is_pit(tt) || is_hole(tt)) && !trap->madeby_u) {