diff --git a/Source/Framework/Constants/Spells/SpellAuraConst.cs b/Source/Framework/Constants/Spells/SpellAuraConst.cs index 3056e0d42..a4f61d5a5 100644 --- a/Source/Framework/Constants/Spells/SpellAuraConst.cs +++ b/Source/Framework/Constants/Spells/SpellAuraConst.cs @@ -199,7 +199,7 @@ namespace Framework.Constants ModSpellHealingOfStatPercent = 175, SpiritOfRedemption = 176, AoeCharm = 177, - ModMaxPowerPct = 178, // NYI + ModMaxPowerPct = 178, ModPowerDisplay = 179, ModFlatSpellDamageVersus = 180, Unk181 = 181, // Old ModFlatSpellCritDamageVersus - Possible Flat Spell Crit Damage Versus diff --git a/Source/Game/Spells/Auras/AuraEffect.cs b/Source/Game/Spells/Auras/AuraEffect.cs index 9a1d3dd39..c1307612f 100644 --- a/Source/Game/Spells/Auras/AuraEffect.cs +++ b/Source/Game/Spells/Auras/AuraEffect.cs @@ -3516,6 +3516,32 @@ namespace Game.Spells target.SetUInt32Value(UnitFields.OverrideDisplayPowerId, 0); } + [AuraEffectHandler(AuraType.ModMaxPowerPct)] + void HandleAuraModMaxPowerPct(AuraApplication aurApp, AuraEffectHandleModes mode, bool apply) + { + if (!mode.HasAnyFlag(AuraEffectHandleModes.ChangeAmountMask | AuraEffectHandleModes.Stat)) + return; + + Unit target = aurApp.GetTarget(); + if (!target.IsPlayer()) + return; + + PowerType powerType = (PowerType)GetMiscValue(); + UnitMods unitMod = UnitMods.PowerStart + (int)powerType; + + // Save old powers for further calculation + int oldPower = target.GetPower(powerType); + int oldMaxPower = target.GetMaxPower(powerType); + + // Handle aura effect for max power + target.HandleStatModifier(unitMod, UnitModifierType.TotalPCT, (float)GetAmount(), apply); + + // Calculate the current power change + int change = target.GetMaxPower(powerType) - oldMaxPower; + change = (oldPower + change) - target.GetPower(powerType); + target.ModifyPower(powerType, change); + } + /********************************/ /*** FIGHT ***/ /********************************/