Move Pw regen into separate routine

This commit is contained in:
Pasi Kallinen
2021-09-18 20:23:20 +03:00
parent 74a0ede6d9
commit 2dce29e965

View File

@@ -17,6 +17,7 @@ static void u_calc_moveamt(int);
#ifdef POSITIONBAR
static void do_positionbar(void);
#endif
static void regen_pw(int);
static void regen_hp(int);
static void interrupt_multi(const char *);
static void debug_fields(const char *);
@@ -258,19 +259,7 @@ moveloop_core(void)
}
}
if (u.uen < u.uenmax
&& ((mvl_wtcap < MOD_ENCUMBER
&& (!(g.moves % ((MAXULEV + 8 - u.ulevel)
* (Role_if(PM_WIZARD) ? 3 : 4)
/ 6)))) || Energy_regeneration)) {
u.uen += rn1(
(int) (ACURR(A_WIS) + ACURR(A_INT)) / 15 + 1, 1);
if (u.uen > u.uenmax)
u.uen = u.uenmax;
g.context.botl = TRUE;
if (u.uen == u.uenmax)
interrupt_multi("You feel full of energy.");
}
regen_pw(mvl_wtcap);
if (!u.uinvulnerable) {
if (Teleportation && !rn2(85)) {
@@ -506,6 +495,25 @@ moveloop(boolean resuming)
}
}
static void
regen_pw(int wtcap)
{
if (u.uen < u.uenmax
&& ((wtcap < MOD_ENCUMBER
&& (!(g.moves % ((MAXULEV + 8 - u.ulevel)
* (Role_if(PM_WIZARD) ? 3 : 4)
/ 6)))) || Energy_regeneration)) {
int upper = (int) (ACURR(A_WIS) + ACURR(A_INT)) / 15 + 1;
u.uen += rn1(upper, 1);
if (u.uen > u.uenmax)
u.uen = u.uenmax;
g.context.botl = TRUE;
if (u.uen == u.uenmax)
interrupt_multi("You feel full of energy.");
}
}
#define U_CAN_REGEN() (Regeneration || (Sleepy && u.usleep))
/* maybe recover some lost health (or lose some when an eel out of water) */