From 936be565d981c000f5f1cf9a47cd492f0d092edd Mon Sep 17 00:00:00 2001 From: PatR Date: Sat, 4 Dec 2021 05:19:45 -0800 Subject: [PATCH] tracking peak maximum HP and energy Keep track of the highest value that u.uhpmax and u.uenmax have attained, in new u.uhppeak and u.uenpeak. They aren't used for anything yet. u.mhmax (max HP while polymorphed) isn't interesting enough to track. Not save and bones compatible so increments EDITLEVEL. --- doc/fixes37.0 | 1 + include/patchlevel.h | 2 +- include/you.h | 11 +++++++---- src/artifact.c | 2 ++ src/eat.c | 10 ++++++++-- src/exper.c | 4 ++++ src/mhitu.c | 2 ++ src/potion.c | 10 ++++++++-- src/pray.c | 4 ++++ src/sit.c | 5 ++++- src/trap.c | 2 ++ src/u_init.c | 4 ++-- src/uhitm.c | 5 ++++- 13 files changed, 49 insertions(+), 13 deletions(-) diff --git a/doc/fixes37.0 b/doc/fixes37.0 index 47a8cf420..634226e7e 100644 --- a/doc/fixes37.0 +++ b/doc/fixes37.0 @@ -1270,6 +1270,7 @@ decaying globs of {ooze,pudding,slime} shrink over time based on their total weight, eventually to nothing; for combined globs it can take a long time, and while doing so they no longer give the tainted corpse food poisoning effect when eaten +track peak maximum HP and peak maximum energy/power; no noticeable effect Platform- and/or Interface-Specific New Features diff --git a/include/patchlevel.h b/include/patchlevel.h index aa42913d4..77ffff403 100644 --- a/include/patchlevel.h +++ b/include/patchlevel.h @@ -17,7 +17,7 @@ * Incrementing EDITLEVEL can be used to force invalidation of old bones * and save files. */ -#define EDITLEVEL 45 +#define EDITLEVEL 46 /* * Development status possibilities. diff --git a/include/you.h b/include/you.h index 79d3737ff..11c3ab32a 100644 --- a/include/you.h +++ b/include/you.h @@ -400,7 +400,8 @@ struct you { int umonster; /* hero's "real" monster num */ int umonnum; /* current monster number */ - int mh, mhmax, mtimedone; /* for polymorph-self */ + int mh, mhmax, /* current and max hit points when polyd */ + mtimedone; /* no. of turns until polymorph times out */ struct attribs macurr, /* for monster attribs */ mamax; /* for monster attribs */ int ulycn; /* lycanthrope type */ @@ -450,8 +451,10 @@ struct you { uchar uspellprot; /* protection by SPE_PROTECTION */ uchar usptime; /* #moves until uspellprot-- */ uchar uspmtime; /* #moves between uspellprot-- */ - int uhp, uhpmax; /* hit points, aka health */ - int uen, uenmax; /* magical energy - M. Stephenson */ + int uhp, uhpmax, /* hit points, aka health */ + uhppeak; /* highest value of uhpmax so far */ + int uen, uenmax, /* magical energy, aka spell power */ + uenpeak; /* highest value of uenmax so far */ xchar uhpinc[MAXULEV], /* increases to uhpmax for each level gain */ ueninc[MAXULEV]; /* increases to uenmax for each level gain */ int ugangr; /* if the gods are angry at you */ @@ -459,7 +462,7 @@ struct you { int ublessed, ublesscnt; /* blessing/duration from #pray */ long umoney0; long uspare1; - long uexp, urexp; + long uexp, urexp; /* exper pts for gaining levels and for score */ long ucleansed; /* to record moves when player was cleansed */ long usleep; /* sleeping; monstermove you last started */ int uinvault; diff --git a/src/artifact.c b/src/artifact.c index 832162a1d..3458f1855 100644 --- a/src/artifact.c +++ b/src/artifact.c @@ -1000,6 +1000,8 @@ Mb_hit(struct monst *magr, /* attacker */ mdef->mhp = 1; /* cancelled clay golems will die */ if (youattack && attacktype(mdef->data, AT_MAGC)) { u.uenmax++; + if (u.uenmax > u.uenpeak) + u.uenpeak = u.uenmax; u.uen++; g.context.botl = TRUE; You("absorb magical energy!"); diff --git a/src/eat.c b/src/eat.c index 8cc247d47..e9bb086a7 100644 --- a/src/eat.c +++ b/src/eat.c @@ -937,8 +937,11 @@ eye_of_newt_buzz(void) u.uen += rnd(3); if (u.uen > u.uenmax) { - if (!rn2(3)) + if (!rn2(3)) { u.uenmax++; + if (u.uenmax > u.uenpeak) + u.uenpeak = u.uenmax; + } u.uen = u.uenmax; } if (old_uen != u.uen) { @@ -2247,8 +2250,11 @@ fpostfx(struct obj *otmp) } else { u.uhp += otmp->cursed ? -rnd(20) : rnd(20); if (u.uhp > u.uhpmax) { - if (!rn2(17)) + if (!rn2(17)) { u.uhpmax++; + if (u.uhpmax > u.uhppeak) + u.uhppeak = u.uhpmax; + } u.uhp = u.uhpmax; } else if (u.uhp <= 0) { g.killer.format = KILLED_BY_AN; diff --git a/src/exper.c b/src/exper.c index 4673d8aec..6936369fd 100644 --- a/src/exper.c +++ b/src/exper.c @@ -289,11 +289,15 @@ pluslvl(boolean incr) /* true iff via incremental experience growth */ } hpinc = newhp(); u.uhpmax += hpinc; + if (u.uhpmax > u.uhppeak) + u.uhppeak = u.uhpmax; u.uhp += hpinc; /* increase spell power/energy points */ eninc = newpw(); u.uenmax += eninc; + if (u.uenmax > u.uenpeak) + u.uenpeak = u.uenmax; u.uen += eninc; /* increase level (unless already maxxed) */ diff --git a/src/mhitu.c b/src/mhitu.c index af42ae581..f12efe641 100644 --- a/src/mhitu.c +++ b/src/mhitu.c @@ -1953,6 +1953,8 @@ doseduce(struct monst *mon) You_feel("raised to your full potential."); exercise(A_CON, TRUE); u.uen = (u.uenmax += rnd(5)); + if (u.uenmax > u.uenpeak) + u.uenpeak = u.uenmax; break; case 1: You_feel("good enough to do it again."); diff --git a/src/potion.c b/src/potion.c index 1aa56fd20..04b115b56 100644 --- a/src/potion.c +++ b/src/potion.c @@ -1174,7 +1174,9 @@ peffect_gain_energy(struct obj *otmp) if (otmp->cursed) num = -num; /* subtract instead of add when cursed */ u.uenmax += num; - if (u.uenmax <= 0) + if (u.uenmax > u.uenpeak) + u.uenpeak = u.uenmax; + else if (u.uenmax <= 0) u.uenmax = 0; u.uen += 3 * num; if (u.uen > u.uenmax) @@ -1356,8 +1358,11 @@ healup(int nhp, int nxtra, boolean curesick, boolean cureblind) u.mh = (u.mhmax += nxtra); } else { u.uhp += nhp; - if (u.uhp > u.uhpmax) + if (u.uhp > u.uhpmax) { u.uhp = (u.uhpmax += nxtra); + if (u.uhpmax > u.uhppeak) + u.uhppeak = u.uhpmax; + } } } if (cureblind) { @@ -1966,6 +1971,7 @@ potionbreathe(struct obj *obj) break; /* case POT_GAIN_LEVEL: + case POT_GAIN_ENERGY: case POT_LEVITATION: case POT_FRUIT_JUICE: case POT_MONSTER_DETECTION: diff --git a/src/pray.c b/src/pray.c index aae013c8d..65a4ce085 100644 --- a/src/pray.c +++ b/src/pray.c @@ -387,6 +387,8 @@ fix_worst_trouble(int trouble) u.uhpmax += rnd(5); if (u.uhpmax <= 5) u.uhpmax = 5 + 1; + if (u.uhpmax > u.uhppeak) + u.uhppeak = u.uhpmax; u.uhp = u.uhpmax; g.context.botl = 1; break; @@ -1087,6 +1089,8 @@ pleased(aligntyp g_align) pluslvl(FALSE); } else { u.uhpmax += 5; + if (u.uhpmax > u.uhppeak) + u.uhppeak = u.uhpmax; if (Upolyd) u.mhmax += 5; } diff --git a/src/sit.c b/src/sit.c index 0ca44dcc7..ef016650f 100644 --- a/src/sit.c +++ b/src/sit.c @@ -185,8 +185,11 @@ dosit(void) u.mhmax += 4; u.mh = u.mhmax; } - if (u.uhp >= (u.uhpmax - 5)) + if (u.uhp >= (u.uhpmax - 5)) { u.uhpmax += 4; + if (u.uhpmax > u.uhppeak) + u.uhppeak = u.uhpmax; + } u.uhp = u.uhpmax; u.ucreamed = 0; make_blinded(0L, TRUE); diff --git a/src/trap.c b/src/trap.c index 0efd764c2..56622e1d7 100644 --- a/src/trap.c +++ b/src/trap.c @@ -1959,6 +1959,8 @@ trapeffect_magic_trap( losehp(rnd(10), "magical explosion", KILLED_BY_AN); Your("body absorbs some of the magical energy!"); u.uen = (u.uenmax += 2); + if (u.uenmax > u.uenpeak) + u.uenpeak = u.uenmax; return 0; } else { domagictrap(); diff --git a/src/u_init.c b/src/u_init.c index 45a0012f5..42b7f6fd0 100644 --- a/src/u_init.c +++ b/src/u_init.c @@ -661,8 +661,8 @@ u_init(void) set_uasmon(); u.ulevel = 0; /* set up some of the initial attributes */ - u.uhp = u.uhpmax = newhp(); - u.uen = u.uenmax = newpw(); + u.uhp = u.uhpmax = u.uhppeak = newhp(); + u.uen = u.uenmax = u.uenpeak = newpw(); u.uspellprot = 0; adjabil(0, 1); u.ulevel = u.ulevelmax = 1; diff --git a/src/uhitm.c b/src/uhitm.c index 8c8348ff7..6d2ab7fa3 100644 --- a/src/uhitm.c +++ b/src/uhitm.c @@ -3662,8 +3662,11 @@ mhitm_ad_heal(struct monst *magr, struct attack *mattk, struct monst *mdef, u.uhp += rnd(7); if (!rn2(7)) { /* hard upper limit via nurse care: 25 * ulevel */ - if (u.uhpmax < 5 * u.ulevel + d(2 * u.ulevel, 10)) + if (u.uhpmax < 5 * u.ulevel + d(2 * u.ulevel, 10)) { u.uhpmax++; + if (u.uhpmax > u.uhppeak) + u.uhppeak = u.uhpmax; + } if (!rn2(13)) goaway = TRUE; }