Skip to content

Commit

Permalink
Fix [damage] weapon special produces unexpected damage values
Browse files Browse the repository at this point in the history
  • Loading branch information
newfrenchy83 committed Oct 17, 2024
1 parent 491c236 commit 9975316
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/units/abilities.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<int>((value_set + addition + substraction) * multiplier / divisor);
double temp_value = (value_set + addition + substraction) * multiplier / divisor;
composite_value_ = static_cast<int>(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_);
Expand Down

0 comments on commit 9975316

Please sign in to comment.