Core/Auras: implement mana cost modification aura

Port From (https://github.com/TrinityCore/TrinityCore/commit/a76c08843fc1695241b7246c4014322ee07a6453)
This commit is contained in:
hondacrx
2021-02-22 16:06:13 -05:00
parent e74d30024f
commit f25af46c8f
4 changed files with 15 additions and 5 deletions
@@ -444,7 +444,7 @@ namespace Framework.Constants
ModBattlePetXpPct = 420,
ModAbsorbEffectsDonePct = 421, // NYI
ModAbsorbEffectsTakenPct = 422, //NYI
Unk423 = 423,
ModManaCostPct = 423,
CasterIgnoreLos = 424, //NYI
Unk425 = 425,
Unk426 = 426,
+2
View File
@@ -932,6 +932,8 @@ namespace Game.Entities
return Math.Max(resistMech, 0);
}
public void ApplyModManaCostMultiplier(float manaCostMultiplier, bool apply) { ApplyModUpdateFieldValue(m_values.ModifyValue(m_unitData).ModifyValue(m_unitData.ManaCostMultiplier), manaCostMultiplier, apply); }
public void ApplyModManaCostModifier(SpellSchools school, int mod, bool apply) { ApplyModUpdateFieldValue(ref m_values.ModifyValue(m_unitData).ModifyValue(m_unitData.ManaCostModifier, (int)school), mod, apply); }
}
+9
View File
@@ -3461,6 +3461,15 @@ namespace Game.Spells
}
}
[AuraEffectHandler(AuraType.ModManaCostPct)]
void HandleModManaCostPct(AuraApplication aurApp, AuraEffectHandleModes mode, bool apply)
{
if (!mode.HasAnyFlag(AuraEffectHandleModes.ChangeAmountMask | AuraEffectHandleModes.Stat))
return;
aurApp.GetTarget().ApplyModManaCostMultiplier(GetAmount() / 100.0f, apply);
}
[AuraEffectHandler(AuraType.ModPowerDisplay)]
void HandleAuraModPowerDisplay(AuraApplication aurApp, AuraEffectHandleModes mode, bool apply)
{
+3 -4
View File
@@ -2773,9 +2773,6 @@ namespace Game.Spells
flatMod += eff.GetAmount();
}
if (power.PowerType == PowerType.Mana)
flatMod *= (int)(1.0f + caster.m_unitData.ManaCostMultiplier); // this is wrong
powerCost += flatMod;
}
@@ -2842,7 +2839,9 @@ namespace Game.Spells
powerCost += MathFunctions.CalculatePct(powerCost, eff.GetAmount());
}
if (power.PowerType == PowerType.Health)
if (power.PowerType == PowerType.Mana)
powerCost = (int)((float)powerCost * (1.0f + caster.m_unitData.ManaCostMultiplier));
else if (power.PowerType == PowerType.Health)
{
healthCost += powerCost;
continue;