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

Function monster_nearby

src/hack.c:4105–4127  ·  view source on GitHub ↗

something like lookaround, but we are not running */ react only to monsters that might hit us */

Source from the content-addressed store, hash-verified

4103/* something like lookaround, but we are not running */
4104/* react only to monsters that might hit us */
4105int
4106monster_nearby(void)
4107{
4108 coordxy x, y;
4109 struct monst *mtmp;
4110
4111 /* Also see the similar check in dochugw() in monmove.c */
4112 for (x = u.ux - 1; x <= u.ux + 1; x++)
4113 for (y = u.uy - 1; y <= u.uy + 1; y++) {
4114 if (!isok(x, y) || u_at(x, y))
4115 continue;
4116 if ((mtmp = m_at(x, y)) != 0
4117 && M_AP_TYPE(mtmp) != M_AP_FURNITURE
4118 && M_AP_TYPE(mtmp) != M_AP_OBJECT
4119 && (Hallucination
4120 || (!mtmp->mpeaceful && !noattacks(mtmp->data)))
4121 && (!is_hider(mtmp->data) || !mtmp->mundetected)
4122 && !helpless(mtmp)
4123 && !onscary(u.ux, u.uy, mtmp) && canspotmon(mtmp))
4124 return 1;
4125 }
4126 return 0;
4127}
4128
4129void
4130end_running(boolean and_travel)

Callers 4

allmain.cFile · 0.85
cmd_safety_preventionFunction · 0.85
you_wereFunction · 0.85
you_unwereFunction · 0.85

Calls 3

isokFunction · 0.85
noattacksFunction · 0.85
onscaryFunction · 0.85

Tested by

no test coverage detected