mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2025-11-29 17:38:24 +08:00
fix(Core/AI): Ignore PvP flagged players for aggressive pets if owner is not PvP flagged. (#21922)
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user