From 3f793e909b06fa4dfeb110d1ad6587c62ef7a7b2 Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Sat, 15 Apr 2023 07:47:21 +0300 Subject: [PATCH 29/29] Add support for unit instance requirements for Attack_Bonus See osdn #47862 Signed-off-by: Marko Lindqvist --- common/combat.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/common/combat.c b/common/combat.c index 32f85aea2e..bf2e9695b0 100644 --- a/common/combat.c +++ b/common/combat.c @@ -610,10 +610,21 @@ int get_total_attack_power(const struct unit *attacker, { int mod; int attackpower = get_attack_power(attacker); - - mod = 100 + get_unittype_bonus(unit_owner(attacker), unit_tile(defender), - unit_type_get(attacker), paction, - EFT_ATTACK_BONUS); + struct tile *deftile = unit_tile(defender); + struct city *pcity = tile_city(deftile); + + /* Note: get_unit_bonus() would use the tile unit is on, + * but we want defending tile. */ + mod = 100 + get_target_bonus_effects(NULL, + &(const struct req_context) { + .player = unit_owner(attacker), + .city = pcity, + .tile = deftile, + .unit = attacker, + .unittype = unit_type_get(attacker), + .action = paction, + }, + NULL, EFT_ATTACK_BONUS); return attackpower * mod / 100; } -- 2.39.2