Difference between revisions of "User:Ogmobot/Midas Touch Patch"

From NetHackWiki
Jump to navigation Jump to search
(Created page with " diff --git a/include/artilist.h b/include/artilist.h index d2a8c447..f487df63 100644 --- a/include/artilist.h +++ b/include/artilist.h @@ -221,6 +221,10 @@...")
 
m (Midas Touch grants sickness resistance when carried.)
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
    diff --git a/include/artilist.h b/include/artilist.h
+
diff --git a/include/artifact.h b/include/artifact.h
    index d2a8c447..f487df63 100644
+
index 987c0bf6..d45229b1 100644
    --- a/include/artilist.h
+
--- a/include/artifact.h
    +++ b/include/artilist.h
+
+++ b/include/artifact.h
    @@ -221,6 +221,10 @@ STATIC_OVL NEARDATA struct artifact artilist[] = {
+
@@ -68,7 +68,8 @@ enum invoke_prop_types {
        A("Luck Blade", BROADSWORD, (SPFX_RESTR | SPFX_LUCK | SPFX_INTEL), 0, 0,
+
      CREATE_PORTAL,
          PHYS(5,6), NO_DFNS, NO_CARY, 0, A_CHAOTIC, PM_CONVICT, NON_PM, 3000L,
+
      ENLIGHTENING,
          NO_COLOR),
+
      CREATE_AMMO,
    +    /* Golden gauntlets that turn wielded items into gold. These belong to Croesus.
+
-    PHASING
    +    */
+
+    PHASING,
    +    A("Midas Touch", GAUNTLETS, (SPFX_NOGEN | SPFX_RESTR), 0, 0, NO_ATTK, NO_DFNS,
+
+    CHANGE_MATERIAL
    +      NO_CARY, 0, A_NEUTRAL, NON_PM, NON_PM, 5000L, NO_COLOR),
+
  };
   
+
 
        /*
+
  #endif /* ARTIFACT_H */
          *      The artifacts for the quest dungeon, all self-willed.
+
diff --git a/include/artilist.h b/include/artilist.h
    diff --git a/include/extern.h b/include/extern.h
+
index d2a8c447..119a7a0b 100644
    index 13ce605c..787bf329 100644
+
--- a/include/artilist.h
    --- a/include/extern.h
+
+++ b/include/artilist.h
    +++ b/include/extern.h
+
@@ -221,6 +221,10 @@ STATIC_OVL NEARDATA struct artifact artilist[] = {
    @@ -104,6 +104,7 @@ E void FDECL(retouch_equipment, (int));
+
      A("Luck Blade", BROADSWORD, (SPFX_RESTR | SPFX_LUCK | SPFX_INTEL), 0, 0,
    E void NDECL(mkot_trap_warn);
+
        PHYS(5,6), NO_DFNS, NO_CARY, 0, A_CHAOTIC, PM_CONVICT, NON_PM, 3000L,
    E boolean FDECL(is_magic_key, (struct monst *, struct obj *));
+
        NO_COLOR),
    E struct obj *FDECL(has_magic_key, (struct monst *));
+
+   /* Golden gauntlets that turn wielded items into gold. These belong to Croesus.
    +E boolean FDECL(turn_to_gold, (struct obj *, struct monst *));
+
+    */
   
+
+    A("Midas Touch", GAUNTLETS, (SPFX_NOGEN | SPFX_RESTR | SPFX_DEFN), 0, 0, NO_ATTK, DFNS(AD_DISE),
    /* ### attrib.c ### */
+
+     NO_CARY, CHANGE_MATERIAL, A_NEUTRAL, NON_PM, NON_PM, 5000L, NO_COLOR),
      
+
 
    diff --git a/src/artifact.c b/src/artifact.c
+
      /*
    index 1f9ebdd0..078eaadd 100644
+
      *      The artifacts for the quest dungeon, all self-willed.
    --- a/src/artifact.c
+
diff --git a/include/extern.h b/include/extern.h
    +++ b/src/artifact.c
+
index 13ce605c..b99b2ca4 100644
    @@ -15,6 +15,8 @@
+
--- a/include/extern.h
      */
+
+++ b/include/extern.h
   
+
@@ -104,6 +104,7 @@ E void FDECL(retouch_equipment, (int));
    extern boolean notonhead; /* for long worms */
+
  E void NDECL(mkot_trap_warn);
    +extern const int matprices[];
+
  E boolean FDECL(is_magic_key, (struct monst *, struct obj *));
    +extern const int matdensities[];
+
  E struct obj *FDECL(has_magic_key, (struct monst *));
   
+
+E boolean FDECL(change_material, (struct obj *, int mat));
    #define get_artifact(o) \
+
 
        (((o) && (o)->oartifact) ? &artilist[(int) (o)->oartifact] : 0)
+
  /* ### attrib.c ### */
    @@ -2802,4 +2804,27 @@ struct monst *mon; /* if null, hero assumed */
+
 
        return (struct obj *) 0;
+
diff --git a/src/artifact.c b/src/artifact.c
    }
+
index 1f9ebdd0..21f2dfbc 100644
   
+
--- a/src/artifact.c
    +boolean
+
+++ b/src/artifact.c
    +turn_to_gold(obj, mon)
+
@@ -15,6 +15,8 @@
    +struct obj *obj;
+
  */
    +struct monst *mon; /* if null, hero assumed */
+
 
    +{
+
  extern boolean notonhead; /* for long worms */
    +    if (obj && (obj->material != GOLD) && valid_obj_material(obj, GOLD)
+
+extern const int matprices[];
    +        && !obj->oartifact) {
+
+extern const int matdensities[];
    +       if ((mon && canseemon(mon)) || (!mon && !Blind))
+
 
    +            pline("%s to gold!", Tobjnam(obj, "turn"));
+
  #define get_artifact(o) \
    +       else if ((obj == uwep || obj == uswapwep)
+
      (((o) && (o)->oartifact) ? &artilist[(int) (o)->oartifact] : 0)
    +                && (matdensities[obj->material] != matdensities[GOLD]))
+
@@ -2146,6 +2148,24 @@ struct obj *obj;
    +           pline("%s %s.", Tobjnam(obj, "feel"),
+
              incr_itimeout(&HPasses_walls, (50 + rnd(100)));
    +                 matdensities[obj->material] > matdensities[GOLD]
+
              obj->age += HPasses_walls; /* Time begins after phasing ends */
    +                 ? "lighter" : "heavier");
+
              break;
    +       if (!mon && matprices[obj->material] > matprices[GOLD])
+
+        case CHANGE_MATERIAL: {
    +           costly_alteration(obj, COST_DEGRD);
+
+            int mat, tryct = 0;
    +       set_material(obj, GOLD);
+
+           if (oart == &artilist[ART_MIDAS_TOUCH])
    +        return TRUE;
+
+               /* Transform wielded item into gold, if possible */
    +   } else {
+
+               mat = GOLD;
    +        return FALSE;
+
+           else if (uwep) {
    +   }
+
+               /* Transform wielded item into something different */
    +}
+
+                mat = uwep->material;
    +
+
+               while ((mat == uwep->material
    /*artifact.c*/
+
+                       || (mat == objects[uwep->otyp].oc_material && rn2(3))
    diff --git a/src/do_name.c b/src/do_name.c
+
+                       || !valid_obj_material(uwep, mat)) && tryct++ < 100)
    index 8e037c37..2eea2482 100644
+
+                   mat = rnd(NUM_MATERIAL_TYPES - 1);
    --- a/src/do_name.c
+
+           } else
    +++ b/src/do_name.c
+
+               mat = 0; /* Should always be invalid */
    @@ -1350,6 +1350,9 @@ const char *name;
+
+            if (!change_material(uwep, mat))
            case ART_IRON_BALL_OF_LIBERATION:
+
+                goto nothing_special;
                set_material(obj, IRON);
+
+            break;
                break;
+
+       }
    +        case ART_MIDAS_TOUCH:
+
          }
    +           set_material(obj, GOLD);
