aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/server/game/AI/ScriptedAI/ScriptedEscortAI.cpp17
-rw-r--r--src/server/game/AI/SmartScripts/SmartAI.cpp17
2 files changed, 30 insertions, 4 deletions
diff --git a/src/server/game/AI/ScriptedAI/ScriptedEscortAI.cpp b/src/server/game/AI/ScriptedAI/ScriptedEscortAI.cpp
index b4c2a640517..376aceba4ba 100644
--- a/src/server/game/AI/ScriptedAI/ScriptedEscortAI.cpp
+++ b/src/server/game/AI/ScriptedAI/ScriptedEscortAI.cpp
@@ -62,11 +62,24 @@ bool EscortAI::AssistPlayerInCombatAgainst(Unit* who)
if (!who->EnsureVictim()->GetCharmerOrOwnerPlayerOrPlayerItself())
return false;
- // never attack friendly
+ if (!who->isInAccessiblePlaceFor(me))
+ return false;
+
+ if (!CanAIAttack(who))
+ return false;
+
+ // we cannot attack in evade mode
+ if (me->IsInEvadeMode())
+ return false;
+
+ // or if enemy is in evade mode
+ if (who->GetTypeId() == TYPEID_UNIT && who->ToCreature()->IsInEvadeMode())
+ return false;
+
if (!me->IsValidAssistTarget(who->GetVictim()))
return false;
- // too far away and no free sight?
+ // too far away and no free sight
if (me->IsWithinDistInMap(who, GetMaxPlayerDistance()) && me->IsWithinLOSInMap(who))
{
me->EngageWithTarget(who);
diff --git a/src/server/game/AI/SmartScripts/SmartAI.cpp b/src/server/game/AI/SmartScripts/SmartAI.cpp
index b886f0d98ad..77a6ba642be 100644
--- a/src/server/game/AI/SmartScripts/SmartAI.cpp
+++ b/src/server/game/AI/SmartScripts/SmartAI.cpp
@@ -515,11 +515,24 @@ bool SmartAI::AssistPlayerInCombatAgainst(Unit* who)
if (!who->EnsureVictim()->GetCharmerOrOwnerPlayerOrPlayerItself())
return false;
- // never attack friendly
+ if (!who->isInAccessiblePlaceFor(me))
+ return false;
+
+ if (!CanAIAttack(who))
+ return false;
+
+ // we cannot attack in evade mode
+ if (me->IsInEvadeMode())
+ return false;
+
+ // or if enemy is in evade mode
+ if (who->GetTypeId() == TYPEID_UNIT && who->ToCreature()->IsInEvadeMode())
+ return false;
+
if (!me->IsValidAssistTarget(who->GetVictim()))
return false;
- // too far away and no free sight?
+ // too far away and no free sight
if (me->IsWithinDistInMap(who, SMART_MAX_AID_DIST) && me->IsWithinLOSInMap(who))
{
me->EngageWithTarget(who);