Core/Spells: Add Spell::HasPowerTypeCost to check which power types a spell uses

This commit is contained in:
Shauren
2021-03-04 21:23:06 +01:00
parent 36496c7172
commit 0960308cfc
2 changed files with 12 additions and 3 deletions

View File

@@ -4061,7 +4061,7 @@ void Spell::SendSpellStart()
&& std::find_if(m_powerCost.begin(), m_powerCost.end(), [](SpellPowerCost const& cost) { return cost.Power != POWER_HEALTH; }) != m_powerCost.end())
castFlags |= CAST_FLAG_POWER_LEFT_SELF;
if (std::find_if(m_powerCost.begin(), m_powerCost.end(), [](SpellPowerCost const& cost) { return cost.Power == POWER_RUNES; }) != m_powerCost.end())
if (HasPowerTypeCost(POWER_RUNES))
castFlags |= CAST_FLAG_NO_GCD; // not needed, but Blizzard sends it
WorldPackets::Spells::SpellStart packet;
@@ -4164,7 +4164,7 @@ void Spell::SendSpellGo()
if ((m_caster->GetTypeId() == TYPEID_PLAYER)
&& (m_caster->getClass() == CLASS_DEATH_KNIGHT)
&& std::find_if(m_powerCost.begin(), m_powerCost.end(), [](SpellPowerCost const& cost) { return cost.Power == POWER_RUNES; }) != m_powerCost.end()
&& HasPowerTypeCost(POWER_RUNES)
&& !(_triggeredCastFlags & TRIGGERED_IGNORE_POWER_AND_REAGENT_COST))
{
castFlags |= CAST_FLAG_NO_GCD; // not needed, but Blizzard sends it
@@ -6955,6 +6955,14 @@ void Spell::DelayedChannel()
SendChannelUpdate(m_timer);
}
bool Spell::HasPowerTypeCost(Powers power) const
{
return std::find_if(m_powerCost.cbegin(), m_powerCost.cend(), [power](SpellPowerCost const& cost)
{
return cost.Power == power;
}) != m_powerCost.cend();
}
bool Spell::UpdatePointers()
{
if (m_originalCasterGUID == m_caster->GetGUID())

View File

@@ -682,6 +682,7 @@ class TC_GAME_API Spell
SpellInfo const* GetSpellInfo() const { return m_spellInfo; }
Difficulty GetCastDifficulty() const;
std::vector<SpellPowerCost> const& GetPowerCost() const { return m_powerCost; }
bool HasPowerTypeCost(Powers power) const;
bool UpdatePointers(); // must be used at call Spell code after time delay (non triggered spell cast/update spell call/etc)
@@ -716,7 +717,7 @@ class TC_GAME_API Spell
SpellSchoolMask m_spellSchoolMask; // Spell school (can be overwrite for some spells (wand shoot for example)
WeaponAttackType m_attackType; // For weapon based attack
std::vector<SpellPowerCost> m_powerCost; // Calculated spell cost initialized only in Spell::prepare
std::vector<SpellPowerCost> m_powerCost; // Calculated spell cost initialized only in Spell::prepare
int32 m_casttime; // Calculated spell cast time initialized only in Spell::prepare
int32 m_channeledDuration; // Calculated channeled spell duration in order to calculate correct pushback.
bool m_canReflect; // can reflect this spell?