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

Function savelife

src/end.c:703–756  ·  view source on GitHub ↗

try to get the player back in a viable state after being killed */

Source from the content-addressed store, hash-verified

701
702/* try to get the player back in a viable state after being killed */
703staticfn void
704savelife(int how)
705{
706 int uhpmin;
707 int givehp = 50 + 10 * (ACURR(A_CON) / 2);
708
709 /* life-drain/level-loss to experience level 0 kills without actually
710 reducing ulevel below 1, but include this for bulletproofing */
711 if (u.ulevel < 1)
712 u.ulevel = 1;
713 uhpmin = minuhpmax(10);
714 if (u.uhpmax < uhpmin)
715 setuhpmax(uhpmin, TRUE);
716 u.uhp = min(u.uhpmax, givehp);
717 if (Upolyd) /* Unchanging, or death which bypasses losing hit points */
718 u.mh = min(u.mhmax, givehp);
719 if (u.uhunger < 500 || how == CHOKING) {
720 init_uhunger();
721 }
722 /* cure impending doom of sickness hero won't have time to fix
723 [shouldn't this also be applied to other fatal timeouts?] */
724 if ((Sick & TIMEOUT) == 1L) {
725 make_sick(0L, (char *) 0, FALSE, SICK_ALL);
726 }
727 gn.nomovemsg = "You survived that attempt on your life.";
728 svc.context.move = 0;
729
730 gm.multi = -1; /* can't move again during the current turn */
731 /* in case being life-saved is immediately followed by being killed
732 again (perhaps due to zap rebound); this text will be appended to
733 "killed by <something>, while "
734 in high scores entry, if any, and in logfile (but not on tombstone) */
735 gm.multi_reason = Role_if(PM_TOURIST) ? "being toyed with by Fate"
736 : "attempting to cheat Death";
737
738 if (u.utrap && u.utraptype == TT_LAVA)
739 reset_utrap(FALSE);
740 disp.botl = TRUE;
741 u.ugrave_arise = NON_PM;
742 HUnchanging = 0L;
743 curs_on_u();
744 if (!svc.context.mon_moving)
745 endmultishot(FALSE);
746 if (u.uswallow) {
747 /* might drop hero onto a trap that kills her all over again */
748 expels(u.ustuck, u.ustuck->data, TRUE);
749 } else if (u.ustuck) {
750 if (Upolyd && sticks(gy.youmonst.data))
751 You("release %s.", mon_nam(u.ustuck));
752 else
753 pline("%s releases you.", Monnam(u.ustuck));
754 unstuck(u.ustuck);
755 }
756}
757
758/*
759 * Get valuables from the given list. Revised code: the list always remains

Callers 2

fuzzer_savelifeFunction · 0.85
doneFunction · 0.85

Calls 14

minuhpmaxFunction · 0.85
setuhpmaxFunction · 0.85
init_uhungerFunction · 0.85
make_sickFunction · 0.85
reset_utrapFunction · 0.85
curs_on_uFunction · 0.85
endmultishotFunction · 0.85
expelsFunction · 0.85
sticksFunction · 0.85
YouFunction · 0.85
mon_namFunction · 0.85
MonnamFunction · 0.85

Tested by

no test coverage detected