From 61e54c2a878d192e2c11f22b16ebfd35957e891d Mon Sep 17 00:00:00 2001 From: Pasi Kallinen Date: Tue, 28 May 2024 20:58:00 +0300 Subject: [PATCH] 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. --- src/trap.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/trap.c b/src/trap.c index f0c7e63a4..a7d2a1f48 100644 --- a/src/trap.c +++ b/src/trap.c @@ -1714,10 +1714,11 @@ trapeffect_fire_trap( if (thitm(0, mtmp, (struct obj *) 0, num, immolate)) trapkilled = TRUE; - else - /* we know mhp is at least `num' below mhpmax, - so no (mhp > mhpmax) check is needed here */ + else { mtmp->mhpmax -= rn2(num + 1); + if (mtmp->mhp > mtmp->mhpmax) + mtmp->mhp = mtmp->mhpmax; + } } if (burnarmor(mtmp) || rn2(3)) { int xtradmg = destroy_items(mtmp, AD_FIRE, orig_dmg);