Core/Auras: Implemented aura to increase armor by percentage of primary stat

Port From (https://github.com/TrinityCore/TrinityCore/commit/b574be08ae552dcc4bba09e15422d74866a0e7d2)
This commit is contained in:
hondacrx
2021-03-29 12:12:49 -04:00
parent b00a895f19
commit 6e2c9a32e7
3 changed files with 30 additions and 4 deletions
@@ -289,7 +289,7 @@ namespace Framework.Constants
Unk265 = 265, Unk265 = 265,
SetVignette = 266, //NYI SetVignette = 266, //NYI
ModImmuneAuraApplySchool = 267, ModImmuneAuraApplySchool = 267,
Unk268 = 268, // Old ModAttackPowerOfStatPercent. Unused 4.3.4 ModArmorPctFromStat = 268,
ModIgnoreTargetResist = 269, ModIgnoreTargetResist = 269,
ModSchoolMaskDamageFromCaster = 270, ModSchoolMaskDamageFromCaster = 270,
ModSpellDamageFromCaster = 271, ModSpellDamageFromCaster = 271,
@@ -505,7 +505,7 @@ namespace Framework.Constants
ConvertConsumedRune = 481, ConvertConsumedRune = 481,
Unk482 = 482, Unk482 = 482,
SuppressTransforms = 483, // NYI SuppressTransforms = 483, // NYI
Unk484 = 484, AllowInterruptSpell = 484, // NYI
ModMovementForceMagnitude = 485, ModMovementForceMagnitude = 485,
Unk486 = 486, Unk486 = 486,
Unk487 = 487, Unk487 = 487,
+13 -2
View File
@@ -1036,7 +1036,6 @@ namespace Game.Entities
switch (stat) switch (stat)
{ {
case Stats.Agility: case Stats.Agility:
UpdateArmor();
UpdateAllCritPercentages(); UpdateAllCritPercentages();
UpdateDodgePercentage(); UpdateDodgePercentage();
break; break;
@@ -1045,7 +1044,6 @@ namespace Game.Entities
break; break;
case Stats.Intellect: case Stats.Intellect:
UpdateSpellCritChance(); UpdateSpellCritChance();
UpdateArmor(); //SPELL_AURA_MOD_RESISTANCE_OF_INTELLECT_PERCENT, only armor currently
break; break;
default: default:
break; break;
@@ -1059,6 +1057,7 @@ namespace Game.Entities
UpdateAttackPowerAndDamage(true); UpdateAttackPowerAndDamage(true);
} }
UpdateArmor();
UpdateSpellDamageAndHealingBonus(); UpdateSpellDamageAndHealingBonus();
UpdateManaRegen(); UpdateManaRegen();
@@ -1302,6 +1301,18 @@ namespace Game.Entities
float value = GetFlatModifierValue(unitMod, UnitModifierFlatType.Base); // base armor (from items) float value = GetFlatModifierValue(unitMod, UnitModifierFlatType.Base); // base armor (from items)
float baseValue = value; 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 *= GetPctModifierValue(unitMod, UnitModifierPctType.Base); // armor percent from items
value += GetFlatModifierValue(unitMod, UnitModifierFlatType.Total); value += GetFlatModifierValue(unitMod, UnitModifierFlatType.Total);
value *= GetPctModifierValue(unitMod, UnitModifierPctType.Total); value *= GetPctModifierValue(unitMod, UnitModifierPctType.Total);
+15
View File
@@ -3079,6 +3079,21 @@ namespace Game.Spells
target.ToPlayer().UpdateExpertise(WeaponAttackType.OffAttack); target.ToPlayer().UpdateExpertise(WeaponAttackType.OffAttack);
} }
// Increase armor by <AuraEffect.BasePoints> % of your <primary stat>
[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)] [AuraEffectHandler(AuraType.ModStatBonusPct)]
void HandleModStatBonusPercent(AuraApplication aurApp, AuraEffectHandleModes mode, bool apply) void HandleModStatBonusPercent(AuraApplication aurApp, AuraEffectHandleModes mode, bool apply)
{ {