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

Function hero_behind_chokepoint

src/muse.c:1343–1367  ·  view source on GitHub ↗

from monster's point of view, is hero behind a chokepoint? */

Source from the content-addressed store, hash-verified

1341
1342/* from monster's point of view, is hero behind a chokepoint? */
1343staticfn boolean
1344hero_behind_chokepoint(struct monst *mtmp)
1345{
1346 coordxy dx = sgn(mtmp->mx - mtmp->mux);
1347 coordxy dy = sgn(mtmp->my - mtmp->muy);
1348
1349 coordxy x = mtmp->mux + dx;
1350 coordxy y = mtmp->muy + dy;
1351
1352 int dir = xytodir(dx, dy);
1353 int dir_l = DIR_CLAMP(DIR_LEFT2(dir));
1354 int dir_r = DIR_CLAMP(DIR_RIGHT2(dir));
1355
1356 coord c1, c2;
1357
1358 dirtocoord(&c1, dir_l);
1359 dirtocoord(&c2, dir_r);
1360 c1.x += x, c2.x += x;
1361 c1.y += y, c2.y += y;
1362
1363 if ((!isok(c1.x, c1.y) || !accessible(c1.x, c1.y))
1364 && (!isok(c2.x, c2.y) || !accessible(c2.x, c2.y)))
1365 return TRUE;
1366 return FALSE;
1367}
1368
1369/* hostile monster has another hostile next to it */
1370staticfn boolean

Callers 1

find_offensiveFunction · 0.85

Calls 5

sgnFunction · 0.85
xytodirFunction · 0.85
dirtocoordFunction · 0.85
isokFunction · 0.85
accessibleFunction · 0.85

Tested by

no test coverage detected