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

Function e_died

src/dbridge.c:401–480  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

399}
400
401staticfn void
402e_died(
403 struct entity *etmp,
404 int xkill_flags, int how)
405{
406 if (is_u(etmp)) {
407 if (how == DROWNING) {
408 svk.killer.name[0] = 0; /* drown() sets its own killer */
409 (void) drown();
410 } else if (how == BURNING) {
411 svk.killer.name[0] = 0; /* lava_effects() sets own killer */
412 (void) lava_effects();
413 } else {
414 coord xy;
415
416 /* use more specific killer if specified */
417 if (!svk.killer.name[0]) {
418 svk.killer.format = KILLED_BY_AN;
419 Strcpy(svk.killer.name, "falling drawbridge");
420 }
421 done(how);
422 /* So, you didn't die */
423 if (!e_survives_at(etmp, etmp->ex, etmp->ey)) {
424 if (enexto(&xy, etmp->ex, etmp->ey, etmp->edata)) {
425 pline("A %s force teleports you away...",
426 Hallucination ? "normal" : "strange");
427 teleds(xy.x, xy.y, TELEDS_NO_FLAGS);
428 }
429 /* otherwise on top of the drawbridge is the
430 * only viable spot in the dungeon, so stay there
431 */
432 }
433 }
434 /* we might have crawled out of the moat to survive */
435 etmp->ex = u.ux, etmp->ey = u.uy;
436 } else {
437 int entitycnt;
438
439 svk.killer.name[0] = 0;
440/* fake "digested to death" damage-type suppresses corpse */
441#define mk_message(dest) (((dest & XKILL_NOMSG) != 0) ? (char *) 0 : "")
442#define mk_corpse(dest) (((dest & XKILL_NOCORPSE) != 0) ? AD_DGST : AD_PHYS)
443 /* if monsters are moving, one of them caused the destruction */
444 if (svc.context.mon_moving)
445 monkilled(etmp->emon,
446 mk_message(xkill_flags), mk_corpse(xkill_flags));
447 else /* you caused it */
448 xkilled(etmp->emon, xkill_flags);
449
450 /* if etmp gets life-saved, kill it again; otherwise we might end up
451 trying to place another monster (probably a xorn) on same spot */
452 if (!DEADMONSTER(etmp->emon)) {
453 int seeit = canspotmon(etmp->emon);
454
455 xkill_flags |= XKILL_NOMSG | XKILL_NOCONDUCT;
456 if (svc.context.mon_moving)
457 monkilled(etmp->emon, "", mk_corpse(xkill_flags));
458 else /* you caused it */

Callers 2

do_entityFunction · 0.85
destroy_drawbridgeFunction · 0.85

Calls 10

drownFunction · 0.85
lava_effectsFunction · 0.85
doneFunction · 0.85
e_survives_atFunction · 0.85
enextoFunction · 0.85
teledsFunction · 0.85
monkilledFunction · 0.85
xkilledFunction · 0.85
mon_namFunction · 0.85
plineFunction · 0.70

Tested by

no test coverage detected