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

Function howmonseen

src/vision.c:2151–2186  ·  view source on GitHub ↗

bitmask indicating ways mon is seen; extracted from lookat(pager.c) */

Source from the content-addressed store, hash-verified

2149
2150/* bitmask indicating ways mon is seen; extracted from lookat(pager.c) */
2151unsigned
2152howmonseen(struct monst *mon)
2153{
2154 boolean useemon = (boolean) canseemon(mon);
2155 int xraydist = (u.xray_range < 0) ? -1 : (u.xray_range * u.xray_range);
2156 unsigned how_seen = 0; /* result */
2157
2158 /* assert(mon != NULL) */
2159 /* normal vision;
2160 cansee is true for both normal and astral vision,
2161 but couldsee it not true for astral vision */
2162 if ((mon->wormno ? worm_known(mon) : (cansee(mon->mx, mon->my)
2163 && couldsee(mon->mx, mon->my)))
2164 && mon_visible(mon) && !mon->minvis)
2165 how_seen |= MONSEEN_NORMAL;
2166 /* see invisible */
2167 if (useemon && mon->minvis)
2168 how_seen |= MONSEEN_SEEINVIS;
2169 /* infravision */
2170 if ((!mon->minvis || See_invisible) && see_with_infrared(mon))
2171 how_seen |= MONSEEN_INFRAVIS;
2172 /* telepathy */
2173 if (tp_sensemon(mon))
2174 how_seen |= MONSEEN_TELEPAT;
2175 /* xray */
2176 if (useemon && xraydist > 0 && mdistu(mon) <= xraydist)
2177 how_seen |= MONSEEN_XRAYVIS;
2178 /* extended detection */
2179 if (Detect_monsters)
2180 how_seen |= MONSEEN_DETECT;
2181 /* class-/type-specific warning */
2182 if (MATCH_WARN_OF_MON(mon))
2183 how_seen |= MONSEEN_WARNMON;
2184
2185 return how_seen;
2186}
2187
2188/*vision.c*/

Callers 2

use_mirrorFunction · 0.85
look_at_monsterFunction · 0.85

Calls 5

canseemonFunction · 0.85
worm_knownFunction · 0.85
mon_visibleFunction · 0.85
see_with_infraredFunction · 0.85
tp_sensemonFunction · 0.85

Tested by

no test coverage detected