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

Function death_inflicted_by

src/mcastu.c:357–382  ·  view source on GitHub ↗

give a reason for death by some monster spells */

Source from the content-addressed store, hash-verified

355
356/* give a reason for death by some monster spells */
357char *
358death_inflicted_by(
359 char *outbuf, /* assumed big enough; pm_names are short */
360 const char *deathreason, /* cause of death */
361 struct monst *mtmp) /* monster who caused it */
362{
363 Strcpy(outbuf, deathreason);
364 if (mtmp) {
365 struct permonst *mptr = mtmp->data,
366 *champtr = (ismnum(mtmp->cham)) ? &mons[mtmp->cham] : mptr;
367 const char *realnm = pmname(champtr, Mgender(mtmp)),
368 *fakenm = pmname(mptr, Mgender(mtmp));
369
370 /* greatly simplified extract from done_in_by(), primarily for
371 reason for death due to 'touch of death' spell; if mtmp is
372 shape changed, it won't be a vampshifter or mimic since they
373 can't cast spells */
374 if (!type_is_pname(champtr) && !the_unique_pm(mptr))
375 realnm = an(realnm);
376 Sprintf(eos(outbuf), " inflicted by %s%s",
377 the_unique_pm(mptr) ? "the " : "", realnm);
378 if (champtr != mptr)
379 Sprintf(eos(outbuf), " imitating %s", an(fakenm));
380 }
381 return outbuf;
382}
383
384/*
385 * Monster wizard and cleric spellcasting functions.

Callers 3

touch_of_deathFunction · 0.85
mcast_weaken_youFunction · 0.85
zhituFunction · 0.85

Calls 5

pmnameFunction · 0.85
MgenderFunction · 0.85
the_unique_pmFunction · 0.85
anFunction · 0.85
eosFunction · 0.85

Tested by

no test coverage detected