Show menu of possible actions hero could do with item otmp */
| 275 | |
| 276 | /* Show menu of possible actions hero could do with item otmp */ |
| 277 | int |
| 278 | itemactions(struct obj *otmp) |
| 279 | { |
| 280 | int n, act = IA_NONE; |
| 281 | winid win; |
| 282 | char buf[BUFSZ], buf2[BUFSZ]; |
| 283 | menu_item *selected; |
| 284 | struct monst *mtmp; |
| 285 | const char *light = otmp->lamplit ? "Extinguish" : "Light"; |
| 286 | boolean already_worn = (otmp->owornmask & (W_ARMOR | W_ACCESSORY)) != 0; |
| 287 | |
| 288 | win = create_nhwindow(NHW_MENU); |
| 289 | start_menu(win, MENU_BEHAVE_STANDARD); |
| 290 | |
| 291 | /* -: unwield; picking current weapon offers an opportunity for 'w-' |
| 292 | to wield bare/gloved hands; likewise for 'Q-' with quivered item(s) */ |
| 293 | if (otmp == uwep || otmp == uswapwep || otmp == uquiver) { |
| 294 | const char *verb = (otmp == uquiver) ? "Quiver" : "Wield", |
| 295 | *action = (otmp == uquiver) ? "un-ready" : "un-wield", |
| 296 | *which = is_plural(otmp) ? "these" : "this", |
| 297 | *what = ((otmp->oclass == WEAPON_CLASS || is_weptool(otmp)) |
| 298 | ? "weapon" : "item"); |
| 299 | /* |
| 300 | * TODO: if uwep is ammo, tell player that to shoot instead of toss, |
| 301 | * the corresponding launcher must be wielded; |
| 302 | */ |
| 303 | Sprintf(buf, "%s '%c' to %s %s %s", |
| 304 | verb, HANDS_SYM, action, which, |
| 305 | is_plural(otmp) ? makeplural(what) : what); |
| 306 | ia_addmenu(win, IA_UNWIELD, '-', buf); |
| 307 | } |
| 308 | |
| 309 | /* a: apply */ |
| 310 | if (otmp->oclass == COIN_CLASS) |
| 311 | ia_addmenu(win, IA_APPLY_OBJ, 'a', "Flip a coin"); |
| 312 | else if (otmp->otyp == CREAM_PIE) |
| 313 | ia_addmenu(win, IA_APPLY_OBJ, 'a', |
| 314 | "Hit yourself with this cream pie"); |
| 315 | else if (otmp->otyp == BULLWHIP) |
| 316 | ia_addmenu(win, IA_APPLY_OBJ, 'a', "Lash out with this whip"); |
| 317 | else if (otmp->otyp == GRAPPLING_HOOK) |
| 318 | ia_addmenu(win, IA_APPLY_OBJ, 'a', |
| 319 | "Grapple something with this hook"); |
| 320 | else if (otmp->otyp == BAG_OF_TRICKS && objects[otmp->otyp].oc_name_known) |
| 321 | /* bag of tricks skips this unless discovered */ |
| 322 | ia_addmenu(win, IA_APPLY_OBJ, 'a', "Reach into this bag"); |
| 323 | else if (Is_container(otmp)) |
| 324 | /* bag of tricks gets here only if not yet discovered */ |
| 325 | ia_addmenu(win, IA_APPLY_OBJ, 'a', "Open this container"); |
| 326 | else if (otmp->otyp == CAN_OF_GREASE) |
| 327 | ia_addmenu(win, IA_APPLY_OBJ, 'a', "Use the can to grease an item"); |
| 328 | else if (otmp->otyp == LOCK_PICK |
| 329 | || otmp->otyp == CREDIT_CARD |
| 330 | || otmp->otyp == SKELETON_KEY) |
| 331 | ia_addmenu(win, IA_APPLY_OBJ, 'a', "Use this tool to pick a lock"); |
| 332 | else if (otmp->otyp == TINNING_KIT) |
| 333 | ia_addmenu(win, IA_APPLY_OBJ, 'a', "Use this kit to tin a corpse"); |
| 334 | else if (otmp->otyp == LEASH) |
no test coverage detected