refactor(Core/Object): adds consistency in the use of type object check (#19671)

This commit is contained in:
Grimdhex
2024-08-25 14:57:37 +02:00
committed by GitHub
parent 61f3a631c3
commit 643362d697
189 changed files with 783 additions and 775 deletions

View File

@@ -1905,13 +1905,13 @@ bool Creature::CanStartAttack(Unit const* who) const
// This set of checks is should be done only for creatures
if ((IsImmuneToNPC() && who->GetTypeId() != TYPEID_PLAYER) || // flag is valid only for non player characters
(IsImmuneToPC() && who->GetTypeId() == TYPEID_PLAYER)) // immune to PC and target is a player, return false
(IsImmuneToPC() && who->IsPlayer())) // immune to PC and target is a player, return false
{
return false;
}
if (Unit* owner = who->GetOwner())
if (owner->GetTypeId() == TYPEID_PLAYER && IsImmuneToPC()) // immune to PC and target has player owner
if (owner->IsPlayer() && IsImmuneToPC()) // immune to PC and target has player owner
return false;
// Do not attack non-combat pets