void pluslvl(boolean incr) /* true iff via incremental experience growth */ { /* (false for potion of gain level) */ register int num; if (!incr) You_feel("more experienced."); num = newhp(); u.uhpmax += num; u.uhp += num; if (Upolyd) { num = rnd(8); u.mhmax += num; u.mh += num; } if (u.ulevel < urole.xlev) num = rn1((int)ACURR(A_WIS)/2 + urole.enadv.lornd + urace.enadv.lornd, urole.enadv.lofix + urace.enadv.lofix); else num = rn1((int)ACURR(A_WIS)/2 + urole.enadv.hirnd + urace.enadv.hirnd, urole.enadv.hifix + urace.enadv.hifix); num = enermod(num); /* M. Stephenson */ if (!Role_if(PM_TOURIST)) { /* Tourists have no innate magic abilities */ u.uenmax += num; u.uen += num; } if (u.ulevel < MAXULEV) { if (incr) { long tmp = newuexp(u.ulevel + 1); if (u.uexp >= tmp) u.uexp = tmp - 1; } else { u.uexp = newuexp(u.ulevel); } ++u.ulevel; if (u.ulevelmax < u.ulevel) u.ulevelmax = u.ulevel; pline("Welcome to experience level %d.", u.ulevel); adjabil(u.ulevel - 1, u.ulevel); /* give new intrinsics */ reset_rndmonst(NON_PM); /* new monster selection */ } flags.botl = 1; }
void losexp(const char *drainer) /* e.g., hit by drain life attack */ /* cause of death, if drain should be fatal */ { register int num; #ifdef WIZARD /* override life-drain resistance when handling an explicit wizard mode request to reduce level; never fatal though */ if (drainer && !strcmp(drainer, "#levelchange")) drainer = 0; else #endif if (resists_drli(&youmonst)) return; if (u.ulevel > 1) { pline("%s level %d.", Goodbye(), u.ulevel--); /* remove intrinsic abilities */ adjabil(u.ulevel + 1, u.ulevel); reset_rndmonst(NON_PM); /* new monster selection */ } else { if (drainer) { killer_format = KILLED_BY; killer = drainer; done(DIED); } /* no drainer or lifesaved */ u.uexp = 0; } num = newhp(); u.uhpmax -= num; check_uhpmax(); if (u.uhpmax < 1) u.uhpmax = 1; u.uhp -= num; if (u.uhp < 1) u.uhp = 1; else if (u.uhp > u.uhpmax) u.uhp = u.uhpmax; if (u.ulevel < urole.xlev) num = rn1((int)ACURR(A_WIS)/2 + urole.enadv.lornd + urace.enadv.lornd, urole.enadv.lofix + urace.enadv.lofix); else num = rn1((int)ACURR(A_WIS)/2 + urole.enadv.hirnd + urace.enadv.hirnd, urole.enadv.hifix + urace.enadv.hifix); num = enermod(num); /* M. Stephenson */ u.uenmax -= num; if (u.uenmax < 0) u.uenmax = 0; u.uen -= num; if (u.uen < 0) u.uen = 0; else if (u.uen > u.uenmax) u.uen = u.uenmax; if (u.uexp > 0) u.uexp = newuexp(u.ulevel) - 1; flags.botl = 1; }
void pluslvl() { int num; pline("You feel more experienced."); num = rnd(10); u.uhpmax += num; u.uhp += num; if(u.ulevel < 14) { u.uexp = newuexp()+1; pline("Welcome to experience level %u.", ++u.ulevel); } 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(boolean gaining) /* gaining XP via potion vs setting XP for polyself */ { 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; 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; }
/* * Make experience gaining similar to AD&D(tm), whereby you can at most go * up by one level at a time, extra expr possibly helping you along. * After all, how much real experience does one get shooting a wand of death * at a dragon created with a wand of polymorph?? */ void newexplevel(void) { if (u.ulevel < MAXULEV && u.uexp >= newuexp(u.ulevel)) pluslvl(TRUE); }