inventory item-action: add '-' for uswapwep

There's no 'w-' or 'Q-' for alternate weapon, but context-sensitive
inventory is starting from the object rather than the command so can
finesse that.  'A' does allow alternate weapon to be directly unset
(aka reset to bare/gloved hands) but is not friendly to being passed
queued input.

This adds an extra internal command which only handles unset uswapwep,
even though that is something which is awfully specialized to get it's
own command.  Users don't see this command so that shouldn't matter.
This commit is contained in:
PatR
2022-04-23 11:58:52 -07:00
parent dce05d487a
commit c2ac36f0c9
4 changed files with 42 additions and 11 deletions

View File

@@ -568,6 +568,7 @@ extern struct obj *stuck_ring(struct obj *, int);
extern struct obj *unchanger(void);
extern void reset_remarm(void);
extern int doddoremarm(void);
extern int remarm_swapwep(void);
extern int destroy_arm(struct obj *);
extern void adj_abon(struct obj *, schar);
extern boolean inaccessible_equipment(struct obj *, const char *, boolean);

View File

@@ -2606,6 +2606,7 @@ struct ext_func_tab extcmdlist[] = {
{ '\0', "clicklook", NULL, doclicklook, INTERNALCMD, NULL },
{ '\0', "altdip", NULL, dip_into, INTERNALCMD, NULL },
{ '\0', "altadjust", NULL, adjust_split, INTERNALCMD, NULL },
{ '\0', "altunwield", NULL, remarm_swapwep, INTERNALCMD, NULL },
{ '\0', (char *) 0, (char *) 0, donull, 0, (char *) 0 } /* sentinel */
};

View File

@@ -86,10 +86,10 @@ on_msg(struct obj *otmp)
give feedback and discover it iff stealth state is changing */
static
void
toggle_stealth(struct obj *obj,
long oldprop, /* prop[].extrinsic, with obj->owornmask
stripped by caller */
boolean on)
toggle_stealth(
struct obj *obj,
long oldprop, /* prop[].extrinsic, with obj->owornmask pre-stripped */
boolean on)
{
if (on ? g.initial_don : g.context.takeoff.cancelled_don)
return;
@@ -2825,8 +2825,8 @@ doddoremarm(void)
You("continue %s.", g.context.takeoff.disrobing);
set_occupation(take_off, g.context.takeoff.disrobing, 0);
return ECMD_OK;
} else if (!uwep && !uswapwep && !uquiver && !uamul && !ublindf && !uleft
&& !uright && !wearing_armor()) {
} else if (!uwep && !uswapwep && !uquiver && !uamul && !ublindf
&& !uleft && !uright && !wearing_armor()) {
You("are not wearing anything.");
return ECMD_OK;
}
@@ -2854,6 +2854,36 @@ doddoremarm(void)
return ECMD_OK;
}
/* #altunwield - just unwield alternate weapon, item-action '-' when picking
uswapwep from context-sensitive inventory */
int
remarm_swapwep(void)
{
struct _cmd_queue cq, *cmdq;
boolean oldbknown;
if ((cmdq = cmdq_pop()) != 0) {
/* '-' uswapwep item-action picked from context-sensitive invent */
cq = *cmdq;
free(cmdq);
} else {
cq.typ = CMDQ_KEY;
cq.key = '\0'; /* something other than '-' */
}
if (cq.typ != CMDQ_KEY || cq.key != '-' || !uswapwep)
return ECMD_FAIL;
oldbknown = uswapwep->bknown; /* when deciding whether this command
* has done something that takes time,
* behave as if a cursed secondary weapon
* can't be unwielded even though things
* don't work that way... */
reset_remarm();
g.context.takeoff.what = g.context.takeoff.mask = W_SWAPWEP;
(void) do_takeoff();
return (!uswapwep || uswapwep->bknown != oldbknown) ? ECMD_TIME : ECMD_OK;
}
static int
menu_remarm(int retry)
{

View File

@@ -2656,7 +2656,7 @@ itemactions(struct obj *otmp)
/* -: unwield; picking current weapon offers an opportunity for 'w-'
to wield bare/gloved hands; likewise for 'Q-' with quivered item(s) */
if (otmp == uwep || otmp == uquiver) {
if (otmp == uwep || otmp == uswapwep || otmp == uquiver) {
const char *verb = (otmp == uquiver) ? "Quiver" : "Wield",
*action = (otmp == uquiver) ? "un-ready" : "un-wield",
*which = is_plural(otmp) ? "these" : "this",
@@ -2665,8 +2665,6 @@ itemactions(struct obj *otmp)
/*
* TODO: if uwep is ammo, tell player that to shoot instead of toss,
* the corresponding launcher must be wielded;
* TODO too: if otmp is uswapwep, remove it from that slot (possibly
* stopping dual-wielding in the process).
*/
Sprintf(buf, "%s '%c' to %s %s %s",
verb, HANDS_SYM, action, which,
@@ -2942,8 +2940,9 @@ itemactions(struct obj *otmp)
break;
case IA_UNWIELD:
cmdq_add_ec((otmp == uwep) ? dowield
: (otmp == uquiver) ? dowieldquiver
: donull); /* can't happen */
: (otmp == uswapwep) ? remarm_swapwep
: (otmp == uquiver) ? dowieldquiver
: donull); /* can't happen */
cmdq_add_key('-');
break;
case IA_APPLY_OBJ: