fix(Core/AI): Ignore PvP flagged players for aggressive pets if owner is not PvP flagged. (#21922)
This commit is contained in:
parent
3baadd0637
commit
9ced420849
1 changed files with 14 additions and 1 deletions
|
|
@ -514,9 +514,22 @@ Unit* PetAI::SelectNextTarget(bool allowAutoSelect) const
|
|||
// To prevent aggressive pets from chain selecting targets and running off, we
|
||||
// only select a random target if certain conditions are met.
|
||||
if (allowAutoSelect)
|
||||
{
|
||||
if (!me->GetCharmInfo()->IsReturning() || me->GetCharmInfo()->IsFollowing() || me->GetCharmInfo()->IsAtStay())
|
||||
{
|
||||
if (Unit* nearTarget = me->ToCreature()->SelectNearestTargetInAttackDistance(MAX_AGGRO_RADIUS))
|
||||
return nearTarget;
|
||||
{
|
||||
if (nearTarget->IsPlayer() && nearTarget->ToPlayer()->IsPvP() && !owner->IsPvP()) // If owner is not PvP flagged and target is PvP flagged, do not attack
|
||||
{
|
||||
return nullptr; /// @todo: try for another target
|
||||
}
|
||||
else
|
||||
{
|
||||
return nearTarget;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Default - no valid targets
|
||||
return nullptr;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue