pick a random goodpos() next to x,y for monster mtmp. mtmp could be &gy.youmonst, uses then crawl_destination(). returns TRUE if any good position found, with the coord in x,y */
| 4944 | mtmp could be &gy.youmonst, uses then crawl_destination(). |
| 4945 | returns TRUE if any good position found, with the coord in x,y */ |
| 4946 | boolean |
| 4947 | rnd_nextto_goodpos(coordxy *x, coordxy *y, struct monst *mtmp) |
| 4948 | { |
| 4949 | int i, j; |
| 4950 | boolean is_u = (mtmp == &gy.youmonst); |
| 4951 | coordxy nx, ny, k, dirs[N_DIRS]; |
| 4952 | |
| 4953 | for (i = 0; i < N_DIRS; ++i) |
| 4954 | dirs[i] = i; |
| 4955 | for (i = N_DIRS; i > 0; --i) { |
| 4956 | j = rn2(i); |
| 4957 | k = dirs[j]; |
| 4958 | dirs[j] = dirs[i - 1]; |
| 4959 | dirs[i - 1] = k; |
| 4960 | } |
| 4961 | for (i = 0; i < N_DIRS; ++i) { |
| 4962 | nx = *x + xdir[dirs[i]]; |
| 4963 | ny = *y + ydir[dirs[i]]; |
| 4964 | /* crawl_destination and goodpos both include an isok() check */ |
| 4965 | if (is_u ? crawl_destination(nx, ny) : goodpos(nx, ny, mtmp, 0)) { |
| 4966 | *x = nx; |
| 4967 | *y = ny; |
| 4968 | return TRUE; |
| 4969 | } |
| 4970 | } |
| 4971 | return FALSE; |
| 4972 | } |
| 4973 | |
| 4974 | /* print a message about being back on the ground after leaving a pool */ |
| 4975 | void |
no test coverage detected