static void release_hero(struct monst *);
static void distfleeck(struct monst *, int *, int *, int *);
static int m_arrival(struct monst *);
+static boolean holds_up_web(xchar, xchar);
+static int count_webbing_walls(xchar, xchar);
static boolean m_balks_at_approaching(struct monst *);
static boolean stuff_prevents_passage(struct monst *);
static int vamp_shift(struct monst *, struct permonst *, boolean);
return FALSE;
}
+static boolean
+holds_up_web(xchar x, xchar y)
+{
+ stairway *sway;
+
+ if (!isok(x, y)
+ || IS_ROCK(levl[x][y].typ)
+ || ((levl[x][y].typ == STAIRS
+ || levl[x][y].typ == LADDER)
+ && (sway = stairway_at(x,y)) != 0
+ && sway->up)
+ || levl[x][y].typ == IRONBARS)
+ return TRUE;
+
+ return FALSE;
+}
+
+/* returns the number of walls in the four cardinal directions that could
+ hold up a web */
+static int
+count_webbing_walls(xchar x, xchar y)
+{
+ return (holds_up_web(x, y - 1) + holds_up_web(x + 1, y)
+ + holds_up_web(x, y + 1) + holds_up_web(x - 1, y));
+}
+
+/* monster might spin a web */
+static void
+maybe_spin_web(struct monst *mtmp)
+{
+ if (webmaker(mtmp->data) && !mtmp->mspec_used
+ && !t_at(mtmp->mx, mtmp->my)) {
+ struct trap *trap;
+ int prob = (((mtmp->data == &mons[PM_GIANT_SPIDER]) ? 15 : 5)
+ * (count_webbing_walls(mtmp->mx, mtmp->my) + 1))
+ - (3 * count_traps(WEB));
+
+ if (rn2(1000) < prob
+ && (trap = maketrap(mtmp->mx, mtmp->my, WEB)) != 0) {
+ mtmp->mspec_used = d(4, 4); /* 4..16 */
+ if (cansee(mtmp->mx, mtmp->my)) {
+ char mbuf[BUFSZ];
+
+ Strcpy(mbuf,
+ canspotmon(mtmp) ? y_monnam(mtmp) : something);
+ pline("%s spins a web.", upstart(mbuf));
+ trap->tseen = 1;
+ }
+ }
+ }
+}
+
/* Return values:
* 0: did not move, but can still attack and do other stuff.
* 1: moved, possibly can attack.
}
}
+ maybe_spin_web(mtmp);
+
if (hides_under(ptr) || ptr->mlet == S_EEL) {
/* Always set--or reset--mundetected if it's already hidden
(just in case the object it was hiding under went away);