From e261eb8df15e8091ca79909a3cc47016cebaec63 Mon Sep 17 00:00:00 2001 From: newfrenchy83 Date: Sat, 7 Oct 2023 17:42:33 +0200 Subject: [PATCH] fix affect_allies can have 3 value true,false and noexistent when abilities don't have affect_allies implemented, then onlyunit same side are affected, if affect_allies=yes, unit of allied side inclus and if falsethen none unit allied or same side are affected. --- data/schema/filters/abilities.cfg | 2 +- data/schema/game_config.cfg | 4 ++++ src/units/unit.cpp | 7 ++++++- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/data/schema/filters/abilities.cfg b/data/schema/filters/abilities.cfg index 7642c11790fea..55860ca7c5a78 100644 --- a/data/schema/filters/abilities.cfg +++ b/data/schema/filters/abilities.cfg @@ -14,7 +14,7 @@ {SIMPLE_KEY divide s_real_range_list} {SIMPLE_KEY affect_adjacent s_bool} {SIMPLE_KEY affect_self s_bool} - {SIMPLE_KEY affect_allies s_bool} + {DEFAULT_KEY affect_allies affect_allies_filter empty} {SIMPLE_KEY affect_enemies s_bool} {DEFAULT_KEY type_value value_type empty} {FILTER_BOOLEAN_OPS abilities} diff --git a/data/schema/game_config.cfg b/data/schema/game_config.cfg index a360df25583f5..2ad2d6d414178 100644 --- a/data/schema/game_config.cfg +++ b/data/schema/game_config.cfg @@ -44,6 +44,10 @@ name="value_type" value="empty|value|add|sub|multiply|divide" [/type] + [type] + name="affect_allies_filter" + value="empty|yes|no" + [/type] [type] name="addon_type" value="sp|mp|hybrid" diff --git a/src/units/unit.cpp b/src/units/unit.cpp index 1c709233af206..bee19fc83ec95 100644 --- a/src/units/unit.cpp +++ b/src/units/unit.cpp @@ -1457,8 +1457,13 @@ static bool matches_ability_filter(const config & cfg, const std::string& tag_na if(!bool_matches_if_present(filter, cfg, "affect_self", true)) return false; - if(!bool_matches_if_present(filter, cfg, "affect_allies", true)) + if(!filter["affect_allies"].empty() && !cfg["affect_allies"].empty()){ + if(!bool_matches_if_present(filter, cfg, "affect_allies", true)){ + return false; + } + } else if(!filter["affect_allies"].empty() && filter["affect_allies"].str() != "empty"){ return false; + } if(!bool_matches_if_present(filter, cfg, "affect_enemies", false)) return false;