From 81ef433def1807a317ac92787bbc9d0d876c106c Mon Sep 17 00:00:00 2001 From: Pasi Kallinen Date: Fri, 18 Mar 2022 18:33:32 +0200 Subject: [PATCH] Fix dmonsfree pending when hero was hit with drain-life artifact When a monster hit hero with an artifact with drain-life attack (Stormbringer or The Staff of Aesculapius), and hero lost a level and hero had more max hp in the lower xp level, the math made the attacker lose hp. This could put the monster hp in the negative, causing "dmonsfree: 1 removed doesn't match 0 pending" --- src/artifact.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/artifact.c b/src/artifact.c index 18d981b21..7e3ca12a2 100644 --- a/src/artifact.c +++ b/src/artifact.c @@ -1589,7 +1589,7 @@ artifact_hit(struct monst *magr, struct monst *mdef, struct obj *otmp, } losexp("life drainage"); if (magr && magr->mhp < magr->mhpmax) { - magr->mhp += (oldhpmax - u.uhpmax + 1) / 2; + magr->mhp += (abs(oldhpmax - u.uhpmax) + 1) / 2; if (magr->mhp > magr->mhpmax) magr->mhp = magr->mhpmax; }