Add 'pickup_stolen' option

Add pickup_stolen option to autopick items stolen from you by a nymph or
monkey, even if they don't match your normal autopickup settings.
Replace was_dropped, was_thrown with a 2-bit bitfield that can contain
values LOST_DROPPED, LOST_THROWN, and LOST_STOLEN (or 0), since they
should all be mutually exclusive anyway as they track the most recent
way the item left the hero's inventory.

[Rebase/merge conflict fixed up.  PR]
This commit is contained in:
Michael Meyer
2023-11-17 09:37:16 -05:00
committed by PatR
parent ecda85cc32
commit 1736f3caaa
15 changed files with 54 additions and 23 deletions

View File

@@ -904,10 +904,12 @@ autopick_testobj(struct obj *otmp, boolean calc_costly)
if (costly && !otmp->no_charge)
return FALSE;
/* pickup_thrown/nopick_dropped override pickup_types and exceptions */
if (flags.pickup_thrown && otmp->was_thrown)
/* pickup_thrown/pickup_stolen/nopick_dropped override pickup_types and
exceptions */
if ((flags.pickup_thrown && otmp->how_lost == LOST_THROWN)
|| (flags.pickup_stolen && otmp->how_lost == LOST_STOLEN))
return TRUE;
if (flags.nopick_dropped && otmp->was_dropped)
if (flags.nopick_dropped && otmp->how_lost == LOST_DROPPED)
return FALSE;
/* check for pickup_types */
@@ -3667,7 +3669,7 @@ tipcontainer(struct obj *box) /* or bag */
(void) add_to_container(targetbox, otmp);
}
} else if (highdrop) {
otmp->was_dropped = 1;
otmp->how_lost = LOST_DROPPED;
/* might break or fall down stairs; handles altars itself */
hitfloor(otmp, TRUE);
} else {
@@ -3680,7 +3682,7 @@ tipcontainer(struct obj *box) /* or bag */
pline("%s%c", doname(otmp), nobj ? ',' : '.');
iflags.last_msg = PLNMSG_OBJNAM_ONLY;
}
otmp->was_dropped = 1;
otmp->how_lost = LOST_DROPPED;
dropy(otmp);
if (iflags.last_msg != PLNMSG_OBJNAM_ONLY)
terse = FALSE; /* terse formatting has been interrupted */