Fix autowielding tools taking no time

When applying some tools (whips, polearms, grapples), or rubbing
a lamp, or when fireassist is on and you fire something without
wielded launcher, the automatic wielding should take as much time
as wielding the item normally does.

Fixes #696
This commit is contained in:
Pasi Kallinen
2022-03-15 11:34:45 +02:00
parent cc04bf9d8f
commit 006ae67029
3 changed files with 36 additions and 21 deletions

View File

@@ -1576,8 +1576,14 @@ dorub(void)
return ECMD_OK;
}
}
if (!wield_tool(obj, "rub"))
if (obj != uwep) {
if (wield_tool(obj, "rub")) {
cmdq_add_ec(dorub);
cmdq_add_key(obj->invlet);
return ECMD_TIME;
}
return ECMD_OK;
}
/* now uwep is obj */
if (uwep->otyp == MAGIC_LAMP) {
@@ -2686,9 +2692,12 @@ use_whip(struct obj *obj)
const char *msg_snap = "Snap!";
if (obj != uwep) {
if (!wield_tool(obj, "lash"))
return ECMD_OK;
res = ECMD_TIME;
if (wield_tool(obj, "lash")) {
cmdq_add_ec(doapply);
cmdq_add_key(obj->invlet);
return ECMD_TIME;
}
return ECMD_OK;
}
if (!getdir((char *) 0))
return (res|ECMD_CANCEL);
@@ -3078,9 +3087,12 @@ use_pole(struct obj *obj, boolean autohit)
return ECMD_OK;
}
if (obj != uwep) {
if (!wield_tool(obj, "swing"))
return ECMD_OK;
res = ECMD_TIME;
if (wield_tool(obj, "swing")) {
cmdq_add_ec(doapply);
cmdq_add_key(obj->invlet);
return ECMD_TIME;
}
return ECMD_OK;
}
/* assert(obj == uwep); */
@@ -3331,10 +3343,12 @@ use_grapple(struct obj *obj)
return ECMD_OK;
}
if (obj != uwep) {
if (!wield_tool(obj, "cast"))
return ECMD_OK;
else
res = ECMD_TIME;
if (wield_tool(obj, "cast")) {
cmdq_add_ec(doapply);
cmdq_add_key(obj->invlet);
return ECMD_TIME;
}
return ECMD_OK;
}
/* assert(obj == uwep); */
@@ -3947,12 +3961,10 @@ doapply(void)
break;
}
pline("Sorry, I don't know how to use that.");
nomul(0);
return ECMD_OK;
return ECMD_FAIL;
}
if ((res & ECMD_TIME) && obj && obj->oartifact)
arti_speak(obj);
nomul(0);
return res;
}

View File

@@ -966,10 +966,13 @@ use_pick_axe(struct obj *obj)
/* Check tool */
if (obj != uwep) {
if (!wield_tool(obj, "swing"))
return ECMD_OK;
else
res = ECMD_TIME;
if (wield_tool(obj, "swing")) {
/* we're now wielding it. next turn, apply to dig. */
cmdq_add_ec(doapply);
cmdq_add_key(obj->invlet);
return ECMD_TIME;
}
return ECMD_OK;
}
ispick = is_pick(obj);
verb = ispick ? "dig" : "chop";

View File

@@ -461,7 +461,7 @@ dofire(void)
swap to it and retry */
cmdq_add_ec(doswapweapon);
cmdq_add_ec(dofire);
return ECMD_OK;
return ECMD_TIME;
} else
You("have no ammunition readied.");
}
@@ -502,7 +502,7 @@ dofire(void)
/* swap weapons and retry fire */
cmdq_add_ec(doswapweapon);
cmdq_add_ec(dofire);
return ECMD_OK;
return ECMD_TIME;
} else if ((olauncher = find_launcher(obj)) != 0) {
/* wield launcher, retry fire */
if (uwep && !flags.pushweapon)
@@ -510,7 +510,7 @@ dofire(void)
cmdq_add_ec(dowield);
cmdq_add_key(olauncher->invlet);
cmdq_add_ec(dofire);
return ECMD_OK;
return ECMD_TIME;
}
}