version 1.107 | | version 1.108 |
---|
| | |
/* | | /* |
* static char *rcsid_player_c = | | * static char *rcsid_player_c = |
* "$Id: player.c,v 1.107 2002/12/03 07:40:18 mwedel Exp $"; | | * "$Id: player.c,v 1.108 2002/12/04 08:12:40 mwedel Exp $"; |
*/ | | */ |
| | |
/* | | /* |
| | |
| | |
void move_player_attack(object *op, int dir) | | void move_player_attack(object *op, int dir) |
{ | | { |
object *tmp; | | object *tmp, *mon; |
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; |
| | |
| | |
return; | | return; |
} | | } |
| | |
/* Go through all the objects, and stop if we find one of interest. */ | | mon = NULL; |
while (tmp->above!=NULL) { | | /* Go through all the objects, and find ones of interest. Only stop if |
if ((QUERY_FLAG(tmp,FLAG_ALIVE) || QUERY_FLAG(tmp,FLAG_CAN_ROLL) | | * we find a monster - that is something we know we want to attack. |
|| tmp->type ==LOCKED_DOOR) && tmp!=op) | | * if its a door or barrel (can roll) see if there may be monsters |
| | * on the space |
| | */ |
| | while (tmp!=NULL) { |
| | if (tmp == op) continue; |
| | if (QUERY_FLAG(tmp,FLAG_ALIVE)) { |
| | mon = tmp; |
break; | | break; |
| | } |
| | if (tmp->type==LOCKED_DOOR || QUERY_FLAG(tmp,FLAG_CAN_ROLL)) |
| | mon = tmp; |
tmp=tmp->above; | | tmp=tmp->above; |
} | | } |
| | |
if (tmp==NULL) /* This happens anytime the player tries to move */ | | if (mon==NULL) /* This happens anytime the player tries to move */ |
return; /* into a wall */ | | return; /* into a wall */ |
| | |
if(tmp->head != NULL) | | if(mon->head != NULL) |
tmp = tmp->head; | | mon = mon->head; |
| | |
if ((tmp->type==DOOR && tmp->stats.hp>=0) || (tmp->type==LOCKED_DOOR)) | | if ((mon->type==DOOR && mon->stats.hp>=0) || (mon->type==LOCKED_DOOR)) |
if (player_attack_door(op, tmp)) return; | | if (player_attack_door(op, mon)) 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 |
| | |
* peaceful. Our assumption is the creature is a pet if the | | * peaceful. Our assumption is the creature is a pet if the |
* player owns it and it is either friendly or unagressive. | | * player owns it and it is either friendly or unagressive. |
*/ | | */ |
if ((op->type==PLAYER) && get_owner(tmp)==op && | | if ((op->type==PLAYER) && get_owner(mon)==op && |
(QUERY_FLAG(tmp,FLAG_UNAGGRESSIVE) || QUERY_FLAG(tmp, FLAG_FRIENDLY))) | | (QUERY_FLAG(mon,FLAG_UNAGGRESSIVE) || QUERY_FLAG(mon, 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; | | 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); |
(void) push_ob(tmp,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; |
} | | } |
| | |
* someone, but put it inside this loop so that you won't | | * someone, but put it inside this loop so that you won't |
* attack them either. | | * attack them either. |
*/ | | */ |
if ((tmp->type==PLAYER || tmp->enemy != op) && | | if ((mon->type==PLAYER || mon->enemy != op) && |
(tmp->type==PLAYER || QUERY_FLAG(tmp,FLAG_UNAGGRESSIVE) | | (mon->type==PLAYER || QUERY_FLAG(mon,FLAG_UNAGGRESSIVE) || QUERY_FLAG(mon, FLAG_FRIENDLY)) && |
|| QUERY_FLAG(tmp, FLAG_FRIENDLY)) && (op->contr->peaceful | | (op->contr->peaceful && !op_on_battleground(op, NULL, NULL))) { |
&& !op_on_battleground(op, NULL, NULL))) { | | |
if (!op->contr->braced) { | | if (!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); |
(void) push_ob(tmp,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"); |
} | | } |
| | |
/* If the object is a boulder or other rollable object, then | | /* If the object is a boulder or other rollable object, then |
* roll it if not braced. You can't roll it if you are braced. | | * roll it if not braced. You can't roll it if you are braced. |
*/ | | */ |
else if(QUERY_FLAG(tmp,FLAG_CAN_ROLL)&&(!op->contr->braced)) { | | else if(QUERY_FLAG(mon,FLAG_CAN_ROLL)&&(!op->contr->braced)) { |
recursive_roll(tmp,dir,op); | | recursive_roll(mon,dir,op); |
if(action_makes_visible(op)) make_visible(op); | | if(action_makes_visible(op)) make_visible(op); |
} | | } |
| | |
| | |
* that party_number -1 is no party, so attacks can still happen. | | * that party_number -1 is no party, so attacks can still happen. |
*/ | | */ |
| | |
else if ((tmp->stats.hp>=0) && QUERY_FLAG(tmp, FLAG_ALIVE) && | | else if ((mon->stats.hp>=0) && QUERY_FLAG(mon, FLAG_ALIVE) && |
((tmp->type!=PLAYER || op->contr->party_number==-1 || | | ((mon->type!=PLAYER || op->contr->party_number==-1 || |
op->contr->party_number!=tmp->contr->party_number))) { | | op->contr->party_number!=mon->contr->party_number))) { |
| | |
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 */ |
| | |
skill_attack(tmp, op, 0, NULL); | | skill_attack(mon, op, 0, NULL); |
/* 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 (tmp->type == PLAYER && tmp->stats.hp >= 0 && !tmp->contr->has_hit) { | | if (mon->type == PLAYER && mon->stats.hp >= 0 && !mon->contr->has_hit) { |
short luck = tmp->stats.luck; | | short luck = mon->stats.luck; |
tmp->contr->has_hit = 1; | | mon->contr->has_hit = 1; |
skill_attack(op, tmp, 0, NULL); | | skill_attack(op, mon, 0, NULL); |
tmp->stats.luck = luck; | | mon->stats.luck = luck; |
} | | } |
if(action_makes_visible(op)) make_visible(op); | | if(action_makes_visible(op)) make_visible(op); |
} | | } |