From 0a480f3ae824cbe7be51ff70a0d5711de04be9c1 Mon Sep 17 00:00:00 2001 From: Ovahlord Date: Mon, 21 Sep 2020 14:06:41 +0200 Subject: [PATCH] Core/Units: update internal facing of units on every update tick when a target guid or a tracking channeled spell is being used --- .../game/Entities/Creature/Creature.cpp | 4 ---- src/server/game/Entities/Unit/Unit.cpp | 21 +++++++++++++++++++ .../game/Spells/Auras/SpellAuraEffects.cpp | 9 -------- src/server/game/Spells/Spell.cpp | 5 ----- 4 files changed, 21 insertions(+), 18 deletions(-) diff --git a/src/server/game/Entities/Creature/Creature.cpp b/src/server/game/Entities/Creature/Creature.cpp index 3eb248ba41..19086e9eef 100644 --- a/src/server/game/Entities/Creature/Creature.cpp +++ b/src/server/game/Entities/Creature/Creature.cpp @@ -1111,11 +1111,7 @@ Unit* Creature::SelectVictim() return nullptr; if (target && _IsTargetAcceptable(target) && CanCreatureAttack(target)) - { - if (!HasSpellFocus()) - SetInFront(target); return target; - } /// @todo a vehicle may eat some mob, so mob should not evade if (GetVehicle()) diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index e9be0eca55..e4572c412a 100644 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -462,6 +462,27 @@ void Unit::Update(uint32 p_time) if (!IsInWorld()) return; + // Update server controlled facing for standing units + if (movespline->Finalized() && !isMoving()) + { + // Prioritize tracking channeled spells above unit targets if they should both be present at the same time. + Spell const* channeledSpell = GetCurrentSpell(CURRENT_CHANNELED_SPELL); + if (channeledSpell && channeledSpell->GetSpellInfo()->HasAttribute(SPELL_ATTR1_CHANNEL_TRACK_TARGET)) + { + ObjectGuid const channelGuid = GetChannelObjectGuid(); + if (!channelGuid.IsEmpty() && channelGuid != GetGUID()) + if (WorldObject const* objectTarget = ObjectAccessor::GetWorldObject(*this, channelGuid)) + SetOrientation(GetAngle(objectTarget)); // use SetOrientation instead of SetInFront because channeling may apply no turn unit states. + } + else + { + ObjectGuid const targetGuid = GetTarget(); + if (!targetGuid.IsEmpty() && targetGuid != GetGUID()) + if (WorldObject const* objectTarget = ObjectAccessor::GetWorldObject(*this, targetGuid)) + SetInFront(objectTarget); + } + } + _UpdateSpells(p_time); // If this is set during update SetCantProc(false) call is missing somewhere in the code diff --git a/src/server/game/Spells/Auras/SpellAuraEffects.cpp b/src/server/game/Spells/Auras/SpellAuraEffects.cpp index 5041e96799..d254a9a498 100644 --- a/src/server/game/Spells/Auras/SpellAuraEffects.cpp +++ b/src/server/game/Spells/Auras/SpellAuraEffects.cpp @@ -1032,15 +1032,6 @@ void AuraEffect::PeriodicTick(AuraApplication* aurApp, Unit* caster) const Unit* target = aurApp->GetTarget(); - // Update serverside orientation of tracking channeled auras on periodic update ticks - if (caster && m_spellInfo->IsChanneled() && m_spellInfo->HasAttribute(SPELL_ATTR1_CHANNEL_TRACK_TARGET)) - { - ObjectGuid const channelGuid = caster->GetChannelObjectGuid(); - if (!channelGuid.IsEmpty() && channelGuid != caster->GetGUID()) - if (WorldObject const* objectTarget = ObjectAccessor::GetWorldObject(*caster, channelGuid)) - caster->SetOrientation(caster->GetAngle(objectTarget)); - } - switch (GetAuraType()) { case SPELL_AURA_PERIODIC_DUMMY: diff --git a/src/server/game/Spells/Spell.cpp b/src/server/game/Spells/Spell.cpp index 8f6d292c98..593718414a 100644 --- a/src/server/game/Spells/Spell.cpp +++ b/src/server/game/Spells/Spell.cpp @@ -3536,11 +3536,6 @@ void Spell::_cast(bool skipCheck) } } - // The spell focusing is making sure that we have a valid cast targe guid when we need it so only check for a guid value here. - if (m_caster->IsCreature() && !m_caster->GetTarget().IsEmpty() && !m_caster->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_POSSESSED)) - if (WorldObject const* target = ObjectAccessor::GetUnit(*m_caster, m_caster->GetTarget())) - m_caster->SetInFront(target); - SelectSpellTargets(); // Spell may be finished after target map check