* Try to choose a stopping point as near as possible to the starting * position while still adjacent to the hero. If all else fails, try * enexto(). Use enexto() as a last resort because enexto() chooses * its point randomly, which is not what we want. */
| 245 | * its point randomly, which is not what we want. |
| 246 | */ |
| 247 | staticfn boolean |
| 248 | md_stop(coord *stopp, /* stopping position (we fill it in) */ |
| 249 | coord *startp) /* starting position (read only) */ |
| 250 | { |
| 251 | coordxy x, y, distance, min_distance = -1; |
| 252 | |
| 253 | for (x = u.ux - 1; x <= u.ux + 1; x++) |
| 254 | for (y = u.uy - 1; y <= u.uy + 1; y++) { |
| 255 | if (!isok(x, y) || u_at(x, y)) |
| 256 | continue; |
| 257 | |
| 258 | if (accessible(x, y) && !MON_AT(x, y)) { |
| 259 | distance = dist2(x, y, startp->x, startp->y); |
| 260 | if (min_distance < 0 || distance < min_distance |
| 261 | || (distance == min_distance && rn2(2))) { |
| 262 | stopp->x = x; |
| 263 | stopp->y = y; |
| 264 | min_distance = distance; |
| 265 | } |
| 266 | } |
| 267 | } |
| 268 | |
| 269 | /* If we didn't find a good spot, try enexto(). */ |
| 270 | if (min_distance < 0 && !enexto(stopp, u.ux, u.uy, &mons[PM_MAIL_DAEMON])) |
| 271 | return FALSE; |
| 272 | |
| 273 | return TRUE; |
| 274 | } |
| 275 | |
| 276 | /* Let the mail daemon have a larger vocabulary. */ |
| 277 | staticfn NEARDATA const char *mail_text[] = { "Gangway!", "Look out!", |