From eb3f72da99e7b9250a823a5ed2298edd276ad556 Mon Sep 17 00:00:00 2001 From: Kamron Batman <3953314+kamronbatman@users.noreply.github.com> Date: Sat, 18 Jul 2020 19:25:15 -0700 Subject: [PATCH] Fixes NPE with Protection Spell (#179) --- .../UOContent/Spells/Fifth/MagicReflect.cs | 26 +++++++++---------- .../UOContent/Spells/First/ReactiveArmor.cs | 26 +++++++++---------- .../UOContent/Spells/Second/Protection.cs | 26 +++++++++---------- 3 files changed, 39 insertions(+), 39 deletions(-) diff --git a/Projects/UOContent/Spells/Fifth/MagicReflect.cs b/Projects/UOContent/Spells/Fifth/MagicReflect.cs index 64bd8a3f6..3041b2b33 100644 --- a/Projects/UOContent/Spells/Fifth/MagicReflect.cs +++ b/Projects/UOContent/Spells/Fifth/MagicReflect.cs @@ -55,7 +55,19 @@ namespace Server.Spells.Fifth { Mobile targ = Caster; - if (!m_Table.TryGetValue(targ, out ResistanceMod[] mods)) + if (m_Table.TryGetValue(targ, out ResistanceMod[] mods)) + { + targ.PlaySound(0x1ED); + targ.FixedParticles(0x375A, 10, 15, 5037, EffectLayer.Waist); + + m_Table.Remove(targ); + + for (int i = 0; i < mods.Length; ++i) + targ.RemoveResistanceMod(mods[i]); + + BuffInfo.RemoveBuff(targ, BuffIcon.MagicReflection); + } + else { targ.PlaySound(0x1E9); targ.FixedParticles(0x375A, 10, 15, 5037, EffectLayer.Waist); @@ -81,18 +93,6 @@ namespace Server.Spells.Fifth BuffInfo.AddBuff(targ, new BuffInfo(BuffIcon.MagicReflection, 1075817, buffFormat, true)); } - else - { - targ.PlaySound(0x1ED); - targ.FixedParticles(0x375A, 10, 15, 5037, EffectLayer.Waist); - - m_Table.Remove(targ); - - for (int i = 0; i < mods.Length; ++i) - targ.RemoveResistanceMod(mods[i]); - - BuffInfo.RemoveBuff(targ, BuffIcon.MagicReflection); - } } FinishSequence(); diff --git a/Projects/UOContent/Spells/First/ReactiveArmor.cs b/Projects/UOContent/Spells/First/ReactiveArmor.cs index c24f41847..b17e4fa33 100644 --- a/Projects/UOContent/Spells/First/ReactiveArmor.cs +++ b/Projects/UOContent/Spells/First/ReactiveArmor.cs @@ -56,7 +56,19 @@ namespace Server.Spells.First { Mobile targ = Caster; - if (!m_Table.TryGetValue(targ, out ResistanceMod[] mods)) + if (m_Table.TryGetValue(targ, out ResistanceMod[] mods)) + { + targ.PlaySound(0x1ED); + targ.FixedParticles(0x376A, 9, 32, 5008, EffectLayer.Waist); + + m_Table.Remove(targ); + + for (int i = 0; i < mods.Length; ++i) + targ.RemoveResistanceMod(mods[i]); + + BuffInfo.RemoveBuff(Caster, BuffIcon.ReactiveArmor); + } + else { targ.PlaySound(0x1E9); targ.FixedParticles(0x376A, 9, 32, 5008, EffectLayer.Waist); @@ -81,18 +93,6 @@ namespace Server.Spells.First BuffInfo.AddBuff(Caster, new BuffInfo(BuffIcon.ReactiveArmor, 1075812, 1075813, args)); } - else - { - targ.PlaySound(0x1ED); - targ.FixedParticles(0x376A, 9, 32, 5008, EffectLayer.Waist); - - m_Table.Remove(targ); - - for (int i = 0; i < mods.Length; ++i) - targ.RemoveResistanceMod(mods[i]); - - BuffInfo.RemoveBuff(Caster, BuffIcon.ReactiveArmor); - } } FinishSequence(); diff --git a/Projects/UOContent/Spells/Second/Protection.cs b/Projects/UOContent/Spells/Second/Protection.cs index 172c3c457..28e7b34cc 100644 --- a/Projects/UOContent/Spells/Second/Protection.cs +++ b/Projects/UOContent/Spells/Second/Protection.cs @@ -53,6 +53,19 @@ namespace Server.Spells.Second */ if (m_Table.TryGetValue(target, out Tuple mods)) + { + target.PlaySound(0x1ED); + target.FixedParticles(0x375A, 9, 20, 5016, EffectLayer.Waist); + + m_Table.Remove(target); + Registry.Remove(target); + + target.RemoveResistanceMod(mods.Item1); + target.RemoveSkillMod(mods.Item2); + + BuffInfo.RemoveBuff(target, BuffIcon.Protection); + } + else { target.PlaySound(0x1E9); target.FixedParticles(0x375A, 9, 20, 5016, EffectLayer.Waist); @@ -74,19 +87,6 @@ namespace Server.Spells.Second string args = $"{physloss}\t{resistloss}"; BuffInfo.AddBuff(target, new BuffInfo(BuffIcon.Protection, 1075814, 1075815, args)); } - else - { - target.PlaySound(0x1ED); - target.FixedParticles(0x375A, 9, 20, 5016, EffectLayer.Waist); - - m_Table.Remove(target); - Registry.Remove(target); - - target.RemoveResistanceMod(mods.Item1); - target.RemoveSkillMod(mods.Item2); - - BuffInfo.RemoveBuff(target, BuffIcon.Protection); - } } public static void EndProtection(Mobile m)