more setuhpmax()

Prayer result of fix very low HP.  Tricky because when poly'd,
prayer operates on both u.mhmax and regular u.uhpmax but setuhpmax()
only operates on one of the two depending on Upolyd.
This commit is contained in:
PatR
2024-09-25 00:58:43 -07:00
parent a3f176c9dc
commit da8ba281a4
+13 -11
View File
@@ -1,4 +1,4 @@
/* NetHack 3.7 pray.c $NHDT-Date: 1712233483 2024/04/04 12:24:43 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.217 $ */ /* NetHack 3.7 pray.c $NHDT-Date: 1727250729 2024/09/25 07:52:09 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.220 $ */
/* Copyright (c) Benson I. Margulies, Mike Stephenson, Steve Linhart, 1989. */ /* Copyright (c) Benson I. Margulies, Mike Stephenson, Steve Linhart, 1989. */
/* NetHack may be freely redistributed. See license for details. */ /* NetHack may be freely redistributed. See license for details. */
@@ -368,7 +368,7 @@ fix_curse_trouble(struct obj *otmp, const char *what)
staticfn void staticfn void
fix_worst_trouble(int trouble) fix_worst_trouble(int trouble)
{ {
int i; int i, maxhp, polyd = NON_PM;
struct obj *otmp = 0; struct obj *otmp = 0;
const char *what = (const char *) 0; const char *what = (const char *) 0;
static NEARDATA const char leftglow[] = "Your left ring softly glows", static NEARDATA const char leftglow[] = "Your left ring softly glows",
@@ -419,18 +419,20 @@ fix_worst_trouble(int trouble)
boosted to be more than that */ boosted to be more than that */
You_feel("much better."); You_feel("much better.");
if (Upolyd) { if (Upolyd) {
u.mhmax += rnd(5); maxhp = u.mhmax + rnd(5);
if (u.mhmax <= 5) setuhpmax(max(maxhp, 5 + 1));
u.mhmax = 5 + 1;
u.mh = u.mhmax; u.mh = u.mhmax;
polyd = u.umonnum;
u.umonnum = u.umonster; /* temporarily unpolymorph so that next
* setuhpmax() call deals with u.uhpmax */
} }
if (u.uhpmax < u.ulevel * 5 + 11) maxhp = u.uhpmax;
u.uhpmax += rnd(5); if (maxhp < u.ulevel * 5 + 11)
if (u.uhpmax <= 5) maxhp += rnd(5);
u.uhpmax = 5 + 1; setuhpmax(max(maxhp, 5 + 1));
if (u.uhpmax > u.uhppeak)
u.uhppeak = u.uhpmax;
u.uhp = u.uhpmax; u.uhp = u.uhpmax;
if (polyd != NON_PM)
u.umonnum = polyd; /* restore Upolyd */
disp.botl = TRUE; disp.botl = TRUE;
break; break;
case TROUBLE_COLLAPSING: case TROUBLE_COLLAPSING: