]> granicus.if.org Git - nethack/commitdiff
fix #4279 - kicked daggers are lost
authorPatR <rankin@nethack.org>
Sat, 19 Mar 2016 21:47:36 +0000 (14:47 -0700)
committerPatR <rankin@nethack.org>
Sat, 19 Mar 2016 21:47:36 +0000 (14:47 -0700)
A kicked object which hits a monster wasn't placed back on map,
removing it from play.

doc/fixes36.1
src/dothrow.c

index 31655d3abb75bceac6652383874dfc8f4a762a94..6f5049a8c5ceb65ab8376a5e8eaef45a64753ecc 100644 (file)
@@ -190,6 +190,7 @@ some instances of stun or confusion timers were being overridden rather than
        incremented when new stun or confusion damage was suffered
 female gnome who gains level can grow up into male-only gnome lord; give an
        an alternate message instead of prohibiting the promotion
+kicked weapon which successfully hits monster vanishes from play
 
 
 Platform- and/or Interface-Specific Fixes
index bfec1303bb9573f1f87b5238c7b89121cabc5a6b..11e2b84bce2cd4b433f79347b90049c161976a55 100644 (file)
@@ -1364,8 +1364,9 @@ register struct obj *obj; /* thrownobj or kickedobj or uwep */
     int otyp = obj->otyp, hmode;
     boolean guaranteed_hit = (u.uswallow && mon == u.ustuck);
 
-    hmode = (obj == uwep) ? HMON_APPLIED : (obj == kickedobj) ? HMON_KICKED
-                                                              : HMON_THROWN;
+    hmode = (obj == uwep) ? HMON_APPLIED
+              : (obj == kickedobj) ? HMON_KICKED
+                : HMON_THROWN;
 
     /* Differences from melee weapons:
      *
@@ -1509,18 +1510,22 @@ register struct obj *obj; /* thrownobj or kickedobj or uwep */
         }
 
         if (tmp >= rnd(20)) {
+            boolean wasthrown = (thrownobj != 0);
+
+            /* attack hits mon */
             if (hmode == HMON_APPLIED)
                 u.uconduct.weaphit++;
             if (hmon(mon, obj, hmode)) { /* mon still alive */
                 cutworm(mon, bhitpos.x, bhitpos.y, obj);
             }
             exercise(A_DEX, TRUE);
-            /* if hero is swallowed and projectile kills the engulfer,
-               obj gets added to engulfer's inventory and then dropped,
+            /* if hero was swallowed and projectile killed the engulfer,
+               'obj' got added to engulfer's inventory and then dropped,
                so we can't safely use that pointer anymore; it escapes
                the chance to be used up here... */
-            if (!thrownobj)
+            if (wasthrown && !thrownobj)
                 return 1;
+
             /* projectiles other than magic stones
                sometimes disappear when thrown */
             if (objects[otyp].oc_skill < P_NONE
@@ -1531,6 +1536,7 @@ register struct obj *obj; /* thrownobj or kickedobj or uwep */
                  * but we need ammo to stay around longer on average.
                  */
                 int broken, chance;
+
                 chance = 3 + greatest_erosion(obj) - obj->spe;
                 if (chance > 1)
                     broken = rn2(chance);