version 1.76 | | version 1.77 |
---|
| | |
/* | | /* |
* static char *rcsid_player_c = | | * static char *rcsid_player_c = |
* "$Id: player.c,v 1.76 2001/12/16 03:31:03 mwedel Exp $"; | | * "$Id: player.c,v 1.77 2002/01/02 06:53:23 garbled Exp $"; |
*/ | | */ |
| | |
/* | | /* |
| | |
| | |
/* moved door processing out of move_player_attack. | | /* moved door processing out of move_player_attack. |
* returns 1 if player has opened the door with a key | | * returns 1 if player has opened the door with a key |
* such that the caller should not do anything more. | | * such that the caller should not do anything more, |
* 0 otherwise | | * 0 otherwise |
*/ | | */ |
static int player_attack_door(object *op, object *door) | | static int player_attack_door(object *op, object *door) |
{ | | { |
| | |
/* If its a door, try to find a use a key. If we do destroy the door, | | /* If its a door, try to find a use a key. If we do destroy the door, |
* might as well return immediately as there is nothing more to do - | | * might as well return immediately as there is nothing more to do - |
* otherwise, we fall through to the rest of the code. | | * otherwise, we fall through to the rest of the code. |
| | |
object *key=find_key(op, op, door); | | object *key=find_key(op, op, door); |
| | |
/* IF we found a key, do some extra work */ | | /* IF we found a key, do some extra work */ |
if (key) | | if (key) { |
{ | | |
object *container=key->env; | | object *container=key->env; |
| | |
play_sound_map(op->map, op->x, op->y, SOUND_OPEN_DOOR); | | play_sound_map(op->map, op->x, op->y, SOUND_OPEN_DOOR); |
if(action_makes_visible(op)) | | if(action_makes_visible(op)) make_visible(op); |
make_visible(op); | | if(door->inv && door->inv->type ==RUNE) spring_trap(door->inv,op); |
if(door->inv && door->inv->type ==RUNE) | | if (door->type == DOOR) { |
spring_trap(door->inv,op); | | |
if (door->type == DOOR) | | |
hit_player(door,9998,op,AT_PHYSICAL); /* Break through the door */ | | hit_player(door,9998,op,AT_PHYSICAL); /* Break through the door */ |
else if(door->type==LOCKED_DOOR) | | } |
{ | | else if(door->type==LOCKED_DOOR) { |
new_draw_info_format(NDI_UNIQUE, NDI_BROWN, op, | | new_draw_info_format(NDI_UNIQUE, NDI_BROWN, op, |
"You open the door with the %s", query_short_name(key)); | | "You open the door with the %s", query_short_name(key)); |
remove_door2(door); /* remove door without violence ;-) */ | | remove_door2(door); /* remove door without violence ;-) */ |
| | |
if (container != op) | | if (container != op) |
esrv_update_item(UPD_WEIGHT, op, container); | | esrv_update_item(UPD_WEIGHT, op, container); |
return 1; /* Nothing more to do below */ | | return 1; /* Nothing more to do below */ |
} | | } else if (door->type==LOCKED_DOOR) { |
else if (door->type==LOCKED_DOOR) | | |
{ | | |
/* Might as well return now - no other way to open this */ | | /* Might as well return now - no other way to open this */ |
new_draw_info(NDI_UNIQUE | NDI_NAVY, 0, op, door->msg); | | new_draw_info(NDI_UNIQUE | NDI_NAVY, 0, op, door->msg); |
return 1; | | return 1; |
| | |
* going to try and move (not fire weapons). | | * going to try and move (not fire weapons). |
*/ | | */ |
| | |
int move_player_attack(object *op, int dir) | | void move_player_attack(object *op, int dir) |
{ | | { |
int ret=0; | | |
object *tmp; | | object *tmp; |
int nx=freearr_x[dir]+op->x,ny=freearr_y[dir]+op->y; | | int nx=freearr_x[dir]+op->x,ny=freearr_y[dir]+op->y; |
mapstruct *m; | | mapstruct *m; |
| | |
if ((op->contr->braced || !move_ob(op,dir,op)) && !out_of_map(op->map,nx,ny)) { | | if ((op->contr->braced || !move_ob(op,dir,op)) && !out_of_map(op->map,nx,ny)) { |
if (OUT_OF_REAL_MAP(op->map, nx, ny)) { | | if (OUT_OF_REAL_MAP(op->map, nx, ny)) { |
m = get_map_from_coord(op->map, &nx, &ny); | | m = get_map_from_coord(op->map, &nx, &ny); |
if (!m) return ret; /* Don't think this should happen */ | | if (!m) return; /* Don't think this should happen */ |
} | | } |
else m =op->map; | | else m =op->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");*/ |
return ret; | | return; |
} | | } |
| | |
/* Go through all the objects, and stop if we find one of interest. */ | | /* Go through all the objects, and stop if we find one of interest. */ |
| | |
} | | } |
| | |
if (tmp==NULL) /* This happens anytime the player tries to move */ | | if (tmp==NULL) /* This happens anytime the player tries to move */ |
return ret; /* into a wall */ | | return; /* into a wall */ |
| | |
if(tmp->head != NULL) | | if(tmp->head != NULL) |
tmp = tmp->head; | | tmp = tmp->head; |
| | |
if ((tmp->type==DOOR && tmp->stats.hp>=0) || (tmp->type==LOCKED_DOOR)) | | if ((tmp->type==DOOR && tmp->stats.hp>=0) || (tmp->type==LOCKED_DOOR)) |
if (player_attack_door(op, tmp)) return ret; | | if (player_attack_door(op, tmp)) return; |
| | |
/* The following deals with possibly attacking peaceful | | /* The following deals with possibly attacking peaceful |
* or frienddly creatures. Basically, all players are considered | | * or frienddly creatures. Basically, all players are considered |
| | |
(QUERY_FLAG(tmp,FLAG_UNAGGRESSIVE) || QUERY_FLAG(tmp, FLAG_FRIENDLY))) | | (QUERY_FLAG(tmp,FLAG_UNAGGRESSIVE) || QUERY_FLAG(tmp, FLAG_FRIENDLY))) |
{ | | { |
/* 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 ret; | | if (op->contr->braced) return; |
play_sound_map(op->map, op->x, op->y, SOUND_PUSH_PLAYER); | | play_sound_map(op->map, op->x, op->y, SOUND_PUSH_PLAYER); |
if(push_ob(tmp,dir,op)) | | (void) push_ob(tmp,dir,op); |
ret = 1; | | |
if(op->contr->tmp_invis||op->hide) make_visible(op); | | if(op->contr->tmp_invis||op->hide) make_visible(op); |
return ret; | | return; |
} | | } |
| | |
if ((tmp->type==PLAYER || tmp->enemy != op) && | | if ((tmp->type==PLAYER || tmp->enemy != op) && |
| | |
|| QUERY_FLAG(tmp, FLAG_FRIENDLY)) && (op->contr->peaceful | | || QUERY_FLAG(tmp, FLAG_FRIENDLY)) && (op->contr->peaceful |
&& !op_on_battleground(op, NULL, NULL)) && (!op->contr->braced)) { | | && !op_on_battleground(op, NULL, NULL)) && (!op->contr->braced)) { |
play_sound_map(op->map, op->x, op->y, SOUND_PUSH_PLAYER); | | play_sound_map(op->map, op->x, op->y, SOUND_PUSH_PLAYER); |
if(push_ob(tmp,dir,op)) | | (void) push_ob(tmp,dir,op); |
ret = 1; | | |
if(op->contr->tmp_invis||op->hide) make_visible(op); | | if(op->contr->tmp_invis||op->hide) make_visible(op); |
} | | } |
| | |
| | |
| | |
op->contr->has_hit = 1; /* The last action was to hit, so use weapon_sp */ | | op->contr->has_hit = 1; /* The last action was to hit, so use weapon_sp */ |
| | |
if(skill_attack(tmp, op, 0, NULL) ) | | skill_attack(tmp, op, 0, NULL); |
ret = 1; | | |
| | |
/* If attacking another player, that player gets automatic | | /* If attacking another player, that player gets automatic |
* hitback, and doesn't loose luck either. | | * hitback, and doesn't loose luck either. |
*/ | | */ |
| | |
if(action_makes_visible(op)) make_visible(op); | | if(action_makes_visible(op)) make_visible(op); |
} | | } |
} /* if player should attack something */ | | } /* if player should attack something */ |
return ret; | | |
} | | } |
| | |
int move_player(object *op,int dir) { | | int move_player(object *op,int dir) { |
int face, pick; | | int face, pick; |
/* | | |
if(op->contr->socket.newanim) | | if(op->contr->socket.newanim) |
face = dir%8; | | face = dir%8; |
else | | else |
*/ | | |
face = dir ? (dir - 1) / 2 : -1; | | face = dir ? (dir - 1) / 2 : -1; |
| | |
if(op->map == NULL || op->map->in_memory != MAP_IN_MEMORY) | | if(op->map == NULL || op->map->in_memory != MAP_IN_MEMORY) |
| | |
if(QUERY_FLAG(op,FLAG_CONFUSED) && dir) | | if(QUERY_FLAG(op,FLAG_CONFUSED) && dir) |
dir = absdir(dir + RANDOM()%3 + RANDOM()%3 - 2); | | dir = absdir(dir + RANDOM()%3 + RANDOM()%3 - 2); |
| | |
op->anim_moving_dir = -1; | | if(op->hide) do_hidden_move(op); |
op->anim_enemy_dir = -1; | | |
op->anim_last_facing = -1; | | |
if(op->hide) | | |
{ | | |
op->anim_moving_dir = dir; | | |
do_hidden_move(op); | | |
} | | |
| | |
if(op->contr->fire_on) | | if(op->contr->fire_on) { |
{ | | |
fire(op,dir); | | fire(op,dir); |
op->anim_enemy_dir = dir; | | |
} | | |
else | | |
{ | | |
if(move_player_attack(op,dir)) | | |
{ | | |
op->anim_enemy_dir = dir; | | |
} | | |
else | | |
{ | | |
op->anim_moving_dir = dir; | | |
} | | |
} | | } |
| | else move_player_attack(op,dir); |
| | |
/* Add special check for newcs players and fire on - this way, the | | /* Add special check for newcs players and fire on - this way, the |
* server can handle repeat firing. | | * server can handle repeat firing. |
| | |
op->direction=0; | | op->direction=0; |
} | | } |
| | |
if(op->contr->socket.newanim) | | |
{ | | |
/* in the new anim system, we use again the CF anim engine */ | | |
if(op->anim_enemy_dir == -1 && op->anim_moving_dir == -1) | | |
op->anim_last_facing = dir; | | |
animate_object(op, 0); | | |
} | | |
else | | |
{ | | |
if(face != -1) | | if(face != -1) |
SET_ANIMATION(op,face); | | SET_ANIMATION(op,face); |
| | |
update_object(op, UP_OBJ_FACE); | | update_object(op, UP_OBJ_FACE); |
} | | |
| | |
return 0; | | return 0; |
} | | } |
| | |
* there, as well as the confusion stuff. | | * there, as well as the confusion stuff. |
*/ | | */ |
move_player(op, op->direction); | | move_player(op, op->direction); |
if (op->speed_left>0) | | if (op->speed_left>0) return 1; |
return 1; | | else return 0; |
} | | } |
return 0; | | return 0; |
} | | } |