diff options
author | Warpten <vertozor@gmail.com> | 2013-02-01 19:55:23 +0100 |
---|---|---|
committer | Warpten <vertozor@gmail.com> | 2013-02-01 19:56:02 +0100 |
commit | 0b72a91e7667943dd128ca28f5bb71d8457d3ec9 (patch) | |
tree | fe48158f5a8ed26bc6ba9e09b1a32e3018bbec39 | |
parent | 8350c088c74aae94ec43ef5b51dc43a7f441e2d1 (diff) |
Core/Hunters: Fixed focus power for pets.
Closes #8553.
-rw-r--r-- | src/server/game/Entities/Player/Player.cpp | 8 | ||||
-rw-r--r-- | src/server/game/Entities/Unit/Unit.cpp | 25 | ||||
-rw-r--r-- | src/server/game/Entities/Unit/Unit.h | 1 |
3 files changed, 24 insertions, 10 deletions
diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp index 67dc948ed99..41142e2de27 100644 --- a/src/server/game/Entities/Player/Player.cpp +++ b/src/server/game/Entities/Player/Player.cpp @@ -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) diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index 32ade87fef4..2db63040e83 100644 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -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) diff --git a/src/server/game/Entities/Unit/Unit.h b/src/server/game/Entities/Unit/Unit.h index b723be7bee7..a8e088b2dd3 100644 --- a/src/server/game/Entities/Unit/Unit.h +++ b/src/server/game/Entities/Unit/Unit.h @@ -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); } |