item actions for accessories

Update item actions for rings, amulets, and eyewear.  Make 'P' for an
accessory that isn't worn behave similarly to recently modified 'W',
and make 'R' for an accessory that is worn be more specific.
This commit is contained in:
PatR
2025-10-15 23:49:52 -07:00
parent 98b526eb15
commit da20b839b5
+31 -11
View File
@@ -3333,15 +3333,29 @@ itemactions(struct obj *otmp)
/* P: put on accessory */ /* P: put on accessory */
if (!already_worn) { if (!already_worn) {
if (otmp->oclass == RING_CLASS || otmp->otyp == MEAT_RING) /* if 'otmp' is worn, we'll skip 'P' and show 'R' below;
ia_addmenu(win, IA_WEAR_OBJ, 'P', "Put this ring on"); if not worn, we show 'P - Put on this <simple-item>' if
else if (otmp->oclass == AMULET_CLASS) the slot is available, or 'P - <unavailable>'; for the latter,
ia_addmenu(win, IA_WEAR_OBJ, 'P', "Put this amulet on"); 'P' will fail but we don't want to omit the choice because
else if (otmp->otyp == TOWEL || otmp->otyp == BLINDFOLD) item actions can be used to learn commands */
ia_addmenu(win, IA_WEAR_OBJ, 'P', *buf = '\0';
"Use this to blindfold yourself"); if (otmp->oclass == RING_CLASS || otmp->otyp == MEAT_RING) {
else if (otmp->otyp == LENSES) Strcpy(buf, (!uleft || !uright) ? "Put this ring on"
ia_addmenu(win, IA_WEAR_OBJ, 'P', "Put these lenses on"); : "[both ring fingers in use]");
} else if (otmp->oclass == AMULET_CLASS) {
Strcpy(buf, !uamul ? "Put this amulet on"
: "[already wearing an amulet]");
} else if (otmp->otyp == TOWEL || otmp->otyp == BLINDFOLD
|| otmp->otyp == LENSES) {
if (ublindf)
Strcpy(buf, "[already wearing eyewear]");
else if (otmp->otyp == LENSES)
Strcpy(buf, "Put these lenses on");
else
Strcpy(buf, "Use this to blindfold yourself");
}
if (*buf)
ia_addmenu(win, IA_WEAR_OBJ, 'P', buf);
} }
/* q: drink item */ /* q: drink item */
@@ -3365,8 +3379,14 @@ itemactions(struct obj *otmp)
ia_addmenu(win, IA_READ_OBJ, 'r', buf); ia_addmenu(win, IA_READ_OBJ, 'r', buf);
/* R: remove accessory or rub item */ /* R: remove accessory or rub item */
if (otmp->owornmask & W_ACCESSORY) if (otmp->owornmask & W_ACCESSORY) {
ia_addmenu(win, IA_TAKEOFF_OBJ, 'R', "Remove this accessory"); Sprintf(buf, "Remove this %s",
(otmp->owornmask & W_RING) ? "ring"
: (otmp->owornmask & W_AMUL) ? "amulet"
: (otmp->owornmask & W_TOOL) ? "eyewear"
: "accessory"); /* catchall */
ia_addmenu(win, IA_TAKEOFF_OBJ, 'R', buf);
}
if (otmp->otyp == OIL_LAMP || otmp->otyp == MAGIC_LAMP if (otmp->otyp == OIL_LAMP || otmp->otyp == MAGIC_LAMP
|| otmp->otyp == BRASS_LANTERN) { || otmp->otyp == BRASS_LANTERN) {
Sprintf(buf, "Rub this %s", simpleonames(otmp)); Sprintf(buf, "Rub this %s", simpleonames(otmp));