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

Function slimed_to_death

src/timeout.c:456–519  ·  view source on GitHub ↗

countdown timer for turning into green slime has run out; kill our hero */

Source from the content-addressed store, hash-verified

454
455/* countdown timer for turning into green slime has run out; kill our hero */
456staticfn void
457slimed_to_death(struct kinfo *kptr)
458{
459 uchar save_mvflags;
460
461 /* redundant: polymon() cures sliming when polying into green slime */
462 if (Upolyd && gy.youmonst.data == &mons[PM_GREEN_SLIME]) {
463 dealloc_killer(kptr);
464 return;
465 }
466 /* more sure killer reason is set up */
467 if (kptr && kptr->name[0]) {
468 svk.killer.format = kptr->format;
469 Strcpy(svk.killer.name, kptr->name);
470 } else {
471 svk.killer.format = NO_KILLER_PREFIX;
472 Strcpy(svk.killer.name, "turned into green slime");
473 }
474 dealloc_killer(kptr);
475
476 /*
477 * Polymorph into a green slime, which might destroy some worn armor
478 * (potentially affecting bones) and dismount from steed.
479 * Can't be Unchanging; wouldn't have turned into slime if we were.
480 * Despite lack of Unchanging, neither done() nor savelife() calls
481 * rehumanize() if hero dies while polymorphed.
482 * polymon() undoes the slime countdown's mimick-green-slime hack
483 * but does not perform polyself()'s light source bookkeeping.
484 * No longer need to manually increment uconduct.polyselfs to reflect
485 * [formerly implicit] change of form; polymon() takes care of that.
486 * Temporarily ungenocide if necessary.
487 */
488 if (emits_light(gy.youmonst.data))
489 del_light_source(LS_MONSTER, monst_to_any(&gy.youmonst));
490 save_mvflags = svm.mvitals[PM_GREEN_SLIME].mvflags;
491 svm.mvitals[PM_GREEN_SLIME].mvflags = save_mvflags & ~G_GENOD;
492 /* become a green slime; also resets youmonst.m_ap_type+.mappearance */
493 (void) polymon(PM_GREEN_SLIME);
494 svm.mvitals[PM_GREEN_SLIME].mvflags = save_mvflags;
495 done_timeout(TURNED_SLIME, SLIMED);
496
497 /* life-saved; even so, hero still has turned into green slime;
498 player may have genocided green slimes after being infected */
499 if ((svm.mvitals[PM_GREEN_SLIME].mvflags & G_GENOD) != 0) {
500 char slimebuf[BUFSZ];
501
502 svk.killer.format = KILLED_BY;
503 Strcpy(svk.killer.name, "slimicide");
504 /* vary the message depending upon whether life-save was due to
505 amulet or due to declining to die in explore or wizard mode */
506 Strcpy(slimebuf, "green slime has been genocided...");
507 if (iflags.last_msg == PLNMSG_OK_DONT_DIE)
508 /* follows "OK, so you don't die." and arg is second sentence */
509 urgent_pline("Yes, you do. %s", upstart(slimebuf));
510 else
511 /* follows "The medallion crumbles to dust." */
512 urgent_pline("Unfortunately, %s", slimebuf);
513 /* die again; no possibility of amulet this time */

Callers 1

nh_timeoutFunction · 0.85

Calls 8

dealloc_killerFunction · 0.85
del_light_sourceFunction · 0.85
monst_to_anyFunction · 0.85
polymonFunction · 0.85
done_timeoutFunction · 0.85
urgent_plineFunction · 0.85
upstartFunction · 0.85
doneFunction · 0.85

Tested by

no test coverage detected