]> granicus.if.org Git - nethack/commitdiff
B04002 - blessed gain level vs XL 30
authornethack.rankin <nethack.rankin>
Sat, 13 Jul 2002 12:19:09 +0000 (12:19 +0000)
committernethack.rankin <nethack.rankin>
Sat, 13 Jul 2002 12:19:09 +0000 (12:19 +0000)
     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.

doc/fixes34.1
include/extern.h
src/exper.c
src/polyself.c
src/potion.c

index 68b8c24d11c2ee755379862d9fa619a7e78b7bf1..9c88e1f207be5800ac1bbd5221686835dca20c70 100644 (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
index 335c4615e3842da169f9ada462289f86479def14..1e290ae028b745106b667130b6087addbd440341 100644 (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 ### */
 
index 37771a8bb77e3849346233cc43677cfec26450f1..932b2833a58b4a5552ecc2838d0e5ee7de80f3cd 100644 (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*/
index e080ba518966f0accaeac309a563902d2a276749..fb860ac755937eba47d7c914535fc263a402d4b8 100644 (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
index bbade3880c13dabc97d3e4cf9e70587d727f7e47..fe8726a096be679530f9bc966a2d06a11bb91429 100644 (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.");