Skip to content

Commit

Permalink
Make wolves attack enemies
Browse files Browse the repository at this point in the history
  • Loading branch information
Keriew committed Oct 23, 2023
1 parent f6ba6d0 commit ca91441
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 8 deletions.
25 changes: 20 additions & 5 deletions src/figure/combat.c
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ int figure_combat_get_target_for_wolf(int x, int y, int max_distance)
case FIGURE_CREATURE:
continue;
}
if (figure_is_enemy(f) || figure_is_herd(f)) {
if (figure_is_herd(f)) {
continue;
}
if (figure_is_legion(f) && f->action_state == FIGURE_ACTION_80_SOLDIER_AT_REST) {
Expand Down Expand Up @@ -387,8 +387,9 @@ static int can_attack_animal(figure_category category, figure_category opponent_
void figure_combat_attack_figure_at(figure *f, int grid_offset)
{
figure_category category = figure_properties_for_type(f->type)->category;
if (category <= FIGURE_CATEGORY_INACTIVE || category >= FIGURE_CATEGORY_CRIMINAL ||
f->action_state == FIGURE_ACTION_150_ATTACK) {
if (category <= FIGURE_CATEGORY_INACTIVE ||
(category >= FIGURE_CATEGORY_CRIMINAL && category <= FIGURE_CATEGORY_ANIMAL) ||
f->action_state == FIGURE_ACTION_150_ATTACK) {
return;
}
formation *l = formation_get(f->formation_id);
Expand Down Expand Up @@ -418,16 +419,30 @@ void figure_combat_attack_figure_at(figure *f, int grid_offset)
attack = 1;
} else if (category == FIGURE_CATEGORY_ARMED && opponent_category == FIGURE_CATEGORY_HOSTILE) {
attack = 1;
} else if (category == FIGURE_CATEGORY_ARMED && opponent_category == FIGURE_CATEGORY_AGGRESSIVE_ANIMAL) {
attack = 1;
} else if (category == FIGURE_CATEGORY_HOSTILE && opponent_category == FIGURE_CATEGORY_CITIZEN) {
attack = 1;
} else if (category == FIGURE_CATEGORY_HOSTILE && opponent_category == FIGURE_CATEGORY_ARMED) {
attack = 1;
} else if (category == FIGURE_CATEGORY_HOSTILE && opponent_category == FIGURE_CATEGORY_CRIMINAL) {
attack = 1;
} else if (can_attack_animal(category, opponent_category, l, opponent)) {
attack = 1;
} else if (category == FIGURE_CATEGORY_HOSTILE && opponent_category == FIGURE_CATEGORY_ANIMAL) {
attack = 1;
} else if (category == FIGURE_CATEGORY_HOSTILE && opponent_category == FIGURE_CATEGORY_AGGRESSIVE_ANIMAL) {
attack = 1;
} else if (category == FIGURE_CATEGORY_AGGRESSIVE_ANIMAL && opponent_category == FIGURE_CATEGORY_CITIZEN) {
attack = 1;
} else if (category == FIGURE_CATEGORY_AGGRESSIVE_ANIMAL && opponent_category == FIGURE_CATEGORY_ARMED) {
attack = 1;
} else if (category == FIGURE_CATEGORY_AGGRESSIVE_ANIMAL && opponent_category == FIGURE_CATEGORY_CRIMINAL) {
attack = 1;
} else if (category == FIGURE_CATEGORY_AGGRESSIVE_ANIMAL && opponent_category == FIGURE_CATEGORY_ANIMAL) {
attack = 1;
} else if (category == FIGURE_CATEGORY_AGGRESSIVE_ANIMAL && opponent_category == FIGURE_CATEGORY_HOSTILE) {
attack = 1;
} else if (can_attack_animal(category, opponent_category, l, opponent)) {
attack = 1;
}
if (attack && opponent->action_state == FIGURE_ACTION_150_ATTACK && opponent->num_attackers >= 2) {
attack = 0;
Expand Down
2 changes: 1 addition & 1 deletion src/figure/properties.c
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ static const figure_properties properties[FIGURE_TYPE_MAX] = {
.missile_defense_value = 0, .missile_attack_value = 0, .missile_delay = 0
},
[FIGURE_WOLF] = {
.category = FIGURE_CATEGORY_HOSTILE,
.category = FIGURE_CATEGORY_AGGRESSIVE_ANIMAL,
.max_damage = 80, .attack_value = 8, .defense_value = 0,
.missile_defense_value = 0, .missile_attack_value = 0, .missile_delay = 0
},
Expand Down
3 changes: 2 additions & 1 deletion src/figure/properties.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ typedef enum {
FIGURE_CATEGORY_HOSTILE = 3,
FIGURE_CATEGORY_CRIMINAL = 4,
FIGURE_CATEGORY_NATIVE = 5,
FIGURE_CATEGORY_ANIMAL = 6
FIGURE_CATEGORY_ANIMAL = 6,
FIGURE_CATEGORY_AGGRESSIVE_ANIMAL = 7
} figure_category;

typedef struct {
Expand Down
2 changes: 1 addition & 1 deletion src/widget/city_overlay_risks.c
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ static int show_figure_native(const figure *f)
static int show_figure_enemy(const figure *f)
{
const figure_properties *props = figure_properties_for_type(f->type);
return props->category == FIGURE_CATEGORY_HOSTILE || props->category == FIGURE_CATEGORY_NATIVE;
return props->category == FIGURE_CATEGORY_HOSTILE || props->category == FIGURE_CATEGORY_NATIVE || props->category == FIGURE_CATEGORY_AGGRESSIVE_ANIMAL;
}

static int get_column_height_fire(const building *b)
Expand Down

0 comments on commit ca91441

Please sign in to comment.