Fix monster hp being above max hp

If the monster took damage from a fire trap, got killed, and then
lifesaved, the trap effect then reduced the map hp below the hp.
This commit is contained in:
Pasi Kallinen
2024-05-28 20:58:03 +03:00
parent 2ebbd13f79
commit 61e54c2a87
+4 -3
View File
@@ -1714,10 +1714,11 @@ trapeffect_fire_trap(
if (thitm(0, mtmp, (struct obj *) 0, num, immolate)) if (thitm(0, mtmp, (struct obj *) 0, num, immolate))
trapkilled = TRUE; trapkilled = TRUE;
else else {
/* we know mhp is at least `num' below mhpmax,
so no (mhp > mhpmax) check is needed here */
mtmp->mhpmax -= rn2(num + 1); mtmp->mhpmax -= rn2(num + 1);
if (mtmp->mhp > mtmp->mhpmax)
mtmp->mhp = mtmp->mhpmax;
}
} }
if (burnarmor(mtmp) || rn2(3)) { if (burnarmor(mtmp) || rn2(3)) {
int xtradmg = destroy_items(mtmp, AD_FIRE, orig_dmg); int xtradmg = destroy_items(mtmp, AD_FIRE, orig_dmg);