Core/Creatures: port power type updates from master branch

Core/Misc: Added helper function Unit::SetFullPower
Cherry-picked from 8199eef81c

Core/Creatures: Updated power type handling (#20981)
Cherry-picked from 16a7a414ab
This commit is contained in:
ariel-
2018-03-07 03:32:32 -03:00
parent 68dde9f8c5
commit 6e0b9a7916
37 changed files with 205 additions and 204 deletions
+9 -3
View File
@@ -326,7 +326,7 @@ void Player::UpdateMaxPower(Powers power)
value += GetFlatModifierValue(unitMod, TOTAL_VALUE) + bonusPower;
value *= GetPctModifierValue(unitMod, TOTAL_PCT);
SetMaxPower(power, uint32(value));
SetMaxPower(power, uint32(std::lroundf(value)));
}
void Player::ApplyFeralAPBonus(int32 amount, bool apply)
@@ -1029,8 +1029,12 @@ void Creature::UpdateMaxPower(Powers power)
{
UnitMods unitMod = UnitMods(UNIT_MOD_POWER_START + power);
float value = GetTotalAuraModValue(unitMod);
SetMaxPower(power, uint32(value));
float value = GetFlatModifierValue(unitMod, BASE_VALUE) + GetCreatePowers(power);
value *= GetPctModifierValue(unitMod, BASE_PCT);
value += GetFlatModifierValue(unitMod, TOTAL_VALUE);
value *= GetPctModifierValue(unitMod, TOTAL_PCT);
SetMaxPower(power, uint32(std::lroundf(value)));
}
void Creature::UpdateAttackPowerAndDamage(bool ranged)
@@ -1237,6 +1241,8 @@ bool Guardian::UpdateStats(Stats stat)
bool Guardian::UpdateAllStats()
{
UpdateMaxHealth();
for (uint8 i = STAT_STRENGTH; i < MAX_STATS; ++i)
UpdateStats(Stats(i));