]> granicus.if.org Git - nethack/commitdiff
hitting and mhurtle
authorcohrs <cohrs>
Fri, 23 Aug 2002 05:47:54 +0000 (05:47 +0000)
committercohrs <cohrs>
Fri, 23 Aug 2002 05:47:54 +0000 (05:47 +0000)
Fix part of the buglist entry regarding hitting and mhurtle.  Flag if
mhurtle already killed the monster, and don't call killed again in this case.
One of the new checks for this already_killed flag is just futureproofing.

doc/fixes34.1
src/uhitm.c

index ff63e304c96f780edccf7b5a6627e777c312372d..7644ba07563a88619fc64fd9353474e70a8c4d02 100644 (file)
@@ -223,6 +223,7 @@ don't let monster end up with more current HP than max HP after life drain
 make sure that missing file trickery in wizard mode which is discovered during
        level change doesn't try to keep going after discarding current level
 contribution by Adam Wozniak adds several const & changes some char* to char[]
+fix impossible when hitting/jousting a monster causes it to be killed twice
 
 
 Platform- and/or Interface-Specific Fixes
index 5ae9e201b4017aca410873e3f2ca94b94cd6f3f1..4e1c1142f91a27a8f8688cb884bfff0cf6329e2e 100644 (file)
@@ -508,7 +508,7 @@ int thrown;
         * associated with the damage don't come out until _after_ outputting
         * a hit message.
         */
-       boolean hittxt = FALSE, destroyed = FALSE;
+       boolean hittxt = FALSE, destroyed = FALSE, already_killed = FALSE;
        boolean get_dmg_bonus = TRUE;
        boolean ispoisoned = FALSE, needpoismsg = FALSE, poiskilled = FALSE;
        boolean silvermsg = FALSE;
@@ -911,8 +911,10 @@ int thrown;
            You("joust %s%s",
                         mon_nam(mon), canseemon(mon) ? exclam(tmp) : ".");
            /* avoid migrating a dead monster */
-           if (mon->mhp > tmp)
+           if (mon->mhp > tmp) {
                mhurtle(mon, u.dx, u.dy, 1);
+               if (DEADMONSTER(mon)) already_killed = TRUE;
+           }
            hittxt = TRUE;
        } else
 #endif
@@ -925,13 +927,15 @@ int thrown;
                    pline("%s %s from your powerful strike!", Monnam(mon),
                          makeplural(stagger(mon->data, "stagger")));
                /* avoid migrating a dead monster */
-               if (mon->mhp > tmp)
+               if (mon->mhp > tmp) {
                    mhurtle(mon, u.dx, u.dy, 1);
+                   if (DEADMONSTER(mon)) already_killed = TRUE;
+               }
                hittxt = TRUE;
            }
        }
 
-       mon->mhp -= tmp;
+       if (!already_killed) mon->mhp -= tmp;
        /* adjustments might have made tmp become less than what
           a level draining artifact has already done to max HP */
        if (mon->mhp > mon->mhpmax) mon->mhp = mon->mhpmax;
@@ -985,10 +989,11 @@ int thrown;
                pline_The("poison doesn't seem to affect %s.", mon_nam(mon));
        if (poiskilled) {
                pline_The("poison was deadly...");
-               xkilled(mon, 0);
+               if (!already_killed) xkilled(mon, 0);
                return FALSE;
        } else if (destroyed) {
-               killed(mon);    /* takes care of most messages */
+               if (!already_killed)
+                   killed(mon);        /* takes care of most messages */
        } else if(u.umconf && !thrown) {
                nohandglow(mon);
                if(!mon->mconf && !resist(mon, '+', 0, NOTELL)) {