diff options
author | Shauren <shauren.trinity@gmail.com> | 2021-03-04 21:23:06 +0100 |
---|---|---|
committer | Shauren <shauren.trinity@gmail.com> | 2021-03-04 22:46:44 +0100 |
commit | 0960308cfcfab740456b070901bed92b4d6fb4a7 (patch) | |
tree | 1305b5a87cde5e964ece589d4984ca65d8180715 | |
parent | 36496c717203fab56eadff8c55f3b1e136fbe363 (diff) |
Core/Spells: Add Spell::HasPowerTypeCost to check which power types a spell uses
-rw-r--r-- | src/server/game/Spells/Spell.cpp | 12 | ||||
-rw-r--r-- | src/server/game/Spells/Spell.h | 3 |
2 files changed, 12 insertions, 3 deletions
diff --git a/src/server/game/Spells/Spell.cpp b/src/server/game/Spells/Spell.cpp index b8edc68b9b3..4ad47040980 100644 --- a/src/server/game/Spells/Spell.cpp +++ b/src/server/game/Spells/Spell.cpp @@ -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()) diff --git a/src/server/game/Spells/Spell.h b/src/server/game/Spells/Spell.h index 71838498351..de5e6c72f7f 100644 --- a/src/server/game/Spells/Spell.h +++ b/src/server/game/Spells/Spell.h @@ -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? |