diff --git a/src/muse.c b/src/muse.c index 4d381495b..3a5849be8 100644 --- a/src/muse.c +++ b/src/muse.c @@ -22,6 +22,7 @@ static void mquaffmsg(struct monst *, struct obj *); static boolean m_use_healing(struct monst *); static boolean m_sees_sleepy_soldier(struct monst *); static void m_tele(struct monst *, boolean, boolean, int); +static boolean m_next2m(struct monst *); static void reveal_trap(struct trap *, boolean); static boolean linedup_chk_corpse(coordxy, coordxy); static void m_use_undead_turning(struct monst *, struct obj *); @@ -398,6 +399,26 @@ m_tele( } } +/* return TRUE if monster mtmp has another monster next to it */ +static boolean +m_next2m(struct monst *mtmp) +{ + coordxy x, y; + struct monst *m2; + + if (DEADMONSTER(mtmp) || mon_offmap(mtmp)) + return FALSE; + + for (x = mtmp->mx - 1; x <= mtmp->mx + 1; x++) + for (y = mtmp->my - 1; y <= mtmp->my + 1; y++) { + if (!isok(x,y)) + continue; + if ((m2 = m_at(x, y)) && m2 != mtmp) + return TRUE; + } + return FALSE; +} + /* Select a defensive item/action for a monster. Returns TRUE iff one is found. */ boolean @@ -418,6 +439,9 @@ find_defensive(struct monst *mtmp, boolean tryescape) return FALSE; if (!tryescape && dist2(x, y, mtmp->mux, mtmp->muy) > 25) return FALSE; + if (tryescape && Is_knox(&u.uz) + && !next2u(mtmp->mx, mtmp->my) && m_next2m(mtmp)) + return FALSE; if (u.uswallow && stuck) return FALSE;