give a reason for death by some monster spells */
| 355 | |
| 356 | /* give a reason for death by some monster spells */ |
| 357 | char * |
| 358 | death_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. |
no test coverage detected