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

Function mon_leaving_level

src/mon.c:2695–2730  ·  view source on GitHub ↗

'mon' is being removed from level due to migration [relmon from keepdogs or migrate_to_level] or due to death [m_detach from mondead or mongone] */

Source from the content-addressed store, hash-verified

2693/* 'mon' is being removed from level due to migration [relmon from keepdogs
2694 or migrate_to_level] or due to death [m_detach from mondead or mongone] */
2695staticfn void
2696mon_leaving_level(struct monst *mon)
2697{
2698 coordxy mx = mon->mx, my = mon->my;
2699 boolean onmap = (isok(mx, my) && svl.level.monsters[mx][my] == mon);
2700
2701 /* to prevent an infinite relobj-flooreffects-hmon-killed loop */
2702 mon->mtrapped = 0;
2703 unstuck(mon); /* mon is not swallowing or holding you nor held by you */
2704
2705 /* vault guard might be at <0,0> */
2706 if (onmap || mon == svl.level.monsters[0][0]) {
2707 if (mon->wormno)
2708 remove_worm(mon);
2709 else
2710 remove_monster(mx, my);
2711
2712#if 0 /* mustn't do this; too many places assume that the stale
2713 * monst->mx,my values are still valid */
2714 mon->mx = mon->my = 0; /* off normal map */
2715#endif
2716 }
2717 if (onmap) {
2718 mon->mundetected = 0; /* for migration; doesn't matter for death */
2719 /* unhide mimic in case its shape has been blocking line of sight
2720 or it is accompanying the hero to another level */
2721 if (M_AP_TYPE(mon) != M_AP_NOTHING && M_AP_TYPE(mon) != M_AP_MONSTER)
2722 seemimic(mon);
2723 /* if mon is pinned by a boulder, removing mon lets boulder drop */
2724 fill_pit(mx, my);
2725 newsym(mx, my);
2726 }
2727 /* if mon is a remembered target, forget it since it isn't here anymore */
2728 if (mon == svc.context.polearm.hitmon)
2729 svc.context.polearm.hitmon = (struct monst *) 0;
2730}
2731
2732/* 'mtmp' is going away; remove effects of mtmp from other data structures */
2733staticfn void

Callers 3

relmonFunction · 0.85
m_detachFunction · 0.85
mneartoFunction · 0.85

Calls 6

isokFunction · 0.85
unstuckFunction · 0.85
remove_wormFunction · 0.85
seemimicFunction · 0.85
fill_pitFunction · 0.85
newsymFunction · 0.85

Tested by

no test coverage detected