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

Function corpse_chance

src/mon.c:3180–3249  ·  view source on GitHub ↗

TRUE if corpse might be dropped, magr may die if mon was swallowed */

Source from the content-addressed store, hash-verified

3178
3179/* TRUE if corpse might be dropped, magr may die if mon was swallowed */
3180boolean
3181corpse_chance(
3182 struct monst *mon,
3183 struct monst *magr, /* killer, if swallowed */
3184 boolean was_swallowed) /* digestion */
3185{
3186 struct permonst *mdat = mon->data;
3187 int i, tmp;
3188
3189 if (!magr && gm.mswallower && attacktype(gm.mswallower->data, AT_ENGL))
3190 magr = gm.mswallower, was_swallowed = TRUE; /* for gas spore boom */
3191
3192 if (mdat == &mons[PM_VLAD_THE_IMPALER] || mdat->mlet == S_LICH) {
3193 if (cansee(mon->mx, mon->my) && !was_swallowed)
3194 pline_mon(mon, "%s body crumbles into dust.",
3195 s_suffix(Monnam(mon)));
3196 return FALSE;
3197 }
3198
3199 /* Gas spores always explode upon death */
3200 for (i = 0; i < NATTK; i++) {
3201 if (mdat->mattk[i].aatyp == AT_BOOM) {
3202 if (mdat->mattk[i].damn)
3203 tmp = d((int) mdat->mattk[i].damn, (int) mdat->mattk[i].damd);
3204 else if (mdat->mattk[i].damd)
3205 tmp = d((int) mdat->mlevel + 1, (int) mdat->mattk[i].damd);
3206 else
3207 tmp = 0;
3208
3209 if (was_swallowed && magr) {
3210 /* mdef is a gas spore (AT_BOOM) that is exploding inside an
3211 engulfer; suppress usual explosion since it's contained */
3212 if (magr == &gy.youmonst) {
3213 There("is an explosion in your %s!", body_part(STOMACH));
3214 Sprintf(svk.killer.name, "%s explosion",
3215 s_suffix(pmname(mdat, Mgender(mon))));
3216 losehp(Maybe_Half_Phys(tmp), svk.killer.name,
3217 KILLED_BY_AN);
3218 } else {
3219 You_hear("an explosion.");
3220 magr->mhp -= tmp;
3221 if (DEADMONSTER(magr))
3222 mondied(magr);
3223 if (DEADMONSTER(magr)) { /* maybe lifesaved */
3224 if (canspotmon(magr))
3225 pline_mon(magr, "%s rips open!", Monnam(magr));
3226 } else if (canseemon(magr))
3227 pline_mon(magr, "%s seems to have indigestion.",
3228 Monnam(magr));
3229 }
3230 return FALSE;
3231 }
3232
3233 mon_explodes(mon, &mdat->mattk[i]);
3234 return FALSE;
3235 }
3236 }
3237

Callers 4

mhitm_ad_dgstFunction · 0.85
gulpumFunction · 0.85
mondiedFunction · 0.85
xkilledFunction · 0.85

Calls 15

attacktypeFunction · 0.85
pline_monFunction · 0.85
s_suffixFunction · 0.85
MonnamFunction · 0.85
dFunction · 0.85
ThereFunction · 0.85
body_partFunction · 0.85
pmnameFunction · 0.85
MgenderFunction · 0.85
losehpFunction · 0.85
You_hearFunction · 0.85
mondiedFunction · 0.85

Tested by

no test coverage detected