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:
@@ -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
|
||||
|
||||
@@ -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 ### */
|
||||
|
||||
|
||||
@@ -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*/
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user