MCPcopy Create free account
hub / github.com/NetHack/NetHack / dotrap

Function dotrap

src/trap.c:2995–3060  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2993}
2994
2995void
2996dotrap(struct trap *trap, unsigned trflags)
2997{
2998 int ttype = trap->ttyp;
2999 boolean already_seen = trap->tseen,
3000 forcetrap = ((trflags & FORCETRAP) != 0
3001 || (trflags & FAILEDUNTRAP) != 0),
3002 forcebungle = (trflags & FORCEBUNGLE) != 0,
3003 plunged = (trflags & TOOKPLUNGE) != 0,
3004 conj_pit = conjoined_pits(trap, t_at(u.ux0, u.uy0), TRUE),
3005 adj_pit = adj_nonconjoined_pit(trap);
3006
3007 nomul(0);
3008
3009 if (fixed_tele_trap(trap)) {
3010 trflags |= FORCETRAP;
3011 forcetrap = TRUE;
3012 }
3013
3014 /* KMH -- You can't escape the Sokoban level traps */
3015 if (Sokoban && (is_pit(ttype) || is_hole(ttype))) {
3016 /* The "air currents" message is still appropriate -- even when
3017 * the hero isn't flying or levitating -- because it conveys the
3018 * reason why the player cannot escape the trap with a dexterity
3019 * check, clinging to the ceiling, etc.
3020 */
3021 pline("Air currents pull you down into %s %s!",
3022 a_your[trap->madeby_u],
3023 trapname(ttype, TRUE)); /* do force "pit" while hallucinating */
3024 /* then proceed to normal trap effect */
3025 } else if (!forcetrap) {
3026 if (floor_trigger(ttype) && check_in_air(&gy.youmonst, trflags)) {
3027 if (already_seen) {
3028 You("%s over %s %s.", u_locomotion("step"),
3029 (ttype == ARROW_TRAP && !trap->madeby_u)
3030 ? "an" : a_your[trap->madeby_u],
3031 trapname(ttype, FALSE));
3032 }
3033 return;
3034 }
3035 if (already_seen && !Fumbling && !undestroyable_trap(ttype)
3036 && ttype != ANTI_MAGIC && !forcebungle && !plunged
3037 && !conj_pit && !adj_pit
3038 && (!rn2(5) || (is_pit(ttype) && is_clinger(gy.youmonst.data)))) {
3039 You("escape %s %s.", (ttype == ARROW_TRAP && !trap->madeby_u)
3040 ? "an"
3041 : a_your[trap->madeby_u],
3042 trapname(ttype, FALSE));
3043 return;
3044 }
3045 }
3046
3047 if (u.usteed)
3048 mon_learns_traps(u.usteed, ttype);
3049 mons_see_trap(trap);
3050
3051 /*
3052 * Note:

Callers 15

dositFunction · 0.85
dodownFunction · 0.85
spoteffectsFunction · 0.85
digFunction · 0.85
use_pick_axe2Function · 0.85
hurtle_stepFunction · 0.85
dospinwebFunction · 0.85
trapeffect_landmineFunction · 0.85
float_downFunction · 0.85
try_disarmFunction · 0.85
closeholdingtrapFunction · 0.85
openfallingtrapFunction · 0.85

Calls 14

conjoined_pitsFunction · 0.85
t_atFunction · 0.85
adj_nonconjoined_pitFunction · 0.85
nomulFunction · 0.85
trapnameFunction · 0.85
floor_triggerFunction · 0.85
check_in_airFunction · 0.85
YouFunction · 0.85
u_locomotionFunction · 0.85
rn2Function · 0.85
mon_learns_trapsFunction · 0.85
mons_see_trapFunction · 0.85

Tested by

no test coverage detected