From: Pasi Kallinen Date: Mon, 13 Apr 2015 17:49:38 +0000 (+0300) Subject: Add Auto open doors -patch X-Git-Tag: NetHack-3.6.0_RC01~480^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=879f6d55c20f9eb848279feebc1e2d6de9c68ce8;p=nethack Add Auto open doors -patch --- diff --git a/dat/opthelp b/dat/opthelp index ce1d743cc..1cffdeb73 100644 --- a/dat/opthelp +++ b/dat/opthelp @@ -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] diff --git a/doc/Guidebook.mn b/doc/Guidebook.mn index a62cfd02a..8b32a50aa 100644 --- a/doc/Guidebook.mn +++ b/doc/Guidebook.mn @@ -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 diff --git a/doc/Guidebook.tex b/doc/Guidebook.tex index d31fa52aa..057fbc8e9 100644 --- a/doc/Guidebook.tex +++ b/doc/Guidebook.tex @@ -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. diff --git a/doc/fixes35.0 b/doc/fixes35.0 index 9744a0a4c..9e5c508d3 100644 --- a/doc/fixes35.0 +++ b/doc/fixes35.0 @@ -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 diff --git a/include/context.h b/include/context.h index a544f6ae0..dfacbb5ad 100644 --- a/include/context.h +++ b/include/context.h @@ -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; diff --git a/include/extern.h b/include/extern.h index f5600661d..ebe38de5e 100644 --- a/include/extern.h +++ b/include/extern.h @@ -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 diff --git a/include/flag.h b/include/flag.h index dc58375e4..38dbe48ce 100644 --- a/include/flag.h +++ b/include/flag.h @@ -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 */ diff --git a/include/patchlevel.h b/include/patchlevel.h index 76d514afa..0665df6fe 100644 --- a/include/patchlevel.h +++ b/include/patchlevel.h @@ -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" diff --git a/src/hack.c b/src/hack.c index e8e095da5..df437391a 100644 --- a/src/hack.c +++ b/src/hack.c @@ -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. */ diff --git a/src/lock.c b/src/lock.c index 3de76fe66..c29be8549 100644 --- a/src/lock.c +++ b/src/lock.c @@ -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); diff --git a/src/options.c b/src/options.c index 83c3c0abf..2291b0c13 100644 --- a/src/options.c +++ b/src/options.c @@ -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)