From e69a483aa942c1c6c4bd9b5fa47139f89643b8d5 Mon Sep 17 00:00:00 2001 From: treeston Date: Fri, 9 Sep 2016 15:01:42 +0200 Subject: AI/SmartAI: Fix an issue where SmartAI creatures would not properly follow their owner on evade. Also fix a bug where creatures with INHABIT_ROOT would get stuck in evade under certain conditions. This allows us to fix quest 12261 (No Place to Run). Closes #16291. --- src/server/game/AI/SmartScripts/SmartAI.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'src/server/game/AI/SmartScripts') diff --git a/src/server/game/AI/SmartScripts/SmartAI.cpp b/src/server/game/AI/SmartScripts/SmartAI.cpp index 40f71d94632..3ce27ae0105 100644 --- a/src/server/game/AI/SmartScripts/SmartAI.cpp +++ b/src/server/game/AI/SmartScripts/SmartAI.cpp @@ -449,14 +449,17 @@ void SmartAI::EnterEvadeMode(EvadeReason /*why*/) AddEscortState(SMART_ESCORT_RETURNING); ReturnToLastOOCPos(); } - else if (mFollowGuid) + else if (Unit* target = mFollowGuid ? ObjectAccessor::GetUnit(*me, mFollowGuid) : nullptr) { - if (Unit* target = ObjectAccessor::GetUnit(*me, mFollowGuid)) - me->GetMotionMaster()->MoveFollow(target, mFollowDist, mFollowAngle); - + me->GetMotionMaster()->MoveFollow(target, mFollowDist, mFollowAngle); // evade is not cleared in MoveFollow, so we can't keep it me->ClearUnitState(UNIT_STATE_EVADE); } + else if (Unit* owner = me->GetCharmerOrOwner()) + { + me->GetMotionMaster()->MoveFollow(target, PET_FOLLOW_DIST, PET_FOLLOW_ANGLE); + me->ClearUnitState(UNIT_STATE_EVADE); + } else me->GetMotionMaster()->MoveTargetedHome(); -- cgit v1.2.3