From 71040bf22f373a4da0fe0d7de9f8786cea565ec8 Mon Sep 17 00:00:00 2001 From: Sveinung Kvilhaugsvik Date: Tue, 11 May 2021 15:53:21 +0200 Subject: [PATCH 12/12] Support action requirements in Unit_No_Lose_Pop. This makes it possible to let a unit have two attack variants where one reduces city population and the other doesn't. See osdn #42242 --- doc/README.effects | 3 ++- server/unithand.c | 5 ++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/doc/README.effects b/doc/README.effects index 8db5c5b5bd..8332ee860b 100644 --- a/doc/README.effects +++ b/doc/README.effects @@ -406,7 +406,8 @@ Move_Bonus 'Local' to give it a specific class of units only. Unit_No_Lose_Pop - No population lost when a city's defender is lost. + No population lost when a city's defender is lost. Can be limited to +only apply to some actions via an Action requirement. Unit_Recover Units recover amount extra hitpoints per turn. diff --git a/server/unithand.c b/server/unithand.c index cbabdcceea..3343f61357 100644 --- a/server/unithand.c +++ b/server/unithand.c @@ -4180,7 +4180,10 @@ static void unit_attack_civilian_casualties(const struct unit *punit, if (pcity && city_size_get(pcity) > 1 - && get_city_bonus(pcity, EFT_UNIT_NO_LOSE_POP) <= 0 + && get_target_bonus_effects(NULL, + city_owner(pcity), NULL, pcity, NULL, + city_tile(pcity), NULL, NULL, NULL, NULL, + paction, EFT_UNIT_NO_LOSE_POP) <= 0 && kills_citizen_after_attack(punit)) { city_reduce_size(pcity, 1, pplayer, reason); city_refresh(pcity); -- 2.30.2