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

View File

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

View File

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