MCPcopy Index your code
hub / github.com/NetHack/NetHack / use_pick_axe2

Function use_pick_axe2

src/dig.c:1161–1359  ·  view source on GitHub ↗

MRKR: use_pick_axe() is split in two to allow autodig to bypass */ the "In what direction do you want to dig?" query. */ use_pick_axe2() uses the existing u.dx, u.dy and u.dz */

Source from the content-addressed store, hash-verified

1159/* the "In what direction do you want to dig?" query. */
1160/* use_pick_axe2() uses the existing u.dx, u.dy and u.dz */
1161int
1162use_pick_axe2(struct obj *obj)
1163{
1164 coordxy rx, ry;
1165 struct rm *lev;
1166 struct trap *trap, *trap_with_u;
1167 int dig_target;
1168 boolean ispick = is_pick(obj);
1169 const char *verbing = ispick ? "digging" : "chopping";
1170
1171 if (u.uswallow && do_attack(u.ustuck)) {
1172 ; /* return 1 */
1173 } else if (Underwater) {
1174 pline("Turbulence torpedoes your %s attempts.", verbing);
1175 } else if (u.dz < 0) {
1176 if (Levitation)
1177 You("don't have enough leverage.");
1178 else
1179 You_cant("reach the %s.", ceiling(u.ux, u.uy));
1180 } else if (!u.dx && !u.dy && !u.dz) {
1181 char buf[BUFSZ];
1182 int dam;
1183
1184 dam = rnd(2) + dbon() + obj->spe;
1185 if (dam <= 0)
1186 dam = 1;
1187 You("hit yourself with %s.", yname(uwep));
1188 Sprintf(buf, "%s own %s", uhis(), OBJ_NAME(objects[obj->otyp]));
1189 losehp(Maybe_Half_Phys(dam), buf, KILLED_BY);
1190 disp.botl = TRUE;
1191 return ECMD_TIME;
1192 } else if (u.dz == 0) {
1193 confdir(FALSE);
1194 rx = u.ux + u.dx;
1195 ry = u.uy + u.dy;
1196 if (!isok(rx, ry)) {
1197 Soundeffect(se_clash, 40);
1198 pline("Clash!");
1199 return ECMD_TIME;
1200 }
1201 lev = &levl[rx][ry];
1202 if (MON_AT(rx, ry) && do_attack(m_at(rx, ry)))
1203 return ECMD_TIME;
1204 dig_target = dig_typ(obj, rx, ry);
1205 if (dig_target == DIGTYP_UNDIGGABLE) {
1206 struct obj *boulder;
1207
1208 /* ACCESSIBLE or POOL */
1209 trap = t_at(rx, ry);
1210 if (trap && trap->ttyp == WEB) {
1211 if (!trap->tseen) {
1212 seetrap(trap);
1213 There("is a spider web there!");
1214 }
1215 pline("%s entangled in the web.", Yobjnam2(obj, "become"));
1216 /* you ought to be able to let go; tough luck */
1217 /* (maybe `move_into_trap()' would be better) */
1218 nomul(-d(2, 2));

Callers 4

dodownFunction · 0.85
test_moveFunction · 0.85
domove_fight_emptyFunction · 0.85
use_pick_axeFunction · 0.85

Calls 15

do_attackFunction · 0.85
YouFunction · 0.85
You_cantFunction · 0.85
ceilingFunction · 0.85
rndFunction · 0.85
dbonFunction · 0.85
ynameFunction · 0.85
losehpFunction · 0.85
confdirFunction · 0.85
isokFunction · 0.85
dig_typFunction · 0.85
t_atFunction · 0.85

Tested by 1

test_moveFunction · 0.68