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"
This commit is contained in:
Pasi Kallinen
2022-03-18 18:33:32 +02:00
parent 39acd095b2
commit 81ef433def

View File

@@ -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;
}