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

Function cannot_push

src/hack.c:261–312  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

259}
260
261staticfn int
262cannot_push(struct obj *otmp, coordxy sx, coordxy sy)
263{
264 if (throws_rocks(gy.youmonst.data)) {
265 boolean
266 canpickup = (!Sokoban
267 /* similar exception as in can_lift():
268 when poly'd into a giant, you can
269 pick up a boulder if you have a free
270 slot or into the overflow ('#') slot
271 unless already carrying at least one */
272 && (inv_cnt(FALSE) < invlet_basic
273 || !carrying(BOULDER))),
274 willpickup = (canpickup
275 && (flags.pickup && !svc.context.nopick)
276 && autopick_testobj(otmp, TRUE));
277
278 if (u.usteed && P_SKILL(P_RIDING) < P_BASIC) {
279 You("aren't skilled enough to %s %s from %s.",
280 willpickup ? "pick up" : "push aside",
281 the(xname(otmp)), y_monnam(u.usteed));
282 } else {
283 /*
284 * will pick up: you easily pick it up
285 * can but won't: you maneuver over it and could pick it up
286 * can't pick up: you maneuver over it (possibly followed
287 * by feedback from failed auto-pickup attempt)
288 */
289 pline("However, you %s%s.",
290 willpickup ? "easily pick it up"
291 : "maneuver over it",
292 (canpickup && !willpickup)
293 ? " and could pick it up"
294 : "");
295 /* similar to dropping everything and squeezing onto
296 a Sokoban boulder's spot, moving to same breaks the
297 Sokoban rules because on next step you could go
298 past it without pushing it to plug a pit or hole */
299 sokoban_guilt();
300 }
301 return 0;
302 }
303
304 if (could_move_onto_boulder(sx, sy)) {
305 pline(
306 "However, you can squeeze yourself into a small opening.");
307 sokoban_guilt();
308 return 0;
309 } else {
310 return -1;
311 }
312}
313
314staticfn void
315rock_disappear_msg(struct obj *otmp)

Callers 1

moverock_coreFunction · 0.85

Calls 10

inv_cntFunction · 0.85
carryingFunction · 0.85
autopick_testobjFunction · 0.85
YouFunction · 0.85
theFunction · 0.85
xnameFunction · 0.85
y_monnamFunction · 0.85
sokoban_guiltFunction · 0.85
could_move_onto_boulderFunction · 0.85
plineFunction · 0.70

Tested by

no test coverage detected