github PR #259 - paranoid_confirmation:trap
Fairly old pull request from copperwater: add new paranoid_confirm setting 'trap'. The old commit suffered from bit rot and merging needed too much fixing up despite there not being many bands of change in the commit's diffs. I ultimately redid it from scratch, although the two biggest chunks of code started with copy+paste of the pull request's commit. It operates like paranoid:pray. Setting paranoid:trap adds a new "Really step into <trap>?" y/n prompt when attempting to move into/onto a known trap, even if an object covers it on the map. Setting both 'paranoid:Confirm trap' turns that into a yes/no prompt. (Adding 'Confirm' affects other paranoid confirmations; in addition to requiring yes<return> rather than just y to accept, it also forces no<return> to reject.) However, moving into a known trap that is considered to be harmless behaves as if no trap was present. Some of the trap classification might be out of date; several types of traps have undergone changes since implementation of the original pull request, notably anti-magic field. When the hero is hallucinating, all known traps are considered harmful since the map no longer reliably describes them. Preceding a movement command with the 'm' prefix also behaves as if no trap was present, bypassing confirmation for that move, similar to how paranoid:swim currently behaves. Being stunned or confused also behaves as if no trap was present, taking priority over hallucination. This updates the documentation. Supersedes #259 Closes #259
This commit is contained in:
39
src/hack.c
39
src/hack.c
@@ -2459,6 +2459,45 @@ domove_core(void)
|
||||
if (u_rooted())
|
||||
return;
|
||||
|
||||
/* warn maybe player before walking into known traps */
|
||||
if (ParanoidTrap && (trap = t_at(x, y)) != 0 && trap->tseen
|
||||
&& (!gc.context.nopick || gc.context.run)
|
||||
&& !Stunned && !Confusion
|
||||
&& (immune_to_trap(&gy.youmonst, trap->ttyp) != TRAP_CLEARLY_IMMUNE
|
||||
/* hallucination: all traps still show as ^, but the
|
||||
hero can't tell what they are, so treat as dangerous */
|
||||
|| Hallucination)) {
|
||||
char qbuf[QBUFSZ];
|
||||
int traptype = (Hallucination ? rnd(TRAPNUM - 1) : (int) trap->ttyp);
|
||||
boolean into = FALSE; /* "onto" the trap vs "into" */
|
||||
|
||||
switch (traptype) {
|
||||
case BEAR_TRAP:
|
||||
case PIT:
|
||||
case SPIKED_PIT:
|
||||
case HOLE:
|
||||
case TELEP_TRAP:
|
||||
case LEVEL_TELEP:
|
||||
case MAGIC_PORTAL:
|
||||
case WEB:
|
||||
into = TRUE;
|
||||
break;
|
||||
}
|
||||
Snprintf(qbuf, sizeof qbuf, "Really %s %s that %s?",
|
||||
locomotion(gy.youmonst.data, "step"),
|
||||
into ? "into" : "onto",
|
||||
defsyms[trap_to_defsym(traptype)].explanation);
|
||||
/* handled like paranoid_confirm:pray; when paranoid_confirm:trap
|
||||
isn't set, don't ask at all but if it is set (checked above),
|
||||
ask via y/n if parnoid_confirm:confirm isn't also set or via
|
||||
yes/no if it is */
|
||||
if (!paranoid_query(ParanoidConfirm, qbuf)) {
|
||||
nomul(0);
|
||||
gc.context.move = 0;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (u.utrap) {
|
||||
boolean moved = trapmove(x, y, trap);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user