From e179d29b555135a6c5dd3c0f0950ce2d1586e196 Mon Sep 17 00:00:00 2001 From: hondacrx Date: Tue, 14 Jul 2020 16:58:41 -0400 Subject: [PATCH] Core/Spells: Include more than first 2 spell effects when determining if a spell is negative Port From (https://github.com/TrinityCore/TrinityCore/commit/176c75e8dbad95bfdcd88034f75e1452997ddb07) --- .../Framework/Constants/Spells/SpellConst.cs | 10 ++++------ Source/Game/Spells/SpellInfo.cs | 19 ++++++++----------- Source/Game/Spells/SpellManager.cs | 12 +++--------- 3 files changed, 15 insertions(+), 26 deletions(-) diff --git a/Source/Framework/Constants/Spells/SpellConst.cs b/Source/Framework/Constants/Spells/SpellConst.cs index 2a367fbf7..f124e8bf8 100644 --- a/Source/Framework/Constants/Spells/SpellConst.cs +++ b/Source/Framework/Constants/Spells/SpellConst.cs @@ -1865,9 +1865,9 @@ namespace Framework.Constants DirectDamage = 0x100, Charge = 0x200, PickPocket = 0x400, - NegativeEff0 = 0x1000, - NegativeEff1 = 0x2000, - NegativeEff2 = 0x4000, + DeprecatedNegativeEff0 = 0x1000, // DO NOT REUSE + DeprecatedNegativeEff1 = 0x2000, // DO NOT REUSE + DeprecatedNegativeEff2 = 0x4000, // DO NOT REUSE IgnoreArmor = 0x8000, ReqTargetFacingCaster = 0x10000, ReqCasterBehindTarget = 0x20000, @@ -1876,9 +1876,7 @@ namespace Framework.Constants BinarySpell = 0x00100000, SchoolmaskNormalWithMagic = 0x00200000, LiquidAura = 0x00400000, - IsTalent = 0x00800000, - - Negative = NegativeEff0 | NegativeEff1 | NegativeEff2 + IsTalent = 0x00800000 } #endregion diff --git a/Source/Game/Spells/SpellInfo.cs b/Source/Game/Spells/SpellInfo.cs index 3d3d48dd3..343233f4c 100644 --- a/Source/Game/Spells/SpellInfo.cs +++ b/Source/Game/Spells/SpellInfo.cs @@ -23,6 +23,7 @@ using Game.DataStorage; using Game.Entities; using Game.Maps; using System; +using System.Collections; using System.Collections.Generic; using System.Linq; @@ -510,21 +511,16 @@ namespace Game.Spells public bool IsPositive() { - return !HasAttribute(SpellCustomAttributes.Negative); + for (var index = 0; index < NegativeEffects.Length; ++index) + if (NegativeEffects.Get(index)) + return false; + + return true; } public bool IsPositiveEffect(uint effIndex) { - switch (effIndex) - { - default: - case 0: - return !HasAttribute(SpellCustomAttributes.NegativeEff0); - case 1: - return !HasAttribute(SpellCustomAttributes.NegativeEff1); - case 2: - return !HasAttribute(SpellCustomAttributes.NegativeEff2); - } + return NegativeEffects.Get((int)effIndex); } public bool IsChanneled() @@ -3528,6 +3524,7 @@ namespace Game.Spells public SpellAttr12 AttributesEx12 { get; set; } public SpellAttr13 AttributesEx13 { get; set; } public SpellCustomAttributes AttributesCu { get; set; } + public BitSet NegativeEffects { get; set; } = new BitSet(SpellConst.MaxEffects); public ulong Stances { get; set; } public ulong StancesNot { get; set; } public SpellCastTargetFlags targets { get; set; } diff --git a/Source/Game/Spells/SpellManager.cs b/Source/Game/Spells/SpellManager.cs index f3cff95d2..c44243701 100644 --- a/Source/Game/Spells/SpellManager.cs +++ b/Source/Game/Spells/SpellManager.cs @@ -2499,6 +2499,9 @@ namespace Game.Entities break; } } + + if (!spellInfo._IsPositiveEffect(effect.EffectIndex, false)) + spellInfo.NegativeEffects[(int)effect.EffectIndex] = true; } // spells ignoring hit result should not be binary @@ -2587,15 +2590,6 @@ namespace Game.Entities spellInfo.AttributesCu |= SpellCustomAttributes.SchoolmaskNormalWithMagic; } - if (!spellInfo._IsPositiveEffect(0, false)) - spellInfo.AttributesCu |= SpellCustomAttributes.NegativeEff0; - - if (!spellInfo._IsPositiveEffect(1, false)) - spellInfo.AttributesCu |= SpellCustomAttributes.NegativeEff1; - - if (!spellInfo._IsPositiveEffect(2, false)) - spellInfo.AttributesCu |= SpellCustomAttributes.NegativeEff2; - if (talentSpells.Contains(spellInfo.Id)) spellInfo.AttributesCu |= SpellCustomAttributes.IsTalent;