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

Function find_guard_dest

src/vault.c:280–314  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

278}
279
280staticfn boolean
281find_guard_dest(struct monst *guard, coordxy *rx, coordxy *ry)
282{
283 coordxy x, y, dd, lx, ly;
284
285 for (dd = 2; (dd < ROWNO || dd < COLNO); dd++) {
286 for (y = u.uy - dd; y <= u.uy + dd; y++) {
287 if (y < 0 || y > ROWNO - 1)
288 continue;
289 for (x = u.ux - dd; x <= u.ux + dd; x++) {
290 if (y != u.uy - dd && y != u.uy + dd && x != u.ux - dd)
291 x = u.ux + dd;
292 if (x < 1 || x > COLNO - 1)
293 continue;
294 if (guard && ((x == guard->mx && y == guard->my)
295 || (guard->isgd && in_fcorridor(guard, x, y))))
296 continue;
297 if (levl[x][y].typ == CORR) {
298 lx = (x < u.ux) ? x + 1 : (x > u.ux) ? x - 1 : x;
299 ly = (y < u.uy) ? y + 1 : (y > u.uy) ? y - 1 : y;
300 if (levl[lx][ly].typ != STONE && levl[lx][ly].typ != CORR)
301 goto incr_radius;
302 *rx = x;
303 *ry = y;
304 return TRUE;
305 }
306 }
307 }
308 incr_radius:
309 ;
310 }
311 impossible("Not a single corridor on this level?");
312 tele();
313 return FALSE;
314}
315
316void
317invault(void)

Callers 2

invaultFunction · 0.85
gd_moveFunction · 0.85

Calls 3

in_fcorridorFunction · 0.85
teleFunction · 0.85
impossibleFunction · 0.70

Tested by

no test coverage detected