+
      } else {
    +           break;
+
          long eprop = (u.uprops[oart->inv_prop].extrinsic ^= W_ARTI),
            default:
+
@@ -2802,4 +2822,30 @@ struct monst *mon; /* if null, hero assumed */
                /* prevent any wishes for materials on an artifact */
+
      return (struct obj *) 0;
                set_material(obj, objects[obj->otyp].oc_material);
+
  }
    diff --git a/src/do_wear.c b/src/do_wear.c
+
 
    index da2274a5..803150a0 100644
+
+/* Changes an object into the given material, if possible.
    --- a/src/do_wear.c
+
+ * TODO: allow some objects to change to a material that's not
    +++ b/src/do_wear.c
+
+ *       usually allowed for it; e.g. gold orcish items.
    @@ -610,6 +610,15 @@ Gloves_on(VOID_ARGS)
+
+ */
        if (uarmg->greased)
+
+boolean
            Glib |= FROMOUTSIDE;
+
+change_material(obj, mat)
        uarmg->known = 1; /* gloves' +/- evident because of status line AC */
+
+struct obj *obj;
    +
+
+int mat;
    +    if (uarmg->oartifact == ART_MIDAS_TOUCH) {
+
+{
    +        if (uwep) {
+
+    if (obj && obj->material != mat && !obj->oartifact
    +            turn_to_gold(uwep, 0);
+
+       && valid_obj_material(obj, mat)) {
    +       }
+
+       if (!Blind)
    +        if (uswapwep && u.twoweap) {
+
+            pline("%s %s!", Tobjnam(obj, "become"), materialnm[mat]);
    +            turn_to_gold(uswapwep, 0);
+
+       else if ((obj == uwep || obj == uswapwep)
    +        }
+
+                 && (matdensities[obj->material] != matdensities[mat]))
    +    }
+
+            pline("%s %s.", Tobjnam(obj, "feel"),
        return 0;
+
+                  matdensities[obj->material] > matdensities[mat]
    }
+
+                 ? "lighter" : "heavier");
   
+
+        if (carried(obj) && matprices[obj->material] > matprices[mat])
    diff --git a/src/makemon.c b/src/makemon.c
+
+            costly_alteration(obj, COST_DEGRD);
    index ea2c0bbe..8fbbad1b 100644
+
+        set_material(obj, mat);
    --- a/src/makemon.c
+
+        return TRUE;
    +++ b/src/makemon.c
+
+    } else
    @@ -927,16 +927,23 @@ register struct monst *mtmp;
