MCPcopy Create free account
hub / github.com/NetHack/NetHack / maybe_spin_web

Function maybe_spin_web

src/monmove.c:1268–1293  ·  view source on GitHub ↗

monster might spin a web */

Source from the content-addressed store, hash-verified

1266
1267/* monster might spin a web */
1268staticfn void
1269maybe_spin_web(struct monst *mtmp)
1270{
1271 if (webmaker(mtmp->data)
1272 && !helpless(mtmp) && !mtmp->mspec_used
1273 && !t_at(mtmp->mx, mtmp->my) && soko_allow_web(mtmp)) {
1274 struct trap *trap;
1275 int prob = ((((mtmp->data == &mons[PM_GIANT_SPIDER]) ? 15 : 5)
1276 * (count_webbing_walls(mtmp->mx, mtmp->my) + 1))
1277 - (3 * count_traps(WEB)));
1278
1279 if (rn2(1000) < prob
1280 && (trap = maketrap(mtmp->mx, mtmp->my, WEB)) != 0) {
1281 mtmp->mspec_used = d(4, 4); /* 4..16 */
1282 if (cansee(mtmp->mx, mtmp->my)) {
1283 char mbuf[BUFSZ];
1284
1285 Strcpy(mbuf, canspotmon(mtmp) ? y_monnam(mtmp) : something);
1286 pline_mon(mtmp, "%s spins a web.", upstart(mbuf));
1287 trap->tseen = 1;
1288 }
1289 if (*in_rooms(mtmp->mx, mtmp->my, SHOPBASE))
1290 add_damage(mtmp->mx, mtmp->my, 0L);
1291 }
1292 }
1293}
1294
1295/* monster avoids a location nx, ny, if hero kicked that location */
1296boolean

Callers 1

monmove.cFile · 0.85

Calls 12

t_atFunction · 0.85
soko_allow_webFunction · 0.85
count_webbing_wallsFunction · 0.85
count_trapsFunction · 0.85
rn2Function · 0.85
maketrapFunction · 0.85
dFunction · 0.85
y_monnamFunction · 0.85
pline_monFunction · 0.85
upstartFunction · 0.85
in_roomsFunction · 0.85
add_damageFunction · 0.85

Tested by

no test coverage detected