| 304 | } |
| 305 | |
| 306 | void |
| 307 | pluslvl( |
| 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 |
no test coverage detected