+
+        return FALSE;
                received = m_carrying(mtmp, item);
+
+}
                if (received)
+
+
                    received->material = GOLD;
+
  /*artifact.c*/
    -            int item2 = rn2(2) ? HELMET : DWARVISH_HELM;
+
diff --git a/src/do_name.c b/src/do_name.c
    -            (void) mongets(mtmp, item2);
+
index 8e037c37..2eea2482 100644
    -           received = m_carrying(mtmp, item2);
+
--- a/src/do_name.c
    +            item = rn2(2) ? HELMET : DWARVISH_HELM;
+
+++ b/src/do_name.c
    +           (void) mongets(mtmp, item);
+
@@ -1350,6 +1350,9 @@ const char *name;
    +            received = m_carrying(mtmp, item);
+
          case ART_IRON_BALL_OF_LIBERATION:
                if (received)
+
              set_material(obj, IRON);
                    received->material = GOLD;
+
              break;
    -            int item3 = rn2(2) ? KICKING_BOOTS : DWARVISH_BOOTS;
+
+        case ART_MIDAS_TOUCH:
    -            (void) mongets(mtmp, item3);
+
+            set_material(obj, GOLD);
    -            received = m_carrying(mtmp, item3);
+
+            break;
    +           item = rn2(2) ? KICKING_BOOTS : DWARVISH_BOOTS;
+
          default:
    +           (void) mongets(mtmp, item);
+
              /* prevent any wishes for materials on an artifact */
    +           received = m_carrying(mtmp, item);
+
              set_material(obj, objects[obj->otyp].oc_material);
                if (received)
+
diff --git a/src/makemon.c b/src/makemon.c
                    received->material = GOLD;
+
index ea2c0bbe..f2ad939d 100644
    +            otmp = mksobj(GAUNTLETS, FALSE, FALSE);
+
--- a/src/makemon.c
    +            otmp->material = GOLD;
