Merge pull request #960 from noudess/patch-6

Further refine monk weight checks for floating point
This commit is contained in:
Michael Cook (mackal) 2020-01-30 15:41:25 -05:00 committed by GitHub
commit 6dee837f67
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -726,18 +726,18 @@ int Mob::GetClassRaceACBonus()
} }
int weight = IsClient() ? CastToClient()->CalcCurrentWeight()/10 : 0; int weight = IsClient() ? CastToClient()->CalcCurrentWeight()/10 : 0;
if (weight < hardcap - 1) { if (weight < hardcap - 1) {
int temp = level + 5; double temp = level + 5;
if (weight > softcap) { if (weight > softcap) {
double redux = (weight - softcap) * 6.66667; double redux = static_cast<double>(weight - softcap) * 6.66667;
redux = (100.0 - std::min(100.0, redux)) * 0.01; redux = (100.0 - std::min(100.0, redux)) * 0.01;
temp = std::max(0, static_cast<int>(temp * redux)); temp = std::max(0.0, temp * redux);
} }
ac_bonus = (4 * temp) / 3; ac_bonus = static_cast<int>((4.0 * temp) / 3.0);
} }
else if (weight > hardcap + 1) { else if (weight > hardcap + 1) {
int temp = level + 5; double temp = level + 5;
double multiplier = std::min(1.0, (weight - (hardcap - 10.0)) / 100.0); double multiplier = std::min(1.0, (weight - (static_cast<double>(hardcap) - 10.0)) / 100.0);
temp = (4 * temp) / 3; temp = (4.0 * temp) / 3.0;
ac_bonus -= static_cast<int>(temp * multiplier); ac_bonus -= static_cast<int>(temp * multiplier);
} }
} }