B04002 - blessed gain level vs XL 30

Fix the problem [reported in the newsgroup and forwarded by <Someone>]
of blessed potions of gain level having the possibility of reducing
your experience points if you were already level 30.  The random XP
value that averages "half way to next level" could be less than your
current experience if you had gotten to level 30 via such a blessed
potion or had drunk at least one of same since reaching that level.
This didn't really make any difference to game play since you weren't
losing any levels, HP, mana, or score, but it was visible to users who
enable the `showexp' option.
This commit is contained in:
nethack.rankin
2002-07-13 12:19:09 +00:00
parent ac764db56c
commit 30f6fbb5fe
5 changed files with 25 additions and 9 deletions

View File

@@ -155,6 +155,7 @@ steed movement would use your speed if walking step by step
kicking a known, unseen monster would sometimes leave behind an extra I symbol
applying a lance against a long worm could cause an impossible
a knight applying a lance did not do a caitiff check
blessed gain level when already at level 30 won't reduce experience points
Platform- and/or Interface-Specific Fixes

View File

@@ -577,7 +577,7 @@ E void FDECL(more_experienced, (int,int));
E void FDECL(losexp, (const char *));
E void NDECL(newexplevel);
E void FDECL(pluslvl, (BOOLEAN_P));
E long NDECL(rndexp);
E long FDECL(rndexp, (BOOLEAN_P));
/* ### explode.c ### */

View File

@@ -1,4 +1,4 @@
/* SCCS Id: @(#)exper.c 3.4 2002/06/23 */
/* SCCS Id: @(#)exper.c 3.4 2002/07/11 */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */
@@ -216,17 +216,32 @@ boolean incr; /* true iff via incremental experience growth */
flags.botl = 1;
}
/* compute a random amount of experience points suitable for the hero's
experience level: base number of points needed to reach the current
level plus a random portion of what it takes to get to the next level */
long
rndexp()
rndexp(gaining)
boolean gaining; /* gaining XP via potion vs setting XP for polyself */
{
long minexp, maxexp, diff, factor;
long minexp, maxexp, diff, factor, result;
minexp = (u.ulevel == 1) ? 0L : newuexp(u.ulevel - 1);
maxexp = newuexp(u.ulevel);
diff = maxexp - minexp, factor = 1L;
/* make sure that `diff' is an argument which rn2() can handle */
while (diff >= (long)LARGEST_INT)
diff /= 2L, factor *= 2L;
return minexp + factor * (long)rn2((int)diff);
result = minexp + factor * (long)rn2((int)diff);
/* 3.4.1: if already at level 30, add to current experience
points rather than to threshold needed to reach the current
level; otherwise blessed potions of gain level can result
in lowering the experience points instead of raising them */
if (u.ulevel == MAXULEV && gaining) {
result += (u.uexp - minexp);
/* avoid wrapping (over 400 blessed potions needed for that...) */
if (result < u.uexp) result = u.uexp;
}
return result;
}
/*exper.c*/

View File

@@ -1,4 +1,4 @@
/* SCCS Id: @(#)polyself.c 3.4 2002/06/23 */
/* SCCS Id: @(#)polyself.c 3.4 2002/07/11 */
/* Copyright (C) 1987, 1988, 1989 by Ken Arromdee */
/* NetHack may be freely redistributed. See license for details. */
@@ -159,7 +159,7 @@ newman()
reset_rndmonst(NON_PM); /* new monster generation criteria */
/* random experience points for the new experience level */
u.uexp = rndexp();
u.uexp = rndexp(FALSE);
/* u.uhpmax * u.ulevel / oldlvl: proportionate hit points to new level
* -10 and +10: don't apply proportionate HP to 10 of a starting

View File

@@ -1,4 +1,4 @@
/* SCCS Id: @(#)potion.c 3.4 2002/03/23 */
/* SCCS Id: @(#)potion.c 3.4 2002/07/11 */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */
@@ -770,7 +770,7 @@ peffects(otmp)
/* blessed potions place you at a random spot in the
* middle of the new level instead of the low point
*/
u.uexp = rndexp();
u.uexp = rndexp(TRUE);
break;
case POT_HEALING:
You_feel("better.");