+
+++ b/src/makemon.c
    +            if (!rn2(2)) {
+
@@ -921,22 +921,29 @@ register struct monst *mtmp;
    +               otmp = oname(otmp, artiname(ART_MIDAS_TOUCH));
+
              (void) mongets(mtmp, TWO_HANDED_SWORD);
    +                curse(otmp);
+
              struct obj* received = m_carrying(mtmp, TWO_HANDED_SWORD);
    +            }
+
              if (received)
    +           (void) mpickobj(mtmp, otmp);
+
-                received->material = GOLD;
            }
+
+                set_material(received, GOLD);
            break;
+
              int item = rn2(2) ? BANDED_MAIL : PLATE_MAIL;
   
+
              (void) mongets(mtmp, item);
    diff --git a/src/mkobj.c b/src/mkobj.c
+
              received = m_carrying(mtmp, item);
    index c977853a..0f1c7ed1 100644
+
              if (received)
    --- a/src/mkobj.c
+
-                received->material = GOLD;
    +++ b/src/mkobj.c
+
-           int item2 = rn2(2) ? HELMET : DWARVISH_HELM;
    @@ -1459,7 +1459,6 @@ unsigned onoff; /* 1 or 0 */
+
-           (void) mongets(mtmp, item2);
      * counterpart, and things such as wooden plate mails were incredibly
+
-           received = m_carrying(mtmp, item2);
      * overpowered by weighing about one-tenth as much as the iron counterpart.
+
+                set_material(received, GOLD);
      * Instead, use arbitrary units. */
+
+            item = rn2(2) ? HELMET : DWARVISH_HELM;
    -STATIC_DCL
