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

Function could_untrap

src/trap.c:5257–5284  ·  view source on GitHub ↗

preliminary checks for dountrap(); also used for autounlock */

Source from the content-addressed store, hash-verified

5255
5256/* preliminary checks for dountrap(); also used for autounlock */
5257int
5258could_untrap(boolean verbosely, boolean check_floor)
5259{
5260 char buf[BUFSZ];
5261
5262 buf[0] = '\0';
5263 if (near_capacity() >= HVY_ENCUMBER) {
5264 Strcpy(buf, "You're too strained to do that.");
5265 } else if ((nohands(gy.youmonst.data) && !webmaker(gy.youmonst.data))
5266 || !gy.youmonst.data->mmove) {
5267 Strcpy(buf, "And just how do you expect to do that?");
5268 } else if (u.ustuck && sticks(gy.youmonst.data)) {
5269 Sprintf(buf, "You'll have to let go of %s first.", mon_nam(u.ustuck));
5270 } else if (u.ustuck || (welded(uwep) && bimanual(uwep))) {
5271 Sprintf(buf, "Your %s seem to be too busy for that.",
5272 makeplural(body_part(HAND)));
5273 } else if (check_floor && !can_reach_floor(FALSE)) {
5274 /* only checked here for autounlock of chest/box and that will
5275 be !verbosely so precise details of the message don't matter */
5276 Sprintf(buf, "You can't reach the %s.", surface(u.ux, u.uy));
5277 }
5278 if (buf[0]) {
5279 if (verbosely)
5280 pline("%s", buf);
5281 return 0;
5282 }
5283 return 1;
5284}
5285
5286/* Probability of disabling a trap. Helge Hafting;
5287 Returns 0 for success, non-0 for failure. */

Callers 2

pick_lockFunction · 0.85
dountrapFunction · 0.85

Calls 9

near_capacityFunction · 0.85
sticksFunction · 0.85
mon_namFunction · 0.85
weldedFunction · 0.85
makepluralFunction · 0.85
body_partFunction · 0.85
can_reach_floorFunction · 0.85
surfaceFunction · 0.85
plineFunction · 0.70

Tested by

no test coverage detected