do_run_southwest, MOVEMENTCMD | CMD_M_PREFIX, NULL },
/* internal commands: only used by game core, not available for user */
- { '\0', "clicklook", NULL, doclicklook, INTERNALCMD, NULL },
+ { '\0', "clicklook", NULL, doclicklook, INTERNALCMD, NULL },
+ { '\0', "altdip", NULL, dip_into, INTERNALCMD, NULL },
{ '\0', (char *) 0, (char *) 0, donull, 0, (char *) 0 } /* sentinel */
};
} else if (otmp->otyp == POT_OIL && objects[otmp->otyp].oc_name_known) {
Sprintf(buf, "%s this oil", light);
ia_addmenu(win, IA_APPLY_OBJ, 'a', buf);
- } else if (otmp->oclass == POTION_CLASS)
- ia_addmenu(win, IA_DIP_OBJ, 'a', "Dip something into this potion");
- else if (otmp->otyp == EXPENSIVE_CAMERA)
+ } else if (otmp->oclass == POTION_CLASS) {
+ /* FIXME? this should probably be moved to 'D' rather than be 'a' */
+ Sprintf(buf, "Dip something into %s potion%s",
+ is_plural(otmp) ? "one of these" : "this", plur(otmp->quan));
+ ia_addmenu(win, IA_DIP_OBJ, 'a', buf);
+ } else if (otmp->otyp == EXPENSIVE_CAMERA)
ia_addmenu(win, IA_APPLY_OBJ, 'a', "Take a photograph");
else if (otmp->otyp == TOWEL)
ia_addmenu(win, IA_APPLY_OBJ, 'a',
cmdq_add_key(otmp->invlet);
break;
case IA_DIP_OBJ:
- cmdq_add_ec(dodip);
- cmdq_add_userinput();
+ /*cmdq_add_ec(dodip);*/
+ /*cmdq_add_userinput();*/
+ cmdq_add_ec(dip_into);
cmdq_add_key(otmp->invlet);
break;
case IA_DROP_OBJ:
static int dip_ok(struct obj *);
static void hold_potion(struct obj *, const char *, const char *,
const char *);
+static int potion_dip(struct obj *obj, struct obj *potion);
/* force `val' to be within valid range for intrinsic timeout value */
static long
/* they went up a level */
if ((ledger_no(&u.uz) == 1 && u.uhave.amulet)
|| Can_rise_up(u.ux, u.uy, &u.uz)) {
- const char *riseup = "rise up, through the %s!";
+ static const char *riseup = "rise up, through the %s!";
if (ledger_no(&u.uz) == 1) {
You(riseup, ceiling(u.ux, u.uy));
goto_level(&earth_level, FALSE, FALSE, FALSE);
} else {
- register int newlev = depth(&u.uz) - 1;
+ int newlev = depth(&u.uz) - 1;
d_level newlevel;
get_level(&newlevel, newlev);
return;
}
-/* #dip command */
+/* #dip command - get item to dip, then get potion to dip it into */
int
dodip(void)
{
static const char Dip_[] = "Dip ";
- register struct obj *potion, *obj;
- struct obj *singlepotion;
+ struct obj *potion, *obj;
uchar here;
- short mixture;
char qbuf[QBUFSZ], obuf[QBUFSZ];
const char *shortestname; /* last resort obj name for prompt */
}
/* "What do you want to dip <the object> into? [xyz or ?*] " */
- Snprintf(qbuf, sizeof(qbuf), "dip %s into",
+ Snprintf(qbuf, sizeof qbuf, "dip %s into",
flags.verbose ? obuf : shortestname);
potion = getobj(qbuf, drink_ok, GETOBJ_NOFLAGS);
if (!potion)
return ECMD_CANCEL;
+ return potion_dip(obj, potion);
+}
+
+/* #altdip - for context-sensitive inventory item-action;
+ potion already selected */
+int
+dip_into(void)
+{
+ struct obj *obj, *potion;
+ char qbuf[QBUFSZ];
+
+ if (!cmdq_peek())
+ panic("dip_into: where is potion?");
+ potion = getobj("dip", drink_ok, GETOBJ_NOFLAGS);
+ if (!potion || potion->oclass != POTION_CLASS)
+ return ECMD_CANCEL;
+
+ /* "What do you want to dip into <the potion>? [abc or ?*] " */
+ Snprintf(qbuf, sizeof qbuf, "dip into %s%s",
+ is_plural(potion) ? "one of " : "", thesimpleoname(potion));
+ obj = getobj(qbuf, dip_ok, GETOBJ_PROMPT);
+ if (!obj)
+ return ECMD_CANCEL;
+ if (inaccessible_equipment(obj, "dip", FALSE))
+ return ECMD_OK;
+ return potion_dip(obj, potion);
+}
+
+/* called by dodip() or dip_into() after obj and potion have been chosen */
+static int
+potion_dip(struct obj *obj, struct obj *potion)
+{
+ struct obj *singlepotion;
+ char qbuf[QBUFSZ];
+ short mixture;
+
if (potion == obj && potion->quan == 1L) {
pline("That is a potion bottle, not a Klein bottle!");
return ECMD_OK;