]> granicus.if.org Git - nethack/commitdiff
key use by pets
authornethack.rankin <nethack.rankin>
Tue, 11 Oct 2005 04:22:18 +0000 (04:22 +0000)
committernethack.rankin <nethack.rankin>
Tue, 11 Oct 2005 04:22:18 +0000 (04:22 +0000)
     Spotted when fixing the Rogue level digging/phasing bug:  pet movement
was setting up the wrong flag for pets who happened to be carrying a key.
This wasn't particularly noticeable because they tended to drop keys right
after picking them up.  And apparently the checks elsewhere in movement
prevented that wrong flag from having any effect; once I changed it so that
pets would hang on to keys, I never saw them break a door down with one.
Now they'll keep keys, similar to unicorn horns and pick-axes, and use them
properly.  The door unlocking message needed a tweak because it assumed
that the opener was on the far side trying to reach you and looked quite
odd when you could see the action taking place.

     I've put this into the fixes file as a new feature rather than a fix.

doc/fixes34.4
src/dogmove.c
src/monmove.c

index a7d53d69b6cac0e016da8b056ef0252eb482d80b..a5b327a7e75afb67779cc94b461ef3c69c5617ee 100644 (file)
@@ -177,6 +177,7 @@ wish request for "<something> armor" will match item named "<something> mail"
 Fire Brand and Frost Brand have a chance to avoid taking rust damage
 support ^R (and ^L in numpad mode) to request display repaint during direction
        choosing and location choosing prompting modes
+intelligent pets will use keys to unlock doors
 
 
 Platform- and/or Interface-Specific New Features
index 7779e5c027d109d1620b5af06aaeb8a26343fbf4..8add2faffc049cd8e33784f62e4355e82063e513 100644 (file)
@@ -25,12 +25,14 @@ register struct monst *mon;
 {
        register struct obj *obj;
        struct obj *wep = MON_WEP(mon);
-       boolean item1 = FALSE, item2 = FALSE;
+       boolean item1 = FALSE, item2 = FALSE, item3 = FALSE;
 
        if (is_animal(mon->data) || mindless(mon->data))
-               item1 = item2 = TRUE;
+               item1 = item2 = item3 = TRUE;
        if (!tunnels(mon->data) || !needspick(mon->data))
                item1 = TRUE;
+       if (nohands(mon->data) || verysmall(mon->data))
+               item3 = TRUE;
        for(obj = mon->minvent; obj; obj = obj->nobj) {
                if (!item1 && is_pick(obj) && (obj->otyp != DWARVISH_MATTOCK
                                                || !which_armor(mon, W_ARMS))) {
@@ -41,6 +43,10 @@ register struct monst *mon;
                        item2 = TRUE;
                        continue;
                }
+               if (!item3 && obj->otyp == SKELETON_KEY) {
+                       item3 = TRUE;
+                       continue;
+               }
                if (!obj->owornmask && obj != wep) return obj;
        }
        return (struct obj *)0;
@@ -588,8 +594,10 @@ register int after;        /* this is extra fast monster movement */
            You("get released!");
        }
        if (!nohands(mtmp->data) && !verysmall(mtmp->data)) {
-               allowflags |= OPENDOOR;
-               if (m_carrying(mtmp, SKELETON_KEY)) allowflags |= BUSTDOOR;
+           allowflags |= OPENDOOR;
+           if (m_carrying(mtmp, SKELETON_KEY)) allowflags |= UNLOCKDOOR;
+           /* note:  the Wizard and Riders can unlock doors without a key;
+              they won't use that ability if someone manages to tame them */
        }
        if (is_giant(mtmp->data)) allowflags |= BUSTDOOR;
        if (tunnels(mtmp->data)
index 43cd4f7e56ed2a7c9b50dd6ba6c5e5386e4e2567..85c2b46fa486e31979df2ebbf3f29b4d3d498619 100644 (file)
@@ -1138,10 +1138,13 @@ postmov:
                            if(mb_trapped(mtmp)) return(2);
                        } else {
                            if (flags.verbose) {
-                               if (canseeit)
-                                  You_see("a door unlock and open.");
+                               if (canseemon(mtmp))
+                                   pline("%s unlocks and opens a door.",
+                                         Monnam(mtmp));
+                               else if (canseeit)
+                                   You_see("a door unlock and open.");
                                else if (!Deaf)
-                                  You_hear("a door unlock and open.");
+                                   You_hear("a door unlock and open.");
                            }
                            here->doormask = D_ISOPEN;
                            /* newsym(mtmp->mx, mtmp->my); */