version 1.22 | | version 1.23 |
---|
| | |
/* | | /* |
* static char *rcsid_spell_util_c = | | * static char *rcsid_spell_util_c = |
* "$Id: spell_util.c,v 1.22 2000/10/31 04:53:21 peterm Exp $"; | | * "$Id: spell_util.c,v 1.23 2000/10/31 11:43:07 peterm Exp $"; |
*/ | | */ |
| | |
/* | | /* |
| | |
op->stats.dam = dam_save; | | op->stats.dam = dam_save; |
i=spell_find_dir(op->map,op->x,op->y,get_owner(op)); | | i=spell_find_dir(op->map,op->x,op->y,get_owner(op)); |
| | |
if(i>=0) op->direction=i; | | if(i>=0) { /* we have a preferred direction! */ |
| | /* pick another direction if the preferred dir is blocked. */ |
| | if(wall(op->map,tx + freearr_x[i], ty + freearr_y[i])) { |
| | i+= RANDOM()%3-1; /* -1, 0, +1 */ |
| | if(i==0) i=8; |
| | if(i==9) i=1; |
| | } |
| | op->direction=i; |
| | } |
insert_ob_in_map(op,op->map,op); | | insert_ob_in_map(op,op->map,op); |
} | | } |
| | |
| | |
{2,3,-1}, /* 12 */ | | {2,3,-1}, /* 12 */ |
{2,3,4}, /* 13 */ | | {2,3,4}, /* 13 */ |
{3,4,-1}, /* 14 */ | | {3,4,-1}, /* 14 */ |
{14,4,16}, /* 15 */ | | {4,14,16}, /* 15 */ |
{5,4,-1}, /* 16 */ | | {5,4,-1}, /* 16 */ |
{4,5,6}, /* 17 */ | | {4,5,6}, /* 17 */ |
{6,5,-1}, /* 18 */ | | {6,5,-1}, /* 18 */ |
{20,6,18}, /* 19 */ | | {6,20,18}, /* 19 */ |
{7,6,-1}, /* 20 */ | | {7,6,-1}, /* 20 */ |
{6,7,8}, /* 21 */ | | {6,7,8}, /* 21 */ |
{7,8,-1}, /* 22 */ | | {7,8,-1}, /* 22 */ |
{22,8,24}, /* 23 */ | | {8,22,24}, /* 23 */ |
{8,1,-1}, /* 24 */ | | {8,1,-1}, /* 24 */ |
{24,9,10}, /* 25 */ | | {24,9,10}, /* 25 */ |
{9,10,-1}, /* 26 */ | | {9,10,-1}, /* 26 */ |
| | |
dx = freearr_x[dir]; | | dx = freearr_x[dir]; |
dy = freearr_y[dir]; | | dy = freearr_y[dir]; |
| | |
if(dir==-1) return 0; /* exit condition: invalid direction */ | | if(dir<0) return 0; /* exit condition: invalid direction */ |
if(wall(m,x + dx,y+dy)) return 0; | | if(wall(m,x + dx,y+dy)) return 0; |
| | |
/* yes, can see. */ | | /* yes, can see. */ |
| | |
for(i=(RANDOM()%8)+1;i<max;i++) { | | for(i=(RANDOM()%8)+1;i<max;i++) { |
nx = x + freearr_x[i]; | | nx = x + freearr_x[i]; |
ny = y + freearr_y[i]; | | ny = y + freearr_y[i]; |
if(wall(m, nx,ny)) | | if(!out_of_map(m,nx,ny)) { |
max=maxfree[i]; | | |
else { | | |
tmp=get_map_ob(m,nx,ny); | | tmp=get_map_ob(m,nx,ny); |
while(tmp!=NULL && ((tmp!=NULL&&!QUERY_FLAG(tmp,FLAG_MONSTER)&& | | while(tmp!=NULL && ((!QUERY_FLAG(tmp,FLAG_MONSTER)&& |
!QUERY_FLAG(tmp,FLAG_GENERATOR)) || | | !QUERY_FLAG(tmp,FLAG_GENERATOR)) || |
(tmp == exclude || (tmp->head && tmp->head == exclude)))) | | (tmp == exclude || (tmp->head && tmp->head == exclude)))) |
tmp=tmp->above; | | tmp=tmp->above; |