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

Function xkilled

src/mon.c:3476–3740  ·  view source on GitHub ↗

the player has killed the monster mtmp */

Source from the content-addressed store, hash-verified

3474
3475/* the player has killed the monster mtmp */
3476void
3477xkilled(
3478 struct monst *mtmp,
3479 int xkill_flags) /* 1: suppress mesg, 2: suppress corpse, 4: pacifist */
3480{
3481 int tmp, mndx;
3482 coordxy x = mtmp->mx, y = mtmp->my;
3483 struct monst museum = cg.zeromonst;
3484 struct permonst *mdat;
3485 struct obj *otmp;
3486 struct trap *t;
3487 boolean be_sad;
3488 boolean wasinside = engulfing_u(mtmp),
3489 burycorpse = FALSE,
3490 nomsg = (xkill_flags & XKILL_NOMSG) != 0,
3491 nocorpse = (xkill_flags & XKILL_NOCORPSE) != 0,
3492 noconduct = (xkill_flags & XKILL_NOCONDUCT) != 0;
3493
3494 /* potential pet message; always clear global flag */
3495 be_sad = iflags.sad_feeling;
3496 iflags.sad_feeling = FALSE;
3497
3498 mtmp->mhp = 0; /* caller will usually have already done this */
3499 if (!noconduct) { /* KMH, conduct */
3500 if (!u.uconduct.killer++)
3501 livelog_printf(LL_CONDUCT, "killed for the first time");
3502 }
3503 if (!nomsg) {
3504 boolean namedpet = has_mgivenname(mtmp) && !Hallucination;
3505
3506 You("%s %s!",
3507 nonliving(mtmp->data) ? "destroy" : "kill",
3508 !(wasinside || canspotmon(mtmp)) ? "it"
3509 : !mtmp->mtame ? mon_nam(mtmp)
3510 : x_monnam(mtmp, namedpet ? ARTICLE_NONE : ARTICLE_THE,
3511 "poor", namedpet ? SUPPRESS_SADDLE : 0, FALSE));
3512 }
3513
3514 if (mtmp->mtrapped && (t = t_at(x, y)) != 0 && is_pit(t->ttyp)) {
3515 if (sobj_at(BOULDER, x, y))
3516 nocorpse = TRUE; /* Prevent corpses/treasure being created
3517 * "on top" of boulder that is about to fall in.
3518 * This is out of order, but cannot be helped
3519 * unless this whole routine is rearranged. */
3520 if (m_carrying(mtmp, BOULDER))
3521 burycorpse = TRUE;
3522 }
3523
3524 /* your pet knows who just killed it...watch out */
3525 if (mtmp->mtame && !mtmp->isminion)
3526 EDOG(mtmp)->killed_by_u = 1;
3527
3528 if (wasinside && gt.thrownobj && gt.thrownobj != uball
3529 /* don't give to mon if missile is going to be destroyed */
3530 && gt.thrownobj->oclass != POTION_CLASS
3531 /* don't give to mon if missile is going to return to hero */
3532 && gt.thrownobj != (struct obj *) iflags.returning_missile) {
3533 /* thrown object has killed hero's engulfer; add it to mon's

Callers 15

hmon_hitmonFunction · 0.85
mhitm_ad_rustFunction · 0.85
mhitm_ad_dcayFunction · 0.85
mhitm_ad_drliFunction · 0.85
mhitm_ad_fireFunction · 0.85
mhitm_ad_cursFunction · 0.85
damageumFunction · 0.85
gulpumFunction · 0.85
mon_polyFunction · 0.85
god_zaps_youFunction · 0.85
do_pitFunction · 0.85
wiz_killFunction · 0.85

Calls 15

livelog_printfFunction · 0.85
YouFunction · 0.85
mon_namFunction · 0.85
t_atFunction · 0.85
sobj_atFunction · 0.85
m_carryingFunction · 0.85
mpickobjFunction · 0.85
monstoneFunction · 0.85
mondeadFunction · 0.85
stackobjFunction · 0.85
mksobj_atFunction · 0.85
accessibleFunction · 0.85

Tested by

no test coverage detected