if paranoid_confirm:Trap is enabled, check whether the next step forward needs player confirmation due to visible region or discovered trap; result: True => stop moving, False => proceed */
| 2512 | needs player confirmation due to visible region or discovered trap; |
| 2513 | result: True => stop moving, False => proceed */ |
| 2514 | staticfn boolean |
| 2515 | avoid_trap_andor_region(coordxy x, coordxy y) |
| 2516 | { |
| 2517 | char qbuf[QBUFSZ]; |
| 2518 | NhRegion *newreg, *oldreg; |
| 2519 | struct trap *trap = NULL; |
| 2520 | |
| 2521 | /* treat entering a visible gas cloud region like entering a trap; |
| 2522 | there could be a known trap as well as a region at the target spot; |
| 2523 | if so, ask about entring the region first; even though this could |
| 2524 | lead to two consecutive confirmation prompts, the situation seems |
| 2525 | to be too uncommon to warrant a separate case with combined |
| 2526 | trap+region confirmation */ |
| 2527 | if (ParanoidTrap && !Blind && !Stunned && !Confusion && !Hallucination |
| 2528 | /* skip if player used 'm' prefix or is moving recklessly */ |
| 2529 | && (!svc.context.nopick || svc.context.run) |
| 2530 | /* check for region(s) */ |
| 2531 | && (newreg = visible_region_at(x, y)) != 0 |
| 2532 | && ((oldreg = visible_region_at(u.ux, u.uy)) == 0 |
| 2533 | /* if moving from one region into another, only ask for |
| 2534 | confirmation if the one potentially being entered inflicts |
| 2535 | damage (poison gas) and the one being exited doesn't (vapor) */ |
| 2536 | || (reg_damg(newreg) > 0 && reg_damg(oldreg) == 0)) |
| 2537 | /* check whether attempted move will be viable */ |
| 2538 | && test_move(u.ux, u.uy, u.dx, u.dy, TEST_MOVE) |
| 2539 | /* we don't override confirmation for poison resistance since the |
| 2540 | region also hinders hero's vision even if/when no damage is done */ |
| 2541 | ) { |
| 2542 | Snprintf(qbuf, sizeof qbuf, "%s into that %s cloud?", |
| 2543 | u_locomotion("step"), |
| 2544 | (reg_damg(newreg) > 0) ? "poison gas" : "vapor"); |
| 2545 | if (!paranoid_query(ParanoidConfirm, upstart(qbuf))) { |
| 2546 | nomul(0); |
| 2547 | svc.context.move = 0; |
| 2548 | return TRUE; |
| 2549 | } |
| 2550 | } |
| 2551 | |
| 2552 | /* maybe ask player for confirmation before walking into known trap */ |
| 2553 | if (ParanoidTrap && !Stunned && !Confusion |
| 2554 | /* skip if player used 'm' prefix or is moving recklessly */ |
| 2555 | && (!svc.context.nopick || svc.context.run) |
| 2556 | /* check for discovered trap */ |
| 2557 | && (trap = t_at(x, y)) != 0 && trap->tseen |
| 2558 | /* check whether attempted move will be viable */ |
| 2559 | && test_move(u.ux, u.uy, u.dx, u.dy, TEST_MOVE) |
| 2560 | /* override confirmation if the trap is harmless to the hero */ |
| 2561 | && (immune_to_trap(&gy.youmonst, trap->ttyp) != TRAP_CLEARLY_IMMUNE |
| 2562 | /* Hallucination: all traps still show as ^, but the |
| 2563 | hero can't tell what they are, so treat as dangerous */ |
| 2564 | || Hallucination)) { |
| 2565 | int traptype = (Hallucination ? rnd(TRAPNUM - 1) : (int) trap->ttyp); |
| 2566 | boolean into = into_vs_onto(traptype); |
| 2567 | |
| 2568 | Snprintf(qbuf, sizeof qbuf, "Really %s %s that %s?", |
| 2569 | u_locomotion("step"), into ? "into" : "onto", |
| 2570 | defsyms[trap_to_defsym(traptype)].explanation); |
| 2571 | /* handled like paranoid_confirm:pray; when paranoid_confirm:trap |
no test coverage detected