Newsgroups: rec.games.roguelike.nethack Subject: 3.4.0 pickup_thrown option, version 2 From: Roderick Schertler Date: 29 May 2002 14:57:47 -0400 Message-ID: Lines: 193 X-Newsreader: Gnus v5.7/Emacs 20.7 Here's a second version of my pickup_thrown patch for Nethack 3.4.0. This one keeps both saved game and bones compatibility with the standard distribution. It's also available at http://www.argon.org/~roderick/. This patch adds a new "pickup_thrown" option to the game. If pickup_thrown and autopickup are both on, you'll automatically pick up things you threw, even if you wouldn't normally have picked up that sort of thing. It makes using missile weapons less hassle and more fun. This does change the game mechanics a bit, but it's not terribly different from what you can already do by manipulating your pickup_types. Without this, if you're in a tight spot and you need the missiles you've already thrown, you can temporarily add ) to your pickup types. With pickup_thrown you just don't have to worry about it. I think it's a good tradeoff. I sent a 3.3.1 version of this patch in to the Nethack dev team back in August of 2000. It wasn't included in the 3.4.0 release, but I don't know if that's because they disapproved or because they overlooked it (I didn't hear from them at all). In case it's the latter (this is a problem we had with the Perl development effort) I'm going to send another copy, but I'm also going to release it publically, as directed by the README. This patch keeps both saved game and bones compatibility with the standard distribution. There are two parts to this: - The pickup_thrown option is stored in the interface flags, rather than with the normal flags. This is required both for bones compatibility (the size of the flags struct is part of the version info), and for saves (the normal flags are stored in the save file). This isn't ideal (the option really should be stored in the save file), but I think it's worth it to retain bones compatibility. - The was_thrown bit fits in the existing object structure. When a bones file is read or written, this bit is cleared. Normally this would only be done when reading bones files, but I do it when writing as well in case that bones file will be given to somebody else (via Hearse, eg) who is similarly using that bit in a not otherwise incompatible manner. Roderick Schertler diff -r -X /home/roderick/.diff-exclude -but nethack-3.4.0/dat/opthelp nethack/dat/opthelp --- nethack-3.4.0/dat/opthelp Wed Mar 20 18:42:31 2002 +++ nethack/dat/opthelp Tue May 28 20:49:24 2002 @@ -23,6 +23,7 @@ delay code) if moving objects seem to teleport across rooms number_pad use the number keys to move instead of yuhjklbn [FALSE] perm_invent keep inventory in a permanent window [FALSE] +pickup_thrown autopickup things you threw [TRUE] prayconfirm use confirmation prompt when #pray command issued [TRUE] pushweapon when wielding a new weapon, put your previously wielded weapon into the secondary weapon slot [FALSE] diff -r -X /home/roderick/.diff-exclude -but nethack-3.4.0/doc/Guidebook.mn nethack/doc/Guidebook.mn --- nethack-3.4.0/doc/Guidebook.mn Wed Mar 20 18:42:39 2002 +++ nethack/doc/Guidebook.mn Tue May 28 20:49:24 2002 @@ -1940,6 +1940,12 @@ level (Unburdened, Burdened, streSsed, straiNed, overTaxed, or overLoaded), you will be asked if you want to continue. (Default `S'). +.lp pickup_thrown +If this boolean option is true and +.op autopickup +is on, try to pick up things that you threw, even if they aren't in +.op pickup_types . +Default is on. .lp pickup_types Specify the object types to be picked up when .op autopickup diff -r -X /home/roderick/.diff-exclude -but nethack-3.4.0/doc/Guidebook.tex nethack/doc/Guidebook.tex --- nethack-3.4.0/doc/Guidebook.tex Wed Mar 20 18:42:39 2002 +++ nethack/doc/Guidebook.tex Tue May 28 20:49:24 2002 @@ -2382,6 +2382,11 @@ or overLoaded), you will be asked if you want to continue. (Default `S'). %.lp +\item[\ib{pickup\_thrown}] +If this boolean option is true and {\it autopickup\/} is on, try to pick up +things that you threw, even if they aren't in {\it pickup\_types\/}. +Default is on. +%.lp \item[\ib{pickup\_types}] Specify the object types to be picked up when {\it autopickup\/} is on. Default is all types. diff -r -X /home/roderick/.diff-exclude -but nethack-3.4.0/include/flag.h nethack/include/flag.h --- nethack-3.4.0/include/flag.h Wed Mar 20 18:42:46 2002 +++ nethack/include/flag.h Wed May 29 08:18:50 2002 @@ -252,6 +252,11 @@ boolean wc_large_font; /* draw in larger fonts (say, 12pt instead of 9pt) */ boolean wc_eight_bit_input; /* allow eight bit input */ + + /* This belongs in flag rather than instance_flags, but it's + here to maintain save/bones file compatibility while it isn't + part of the standard distribution. */ + boolean pickup_thrown; /* auto-pickup items you threw */ }; /* diff -r -X /home/roderick/.diff-exclude -but nethack-3.4.0/include/obj.h nethack/include/obj.h --- nethack-3.4.0/include/obj.h Wed Mar 20 18:42:51 2002 +++ nethack/include/obj.h Tue May 28 20:49:24 2002 @@ -86,7 +86,8 @@ Bitfield(in_use,1); /* for magic items before useup items */ Bitfield(bypass,1); /* mark this as an object to be skipped by bhito() */ - /* 6 free bits */ + Bitfield(was_thrown,1); /* thrown by the hero since last picked up */ + /* 5 free bits */ int corpsenm; /* type of corpse is mons[corpsenm] */ #define leashmon corpsenm /* gets m_id of attached pet */ diff -r -X /home/roderick/.diff-exclude -but nethack-3.4.0/src/bones.c nethack/src/bones.c --- nethack-3.4.0/src/bones.c Wed Mar 20 18:43:00 2002 +++ nethack/src/bones.c Tue May 28 20:57:16 2002 @@ -74,6 +74,10 @@ *ONAME(otmp) = '\0'; } else if (otmp->oartifact && restore) artifact_exists(otmp,ONAME(otmp),TRUE); + /* Zero out was_thrown even if !restore, to improve + bones compatibility while this isn't in the official + distribution. */ + otmp->was_thrown = 0; if (!restore) { /* do not zero out o_ids for ghost levels anymore */ diff -r -X /home/roderick/.diff-exclude -but nethack-3.4.0/src/dothrow.c nethack/src/dothrow.c --- nethack-3.4.0/src/dothrow.c Wed Mar 20 18:43:03 2002 +++ nethack/src/dothrow.c Tue May 28 20:49:24 2002 @@ -830,6 +830,7 @@ boolean impaired = (Confusion || Stunned || Blind || Hallucination || Fumbling); + obj->was_thrown = 1; if ((obj->cursed || obj->greased) && (u.dx || u.dy) && !rn2(7)) { boolean slipok = TRUE; if (ammo_and_launcher(obj, uwep)) diff -r -X /home/roderick/.diff-exclude -but nethack-3.4.0/src/options.c nethack/src/options.c --- nethack-3.4.0/src/options.c Wed Mar 20 18:43:12 2002 +++ nethack/src/options.c Tue May 28 21:01:01 2002 @@ -140,6 +140,7 @@ {"page_wait", (boolean *)0, FALSE, SET_IN_FILE}, #endif {"perm_invent", &flags.perm_invent, FALSE, SET_IN_GAME}, + {"pickup_thrown", &iflags.pickup_thrown, TRUE, SET_IN_GAME}, {"popup_dialog", &iflags.wc_popup_dialog, FALSE, SET_IN_GAME}, /*WC*/ {"prayconfirm", &flags.prayconfirm, TRUE, SET_IN_GAME}, {"preload_tiles", &iflags.wc_preload_tiles, TRUE, DISP_IN_GAME}, /*WC*/ diff -r -X /home/roderick/.diff-exclude -but nethack-3.4.0/src/pickup.c nethack/src/pickup.c --- nethack-3.4.0/src/pickup.c Wed Mar 20 18:43:13 2002 +++ nethack/src/pickup.c Tue May 28 21:52:15 2002 @@ -588,13 +588,15 @@ /* first count the number of eligible items */ for (n = 0, curr = olist; curr; curr = FOLLOW(curr, follow)) - if (!*otypes || index(otypes, curr->oclass)) + if (!*otypes || index(otypes, curr->oclass) + || (iflags.pickup_thrown && curr->was_thrown)) n++; if (n) { *pick_list = pi = (menu_item *) alloc(sizeof(menu_item) * n); for (n = 0, curr = olist; curr; curr = FOLLOW(curr, follow)) - if (!*otypes || index(otypes, curr->oclass)) { + if (!*otypes || index(otypes, curr->oclass) + || (iflags.pickup_thrown && curr->was_thrown)) { pi[n].item.a_obj = curr; pi[n].count = curr->quan; n++; @@ -1253,6 +1255,7 @@ obj = splitobj(obj, count); obj = pick_obj(obj); + obj->was_thrown = 0; if (uwep && uwep == obj) mrg_to_wielded = TRUE; nearload = near_capacity(); diff -r -X /home/roderick/.diff-exclude -but nethack-3.4.0/util/makedefs.c nethack/util/makedefs.c --- nethack-3.4.0/util/makedefs.c Wed Mar 20 18:44:05 2002 +++ nethack/util/makedefs.c Wed May 29 08:15:51 2002 @@ -725,6 +725,7 @@ #ifdef ZEROCOMP "zero-compressed save files", #endif + "patch: pickup_thrown", "basic NetHack features" }; -- Roderick Schertler roderick@argon.org