From 9975316f6c838212ec0ec1fbb4bec2b12445c54d Mon Sep 17 00:00:00 2001 From: newfrenchy83 Date: Thu, 17 Oct 2024 18:29:13 +0200 Subject: [PATCH] Fix [damage] weapon special produces unexpected damage values Fix https://github.com/wesnoth/wesnoth/issues/9467 --- src/units/abilities.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/units/abilities.cpp b/src/units/abilities.cpp index dd2806fa16aed..c88993dac62e0 100644 --- a/src/units/abilities.cpp +++ b/src/units/abilities.cpp @@ -2474,7 +2474,9 @@ effect::effect(const unit_ability_list& list, int def, const_attack_ptr att, EFF effect_list_.push_back(val.second); } - composite_value_ = static_cast((value_set + addition + substraction) * multiplier / divisor); + double temp_value = (value_set + addition + substraction) * multiplier / divisor; + composite_value_ = static_cast(temp_value); + composite_value_ = ((temp_value - composite_value_) >= 0.5) ? std::round(temp_value) : composite_value_; //clamp what if min_value < max_value or one attribute only used. if(max_value && min_value && *min_value < *max_value) { composite_value_ = std::clamp(*min_value, *max_value, composite_value_);