Core/Units: update internal facing of units on every update tick when a target guid or a tracking channeled spell is being used

This commit is contained in:
Ovahlord committed 2020-09-23 20:48:43 +02:00
1 parent 3e5ff77e0d
commit 0a480f3ae8
4 files changed
+21 -18

No files matched your search

+21
View File
@@ -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