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

Function mondead

src/mon.c:3080–3177  ·  view source on GitHub ↗

monster 'mtmp' has died; maybe life-save, otherwise unshapeshift and update vanquished stats and update map */

Source from the content-addressed store, hash-verified

3078/* monster 'mtmp' has died; maybe life-save, otherwise unshapeshift and
3079 update vanquished stats and update map */
3080void
3081mondead(struct monst *mtmp)
3082{
3083 struct permonst *mptr;
3084 boolean be_sad;
3085 int mndx;
3086
3087 /* potential pet message; always clear global flag */
3088 be_sad = iflags.sad_feeling;
3089 iflags.sad_feeling = FALSE;
3090
3091 mtmp->mhp = 0; /* in case caller hasn't done this */
3092 lifesaved_monster(mtmp);
3093 if (!DEADMONSTER(mtmp))
3094 return;
3095
3096 /* vampire in bat/fog/wolf form reverts to vampire instead of dying */
3097 if (is_vampshifter(mtmp) && vamprises(mtmp))
3098 return;
3099
3100 if (be_sad)
3101 You("have a sad feeling for a moment, then it passes.");
3102
3103 if (mtmp->data == &mons[PM_STEAM_VORTEX])
3104 create_gas_cloud(mtmp->mx, mtmp->my, rn2(10) + 5, 0); /* harmless */
3105
3106 /* dead vault guard is actually kept at coordinate <0,0> until
3107 his temporary corridor to/from the vault has been removed;
3108 need to do this after life-saving and before m_detach() */
3109 if (mtmp->isgd && !grddead(mtmp))
3110 return;
3111
3112 mptr = mtmp->data; /* save this for m_detach() */
3113 /* restore chameleon, lycanthropes to true form at death */
3114 if (ismnum(mtmp->cham)) {
3115 set_mon_data(mtmp, &mons[mtmp->cham]);
3116 mtmp->cham = NON_PM;
3117 } else if (mtmp->data == &mons[PM_WEREJACKAL])
3118 set_mon_data(mtmp, &mons[PM_HUMAN_WEREJACKAL]);
3119 else if (mtmp->data == &mons[PM_WEREWOLF])
3120 set_mon_data(mtmp, &mons[PM_HUMAN_WEREWOLF]);
3121 else if (mtmp->data == &mons[PM_WERERAT])
3122 set_mon_data(mtmp, &mons[PM_HUMAN_WERERAT]);
3123
3124 /*
3125 * svm.mvitals[].died does double duty as total number of dead monsters
3126 * and as experience factor for the player killing more monsters.
3127 * this means that a dragon dying by other means reduces the
3128 * experience the player gets for killing a dragon directly; this
3129 * is probably not too bad, since the player likely finagled the
3130 * first dead dragon via ring of conflict or pets, and extinguishing
3131 * based on only player kills probably opens more avenues of abuse
3132 * for rings of conflict and such.
3133 */
3134 mndx = monsndx(mtmp->data);
3135 if (svm.mvitals[mndx].died < 255)
3136 svm.mvitals[mndx].died++;
3137

Callers 10

explmmFunction · 0.85
minliquid_coreFunction · 0.85
mondiedFunction · 0.85
monstoneFunction · 0.85
monkilledFunction · 0.85
xkilledFunction · 0.85
kill_genocided_monstersFunction · 0.85
mon_consume_unstoneFunction · 0.85
explmuFunction · 0.85
mon_explodesFunction · 0.85

Calls 13

lifesaved_monsterFunction · 0.85
vamprisesFunction · 0.85
YouFunction · 0.85
create_gas_cloudFunction · 0.85
rn2Function · 0.85
grddeadFunction · 0.85
set_mon_dataFunction · 0.85
stairway_find_type_dirFunction · 0.85
rndFunction · 0.85
makemonFunction · 0.85
logdeadmonFunction · 0.85
unmap_objectFunction · 0.85

Tested by

no test coverage detected