diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/server/game/Entities/Player/Player.cpp | 4 | ||||
-rw-r--r-- | src/server/game/Entities/Unit/Unit.cpp | 26 | ||||
-rw-r--r-- | src/server/game/Spells/Auras/SpellAuraEffects.cpp | 2 | ||||
-rw-r--r-- | src/server/game/Spells/Spell.cpp | 24 | ||||
-rw-r--r-- | src/server/game/Spells/Spell.h | 38 | ||||
-rw-r--r-- | src/server/game/Spells/SpellEffects.cpp | 2 | ||||
-rw-r--r-- | src/server/scripts/Northrend/Ulduar/Ulduar/boss_yogg_saron.cpp | 2 | ||||
-rw-r--r-- | src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_leotheras_the_blind.cpp | 7 |
8 files changed, 49 insertions, 56 deletions
diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp index 8f99ffef2e8..48a0156ffce 100644 --- a/src/server/game/Entities/Player/Player.cpp +++ b/src/server/game/Entities/Player/Player.cpp @@ -26006,8 +26006,8 @@ void Player::RemoveItemDependentAurasAndCasts(Item* pItem) // currently cast spells can be dependent from item for (uint32 i = 0; i < CURRENT_MAX_SPELL; ++i) if (Spell* spell = GetCurrentSpell(CurrentSpellTypes(i))) - if (spell->getState() != SPELL_STATE_DELAYED && !HasItemFitToSpellRequirements(spell->m_spellInfo, pItem)) - InterruptSpell(CurrentSpellTypes(i)); + if (!HasItemFitToSpellRequirements(spell->m_spellInfo, pItem)) + InterruptSpell(CurrentSpellTypes(i), false); } void Player::InitializeSelfResurrectionSpells() diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index c71ac3383e8..5c21ec7ac5c 100644 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -734,7 +734,7 @@ void Unit::UpdateInterruptMask() if (Spell* spell = m_currentSpells[CURRENT_CHANNELED_SPELL]) { - if (spell->getState() == SPELL_STATE_CASTING) + if (spell->getState() == SPELL_STATE_CHANNELING) { m_interruptMask |= spell->m_spellInfo->ChannelInterruptFlags; m_interruptMask2 |= spell->m_spellInfo->ChannelInterruptFlags2; @@ -1123,7 +1123,7 @@ bool Unit::HasBreakableByDamageCrowdControlAura(Unit* excludeCasterChannel) cons if (damageTaken && victim->IsPlayer()) if (Spell* spell = victim->m_currentSpells[CURRENT_CHANNELED_SPELL]) - if (spell->getState() == SPELL_STATE_CASTING && spell->m_spellInfo->HasChannelInterruptFlag(SpellAuraInterruptFlags::DamageChannelDuration)) + if (spell->getState() == SPELL_STATE_CHANNELING && spell->m_spellInfo->HasChannelInterruptFlag(SpellAuraInterruptFlags::DamageChannelDuration)) spell->DelayedChannel(); } } @@ -2910,12 +2910,12 @@ void Unit::_UpdateSpells(uint32 time) _UpdateAutoRepeatSpell(); // remove finished spells from current pointers - for (uint32 i = 0; i < CURRENT_MAX_SPELL; ++i) + for (Spell*& spell : m_currentSpells) { - if (m_currentSpells[i] && m_currentSpells[i]->getState() == SPELL_STATE_FINISHED) + if (spell && spell->getState() == SPELL_STATE_FINISHED) { - m_currentSpells[i]->SetReferencedFromCurrent(false); - m_currentSpells[i] = nullptr; // remove pointer + spell->SetReferencedFromCurrent(false); + spell = nullptr; // remove pointer } } @@ -3081,8 +3081,8 @@ void Unit::InterruptSpell(CurrentSpellTypes spellType, bool withDelayed, bool wi //TC_LOG_DEBUG("entities.unit", "Interrupt spell for unit {}.", GetEntry()); Spell* spell = m_currentSpells[spellType]; if (spell - && (withDelayed || spell->getState() != SPELL_STATE_DELAYED) - && (withInstant || spell->GetCastTime() > 0 || spell->getState() == SPELL_STATE_CASTING)) + && (withDelayed || spell->getState() != SPELL_STATE_LAUNCHED) + && (withInstant || spell->GetCastTime() > 0 || spell->getState() == SPELL_STATE_CHANNELING)) { // for example, do not let self-stun aura interrupt itself if (!spell->IsInterruptable()) @@ -3126,7 +3126,7 @@ bool Unit::IsNonMeleeSpellCast(bool withDelayed, bool skipChanneled, bool skipAu // generic spells are cast when they are not finished and not delayed if (m_currentSpells[CURRENT_GENERIC_SPELL] && (m_currentSpells[CURRENT_GENERIC_SPELL]->getState() != SPELL_STATE_FINISHED) && - (withDelayed || m_currentSpells[CURRENT_GENERIC_SPELL]->getState() != SPELL_STATE_DELAYED)) + (withDelayed || m_currentSpells[CURRENT_GENERIC_SPELL]->getState() != SPELL_STATE_LAUNCHED)) { if (!skipInstant || m_currentSpells[CURRENT_GENERIC_SPELL]->GetCastTime()) { @@ -3165,9 +3165,9 @@ void Unit::InterruptNonMeleeSpells(bool withDelayed, uint32 spell_id, bool withI Spell* Unit::FindCurrentSpellBySpellId(uint32 spell_id) const { - for (uint32 i = 0; i < CURRENT_MAX_SPELL; i++) - if (m_currentSpells[i] && m_currentSpells[i]->m_spellInfo->Id == spell_id) - return m_currentSpells[i]; + for (Spell* spell : m_currentSpells) + if (spell && spell->m_spellInfo->Id == spell_id) + return spell; return nullptr; } @@ -4191,7 +4191,7 @@ void Unit::RemoveAurasWithInterruptFlags(InterruptFlags flag, SpellInfo const* s // interrupt channeled spell if (Spell* spell = m_currentSpells[CURRENT_CHANNELED_SPELL]) - if (spell->getState() == SPELL_STATE_CASTING + if (spell->getState() == SPELL_STATE_CHANNELING && spell->GetSpellInfo()->HasChannelInterruptFlag(flag) && (!source || spell->GetSpellInfo()->Id != source->Id) && !IsInterruptFlagIgnoredForSpell(flag, this, spell->GetSpellInfo(), true, source)) diff --git a/src/server/game/Spells/Auras/SpellAuraEffects.cpp b/src/server/game/Spells/Auras/SpellAuraEffects.cpp index 66e797eba2f..0bc04b4a0b1 100644 --- a/src/server/game/Spells/Auras/SpellAuraEffects.cpp +++ b/src/server/game/Spells/Auras/SpellAuraEffects.cpp @@ -2578,7 +2578,7 @@ void AuraEffect::HandleAuraModNoActions(AuraApplication const* aurApp, uint8 mod target->SetUnitFlag2(UNIT_FLAG2_NO_ACTIONS); // call functions which may have additional effects after chainging 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 (uint32 i = CURRENT_MELEE_SPELL; i < CURRENT_MAX_SPELL; ++i) if (Spell* spell = target->GetCurrentSpell(CurrentSpellTypes(i))) if (spell->m_spellInfo->PreventionType & SPELL_PREVENTION_TYPE_NO_ACTIONS) diff --git a/src/server/game/Spells/Spell.cpp b/src/server/game/Spells/Spell.cpp index 85f533b3d69..f463e635085 100644 --- a/src/server/game/Spells/Spell.cpp +++ b/src/server/game/Spells/Spell.cpp @@ -2762,7 +2762,7 @@ void Spell::TargetInfo::DoTargetSpellHit(Spell* spell, SpellEffectInfo const& sp if (unit->IsAlive() != IsAlive && !spell->m_spellInfo->HasAttribute(SPELL_ATTR9_FORCE_CORPSE_TARGET)) return; - if (!spell->m_spellInfo->HasAttribute(SPELL_ATTR8_IGNORE_SANCTUARY) && spell->getState() == SPELL_STATE_DELAYED && !spell->IsPositive() && (GameTime::GetGameTimeMS() - TimeDelay) <= unit->m_lastSanctuaryTime) + if (!spell->m_spellInfo->HasAttribute(SPELL_ATTR8_IGNORE_SANCTUARY) && spell->getState() == SPELL_STATE_LAUNCHED && !spell->IsPositive() && (GameTime::GetGameTimeMS() - TimeDelay) <= unit->m_lastSanctuaryTime) return; // No missinfo in that case if (_spellHitTarget) @@ -3606,7 +3606,7 @@ void Spell::cancel() if (m_spellState == SPELL_STATE_FINISHED) return; - uint32 oldState = m_spellState; + SpellState oldState = m_spellState; m_spellState = SPELL_STATE_FINISHED; m_autoRepeat = false; @@ -3615,12 +3615,11 @@ void Spell::cancel() case SPELL_STATE_PREPARING: CancelGlobalCooldown(); [[fallthrough]]; - case SPELL_STATE_DELAYED: + case SPELL_STATE_LAUNCHED: SendInterrupted(0); SendCastResult(SPELL_FAILED_INTERRUPTED); break; - - case SPELL_STATE_CASTING: + case SPELL_STATE_CHANNELING: for (TargetInfo const& targetInfo : m_UniqueTargetInfo) if (targetInfo.MissCondition == SPELL_MISS_NONE) if (Unit* unit = m_caster->GetGUID() == targetInfo.TargetGUID ? m_caster->ToUnit() : ObjectAccessor::GetUnit(*m_caster, targetInfo.TargetGUID)) @@ -3632,7 +3631,6 @@ void Spell::cancel() m_appliedMods.clear(); break; - default: break; } @@ -3885,7 +3883,7 @@ void Spell::_cast(bool skipCheck) // Okay, maps created, now prepare flags m_immediateHandled = false; - m_spellState = SPELL_STATE_DELAYED; + m_spellState = SPELL_STATE_LAUNCHED; SetDelayStart(0); if (Unit* unitCaster = m_caster->ToUnit()) @@ -4048,7 +4046,7 @@ void Spell::handle_immediate() if (duration != 0) { - m_spellState = SPELL_STATE_CASTING; + m_spellState = SPELL_STATE_CHANNELING; // GameObjects shouldn't cast channeled spells ASSERT_NOTNULL(m_caster->ToUnit())->AddInterruptMask(m_spellInfo->ChannelInterruptFlags, m_spellInfo->ChannelInterruptFlags2); } @@ -4080,7 +4078,7 @@ void Spell::handle_immediate() // Remove used for cast item if need (it can be already NULL after TakeReagents call TakeCastItem(); - if (m_spellState != SPELL_STATE_CASTING) + if (m_spellState != SPELL_STATE_CHANNELING) finish(); // successfully finish spell cast (not last in case autorepeat or channel spell) } @@ -4300,7 +4298,7 @@ void Spell::update(uint32 difftime) cast(!m_casttime); break; } - case SPELL_STATE_CASTING: + case SPELL_STATE_CHANNELING: { if (m_timer) { @@ -7267,7 +7265,7 @@ SpellCastResult Spell::CheckMovement() const if (m_spellInfo->InterruptFlags.HasFlag(SpellInterruptFlags::Movement)) return SPELL_FAILED_MOVING; } - else if (getState() == SPELL_STATE_CASTING) + else if (getState() == SPELL_STATE_CHANNELING) if (!m_spellInfo->IsMoveAllowedChannel()) return SPELL_FAILED_MOVING; } @@ -8107,7 +8105,7 @@ void Spell::DelayedChannel() if (!unitCaster) return; - if (m_spellState != SPELL_STATE_CASTING) + if (m_spellState != SPELL_STATE_CHANNELING) return; if (IsDelayableNoMore()) // Spells may only be delayed twice @@ -8455,7 +8453,7 @@ bool SpellEvent::Execute(uint64 e_time, uint32 p_time) // event will be re-added automatically at the end of routine) break; } - case SPELL_STATE_DELAYED: + case SPELL_STATE_LAUNCHED: { // first, check, if we have just started if (m_Spell->GetDelayStart() != 0) diff --git a/src/server/game/Spells/Spell.h b/src/server/game/Spells/Spell.h index 2c4f996d360..25f7283507d 100644 --- a/src/server/game/Spells/Spell.h +++ b/src/server/game/Spells/Spell.h @@ -238,12 +238,12 @@ struct SpellValue enum SpellState { - SPELL_STATE_NULL = 0, - SPELL_STATE_PREPARING = 1, - SPELL_STATE_CASTING = 2, - SPELL_STATE_FINISHED = 3, - SPELL_STATE_IDLE = 4, - SPELL_STATE_DELAYED = 5 + SPELL_STATE_NULL = 0, + SPELL_STATE_PREPARING = 1, + SPELL_STATE_LAUNCHED = 2, + SPELL_STATE_CHANNELING = 3, + SPELL_STATE_FINISHED = 4, + SPELL_STATE_IDLE = 5, }; enum SpellEffectHandleMode @@ -524,8 +524,8 @@ class TC_GAME_API Spell void Delayed(); void DelayedChannel(); - uint32 getState() const { return m_spellState; } - void setState(uint32 state) { m_spellState = state; } + SpellState getState() const { return m_spellState; } + void setState(SpellState state) { m_spellState = state; } void DoCreateItem(uint32 itemId, ItemContext context = ItemContext::NONE, std::vector<int32> const* bonusListIDs = nullptr); @@ -729,16 +729,6 @@ class TC_GAME_API Spell bool m_autoRepeat; uint8 m_runesState; - struct EmpowerData - { - Milliseconds MinHoldTime = 0ms; - std::vector<Milliseconds> StageDurations; - int32 CompletedStages = 0; - bool IsReleasedByClient = false; - bool IsReleased = false; - }; - std::unique_ptr<EmpowerData> m_empower; - uint8 m_delayAtDamageCount; bool IsDelayableNoMore() { @@ -749,6 +739,16 @@ class TC_GAME_API Spell return false; } + struct EmpowerData + { + Milliseconds MinHoldTime = 0ms; + std::vector<Milliseconds> StageDurations; + int32 CompletedStages = 0; + bool IsReleasedByClient = false; + bool IsReleased = false; + }; + std::unique_ptr<EmpowerData> m_empower; + // Delayed spells system uint64 m_delayStart; // time of spell delay start, filled by event handler, zero = just started uint64 m_delayMoment; // moment of next delay call, used internally @@ -948,7 +948,7 @@ class TC_GAME_API Spell SpellCastResult CanOpenLock(SpellEffectInfo const& effect, uint32 lockid, SkillType& skillid, int32& reqSkillValue, int32& skillValue); // ------------------------------------------- - uint32 m_spellState; + SpellState m_spellState; int32 m_timer; SpellEvent* _spellEvent; diff --git a/src/server/game/Spells/SpellEffects.cpp b/src/server/game/Spells/SpellEffects.cpp index 0018435dbf1..e8ce54b1afb 100644 --- a/src/server/game/Spells/SpellEffects.cpp +++ b/src/server/game/Spells/SpellEffects.cpp @@ -2923,7 +2923,7 @@ void Spell::EffectInterruptCast() { SpellInfo const* curSpellInfo = spell->m_spellInfo; // check if we can interrupt spell - if ((spell->getState() == SPELL_STATE_CASTING + if ((spell->getState() == SPELL_STATE_CHANNELING || (spell->getState() == SPELL_STATE_PREPARING && spell->GetCastTime() > 0.0f)) && curSpellInfo->CanBeInterrupted(m_caster, unitTarget)) { diff --git a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_yogg_saron.cpp b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_yogg_saron.cpp index f2e09b6605a..fabd012123b 100644 --- a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_yogg_saron.cpp +++ b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_yogg_saron.cpp @@ -2465,7 +2465,7 @@ class spell_yogg_saron_diminsh_power : public SpellScriptLoader // 64148 { PreventDefaultAction(); if (Spell* spell = GetTarget()->GetCurrentSpell(CURRENT_CHANNELED_SPELL)) - if (spell->getState() == SPELL_STATE_CASTING) + if (spell->getState() == SPELL_STATE_CHANNELING) GetTarget()->InterruptSpell(CURRENT_CHANNELED_SPELL); } diff --git a/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_leotheras_the_blind.cpp b/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_leotheras_the_blind.cpp index 0c6aa3f1fb5..f19b3d010f3 100644 --- a/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_leotheras_the_blind.cpp +++ b/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_leotheras_the_blind.cpp @@ -743,12 +743,7 @@ struct npc_greyheart_spellbinder : public ScriptedAI { if (Player* i_pl = itr->GetSource()) { - bool isCasting = false; - for (uint8 i = 0; i < CURRENT_MAX_SPELL; ++i) - if (i_pl->GetCurrentSpell(i)) - isCasting = true; - - if (isCasting) + if (i_pl->IsNonMeleeSpellCast(false, false, true)) { DoCast(i_pl, SPELL_EARTHSHOCK); break; |