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.6 dothrow.c $NHDT-Date: 1579655027 2020/01/22 01:03:47 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.181 $ */
/* NetHack 3.6 dothrow.c $NHDT-Date: 1583073990 2020/03/01 14:46:30 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.183 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Robert Patrick Rankin, 2013. */
/* NetHack may be freely redistributed. See license for details. */
@@ -80,7 +80,7 @@ throw_obj(obj, shotlimit)
struct obj *obj;
int shotlimit;
{
struct obj *otmp;
struct obj *otmp, *oldslot;
int multishot;
schar skill;
long wep_mask;
@@ -228,6 +228,7 @@ int shotlimit;
}
wep_mask = obj->owornmask;
oldslot = 0;
g.m_shot.o = obj->otyp;
g.m_shot.n = multishot;
for (g.m_shot.i = 1; g.m_shot.i <= g.m_shot.n; g.m_shot.i++) {
@@ -239,9 +240,10 @@ int shotlimit;
otmp = obj;
if (otmp->owornmask)
remove_worn_item(otmp, FALSE);
oldslot = obj->nobj;
}
freeinv(otmp);
throwit(otmp, wep_mask, twoweap);
throwit(otmp, wep_mask, twoweap, oldslot);
}
g.m_shot.n = g.m_shot.i = 0;
g.m_shot.o = STRANGE_OBJECT;
@@ -429,7 +431,8 @@ boolean verbose;
if (g.m_shot.i < g.m_shot.n) {
if (verbose && !g.context.mon_moving) {
You("stop %s after the %d%s %s.",
g.m_shot.s ? "firing" : "throwing", g.m_shot.i, ordin(g.m_shot.i),
g.m_shot.s ? "firing" : "throwing",
g.m_shot.i, ordin(g.m_shot.i),
g.m_shot.s ? "shot" : "toss");
}
g.m_shot.n = g.m_shot.i; /* make current shot be the last */
@@ -1107,10 +1110,11 @@ struct obj *obj;
/* throw an object, NB: obj may be consumed in the process */
void
throwit(obj, wep_mask, twoweap)
throwit(obj, wep_mask, twoweap, oldslot)
struct obj *obj;
long wep_mask; /* used to re-equip returning boomerang */
boolean twoweap; /* used to restore twoweapon mode if wielded weapon returns */
struct obj *oldslot; /* for thrown-and-return used with !fixinv */
{
register struct monst *mon;
int range, urange;
@@ -1183,7 +1187,7 @@ boolean twoweap; /* used to restore twoweapon mode if wielded weapon returns */
&& !impaired) {
pline("%s the %s and returns to your hand!", Tobjnam(obj, "hit"),
ceiling(u.ux, u.uy));
obj = addinv(obj);
obj = addinv_before(obj, oldslot);
(void) encumber_msg();
if (obj->owornmask & W_QUIVER) /* in case addinv() autoquivered */
setuqwep((struct obj *) 0);
@@ -1208,7 +1212,7 @@ boolean twoweap; /* used to restore twoweapon mode if wielded weapon returns */
mon = boomhit(obj, u.dx, u.dy);
if (mon == &g.youmonst) { /* the thing was caught */
exercise(A_DEX, TRUE);
obj = addinv(obj);
obj = addinv_before(obj, oldslot);
(void) encumber_msg();
if (wep_mask && !(obj->owornmask & wep_mask)) {
setworn(obj, wep_mask);
@@ -1340,7 +1344,7 @@ boolean twoweap; /* used to restore twoweapon mode if wielded weapon returns */
if (!impaired && rn2(100)) {
pline("%s to your hand!", Tobjnam(obj, "return"));
obj = addinv(obj);
obj = addinv_before(obj, oldslot);
(void) encumber_msg();
/* addinv autoquivers an aklys if quiver is empty;
if obj is quivered, remove it before wielding */
@@ -1366,8 +1370,8 @@ boolean twoweap; /* used to restore twoweapon mode if wielded weapon returns */
Tobjnam(obj, Blind ? "hit" : "fly"),
body_part(ARM));
if (obj->oartifact)
(void) artifact_hit((struct monst *) 0, &g.youmonst,
obj, &dmg, 0);
(void) artifact_hit((struct monst *) 0,
&g.youmonst, obj, &dmg, 0);
losehp(Maybe_Half_Phys(dmg), killer_xname(obj),
KILLED_BY);
}