MCPcopy Index your code
hub / github.com/NetHack/NetHack / postmov

Function postmov

src/monmove.c:1454–1658  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1452#undef SQSRCHRADIUS
1453
1454staticfn int
1455postmov(
1456 struct monst *mtmp,
1457 struct permonst *ptr,
1458 coordxy omx, coordxy omy,
1459 int mmoved,
1460 unsigned seenflgs,
1461 boolean can_tunnel,
1462 boolean can_unlock,
1463 boolean can_open)
1464{
1465 coordxy nix, niy;
1466 int etmp, trapret;
1467 boolean canseeit = cansee(mtmp->mx, mtmp->my),
1468 didseeit = canseeit;
1469
1470 notice_mon(mtmp);
1471
1472 if (mmoved == MMOVE_MOVED) {
1473 nix = mtmp->mx, niy = mtmp->my;
1474 /* sequencing issue: when monster movement decides that a
1475 monster can move to a door location, it moves the monster
1476 there before dealing with the door rather than after;
1477 so a vampire/bat that is going to shift to fog cloud and
1478 pass under the door is already there but transformation
1479 into fog form--and its message, when in sight--has not
1480 happened yet; we have to move monster back to previous
1481 location before performing the vamp_shift() to make the
1482 message happen at right time, then back to the door again
1483 [if we did the shift sooner, before moving the monster,
1484 we would need to duplicate it in dog_move()...] */
1485 if (is_vampshifter(mtmp) && !amorphous(mtmp->data)
1486 && IS_DOOR(levl[nix][niy].typ)
1487 && ((levl[nix][niy].doormask & (D_LOCKED | D_CLOSED)) != 0)
1488 && can_fog(mtmp)) {
1489 /* note: remove_monster()+place_monster is not right for
1490 long worms but they won't reach here */
1491 if (seenflgs) {
1492 remove_monster(nix, niy);
1493 place_monster(mtmp, omx, omy);
1494 newsym(nix, niy), newsym(omx, omy);
1495 }
1496 if (vamp_shift(mtmp, &mons[PM_FOG_CLOUD],
1497 ((seenflgs & 1) != 0) ? TRUE : FALSE)) {
1498 ptr = mtmp->data; /* update cached value */
1499 nhUse(ptr);
1500 }
1501 if (seenflgs) {
1502 remove_monster(omx, omy);
1503 place_monster(mtmp, nix, niy);
1504 newsym(omx, omy), newsym(nix, niy);
1505 }
1506 }
1507
1508 newsym(omx, omy); /* update the old position */
1509 trapret = mintrap(mtmp, NO_TRAP_FLAGS);
1510 if (trapret == Trap_Killed_Mon || trapret == Trap_Moved_Mon) {
1511 if (mtmp->mx)

Callers 1

m_moveFunction · 0.85

Calls 15

notice_monFunction · 0.85
can_fogFunction · 0.85
place_monsterFunction · 0.85
newsymFunction · 0.85
vamp_shiftFunction · 0.85
mintrapFunction · 0.85
has_magic_keyFunction · 0.85
canseemonFunction · 0.85
pline_monFunction · 0.85
YMonnamFunction · 0.85
mb_trappedFunction · 0.85
MonnamFunction · 0.85

Tested by

no test coverage detected