MCPcopy Create free account
hub / github.com/NetHack/NetHack / newpw

Function newpw

src/exper.c:44–81  ·  view source on GitHub ↗

calculate spell power/energy points for new level */

Source from the content-addressed store, hash-verified

42
43/* calculate spell power/energy points for new level */
44int
45newpw(void)
46{
47 int en = 0, enrnd, enfix;
48
49 if (u.ulevel == 0) {
50 en = gu.urole.enadv.infix + gu.urace.enadv.infix;
51 if (gu.urole.enadv.inrnd > 0)
52 en += rnd(gu.urole.enadv.inrnd);
53 if (gu.urace.enadv.inrnd > 0)
54 en += rnd(gu.urace.enadv.inrnd);
55 } else {
56 enrnd = (int) ACURR(A_WIS) / 2;
57 if (u.ulevel < gu.urole.xlev) {
58 enrnd += gu.urole.enadv.lornd + gu.urace.enadv.lornd;
59 enfix = gu.urole.enadv.lofix + gu.urace.enadv.lofix;
60 } else {
61 enrnd += gu.urole.enadv.hirnd + gu.urace.enadv.hirnd;
62 enfix = gu.urole.enadv.hifix + gu.urace.enadv.hifix;
63 }
64 en = enermod(rn1(enrnd, enfix));
65 }
66 if (en <= 0)
67 en = 1;
68 if (u.ulevel < MAXULEV) {
69 /* remember increment; future level drain could take it away again */
70 u.ueninc[u.ulevel] = (xint16) en;
71 } else {
72 /* after level 30, throttle energy gains from extra experience;
73 once max reaches 600, further increments will be just 1 more */
74 char lim = 4 - u.uenmax / 200;
75
76 lim = max(lim, 1);
77 if (en > lim)
78 en = lim;
79 }
80 return en;
81}
82
83/* return # of exp points for mtmp after nk killed */
84int

Callers 3

pluslvlFunction · 0.85
newmanFunction · 0.85
u_init_miscFunction · 0.85

Calls 2

rndFunction · 0.85
enermodFunction · 0.85

Tested by

no test coverage detected