]> granicus.if.org Git - nethack/commitdiff
Add Auto open doors -patch
authorPasi Kallinen <paxed@alt.org>
Mon, 13 Apr 2015 17:49:38 +0000 (20:49 +0300)
committerPasi Kallinen <paxed@alt.org>
Mon, 13 Apr 2015 18:11:44 +0000 (21:11 +0300)
dat/opthelp
doc/Guidebook.mn
doc/Guidebook.tex
doc/fixes35.0
include/context.h
include/extern.h
include/flag.h
include/patchlevel.h
src/hack.c
src/lock.c
src/options.c

index ce1d743cc3c6d4e04c8b0c2f15199169f0481057..1cffdeb731365d1c3f53384279357d06f8e18032 100644 (file)
@@ -3,6 +3,7 @@ Boolean options not under specific compile flags (with default values in []):
 option setting, which is reached via the 'O' cmd.)
 
 autodig        dig if moving and wielding digging tool            [FALSE]
+autoopen       walking into a door attempts to open it            [TRUE]
 autopickup     automatically pick up objects you move over        [TRUE]
 autoquiver     when firing with an empty quiver, select some
                suitable inventory weapon to fill the quiver       [FALSE]
index a62cfd02acc2d02e2e4965f80ad0c618cc0b7b02..8b32a50aacb8e1f0958c6086d3da17564b05de32 100644 (file)
@@ -1905,6 +1905,8 @@ Cannot be set with the `O' command.
 .lp autodig
 Automatically dig if you are wielding a digging tool and moving into a place
 that can be dug (default false).
+.lp autoopen
+Walking into a door attempts to open it (default true).
 .lp "autopickup  "
 Automatically pick up things onto which you move (default on). 
 See
index d31fa52aad2f0f4dc644a6dd751586d28e94bd1a..057fbc8e94590e4570b0294c5d721b333e2f8549 100644 (file)
@@ -2306,6 +2306,9 @@ Cannot be set with the `{\tt O}' command.
 Automatically dig if you are wielding a digging tool and moving into a place
 that can be dug (default false).
 %.lp
+\item[\ib{autoopen}]
+Walking into a door attempts to open it (default true).
+%.lp
 \item[\ib{autopickup}]
 Automatically pick up things onto which you move (default on).
 See ``{\it pickup\_types\/}'' to refine the behavior.
index 9744a0a4cc739c15e29de3bc225535ebbdbcd0e0..9e5c508d36786924730df9140794482ba1b100c9 100644 (file)
@@ -1165,6 +1165,7 @@ Aardvark Joe's Extended Logfile
 Michael Deutschmann's use_darkgray
 Clive Crous' dark_room
 sortloot by Jeroen Demeyer and Jukka Lahtinen
+Auto open doors by Stefano Busti
 
 
 Code Cleanup and Reorganization
