| 3726 | } |
| 3727 | |
| 3728 | staticfn int |
| 3729 | use_grapple(struct obj *obj) |
| 3730 | { |
| 3731 | int res = ECMD_OK, typ, tohit; |
| 3732 | boolean save_confirm; |
| 3733 | coord cc; |
| 3734 | struct monst *mtmp; |
| 3735 | struct obj *otmp; |
| 3736 | |
| 3737 | /* Are you allowed to use the hook? */ |
| 3738 | if (u.uswallow) { |
| 3739 | pline(not_enough_room); |
| 3740 | return ECMD_OK; |
| 3741 | } |
| 3742 | if (obj != uwep) { |
| 3743 | /* "cast": grappling hook evolved from slash'em's fishing pole */ |
| 3744 | if (wield_tool(obj, "cast")) { |
| 3745 | cmdq_add_ec(CQ_CANNED, doapply); |
| 3746 | cmdq_add_key(CQ_CANNED, obj->invlet); |
| 3747 | return ECMD_TIME; |
| 3748 | } |
| 3749 | return ECMD_OK; |
| 3750 | } |
| 3751 | /* assert(obj == uwep); */ |
| 3752 | |
| 3753 | /* Prompt for a location */ |
| 3754 | pline(where_to_hit); |
| 3755 | cc.x = u.ux; |
| 3756 | cc.y = u.uy; |
| 3757 | getpos_sethilite(display_grapple_positions, can_grapple_location); |
| 3758 | if (getpos(&cc, TRUE, "the spot to hit") < 0) |
| 3759 | /* ESC; uses turn iff grapnel became wielded */ |
| 3760 | return (res | ECMD_CANCEL); |
| 3761 | |
| 3762 | /* Calculate range; unlike use_pole(), there's no minimum for range */ |
| 3763 | typ = uwep_skill_type(); |
| 3764 | if (distu(cc.x, cc.y) > grapple_range()) { |
| 3765 | pline("Too far!"); |
| 3766 | return res; |
| 3767 | } else if (!cansee(cc.x, cc.y)) { |
| 3768 | You(cant_see_spot); |
| 3769 | return res; |
| 3770 | } else if (!couldsee(cc.x, cc.y)) { /* Eyes of the Overworld */ |
| 3771 | You(cant_reach); |
| 3772 | return res; |
| 3773 | } |
| 3774 | |
| 3775 | /* What do you want to hit? */ |
| 3776 | tohit = rn2(5); |
| 3777 | if (typ != P_NONE && P_SKILL(typ) >= P_SKILLED) { |
| 3778 | winid tmpwin = create_nhwindow(NHW_MENU); |
| 3779 | anything any; |
| 3780 | char buf[BUFSZ]; |
| 3781 | menu_item *selected; |
| 3782 | int clr = NO_COLOR; |
| 3783 | |
| 3784 | any = cg.zeroany; /* set all bits to zero */ |
| 3785 | any.a_int = 1; /* use index+1 (can't use 0) as identifier */ |
no test coverage detected