Core/Spells: greatly simplified spell focusing based on new attributes implementations and fixed up interrupt flag checks for movement based interrupts

This commit is contained in:
Ovahlord committed 2022-10-03 16:10:06 +02:00
1 parent 7d67f10f77
commit 09a1987286
2 files changed
+54 -54

No files matched your search

+14 -16
View File
@@ -3354,7 +3354,7 @@ SpellCastResult Spell::prepare(SpellCastTargets const& targets, AuraEffect const
else
m_casttime = m_spellInfo->CalcCastTime(m_caster->IsUnit() ? m_caster->ToUnit()->getLevel() : 0, this);
if (m_caster->IsUnit() && m_caster->ToUnit()->isMoving())
if (m_caster->IsPlayer() && m_caster->ToUnit()->isMoving())
{
result = CheckMovement();
if (result != SPELL_CAST_OK)
@@ -4044,7 +4044,7 @@ void Spell::update(uint32 difftime)
// check if the player caster has moved before the spell finished
// with the exception of spells affected with SPELL_AURA_CAST_WHILE_WALKING effect
if (m_timer != 0 && m_caster->IsUnit() && m_caster->ToUnit()->isMoving() && CheckMovement() != SPELL_CAST_OK)
if (m_timer != 0 && m_caster->IsPlayer() && m_caster->ToUnit()->isMoving() && CheckMovement() != SPELL_CAST_OK)
{
// if charmed by creature, trust the AI not to cheat and allow the cast to proceed
// @todo this is a hack, "creature" movesplines don't differentiate turning/moving right now
@@ -5012,6 +5012,8 @@ void Spell::SendChannelStart(uint32 duration)
packet.InterruptImmunities->Immunities = mechanicImmunityMask; // CastImmunities
}
m_timer = duration;
if (!m_targets.HasDst())
{
uint32 channelAuraMask = 0;
@@ -5064,12 +5066,11 @@ void Spell::SendChannelStart(uint32 duration)
}
m_caster->SendMessageToSet(packet.Write(), true);
m_timer = duration;
m_caster->SetUInt32Value(UNIT_CHANNEL_SPELL, m_spellInfo->Id);
if (Creature* creatureCaster = m_caster->ToCreature())
if (!creatureCaster->HasSpellFocus(this))
creatureCaster->SetSpellFocus(this, ObjectAccessor::GetWorldObject(*creatureCaster, unitCaster->GetChannelObjectGuid()));
m_caster->SetUInt32Value(UNIT_CHANNEL_SPELL, m_spellInfo->Id);
creatureCaster->SetSpellFocus(this, nullptr);
}
void Spell::SendResurrectRequest(Player* target)
@@ -6792,17 +6793,15 @@ SpellCastResult Spell::CheckMovement() const
{
if (!unitCaster->HasAuraTypeWithAffectMask(SPELL_AURA_CAST_WHILE_WALKING, m_spellInfo))
{
if (m_casttime)
if (getState() == SPELL_STATE_PREPARING)
{
if (m_spellInfo->InterruptFlags.HasFlag(SpellInterruptFlags::Movement))
return SPELL_FAILED_MOVING;
if (m_casttime > 0)
if (m_spellInfo->InterruptFlags.HasFlag(SpellInterruptFlags::Movement))
return SPELL_FAILED_MOVING;
}
else
{
// only fail channeled casts if they are instant but cannot be channeled while moving
if (m_spellInfo->IsChanneled() && !m_spellInfo->IsMoveAllowedChannel())
else if (getState() == SPELL_STATE_CASTING)
if (!m_spellInfo->IsMoveAllowedChannel())
return SPELL_FAILED_MOVING;
}
}
}
@@ -7772,8 +7771,7 @@ bool Spell::IsIgnoringCooldowns() const
bool Spell::IsFocusDisabled() const
{
return ((_triggeredCastFlags & TRIGGERED_IGNORE_SET_FACING) != 0
|| (m_spellInfo->IsChanneled() && !m_spellInfo->HasAttribute(SPELL_ATTR1_TRACK_TARGET_IN_CHANNEL)));
return (_triggeredCastFlags & TRIGGERED_IGNORE_SET_FACING) != 0;
}
bool Spell::IsProcDisabled() const