aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/bindings/scripts/base/escort_ai.h2
-rw-r--r--src/game/CreatureAI.h1
-rw-r--r--src/game/Unit.cpp6
3 files changed, 6 insertions, 3 deletions
diff --git a/src/bindings/scripts/base/escort_ai.h b/src/bindings/scripts/base/escort_ai.h
index 44c244ab862..60e555dcfd4 100644
--- a/src/bindings/scripts/base/escort_ai.h
+++ b/src/bindings/scripts/base/escort_ai.h
@@ -72,6 +72,8 @@ struct TRINITY_DLL_DECL npc_escortAI : public ScriptedAI
void SetMaxPlayerDistance(float newMax) { MaxPlayerDistance = newMax; }
float GetMaxPlayerDistance() { return MaxPlayerDistance; }
+ bool IsEscorted() {return IsBeingEscorted;}
+
void SetCanMelee(bool usemelee) { CanMelee = usemelee; }
void SetDespawnAtEnd(bool despawn) { DespawnAtEnd = despawn; }
void SetDespawnAtFar(bool despawn) { DespawnAtFar = despawn; }
diff --git a/src/game/CreatureAI.h b/src/game/CreatureAI.h
index b47156f5876..791c4a96ca8 100644
--- a/src/game/CreatureAI.h
+++ b/src/game/CreatureAI.h
@@ -123,6 +123,7 @@ class TRINITY_DLL_SPEC CreatureAI : public UnitAI
// Called when the creature is target of hostile action: swing, hostile spell landed, fear/etc)
//virtual void AttackedBy(Unit* attacker);
+ virtual bool IsEscorted() {return false;}
// Called when creature is spawned or respawned (for reseting variables)
virtual void JustRespawned() { Reset(); }
diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp
index c6fd2e5c270..d37aa91373a 100644
--- a/src/game/Unit.cpp
+++ b/src/game/Unit.cpp
@@ -10528,9 +10528,9 @@ void Unit::SetInCombatState(bool PvP, Unit* enemy)
if(GetTypeId() != TYPEID_PLAYER)
{
// Set home position at place of engaging combat for escorted creatures
- //if(((Creature*)this)->IsAIEnabled)
- //if (((Creature *)this)->AI()->IsEscorted())
- ((Creature*)this)->SetHomePosition(GetPositionX(), GetPositionY(), GetPositionZ(), GetOrientation());
+ if((((Creature*)this)->IsAIEnabled && ((Creature*)this)->AI()->IsEscorted()) || ((Creature*)this)->GetMotionMaster()->GetCurrentMovementGeneratorType() == WAYPOINT_MOTION_TYPE)
+ ((Creature*)this)->SetHomePosition(GetPositionX(), GetPositionY(), GetPositionZ(), GetOrientation());
+
if(enemy)
{
if(((Creature*)this)->IsAIEnabled)