diff --git a/doc/fixes35.0 b/doc/fixes35.0 index 15d49459c..f2a1c41b1 100644 --- a/doc/fixes35.0 +++ b/doc/fixes35.0 @@ -83,6 +83,7 @@ dipping in acid can erode the dipped object various actions--such as enchanting--performed on an unpaid shop object either force the hero to buy the item (when its value is lowered) or increase the current bill (when its value is raised) +adjust health threshold where wounded hero will be healed by successful prayer Platform- and/or Interface-Specific Fixes diff --git a/include/extern.h b/include/extern.h index bed2f8e60..6623fdf60 100644 --- a/include/extern.h +++ b/include/extern.h @@ -1636,6 +1636,7 @@ E const char *NDECL(bottlename); /* ### pray.c ### */ +E boolean FDECL(critically_low_hp, (BOOLEAN_P)); #ifdef USE_TRAMPOLI E int NDECL(prayer_done); #endif diff --git a/src/pray.c b/src/pray.c index 26b83c3db..3c5afb1a8 100644 --- a/src/pray.c +++ b/src/pray.c @@ -1,4 +1,4 @@ -/* SCCS Id: @(#)pray.c 3.5 2005/06/21 */ +/* SCCS Id: @(#)pray.c 3.5 2005/06/24 */ /* Copyright (c) Benson I. Margulies, Mike Stephenson, Steve Linhart, 1989. */ /* NetHack may be freely redistributed. See license for details. */ @@ -116,6 +116,34 @@ but that's really hard. #define on_shrine() ((levl[u.ux][u.uy].altarmask & AM_SHRINE) != 0) #define a_align(x,y) ((aligntyp)Amask2align(levl[x][y].altarmask & AM_MASK)) +/* criticially low hit points if hp <= 5 or hp <= maxhp/N for some N */ +boolean +critically_low_hp(only_if_injured) +boolean only_if_injured; /* determines whether maxhp <= 5 matters */ +{ + int divisor, hplim, + curhp = Upolyd ? u.mh : u.uhp, + maxhp = Upolyd ? u.mhmax : u.uhpmax; + + if (only_if_injured && !(curhp < maxhp)) return FALSE; + /* if maxhp is extremely high, use lower threshold for the division test + (golden glow cuts off at 11+5*lvl, nurse interaction at 25*lvl; this + ought to use monster hit dice--and a smaller multiplier--rather than + ulevel when polymorphed, but polyself doesn't maintain that) */ + hplim = 15 * u.ulevel; + if (maxhp > hplim) maxhp = hplim; + /* 7 used to be the unconditional divisor */ + switch (xlev_to_rank(u.ulevel)) { /* maps 1..30 into 0..8 */ + case 0: case 1: divisor = 5; break; /* explvl 1 to 5 */ + case 2: case 3: divisor = 6; break; /* explvl 6 to 13 */ + case 4: case 5: divisor = 7; break; /* explvl 14 to 21 */ + case 6: case 7: divisor = 8; break; /* explvl 22 to 29 */ + default: divisor = 9; break; /* explvl 30+ */ + } + /* 5 is a magic number in TROUBLE_HIT handling below */ + return (curhp <= 5 || curhp * divisor <= maxhp); +} + STATIC_OVL int in_trouble() { @@ -141,8 +169,7 @@ in_trouble() if(u.utrap && u.utraptype == TT_LAVA) return(TROUBLE_LAVA); if(Sick) return(TROUBLE_SICK); if(u.uhs >= WEAK) return(TROUBLE_STARVING); - if (Upolyd ? (u.mh <= 5 || u.mh*7 <= u.mhmax) : - (u.uhp <= 5 || u.uhp*7 <= u.uhpmax)) return TROUBLE_HIT; + if (critically_low_hp(FALSE)) return TROUBLE_HIT; if(u.ulycn >= LOW_PM) return(TROUBLE_LYCANTHROPE); if(near_capacity() >= EXT_ENCUMBER && AMAX(A_STR)-ABASE(A_STR) > 3) return(TROUBLE_COLLAPSING);