MCPcopy Index your code
hub / github.com/NetHack/NetHack / pluslvl

Function pluslvl

src/exper.c:306–372  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

304}
305
306void
307pluslvl(
308 boolean incr) /* True: incremental experience growth;
309 * False: potion of gain level or wraith corpse
310 * or wizard mode #levelchange */
311{
312 int hpinc, eninc;
313
314 if (!incr)
315 You_feel("more experienced.");
316
317 /* increase hit points (when polymorphed, do monster form first
318 in order to retain normal human/whatever increase for later) */
319 if (Upolyd) {
320 hpinc = monhp_per_lvl(&gy.youmonst);
321 u.mh += hpinc;
322 setuhpmax(u.mhmax, FALSE); /* acts as setmhmax() when Upolyd */
323 }
324 hpinc = newhp();
325 u.uhp += hpinc;
326 setuhpmax(u.uhpmax + hpinc, TRUE); /* will lower u.uhp if it exceeds
327 * u.uhpmax */
328
329 /* increase spell power/energy points */
330 eninc = newpw();
331 u.uenmax += eninc;
332 if (u.uenmax > u.uenpeak)
333 u.uenpeak = u.uenmax;
334 u.uen += eninc;
335
336 /* increase level (unless already maxxed) */
337 if (u.ulevel < MAXULEV) {
338 int old_ach_cnt, newrank, oldrank = xlev_to_rank(u.ulevel);
339
340 /* increase experience points to reflect new level */
341 if (incr) {
342 long tmp = newuexp(u.ulevel + 1);
343
344 if (u.uexp >= tmp)
345 u.uexp = tmp - 1;
346 } else {
347 u.uexp = newuexp(u.ulevel);
348 }
349 ++u.ulevel;
350 pline("Welcome %sto experience level %d.",
351 (u.ulevelmax < u.ulevel) ? "" : "back ",
352 u.ulevel);
353 if (u.ulevelmax < u.ulevel)
354 u.ulevelmax = u.ulevel;
355 adjabil(u.ulevel - 1, u.ulevel); /* give new intrinsics */
356 SoundAchievement(0, sa2_xplevelup, 0);
357 old_ach_cnt = count_achievements();
358 newrank = xlev_to_rank(u.ulevel);
359 if (newrank > oldrank)
360 record_achievement(achieve_rank(newrank));
361 /* a new rank achievement will log its own message; log a simpler
362 message here if we didn't just get an achievement (so when rank
363 hasn't changed or hero just regained a lost level and the rank

Callers 8

newexplevelFunction · 0.85
peffect_restore_abilityFunction · 0.85
peffect_gain_levelFunction · 0.85
peffect_full_healingFunction · 0.85
pleasedFunction · 0.85
wiz_level_changeFunction · 0.85
cpostfxFunction · 0.85
doseduceFunction · 0.85

Calls 13

You_feelFunction · 0.85
monhp_per_lvlFunction · 0.85
setuhpmaxFunction · 0.85
newhpFunction · 0.85
newpwFunction · 0.85
xlev_to_rankFunction · 0.85
newuexpFunction · 0.85
adjabilFunction · 0.85
count_achievementsFunction · 0.85
record_achievementFunction · 0.85
achieve_rankFunction · 0.85
livelog_printfFunction · 0.85

Tested by

no test coverage detected