like mnexto() but requires destination to be directly accessible */
| 3996 | |
| 3997 | /* like mnexto() but requires destination to be directly accessible */ |
| 3998 | void |
| 3999 | maybe_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. |
no test coverage detected