From 1f591c97dcbd2c6d39b08c970514e8d2277370f0 Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Sun, 27 Mar 2022 06:50:39 +0300 Subject: [PATCH 41/41] Unhardcode minimum HP unit gets in a city by new "Min_HP_Pct" effect Requested by Ihnatus See osdn #42699 Signed-off-by: Marko Lindqvist --- ai/default/daieffects.c | 7 +++++++ common/effects.h | 18 ++++++++++-------- common/unit.c | 6 +++--- data/alien/effects.ruleset | 8 ++++++++ data/civ1/effects.ruleset | 8 ++++++++ data/civ2/effects.ruleset | 8 ++++++++ data/civ2civ3/effects.ruleset | 8 ++++++++ data/classic/effects.ruleset | 8 ++++++++ data/goldkeep/effects.ruleset | 8 ++++++++ data/multiplayer/effects.ruleset | 8 ++++++++ data/sandbox/effects.ruleset | 8 ++++++++ data/webperimental/effects.ruleset | 8 ++++++++ doc/README.effects | 5 +++++ fc_version | 2 +- 14 files changed, 98 insertions(+), 12 deletions(-) diff --git a/ai/default/daieffects.c b/ai/default/daieffects.c index 20992967e0..27a36bfd21 100644 --- a/ai/default/daieffects.c +++ b/ai/default/daieffects.c @@ -429,6 +429,13 @@ adv_want dai_effect_value(struct player *pplayer, struct government *gov, num = num_affected_units(peffect, adv); v += (5 * c + num); break; + case EFT_MIN_HP_PCT: + num = num_affected_units(peffect, adv); + /* Lesser value than EFT_HP_REGEN as this does not add health + * with full effect value, but only up to the effect value. + * Only badly wounded units affected at all. */ + v += (3 * c + num); + break; case EFT_VETERAN_COMBAT: num = num_affected_units(peffect, adv); v += (2 * c + num); diff --git a/common/effects.h b/common/effects.h index c5788b71bf..71a263e699 100644 --- a/common/effects.h +++ b/common/effects.h @@ -324,15 +324,17 @@ extern "C" { #define SPECENUM_VALUE130NAME "Action_Resist_Pct" #define SPECENUM_VALUE131 EFT_OUTPUT_BONUS_ABSOLUTE #define SPECENUM_VALUE131NAME "Output_Bonus_Absolute" +#define SPECENUM_VALUE132 EFT_MIN_HP_PCT +#define SPECENUM_VALUE132NAME "Min_HP_Pct" /* Ruleset specific effects for use from Lua scripts */ -#define SPECENUM_VALUE132 EFT_USER_EFFECT_1 -#define SPECENUM_VALUE132NAME "User_Effect_1" -#define SPECENUM_VALUE133 EFT_USER_EFFECT_2 -#define SPECENUM_VALUE133NAME "User_Effect_2" -#define SPECENUM_VALUE134 EFT_USER_EFFECT_3 -#define SPECENUM_VALUE134NAME "User_Effect_3" -#define SPECENUM_VALUE135 EFT_USER_EFFECT_4 -#define SPECENUM_VALUE135NAME "User_Effect_4" +#define SPECENUM_VALUE133 EFT_USER_EFFECT_1 +#define SPECENUM_VALUE133NAME "User_Effect_1" +#define SPECENUM_VALUE134 EFT_USER_EFFECT_2 +#define SPECENUM_VALUE134NAME "User_Effect_2" +#define SPECENUM_VALUE135 EFT_USER_EFFECT_3 +#define SPECENUM_VALUE135NAME "User_Effect_3" +#define SPECENUM_VALUE136 EFT_USER_EFFECT_4 +#define SPECENUM_VALUE136NAME "User_Effect_4" /* keep this last */ #define SPECENUM_COUNT EFT_COUNT #include "specenum_gen.h" diff --git a/common/unit.c b/common/unit.c index eb53f5dd94..6d7b37eaf1 100644 --- a/common/unit.c +++ b/common/unit.c @@ -2068,13 +2068,13 @@ int hp_gain_coord(struct unit *punit) { int hp = 0; const int base = unit_type_get(punit)->hp; + int min = base * get_unit_bonus(punit, EFT_MIN_HP_PCT) / 100; /* Includes barracks (100%), fortress (25%), etc. */ hp += base * get_unit_bonus(punit, EFT_HP_REGEN) / 100; - if (tile_city(unit_tile(punit))) { - hp = MAX(hp, base / 3); - } + /* Minimum HP after regen effects applied. */ + hp = MAX(hp, min); if (!unit_class_get(punit)->hp_loss_pct) { hp += (base + 9) / 10; diff --git a/data/alien/effects.ruleset b/data/alien/effects.ruleset index 70eedda4e7..cb7b6db73c 100644 --- a/data/alien/effects.ruleset +++ b/data/alien/effects.ruleset @@ -1087,6 +1087,14 @@ reqs = "UnitFlag", "Cant_Fortify", "Local", FALSE } +[effect_city_min_hp] +type = "Min_HP_Pct" +value = 33 +reqs = + { "type", "name", "range" + "CityTile", "Center", "Tile" + } + [effect_action_success_move_cost_from_non_native] type = "Action_Success_Actor_Move_Cost" value = 65535 diff --git a/data/civ1/effects.ruleset b/data/civ1/effects.ruleset index cf27cbde68..306721b644 100644 --- a/data/civ1/effects.ruleset +++ b/data/civ1/effects.ruleset @@ -1356,6 +1356,14 @@ reqs = "UnitFlag", "Cant_Fortify", "Local", FALSE } +[effect_city_min_hp] +type = "Min_HP_Pct" +value = 33 +reqs = + { "type", "name", "range" + "CityTile", "Center", "Tile" + } + [effect_incite_cost_empty] type = "Incite_Cost_Pct" value = -50 diff --git a/data/civ2/effects.ruleset b/data/civ2/effects.ruleset index b5c9a4f021..78e66f4a12 100644 --- a/data/civ2/effects.ruleset +++ b/data/civ2/effects.ruleset @@ -1207,6 +1207,14 @@ reqs = "UnitFlag", "Cant_Fortify", "Local", FALSE } +[effect_city_min_hp] +type = "Min_HP_Pct" +value = 33 +reqs = + { "type", "name", "range" + "CityTile", "Center", "Tile" + } + [effect_incite_cost_empty] type = "Incite_Cost_Pct" value = -50 diff --git a/data/civ2civ3/effects.ruleset b/data/civ2civ3/effects.ruleset index 01116d11d9..d1d4ade376 100644 --- a/data/civ2civ3/effects.ruleset +++ b/data/civ2civ3/effects.ruleset @@ -374,6 +374,14 @@ reqs = "UnitFlag", "Cant_Fortify", "Local", FALSE } +[effect_city_min_hp] +type = "Min_HP_Pct" +value = 33 +reqs = + { "type", "name", "range" + "CityTile", "Center", "Tile" + } + [effect_trade_routes] type = "Max_Trade_Routes" value = 2 diff --git a/data/classic/effects.ruleset b/data/classic/effects.ruleset index a9fb06eb2c..40c83a53dc 100644 --- a/data/classic/effects.ruleset +++ b/data/classic/effects.ruleset @@ -147,6 +147,14 @@ reqs = "UnitFlag", "Cant_Fortify", "Local", FALSE } +[effect_city_min_hp] +type = "Min_HP_Pct" +value = 33 +reqs = + { "type", "name", "range" + "CityTile", "Center", "Tile" + } + ; Base vision range - radius of vision is sqrt(5) = 2.24 [effect_city_vision] type = "City_Vision_Radius_Sq" diff --git a/data/goldkeep/effects.ruleset b/data/goldkeep/effects.ruleset index 4ac372e47e..7f36a7c8d4 100644 --- a/data/goldkeep/effects.ruleset +++ b/data/goldkeep/effects.ruleset @@ -170,6 +170,14 @@ reqs = "UnitFlag", "Cant_Fortify", "Local", FALSE } +[effect_city_min_hp] +type = "Min_HP_Pct" +value = 33 +reqs = + { "type", "name", "range" + "CityTile", "Center", "Tile" + } + ; Nuclear power gives +1 moves to sea units [effect_nuclear_powered_boats] type = "Move_Bonus" diff --git a/data/multiplayer/effects.ruleset b/data/multiplayer/effects.ruleset index 0a047c1987..11376f2f7d 100644 --- a/data/multiplayer/effects.ruleset +++ b/data/multiplayer/effects.ruleset @@ -147,6 +147,14 @@ reqs = "UnitFlag", "Cant_Fortify", "Local", FALSE } +[effect_city_min_hp] +type = "Min_HP_Pct" +value = 33 +reqs = + { "type", "name", "range" + "CityTile", "Center", "Tile" + } + ; Base vision range - radius of vision is sqrt(5) = 2.24 [effect_city_vision] type = "City_Vision_Radius_Sq" diff --git a/data/sandbox/effects.ruleset b/data/sandbox/effects.ruleset index 92c2743e32..3b16614ccc 100644 --- a/data/sandbox/effects.ruleset +++ b/data/sandbox/effects.ruleset @@ -374,6 +374,14 @@ reqs = "UnitFlag", "Cant_Fortify", "Local", FALSE } +[effect_city_min_hp] +type = "Min_HP_Pct" +value = 33 +reqs = + { "type", "name", "range" + "CityTile", "Center", "Tile" + } + [effect_trade_routes] type = "Max_Trade_Routes" value = 2 diff --git a/data/webperimental/effects.ruleset b/data/webperimental/effects.ruleset index 1f3d70da98..df6d036e6a 100644 --- a/data/webperimental/effects.ruleset +++ b/data/webperimental/effects.ruleset @@ -147,6 +147,14 @@ reqs = "UnitFlag", "Cant_Fortify", "Local", FALSE } +[effect_city_min_hp] +type = "Min_HP_Pct" +value = 33 +reqs = + { "type", "name", "range" + "CityTile", "Center", "Tile" + } + ; Base vision range - radius of vision is sqrt(5) = 2.24 [effect_city_vision] type = "City_Vision_Radius_Sq" diff --git a/doc/README.effects b/doc/README.effects index 65928ca44f..a63e403862 100644 --- a/doc/README.effects +++ b/doc/README.effects @@ -424,6 +424,11 @@ Migration_Pct Increase the calculated migration score for the a city by amount in percent. +Min_HP_Pct + The minimum HP (pct from full) units that have not moved during + previous turn will have in the beginning of the new turn, + after the HP_Regen effects have been applied. + Mining_Pct The tile gets value % of its terrain's mining_shield_incr bonus. (This is how mine-like extras have an effect.) diff --git a/fc_version b/fc_version index d287352789..fcf3bc6da4 100755 --- a/fc_version +++ b/fc_version @@ -56,7 +56,7 @@ DEFAULT_FOLLOW_TAG=S3_2 # - No new mandatory capabilities can be added to the release branch; doing # so would break network capability of supposedly "compatible" releases. # -NETWORK_CAPSTRING="+Freeciv.Devel-3.2-2022.Mar.15" +NETWORK_CAPSTRING="+Freeciv.Devel-3.2-2022.Mar.27" FREECIV_DISTRIBUTOR="" -- 2.35.1