Spiders will occasionally spin webs

Idea and code inspired by aosdict
This commit is contained in:
Pasi Kallinen
2018-09-07 20:26:14 +03:00
parent 533234f13d
commit 2122506ebe
2 changed files with 26 additions and 0 deletions

View File

@@ -114,6 +114,7 @@ add window port status_update() value BL_RESET to use as a flag to
for hilite_status of string status fields (title, dungeon-level, alignment),
the types value-goes-up and -down aren't meaningful; treat them as
value-changed if from config file and don't offer as choices with 'O'
spiders will occasionally spin webs when moving around
Fixes to Post-3.6.1 Problems that Were Exposed Via git Repository

View File

@@ -742,6 +742,18 @@ 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;
{
#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);
#undef holds_up_web
}
/* Return values:
* 0: did not move, but can still attack and do other stuff.
* 1: moved, possibly can attack.
@@ -1436,6 +1448,19 @@ 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)));
trap->tseen = 1;
}
}
}
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);