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

Function watch_dig

src/dig.c:1376–1410  ·  view source on GitHub ↗

* Town Watchmen frown on damage to the town walls, trees or fountains. * It's OK to dig holes in the ground, however. * If mtmp is assumed to be a watchman, a watchman is found if mtmp == 0 * zap == TRUE if wand/spell of digging, FALSE otherwise (chewing) */

Source from the content-addressed store, hash-verified

1374 * zap == TRUE if wand/spell of digging, FALSE otherwise (chewing)
1375 */
1376void
1377watch_dig(struct monst *mtmp, coordxy x, coordxy y, boolean zap)
1378{
1379 struct rm *lev = &levl[x][y];
1380
1381 if (in_town(x, y)
1382 && (closed_door(x, y) || lev->typ == SDOOR || IS_WALL(lev->typ)
1383 || IS_FOUNTAIN(lev->typ) || IS_TREE(lev->typ))) {
1384 if (!mtmp)
1385 mtmp = get_iter_mons(watchman_canseeu);
1386
1387 if (mtmp) {
1388 SetVoice(mtmp, 0, 80, 0);
1389 if (zap || svc.context.digging.warned) {
1390 verbalize("Halt, vandal! You're under arrest!");
1391 (void) angry_guards(!!Deaf);
1392 } else {
1393 const char *str;
1394
1395 if (IS_DOOR(lev->typ))
1396 str = "door";
1397 else if (IS_TREE(lev->typ))
1398 str = "tree";
1399 else if (IS_OBSTRUCTED(lev->typ))
1400 str = "wall";
1401 else
1402 str = "fountain";
1403 verbalize("Hey, stop damaging that %s!", str);
1404 svc.context.digging.warned = TRUE;
1405 }
1406 if (is_digging())
1407 stop_occupation();
1408 }
1409 }
1410}
1411
1412/* Return TRUE if monster died, FALSE otherwise. Called from m_move(). */
1413boolean

Callers 4

still_chewingFunction · 0.85
zap_digFunction · 0.85
watch_on_dutyFunction · 0.85
do_break_wandFunction · 0.85

Calls 7

in_townFunction · 0.85
closed_doorFunction · 0.85
get_iter_monsFunction · 0.85
verbalizeFunction · 0.85
angry_guardsFunction · 0.85
is_diggingFunction · 0.85
stop_occupationFunction · 0.85

Tested by

no test coverage detected