Skip to content

Commit

Permalink
Core/Creature: Fix UNIT_FLAG_IMMUNE_TO_PC validity for player pets
Browse files Browse the repository at this point in the history
related to #14780 and #14744
  • Loading branch information
mik1893 committed Jun 26, 2015
1 parent 409c8e4 commit accab54
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/server/game/Entities/Creature/Creature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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

This comment has been minimized.

Copy link
@jackpoz

jackpoz Jun 26, 2015

Member

travis is reporting a build warning https://travis-ci.org/TrinityCore/TrinityCore/builds/68491667#L1082

|| (who->GetOwner() && who->GetOwner()->GetTypeId() == TYPEID_PLAYER && HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC)))

should fix it, moving a ) to the end

return false;

// Do not attack non-combat pets
if (who->GetTypeId() == TYPEID_UNIT && who->GetCreatureType() == CREATURE_TYPE_NON_COMBAT_PET)
return false;
Expand Down

0 comments on commit accab54

Please sign in to comment.