| 1089 | } |
| 1090 | |
| 1091 | int |
| 1092 | use_pick_axe(struct obj *obj) |
| 1093 | { |
| 1094 | const char *verb; |
| 1095 | char *dsp, dirsyms[12], qbuf[BUFSZ]; |
| 1096 | boolean ispick; |
| 1097 | int rx, ry, downok, res = ECMD_OK; |
| 1098 | int dir; |
| 1099 | |
| 1100 | /* Check tool */ |
| 1101 | if (obj != uwep) { |
| 1102 | if (wield_tool(obj, "swing")) { |
| 1103 | /* we're now wielding it. next turn, apply to dig. */ |
| 1104 | cmdq_add_ec(CQ_CANNED, doapply); |
| 1105 | cmdq_add_key(CQ_CANNED, obj->invlet); |
| 1106 | return ECMD_TIME; |
| 1107 | } |
| 1108 | return ECMD_OK; |
| 1109 | } |
| 1110 | ispick = is_pick(obj); |
| 1111 | verb = ispick ? "dig" : "chop"; |
| 1112 | |
| 1113 | if (u.utrap && u.utraptype == TT_WEB) { |
| 1114 | pline("%s you can't %s while entangled in a web.", |
| 1115 | /* res==0 => no prior message; |
| 1116 | res==1 => just got "You now wield a pick-axe." message */ |
| 1117 | !res ? "Unfortunately," : "But", verb); |
| 1118 | return res; |
| 1119 | } |
| 1120 | |
| 1121 | /* construct list of directions to show player for likely choices */ |
| 1122 | downok = !!can_reach_floor(FALSE); |
| 1123 | dsp = dirsyms; |
| 1124 | for (dir = 0; dir < N_DIRS_Z; dir++) { |
| 1125 | char dirch = cmd_from_dir(dir, MV_WALK); |
| 1126 | |
| 1127 | /* filter out useless directions */ |
| 1128 | if (u.uswallow) { |
| 1129 | ; /* all directions are viable when swallowed */ |
| 1130 | } else if (movecmd(dirch, MV_WALK)) { |
| 1131 | /* normal direction, within plane of the level map */ |
| 1132 | if (!dxdy_moveok()) |
| 1133 | continue; /* handle NODIAG */ |
| 1134 | rx = u.ux + u.dx; |
| 1135 | ry = u.uy + u.dy; |
| 1136 | if (!isok(rx, ry) || dig_typ(obj, rx, ry) == DIGTYP_UNDIGGABLE) |
| 1137 | continue; |
| 1138 | } else { |
| 1139 | /* up or down; we used to always include down, so that |
| 1140 | there would always be at least one choice shown, but |
| 1141 | it shouldn't be a likely candidate when floating high |
| 1142 | above the floor; include up instead in that situation |
| 1143 | (as a silly candidate rather than a likely one...) */ |
| 1144 | if ((u.dz > 0) ^ downok) |
| 1145 | continue; |
| 1146 | } |
| 1147 | /* include this direction */ |
| 1148 | *dsp++ = dirch; |
no test coverage detected