version 1.184 | | version 1.185 |
---|
| | |
/* | | /* |
* static char *rcsid_player_c = | | * static char *rcsid_player_c = |
* "$Id: player.c,v 1.184 2005/11/12 13:49:07 ryo_saeba Exp $"; | | * "$Id: player.c,v 1.185 2005/11/16 08:16:09 mwedel Exp $"; |
*/ | | */ |
| | |
/* | | /* |
| | |
int path_to_player(object *mon, object *pl, unsigned mindiff) { | | int path_to_player(object *mon, object *pl, unsigned mindiff) { |
rv_vector rv; | | rv_vector rv; |
sint16 x,y; | | sint16 x,y; |
int lastx,lasty,dir,i,diff, firstdir=0,lastdir, max=MAX_SPACES, mflags; | | int lastx,lasty,dir,i,diff, firstdir=0,lastdir, max=MAX_SPACES, mflags, blocked; |
mapstruct *m ,*lastmap; | | mapstruct *m ,*lastmap; |
| | |
get_rangevector(mon, pl, &rv, 0); | | get_rangevector(mon, pl, &rv, 0); |
| | |
y = lasty + freearr_y[dir]; | | y = lasty + freearr_y[dir]; |
| | |
mflags = get_map_flags(m, &m, x, y, &x, &y); | | mflags = get_map_flags(m, &m, x, y, &x, &y); |
| | blocked = GET_MAP_MOVE_BLOCK(m, x, y); |
| | |
/* Space is blocked - try changing direction a little */ | | /* Space is blocked - try changing direction a little */ |
if ((mflags & (P_BLOCKED | P_OUT_OF_MAP)) && (m == mon->map && blocked_link(mon, m, x, y))) { | | if ((mflags & P_OUT_OF_MAP) || ((OB_TYPE_MOVE_BLOCK(mon, blocked)) |
| | && (m == mon->map && blocked_link(mon, m, x, y)))) { |
/* recalculate direction from last good location. Possible | | /* recalculate direction from last good location. Possible |
* we were not traversing ideal location before. | | * we were not traversing ideal location before. |
*/ | | */ |
| | |
y = lasty + freearr_y[absdir(lastdir+i)]; | | y = lasty + freearr_y[absdir(lastdir+i)]; |
m = lastmap; | | m = lastmap; |
mflags = get_map_flags(m, &m, x, y, &x, &y); | | mflags = get_map_flags(m, &m, x, y, &x, &y); |
if (!(mflags & (P_OUT_OF_MAP | P_BLOCKED)) && | | if (mflags & P_OUT_OF_MAP) continue; |
(m == mon->map && blocked_link(mon, m, x, y))) break; | | blocked = GET_MAP_MOVE_BLOCK(m, x, y); |
| | if (OB_TYPE_MOVE_BLOCK(mon, blocked)) continue; |
| | |
| | if (m == mon->map && blocked_link(mon, m, x, y)) break; |
} | | } |
/* go through entire loop without finding a valid | | /* go through entire loop without finding a valid |
* sidestep to take - thus, no valid path. | | * sidestep to take - thus, no valid path. |
| | |
| | |
| | |
/* if you're flying, you cna't pick up anything */ | | /* if you're flying, you cna't pick up anything */ |
if (QUERY_FLAG (op, FLAG_FLYING)) | | if (op->move_type & MOVE_FLYING) |
return 1; | | return 1; |
| | |
op_tag = op->count; | | op_tag = op->count; |
| | |
x += freearr_x[dir]; | | x += freearr_x[dir]; |
y += freearr_y[dir]; | | y += freearr_y[dir]; |
mflags = get_map_flags(m, &m, x, y, &x, &y); | | mflags = get_map_flags(m, &m, x, y, &x, &y); |
if (mflags & P_OUT_OF_MAP || mflags & P_WALL || | | if (mflags & P_OUT_OF_MAP || mflags & P_BLOCKSVIEW) { |
mflags & P_BLOCKSVIEW) { | | tmp = NULL; |
| | break; |
| | } else if (GET_MAP_MOVE_BLOCK(m, x, y) == MOVE_FLY_LOW) { |
| | /* This block presumes arrows and the like are MOVE_FLY_SLOW - |
| | * perhaps a bad assumption. |
| | */ |
tmp = NULL; | | tmp = NULL; |
break; | | break; |
} | | } |
| | |
} | | } |
} | | } |
mflags = get_map_flags(op->map,&m, sx, sy, &sx, &sy); | | mflags = get_map_flags(op->map,&m, sx, sy, &sx, &sy); |
if ( mflags & P_WALL) { | | if (mflags & P_OUT_OF_MAP) { |
new_draw_info(NDI_UNIQUE, 0,op,"Something is in the way."); | | |
return 0; | | return 0; |
} | | } |
if (mflags & P_OUT_OF_MAP) { | | if (GET_MAP_MOVE_BLOCK(m, sx, sy) == MOVE_FLY_LOW) { |
| | new_draw_info(NDI_UNIQUE, 0,op,"Something is in the way."); |
return 0; | | return 0; |
} | | } |
| | |
| | |
update_ob_speed(arrow); | | update_ob_speed(arrow); |
arrow->speed_left = 0; | | arrow->speed_left = 0; |
| | |
| | |
if (op->type == PLAYER) { | | if (op->type == PLAYER) { |
arrow->stats.wc = 20 - bow->magic - arrow->magic - | | arrow->stats.wc = 20 - bow->magic - arrow->magic - |
(op->chosen_skill?op->chosen_skill->level:op->level) - | | (op->chosen_skill?op->chosen_skill->level:op->level) - |
| | |
arrow->slaying = add_string(bow->slaying); | | arrow->slaying = add_string(bow->slaying); |
| | |
arrow->map = m; | | arrow->map = m; |
SET_FLAG(arrow, FLAG_FLYING); | | arrow->move_type = MOVE_FLY_LOW; |
SET_FLAG(arrow, FLAG_FLY_ON); | | arrow->move_on = MOVE_FLY_LOW | MOVE_WALK; |
SET_FLAG(arrow, FLAG_WALK_ON); | | |
play_sound_map(op->map, op->x, op->y, SOUND_FIRE_ARROW); | | play_sound_map(op->map, op->x, op->y, SOUND_FIRE_ARROW); |
tag = arrow->count; | | tag = arrow->count; |
insert_ob_in_map(arrow, m, op, 0); | | insert_ob_in_map(arrow, m, op, 0); |
| | |
/* space must be blocked if there is a monster. If not | | /* space must be blocked if there is a monster. If not |
* blocked, don't need to check this space. | | * blocked, don't need to check this space. |
*/ | | */ |
if (mflags & P_OUT_OF_MAP || !(mflags & P_BLOCKED)) continue; | | if (mflags & P_OUT_OF_MAP) continue; |
| | if (OB_TYPE_MOVE_BLOCK(who, GET_MAP_MOVE_BLOCK(m, x, y))) continue; |
| | |
for(tmp=get_map_ob(m,x,y);tmp;tmp=tmp->above) { | | for(tmp=get_map_ob(m,x,y);tmp;tmp=tmp->above) { |
if((player||friendly) | | if((player||friendly) |