throw-and-return vs !fixinv

Implement the request that a wielded+thrown aklys be given the same
inventory letter when it returns and is caught and rewielded, even for
the !fixinv setting where inventory letters don't stick.  Works for
Valkyrie-thrown Mjollnir and returning (ie, didn't hit) boomerangs as
well as for aklys.

I'm not sure how useful this really is, because on the rare occasions
that it either doesn't return or fails to be caught, it won't be given
the same letter when subsequently picked up.  So the player who relies
on it will still be vulnerable to using the wrong letter next time a
throw is attempted.  But at least picking it up explicitly displays
the new inventory letter, unlike catching it upon return.
This commit is contained in:
PatR
2020-03-01 06:46:37 -08:00
parent 297863d4bc
commit 99035e72ee
5 changed files with 60 additions and 21 deletions

View File

@@ -1,4 +1,4 @@
/* NetHack 3.7 invent.c $NHDT-Date: 1581322662 2020/02/10 08:17:42 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.290 $ */
/* NetHack 3.7 invent.c $NHDT-Date: 1583073990 2020/03/01 14:46:30 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.294 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Derek S. Ray, 2015. */
/* NetHack may be freely redistributed. See license for details. */
@@ -19,6 +19,7 @@ static int FDECL(invletter_value, (CHAR_P));
static int FDECL(CFDECLSPEC sortloot_cmp, (const genericptr,
const genericptr));
static void NDECL(reorder_invent);
static struct obj *FDECL(addinv_core0, (struct obj *, struct obj *));
static void FDECL(noarmor, (BOOLEAN_P));
static void FDECL(invdisp_nothing, (const char *, const char *));
static boolean FDECL(worn_wield_only, (struct obj *));
@@ -873,9 +874,9 @@ struct obj *obj;
* Add obj to the hero's inventory. Make sure the object is "free".
* Adjust hero attributes as necessary.
*/
struct obj *
addinv(obj)
struct obj *obj;
static struct obj *
addinv_core0(obj, other_obj)
struct obj *obj, *other_obj;
{
struct obj *otmp, *prev;
int saved_otyp = (int) obj->otyp; /* for panic */
@@ -893,6 +894,20 @@ struct obj *obj;
addinv_core1(obj);
/* for addinv_before(); if something has been removed and is now being
reinserted, try to put it in the same place instead of merging or
placing at end; for thrown-and-return weapon with !fixinv setting */
if (other_obj) {
for (otmp = g.invent; otmp; otmp = otmp->nobj) {
if (otmp->nobj == other_obj) {
obj->nobj = other_obj;
otmp->nobj = obj;
obj->where = OBJ_INVENT;
goto added;
}
}
}
/* merge with quiver in preference to any other inventory slot
in case quiver and wielded weapon are both eligible; adding
extra to quivered stack is more useful than to wielded one */
@@ -939,6 +954,22 @@ struct obj *obj;
return obj;
}
/* add obj to the hero's inventory in the default fashion */
struct obj *
addinv(obj)
struct obj *obj;
{
return addinv_core0(obj, (struct obj *) 0);
}
/* add obj to the hero's inventory by inserting in front of a specific item */
struct obj *
addinv_before(obj, other_obj)
struct obj *obj, *other_obj;
{
return addinv_core0(obj, other_obj);
}
/*
* Some objects are affected by being carried.
* Make those adjustments here. Called _after_ the object