Core/Units: ported power type updates from master branch
This commit is contained in:
1 parent
e67167e8cf
commit
b653f2f819
40 files changed
+259
-278
No files matched your search
@@ -306,8 +306,17 @@ void Player::UpdateMaxHealth()
|
||||
SetMaxHealth((uint32)value);
|
||||
}
|
||||
|
||||
uint32 Player::GetPowerIndex(Powers power) const
|
||||
{
|
||||
return sDBCManager.GetPowerIndexByClass(power, getClass());
|
||||
}
|
||||
|
||||
void Player::UpdateMaxPower(Powers power)
|
||||
{
|
||||
uint32 powerIndex = GetPowerIndex(power);
|
||||
if (powerIndex == MAX_POWERS || powerIndex >= MAX_POWERS_PER_CLASS)
|
||||
return;
|
||||
|
||||
UnitMods unitMod = UnitMods(UNIT_MOD_POWER_START + power);
|
||||
|
||||
float bonusPower = (power == POWER_MANA && GetCreatePowers(power) > 0) ? GetManaBonusFromIntellect() : 0;
|
||||
@@ -317,7 +326,7 @@ void Player::UpdateMaxPower(Powers power)
|
||||
value += GetModifierValue(unitMod, TOTAL_VALUE) + bonusPower;
|
||||
value *= GetModifierValue(unitMod, TOTAL_PCT);
|
||||
|
||||
SetMaxPower(power, uint32(value));
|
||||
SetMaxPower(power, (int32)std::lroundf(value));
|
||||
}
|
||||
|
||||
void Player::UpdateAttackPowerAndDamage(bool ranged)
|
||||
@@ -880,12 +889,28 @@ void Creature::UpdateMaxHealth()
|
||||
SetMaxHealth(uint32(value));
|
||||
}
|
||||
|
||||
uint32 Creature::GetPowerIndex(Powers power) const
|
||||
{
|
||||
if (power == GetPowerType())
|
||||
return 0;
|
||||
if (power == POWER_ALTERNATE_POWER)
|
||||
return 1;
|
||||
return MAX_POWERS;
|
||||
}
|
||||
|
||||
void Creature::UpdateMaxPower(Powers power)
|
||||
{
|
||||
if (GetPowerIndex(power) == MAX_POWERS)
|
||||
return;
|
||||
|
||||
UnitMods unitMod = UnitMods(UNIT_MOD_POWER_START + power);
|
||||
|
||||
float value = GetTotalAuraModValue(unitMod);
|
||||
SetMaxPower(power, uint32(value));
|
||||
float value = GetModifierValue(unitMod, BASE_VALUE) + GetCreatePowers(power);
|
||||
value *= GetModifierValue(unitMod, BASE_PCT);
|
||||
value += GetModifierValue(unitMod, TOTAL_VALUE);
|
||||
value *= GetModifierValue(unitMod, TOTAL_PCT);
|
||||
|
||||
SetMaxPower(power, uint32(std::lroundf(value)));
|
||||
}
|
||||
|
||||
void Creature::UpdateAttackPowerAndDamage(bool ranged)
|
||||
@@ -1018,6 +1043,8 @@ bool Guardian::UpdateStats(Stats stat)
|
||||
|
||||
bool Guardian::UpdateAllStats()
|
||||
{
|
||||
UpdateMaxHealth();
|
||||
|
||||
for (uint8 i = STAT_STRENGTH; i < MAX_STATS; ++i)
|
||||
UpdateStats(Stats(i));
|
||||
|
||||
@@ -1069,6 +1096,9 @@ void Guardian::UpdateMaxHealth()
|
||||
|
||||
void Guardian::UpdateMaxPower(Powers power)
|
||||
{
|
||||
if (GetPowerIndex(power) == MAX_POWERS)
|
||||
return;
|
||||
|
||||
UnitMods unitMod = UnitMods(UNIT_MOD_POWER_START + power);
|
||||
|
||||
float addValue = (power == POWER_MANA) ? GetStat(STAT_INTELLECT) - GetCreateStat(STAT_INTELLECT) : 0.0f;
|
||||
@@ -1079,7 +1109,7 @@ void Guardian::UpdateMaxPower(Powers power)
|
||||
value += GetModifierValue(unitMod, TOTAL_VALUE) + addValue * multiplicator;
|
||||
value *= GetModifierValue(unitMod, TOTAL_PCT);
|
||||
|
||||
SetMaxPower(power, uint32(value));
|
||||
SetMaxPower(power, int32(value));
|
||||
}
|
||||
|
||||
void Guardian::UpdateAttackPowerAndDamage(bool ranged)
|
||||
|
||||
Reference in new issue
Block a user