]> granicus.if.org Git - nethack/commitdiff
fix #H4475 - shop message about disenchanted item
authorPatR <rankin@nethack.org>
Wed, 10 Aug 2016 09:04:09 +0000 (02:04 -0700)
committerPatR <rankin@nethack.org>
Wed, 10 Aug 2016 09:04:09 +0000 (02:04 -0700)
drain_item() always assumed player was responsible, so called
costly_alteration() to adjust shop price of disenchanted item.
If it was unpaid and the effect was caused by a disenchanter
attack rather than by the hero, the feedback was nonsensical.

This also lets a disenchanter hit worn rings, amulet, or blindfold
if no armor gets targetted.  Amulets, blindfolds, and most rings
have no charge to be drained, but several types of rings do.

doc/fixes36.1
include/extern.h
src/mhitm.c
src/mhitu.c
src/uhitm.c
src/zap.c

index d1bf9973ad65354e7e0b3c030e04e1ed9f761719..d827071aeb7338dbde375b3c81cae9ba2f35eb06 100644 (file)
@@ -329,6 +329,8 @@ eating the corpse of a unique non-named monster (Wizard of Yendor, Oracle,
 when escaping the dungeon, change "you were here" annotation in dungeon
        overview to "you left from here"
 option parsing will crash if 'playmode' option is present without a value
+any item drained of enchantment was blamed on the player as far as shop
+       billing was concerned, even if caused by disenchanter attack
 
 
 Fixes to Post-3.6.0 Problems that Were Exposed Via git Repository
index 4781d1b9c5e33450d5bfcaace80b1d29b53c0f6b..0865432879112f98b6c7e0431b9be7aa82c5c666 100644 (file)
@@ -1,4 +1,4 @@
-/* NetHack 3.6 extern.h        $NHDT-Date: 1461967848 2016/04/29 22:10:48 $  $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.558 $ */
+/* NetHack 3.6 extern.h        $NHDT-Date: 1470819839 2016/08/10 09:03:59 $  $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.569 $ */
 /* Copyright (c) Steve Creps, 1988.                              */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -2771,7 +2771,7 @@ E struct monst *FDECL(montraits, (struct obj *, coord *));
 E struct monst *FDECL(revive, (struct obj *, BOOLEAN_P));
 E int FDECL(unturn_dead, (struct monst *));
 E void FDECL(cancel_item, (struct obj *));
-E boolean FDECL(drain_item, (struct obj *));
+E boolean FDECL(drain_item, (struct obj *, BOOLEAN_P));
 E struct obj *FDECL(poly_obj, (struct obj *, int));
 E boolean FDECL(obj_resists, (struct obj *, int, int));
 E boolean FDECL(obj_shudders, (struct obj *));
index e92b6e2873f9f1026b8d0a6e00988ec0eee01b47..9836136a17abdb161e78c36b54f350370a8c0fe3 100644 (file)
@@ -1,4 +1,4 @@
-/* NetHack 3.6 mhitm.c $NHDT-Date: 1456992461 2016/03/03 08:07:41 $  $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.86 $ */
+/* NetHack 3.6 mhitm.c $NHDT-Date: 1470819842 2016/08/10 09:04:02 $  $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.92 $ */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -1524,7 +1524,7 @@ int mdead;
         goto assess_dmg;
     case AD_ENCH: /* KMH -- remove enchantment (disenchanter) */
         if (mhit && !mdef->mcan && otmp) {
-            (void) drain_item(otmp);
+            (void) drain_item(otmp, FALSE);
             /* No message */
         }
         break;
index e07718fdac7499b53e2250f4c3f987d78e29ad25..1cdd7bce72cc9d97a10e76a025071e78409c4691 100644 (file)
@@ -1,4 +1,4 @@
-/* NetHack 3.6 mhitu.c $NHDT-Date: 1456992469 2016/03/03 08:07:49 $  $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.136 $ */
+/* NetHack 3.6 mhitu.c $NHDT-Date: 1470819843 2016/08/10 09:04:03 $  $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.144 $ */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -1597,7 +1597,27 @@ register struct attack *mattk;
         if (uncancelled) {
             struct obj *obj = some_armor(&youmonst);
 
-            if (drain_item(obj)) {
+            if (!obj) {
+                /* some rings are susceptible;
+                   amulets and blindfolds aren't (at present) */
+                switch (rn2(5)) {
+                case 0:
+                    break;
+                case 1:
+                    obj = uright;
+                    break;
+                case 2:
+                    obj = uleft;
+                    break;
+                case 3:
+                    obj = uamul;
+                    break;
+                case 4:
+                    obj = ublindf;
+                    break;
+                }
+            }
+            if (drain_item(obj, FALSE)) {
                 pline("%s less effective.", Yobjnam2(obj, "seem"));
             }
         }
@@ -2691,7 +2711,9 @@ register struct attack *mattk;
     }
     case AD_ENCH: /* KMH -- remove enchantment (disenchanter) */
         if (otmp) {
-            (void) drain_item(otmp);
+            /* by_you==True: passive counterattack to hero's action
+               is hero's fault */
+            (void) drain_item(otmp, TRUE);
             /* No message */
         }
         return 1;
index 1217b5b486eaadef8733185e19e1cc82396db04b..832390694d2c93706870f50c4f09519faa8ef08b 100644 (file)
@@ -1,4 +1,4 @@
-/* NetHack 3.6 uhitm.c $NHDT-Date: 1460103141 2016/04/08 08:12:21 $  $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.156 $ */
+/* NetHack 3.6 uhitm.c $NHDT-Date: 1470819843 2016/08/10 09:04:03 $  $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.164 $ */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -2537,12 +2537,12 @@ boolean wep_was_destroyed;
  */
 void
 passive_obj(mon, obj, mattk)
-register struct monst *mon;
-register struct obj *obj; /* null means pick uwep, uswapwep or uarmg */
+struct monst *mon;
+struct obj *obj;          /* null means pick uwep, uswapwep or uarmg */
 struct attack *mattk;     /* null means we find one internally */
 {
     struct permonst *ptr = mon->data;
-    register int i;
+    int i;
 
     /* if caller hasn't specified an object, use uwep, uswapwep or uarmg */
     if (!obj) {
@@ -2589,7 +2589,7 @@ struct attack *mattk;     /* null means we find one internally */
         break;
     case AD_ENCH:
         if (!mon->mcan) {
-            if (drain_item(obj) && carried(obj)
+            if (drain_item(obj, TRUE) && carried(obj)
                 && (obj->known || obj->oclass == ARMOR_CLASS)) {
                 pline("%s less effective.", Yobjnam2(obj, "seem"));
             }
index ea246aabbfc88bd31790a1925a88dc5ef5fe89ce..927bcb1dcdf719fe1a89a267bcaf15af8bf84db5 100644 (file)
--- a/src/zap.c
+++ b/src/zap.c
@@ -1,4 +1,4 @@
-/* NetHack 3.6 zap.c   $NHDT-Date: 1464163779 2016/05/25 08:09:39 $  $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.258 $ */
+/* NetHack 3.6 zap.c   $NHDT-Date: 1470819844 2016/08/10 09:04:04 $  $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.263 $ */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -1062,8 +1062,9 @@ register struct obj *obj;
  * possibly carried by you or a monster
  */
 boolean
-drain_item(obj)
-register struct obj *obj;
+drain_item(obj, by_you)
+struct obj *obj;
+boolean by_you;
 {
     boolean u_ring;
 
@@ -1078,7 +1079,8 @@ register struct obj *obj;
         return FALSE;
 
     /* Charge for the cost of the object */
-    costly_alteration(obj, COST_DRAIN);
+    if (by_you)
+        costly_alteration(obj, COST_DRAIN);
 
     /* Drain the object and any implied effects */
     obj->spe--;
@@ -1110,6 +1112,10 @@ register struct obj *obj;
         if ((obj->owornmask & W_RING) && u_ring)
             u.udaminc--;
         break;
+    case RIN_PROTECTION:
+        if (u_ring)
+            context.botl = 1; /* bot() will recalc u.uac */
+        break;
     case HELM_OF_BRILLIANCE:
         if ((obj->owornmask & W_ARMH) && (obj == uarmh)) {
             ABON(A_INT)--;
@@ -1123,10 +1129,11 @@ register struct obj *obj;
             context.botl = 1;
         }
         break;
-    case RIN_PROTECTION:
-        context.botl = 1;
+    default:
         break;
     }
+    if (context.botl)
+        bot();
     if (carried(obj))
         update_inventory();
     return TRUE;
@@ -1935,7 +1942,7 @@ struct obj *obj, *otmp;
 #endif
             break;
         case SPE_DRAIN_LIFE:
-            (void) drain_item(obj);
+            (void) drain_item(obj, TRUE);
             break;
         case WAN_TELEPORTATION:
         case SPE_TELEPORT_AWAY: