From 21db5a3ae6ee0ec7f2fbc055133c244985512819 Mon Sep 17 00:00:00 2001 From: PatR Date: Thu, 27 Sep 2018 18:42:12 -0700 Subject: [PATCH] alternate bear trap fix Fix the situation of Flying hero failing to untrap a bear trap that was resulting in the trap becoming hidden. Previous fix prevented hero from moving onto the trap's location so that the reason for hiding it didn't occur. This moves the hero and forces the trap, so it will become unhidden again before there's any chance to notice that it had been hidden. Status 'Flying' conflicts with being trapped at floor level, but that is a separate, known issue. I'll have to resurrect my unfinished fix for that sooner rather than later. --- include/flag.h | 5 +++-- src/hack.c | 3 ++- src/trap.c | 39 +++++++++++++++++++++------------------ 3 files changed, 26 insertions(+), 21 deletions(-) diff --git a/include/flag.h b/include/flag.h index 29b74b37c..58cda7838 100644 --- a/include/flag.h +++ b/include/flag.h @@ -240,11 +240,12 @@ struct instance_flags { boolean defer_plname; /* X11 hack: askname() might not set plname */ boolean herecmd_menu; /* use menu when mouseclick on yourself */ boolean invis_goldsym; /* gold symbol is ' '? */ - int parse_config_file_src; /* hack for parse_config_line() */ + int failing_untrap; /* move_into_trap() -> spoteffects() -> dotrap() */ int in_lava_effects; /* hack for Boots_off() */ int last_msg; /* indicator of last message player saw */ - int purge_monsters; /* # of dead monsters still on fmon list */ int override_ID; /* true to force full identification of objects */ + int parse_config_file_src; /* hack for parse_config_line() */ + int purge_monsters; /* # of dead monsters still on fmon list */ int suppress_price; /* controls doname() for unpaid objects */ int terrainmode; /* for getpos()'s autodescribe when #terrain is active */ #define TER_MAP 0x01 diff --git a/src/hack.c b/src/hack.c index eb96563fb..1a83ae3d9 100644 --- a/src/hack.c +++ b/src/hack.c @@ -2042,6 +2042,7 @@ boolean pick; struct monst *mtmp; struct trap *trap = t_at(u.ux, u.uy); + int trapflag = iflags.failing_untrap ? FORCETRAP : 0; /* prevent recursion from affecting the hero all over again [hero poly'd to iron golem enters water here, drown() inflicts @@ -2107,7 +2108,7 @@ boolean pick; if (!spottrap || spottraptyp != trap->ttyp) { spottrap = trap; spottraptyp = trap->ttyp; - dotrap(trap, 0); /* fall into arrow trap, etc. */ + dotrap(trap, trapflag); /* fall into arrow trap, etc. */ spottrap = (struct trap *) 0; spottraptyp = NO_TRAP; } diff --git a/src/trap.c b/src/trap.c index b9252d18e..056570906 100644 --- a/src/trap.c +++ b/src/trap.c @@ -886,8 +886,7 @@ unsigned trflags; /* then proceed to normal trap effect */ } else if (already_seen && !forcetrap) { if ((Levitation || (Flying && !plunged)) - && (is_pit(ttype) || ttype == HOLE - || ttype == BEAR_TRAP)) { + && (is_pit(ttype) || ttype == HOLE || ttype == BEAR_TRAP)) { You("%s over %s %s.", Levitation ? "float" : "fly", a_your[trap->madeby_u], defsyms[trap_to_defsym(ttype)].explanation); @@ -1198,16 +1197,23 @@ unsigned trflags; if (ttype == SPIKED_PIT) { oldumort = u.umortality; losehp(Maybe_Half_Phys(rnd(conj_pit ? 4 : adj_pit ? 6 : 10)), + /* note: these don't need locomotion() handling; + if fatal while poly'd and Unchanging, the + death reason will be overridden with + "killed while stuck in creature form" */ plunged - ? "deliberately plunged into a pit of iron spikes" - : conj_pit ? "stepped into a pit of iron spikes" - : adj_pit ? "stumbled into a pit of iron spikes" - : "fell into a pit of iron spikes", + ? "deliberately plunged into a pit of iron spikes" + : conj_pit + ? "stepped into a pit of iron spikes" + : adj_pit + ? "stumbled into a pit of iron spikes" + : "fell into a pit of iron spikes", NO_KILLER_PREFIX); if (!rn2(6)) poisoned("spikes", A_STR, - (conj_pit || adj_pit) ? "stepping on poison spikes" - : "fall onto poison spikes", + (conj_pit || adj_pit) + ? "stepping on poison spikes" + : "fall onto poison spikes", /* if damage triggered life-saving, poison is limited to attrib loss */ (u.umortality > oldumort) ? 0 : 8, FALSE); @@ -3912,7 +3918,14 @@ struct trap *ttmp; there are objects covering this trap */ ttmp->tseen = 0; /* hack for check_here() */ /* trigger the trap */ + iflags.failing_untrap++; /* spoteffects() -> dotrap(,FORCETRAP) */ spoteffects(TRUE); /* pickup() + dotrap() */ + iflags.failing_untrap--; + /* this should no longer be necessary; before the failing_untrap + hack, Flying hero would not trigger an unseen bear trap and + setting it not-yet-seen above resulted in leaving it hidden */ + if ((ttmp = t_at(u.ux, u.uy)) != 0) + ttmp->tseen = 1; exercise(A_WIS, FALSE); } } @@ -3991,16 +4004,6 @@ boolean force_failure; } } else if (under_u) { dotrap(ttmp, 0); - } else if (ttype == BEAR_TRAP && (Levitation || Flying)) { - /* There was a report of oddities of the trap - vanishing from view due to tseen being cleared - (which was deliberate to work around a check_here() - issue). Since you won't actually end up in the trap - during the #untrap operation anyway due to - Levitation and Flying checks further along, - just avoid the whole "vanishing trap" scenario - by failing the #untrap operation right here. */ - You("couldn't reach it from your vantage point."); } else { move_into_trap(ttmp); } -- 2.40.0