From: Michael Meyer Date: Tue, 4 Oct 2022 21:13:58 +0000 (-0400) Subject: Fix: 'weaken target' spell against poly'd hero... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4b32f8b3bd3ea146f2b058b70ca849ddfecd6488;p=nethack Fix: 'weaken target' spell against poly'd hero... ...could leave hero in creature form with negative u.mh losestr can subtract HP, but doesn't directly kill its target. The caller is responsible for possibly killing the hero if losestr reduces her HP to 0 or lower; most callers do this by combining losestr with a losehp call, which can kill off the hero if necessary. MGC_WEAKEN_YOU calls done_in_by if u.uhp < 1 after losestr, but didn't handle the Upolyd u.mh case, so could leave a polymorphed hero with negative health. Add a rehumanize call in that case. This could also be done by changing losestr to call losehp itself for the HP loss it deals out, but this would interfere with cast_wizard_spell's use of done_in_by to generate the death reason: either all strength loss is described one way ("terminal frailty" or something -- not great) or else losestr must be passed a death reason and is described a different way than other attack spells (because it wouldn't go through done_in_by). --- diff --git a/src/mcastu.c b/src/mcastu.c index 1179988cb..f83a38689 100644 --- a/src/mcastu.c +++ b/src/mcastu.c @@ -468,6 +468,8 @@ cast_wizard_spell(struct monst *mtmp, int dmg, int spellnum) losestr(rnd(dmg)); if (u.uhp < 1) done_in_by(mtmp, DIED); + else if (Upolyd && u.mh < 1) + rehumanize(); } dmg = 0; break;