From 6e2c9a32e7dc6925471311b50f6288cce91fbde3 Mon Sep 17 00:00:00 2001 From: hondacrx Date: Mon, 29 Mar 2021 12:12:49 -0400 Subject: [PATCH] Core/Auras: Implemented aura to increase armor by percentage of primary stat Port From (https://github.com/TrinityCore/TrinityCore/commit/b574be08ae552dcc4bba09e15422d74866a0e7d2) --- .../Framework/Constants/Spells/SpellAuraConst.cs | 4 ++-- Source/Game/Entities/StatSystem.cs | 15 +++++++++++++-- Source/Game/Spells/Auras/AuraEffect.cs | 15 +++++++++++++++ 3 files changed, 30 insertions(+), 4 deletions(-) diff --git a/Source/Framework/Constants/Spells/SpellAuraConst.cs b/Source/Framework/Constants/Spells/SpellAuraConst.cs index a6ef5e5a1..2fbbd2f0f 100644 --- a/Source/Framework/Constants/Spells/SpellAuraConst.cs +++ b/Source/Framework/Constants/Spells/SpellAuraConst.cs @@ -289,7 +289,7 @@ namespace Framework.Constants Unk265 = 265, SetVignette = 266, //NYI ModImmuneAuraApplySchool = 267, - Unk268 = 268, // Old ModAttackPowerOfStatPercent. Unused 4.3.4 + ModArmorPctFromStat = 268, ModIgnoreTargetResist = 269, ModSchoolMaskDamageFromCaster = 270, ModSpellDamageFromCaster = 271, @@ -505,7 +505,7 @@ namespace Framework.Constants ConvertConsumedRune = 481, Unk482 = 482, SuppressTransforms = 483, // NYI - Unk484 = 484, + AllowInterruptSpell = 484, // NYI ModMovementForceMagnitude = 485, Unk486 = 486, Unk487 = 487, diff --git a/Source/Game/Entities/StatSystem.cs b/Source/Game/Entities/StatSystem.cs index d9820ecc2..a37509d90 100644 --- a/Source/Game/Entities/StatSystem.cs +++ b/Source/Game/Entities/StatSystem.cs @@ -1036,7 +1036,6 @@ namespace Game.Entities switch (stat) { case Stats.Agility: - UpdateArmor(); UpdateAllCritPercentages(); UpdateDodgePercentage(); break; @@ -1045,7 +1044,6 @@ namespace Game.Entities break; case Stats.Intellect: UpdateSpellCritChance(); - UpdateArmor(); //SPELL_AURA_MOD_RESISTANCE_OF_INTELLECT_PERCENT, only armor currently break; default: break; @@ -1059,6 +1057,7 @@ namespace Game.Entities UpdateAttackPowerAndDamage(true); } + UpdateArmor(); UpdateSpellDamageAndHealingBonus(); UpdateManaRegen(); @@ -1302,6 +1301,18 @@ namespace Game.Entities float value = GetFlatModifierValue(unitMod, UnitModifierFlatType.Base); // base armor (from items) float baseValue = value; + + GetTotalAuraModifier(AuraType.ModArmorPctFromStat, aurEff => + { + int miscValue = aurEff.GetMiscValue(); + Stats stat = (miscValue != -2) ? (Stats)miscValue : GetPrimaryStat(); + + int armorAmount = (int)MathFunctions.CalculatePct(GetStat(stat), aurEff.GetAmount()); + baseValue += armorAmount; + + return true; + }); + value *= GetPctModifierValue(unitMod, UnitModifierPctType.Base); // armor percent from items value += GetFlatModifierValue(unitMod, UnitModifierFlatType.Total); value *= GetPctModifierValue(unitMod, UnitModifierPctType.Total); diff --git a/Source/Game/Spells/Auras/AuraEffect.cs b/Source/Game/Spells/Auras/AuraEffect.cs index d2bd68e90..7c0ea6fbd 100644 --- a/Source/Game/Spells/Auras/AuraEffect.cs +++ b/Source/Game/Spells/Auras/AuraEffect.cs @@ -3079,6 +3079,21 @@ namespace Game.Spells target.ToPlayer().UpdateExpertise(WeaponAttackType.OffAttack); } + // Increase armor by % of your + [AuraEffectHandler(AuraType.ModArmorPctFromStat)] + void HandleModArmorPctFromStat(AuraApplication aurApp, AuraEffectHandleModes mode, bool apply) + { + if (!mode.HasAnyFlag(AuraEffectHandleModes.ChangeAmountMask | AuraEffectHandleModes.Stat)) + return; + + // only players have primary stats + Player player = aurApp.GetTarget().ToPlayer(); + if (!player) + return; + + player.UpdateArmor(); + } + [AuraEffectHandler(AuraType.ModStatBonusPct)] void HandleModStatBonusPercent(AuraApplication aurApp, AuraEffectHandleModes mode, bool apply) {