MCPcopy Index your code
hub / github.com/NetHack/NetHack / trapeffect_hole

Function trapeffect_hole

src/trap.c:2012–2067  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2010}
2011
2012staticfn int
2013trapeffect_hole(
2014 struct monst *mtmp,
2015 struct trap *trap,
2016 unsigned int trflags)
2017{
2018 if (mtmp == &gy.youmonst) {
2019 if (!Can_fall_thru(&u.uz)) {
2020 seetrap(trap); /* normally done in fall_through */
2021 impossible("dotrap: %ss cannot exist on this level.",
2022 trapname(trap->ttyp, TRUE));
2023 return Trap_Effect_Finished; /* don't activate it after all */
2024 }
2025 fall_through(TRUE, (trflags & TOOKPLUNGE));
2026 } else {
2027 int tt = trap->ttyp;
2028 struct permonst *mptr = mtmp->data;
2029 boolean in_sight = canseemon(mtmp) || (mtmp == u.usteed);
2030 boolean forcetrap = ((trflags & FORCETRAP) != 0);
2031 boolean inescapable = (forcetrap || (Sokoban && !trap->madeby_u));
2032
2033 if (!Can_fall_thru(&u.uz)) {
2034 impossible("mintrap: %ss cannot exist on this level.",
2035 trapname(tt, TRUE));
2036 return Trap_Effect_Finished; /* don't activate it after all */
2037 }
2038 if (!grounded(mptr) || (mtmp->wormno && count_wsegs(mtmp) > 5)
2039 || mptr->msize >= MZ_HUGE) {
2040 if (forcetrap && !Sokoban) {
2041 /* openfallingtrap; not inescapable here */
2042 if (in_sight) {
2043 seetrap(trap);
2044 if (tt == TRAPDOOR)
2045 pline_mon(mtmp,
2046 "A trap door opens, but %s doesn't fall through.",
2047 mon_nam(mtmp));
2048 else /* (tt == HOLE) */
2049 pline_mon(mtmp,
2050 "%s doesn't fall through the hole.",
2051 Monnam(mtmp));
2052 }
2053 return Trap_Effect_Finished; /* inescapable = FALSE; */
2054 }
2055 if (inescapable) { /* sokoban hole */
2056 if (in_sight) {
2057 pline_mon(mtmp,
2058 "%s seems to be yanked down!", Monnam(mtmp));
2059 seetrap(trap);
2060 }
2061 } else
2062 return Trap_Effect_Finished;
2063 }
2064 return trapeffect_level_telep(mtmp, trap, trflags);
2065 }
2066 return Trap_Effect_Finished;
2067}
2068
2069staticfn int

Callers 1

trapeffect_selectorFunction · 0.85

Calls 11

Can_fall_thruFunction · 0.85
seetrapFunction · 0.85
trapnameFunction · 0.85
fall_throughFunction · 0.85
canseemonFunction · 0.85
count_wsegsFunction · 0.85
pline_monFunction · 0.85
mon_namFunction · 0.85
MonnamFunction · 0.85
trapeffect_level_telepFunction · 0.85
impossibleFunction · 0.70

Tested by

no test coverage detected