From da61c920b7203a7f655a6d6c1b634c11492988cd Mon Sep 17 00:00:00 2001 From: hondacrx Date: Sun, 8 Apr 2018 18:55:25 -0400 Subject: [PATCH] Core/Auras: implement Aura 379 (SPELL_AURA_MOD_MANA_REGEN_PCT) --- .../Constants/Spells/SpellAuraConst.cs | 2 +- Source/Game/Entities/StatSystem.cs | 22 ++++++++++--------- Source/Game/Entities/Transport.cs | 2 +- Source/Game/Spells/Auras/AuraEffect.cs | 14 ++++++++++++ 4 files changed, 28 insertions(+), 12 deletions(-) diff --git a/Source/Framework/Constants/Spells/SpellAuraConst.cs b/Source/Framework/Constants/Spells/SpellAuraConst.cs index 3b8d21798..3056e0d42 100644 --- a/Source/Framework/Constants/Spells/SpellAuraConst.cs +++ b/Source/Framework/Constants/Spells/SpellAuraConst.cs @@ -400,7 +400,7 @@ namespace Framework.Constants ModCurrencyGainFromSource = 376, // NYI CastWhileWalking2 = 377, // NYI Unk378 = 378, - Unk379 = 379, + ModManaRegenPct = 379, ModGlobalCooldownByHaste = 380, // Allows melee abilities to benefit from haste GCD reduction Unk381 = 381, ModPetStatPct = 382, // NYI diff --git a/Source/Game/Entities/StatSystem.cs b/Source/Game/Entities/StatSystem.cs index 182dc5628..4d4074b8d 100644 --- a/Source/Game/Entities/StatSystem.cs +++ b/Source/Game/Entities/StatSystem.cs @@ -997,19 +997,21 @@ namespace Game.Entities if (manaIndex == (int)PowerType.Max) return; - // Mana regen from spirit - float spirit_regen = 0.0f; - // Apply PCT bonus from SPELL_AURA_MOD_POWER_REGEN_PERCENT aura on spirit base regen - spirit_regen *= GetTotalAuraMultiplierByMiscValue(AuraType.ModPowerRegenPercent, (int)PowerType.Mana); + // Get base of Mana Pool in sBaseMPGameTable + uint basemana; + Global.ObjectMgr.GetPlayerClassLevelInfo(GetClass(), getLevel(), out basemana); + float base_regen = basemana / 100.0f; - // CombatRegen = 5% of Base Mana - float base_regen = GetCreateMana() * 0.02f + GetTotalAuraModifierByMiscValue(AuraType.ModPowerRegen, (int)PowerType.Mana) / 5.0f; + base_regen += GetTotalAuraModifierByMiscValue(AuraType.ModPowerRegen, (int)PowerType.Mana); - // Set regen rate in cast state apply only on spirit based regen - int modManaRegenInterrupt = GetTotalAuraModifier(AuraType.ModManaRegenInterrupt); + // Apply PCT bonus from SPELL_AURA_MOD_POWER_REGEN_PERCENT + base_regen *= GetTotalAuraMultiplierByMiscValue(AuraType.ModPowerRegenPercent, (int)PowerType.Mana); - SetFloatValue(UnitFields.PowerRegenInterruptedFlatModifier + manaIndex, base_regen + MathFunctions.CalculatePct(spirit_regen, modManaRegenInterrupt)); - SetFloatValue(UnitFields.PowerRegenFlatModifier + manaIndex, 0.001f + spirit_regen + base_regen); + // Apply PCT bonus from SPELL_AURA_MOD_MANA_REGEN_PCT + base_regen *= GetTotalAuraMultiplierByMiscValue(AuraType.ModManaRegenPct, (int)PowerType.Mana); + + SetFloatValue(UnitFields.PowerRegenInterruptedFlatModifier + manaIndex, base_regen); + SetFloatValue(UnitFields.PowerRegenFlatModifier + manaIndex, base_regen); } public void UpdateSpellDamageAndHealingBonus() diff --git a/Source/Game/Entities/Transport.cs b/Source/Game/Entities/Transport.cs index b1a3249d8..171b50cb1 100644 --- a/Source/Game/Entities/Transport.cs +++ b/Source/Game/Entities/Transport.cs @@ -429,7 +429,7 @@ namespace Game.Entities mask = UnitTypeMask.Minion; break; default: - if (properties.Flags.HasAnyFlag(512)) // Mirror Image, Summon Gargoyle + if (properties.Flags.HasAnyFlag(SummonPropFlags.Unk10)) // Mirror Image, Summon Gargoyle mask = UnitTypeMask.Guardian; break; } diff --git a/Source/Game/Spells/Auras/AuraEffect.cs b/Source/Game/Spells/Auras/AuraEffect.cs index 83f0bb9a7..9a1d3dd39 100644 --- a/Source/Game/Spells/Auras/AuraEffect.cs +++ b/Source/Game/Spells/Auras/AuraEffect.cs @@ -3343,6 +3343,20 @@ namespace Game.Spells target.ToPlayer().UpdateManaRegen(); } + [AuraEffectHandler(AuraType.ModManaRegenPct)] + void HandleModManaRegenPct(AuraApplication aurApp, AuraEffectHandleModes mode, bool apply) + { + if (!mode.HasAnyFlag(AuraEffectHandleModes.ChangeAmountMask | AuraEffectHandleModes.Stat)) + return; + + Unit target = aurApp.GetTarget(); + + if (!target.IsPlayer()) + return; + + target.ToPlayer().UpdateManaRegen(); + } + [AuraEffectHandler(AuraType.ModIncreaseHealth)] [AuraEffectHandler(AuraType.ModIncreaseHealth2)] [AuraEffectHandler(AuraType.ModMaxHealth)]