]> granicus.if.org Git - nethack/commitdiff
Fix: 'weaken target' spell against poly'd hero...
authorMichael Meyer <me@entrez.cc>
Tue, 4 Oct 2022 21:13:58 +0000 (17:13 -0400)
committerPatR <rankin@nethack.org>
Sat, 8 Oct 2022 23:29:54 +0000 (16:29 -0700)
...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).

src/mcastu.c

index 1179988cba5337ab10a78d365d90446670af3eae..f83a38689dce909ffa202092e5c5ac7b48e30ec3 100644 (file)
@@ -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;