+
+            (void) mongets(mtmp, item);
    const int matdensities[] = {
+
+            received = m_carrying(mtmp, item);
        0,   // will cause div/0 errors if anything is this material
+
              if (received)
        10, // LIQUID
+
-               received->material = GOLD;
    @@ -3093,6 +3092,11 @@ static const struct icp metal_materials[] = {
+
-            int item3 = rn2(2) ? KICKING_BOOTS : DWARVISH_BOOTS;
   
+
-           (void) mongets(mtmp, item3);
    /* for objects which are normally wooden */
+
-           received = m_carrying(mtmp, item3);
    static const struct icp wood_materials[] = {
+
+                set_material(received, GOLD);
    +   { 0, GOLD},
+
+           item = rn2(2) ? KICKING_BOOTS : DWARVISH_BOOTS;
    +   /* Gold items of this nature can't be generated normally, but can be
+
+           (void) mongets(mtmp, item);
    +    * wished for. The gold entry must be placed before the last normal
+
+            received = m_carrying(mtmp, item);
    +    * material to be considered valid.
+
              if (received)
    +    */
+
-                received->material = GOLD;
        {80, WOOD},
+
+                set_material(received, GOLD);
        {10, MINERAL},
+
+            otmp = mksobj(GAUNTLETS, FALSE, FALSE);
        { 4, IRON},
+
  +            otmp->material = GOLD;
    @@ -3138,6 +3142,7 @@ static const struct icp elven_materials[] = {
+
+           if (!rn2(2)) {
   
+
+                otmp = oname(otmp, artiname(ART_MIDAS_TOUCH));
    /* for objects of orcish make - no mithril! */
+
+                curse(otmp);
    static const struct icp orcish_materials[] = {
+
+           }
    +   { 0, GOLD},
+
+           (void) mpickobj(mtmp, otmp);
        {65, IRON},
+
          }
        {25, BONE},
+
          break;
        {10, MINERAL}
+
 
    @@ -3180,6 +3185,7 @@ static const struct icp horn_materials[] = {
+
diff --git a/src/mkobj.c b/src/mkobj.c
    /* hacks for specific objects... not great because it's a lot of data, but it's
+
index c977853a..f2b1e9cc 100644
       * a relatively clean solution */
+
--- a/src/mkobj.c
    static const struct icp elven_helm_boots_materials[] = {
+
+++ b/src/mkobj.c
    +    { 0, GOLD},
+
@@ -1459,7 +1459,6 @@ unsigned onoff; /* 1 or 0 */
        {70, LEATHER},
+
   * counterpart, and things such as wooden plate mails were incredibly
        {15, MITHRIL},
+
  * overpowered by weighing about one-tenth as much as the iron counterpart.
        {10, COPPER},
+
  * Instead, use arbitrary units. */
    @@ -3188,6 +3194,7 @@ static const struct icp elven_helm_boots_materials[] = {
+
-STATIC_DCL
    };
+
  const int matdensities[] = {
   
+
      0,  // will cause div/0 errors if anything is this material
    static const struct icp dwarvish_weapon_materials[] = {
+
       10,  // LIQUID
    +    { 0, GOLD},
 
        {70, IRON},
 
        {25, MITHRIL},
 
        { 5, GEMSTONE} /* gemstone is very hard and very sharp */
 
    diff --git a/src/uhitm.c b/src/uhitm.c
 
    index ec354b83..47c684a0 100644
 
    --- a/src/uhitm.c
 
    +++ b/src/uhitm.c
 
    @@ -1397,6 +1397,23 @@ int dieroll;
 
            }
 
        }
 
   
 
    +    if ((mdat == &mons[PM_IRON_GOLEM] || mdat == &mons[PM_STONE_GOLEM])
 
    +        && !uwep && !thrown && uarmg && uarmg->oartifact == ART_MIDAS_TOUCH) {
 
    +        char *name = Monnam(mon);
 
    +
 
    +        if (newcham(mon, &mons[PM_GOLD_GOLEM], FALSE, FALSE)) {
 
    +            if (canseemon(mon)) {
 
    +                pline("%s turns to gold as you hit it!", name);
 
    +                hittxt = TRUE;
 
    +            }
 
    +        } else {
 
    +            if (canseemon(mon)) {
 
    +                pline("%s seems to sparkle with gold as you hit it.", name);
 
    +                hittxt = TRUE;
 
    +            }
 
    +        }
 
    +    }
 
    +
 
        if (!hittxt /*( thrown => obj exists )*/
 
            && (!destroyed
 
                || (thrown && m_shot.n > 1 && m_shot.o == obj->otyp))) {
 
    diff --git a/src/weapon.c b/src/weapon.c
 
    index 6f28d6dc..62ea0e23 100644
 
    --- a/src/weapon.c
 
    +++ b/src/weapon.c
 
    @@ -1016,6 +1016,9 @@ register struct monst *mon;
 
                              ? "nearby"
 
                              : "in the distance");
 
            }
 
    +        if (which_armor(mon, W_ARMG)
 
    +            && which_armor(mon, W_ARMG)->oartifact == ART_MIDAS_TOUCH)
 
    +            turn_to_gold(obj, mon);
 
            obj->owornmask = W_WEP;
 
            return 1;
 
        }
 
    diff --git a/src/wield.c b/src/wield.c
 
    index 7d57fad5..af3902d3 100644
 
    --- a/src/wield.c
 
    +++ b/src/wield.c
 
    @@ -106,6 +106,10 @@ register struct obj *obj;
 
            && ((uwep && uwep->oartifact == ART_GIANTSLAYER)
 
                || (olduwep && olduwep->oartifact == ART_GIANTSLAYER)))
 
            context.botl = 1;
 
    +
 
    +    if (uwep == obj && (uarmg && uarmg->oartifact == ART_MIDAS_TOUCH))
 
    +        turn_to_gold(obj, 0);
 
    +
 
        /* Note: Explicitly wielding a pick-axe will not give a "bashing"
 
          * message.  Wielding one via 'a'pplying it will.
 
          * 3.2.2:  Wielding arbitrary objects will give bashing message too.
 
    @@ -697,6 +701,8 @@ dotwoweapon()
 
            /* Success! */
 
            You("begin two-weapon combat.");
 
            u.twoweap = 1;
 
    +        if (uarmg && uarmg->oartifact == ART_MIDAS_TOUCH)
 
    +            turn_to_gold(uswapwep, 0);
 
            update_inventory();
 
            return (rnd(20) > ACURR(A_DEX));
 
        }
 
    diff --git a/src/worn.c b/src/worn.c
 
    index 6fd44fe7..79d37ffb 100644
 
    --- a/src/worn.c
 
    +++ b/src/worn.c
 
    @@ -799,6 +799,9 @@ outer_break:
 
            } /* else if (!mon->minvis) pline("%s suddenly appears!",
 
                  Amonnam(mon)); */
 
        }
 
    +    if (flag == W_ARMG && best->oartifact == ART_MIDAS_TOUCH) {
 
    +        turn_to_gold(MON_WEP(mon), mon);
 
    +    }
 
    }
 
    #undef RACE_EXCEPTION
 

