From accab5451d3e62739e4aa376d25bc6623f0d3c52 Mon Sep 17 00:00:00 2001 From: Mik1893 Date: Fri, 26 Jun 2015 16:52:40 +0200 Subject: [PATCH] Core/Creature: Fix UNIT_FLAG_IMMUNE_TO_PC validity for player pets related to #14780 and #14744 --- src/server/game/Entities/Creature/Creature.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/server/game/Entities/Creature/Creature.cpp b/src/server/game/Entities/Creature/Creature.cpp index a91bbf00735fb..3b9b6d9dfe816 100644 --- a/src/server/game/Entities/Creature/Creature.cpp +++ b/src/server/game/Entities/Creature/Creature.cpp @@ -1370,6 +1370,12 @@ bool Creature::CanStartAttack(Unit const* who, bool force) const if (IsCivilian()) return false; + // This set of checks is should be done only for creatures + if ((HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_NPC) && who->GetTypeId() != TYPEID_PLAYER) // flag is valid only for non player characters + || (HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC) && who->GetTypeId() == TYPEID_PLAYER) // immune to PC and target is a player, return false + || (who->GetOwner() && who->GetOwner()->GetTypeId() == TYPEID_PLAYER) && HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC)) // player pets are immune to pc as well + return false; + // Do not attack non-combat pets if (who->GetTypeId() == TYPEID_UNIT && who->GetCreatureType() == CREATURE_TYPE_NON_COMBAT_PET) return false;