diff --git a/Source/Game/Entities/Player/Player.Spells.cs b/Source/Game/Entities/Player/Player.Spells.cs index 6b1b2a541..d84fa8098 100644 --- a/Source/Game/Entities/Player/Player.Spells.cs +++ b/Source/Game/Entities/Player/Player.Spells.cs @@ -1847,67 +1847,6 @@ namespace Game.Entities CastSpell(this, spell.spellId, true); } - - // Restore spellmods in case of failed cast - public void RestoreSpellMods(Spell spell, uint ownerAuraId = 0, Aura aura = null) - { - if (spell == null || spell.m_appliedMods.Empty()) - return; - - List aurasQueue = new List(); - for (var i = 0; i < (int)SpellModOp.Max; ++i) - { - for (var j = 0; j < (int)SpellModType.End; ++j) - { - foreach (var mod in m_spellMods[i][j]) - { - // Spellmods without charged aura set cannot be charged - if (!mod.ownerAura.IsUsingCharges()) - continue; - - // Restore only specific owner aura mods - if (ownerAuraId != 0 && mod.spellId != ownerAuraId) - continue; - - if (aura != null && mod.ownerAura != aura) - continue; - - // check if mod affected this spell - // first, check if the mod aura applied at least one spellmod to this spell - var iterMod = spell.m_appliedMods.Find(p => p == mod.ownerAura); - if (iterMod == null) - continue; - - // secondly, check if the current mod is one of the spellmods applied by the mod aura - if (!(mod.mask & spell.m_spellInfo.SpellFamilyFlags)) - continue; - - // remove from list - This will be done after all mods have been gone through - // to ensure we iterate over all mods of an aura before removing said aura - // from applied mods (Else, an aura with two mods on the current spell would - // only see the first of its modifier restored) - aurasQueue.Add(mod.ownerAura); - - // add charges back to aura - mod.ownerAura.ModCharges(1); - } - } - } - - foreach (var removeAura in aurasQueue) - spell.m_appliedMods.Remove(aura); - } - - public void RestoreAllSpellMods(uint ownerAuraId = 0, Aura aura = null) - { - for (CurrentSpellTypes i = 0; i < CurrentSpellTypes.Max; ++i) - { - Spell spell = GetCurrentSpell(i); - if (spell != null) - RestoreSpellMods(spell, ownerAuraId, aura); - } - } - public void ApplyModToSpell(SpellModifier mod, Spell spell) { if (spell == null) diff --git a/Source/Game/Spells/Auras/Aura.cs b/Source/Game/Spells/Auras/Aura.cs index 5e5f4d069..86bf70893 100644 --- a/Source/Game/Spells/Auras/Aura.cs +++ b/Source/Game/Spells/Auras/Aura.cs @@ -882,7 +882,6 @@ namespace Game.Spells if (refresh) { - RefreshSpellMods(); RefreshTimers(resetPeriodicTimer); // reset charges @@ -892,16 +891,6 @@ namespace Game.Spells return false; } - void RefreshSpellMods() - { - foreach (var app in m_applications.Values) - { - Player player = app.GetTarget().ToPlayer(); - if (player != null) - player.RestoreAllSpellMods(0, this); - } - } - public bool HasMoreThanOneEffectForType(AuraType auraType) { uint count = 0; diff --git a/Source/Game/Spells/Spell.cs b/Source/Game/Spells/Spell.cs index aac3d3583..98938e24a 100644 --- a/Source/Game/Spells/Spell.cs +++ b/Source/Game/Spells/Spell.cs @@ -2541,13 +2541,10 @@ namespace Game.Spells triggeredByAura.GetBase().SetDuration(0); } + // cleanup after mod system + // triggered spell pointer can be not removed in some cases if (m_caster.IsTypeId(TypeId.Player)) - { - m_caster.ToPlayer().RestoreSpellMods(this); - // cleanup after mod system - // triggered spell pointer can be not removed in some cases m_caster.ToPlayer().SetSpellModTakingSpell(this, false); - } if (param1 != 0 || param2 != 0) SendCastResult(result, param1, param2); @@ -2659,8 +2656,6 @@ namespace Game.Spells { case SpellState.Preparing: CancelGlobalCooldown(); - if (m_caster.IsTypeId(TypeId.Player)) - m_caster.ToPlayer().RestoreSpellMods(this); goto case SpellState.Delayed; case SpellState.Delayed: SendInterrupted(0); @@ -2763,13 +2758,12 @@ namespace Game.Spells { SendCastResult(castResult, param1, param2); SendInterrupted(0); - //restore spell mods + + // cleanup after mod system + // triggered spell pointer can be not removed in some cases if (m_caster.IsTypeId(TypeId.Player)) - { - m_caster.ToPlayer().RestoreSpellMods(this); - // cleanup after mod system m_caster.ToPlayer().SetSpellModTakingSpell(this, false); - } + finish(false); SetExecutedCurrently(false); return; @@ -2790,9 +2784,10 @@ namespace Game.Spells my_trade.SetSpell(m_spellInfo.Id, m_CastItem); SendCastResult(SpellCastResult.DontReport); SendInterrupted(0); - m_caster.ToPlayer().RestoreSpellMods(this); + // cleanup after mod system m_caster.ToPlayer().SetSpellModTakingSpell(this, false); + finish(false); SetExecutedCurrently(false); return; @@ -2820,13 +2815,12 @@ namespace Game.Spells if (m_spellState == SpellState.Finished) { SendInterrupted(0); - //restore spell mods + + // cleanup after mod system + // triggered spell pointer can be not removed in some cases if (m_caster.IsTypeId(TypeId.Player)) - { - m_caster.ToPlayer().RestoreSpellMods(this); - // cleanup after mod system m_caster.ToPlayer().SetSpellModTakingSpell(this, false); - } + finish(false); SetExecutedCurrently(false); return;