From 1b79f00a39862d8bd98c5e351f6f190ed2c48bab Mon Sep 17 00:00:00 2001 From: PatR Date: Sun, 9 Jul 2023 14:51:30 -0700 Subject: [PATCH] more PR #1077 - #sit on floor trap while Flying Sitting on a squeaky board wasn't triggering it even after the handler for that type of trap allowed VIASITTING to override Flying. The check_in_air() test for floor traps didn't have the same override, so the squeaky board handler didn't get called. This fixes that, which led to inconsistency with some other trap types, and additional fixes for pits and bear traps. There might be others that still behave oddly. For example, if flying over a hole, using #sit yields |You land. There's a gaping hole under you! You don't fall in. I think that's a message phrasing issue rather than a falling trap issue; if you want to go down, use '>' instead of #sit. On the other hand, you do now fall into pit traps for #sit while flying over them. --- src/sit.c | 5 ++++- src/trap.c | 25 +++++++++++++------------ 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/src/sit.c b/src/sit.c index 2dec45bdc..e65da53b7 100644 --- a/src/sit.c +++ b/src/sit.c @@ -321,7 +321,10 @@ dosit(void) u.utrap++; } } else { - You("sit down."); + /* when flying, "you land" might need some refinement; it aounds + as if you're staying on the ground but you will immediately + take off again unless you become stuck in a holding trap */ + You("%s.", Flying ? "land" : "sit down"); dotrap(trap, VIASITTING); } } else if ((Underwater || Is_waterlevel(&u.uz)) diff --git a/src/trap.c b/src/trap.c index e3b54a538..019dbb583 100644 --- a/src/trap.c +++ b/src/trap.c @@ -1041,13 +1041,12 @@ floor_trigger(int ttyp) static boolean check_in_air(struct monst *mtmp, unsigned trflags) { - boolean plunged = (trflags & TOOKPLUNGE) != 0; + boolean is_you = mtmp == &gy.youmonst, + plunged = (trflags & (TOOKPLUNGE | VIASITTING)) != 0; - return (is_floater(mtmp->data) - || (is_flyer(mtmp->data) && !plunged) - || (trflags & HURTLING) != 0 - || (mtmp == &gy.youmonst ? - (Levitation || (Flying && !plunged)) : 0)); + return ((trflags & HURTLING) != 0 + || (is_you ? Levitation : is_floater(mtmp->data)) + || ((is_you ? Flying : is_flyer(mtmp->data)) && !plunged)); } static int @@ -1337,10 +1336,12 @@ trapeffect_bear_trap( struct trap *trap, unsigned trflags) { - boolean forcetrap = ((trflags & FORCETRAP) != 0 - || (trflags & FAILEDUNTRAP) != 0); + boolean is_you = mtmp == &gy.youmonst, + forcetrap = ((trflags & FORCETRAP) != 0 + || (trflags & FAILEDUNTRAP) != 0 + || (is_you && (trflags & VIASITTING) != 0)); - if (mtmp == &gy.youmonst) { + if (is_you) { int dmg = d(2, 4); if ((Levitation || Flying) && !forcetrap) @@ -1663,6 +1664,7 @@ trapeffect_pit( if (mtmp == &gy.youmonst) { boolean plunged = (trflags & TOOKPLUNGE) != 0; + boolean viasitting = (trflags & VIASITTING) != 0; boolean conj_pit = conjoined_pits(trap, t_at(u.ux0, u.uy0), TRUE); boolean adj_pit = adj_nonconjoined_pit(trap); boolean already_known = trap->tseen ? TRUE : FALSE; @@ -1676,7 +1678,7 @@ trapeffect_pit( steed_article = ARTICLE_NONE; /* KMH -- You can't escape the Sokoban level traps */ - if (!Sokoban && (Levitation || (Flying && !plunged))) + if (!Sokoban && (Levitation || (Flying && !plunged && !viasitting))) return Trap_Effect_Finished; feeltrap(trap); if (!Sokoban && is_clinger(gy.youmonst.data) && !plunged) { @@ -2638,8 +2640,7 @@ dotrap(struct trap *trap, unsigned trflags) if (already_seen && !Fumbling && !undestroyable_trap(ttype) && ttype != ANTI_MAGIC && !forcebungle && !plunged && !conj_pit && !adj_pit - && (!rn2(5) || (is_pit(ttype) - && is_clinger(gy.youmonst.data)))) { + && (!rn2(5) || (is_pit(ttype) && is_clinger(gy.youmonst.data)))) { You("escape %s %s.", (ttype == ARROW_TRAP && !trap->madeby_u) ? "an" : a_your[trap->madeby_u],