mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-18 16:38:42 +01:00
Core/AI: add missing checks on AssistPlayerInCombatAgainst
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user