aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorShauren <shauren.trinity@gmail.com>2025-04-20 15:41:58 +0200
committerOvahlord <dreadkiller@gmx.de>2025-05-11 11:40:37 +0200
commitee79dd6d5dca51d6f6cebe8076d882cf7dc6117b (patch)
tree8adccb5d6de269795bc47909010dc63d730f7782 /src
parentde2d7a8bfd53784e967b1d8f9436a09b26ca4b45 (diff)
Core/Spells: Rename confusing SpellState enum values
* SPELL_STATE_CASTING -> SPELL_STATE_CHANNELING (was used for "channel in progress") * SPELL_STATE_DELAYED -> SPELL_STATE_LAUNCHED (cherry picked from commit 2e79d3524f12a525c337c5ce8d84b793cacd6e91)
Diffstat (limited to 'src')
-rw-r--r--src/server/game/Entities/Player/Player.cpp4
-rw-r--r--src/server/game/Entities/Unit/Unit.cpp26
-rw-r--r--src/server/game/Spells/Auras/SpellAuraEffects.cpp2
-rw-r--r--src/server/game/Spells/Spell.cpp24
-rw-r--r--src/server/game/Spells/Spell.h28
-rw-r--r--src/server/game/Spells/SpellEffects.cpp2
-rw-r--r--src/server/scripts/Northrend/Ulduar/Ulduar/boss_yogg_saron.cpp2
-rw-r--r--src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_leotheras_the_blind.cpp7
8 files changed, 49 insertions, 46 deletions
diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp
index 07119b7fabd..f3718505d18 100644
--- a/src/server/game/Entities/Player/Player.cpp
+++ b/src/server/game/Entities/Player/Player.cpp
@@ -24634,8 +24634,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 8cf3fa6af78..3ca60e94320 100644
--- a/src/server/game/Entities/Unit/Unit.cpp
+++ b/src/server/game/Entities/Unit/Unit.cpp
@@ -741,7 +741,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;
@@ -1137,7 +1137,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();
}
}
@@ -2894,12 +2894,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
}
}
@@ -3065,8 +3065,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())
@@ -3110,7 +3110,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())
{
@@ -3149,9 +3149,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;
}
@@ -4175,7 +4175,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 5ffb49b0bb7..7b7f31360b4 100644
--- a/src/server/game/Spells/Auras/SpellAuraEffects.cpp
+++ b/src/server/game/Spells/Auras/SpellAuraEffects.cpp
@@ -2557,7 +2557,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 8e7f2e6d6cf..c52543ec6d9 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)
@@ -3609,7 +3609,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;
@@ -3618,12 +3618,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))
@@ -3635,7 +3634,6 @@ void Spell::cancel()
m_appliedMods.clear();
break;
-
default:
break;
}
@@ -3888,7 +3886,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())
@@ -4028,7 +4026,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);
}
@@ -4060,7 +4058,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)
}
@@ -4280,7 +4278,7 @@ void Spell::update(uint32 difftime)
cast(!m_casttime);
break;
}
- case SPELL_STATE_CASTING:
+ case SPELL_STATE_CHANNELING:
{
if (m_timer)
{
@@ -7050,7 +7048,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;
}
@@ -7842,7 +7840,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
@@ -8173,7 +8171,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 a805d3db80d..48bd69d3cf7 100644
--- a/src/server/game/Spells/Spell.h
+++ b/src/server/game/Spells/Spell.h
@@ -235,12 +235,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
@@ -509,8 +509,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);
@@ -722,6 +722,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
@@ -919,7 +929,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 8e10a21c7bf..37165ab693f 100644
--- a/src/server/game/Spells/SpellEffects.cpp
+++ b/src/server/game/Spells/SpellEffects.cpp
@@ -2913,7 +2913,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;