used for #rub and for applying pick-axe, whip, grappling hook or polearm */
| 680 | |
| 681 | /* used for #rub and for applying pick-axe, whip, grappling hook or polearm */ |
| 682 | boolean |
| 683 | wield_tool(struct obj *obj, |
| 684 | const char *verb) /* "rub",&c */ |
| 685 | { |
| 686 | const char *what; |
| 687 | boolean more_than_1; |
| 688 | |
| 689 | if (uwep && obj == uwep) |
| 690 | return TRUE; /* nothing to do if already wielding it */ |
| 691 | |
| 692 | if (!verb) |
| 693 | verb = "wield"; |
| 694 | what = xname(obj); |
| 695 | more_than_1 = (obj->quan > 1L || strstri(what, "pair of ") != 0 |
| 696 | || strstri(what, "s of ") != 0); |
| 697 | |
| 698 | if (obj->owornmask & (W_ARMOR | W_ACCESSORY)) { |
| 699 | You_cant("%s %s while wearing %s.", verb, yname(obj), |
| 700 | more_than_1 ? "them" : "it"); |
| 701 | return FALSE; |
| 702 | } |
| 703 | if (uwep && welded(uwep)) { |
| 704 | if (flags.verbose) { |
| 705 | const char *hand = body_part(HAND); |
| 706 | |
| 707 | if (bimanual(uwep)) |
| 708 | hand = makeplural(hand); |
| 709 | if (strstri(what, "pair of ") != 0) |
| 710 | more_than_1 = FALSE; |
| 711 | pline( |
| 712 | "Since your weapon is welded to your %s, you cannot %s %s %s.", |
| 713 | hand, verb, more_than_1 ? "those" : "that", xname(obj)); |
| 714 | } else { |
| 715 | You_cant("do that."); |
| 716 | } |
| 717 | return FALSE; |
| 718 | } |
| 719 | if (cantwield(gy.youmonst.data)) { |
| 720 | You_cant("hold %s strongly enough.", more_than_1 ? "them" : "it"); |
| 721 | return FALSE; |
| 722 | } |
| 723 | /* check shield */ |
| 724 | if (uarms && bimanual(obj)) { |
| 725 | You("cannot %s a two-handed %s while wearing a shield.", verb, |
| 726 | (obj->oclass == WEAPON_CLASS) ? "weapon" : "tool"); |
| 727 | return FALSE; |
| 728 | } |
| 729 | |
| 730 | if (uquiver == obj) |
| 731 | setuqwep((struct obj *) 0); |
| 732 | if (uswapwep == obj) { |
| 733 | (void) doswapweapon(); |
| 734 | /* doswapweapon might fail */ |
| 735 | if (uswapwep == obj) |
| 736 | return FALSE; |
| 737 | } else { |
| 738 | struct obj *oldwep = uwep; |
| 739 |
no test coverage detected