diff --git a/doc/fixes3-7-0.txt b/doc/fixes3-7-0.txt index 4c596004c..afdeb9996 100644 --- a/doc/fixes3-7-0.txt +++ b/doc/fixes3-7-0.txt @@ -1013,6 +1013,7 @@ when breaking a wand of sleep hits the hero with the explosion, don't describe that as "the sleep ray hits you" expose fuz tester to wizard-mode as #fuzzer extended command monsters which cannot move due to boulders or walls try to escape +intelligent monsters see and remember when others trigger traps Fixes to 3.7.0-x Problems that Were Exposed Via git Repository diff --git a/include/extern.h b/include/extern.h index dc3e1ffcc..1c180adbf 100644 --- a/include/extern.h +++ b/include/extern.h @@ -1653,6 +1653,7 @@ extern void monstseesu(unsigned long); extern boolean resist_conflict(struct monst *); extern boolean mon_knows_traps(struct monst *, int); extern void mon_learns_traps(struct monst *, int); +extern void mons_see_trap(struct trap *); /* ### monmove.c ### */ diff --git a/src/mondata.c b/src/mondata.c index 9f71f2eb5..64d8fed7c 100644 --- a/src/mondata.c +++ b/src/mondata.c @@ -1396,4 +1396,24 @@ mon_learns_traps(struct monst *mtmp, int ttyp) mtmp->mtrapseen |= (1L << (ttyp - 1)); } +/* monsters see a trap trigger, and remember it */ +void +mons_see_trap(struct trap *ttmp) +{ + struct monst *mtmp; + coordxy tx = ttmp->tx, ty = ttmp->ty; + int maxdist = levl[tx][ty].lit ? 7*7 : 2; + + for (mtmp = fmon; mtmp; mtmp = mtmp->nmon) { + if (is_animal(mtmp->data) || mindless(mtmp->data) + || !haseyes(mtmp->data) || !mtmp->mcansee) + continue; + if (dist2(mtmp->mx, mtmp->my, tx, ty) > maxdist) + continue; + if (!m_cansee(mtmp, tx, ty)) + continue; + mon_learns_traps(mtmp, ttmp->ttyp); + } +} + /*mondata.c*/ diff --git a/src/monmove.c b/src/monmove.c index 65a769d2d..ff5f6cfd1 100644 --- a/src/monmove.c +++ b/src/monmove.c @@ -1269,6 +1269,7 @@ m_move(register struct monst* mtmp, register int after) register struct obj *otmp; register coordxy xx, yy; coordxy oomx, oomy, lmx, lmy; + struct trap *ttmp; /* cut down the search radius if it thinks character is closer. */ if (distmin(mtmp->mux, mtmp->muy, omx, omy) < SQSRCHRADIUS @@ -1321,6 +1322,16 @@ m_move(register struct monst* mtmp, register int after) || (is_lava(xx, yy) && !likes_lava(ptr))) continue; + /* ignore obj if there's a trap and monster knows it */ + if ((ttmp = t_at(xx, yy)) != 0 + && mon_knows_traps(mtmp, ttmp->ttyp)) { + if (gx == xx && gy == yy) { + gx = mtmp->mux; + gy = mtmp->muy; + } + continue; + } + if (((likegold && otmp->oclass == COIN_CLASS) || (likeobjs && index(practical, otmp->oclass) && (otmp->otyp != CORPSE diff --git a/src/trap.c b/src/trap.c index ac611492b..99456dfd5 100644 --- a/src/trap.c +++ b/src/trap.c @@ -2553,6 +2553,7 @@ dotrap(struct trap *trap, unsigned trflags) if (u.usteed) mon_learns_traps(u.usteed, ttype); + mons_see_trap(trap); /* * Note: @@ -3271,6 +3272,7 @@ mintrap(struct monst *mtmp, unsigned mintrapflags) } mon_learns_traps(mtmp, tt); + mons_see_trap(trap); /* Monster is aggravated by being trapped by you. Recognizing who made the trap isn't completely