web spinning

This started as some formatting cleanup but I've added a couple of
additional terrain features which can act as web support (stairs up
and ladder up).

The message "<Spider> spins a web" was given if you could detect or
sense <spider> rather than see it.  I've changed that to only happen
if you see the new web appear rather than the critter spinning it
(it only becomes an unseen trap if you don't watch it appear).

After spinning a web, a spider can't spin another one until 4d4 moves
have elapsed.  That seems suitable when the spider can be seen but
isn't really adequate throttling when the spider is far away--it can
end up spinning a lot of webs by the time you get to its vicinity.
Perhaps it shouldn't be able to spin a new web if there is already
one with N steps of its location?
This commit is contained in:
PatR
2018-09-07 18:12:03 -07:00
parent 2122506ebe
commit b572ccb014

View File

@@ -14,8 +14,10 @@ STATIC_DCL int FDECL(disturb, (struct monst *));
STATIC_DCL void FDECL(release_hero, (struct monst *));
STATIC_DCL void FDECL(distfleeck, (struct monst *, int *, int *, int *));
STATIC_DCL int FDECL(m_arrival, (struct monst *));
STATIC_DCL int FDECL(count_webbing_walls, (XCHAR_P, XCHAR_P));
STATIC_DCL boolean FDECL(stuff_prevents_passage, (struct monst *));
STATIC_DCL int FDECL(vamp_shift, (struct monst *, struct permonst *, BOOLEAN_P));
STATIC_DCL int FDECL(vamp_shift, (struct monst *, struct permonst *,
BOOLEAN_P));
/* True if mtmp died */
boolean
@@ -742,15 +744,21 @@ xchar nix,niy;
return FALSE;
}
/* returns the number of walls in the four cardinal directions that could hold up a web */
int
count_webbing_walls(x,y)
xchar x,y;
/* returns the number of walls in the four cardinal directions that could
hold up a web */
STATIC_OVL int
count_webbing_walls(x, y)
xchar x, y;
{
#define holds_up_web(x,y) ((!isok((x),(y)) \
|| IS_ROCK(levl[(x)][(y)].typ) \
|| levl[(x)][(y)].typ == IRONBARS) ? 1 : 0)
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);
#define holds_up_web(X, Y) ((!isok((X), (Y)) \
|| IS_ROCK(levl[X][Y].typ) \
|| (levl[X][Y].typ == STAIRS \
&& (X) == xupstair && (Y) == yupstair) \
|| (levl[X][Y].typ == LADDER \
&& (X) == xupladder && (Y) == yupladder) \
|| levl[X][Y].typ == IRONBARS) ? 1 : 0)
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));
#undef holds_up_web
}
@@ -1448,14 +1456,22 @@ postmov:
}
}
/* maybe a spider spun a web */
if (webmaker(ptr) && !t_at(mtmp->mx, mtmp->my)) {
int prob = ((ptr == &mons[PM_GIANT_SPIDER]) ? 15 : 5) *
(count_webbing_walls(mtmp->mx, mtmp->my) + 1);
if (rn2(1000) < prob) {
struct trap* trap = maketrap(mtmp->mx, mtmp->my, WEB);
if (trap && canspotmon(mtmp)) {
pline("%s spins a web.", upstart(y_monnam(mtmp)));
/* maybe spin a web -- this needs work; if the spider is far away,
it might spin a lot of webs before hero encounters it */
if (webmaker(ptr) && !mtmp->mspec_used && !t_at(mtmp->mx, mtmp->my)) {
struct trap *trap;
int prob = ((ptr == &mons[PM_GIANT_SPIDER]) ? 15 : 5)
* (count_webbing_walls(mtmp->mx, mtmp->my) + 1);
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;
}
}