diff --git a/Source/Framework/Constants/Spells/SpellConst.cs b/Source/Framework/Constants/Spells/SpellConst.cs index a240bae4e..431bae726 100644 --- a/Source/Framework/Constants/Spells/SpellConst.cs +++ b/Source/Framework/Constants/Spells/SpellConst.cs @@ -431,12 +431,12 @@ namespace Framework.Constants public enum SpellState { - None = 0, + Null = 0, Preparing = 1, - Casting = 2, - Finished = 3, - Idle = 4, - Delayed = 5 + Launched = 2, + Channeling = 3, + Finished = 4, + Idle = 5 } public enum SpellSchools diff --git a/Source/Game/Entities/Player/Player.Spells.cs b/Source/Game/Entities/Player/Player.Spells.cs index 3005e562b..003cd68fe 100644 --- a/Source/Game/Entities/Player/Player.Spells.cs +++ b/Source/Game/Entities/Player/Player.Spells.cs @@ -1750,13 +1750,13 @@ namespace Game.Entities RemoveOwnedAura(pair); } - // currently casted spells can be dependent from item + // currently cast spells can be dependent from item for (CurrentSpellTypes i = 0; i < CurrentSpellTypes.Max; ++i) { Spell spell = GetCurrentSpell(i); if (spell != null) - if (spell.GetState() != SpellState.Delayed && !HasItemFitToSpellRequirements(spell.m_spellInfo, pItem)) - InterruptSpell(i); + if (!HasItemFitToSpellRequirements(spell.m_spellInfo, pItem)) + InterruptSpell(i, false); } } diff --git a/Source/Game/Entities/Unit/Unit.Spells.cs b/Source/Game/Entities/Unit/Unit.Spells.cs index e6bf350aa..0c3af93ca 100644 --- a/Source/Game/Entities/Unit/Unit.Spells.cs +++ b/Source/Game/Entities/Unit/Unit.Spells.cs @@ -981,7 +981,7 @@ namespace Game.Entities } return null; - }; + } SpellInfo newInfo = findMatchingAuraEffectIn(AuraType.OverrideActionbarSpells, ref triggerFlag); if (newInfo != null) @@ -1113,12 +1113,9 @@ namespace Game.Entities public Spell FindCurrentSpellBySpellId(uint spell_id) { foreach (var spell in m_currentSpells.Values) - { - if (spell == null) - continue; - if (spell.m_spellInfo.Id == spell_id) + if (spell != null && spell.m_spellInfo.Id == spell_id) return spell; - } + return null; } @@ -1936,7 +1933,7 @@ namespace Game.Entities // generic spells are cast when they are not finished and not delayed var currentSpell = GetCurrentSpell(CurrentSpellTypes.Generic); - if (currentSpell != null && (currentSpell.GetState() != SpellState.Finished) && (withDelayed || currentSpell.GetState() != SpellState.Delayed)) + if (currentSpell != null && (currentSpell.GetState() != SpellState.Finished) && (withDelayed || currentSpell.GetState() != SpellState.Launched)) { if (!skipInstant || currentSpell.GetCastTime() != 0) { @@ -2630,8 +2627,8 @@ namespace Game.Entities Log.outDebug(LogFilter.Unit, "Interrupt spell for unit {0}", GetEntry()); Spell spell = m_currentSpells.LookupByKey(spellType); if (spell != null - && (withDelayed || spell.GetState() != SpellState.Delayed) - && (withInstant || spell.GetCastTime() > 0 || spell.GetState() == SpellState.Casting)) + && (withDelayed || spell.GetState() != SpellState.Launched) + && (withInstant || spell.GetCastTime() > 0 || spell.GetState() == SpellState.Channeling)) { // for example, do not let self-stun aura interrupt itself if (!spell.IsInterruptable()) @@ -2667,7 +2664,7 @@ namespace Game.Entities Spell spell = GetCurrentSpell(CurrentSpellTypes.Channeled); if (spell != null) { - if (spell.GetState() == SpellState.Casting) + if (spell.GetState() == SpellState.Channeling) { m_interruptMask |= spell.m_spellInfo.ChannelInterruptFlags; m_interruptMask2 |= spell.m_spellInfo.ChannelInterruptFlags2; @@ -3117,7 +3114,7 @@ namespace Game.Entities Spell spell = GetCurrentSpell(CurrentSpellTypes.Channeled); if (spell != null) { - if (spell.GetState() == SpellState.Casting + if (spell.GetState() == SpellState.Channeling && spell.GetSpellInfo().HasChannelInterruptFlag(flag) && (source == null || spell.GetSpellInfo().Id != source.Id) && !IsInterruptFlagIgnoredForSpell(flag, this, spell.GetSpellInfo(), true, source)) @@ -3150,7 +3147,7 @@ namespace Game.Entities Spell spell = GetCurrentSpell(CurrentSpellTypes.Channeled); if (spell != null) { - if (spell.GetState() == SpellState.Casting + if (spell.GetState() == SpellState.Channeling && spell.GetSpellInfo().HasChannelInterruptFlag(flag) && (source == null || spell.GetSpellInfo().Id != source.Id) && !IsInterruptFlagIgnoredForSpell(flag, this, spell.GetSpellInfo(), true, source)) diff --git a/Source/Game/Entities/Unit/Unit.cs b/Source/Game/Entities/Unit/Unit.cs index c59f23d0e..05d89acb1 100644 --- a/Source/Game/Entities/Unit/Unit.cs +++ b/Source/Game/Entities/Unit/Unit.cs @@ -2939,7 +2939,7 @@ namespace Game.Entities { Spell spell1 = victim.GetCurrentSpell(CurrentSpellTypes.Channeled); if (spell1 != null) - if (spell1.GetState() == SpellState.Casting && spell1.m_spellInfo.HasChannelInterruptFlag(SpellAuraInterruptFlags.DamageChannelDuration)) + if (spell1.GetState() == SpellState.Channeling && spell1.m_spellInfo.HasChannelInterruptFlag(SpellAuraInterruptFlags.DamageChannelDuration)) spell1.DelayedChannel(); } } diff --git a/Source/Game/Spells/Auras/AuraEffect.cs b/Source/Game/Spells/Auras/AuraEffect.cs index 9404bdcce..c612a28d6 100644 --- a/Source/Game/Spells/Auras/AuraEffect.cs +++ b/Source/Game/Spells/Auras/AuraEffect.cs @@ -1917,7 +1917,7 @@ namespace Game.Spells target.SetSilencedSchoolMask((SpellSchoolMask)GetMiscValue()); // call functions which may have additional effects after changing state of unit - // Stop cast only spells vs PreventionType & SPELL_PREVENTION_TYPE_SILENCE + // Stop cast only spells vs PreventionType & SPELL_PREVENTION_TYPE_NO_ACTIONS for (var i = CurrentSpellTypes.Melee; i < CurrentSpellTypes.Max; ++i) { Spell spell = target.GetCurrentSpell(i); diff --git a/Source/Game/Spells/Spell.cs b/Source/Game/Spells/Spell.cs index 62aadd071..0de7278b4 100644 --- a/Source/Game/Spells/Spell.cs +++ b/Source/Game/Spells/Spell.cs @@ -2748,13 +2748,12 @@ namespace Game.Spells { case SpellState.Preparing: CancelGlobalCooldown(); - goto case SpellState.Delayed; - case SpellState.Delayed: + goto case SpellState.Launched; + case SpellState.Launched: SendInterrupted(0); SendCastResult(SpellCastResult.Interrupted); break; - - case SpellState.Casting: + case SpellState.Channeling: foreach (var ihit in m_UniqueTargetInfo) { if (ihit.MissCondition == SpellMissInfo.None) @@ -2771,7 +2770,6 @@ namespace Game.Spells m_appliedMods.Clear(); break; - default: break; } @@ -3054,7 +3052,7 @@ namespace Game.Spells // Okay, maps created, now prepare flags m_immediateHandled = false; - m_spellState = SpellState.Delayed; + m_spellState = SpellState.Launched; SetDelayStart(0); unitCaster = m_caster.ToUnit(); @@ -3222,7 +3220,7 @@ namespace Game.Spells if (duration != 0) { - m_spellState = SpellState.Casting; + m_spellState = SpellState.Channeling; // GameObjects shouldn't cast channeled spells m_caster.ToUnit()?.AddInterruptMask(m_spellInfo.ChannelInterruptFlags, m_spellInfo.ChannelInterruptFlags2); } @@ -3254,7 +3252,7 @@ namespace Game.Spells // Remove used for cast item if need (it can be already NULL after TakeReagents call TakeCastItem(); - if (m_spellState != SpellState.Casting) + if (m_spellState != SpellState.Channeling) Finish(); // successfully finish spell cast (not last in case autorepeat or channel spell) } @@ -3472,7 +3470,7 @@ namespace Game.Spells Cast(m_casttime == 0); break; } - case SpellState.Casting: + case SpellState.Channeling: { if (m_timer != 0) { @@ -7287,7 +7285,7 @@ namespace Game.Spells if (unitCaster == null) return; - if (m_spellState != SpellState.Casting) + if (m_spellState != SpellState.Channeling) return; if (IsDelayableNoMore()) // Spells may only be delayed twice @@ -8415,7 +8413,7 @@ namespace Game.Spells if (m_casttime > 0 && m_spellInfo.InterruptFlags.HasFlag(SpellInterruptFlags.Movement)) return SpellCastResult.Moving; } - else if (GetState() == SpellState.Casting && !m_spellInfo.IsMoveAllowedChannel()) + else if (GetState() == SpellState.Channeling && !m_spellInfo.IsMoveAllowedChannel()) return SpellCastResult.Moving; } } @@ -8909,7 +8907,7 @@ namespace Game.Spells if (unit.IsAlive() != IsAlive && !spell.m_spellInfo.HasAttribute(SpellAttr9.ForceCorpseTarget)) return; - if (!spell.m_spellInfo.HasAttribute(SpellAttr8.IgnoreSanctuary) && spell.GetState() == SpellState.Delayed && !spell.IsPositive() && (GameTime.GetGameTimeMS() - TimeDelay) <= unit.LastSanctuaryTime) + if (!spell.m_spellInfo.HasAttribute(SpellAttr8.IgnoreSanctuary) && spell.GetState() == SpellState.Launched && !spell.IsPositive() && (GameTime.GetGameTimeMS() - TimeDelay) <= unit.LastSanctuaryTime) return; // No missinfo in that case if (_spellHitTarget != null) @@ -9652,7 +9650,7 @@ namespace Game.Spells // event will be re-added automatically at the end of routine) break; } - case SpellState.Delayed: + case SpellState.Launched: { // first, check, if we have just started if (m_Spell.GetDelayStart() != 0) diff --git a/Source/Game/Spells/SpellEffects.cs b/Source/Game/Spells/SpellEffects.cs index b85c536b3..533351897 100644 --- a/Source/Game/Spells/SpellEffects.cs +++ b/Source/Game/Spells/SpellEffects.cs @@ -2576,7 +2576,7 @@ namespace Game.Spells { SpellInfo curSpellInfo = spell.m_spellInfo; // check if we can interrupt spell - if ((spell.GetState() == SpellState.Casting + if ((spell.GetState() == SpellState.Channeling || (spell.GetState() == SpellState.Preparing && spell.GetCastTime() > 0.0f)) && curSpellInfo.CanBeInterrupted(m_caster, unitTarget)) {