Latest revision as of 06:27, 1 October 2019

diff --git a/include/artifact.h b/include/artifact.h
index 987c0bf6..d45229b1 100644
--- a/include/artifact.h
+++ b/include/artifact.h
@@ -68,7 +68,8 @@ enum invoke_prop_types {
     CREATE_PORTAL,
     ENLIGHTENING,
     CREATE_AMMO,
-    PHASING
+    PHASING,
+    CHANGE_MATERIAL
 };
 
 #endif /* ARTIFACT_H */
diff --git a/include/artilist.h b/include/artilist.h
index d2a8c447..119a7a0b 100644
--- a/include/artilist.h
+++ b/include/artilist.h
@@ -221,6 +221,10 @@ STATIC_OVL NEARDATA struct artifact artilist[] = {
     A("Luck Blade", BROADSWORD, (SPFX_RESTR | SPFX_LUCK | SPFX_INTEL), 0, 0,
       PHYS(5,6), NO_DFNS, NO_CARY, 0, A_CHAOTIC, PM_CONVICT, NON_PM, 3000L,
       NO_COLOR),
+    /* Golden gauntlets that turn wielded items into gold. These belong to Croesus.
+     */
+    A("Midas Touch", GAUNTLETS, (SPFX_NOGEN | SPFX_RESTR | SPFX_DEFN), 0, 0, NO_ATTK, DFNS(AD_DISE),
+      NO_CARY, CHANGE_MATERIAL, A_NEUTRAL, NON_PM, NON_PM, 5000L, NO_COLOR),
 
     /*
      *      The artifacts for the quest dungeon, all self-willed.
diff --git a/include/extern.h b/include/extern.h
index 13ce605c..b99b2ca4 100644
--- a/include/extern.h
+++ b/include/extern.h
@@ -104,6 +104,7 @@ E void FDECL(retouch_equipment, (int));
 E void NDECL(mkot_trap_warn);
 E boolean FDECL(is_magic_key, (struct monst *, struct obj *));
 E struct obj *FDECL(has_magic_key, (struct monst *));
+E boolean FDECL(change_material, (struct obj *, int mat));
 
 /* ### attrib.c ### */
 
diff --git a/src/artifact.c b/src/artifact.c
index 1f9ebdd0..21f2dfbc 100644
--- a/src/artifact.c
+++ b/src/artifact.c
@@ -15,6 +15,8 @@
  */
 
 extern boolean notonhead; /* for long worms */
+extern const int matprices[];
+extern const int matdensities[];
 
 #define get_artifact(o) \
     (((o) && (o)->oartifact) ? &artilist[(int) (o)->oartifact] : 0)
@@ -2146,6 +2148,24 @@ struct obj *obj;
             incr_itimeout(&HPasses_walls, (50 + rnd(100)));
             obj->age += HPasses_walls; /* Time begins after phasing ends */
             break;
+        case CHANGE_MATERIAL: {
+            int mat, tryct = 0;
+            if (oart == &artilist[ART_MIDAS_TOUCH])
+                /* Transform wielded item into gold, if possible */
+                mat = GOLD;
+            else if (uwep) {
+                /* Transform wielded item into something different */
+                mat = uwep->material;
+                while ((mat == uwep->material
+                       || (mat == objects[uwep->otyp].oc_material && rn2(3))
+                       || !valid_obj_material(uwep, mat)) && tryct++ < 100)
+                    mat = rnd(NUM_MATERIAL_TYPES - 1);
+            } else
+                mat = 0; /* Should always be invalid */
+            if (!change_material(uwep, mat))
+                goto nothing_special;
+            break;
+        }
         }
     } else {
         long eprop = (u.uprops[oart->inv_prop].extrinsic ^= W_ARTI),
@@ -2802,4 +2822,30 @@ struct monst *mon; /* if null, hero assumed */
     return (struct obj *) 0;
 }
 
