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

Function makemap_unmakemon

src/wizcmds.c:72–105  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

70/* used when wiz_makemap() gets rid of monsters for the old incarnation of
71 a level before creating a new incarnation of it */
72staticfn void
73makemap_unmakemon(struct monst *mtmp, boolean migratory)
74{
75 int ndx = monsndx(mtmp->data);
76
77 /* uncreate any unique monster so that it is eligible to be remade
78 on the new incarnation of the level; ignores DEADMONSTER() [why?] */
79 if (mtmp->data->geno & G_UNIQ)
80 svm.mvitals[ndx].mvflags &= ~G_EXTINCT;
81 if (svm.mvitals[ndx].born)
82 svm.mvitals[ndx].born--;
83
84 /* vault is going away; get rid of guard who might be in play or
85 be parked at <0,0>; for the latter, might already be flagged as
86 dead but is being kept around because of the 'isgd' flag */
87 if (mtmp->isgd) {
88 mtmp->isgd = 0; /* after this, fall through to mongone() */
89 } else if (DEADMONSTER(mtmp)) {
90 return; /* already set to be discarded */
91 } else if (mtmp->isshk && on_level(&u.uz, &ESHK(mtmp)->shoplevel)) {
92 setpaid(mtmp);
93 }
94 if (migratory) {
95 /* caller has removed 'mtmp' from migrating_mons; put it onto fmon
96 so that dmonsfree() bookkeeping for number of dead or removed
97 monsters won't get out of sync; it is not on the map but
98 mongone() -> m_detach() -> mon_leaving_level() copes with that */
99 mtmp->mstate |= MON_OFFMAP;
100 mtmp->mstate &= ~(MON_MIGRATING | MON_LIMBO | MON_ENDGAME_MIGR);
101 mtmp->nmon = fmon;
102 fmon = mtmp;
103 }
104 mongone(mtmp);
105}
106
107/* get rid of the all the monsters on--or intimately involved with--current
108 level; used when #wizmakemap destroys the level before replacing it */

Callers 1

makemap_remove_monsFunction · 0.85

Calls 3

on_levelFunction · 0.85
setpaidFunction · 0.85
mongoneFunction · 0.85

Tested by

no test coverage detected