From aed52529bec72262f448df89d1932b9040635c6c Mon Sep 17 00:00:00 2001 From: joschiwald Date: Sat, 12 May 2018 11:42:38 +0200 Subject: Core/Spells: Implemented optional power cost Closes #18348 --- src/server/game/Spells/SpellInfo.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/server/game/Spells/SpellInfo.cpp') diff --git a/src/server/game/Spells/SpellInfo.cpp b/src/server/game/Spells/SpellInfo.cpp index 958bcc82f16..d1dfa32f7cb 100644 --- a/src/server/game/Spells/SpellInfo.cpp +++ b/src/server/game/Spells/SpellInfo.cpp @@ -3698,6 +3698,19 @@ std::vector SpellInfo::CalcPowerCost(Unit const* caster, SpellSc if (power->PowerCostMaxPct) healthCost += int32(CalculatePct(caster->GetMaxHealth(), power->PowerCostMaxPct)); + int32 optionalCost = int32(power->OptionalCost); + optionalCost += caster->GetTotalAuraModifier(SPELL_AURA_MOD_ADDITIONAL_POWER_COST, [this, power](AuraEffect const* aurEff) -> bool + { + return aurEff->GetMiscValue() == power->PowerType + && aurEff->IsAffectingSpell(this); + }); + + if (optionalCost) + { + int32 remainingPower = caster->GetPower(Powers(power->PowerType)) - powerCost; + powerCost += RoundToInterval(remainingPower, 0, optionalCost); + } + if (power->PowerType != POWER_HEALTH) { // Flat mod from caster auras by spell school and power type -- cgit v1.2.3