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

Function mdig_tunnel

src/dig.c:1413–1497  ·  view source on GitHub ↗

Return TRUE if monster died, FALSE otherwise. Called from m_move(). */

Source from the content-addressed store, hash-verified

1411
1412/* Return TRUE if monster died, FALSE otherwise. Called from m_move(). */
1413boolean
1414mdig_tunnel(struct monst *mtmp)
1415{
1416 struct rm *here;
1417 boolean sawit, seeit, trapped;
1418 int pile = rnd(12);
1419
1420 here = &levl[mtmp->mx][mtmp->my];
1421 if (here->typ == SDOOR)
1422 cvt_sdoor_to_door(here); /* ->typ = DOOR */
1423
1424 /* Eats away door if present & closed or locked */
1425 if (closed_door(mtmp->mx, mtmp->my)) {
1426 if (*in_rooms(mtmp->mx, mtmp->my, SHOPBASE))
1427 add_damage(mtmp->mx, mtmp->my, 0L);
1428 /* sawit: closed door location is more visible than an open one */
1429 sawit = canseemon(mtmp); /* before door state change and unblock_pt */
1430 trapped = (here->doormask & D_TRAPPED) ? TRUE : FALSE;
1431 here->doormask = trapped ? D_NODOOR : D_BROKEN;
1432 recalc_block_point(mtmp->mx, mtmp->my); /* vision */
1433 newsym(mtmp->mx, mtmp->my);
1434 if (trapped) {
1435 seeit = canseemon(mtmp);
1436 if (mb_trapped(mtmp, sawit || seeit)) { /* mtmp is killed */
1437 newsym(mtmp->mx, mtmp->my);
1438 return TRUE;
1439 }
1440 } else {
1441 if (flags.verbose) {
1442 if (!Unaware && !rn2(3)) /* not too often.. */
1443 draft_message(TRUE); /* "You feel an unexpected draft." */
1444 }
1445 }
1446 return FALSE;
1447 } else if (here->typ == SCORR) {
1448 here->typ = CORR, here->flags = 0;
1449 unblock_point(mtmp->mx, mtmp->my);
1450 newsym(mtmp->mx, mtmp->my);
1451 draft_message(FALSE); /* "You feel a draft." */
1452 return FALSE;
1453 } else if (!IS_OBSTRUCTED(here->typ) && !IS_TREE(here->typ)) { /* no dig */
1454 return FALSE;
1455 }
1456
1457 /* Only rock, trees, and walls fall through to this point. */
1458 if ((here->wall_info & W_NONDIGGABLE) != 0) {
1459 impossible("mdig_tunnel: %s at (%d,%d) is undiggable",
1460 (IS_WALL(here->typ) ? "wall"
1461 : IS_TREE(here->typ) ? "tree" : "stone"),
1462 (int) mtmp->mx, (int) mtmp->my);
1463 return FALSE; /* still alive */
1464 }
1465
1466 if (IS_WALL(here->typ)) {
1467 /* KMH -- Okay on arboreal levels (room walls are still stone) */
1468 if (flags.verbose && !rn2(5)) {
1469 Soundeffect(se_crashing_rock, 75);
1470 You_hear("crashing rock.");

Callers 1

postmovFunction · 0.85

Calls 15

rndFunction · 0.85
cvt_sdoor_to_doorFunction · 0.85
closed_doorFunction · 0.85
in_roomsFunction · 0.85
add_damageFunction · 0.85
canseemonFunction · 0.85
recalc_block_pointFunction · 0.85
newsymFunction · 0.85
mb_trappedFunction · 0.85
rn2Function · 0.85
draft_messageFunction · 0.85
unblock_pointFunction · 0.85

Tested by

no test coverage detected