]> granicus.if.org Git - nethack/commitdiff
Allow monsters to rummage through containers
authorPasi Kallinen <paxed@alt.org>
Sun, 2 Feb 2020 09:04:08 +0000 (11:04 +0200)
committerPasi Kallinen <paxed@alt.org>
Sun, 2 Feb 2020 09:05:43 +0000 (11:05 +0200)
doc/fixes37.0
src/muse.c

index 58e243ac98be37a3012143f94280bf16e903513c..c381d5156cbaefe9447043fa75b31cec78fad8b1 100644 (file)
@@ -140,6 +140,7 @@ when 'color' if Off and 'use_inverse' is On, draw ice on the map in inverse
 new 'mention_decor' option; when On, describe dungeon features being stepped
        on or floated/flown over even when they're not covered by objects
 applying royal jelly on an egg kills, revives, or changes the egg
+intelligent monsters pick up and rummage through containers
 
 
 Platform- and/or Interface-Specific New Features
index 44e711c6e87e8faab9adaee946d0f02968f5e94b..f31a7667fd0fbaca66ba1f1d755ccd8bc03f02a3 100644 (file)
@@ -1614,6 +1614,7 @@ struct monst *mtmp;
 #define MUSE_WAN_SPEED_MONSTER 7
 #define MUSE_BULLWHIP 8
 #define MUSE_POT_POLYMORPH 9
+#define MUSE_BAG 10
 
 boolean
 find_misc(mtmp)
@@ -1738,6 +1739,13 @@ struct monst *mtmp;
             g.m.misc = obj;
             g.m.has_misc = MUSE_POT_POLYMORPH;
         }
+        nomore(MUSE_BAG);
+        if (Is_container(obj) && obj->otyp != BAG_OF_TRICKS && !rn2(5)
+            && !g.m.has_misc && Has_contents(obj)
+            && !obj->olocked && !obj->otrapped) {
+            g.m.misc = obj;
+            g.m.has_misc = MUSE_BAG;
+        }
     }
     return (boolean) !!g.m.has_misc;
 #undef nomore
@@ -1875,6 +1883,29 @@ struct monst *mtmp;
             makeknown(POT_POLYMORPH);
         m_useup(mtmp, otmp);
         return 2;
+    case MUSE_BAG:
+        {
+            struct obj *xobj;
+            long count = 1;
+
+            /* FIXME: handle cursed bag of holding */
+            if (Is_mbag(otmp) && otmp->cursed)
+                return 0;
+            if (!Has_contents(otmp) || otmp->olocked)
+                return 0;
+
+            for (xobj = otmp->cobj; xobj; xobj = xobj->nobj) count++;
+            count = rn2(count);
+            for (xobj = otmp->cobj; xobj && count; xobj = xobj->nobj) count--;
+            if (xobj && can_carry(mtmp, xobj)) {
+                if (vismon)
+                    pline("%s rummages through something.", Monnam(mtmp));
+                obj_extract_self(xobj);
+                (void) mpickobj(mtmp, xobj);
+                return 2;
+            }
+        }
+        return 0;
     case MUSE_POLY_TRAP:
         if (vismon) {
             const char *Mnam = Monnam(mtmp);
@@ -2087,6 +2118,8 @@ struct obj *obj;
             return (boolean) (!obj->cursed && !is_unicorn(mon->data));
         if (typ == FROST_HORN || typ == FIRE_HORN)
             return (obj->spe > 0 && can_blow(mon));
+        if (Is_container(obj) && !(Is_mbag(obj) && obj->cursed))
+            return TRUE;
         break;
     case FOOD_CLASS:
         if (typ == CORPSE)