diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp index 1f5307e9e..885b9f0b8 100644 --- a/src/game/Unit.cpp +++ b/src/game/Unit.cpp @@ -388,8 +388,8 @@ void Unit::SendMonsterMove(float NewPosX, float NewPosY, float NewPosZ, SplineTy data << float(0); data << float(0); break; - case SPLINETYPE_FACINGTARGET: // not used currently - data << uint64(0); // probably target guid (facing target?) + case SPLINETYPE_FACINGTARGET: + data << uint64(m_InteractionObject); // set in SetFacingToObject() break; case SPLINETYPE_FACINGANGLE: // not used currently data << float(0); // facing angle @@ -3515,6 +3515,24 @@ void Unit::SetFacingTo(float ori) SendMessageToSet(&data, false); } +// Consider move this to Creature:: since only creature appear to be able to use this +void Unit::SetFacingToObject(WorldObject* pObject) +{ + if (GetTypeId() != TYPEID_UNIT) + return; + + // never face when already moving + if (!IsStopped()) + return; + + m_InteractionObject = pObject->GetGUID(); + + // TODO: figure out under what conditions creature will move towards object instead of facing it where it currently is. + + SetOrientation(GetAngle(pObject)); + SendMonsterMove(GetPositionX(), GetPositionY(), GetPositionZ(), SPLINETYPE_FACINGTARGET, ((Creature*)this)->GetSplineFlags(), 0); +} + bool Unit::isInAccessablePlaceFor(Creature const* c) const { if(IsInWater()) diff --git a/src/game/Unit.h b/src/game/Unit.h index 04d88b66f..0cf35b7df 100644 --- a/src/game/Unit.h +++ b/src/game/Unit.h @@ -1581,7 +1581,7 @@ class MANGOS_DLL_SPEC Unit : public WorldObject void SetInFront(Unit const* target); void SetFacingTo(float ori); - void SetFacingToObject(WorldObject* pObject) { SetFacingTo(GetAngle(pObject)); } + void SetFacingToObject(WorldObject* pObject); // Visibility system UnitVisibility GetVisibility() const { return m_Visibility; } @@ -1842,6 +1842,8 @@ class MANGOS_DLL_SPEC Unit : public WorldObject uint32 m_regenTimer; uint32 m_lastManaUseTimer; + uint64 m_InteractionObject; + private: void CleanupDeletedAuras(); diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 3831476d2..4598174e2 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "9496" + #define REVISION_NR "9497" #endif // __REVISION_NR_H__