diff options
Diffstat (limited to 'src/server/game/Spells/Spell.cpp')
-rw-r--r-- | src/server/game/Spells/Spell.cpp | 32 |
1 files changed, 12 insertions, 20 deletions
diff --git a/src/server/game/Spells/Spell.cpp b/src/server/game/Spells/Spell.cpp index 2cbfb94b1b7..2952294b8d4 100644 --- a/src/server/game/Spells/Spell.cpp +++ b/src/server/game/Spells/Spell.cpp @@ -3308,16 +3308,15 @@ SpellCastResult Spell::prepare(SpellCastTargets const& targets, AuraEffect const } } - // focus if not controlled creature - if (m_caster->GetTypeId() == TYPEID_UNIT && !m_caster->ToUnit()->HasUnitFlag(UNIT_FLAG_POSSESSED)) + // Creatures focus their target when possible + if (m_casttime && m_caster->IsCreature() && !m_spellInfo->IsNextMeleeSwingSpell() && !IsAutoRepeat() && !m_caster->ToUnit()->HasUnitFlag(UNIT_FLAG_POSSESSED)) { - if (!(m_spellInfo->IsNextMeleeSwingSpell() || IsAutoRepeat())) - { - if (m_targets.GetObjectTarget() && m_caster != m_targets.GetObjectTarget()) - m_caster->ToCreature()->SetSpellFocus(this, m_targets.GetObjectTarget()); - else if (m_spellInfo->HasAttribute(SPELL_ATTR5_DONT_TURN_DURING_CAST)) - m_caster->ToCreature()->SetSpellFocus(this, nullptr); - } + // Channeled spells and some triggered spells do not focus a cast target. They face their target later on via channel object guid and via spell attribute or not at all + bool const focusTarget = !m_spellInfo->IsChanneled() && !(_triggeredCastFlags & TRIGGERED_IGNORE_SET_FACING); + if (focusTarget && m_targets.GetObjectTarget() && m_caster != m_targets.GetObjectTarget()) + m_caster->ToCreature()->SetSpellFocus(this, m_targets.GetObjectTarget()); + else + m_caster->ToCreature()->SetSpellFocus(this, nullptr); } // set timer base at cast time @@ -3469,10 +3468,6 @@ void Spell::_cast(bool skipCheck) SetExecutedCurrently(true); - if (!(_triggeredCastFlags & TRIGGERED_IGNORE_SET_FACING)) - if (m_caster->GetTypeId() == TYPEID_UNIT && m_targets.GetObjectTarget() && m_caster != m_targets.GetObjectTarget()) - m_caster->ToCreature()->SetInFront(m_targets.GetObjectTarget()); - // Should this be done for original caster? Player* modOwner = m_caster->GetSpellModOwner(); if (modOwner) @@ -3554,13 +3549,10 @@ void Spell::_cast(bool skipCheck) } } } - - // if the spell allows the creature to turn while casting, then adjust server-side orientation to face the target now - // client-side orientation is handled by the client itself, as the cast target is targeted due to Creature::SetSpellFocusTarget - if (m_caster->GetTypeId() == TYPEID_UNIT && !m_caster->ToUnit()->HasUnitFlag(UNIT_FLAG_POSSESSED)) - if (!m_spellInfo->HasAttribute(SPELL_ATTR5_DONT_TURN_DURING_CAST)) - if (WorldObject* objTarget = m_targets.GetObjectTarget()) - m_caster->ToCreature()->SetInFront(objTarget); + // The spell focusing is making sure that we have a valid cast target guid when we need it so only check for a guid value here. + if (Creature* creatureCaster = m_caster->ToCreature()) + if (!creatureCaster->GetTarget().IsEmpty() && !creatureCaster->HasUnitFlag(UNIT_FLAG_POSSESSED)) + creatureCaster->SetInFront(ObjectAccessor::GetUnit(*creatureCaster, creatureCaster->GetTarget())); SelectSpellTargets(); |