aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorOvahlord <dreadkiller@gmx.de>2025-01-11 22:19:24 +0100
committerOvahlord <dreadkiller@gmx.de>2025-01-12 01:12:53 +0100
commitefb8ccc07922c97fa44911a5176d8dc7d721b6ff (patch)
treef84d7c290de0b3dd803dae9e8d2107eaf3d2e0b1 /src
parenta8ceccebf9ce26ed501002bf0213d7f58f187ef7 (diff)
Core/Spells: reduce differences between branches
(cherry picked from commit 9b385282df40eef9370ae21e52a1b11e45bf9ab9)
Diffstat (limited to 'src')
-rw-r--r--src/server/game/Spells/Spell.cpp53
1 files changed, 23 insertions, 30 deletions
diff --git a/src/server/game/Spells/Spell.cpp b/src/server/game/Spells/Spell.cpp
index df5f8b7765a..b79a5ad6b13 100644
--- a/src/server/game/Spells/Spell.cpp
+++ b/src/server/game/Spells/Spell.cpp
@@ -5425,35 +5425,34 @@ void Spell::TakePower()
return;
}
- for (SpellPowerCost& cost : m_powerCost)
+ bool hit = true;
+ if (unitCaster->GetTypeId() == TYPEID_PLAYER)
{
- Powers powerType = Powers(cost.Power);
- bool hit = true;
- if (unitCaster->GetTypeId() == TYPEID_PLAYER)
+ if (m_spellInfo->HasAttribute(SPELL_ATTR1_DISCOUNT_POWER_ON_MISS))
{
- if (m_spellInfo->HasAttribute(SPELL_ATTR1_DISCOUNT_POWER_ON_MISS))
- {
- ObjectGuid targetGUID = m_targets.GetUnitTargetGUID();
- if (!targetGUID.IsEmpty())
- {
- auto ihit = std::find_if(std::begin(m_UniqueTargetInfo), std::end(m_UniqueTargetInfo), [&](TargetInfo const& targetInfo) { return targetInfo.TargetGUID == targetGUID && targetInfo.MissCondition != SPELL_MISS_NONE; });
- if (ihit != std::end(m_UniqueTargetInfo))
- {
- hit = false;
- //lower spell cost on fail (by talent aura)
- if (Player* modOwner = unitCaster->GetSpellModOwner())
- modOwner->ApplySpellMod(m_spellInfo, SpellModOp::PowerCostOnMiss, cost.Amount);
+ ObjectGuid targetGUID = m_targets.GetUnitTargetGUID();
+ if (!targetGUID.IsEmpty())
+ hit = std::ranges::any_of(m_UniqueTargetInfo, [&](TargetInfo const& targetInfo) { return targetInfo.TargetGUID == targetGUID && targetInfo.MissCondition == SPELL_MISS_NONE; });
- if (m_spendComboPoints)
- m_spentComboPoints = 0;
- }
- }
- }
+ if (m_spendComboPoints)
+ m_spentComboPoints = 0;
}
+ }
- if (powerType == POWER_RUNE_BLOOD || powerType == POWER_RUNE_FROST || powerType == POWER_RUNE_UNHOLY)
+ bool hasTakenRunePower = false;
+ for (SpellPowerCost& cost : m_powerCost)
+ {
+ if (!hit)
+ {
+ //lower spell cost on fail (by talent aura)
+ if (Player* modOwner = unitCaster->GetSpellModOwner())
+ modOwner->ApplySpellMod(m_spellInfo, SpellModOp::PowerCostOnMiss, cost.Amount);
+ }
+
+ if ((cost.Power == POWER_RUNE_BLOOD || cost.Power == POWER_RUNE_FROST || cost.Power == POWER_RUNE_UNHOLY) && !hasTakenRunePower)
{
TakeRunePower(hit);
+ hasTakenRunePower = true;
continue;
}
@@ -5461,19 +5460,13 @@ void Spell::TakePower()
continue;
// health as power used
- if (powerType == POWER_HEALTH)
+ if (cost.Power == POWER_HEALTH)
{
unitCaster->ModifyHealth(-cost.Amount);
continue;
}
- if (powerType >= MAX_POWERS)
- {
- TC_LOG_ERROR("spells", "Spell::TakePower: Unknown power type '{}'", powerType);
- continue;
- }
-
- unitCaster->ModifyPower(powerType, -cost.Amount);
+ unitCaster->ModifyPower(cost.Power, -cost.Amount);
}
if (m_spendComboPoints && m_spentComboPoints)