From ae83a430c6928b5f151f00a3ee392a6955c2014d Mon Sep 17 00:00:00 2001 From: PatR Date: Wed, 13 Dec 2023 20:44:13 -0800 Subject: [PATCH] refine pickup_thrown+pickup_stolen+dropped_nopick If a monster picks up an item thrown by the hero, change its 'how_lost' flag from LOST_THROWN to LOST_STOLEN and pickup_stolen will be used instead of pickup_thrown to decide whether to override pickup_types and autopickup exceptions when hero eventually steps on it. If a monster picks up an item dropped by the hero, change its flag to LOST_NONE and autopickup will work normally without being overridden by dropped_nopick. If item is flagged as stolen, leave it that way. --- src/steal.c | 34 +++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/src/steal.c b/src/steal.c index 1ddf9da5b..cffd55dc2 100644 --- a/src/steal.c +++ b/src/steal.c @@ -1,4 +1,4 @@ -/* NetHack 3.7 steal.c $NHDT-Date: 1646688070 2022/03/07 21:21:10 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.98 $ */ +/* NetHack 3.7 steal.c $NHDT-Date: 1702529046 2023/12/14 04:44:06 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.114 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /*-Copyright (c) Robert Patrick Rankin, 2012. */ /* NetHack may be freely redistributed. See license for details. */ @@ -573,17 +573,29 @@ mpickobj(struct monst *mtmp, struct obj *otmp) pline("%s out.", Tobjnam(otmp, "go")); snuff_otmp = TRUE; } - /* for hero owned object on shop floor, mtmp is taking possession - and if it's eventually dropped in a shop, shk will claim it */ - if (!mtmp->mtame) + /* some object handling is only done if mtmp isn't a pet */ + if (!mtmp->mtame) { + /* for hero owned object on shop floor, mtmp is taking possession + and if it's eventually dropped in a shop, shk will claim it */ otmp->no_charge = 0; - /* if monster is unseen, info hero knows about this object becomes lost; - continual pickup and drop by pets makes this too annoying if it is - applied to them; when engulfed (where monster can't be seen because - vision is disabled), or when held (or poly'd and holding) while blind, - behave as if the monster can be 'seen' by touch */ - if (!mtmp->mtame && !(canseemon(mtmp) || mtmp == u.ustuck)) - unknow_object(otmp); + /* if monst is unseen, some info hero knows about this object becomes + lost; continual pickup and drop by pets makes this too annoying if + it is applied to them; when engulfed (where monster can't be seen + because vision is disabled), or when held (or poly'd and holding) + while blind, behave as if the monster can be 'seen' by touch */ + if (!canseemon(mtmp) && mtmp != u.ustuck) + unknow_object(otmp); + /* if otmp has flags set for how it left hero's inventory, change + those flags; if thrown, now stolen and autopickup might override + pickup_types and autopickup exceptions based on 'pickup_stolen' + rather than 'pickup_thrown'; if previously stolen, stays stolen; + if previously dropped, now forgotten and autopickup will operate + normally regardless of the setting for 'dropped_nopick' */ + if (otmp->how_lost == LOST_THROWN) + otmp->how_lost = LOST_STOLEN; + else if (otmp->how_lost == LOST_DROPPED) + otmp->how_lost = LOST_NONE; + } /* Must do carrying effects on object prior to add_to_minv() */ carry_obj_effects(otmp); /* add_to_minv() might free otmp [if merged with something else],