Jump to content

[10759][DEV] Correct resetting orientation when mob reachedHome


Schmoozerd

Recommended Posts

What bug does the patch fix? What features does the patch add?

- Ensure that SetOrientation actually changes the orientation that is sent in HeartBeat

- Ensures that Creature's homeposition is used properly when reaching home

For which repository revision was the patch created?

10720

Is there a thread in the bug report section or at lighthouse? If yes, please add a link to the thread.

no

Who has been writing this patch? Please include either forum user names or email addresses.

me

Example Creatures, where this makes a difference:

Entry: 19726 24436

Originally, I only was concerned about the orientation, and therefore I modified SetOrientation to actually change the orientation that is used in SendHeartBeat.

I think it is the right thing, that _if_ we change the orientation server-side, this change will be used on next heartBeat movement-information.

But after I was happy with the orientation I noticed that infact a mob after reaching home didn't have to be located _exactly_ (the first example mob), so I changed this to Relocate (which made the previous changes unneeded for _this_ problem), but I think this is reasonable.

Infact, if you wouldn't like the use of Relocate, then it is enough to add a SetFacing(data->orientation); at this place

diff --git a/src/game/HomeMovementGenerator.cpp b/src/game/HomeMovementGenerator.cpp
index ae7d3cd..baff821 100644
--- a/src/game/HomeMovementGenerator.cpp
+++ b/src/game/HomeMovementGenerator.cpp
@@ -72,9 +72,10 @@ HomeMovementGenerator<Creature>::Update(Creature &owner, const uint32& time_diff
        // restore orientation of not moving creature at returning to home
        if (owner.GetDefaultMovementType() == IDLE_MOTION_TYPE)
        {
+            // such a mob might need very exact spawning point, hence relocate to spawn-position
            if (CreatureData const* data = sObjectMgr.GetCreatureData(owner.GetDBTableGUIDLow()))
            {
-                owner.SetOrientation(data->orientation);
+                owner.Relocate(data->posX, data->posY, data->posZ, data->orientation);
                owner.SendHeartBeat(false);
            }
        }
diff --git a/src/game/Object.cpp b/src/game/Object.cpp
index f238218..107931f 100644
--- a/src/game/Object.cpp
+++ b/src/game/Object.cpp
@@ -1157,6 +1157,14 @@ void WorldObject::Relocate(float x, float y, float z)
        ((Unit*)this)->m_movementInfo.ChangePosition(x, y, z, GetOrientation());
}

+void WorldObject::SetOrientation(float orientation)
+{
+     m_orientation = orientation;
+
+     if(isType(TYPEMASK_UNIT))
+        ((Unit*)this)->m_movementInfo.ChangeOrientation(orientation);
+}
+
uint32 WorldObject::GetZoneId() const
{
    return GetBaseMap()->GetZoneId(m_positionX, m_positionY, m_positionZ);
diff --git a/src/game/Object.h b/src/game/Object.h
index 653b169..1d272e0 100644
--- a/src/game/Object.h
+++ b/src/game/Object.h
@@ -349,7 +349,7 @@ class MANGOS_DLL_SPEC WorldObject : public Object
        void Relocate(float x, float y, float z, float orientation);
        void Relocate(float x, float y, float z);

-        void SetOrientation(float orientation) { m_orientation = orientation; }
+        void SetOrientation(float orientation);

        float GetPositionX( ) const { return m_positionX; }
        float GetPositionY( ) const { return m_positionY; }
diff --git a/src/game/Unit.h b/src/game/Unit.h
index 28089ad..073b92e 100644
--- a/src/game/Unit.h
+++ b/src/game/Unit.h
@@ -791,6 +791,7 @@ class MovementInfo
        int8 GetTransportSeat() const { return t_seat; }
        uint32 GetTransportTime() const { return t_time; }
        uint32 GetFallTime() const { return fallTime; }
+        void ChangeOrientation(float o) { pos.o = o; }
        void ChangePosition(float x, float y, float z, float o) { pos.x = x; pos.y = y; pos.z = z; pos.o = o; }
        void UpdateTime(uint32 _time) { time = _time; }

Link to comment
Share on other sites

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. Privacy Policy Terms of Use