]> granicus.if.org Git - nethack/commitdiff
Stop monsters from interacting with protected items on the floor
authorPatric Mueller <bhaak@gmx.net>
Mon, 17 Feb 2020 09:27:38 +0000 (10:27 +0100)
committerPatric Mueller <bhaak@gmx.net>
Mon, 17 Feb 2020 09:41:03 +0000 (10:41 +0100)
This fixes the issue of chests with the wand of wishing on the castle level
being stolen by soldiers.

Commit b12ea03d1 revealed that searches_for_item() didn't check for onscary()
and allowed monsters to pick up items even though they were protected by a
scroll of scare monsters.

src/muse.c

index ab5f41668bbfb1f82f57cfd2d68bd78cb649a09b..0d3847c76a5b09a746143138b9fd9e846cdd5466 100644 (file)
@@ -2174,6 +2174,13 @@ struct obj *obj;
 {
     int typ = obj->otyp;
 
+    /* don't let monsters interact with protected items on the floor */
+    if ((obj->where == OBJ_FLOOR)
+        && (obj->ox == mon->mx) && (obj->oy == mon->my)
+        && onscary(obj->ox, obj->oy, mon)) {
+        return FALSE;
+    }
+
     if (is_animal(mon->data) || mindless(mon->data)
         || mon->data == &mons[PM_GHOST]) /* don't loot bones piles */
         return FALSE;