Core/Spells: Implemented optional power cost

Closes #18348
This commit is contained in:
joschiwald
2018-05-12 12:49:12 +02:00
parent 98eb06ac25
commit aed52529be
3 changed files with 15 additions and 2 deletions
@@ -132,7 +132,7 @@ enum AuraType : uint32
SPELL_AURA_MOD_PACIFY_SILENCE = 60,
SPELL_AURA_MOD_SCALE = 61,
SPELL_AURA_PERIODIC_HEALTH_FUNNEL = 62,
SPELL_AURA_MOD_ADDITIONAL_POWER_COST = 63, // NYI
SPELL_AURA_MOD_ADDITIONAL_POWER_COST = 63,
SPELL_AURA_PERIODIC_MANA_LEECH = 64,
SPELL_AURA_MOD_CASTING_SPEED_NOT_STACK = 65,
SPELL_AURA_FEIGN_DEATH = 66,
@@ -129,7 +129,7 @@ pAuraEffectHandler AuraEffectHandler[TOTAL_AURAS]=
&AuraEffect::HandleAuraModPacifyAndSilence, // 60 SPELL_AURA_MOD_PACIFY_SILENCE
&AuraEffect::HandleAuraModScale, // 61 SPELL_AURA_MOD_SCALE
&AuraEffect::HandleNoImmediateEffect, // 62 SPELL_AURA_PERIODIC_HEALTH_FUNNEL implemented in AuraEffect::PeriodicTick
&AuraEffect::HandleNULL, // 63 SPELL_AURA_MOD_ADDITIONAL_POWER_COST
&AuraEffect::HandleNoImmediateEffect, // 63 SPELL_AURA_MOD_ADDITIONAL_POWER_COST implemented in SpellInfo::CalcPowerCost
&AuraEffect::HandleNoImmediateEffect, // 64 SPELL_AURA_PERIODIC_MANA_LEECH implemented in AuraEffect::PeriodicTick
&AuraEffect::HandleModCastingSpeed, // 65 SPELL_AURA_MOD_CASTING_SPEED_NOT_STACK
&AuraEffect::HandleFeignDeath, // 66 SPELL_AURA_FEIGN_DEATH
+13
View File
@@ -3698,6 +3698,19 @@ std::vector<SpellPowerCost> 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<int32>(remainingPower, 0, optionalCost);
}
if (power->PowerType != POWER_HEALTH)
{
// Flat mod from caster auras by spell school and power type