while attempting to disarm an adjacent trap, we've fallen into it */
| 5390 | |
| 5391 | /* while attempting to disarm an adjacent trap, we've fallen into it */ |
| 5392 | staticfn void |
| 5393 | move_into_trap(struct trap *ttmp) |
| 5394 | { |
| 5395 | int bc = 0; |
| 5396 | coordxy x = ttmp->tx, y = ttmp->ty, bx, by, cx, cy; |
| 5397 | boolean unused; |
| 5398 | |
| 5399 | bx = by = cx = cy = 0; /* lint suppression */ |
| 5400 | /* we know there's no monster in the way and we're not trapped, but |
| 5401 | need to make sure the move is not diagonally into or out of a |
| 5402 | doorway; the sgn() calls are redundant since ttmp is adjacent */ |
| 5403 | if (test_move(u.ux, u.uy, sgn(x - u.ux), sgn(y - u.uy), TEST_MOVE) |
| 5404 | && (!Punished |
| 5405 | || drag_ball(x, y, &bc, &bx, &by, &cx, &cy, &unused, TRUE))) { |
| 5406 | /* move hero and update map */ |
| 5407 | u.ux0 = u.ux, u.uy0 = u.uy; |
| 5408 | /* set u.ux,u.uy and u.usteed->mx,my plus handle CLIPPING */ |
| 5409 | u_on_newpos(x, y); |
| 5410 | u.umoved = TRUE; |
| 5411 | newsym(u.ux0, u.uy0); |
| 5412 | vision_recalc(1); |
| 5413 | check_leash(u.ux0, u.uy0); |
| 5414 | if (Punished) |
| 5415 | move_bc(0, bc, bx, by, cx, cy); |
| 5416 | /* marking the trap unseen forces dotrap() to treat it like a new |
| 5417 | discovery and prevents pickup() -> look_here() -> check_here() |
| 5418 | from giving a redundant "there is a <trap> here" message when |
| 5419 | there are objects covering this trap */ |
| 5420 | ttmp->tseen = 0; /* hack for check_here() */ |
| 5421 | /* trigger the trap */ |
| 5422 | iflags.failing_untrap++; /* spoteffects() -> dotrap(,FAILEDUNTRAP) */ |
| 5423 | spoteffects(TRUE); /* pickup() + dotrap() */ |
| 5424 | iflags.failing_untrap--; |
| 5425 | /* this should no longer be necessary; before the failing_untrap |
| 5426 | hack, Flying hero would not trigger an unseen bear trap and |
| 5427 | setting it not-yet-seen above resulted in leaving it hidden */ |
| 5428 | if ((ttmp = t_at(u.ux, u.uy)) != 0) |
| 5429 | ttmp->tseen = 1; |
| 5430 | exercise(A_WIS, FALSE); |
| 5431 | } else { |
| 5432 | /* caller has just printed "Whoops..." so if hero is prevented from |
| 5433 | moving, a followup message is needed */ |
| 5434 | pline("Fortunately, you don't move %s it.", |
| 5435 | into_vs_onto(ttmp->ttyp) ? "into" : "onto"); |
| 5436 | } |
| 5437 | } |
| 5438 | |
| 5439 | /* 0: doesn't even try; 1: tries and fails; 2: succeeds */ |
| 5440 | staticfn int |
no test coverage detected