max HP manipulation

Life-saving has been setting u.uhpmax to max(2 * u.ulevel, 10)
and if it took place during level drain that could make u.uhpmax
increase instead of decrease, confusing healing which gets applied
to a monster who has drained the hero with Stormbringer or the
Staff of Aesculapius.  Change the setting to be max(u.ulevel, 10)
(removing the times two part) and also have level drain force it
to be set back to previous value if/when it gets increased.

Max HP loss due to strength trying to drop below 3 or to fire trap
or to being hit by Death now uses a mininum max HP of u.ulevel
rather than 1.  They don't have the alternate minimum of 10; I'm
uneasy that there are still two different minimum values.

I changed adjattrib() to set the flag to request a status update
before it gave its optional message rather than after so that the
new characteristic value would be visible during the message.  That
resulted in not updating status when eating royal jelly changed HP
or max HP after boosting strength.  But the same missing update
would have occurred--or rather, failed to occur--without the change
in sequencing if the strength boost causes a change in encumbrance.
This commit is contained in:
PatR
2022-03-21 12:32:07 -07:00
parent 8a9578e94c
commit d53c1a7a67
8 changed files with 86 additions and 26 deletions

View File

@@ -204,9 +204,10 @@ more_experienced(register int exper, register int rexp)
/* e.g., hit by drain life attack */
void
losexp(const char *drainer) /* cause of death, if drain should be fatal */
losexp(
const char *drainer) /* cause of death, if drain should be fatal */
{
register int num;
int num, uhpmin, olduhpmax;
/* override life-drain resistance when handling an explicit
wizard mode request to reduce level; never fatal though */
@@ -237,10 +238,21 @@ losexp(const char *drainer) /* cause of death, if drain should be fatal */
u.uexp = 0;
livelog_printf(LL_MINORAC, "lost all experience");
}
olduhpmax = u.uhpmax;
uhpmin = minuhpmax(10); /* same minimum as is used by life-saving */
num = (int) u.uhpinc[u.ulevel];
u.uhpmax -= num;
if (u.uhpmax < 1)
u.uhpmax = 1;
if (u.uhpmax < uhpmin)
setuhpmax(uhpmin);
/* uhpmax might try to go up if it has previously been reduced by
strength loss or by a fire trap or by an attack by Death which
all use a different minimum than life-saving or experience loss;
we don't allow it to go up because that contradicts assumptions
elsewhere (such as healing wielder who drains with Strombringer) */
if (u.uhpmax > olduhpmax)
setuhpmax(olduhpmax);
u.uhp -= num;
if (u.uhp < 1)
u.uhp = 1;
@@ -302,9 +314,7 @@ pluslvl(
u.mh += hpinc;
}
hpinc = newhp();
u.uhpmax += hpinc;
if (u.uhpmax > u.uhppeak)
u.uhppeak = u.uhpmax;
setuhpmax(u.uhpmax + hpinc);
u.uhp += hpinc;
/* increase spell power/energy points */