sanity_check: current hero health better than max
Changes to setuhpmax() a couple of days ago to deal with sanity_check for "current hero health as monster better than maximum" ended up triggering sanity_check about "current hero health better than maximum" when gaining experience level(s) while polymorphed.
This commit is contained in:
+1
-1
@@ -202,7 +202,7 @@ extern void vary_init_attr(void);
|
|||||||
extern void adjabil(int, int);
|
extern void adjabil(int, int);
|
||||||
extern int newhp(void);
|
extern int newhp(void);
|
||||||
extern int minuhpmax(int);
|
extern int minuhpmax(int);
|
||||||
extern void setuhpmax(int);
|
extern void setuhpmax(int, boolean);
|
||||||
extern int adjuhploss(int, int);
|
extern int adjuhploss(int, int);
|
||||||
extern schar acurr(int);
|
extern schar acurr(int);
|
||||||
extern schar acurrstr(void);
|
extern schar acurrstr(void);
|
||||||
|
|||||||
+6
-6
@@ -243,18 +243,18 @@ losestr(int num, const char *knam, schar k_format)
|
|||||||
|
|
||||||
if (Upolyd) {
|
if (Upolyd) {
|
||||||
/* when still poly'd, reduce you-as-monst maxHP; never below 1 */
|
/* when still poly'd, reduce you-as-monst maxHP; never below 1 */
|
||||||
setuhpmax(max(u.mhmax - dmg, 1)); /* acts as setmhmax() */
|
setuhpmax(max(u.mhmax - dmg, 1), FALSE); /* acts as setmhmax() */
|
||||||
} else if (!waspolyd) {
|
} else if (!waspolyd) {
|
||||||
/* not polymorphed now and didn't rehumanize when taking damage;
|
/* not polymorphed now and didn't rehumanize when taking damage;
|
||||||
reduce max HP, but not below uhpmin */
|
reduce max HP, but not below uhpmin */
|
||||||
if (u.uhpmax > uhpmin)
|
if (u.uhpmax > uhpmin)
|
||||||
setuhpmax(max(u.uhpmax - dmg, uhpmin));
|
setuhpmax(max(u.uhpmax - dmg, uhpmin), FALSE);
|
||||||
}
|
}
|
||||||
disp.botl = TRUE;
|
disp.botl = TRUE;
|
||||||
}
|
}
|
||||||
#if 0 /* only possible if uhpmax was already less than uhpmin */
|
#if 0 /* only possible if uhpmax was already less than uhpmin */
|
||||||
if (!Upolyd && u.uhpmax < uhpmin) {
|
if (!Upolyd && u.uhpmax < uhpmin) {
|
||||||
setuhpmax(min(olduhpmax, uhpmin));
|
setuhpmax(min(olduhpmax, uhpmin), FALSE);
|
||||||
if (!Drain_resistance)
|
if (!Drain_resistance)
|
||||||
losexp(NULL); /* won't be fatal when no 'drainer' is supplied */
|
losexp(NULL); /* won't be fatal when no 'drainer' is supplied */
|
||||||
}
|
}
|
||||||
@@ -370,7 +370,7 @@ poisoned(
|
|||||||
int olduhp = u.uhp,
|
int olduhp = u.uhp,
|
||||||
newuhpmax = u.uhpmax - (loss / 2);
|
newuhpmax = u.uhpmax - (loss / 2);
|
||||||
|
|
||||||
setuhpmax(max(newuhpmax, minuhpmax(3)));
|
setuhpmax(max(newuhpmax, minuhpmax(3)), TRUE); /*True: see FIXME*/
|
||||||
loss = adjuhploss(loss, olduhp);
|
loss = adjuhploss(loss, olduhp);
|
||||||
|
|
||||||
losehp(loss, pkiller, kprefix); /* poison damage */
|
losehp(loss, pkiller, kprefix); /* poison damage */
|
||||||
@@ -1148,9 +1148,9 @@ minuhpmax(int altmin)
|
|||||||
/* update u.uhpmax or u.mhmax and values of other things that depend upon
|
/* update u.uhpmax or u.mhmax and values of other things that depend upon
|
||||||
whichever of them is relevant */
|
whichever of them is relevant */
|
||||||
void
|
void
|
||||||
setuhpmax(int newmax)
|
setuhpmax(int newmax, boolean even_when_polyd)
|
||||||
{
|
{
|
||||||
if (!Upolyd) {
|
if (!Upolyd || even_when_polyd) {
|
||||||
if (newmax != u.uhpmax) {
|
if (newmax != u.uhpmax) {
|
||||||
u.uhpmax = newmax;
|
u.uhpmax = newmax;
|
||||||
if (u.uhpmax > u.uhppeak)
|
if (u.uhpmax > u.uhppeak)
|
||||||
|
|||||||
@@ -2464,7 +2464,7 @@ fpostfx(struct obj *otmp)
|
|||||||
u.mh += otmp->cursed ? -rnd(20) : rnd(20), disp.botl = TRUE;
|
u.mh += otmp->cursed ? -rnd(20) : rnd(20), disp.botl = TRUE;
|
||||||
if (u.mh > u.mhmax) {
|
if (u.mh > u.mhmax) {
|
||||||
if (!rn2(17))
|
if (!rn2(17))
|
||||||
u.mhmax++;
|
setuhpmax(u.mhmax + 1, FALSE);
|
||||||
u.mh = u.mhmax;
|
u.mh = u.mhmax;
|
||||||
} else if (u.mh <= 0) {
|
} else if (u.mh <= 0) {
|
||||||
rehumanize();
|
rehumanize();
|
||||||
@@ -2473,7 +2473,7 @@ fpostfx(struct obj *otmp)
|
|||||||
u.uhp += otmp->cursed ? -rnd(20) : rnd(20), disp.botl = TRUE;
|
u.uhp += otmp->cursed ? -rnd(20) : rnd(20), disp.botl = TRUE;
|
||||||
if (u.uhp > u.uhpmax) {
|
if (u.uhp > u.uhpmax) {
|
||||||
if (!rn2(17))
|
if (!rn2(17))
|
||||||
setuhpmax(u.uhpmax + 1);
|
setuhpmax(u.uhpmax + 1, FALSE);
|
||||||
u.uhp = u.uhpmax;
|
u.uhp = u.uhpmax;
|
||||||
} else if (u.uhp <= 0) {
|
} else if (u.uhp <= 0) {
|
||||||
svk.killer.format = KILLED_BY_AN;
|
svk.killer.format = KILLED_BY_AN;
|
||||||
|
|||||||
@@ -702,7 +702,7 @@ savelife(int how)
|
|||||||
u.ulevel = 1;
|
u.ulevel = 1;
|
||||||
uhpmin = minuhpmax(10);
|
uhpmin = minuhpmax(10);
|
||||||
if (u.uhpmax < uhpmin)
|
if (u.uhpmax < uhpmin)
|
||||||
setuhpmax(uhpmin);
|
setuhpmax(uhpmin, TRUE);
|
||||||
u.uhp = min(u.uhpmax, givehp);
|
u.uhp = min(u.uhpmax, givehp);
|
||||||
if (Upolyd) /* Unchanging, or death which bypasses losing hit points */
|
if (Upolyd) /* Unchanging, or death which bypasses losing hit points */
|
||||||
u.mh = min(u.mhmax, givehp);
|
u.mh = min(u.mhmax, givehp);
|
||||||
|
|||||||
+7
-5
@@ -251,14 +251,14 @@ losexp(
|
|||||||
num = (int) u.uhpinc[u.ulevel];
|
num = (int) u.uhpinc[u.ulevel];
|
||||||
u.uhpmax -= num;
|
u.uhpmax -= num;
|
||||||
if (u.uhpmax < uhpmin)
|
if (u.uhpmax < uhpmin)
|
||||||
setuhpmax(uhpmin);
|
setuhpmax(uhpmin, TRUE);
|
||||||
/* uhpmax might try to go up if it has previously been reduced by
|
/* 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
|
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;
|
all use a different minimum than life-saving or experience loss;
|
||||||
we don't allow it to go up because that contradicts assumptions
|
we don't allow it to go up because that contradicts assumptions
|
||||||
elsewhere (such as healing wielder who drains with Stormbringer) */
|
elsewhere (such as healing wielder who drains with Stormbringer) */
|
||||||
if (u.uhpmax > olduhpmax)
|
if (u.uhpmax > olduhpmax)
|
||||||
setuhpmax(olduhpmax);
|
setuhpmax(olduhpmax, TRUE);
|
||||||
|
|
||||||
u.uhp -= num;
|
u.uhp -= num;
|
||||||
if (u.uhp < 1)
|
if (u.uhp < 1)
|
||||||
@@ -306,7 +306,8 @@ newexplevel(void)
|
|||||||
void
|
void
|
||||||
pluslvl(
|
pluslvl(
|
||||||
boolean incr) /* True: incremental experience growth;
|
boolean incr) /* True: incremental experience growth;
|
||||||
* False: potion of gain level or wraith corpse */
|
* False: potion of gain level or wraith corpse
|
||||||
|
* or wizard mode #levelchange */
|
||||||
{
|
{
|
||||||
int hpinc, eninc;
|
int hpinc, eninc;
|
||||||
|
|
||||||
@@ -317,12 +318,13 @@ pluslvl(
|
|||||||
in order to retain normal human/whatever increase for later) */
|
in order to retain normal human/whatever increase for later) */
|
||||||
if (Upolyd) {
|
if (Upolyd) {
|
||||||
hpinc = monhp_per_lvl(&gy.youmonst);
|
hpinc = monhp_per_lvl(&gy.youmonst);
|
||||||
u.mhmax += hpinc;
|
|
||||||
u.mh += hpinc;
|
u.mh += hpinc;
|
||||||
|
setuhpmax(u.mhmax, FALSE); /* acts as setmhmax() when Upolyd */
|
||||||
}
|
}
|
||||||
hpinc = newhp();
|
hpinc = newhp();
|
||||||
u.uhp += hpinc;
|
u.uhp += hpinc;
|
||||||
setuhpmax(u.uhpmax + hpinc); /* will lower u.uhp if it exceeds uhpmax */
|
setuhpmax(u.uhpmax + hpinc, TRUE); /* will lower u.uhp if it exceeds
|
||||||
|
* u.uhpmax */
|
||||||
|
|
||||||
/* increase spell power/energy points */
|
/* increase spell power/energy points */
|
||||||
eninc = newpw();
|
eninc = newpw();
|
||||||
|
|||||||
+2
-1
@@ -392,9 +392,10 @@ touch_of_death(struct monst *mtmp)
|
|||||||
} else {
|
} else {
|
||||||
/* HP manipulation similar to poisoned(attrib.c) */
|
/* HP manipulation similar to poisoned(attrib.c) */
|
||||||
int olduhp = u.uhp,
|
int olduhp = u.uhp,
|
||||||
|
uhpmin = minuhpmax(3),
|
||||||
newuhpmax = u.uhpmax - drain;
|
newuhpmax = u.uhpmax - drain;
|
||||||
|
|
||||||
setuhpmax(max(newuhpmax, minuhpmax(3)));
|
setuhpmax(max(newuhpmax, uhpmin), FALSE);
|
||||||
dmg = adjuhploss(dmg, olduhp); /* reduce pending damage if uhp has
|
dmg = adjuhploss(dmg, olduhp); /* reduce pending damage if uhp has
|
||||||
* already been reduced due to drop
|
* already been reduced due to drop
|
||||||
* in uhpmax */
|
* in uhpmax */
|
||||||
|
|||||||
+1
-1
@@ -383,7 +383,7 @@ newman(void)
|
|||||||
hpmax = u.ulevel; /* min of 1 HP per level */
|
hpmax = u.ulevel; /* min of 1 HP per level */
|
||||||
/* retain same proportion for current HP; u.uhp * hpmax / u.uhpmax */
|
/* retain same proportion for current HP; u.uhp * hpmax / u.uhpmax */
|
||||||
u.uhp = rounddiv((long) u.uhp * (long) hpmax, u.uhpmax);
|
u.uhp = rounddiv((long) u.uhp * (long) hpmax, u.uhpmax);
|
||||||
u.uhpmax = hpmax;
|
setuhpmax(hpmax, TRUE); /* might reduce u.uhp */
|
||||||
/*
|
/*
|
||||||
* Do the same for spell power.
|
* Do the same for spell power.
|
||||||
*/
|
*/
|
||||||
|
|||||||
+6
-9
@@ -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, maxhp, polyd = NON_PM;
|
int i, maxhp;
|
||||||
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",
|
||||||
@@ -420,19 +420,16 @@ fix_worst_trouble(int trouble)
|
|||||||
You_feel("much better.");
|
You_feel("much better.");
|
||||||
if (Upolyd) {
|
if (Upolyd) {
|
||||||
maxhp = u.mhmax + rnd(5);
|
maxhp = u.mhmax + rnd(5);
|
||||||
setuhpmax(max(maxhp, 5 + 1));
|
setuhpmax(max(maxhp, 5 + 1), FALSE); /* acts as setmhmax() */
|
||||||
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 */
|
|
||||||
}
|
}
|
||||||
maxhp = u.uhpmax;
|
maxhp = u.uhpmax;
|
||||||
if (maxhp < u.ulevel * 5 + 11)
|
if (maxhp < u.ulevel * 5 + 11)
|
||||||
maxhp += rnd(5);
|
maxhp += rnd(5);
|
||||||
setuhpmax(max(maxhp, 5 + 1));
|
/* True: update u.uhpmax even if currently poly'd */
|
||||||
u.uhp = u.uhpmax;
|
setuhpmax(max(maxhp, 5 + 1), TRUE);
|
||||||
if (polyd != NON_PM)
|
u.uhp = u.uhpmax; /* setuhpmax() will do this when u.uhp is higher
|
||||||
u.umonnum = polyd; /* restore Upolyd */
|
* than u.uhpmax; prayer also does this if lower */
|
||||||
disp.botl = TRUE;
|
disp.botl = TRUE;
|
||||||
break;
|
break;
|
||||||
case TROUBLE_COLLAPSING:
|
case TROUBLE_COLLAPSING:
|
||||||
|
|||||||
+1
-1
@@ -4154,7 +4154,7 @@ dofiretrap(
|
|||||||
u.uhpmax -= rn2(min(u.uhpmax, num + 1)), disp.botl = TRUE;
|
u.uhpmax -= rn2(min(u.uhpmax, num + 1)), disp.botl = TRUE;
|
||||||
} /* note: no 'else' here */
|
} /* note: no 'else' here */
|
||||||
if (u.uhpmax < uhpmin) {
|
if (u.uhpmax < uhpmin) {
|
||||||
setuhpmax(min(olduhpmax, uhpmin)); /* sets disp.botl */
|
setuhpmax(min(olduhpmax, uhpmin), FALSE); /* sets disp.botl */
|
||||||
if (!Drain_resistance)
|
if (!Drain_resistance)
|
||||||
losexp(NULL); /* never fatal when 'drainer' is Null */
|
losexp(NULL); /* never fatal when 'drainer' is Null */
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-2
@@ -444,16 +444,17 @@ wiz_flip_level(void)
|
|||||||
int
|
int
|
||||||
wiz_level_change(void)
|
wiz_level_change(void)
|
||||||
{
|
{
|
||||||
char buf[BUFSZ] = DUMMY;
|
char buf[BUFSZ], dummy = '\0';
|
||||||
int newlevel = 0;
|
int newlevel = 0;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
buf[0] = '\0'; /* in case EDIT_GETLIN is enabled */
|
||||||
getlin("To what experience level do you want to be set?", buf);
|
getlin("To what experience level do you want to be set?", buf);
|
||||||
(void) mungspaces(buf);
|
(void) mungspaces(buf);
|
||||||
if (buf[0] == '\033' || buf[0] == '\0')
|
if (buf[0] == '\033' || buf[0] == '\0')
|
||||||
ret = 0;
|
ret = 0;
|
||||||
else
|
else
|
||||||
ret = sscanf(buf, "%d", &newlevel);
|
ret = sscanf(buf, "%d%c", &newlevel, &dummy);
|
||||||
|
|
||||||
if (ret != 1) {
|
if (ret != 1) {
|
||||||
pline1(Never_mind);
|
pline1(Never_mind);
|
||||||
@@ -480,6 +481,7 @@ wiz_level_change(void)
|
|||||||
while (u.ulevel < newlevel)
|
while (u.ulevel < newlevel)
|
||||||
pluslvl(FALSE);
|
pluslvl(FALSE);
|
||||||
}
|
}
|
||||||
|
/* blessed full healing or restore ability won't fix any lost levels */
|
||||||
u.ulevelmax = u.ulevel;
|
u.ulevelmax = u.ulevel;
|
||||||
return ECMD_OK;
|
return ECMD_OK;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user