From: PatR Date: Sat, 19 Mar 2016 21:47:36 +0000 (-0700) Subject: fix #4279 - kicked daggers are lost X-Git-Tag: NetHack-3.6.1_RC01~864 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=96dd8003016d1229987a684e0233dea5022750cc;p=nethack fix #4279 - kicked daggers are lost A kicked object which hits a monster wasn't placed back on map, removing it from play. --- diff --git a/doc/fixes36.1 b/doc/fixes36.1 index 31655d3ab..6f5049a8c 100644 --- a/doc/fixes36.1 +++ b/doc/fixes36.1 @@ -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 diff --git a/src/dothrow.c b/src/dothrow.c index bfec1303b..11e2b84bc 100644 --- a/src/dothrow.c +++ b/src/dothrow.c @@ -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);