From e5ffb9bf566270483862c61198f69d95ece322cc Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Sat, 17 Aug 2024 04:21:43 +0300 Subject: [PATCH 18/18] Add Veteran_Work effect type See osdn #43186 Signed-off-by: Marko Lindqvist --- ai/default/daieffects.c | 8 ++++++-- doc/README.effects | 4 ++++ gen_headers/enums/effects_enums.def | 1 + server/unittools.c | 4 +++- 4 files changed, 14 insertions(+), 3 deletions(-) diff --git a/ai/default/daieffects.c b/ai/default/daieffects.c index 4e86a218fc..56f0e18f3e 100644 --- a/ai/default/daieffects.c +++ b/ai/default/daieffects.c @@ -202,8 +202,8 @@ adv_want dai_effect_value(struct player *pplayer, case EFT_CITY_VISION_RADIUS_SQ: case EFT_UNIT_VISION_RADIUS_SQ: - /* Wild guess. "Amount" is the number of tiles (on average) that - * will be revealed by the effect. Note that with an omniscient + /* Wild guess. "Amount" is the number of tiles (on average) that + * will be revealed by the effect. Note that with an omniscient * AI this effect is actually not useful at all. */ v += c * amount; break; @@ -472,6 +472,10 @@ adv_want dai_effect_value(struct player *pplayer, num = num_affected_units(peffect, adv); v += (2 * c + num); break; + case EFT_VETERAN_WORK: + num = num_affected_units(peffect, adv); + v += amount * (2 * c + num) / 70; + break; case EFT_VETERAN_BUILD: /* FIXME: check other reqs (e.g., unitflag) */ num = num_affected_units(peffect, adv); diff --git a/doc/README.effects b/doc/README.effects index 70e9477ec0..e59b5185a8 100644 --- a/doc/README.effects +++ b/doc/README.effects @@ -829,6 +829,10 @@ Veteran_Combat Increases the chance of units of this type becoming veteran after combat by amount percent. +Veteran_Work + Increases the chance of units of this type becoming veteran after finishing + work by amount percent. + Victory Positive value means that player wins the game. diff --git a/gen_headers/enums/effects_enums.def b/gen_headers/enums/effects_enums.def index be60940a62..0197096d49 100644 --- a/gen_headers/enums/effects_enums.def +++ b/gen_headers/enums/effects_enums.def @@ -54,6 +54,7 @@ values NO_UNHAPPY "No_Unhappy" VETERAN_BUILD "Veteran_Build" VETERAN_COMBAT "Veteran_Combat" + VETERAN_WORK "Veteran_Work" HP_REGEN "HP_Regen" CITY_VISION_RADIUS_SQ "City_Vision_Radius_Sq" UNIT_VISION_RADIUS_SQ "Unit_Vision_Radius_Sq" diff --git a/server/unittools.c b/server/unittools.c index c833971129..b73edad322 100644 --- a/server/unittools.c +++ b/server/unittools.c @@ -262,7 +262,9 @@ static bool maybe_become_veteran_real(struct unit *punit, int base_chance, * of +50% the end chance is 75%. */ chance = vlevel->base_raise_chance * mod / 100; } else if (worker && unit_has_type_flag(punit, UTYF_WORKERS)) { - chance = base_chance * vlevel->work_raise_chance / 100; + int mod = base_chance + get_unit_bonus(punit, EFT_VETERAN_WORK); + + chance = vlevel->work_raise_chance * mod / 100; } else { /* No battle and no work done. */ return FALSE; -- 2.43.0