Monsters see and remember when others trigger traps

No longer will there be a conga line of hill orcs stepping into
the same arrow trap one after another.
This commit is contained in:
Pasi Kallinen
2022-08-21 11:46:49 +03:00
parent 953d43f5ac
commit fcf5c1ea50
5 changed files with 35 additions and 0 deletions

View File

@@ -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