+/* Changes an object into the given material, if possible.
+ * TODO: allow some objects to change to a material that's not
+ *       usually allowed for it; e.g. gold orcish items.
+ */
+boolean
+change_material(obj, mat)
+struct obj *obj;
+int mat;
+{
+    if (obj && obj->material != mat && !obj->oartifact
+        && valid_obj_material(obj, mat)) {
+        if (!Blind)
+            pline("%s %s!", Tobjnam(obj, "become"), materialnm[mat]);
+        else if ((obj == uwep || obj == uswapwep)
+                 && (matdensities[obj->material] != matdensities[mat]))
+            pline("%s %s.", Tobjnam(obj, "feel"),
+                  matdensities[obj->material] > matdensities[mat]
+                  ? "lighter" : "heavier");
+        if (carried(obj) && matprices[obj->material] > matprices[mat])
+            costly_alteration(obj, COST_DEGRD);
+        set_material(obj, mat);
+        return TRUE;
+    } else
+        return FALSE;
+}
+
 /*artifact.c*/
diff --git a/src/do_name.c b/src/do_name.c
index 8e037c37..2eea2482 100644
--- a/src/do_name.c
+++ b/src/do_name.c
@@ -1350,6 +1350,9 @@ const char *name;
         case ART_IRON_BALL_OF_LIBERATION:
             set_material(obj, IRON);
             break;
+        case ART_MIDAS_TOUCH:
+            set_material(obj, GOLD);
+            break;
         default:
             /* prevent any wishes for materials on an artifact */
             set_material(obj, objects[obj->otyp].oc_material);
diff --git a/src/makemon.c b/src/makemon.c
index ea2c0bbe..f2ad939d 100644
--- a/src/makemon.c
+++ b/src/makemon.c
@@ -921,22 +921,29 @@ register struct monst *mtmp;
             (void) mongets(mtmp, TWO_HANDED_SWORD);
             struct obj* received = m_carrying(mtmp, TWO_HANDED_SWORD);
             if (received)
-                received->material = GOLD;
+                set_material(received, GOLD);
             int item = rn2(2) ? BANDED_MAIL : PLATE_MAIL;
             (void) mongets(mtmp, item);
             received = m_carrying(mtmp, item);
             if (received)
-                received->material = GOLD;
-            int item2 = rn2(2) ? HELMET : DWARVISH_HELM;
-            (void) mongets(mtmp, item2);
-            received = m_carrying(mtmp, item2);
+                set_material(received, GOLD);
+            item = rn2(2) ? HELMET : DWARVISH_HELM;
+            (void) mongets(mtmp, item);
+            received = m_carrying(mtmp, item);
             if (received)
-                received->material = GOLD;
-            int item3 = rn2(2) ? KICKING_BOOTS : DWARVISH_BOOTS;
-            (void) mongets(mtmp, item3);
-            received = m_carrying(mtmp, item3);
+                set_material(received, GOLD);
+            item = rn2(2) ? KICKING_BOOTS : DWARVISH_BOOTS;
+            (void) mongets(mtmp, item);
+            received = m_carrying(mtmp, item);
             if (received)
-                received->material = GOLD;
+                set_material(received, GOLD);
+            otmp = mksobj(GAUNTLETS, FALSE, FALSE);
+            otmp->material = GOLD;
+            if (!rn2(2)) {
+                otmp = oname(otmp, artiname(ART_MIDAS_TOUCH));
+                curse(otmp);
+            }
+            (void) mpickobj(mtmp, otmp);
         }
         break;
 
diff --git a/src/mkobj.c b/src/mkobj.c
index c977853a..f2b1e9cc 100644
--- a/src/mkobj.c
+++ b/src/mkobj.c
@@ -1459,7 +1459,6 @@ unsigned onoff; /* 1 or 0 */
  * counterpart, and things such as wooden plate mails were incredibly
  * overpowered by weighing about one-tenth as much as the iron counterpart.
  * Instead, use arbitrary units. */
-STATIC_DCL
 const int matdensities[] = {
     0,   // will cause div/0 errors if anything is this material
     10,  // LIQUID