From 9ced420849ae875e1d8d448505e474818925830c Mon Sep 17 00:00:00 2001 From: Benjamin Jackson <38561765+heyitsbench@users.noreply.github.com> Date: Mon, 21 Apr 2025 03:40:56 -0400 Subject: [PATCH] fix(Core/AI): Ignore PvP flagged players for aggressive pets if owner is not PvP flagged. (#21922) --- src/server/game/AI/CoreAI/PetAI.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/server/game/AI/CoreAI/PetAI.cpp b/src/server/game/AI/CoreAI/PetAI.cpp index 33fff5f74..59c39a9ee 100644 --- a/src/server/game/AI/CoreAI/PetAI.cpp +++ b/src/server/game/AI/CoreAI/PetAI.cpp @@ -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;