fixed bug where damage done can be calculated wrongly

This commit is contained in:
Dave White 2003-11-11 21:49:22 +00:00
parent 0dc4977735
commit 106a75f1ed
2 changed files with 4 additions and 8 deletions

View file

@ -278,13 +278,11 @@ battle_stats evaluate_battle_stats(
if(res.chance_to_hit_defender < 0.6 && attack.special() == marksman_string)
res.chance_to_hit_defender = 0.6;
res.damage_defender_takes = int(
res.damage_defender_takes = int(util::round(
double(d->second.damage_against(attack))
* combat_modifier(state,units,a->first,a->second.type().alignment()))
* combat_modifier(state,units,a->first,a->second.type().alignment())))
* (charge ? 2 : 1) * (backstab ? 2 : 1);
std::cerr << "damage defender takes: " << double(d->second.damage_against(attack)) << "*" <<combat_modifier(state,units,a->first,a->second.type().alignment()) << "*" << (charge ? 2:1) << " = " << res.damage_defender_takes << "\n";
if(under_leadership(units,attacker))
res.damage_defender_takes += res.damage_defender_takes/8 + 1;

View file

@ -298,10 +298,8 @@ int unit_movement_type::damage_against(const attack_type& attack) const
const std::string& val = (*resistance)[attack.type()];
const double resist = atof(val.c_str());
const int res = static_cast<int>(resist * static_cast<double>(attack.damage()));
std::cerr << "damage_against: " << resist << "*"
<< attack.damage() << "=" << res << "\n";
return res;
return static_cast<int>(
util::round(resist * static_cast<double>(attack.damage())));
}
const string_map& unit_movement_type::damage_table() const