Add assistance to fire-command
Allows the fire-command to autowield a launcher; it will now do either swapweapon or wield an appropriate launcher, if you have ammo quivered. This assistance can be turned off with the fireassist boolean option. Adds a rudimentary command queue, which allows the code to add keys or extended commands into the queue, and they're executed as if the user did them. Time passes normally when doing the queue, and the queue will get cleared if hero is interrupted.
This commit is contained in:
25
src/invent.c
25
src/invent.c
@@ -1488,6 +1488,31 @@ getobj(const char *word,
|
||||
boolean oneloop = FALSE;
|
||||
Loot *sortedinvent, *srtinv;
|
||||
|
||||
struct _cmd_queue *cmdq = cmdq_pop();
|
||||
|
||||
if (cmdq) {
|
||||
/* it's not a key, abort */
|
||||
if (cmdq->typ != CMDQ_KEY) {
|
||||
free(cmdq);
|
||||
return (struct obj *)0;
|
||||
}
|
||||
|
||||
for (otmp = g.invent; otmp; otmp = otmp->nobj)
|
||||
if (otmp->invlet == cmdq->key) {
|
||||
int v = (*obj_ok)(otmp);
|
||||
|
||||
if (v == GETOBJ_SUGGEST || v == GETOBJ_DOWNPLAY) {
|
||||
free(cmdq);
|
||||
return otmp;
|
||||
}
|
||||
}
|
||||
|
||||
/* did not find the object, abort */
|
||||
free(cmdq);
|
||||
cmdq_clear();
|
||||
return (struct obj *)0;
|
||||
}
|
||||
|
||||
/* is "hands"/"self" a valid thing to do this action on? */
|
||||
switch ((*obj_ok)((struct obj *) 0)) {
|
||||
case GETOBJ_SUGGEST: /* treat as likely candidate */
|
||||
|
||||
Reference in New Issue
Block a user