Add option to exclude dropped items from autopick
This is based on a feature in UnNetHack (and I think some other variants as well). If the hero intentionally drops an item with 'pickup_dropped' disabled, don't autopick it back up when walking over that square again. Typically when the player drops an item, it's because she doesn't want it in her inventory any more, and this option stops autopickup from defeating that goal (especially useful for tasks like stash management without a container). Players have come up with workarounds to this problem like toggling autopickup when approaching their stash pile or adding name-based autopickup exceptions to allow them to exclude individual items from autopickup, but this behavior should reduce the need for those things. I think 'pickup_dropped' is a little unfortunate because it suggests equivalence to 'pickup_thrown' (i.e. any dropped items will be automatically picked up regardless of autopickup exceptions). Calling it something like 'nopick_dropped' might be better, but as far as I can tell options cannot start with the word 'no' because it's interpreted as a negation of the rest of the option name.
This commit is contained in:
@@ -108,6 +108,7 @@ resetobjs(struct obj *ochain, boolean restore)
|
||||
otmp->invlet = 0;
|
||||
otmp->no_charge = 0;
|
||||
otmp->was_thrown = 0;
|
||||
otmp->was_dropped = 0;
|
||||
|
||||
/* strip user-supplied names */
|
||||
/* Statue and some corpse names are left intact,
|
||||
|
||||
1
src/do.c
1
src/do.c
@@ -760,6 +760,7 @@ drop(struct obj *obj)
|
||||
if (!IS_ALTAR(levl[u.ux][u.uy].typ) && flags.verbose)
|
||||
You("drop %s.", doname(obj));
|
||||
}
|
||||
obj->was_dropped = 1;
|
||||
dropx(obj);
|
||||
return ECMD_TIME;
|
||||
}
|
||||
|
||||
@@ -1050,7 +1050,7 @@ addinv_core0(struct obj *obj, struct obj *other_obj,
|
||||
if (Has_contents(obj))
|
||||
picked_container(obj); /* clear no_charge */
|
||||
obj_was_thrown = obj->was_thrown;
|
||||
obj->was_thrown = 0; /* not meaningful for invent */
|
||||
obj->was_thrown = obj->was_dropped = 0; /* not meaningful for invent */
|
||||
|
||||
if (gl.loot_reset_justpicked) {
|
||||
gl.loot_reset_justpicked = FALSE;
|
||||
|
||||
@@ -8593,7 +8593,8 @@ doset_simple_menu(void)
|
||||
/* pickup_types is separated from autopickup due to the
|
||||
spelling of their names; emphasize what it means */
|
||||
if (allopt[i].idx == opt_pickup_types
|
||||
|| allopt[i].idx == opt_pickup_thrown)
|
||||
|| allopt[i].idx == opt_pickup_thrown
|
||||
|| allopt[i].idx == opt_pickup_dropped)
|
||||
Strcat(buf, " (for autopickup)");
|
||||
add_menu(tmpwin, &nul_glyphinfo, &any, 0, 0,
|
||||
ATR_NONE, NO_COLOR, buf, MENU_ITEMFLAGS_NONE);
|
||||
|
||||
11
src/pickup.c
11
src/pickup.c
@@ -904,6 +904,12 @@ autopick_testobj(struct obj *otmp, boolean calc_costly)
|
||||
if (costly && !otmp->no_charge)
|
||||
return FALSE;
|
||||
|
||||
/* pickup_thrown/!pickup_dropped override pickup_types and exceptions */
|
||||
if (flags.pickup_thrown && otmp->was_thrown)
|
||||
return TRUE;
|
||||
if (!flags.pickup_dropped && otmp->was_dropped)
|
||||
return FALSE;
|
||||
|
||||
/* check for pickup_types */
|
||||
pickit = (!*otypes || strchr(otypes, otmp->oclass));
|
||||
|
||||
@@ -912,9 +918,6 @@ autopick_testobj(struct obj *otmp, boolean calc_costly)
|
||||
if (ape)
|
||||
pickit = ape->grab;
|
||||
|
||||
/* pickup_thrown overrides pickup_types and exceptions */
|
||||
if (!pickit)
|
||||
pickit = (flags.pickup_thrown && otmp->was_thrown);
|
||||
return pickit;
|
||||
}
|
||||
|
||||
@@ -3664,6 +3667,7 @@ tipcontainer(struct obj *box) /* or bag */
|
||||
(void) add_to_container(targetbox, otmp);
|
||||
}
|
||||
} else if (highdrop) {
|
||||
otmp->was_dropped = 1;
|
||||
/* might break or fall down stairs; handles altars itself */
|
||||
hitfloor(otmp, TRUE);
|
||||
} else {
|
||||
@@ -3676,6 +3680,7 @@ tipcontainer(struct obj *box) /* or bag */
|
||||
pline("%s%c", doname(otmp), nobj ? ',' : '.');
|
||||
iflags.last_msg = PLNMSG_OBJNAM_ONLY;
|
||||
}
|
||||
otmp->was_dropped = 1;
|
||||
dropy(otmp);
|
||||
if (iflags.last_msg != PLNMSG_OBJNAM_ONLY)
|
||||
terse = FALSE; /* terse formatting has been interrupted */
|
||||
|
||||
Reference in New Issue
Block a user