bitmask indicating ways mon is seen; extracted from lookat(pager.c) */
| 2149 | |
| 2150 | /* bitmask indicating ways mon is seen; extracted from lookat(pager.c) */ |
| 2151 | unsigned |
| 2152 | howmonseen(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*/ |
no test coverage detected