Core/Hunters: Fixed focus power for pets.

Closes #8553.
This commit is contained in:
Warpten committed 2013-02-01 19:56:02 +01:00
1 parent 8350c088c7
commit 0b72a91e76
3 files changed
+24 -10

No files matched your search

+4 -4
View File
@@ -2525,7 +2525,7 @@ void Player::Regenerate(Powers power)
return;
// Skip regeneration for power type we cannot have
uint32 powerIndex = GetPowerIndexByClass(power, getClass());
uint32 powerIndex = GetPowerIndex(power);
if (powerIndex == MAX_POWERS)
return;
@@ -17343,7 +17343,7 @@ bool Player::LoadFromDB(uint32 guid, SQLQueryHolder *holder)
uint32 loadedPowers = 0;
for (uint32 i = 0; i < MAX_POWERS; ++i)
{
if (GetPowerIndexByClass(Powers(i), getClass()) != MAX_POWERS)
if (GetPowerIndex(i) != MAX_POWERS)
{
uint32 savedPower = fields[47+loadedPowers].GetUInt32();
uint32 maxPower = GetUInt32Value(UNIT_FIELD_MAXPOWER1 + loadedPowers);
@@ -18937,7 +18937,7 @@ void Player::SaveToDB(bool create /*=false*/)
uint32 storedPowers = 0;
for (uint32 i = 0; i < MAX_POWERS; ++i)
{
if (GetPowerIndexByClass(Powers(i), getClass()) != MAX_POWERS)
if (GetPowerIndex(i) != MAX_POWERS)
{
stmt->setUInt32(index++, GetUInt32Value(UNIT_FIELD_POWER1 + storedPowers));
if (++storedPowers >= MAX_POWERS_PER_CLASS)
@@ -19057,7 +19057,7 @@ void Player::SaveToDB(bool create /*=false*/)
uint32 storedPowers = 0;
for (uint32 i = 0; i < MAX_POWERS; ++i)
{
if (GetPowerIndexByClass(Powers(i), getClass()) != MAX_POWERS)
if (GetPowerIndex(i) != MAX_POWERS)
{
stmt->setUInt32(index++, GetUInt32Value(UNIT_FIELD_POWER1 + storedPowers));
if (++storedPowers >= MAX_POWERS_PER_CLASS)
+19 -6
View File
@@ -9224,7 +9224,7 @@ int32 Unit::SpellBaseDamageBonusDone(SpellSchoolMask schoolMask)
DoneAdvertisedBenefit += ToPlayer()->GetBaseSpellPowerBonus();
// Check if we are ever using mana - PaperDollFrame.lua
if (GetPowerIndexByClass(POWER_MANA, getClass()) != MAX_POWERS)
if (GetPowerIndex(POWER_MANA) != MAX_POWERS)
DoneAdvertisedBenefit += std::max(0, int32(GetStat(STAT_INTELLECT)) - 10); // spellpower from intellect
// Damage bonus from stats
@@ -9747,7 +9747,7 @@ int32 Unit::SpellBaseHealingBonusDone(SpellSchoolMask schoolMask)
AdvertisedBenefit += ToPlayer()->GetBaseSpellPowerBonus();
// Check if we are ever using mana - PaperDollFrame.lua
if (GetPowerIndexByClass(POWER_MANA, getClass()) != MAX_POWERS)
if (GetPowerIndex(POWER_MANA) != MAX_POWERS)
AdvertisedBenefit += std::max(0, int32(GetStat(STAT_INTELLECT)) - 10); // spellpower from intellect
// Healing bonus from stats
@@ -12364,7 +12364,7 @@ void Unit::SetMaxHealth(uint32 val)
int32 Unit::GetPower(Powers power) const
{
uint32 powerIndex = GetPowerIndexByClass(power, getClass());
uint32 powerIndex = GetPowerIndex(power);
if (powerIndex == MAX_POWERS)
return 0;
@@ -12373,7 +12373,7 @@ int32 Unit::GetPower(Powers power) const
int32 Unit::GetMaxPower(Powers power) const
{
uint32 powerIndex = GetPowerIndexByClass(power, getClass());
uint32 powerIndex = GetPowerIndex(power);
if (powerIndex == MAX_POWERS)
return 0;
@@ -12382,7 +12382,7 @@ int32 Unit::GetMaxPower(Powers power) const
void Unit::SetPower(Powers power, int32 val)
{
uint32 powerIndex = GetPowerIndexByClass(power, getClass());
uint32 powerIndex = GetPowerIndex(power);
if (powerIndex == MAX_POWERS)
return;
@@ -12421,7 +12421,7 @@ void Unit::SetPower(Powers power, int32 val)
void Unit::SetMaxPower(Powers power, int32 val)
{
uint32 powerIndex = GetPowerIndexByClass(power, getClass());
uint32 powerIndex = GetPowerIndex(power);
if (powerIndex == MAX_POWERS)
return;
@@ -12448,6 +12448,19 @@ void Unit::SetMaxPower(Powers power, int32 val)
SetPower(power, val);
}
uint32 Unit::GetPowerIndex(uint32 powerType) const
{
/// This is here because hunter pets are of the warrior class.
/// With the current implementation, the core only gives them
/// POWER_RAGE, so we enforce the class to hunter so that they
/// effectively get focus power.
uint32 classId = getClass();
if (ToPet() && ToPet()->getPetType() == HUNTER_PET)
classId = CLASS_HUNTER;
return GetPowerIndexByClass(powerType, classId);
}
int32 Unit::GetCreatePowers(Powers power) const
{
switch (power)
+1
View File
@@ -1877,6 +1877,7 @@ class Unit : public WorldObject
uint32 GetCreateHealth() const { return GetUInt32Value(UNIT_FIELD_BASE_HEALTH); }
void SetCreateMana(uint32 val) { SetUInt32Value(UNIT_FIELD_BASE_MANA, val); }
uint32 GetCreateMana() const { return GetUInt32Value(UNIT_FIELD_BASE_MANA); }
uint32 GetPowerIndex(uint32 powerType) const;
int32 GetCreatePowers(Powers power) const;
float GetPosStat(Stats stat) const { return GetFloatValue(UNIT_FIELD_POSSTAT0+stat); }
float GetNegStat(Stats stat) const { return GetFloatValue(UNIT_FIELD_NEGSTAT0+stat); }