index a544f6ae0c70e571457a5ae57797b41b2584d370..dfacbb5ad82ad7774d9aa8b1bf52de6a88830fe3 100644 (file)
@@ -110,6 +110,7 @@ struct context_info {
        boolean  bypasses;      /* bypass flag is set on at least one fobj */
        boolean  botl;          /* partially redo status line */
        boolean  botlx;         /* print an entirely new bottom line */
+       boolean  door_opened;   /* set to true if door was opened during test_move */
        struct dig_info digging;
        struct victual_info victual;
        struct tin_info tin;
index f5600661de398c0ab8f9433f0791e73225e75555..ebe38de5e7df466645c959469f7ffe22e703d24f 100644 (file)
@@ -980,6 +980,7 @@ E int NDECL(doforce);
 E boolean FDECL(boxlock, (struct obj *,struct obj *));
 E boolean FDECL(doorlock, (struct obj *,int,int));
 E int NDECL(doopen);
+E int FDECL(doopen_indir, (int,int));
 E int NDECL(doclose);
 
 #ifdef MAC
index dc58375e41fe0655797991ba0690d0e5b6fe09c3..38dbe48ce14430fa1f7f2baad2163720585cb42f 100644 (file)
@@ -19,6 +19,7 @@ struct flag {
        boolean  acoustics;     /* allow dungeon sound messages */
        boolean  autodig;       /* MRKR: Automatically dig */
        boolean  autoquiver;    /* Automatically fill quiver */
+       boolean  autoopen;      /* open doors by walking into them */
        boolean  beginner;
        boolean  biff;          /* enable checking for mail */
        boolean  bones;         /* allow saving/loading bones */
index 76d514afad9a27826049ba8bd1767f0273a6366e..0665df6fe4ec91bba8e4bc7a7b4ede3963d05411 100644 (file)
@@ -14,7 +14,7 @@
  * Incrementing EDITLEVEL can be used to force invalidation of old bones
  * and save files.
  */
-#define EDITLEVEL      60
+#define EDITLEVEL      61
 
 #define COPYRIGHT_BANNER_A \
 "NetHack, Copyright 1985-2015"
index e8e095da5fb0e226e806ba6a967cba061a75f419..df437391ac8110aa0cd7e3a9c41e155f030e98cb 100644 (file)
@@ -627,6 +627,7 @@ int mode;
     register struct rm *tmpr = &levl[x][y];
     register struct rm *ust;
 
+    context.door_opened = FALSE;
     /*
      *  Check for physical obstacles.  First, the place we are going.
      */
@@ -680,8 +681,10 @@ int mode;
         if (mode == DO_MOVE) {
             if (amorphous(youmonst.data))
             You("try to ooze under the door, but can't squeeze your possessions through.");
-            else if (x == ux || y == uy) {
-            if (Blind || Stunned || ACURR(A_DEX) < 10 || Fumbling) {
+           if (flags.autoopen && !context.run && !Confusion && !Stunned && !Fumbling) {
+               context.door_opened = context.move = doopen_indir(x, y);
+           } else if (x == ux || y == uy) {
+               if (Blind || Stunned || ACURR(A_DEX) < 10 || Fumbling) {
                 if (u.usteed) {
                 You_cant("lead %s through that closed door.",
                          y_monnam(u.usteed));
@@ -1405,9 +1408,11 @@ domove()
     }
 
     if (!test_move(u.ux, u.uy, x-u.ux, y-u.uy, DO_MOVE)) {
-        context.move = 0;
-        nomul(0);
-        return;
+       if (!context.door_opened) {
+           context.move = 0;
+           nomul(0);
+       }
+       return;
     }
 
     /* Move ball and chain.  */
index 3de76fe669871545b9901c5aa8522a1f667d4371..c29be8549d509d4a9f5f82a6371e392d7238134f 100644 (file)
@@ -523,6 +523,14 @@ doforce()          /* try to force a chest with your weapon */
 int
 doopen()               /* try to open a door */
 {
+    return doopen_indir(0, 0);
+}
+
+int
+doopen_indir(x, y)             /* try to open a door in direction u.dx/u.dy */
+int x, y;
+{
+
        coord cc;
        register struct rm *door;
        struct monst *mtmp;
@@ -539,7 +547,10 @@ doopen()           /* try to open a door */
            return 0;
        }
 
-       if(!get_adjacent_loc((char *)0, (char *)0, u.ux, u.uy, &cc)) return(0);
+       if (x > 0 && y > 0) {
+           cc.x = x;
+           cc.y = y;
+       } else if(!get_adjacent_loc((char *)0, (char *)0, u.ux, u.uy, &cc)) return(0);
 
        if((cc.x == u.ux) && (cc.y == u.uy)) return(0);
 
index 83c3c0abffc49eade06d7bef81f265ea9cf6c27c..2291b0c131c75a34a0b09f1bdbcbb8d2c096d0d7 100644 (file)
@@ -78,6 +78,7 @@ static struct Bool_Opt
        {"asksavedisk", (boolean *)0, FALSE, SET_IN_FILE},
 #endif
        {"autodig", &flags.autodig, FALSE, SET_IN_GAME},
+       {"autoopen", &flags.autoopen, TRUE, SET_IN_GAME},
        {"autopickup", &flags.pickup, TRUE, SET_IN_GAME},
        {"autoquiver", &flags.autoquiver, FALSE, SET_IN_GAME},
 #if defined(MICRO) && !defined(AMIGA)