From: Pasi Kallinen Date: Thu, 29 Oct 2020 17:14:28 +0000 (+0200) Subject: Restful sleep regenerates hp X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=91c46ab54b08556c9561e3cdb2e01fa2e56a9f27;p=nethack Restful sleep regenerates hp When sleeping due to wearing an amulet of restful sleep, hit points will regenerate, one point faster than with normal regeneration. --- diff --git a/doc/fixes37.0 b/doc/fixes37.0 index a46b9c1c1..8814aa28c 100644 --- a/doc/fixes37.0 +++ b/doc/fixes37.0 @@ -287,6 +287,7 @@ hero poly'd into rust monster could implicitly eat bars when adjacent by trying to move there, now when in rock mole form too; in xorn form can explicitly eat them via 'e' after moving onto their spot monster hiding under an egg that hatched was kept hidden +restful sleep regenerates hit points Fixes to 3.7.0-x Problems that Were Exposed Via git Repository diff --git a/src/allmain.c b/src/allmain.c index eb17b82e0..a11919b85 100644 --- a/src/allmain.c +++ b/src/allmain.c @@ -471,6 +471,8 @@ boolean resuming; } } +#define U_CAN_REGEN() (Regeneration || (Sleepy && u.usleep)) + /* maybe recover some lost health (or lose some when an eel out of water) */ static void regen_hp(wtcap) @@ -491,7 +493,7 @@ int wtcap; && (!Half_physical_damage || !(g.moves % 2L))) heal = -1; } else if (u.mh < u.mhmax) { - if (Regeneration || (encumbrance_ok && !(g.moves % 20L))) + if (U_CAN_REGEN() || (encumbrance_ok && !(g.moves % 20L))) heal = 1; } if (heal) { @@ -506,7 +508,7 @@ int wtcap; no !Upolyd check here, so poly'd hero recovered lost u.uhp once u.mh reached u.mhmax; that may have been convenient for the player, but it didn't make sense for gameplay...] */ - if (u.uhp < u.uhpmax && (encumbrance_ok || Regeneration)) { + if (u.uhp < u.uhpmax && (encumbrance_ok || U_CAN_REGEN())) { if (u.ulevel > 9) { if (!(g.moves % 3L)) { int Con = (int) ACURR(A_CON); @@ -523,8 +525,10 @@ int wtcap; if (!(g.moves % (long) ((MAXULEV + 12) / (u.ulevel + 2) + 1))) heal = 1; } - if (Regeneration && !heal) + if (U_CAN_REGEN() && !heal) heal = 1; + if (Sleepy && u.usleep) + heal++; if (heal) { g.context.botl = TRUE; @@ -541,6 +545,8 @@ int wtcap; interrupt_multi("You are in full health."); } +#undef U_CAN_REGEN + void stop_occupation() {