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
-/* 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. */
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*/
-/* 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. */
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
-/* 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. */
/* 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.");