]> granicus.if.org Git - nethack/commitdiff
praying for health (trunk only)
authornethack.rankin <nethack.rankin>
Sat, 25 Jun 2005 04:31:02 +0000 (04:31 +0000)
committernethack.rankin <nethack.rankin>
Sat, 25 Jun 2005 04:31:02 +0000 (04:31 +0000)
     Make it easier for a low level character with ordinary Max HP to get
the healing result from a successful prayer.  Mid level characters are the
same as before:  will be healed if at 1/7 (or worse) of max.  High level
characters, or anyone with Max HP really high for their level, will need
to wait until current HP is lower before being able to obtain that result.
This mainly affects spoilers; the actual impact for any player who doesn't
know the old formula is fairly small.  The exception is for "protection
racketeers" who manage to build up a high HP without gaining any levels;
a level 1 character will only get healed when at HP 5 or less, regardless
of what percentage of max their current hit points are.

     Under the old system you could get healed at 6 HP if you had 42, at
7 HP out of 49, and so forth.  Now you'll need to be at least level 2 to
get healed at 6 HP out of 30 or more, at least level 3 for 7-9 out of 35-45.
"Normal" max is capped at 15 times level and anyone above normal is treated
as if their max was that lesser normal value.  Levels 1 to 5 use a new
threshold of current HP being 1/5 (or worse) of max, levels 6-13 use 1/6,
14-21 retain old 1/7 threshold, 22-29 now use 1/8, and level 30 uses 1/9.
The somewhat odd level break points are based on where rank titles change.

doc/fixes35.0
include/extern.h
src/pray.c

index 15d49459cb3e0760365f6cc651b130319a152eb3..f2a1c41b12b9cc52a9b80791f425d4ae79c8e488 100644 (file)
@@ -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
index bed2f8e60d2f0ea067ed7cac3467ac5288b4bbeb..6623fdf608131b6b8f965dc5bd8fa7109aaedc5e 100644 (file)
@@ -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
index 26b83c3db97576aaba401c112dc522f8c3ea532d..3c5afb1a81804c95dc65d6f1f1507f5fb7014a31 100644 (file)
@@ -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);