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

Function maybe_mnexto

src/mon.c:3998–4017  ·  view source on GitHub ↗

like mnexto() but requires destination to be directly accessible */

Source from the content-addressed store, hash-verified

3996
3997/* like mnexto() but requires destination to be directly accessible */
3998void
3999maybe_mnexto(struct monst *mtmp)
4000{
4001 coord mm;
4002 struct permonst *ptr = mtmp->data;
4003 boolean diagok = !NODIAG(ptr - mons);
4004 int tryct = 20;
4005
4006 do {
4007 if (!enexto(&mm, u.ux, u.uy, ptr))
4008 return;
4009 if (couldsee(mm.x, mm.y)
4010 /* don't move grid bugs diagonally */
4011 && (diagok || mm.x == mtmp->mx || mm.y == mtmp->my)) {
4012 /* [this doesn't honor the 'montelecontrol' option] */
4013 rloc_to(mtmp, mm.x, mm.y);
4014 return;
4015 }
4016 } while (--tryct > 0);
4017}
4018
4019/* mnearto()
4020 * Put monster near (or at) location if possible.

Callers 1

kick_monsterFunction · 0.85

Calls 2

enextoFunction · 0.85
rloc_toFunction · 0.85

Tested by

no test coverage detected