]> granicus.if.org Git - nethack/commitdiff
fix github issue #275 - artifact life drain
authorPatR <rankin@nethack.org>
Sun, 29 Dec 2019 23:30:55 +0000 (15:30 -0800)
committerPatR <rankin@nethack.org>
Sun, 29 Dec 2019 23:30:55 +0000 (15:30 -0800)
A monster using Stormbringer or Staff of Aesculapius to drain life
from another monster would heal the hero instead of the attacker.

doc/fixes37.0
src/artifact.c

index 7a40e905e0584a40ed0ff38783a62bda0db3a359..dc28569f4ff831fe7c953d9c230712d9f85bfd1f 100644 (file)
@@ -1,4 +1,4 @@
-$NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.35 $ $NHDT-Date: 1577190687 2019/12/24 12:31:27 $
+$NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.39 $ $NHDT-Date: 1577662238 2019/12/29 23:30:38 $
 
 General Fixes and Modified Features
 -----------------------------------
@@ -24,6 +24,8 @@ worn meat ring shouldn't cause increased hunger; neither should fake Amulet
 worn +0 ring of protection should cause increased hunger if it is the only
        source of extrinsic Protection
 fix accessing mons[-1] when monster figures out if a tin cures stoning
+monster wielding Stormbringer or healer's Staff against another monster would
+       heal the hero instead of the wielding monster when draining life
 
 
 Fixes to 3.7.0-x Problems that Were Exposed Via git Repository
index b0a81989de07429b520f15f904821b00f7e3038c..df2e0c65ef89344fce7fe2f91119bc0663bfc10c 100644 (file)
@@ -1,4 +1,4 @@
-/* NetHack 3.6 artifact.c      $NHDT-Date: 1553363416 2019/03/23 17:50:16 $  $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.129 $ */
+/* NetHack 3.6 artifact.c      $NHDT-Date: 1577662239 2019/12/29 23:30:39 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.152 $ */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /*-Copyright (c) Robert Patrick Rankin, 2013. */
 /* NetHack may be freely redistributed.  See license for details. */
@@ -1322,7 +1322,8 @@ int dieroll; /* needed for Magicbane and vorpal blades */
                     *dmgptr = 0;
                     return TRUE;
                 }
-                if (noncorporeal(g.youmonst.data) || amorphous(g.youmonst.data)) {
+                if (noncorporeal(g.youmonst.data)
+                    || amorphous(g.youmonst.data)) {
                     pline("%s slices through your %s.", wepdesc,
                           body_part(NECK));
                     return TRUE;
@@ -1351,6 +1352,7 @@ int dieroll; /* needed for Magicbane and vorpal blades */
                           mon_nam(mdef));
             }
             if (mdef->m_lev == 0) {
+                /* losing a level when at 0 is fatal */
                 *dmgptr = 2 * mdef->mhp + FATAL_DAMAGE_MODIFIER;
             } else {
                 int drain = monhp_per_lvl(mdef);
@@ -1359,8 +1361,16 @@ int dieroll; /* needed for Magicbane and vorpal blades */
                 mdef->mhpmax -= drain;
                 mdef->m_lev--;
                 drain /= 2;
-                if (drain)
-                    healup(drain, 0, FALSE, FALSE);
+                if (drain) {
+                    /* attacker heals in proportion to amount drained */
+                    if (youattack) {
+                        healup(drain, 0, FALSE, FALSE);
+                    } else {
+                        magr->mhp += drain;
+                        if (magr->mhp > magr->mhpmax)
+                            magr->mhp = magr->mhpmax;
+                    }
+                }
             }
             return vis;
         } else { /* youdefend */