From c63b4939046fd744f8ba6a1314d12a1ece6edea5 Mon Sep 17 00:00:00 2001 From: PatR Date: Tue, 13 Aug 2024 13:53:41 -0700 Subject: [PATCH] tweak paranoid_confirm:trap vs regions It is possible to have a known trap be at the same location as a gas cloud region. When paranoid_confirm:trap is set, ask for confirmation about entering the region before confirmation about entering the trap since the map will be showing the region rather than the trap. Dual confirmations will be annoying but not new. Before this change, it would ask about entering the trap, and if the answer was yes, it would ask about entering the region. The situation seems to be too rare to warrant implementing a single combined confirmation, and the code to accomplish that would likely be messy. --- src/hack.c | 59 +++++++++++++++++++++++++++++------------------------- 1 file changed, 32 insertions(+), 27 deletions(-) diff --git a/src/hack.c b/src/hack.c index f59e26eb7..028b49645 100644 --- a/src/hack.c +++ b/src/hack.c @@ -2624,6 +2624,38 @@ domove_core(void) if (u_rooted()) return; + /* treat entering a visible gas cloud region like entering a trap; + there could be a known trap as well as a region at the target spot; + if so, ask about entring the region first; even though this could + lead to two consecutive confirmation prompts, the situation seems to + be too uncommon to warrant a separate case with combined trap+region + confirmation */ + if (ParanoidTrap && !Blind && !Stunned && !Confusion && !Hallucination + /* skip if player used 'm' prefix or is moving recklessly */ + && (!svc.context.nopick || svc.context.run) + /* check for region(s) */ + && (newreg = visible_region_at(x, y)) != 0 + && ((oldreg = visible_region_at(u.ux, u.uy)) == 0 + /* if moving from one region into another, only ask for + confirmation if the one potentially being entered inflicts + damage (poison gas) and the one being exited doesn't (vapor) */ + || (reg_damg(newreg) > 0 && reg_damg(oldreg) == 0)) + /* check whether attempted move will be viable */ + && test_move(u.ux, u.uy, u.dx, u.dy, TEST_MOVE) + /* we don't override confirmation for poison resistance since the + region also hinders hero's vision even if/when no damage is done */ + ) { + char qbuf[QBUFSZ]; + + Snprintf(qbuf, sizeof qbuf, "%s into that %s cloud?", + locomotion(gy.youmonst.data, "step"), + (reg_damg(newreg) > 0) ? "poison gas" : "vapor"); + if (!paranoid_query(ParanoidConfirm, upstart(qbuf))) { + nomul(0); + svc.context.move = 0; + return; + } + } /* maybe ask player for confirmation before walking into known traps */ if (ParanoidTrap && !Stunned && !Confusion /* skip if player used 'm' prefix or is moving recklessly */ @@ -2667,33 +2699,6 @@ domove_core(void) return; } } - /* treat entering a visible region like entering a trap */ - if (ParanoidTrap && !Blind && !Stunned && !Confusion && !Hallucination - /* skip if player used 'm' prefix or is moving recklessly */ - && (!svc.context.nopick || svc.context.run) - /* check for region(s) */ - && (newreg = visible_region_at(x, y)) != 0 - && ((oldreg = visible_region_at(u.ux, u.uy)) == 0 - /* if moving from one region into another, only ask for - confirmation if the one potentially being entered inflicts - damage (poison gas) and the one being exited doesn't (vapor) */ - || (reg_damg(newreg) > 0 && reg_damg(oldreg) == 0)) - /* check whether attempted move will be viable */ - && test_move(u.ux, u.uy, u.dx, u.dy, TEST_MOVE) - /* we don't override confirmation for poison resistance since the - region also hinders hero's vision even if/when no damage is done */ - ) { - char qbuf[QBUFSZ]; - - Snprintf(qbuf, sizeof qbuf, "%s into that %s cloud?", - locomotion(gy.youmonst.data, "step"), - (reg_damg(newreg) > 0) ? "poison gas" : "vapor"); - if (!paranoid_query(ParanoidConfirm, upstart(qbuf))) { - nomul(0); - svc.context.move = 0; - return; - } - } if (u.utrap) { boolean moved = trapmove(x, y, trap);