version 1.72 | | version 1.73 |
---|
| | |
/* | | /* |
* static char *rcsid_player_c = | | * static char *rcsid_player_c = |
* "$Id: player.c,v 1.72 2001/11/17 21:25:21 michtoen Exp $"; | | * "$Id: player.c,v 1.73 2001/11/26 17:52:26 michtoen Exp $"; |
*/ | | */ |
| | |
/* | | /* |
| | |
mapstruct *m ,*lastmap; | | mapstruct *m ,*lastmap; |
| | |
get_rangevector(mon, pl, &rv, 0); | | get_rangevector(mon, pl, &rv, 0); |
| | |
if (rv.distance<mindiff) return 0; | | if (rv.distance<mindiff) return 0; |
| | |
x=mon->x; | | x=mon->x; |
y=mon->y; | | y=mon->y; |
m=mon->map; | | m=mon->map; |
dir = rv.direction; | | dir = rv.direction; |
lastdir = rv.direction; | | lastdir = firstdir = rv.direction; /* perhaps we stand next to pl, init firstdir too */ |
diff = FABS(rv.distance_x)>FABS(rv.distance_y)?FABS(rv.distance_x):FABS(rv.distance_y); | | diff = FABS(rv.distance_x)>FABS(rv.distance_y)?FABS(rv.distance_x):FABS(rv.distance_y); |
/* If we can't solve it within the search distance, return now. */ | | /* If we can't solve it within the search distance, return now. */ |
if (diff>max) return 0; | | if (diff>max) return 0; |
| | |
x = lastx; | | x = lastx; |
y = lasty; | | y = lasty; |
m = lastmap; | | m = lastmap; |
dir = rv.direction; | | dir = firstdir = rv.direction; |
} else { | | } else { |
/* direct path is blocked - try taking a side step to | | /* direct path is blocked - try taking a side step to |
* either the left or right. | | * either the left or right. |
| | |
} | | } |
/* If we reached the max, didn't find a direction in time */ | | /* If we reached the max, didn't find a direction in time */ |
if (!max) return 0; | | if (!max) return 0; |
| | |
return firstdir; | | return firstdir; |
} | | } |
| | |