From 49f21769da5b2dd1d9832fabc4ccb1381ed6fad4 Mon Sep 17 00:00:00 2001 From: PatR Date: Tue, 7 Dec 2021 15:54:46 -0800 Subject: [PATCH] long worm growth again The previous change could have resulted in a long worm losing HP when gaining a segment (if it had gained levels while at the peak amount for the previous number of segments). I think this is finally right. --- src/worm.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/worm.c b/src/worm.c index 7455a1411..53561657d 100644 --- a/src/worm.c +++ b/src/worm.c @@ -214,7 +214,7 @@ worm_move(struct monst *worm) wheads[wnum] = new_seg; /* move the end pointer */ if (wgrowtime[wnum] <= g.moves) { - int whplimit, whpcap, wsegs = count_wsegs(worm); + int whplimit, whpcap, prev_mhp, wsegs = count_wsegs(worm); /* first set up for the next time to grow */ if (!wgrowtime[wnum]) { @@ -251,6 +251,7 @@ worm_move(struct monst *worm) if (whplimit > MHPMAX) whplimit = MHPMAX; + prev_mhp = worm->mhp; worm->mhp += d(2, 2); /* 2..4, average 3 */ whpcap = max(whplimit, worm->mhpmax); if (worm->mhp < whpcap) { @@ -258,7 +259,7 @@ worm_move(struct monst *worm) peak tail growth has already done so; when that isn't the case, if segment growth exceeds current max HP then increase it */ if (worm->mhp > whplimit) - worm->mhp = whplimit; + worm->mhp = max(prev_mhp, whplimit); if (worm->mhp > worm->mhpmax) worm->mhpmax = worm->mhp; } else {