version 1.190 | | version 1.191 |
---|
| | |
/* | | /* |
* static char *rcsid_player_c = | | * static char *rcsid_player_c = |
* "$Id: player.c,v 1.190 2006/01/08 23:57:19 qal21 Exp $"; | | * "$Id: player.c,v 1.191 2006/02/07 07:54:46 mwedel Exp $"; |
*/ | | */ |
| | |
/* | | /* |
| | |
| | |
void move_player_attack(object *op, int dir) | | void move_player_attack(object *op, int dir) |
{ | | { |
object *tmp, *mon; | | object *tmp, *mon, *tpl; |
sint16 nx=freearr_x[dir]+op->x,ny=freearr_y[dir]+op->y; | | sint16 nx, ny; |
int on_battleground; | | int on_battleground; |
mapstruct *m; | | mapstruct *m; |
| | |
on_battleground = op_on_battleground(op, NULL, NULL); | | if (op->contr->transport) tpl = op->contr->transport; |
| | else tpl = op; |
| | nx=freearr_x[dir]+tpl->x; |
| | ny=freearr_y[dir]+tpl->y; |
| | |
| | on_battleground = op_on_battleground(tpl, NULL, NULL); |
| | |
/* If braced, or can't move to the square, and it is not out of the | | /* If braced, or can't move to the square, and it is not out of the |
* map, attack it. Note order of if statement is important - don't | | * map, attack it. Note order of if statement is important - don't |
| | |
* quite a bit of processing. However, it probably is less than what | | * quite a bit of processing. However, it probably is less than what |
* move_ob uses. | | * move_ob uses. |
*/ | | */ |
if ((op->contr->braced || !move_ob(op,dir,op)) && !out_of_map(op->map,nx,ny)) { | | if ((op->contr->braced || !move_ob(tpl,dir,tpl)) && !out_of_map(tpl->map,nx,ny)) { |
if (OUT_OF_REAL_MAP(op->map, nx, ny)) { | | if (OUT_OF_REAL_MAP(tpl->map, nx, ny)) { |
m = get_map_from_coord(op->map, &nx, &ny); | | m = get_map_from_coord(tpl->map, &nx, &ny); |
if (!m) return; /* Don't think this should happen */ | | if (!m) return; /* Don't think this should happen */ |
} | | } |
else m =op->map; | | else m =tpl->map; |
| | |
if ((tmp=get_map_ob(m,nx,ny))==NULL) { | | if ((tmp=get_map_ob(m,nx,ny))==NULL) { |
/* LOG(llevError,"player_move_attack: get_map_ob returns NULL, but player can not more there.\n");*/ | | /* LOG(llevError,"player_move_attack: get_map_ob returns NULL, but player can not more there.\n");*/ |
| | |
{ | | { |
/* If we're braced, we don't want to switch places with it */ | | /* If we're braced, we don't want to switch places with it */ |
if (op->contr->braced) return; | | if (op->contr->braced) return; |
play_sound_map(op->map, op->x, op->y, SOUND_PUSH_PLAYER); | | play_sound_map(tpl->map, tpl->x, tpl->y, SOUND_PUSH_PLAYER); |
(void) push_ob(mon,dir,op); | | (void) push_ob(mon,dir,op); |
if(op->contr->tmp_invis||op->hide) make_visible(op); | | if(op->contr->tmp_invis||op->hide) make_visible(op); |
return; | | return; |
| | |
(mon->type==PLAYER || QUERY_FLAG(mon,FLAG_UNAGGRESSIVE) || QUERY_FLAG(mon, FLAG_FRIENDLY)) && | | (mon->type==PLAYER || QUERY_FLAG(mon,FLAG_UNAGGRESSIVE) || QUERY_FLAG(mon, FLAG_FRIENDLY)) && |
(op->contr->peaceful && !on_battleground)) { | | (op->contr->peaceful && !on_battleground)) { |
if (!op->contr->braced) { | | if (!op->contr->braced) { |
play_sound_map(op->map, op->x, op->y, SOUND_PUSH_PLAYER); | | play_sound_map(tpl->map, tpl->x, tpl->y, SOUND_PUSH_PLAYER); |
(void) push_ob(mon,dir,op); | | (void) push_ob(mon,dir,op); |
} else { | | } else { |
new_draw_info(0, 0,op,"You withhold your attack"); | | new_draw_info(0, 0,op,"You withhold your attack"); |
| | |
| | |
int move_player(object *op,int dir) { | | int move_player(object *op,int dir) { |
int pick; | | int pick; |
| | object *transport = op->contr->transport; |
| | |
if(op->map == NULL || op->map->in_memory != MAP_IN_MEMORY) | | if(!transport && (op->map == NULL || op->map->in_memory != MAP_IN_MEMORY)) |
return 0; | | return 0; |
| | |
/* Sanity check: make sure dir is valid */ | | /* Sanity check: make sure dir is valid */ |
| | |
| | |
op->facing = dir; | | op->facing = dir; |
| | |
if(op->hide) do_hidden_move(op); | | if(!transport && op->hide) do_hidden_move(op); |
| | |
| | if (transport) { |
| | /* transport->contr is set up for the person in charge of the boat. |
| | * if that isn't this person, he can't steer it, etc |
| | */ |
| | if (transport->contr != op->contr) return 0; |
| | |
| | /* Transport can't move. But update dir so it at least |
| | * will point in the same direction if player is running. |
| | */ |
| | if (transport->speed_left < 0.0) { |
| | transport->direction = dir; |
| | op->direction = dir; |
| | return 0; |
| | } |
| | /* Remove transport speed. Give player just a little speed - |
| | * enough so that they will get an action again quickly. |
| | * |
| | */ |
| | transport->speed_left -= 1.0; |
| | if (op->speed_left < 0.0) op->speed_left = -0.01; |
| | |
| | } |
| | |
if(op->contr->fire_on) { | | if(op->contr->fire_on) { |
fire(op,dir); | | fire(op,dir); |
| | |
* get reset to zero. This allows for full animation capabilities | | * get reset to zero. This allows for full animation capabilities |
* for players. | | * for players. |
*/ | | */ |
animate_object(op, op->facing); | | if (!transport) animate_object(op, op->facing); |
return 0; | | return 0; |
} | | } |
| | |