From 60f61b777fb4318b7d19d27b25c1570156cdc8e5 Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Mon, 8 Nov 2021 01:12:37 +0200 Subject: [PATCH 11/11] Consider it land bombardment when a ship attacks from a city to land Reported by log65536 See osdn #42960 Signed-off-by: Marko Lindqvist --- common/combat.c | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/common/combat.c b/common/combat.c index a3ef4c9e7e..99bfaca0cc 100644 --- a/common/combat.c +++ b/common/combat.c @@ -344,15 +344,19 @@ double win_chance(int as, int ahp, int afp, int ds, int dhp, int dfp) } /************************************************************************** -A unit's effective firepower depend on the situation. + A unit's effective firepower depend on the situation. **************************************************************************/ void get_modified_firepower(const struct unit *attacker, const struct unit *defender, int *att_fp, int *def_fp) { struct city *pcity = tile_city(unit_tile(defender)); + const struct unit_type *att_type; + struct tile *att_tile; - *att_fp = unit_type_get(attacker)->firepower; + att_type = unit_type_get(attacker); + + *att_fp = att_type->firepower; *def_fp = unit_type_get(defender)->firepower; /* Check CityBuster flag */ @@ -367,7 +371,7 @@ void get_modified_firepower(const struct unit *attacker, */ if (unit_has_type_flag(attacker, UTYF_BADWALLATTACKER) && get_unittype_bonus(unit_owner(defender), unit_tile(defender), - unit_type_get(attacker), EFT_DEFEND_BONUS) > 0) { + att_type, EFT_DEFEND_BONUS) > 0) { *att_fp = 1; } @@ -383,15 +387,21 @@ void get_modified_firepower(const struct unit *attacker, * When attacked by fighters, helicopters have their firepower * reduced to 1. */ - if (combat_bonus_against(unit_type_get(attacker)->bonuses, + if (combat_bonus_against(att_type->bonuses, unit_type_get(defender), CBONUS_FIREPOWER1)) { *def_fp = 1; } - /* In land bombardment both units have their firepower reduced to 1 */ - if (!is_native_tile(unit_type_get(attacker), unit_tile(defender)) - && !can_exist_at_tile(unit_type_get(defender), unit_tile(attacker))) { + att_tile = unit_tile(attacker); + + /* In land bombardment both units have their firepower reduced to 1. + * Land bombardment is always towards tile not native for attacker. + * It's initiated either from a tile not native to defender (Ocean for Land unit) + * or from a tile where attacker is despite non-native terrain (city, transport) */ + if (!is_native_tile(att_type, unit_tile(defender)) + && (!can_exist_at_tile(unit_type_get(defender), att_tile) + || !is_native_tile(att_type, att_tile))) { *att_fp = 1; *def_fp = 1; } -- 2.30.2