add pickup_thrown option (trunk only)

This patch by <email deleted> was released
when 3.4.1 was current and has been incorporated into slash'em.  It is
extremely useful while using ranged weapons.  When both autopickup and
pickup_thrown are enabled, walking across previously thrown objects will
pick them up even if they don't match the current pickup_types list.
[See cvs log for patchlevel.h for longer description.]
This commit is contained in:
nethack.rankin
2006-05-13 04:57:52 +00:00
parent 151bff298c
commit 9151db8aaf
11 changed files with 41 additions and 20 deletions

View File

@@ -88,6 +88,7 @@ boolean restore;
otmp->cknown = 0;
otmp->invlet = 0;
otmp->no_charge = 0;
otmp->was_thrown = 0;
/* strip user-supplied names */
/* Statue and some corpse names are left intact,

View File

@@ -923,6 +923,7 @@ boolean twoweap; /* used to restore twoweapon mode if wielded weapon returns */
}
thrownobj = obj;
thrownobj->was_thrown = 1;
if(u.uswallow) {
mon = u.ustuck;

View File

@@ -298,6 +298,7 @@ struct obj *obj;
if (obj->where != OBJ_FREE)
panic("addinv: obj not free");
obj->no_charge = 0; /* not meaningful for invent */
obj->was_thrown = 0; /* ditto */
addinv_core1(obj);
#ifndef GOLDOBJ

View File

@@ -155,6 +155,7 @@ static struct Bool_Opt
{"page_wait", (boolean *)0, FALSE, SET_IN_FILE},
#endif
{"perm_invent", &flags.perm_invent, FALSE, SET_IN_GAME},
{"pickup_thrown", &flags.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*/

View File

@@ -662,35 +662,39 @@ menu_item **pick_list; /* list of objects and counts to pick up */
menu_item *pi; /* pick item */
struct obj *curr;
int n;
boolean pickit;
const char *otypes = flags.pickup_types;
/* first count the number of eligible items */
for (n = 0, curr = olist; curr; curr = FOLLOW(curr, follow))
#ifndef AUTOPICKUP_EXCEPTIONS
if (!*otypes || index(otypes, curr->oclass))
#else
if ((!*otypes || index(otypes, curr->oclass) ||
is_autopickup_exception(curr, TRUE)) &&
!is_autopickup_exception(curr, FALSE))
for (n = 0, curr = olist; curr; curr = FOLLOW(curr, follow)) {
pickit = (!*otypes || index(otypes, curr->oclass));
#ifdef AUTOPICKUP_EXCEPTIONS
/* check for "always pick up */
if (!pickit) pickit = is_autopickup_exception(curr, TRUE);
/* then for "never pick up */
if (pickit) pickit = !is_autopickup_exception(curr, FALSE);
#endif
n++;
/* pickup_thrown overrides pickup_types and exceptions */
if (!pickit) pickit = (flags.pickup_thrown && curr->was_thrown);
/* finally, do we count this object? */
if (pickit) ++n;
}
if (n) {
*pick_list = pi = (menu_item *) alloc(sizeof(menu_item) * n);
for (n = 0, curr = olist; curr; curr = FOLLOW(curr, follow))
#ifndef AUTOPICKUP_EXCEPTIONS
if (!*otypes || index(otypes, curr->oclass)) {
#else
if ((!*otypes || index(otypes, curr->oclass) ||
is_autopickup_exception(curr, TRUE)) &&
!is_autopickup_exception(curr, FALSE)) {
for (n = 0, curr = olist; curr; curr = FOLLOW(curr, follow)) {
pickit = (!*otypes || index(otypes, curr->oclass));
#ifdef AUTOPICKUP_EXCEPTIONS
if (!pickit) pickit = is_autopickup_exception(curr, TRUE);
if (pickit) pickit = !is_autopickup_exception(curr, FALSE);
#endif
if (!pickit) pickit = (flags.pickup_thrown && curr->was_thrown);
if (pickit) {
pi[n].item.a_obj = curr;
pi[n].count = curr->quan;
n++;
}
}
}
return n;
}