diff options
-rw-r--r-- | src/server/game/AI/CoreAI/PetAI.cpp | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/server/game/AI/CoreAI/PetAI.cpp b/src/server/game/AI/CoreAI/PetAI.cpp index a860c8152c5..b7fa3940a20 100644 --- a/src/server/game/AI/CoreAI/PetAI.cpp +++ b/src/server/game/AI/CoreAI/PetAI.cpp @@ -550,10 +550,14 @@ bool PetAI::CanAttack(Unit* target) return (me->IsWithinMeleeRange(target) || me->GetCharmInfo()->IsCommandAttack()); // Pets attacking something (or chasing) should only switch targets if owner tells them to - if (me->getVictim() && (me->getVictim() != target)) + if (me->getVictim() && me->getVictim() != target) { // Check if our owner selected this target and clicked "attack" - Unit* ownerTarget = me->GetCharmerOrOwner()->ToPlayer()->GetSelectedUnit(); + Unit* ownerTarget = NULL; + if (Player* owner = me->GetCharmerOrOwner()->ToPlayer()) + ownerTarget = owner->GetSelectedUnit(); + else + ownerTarget = me->GetCharmerOrOwner()->getVictim(); if (ownerTarget && me->GetCharmInfo()->IsCommandAttack()) return (target->GetGUID() == ownerTarget->GetGUID()); |