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

@@ -1784,7 +1784,7 @@ SpellCastResult SpellInfo::CheckTarget(Unit const* caster, WorldObject const* ta
if (caster != unitTarget)
{
if (caster->GetTypeId() == TYPEID_PLAYER)
if (caster->IsPlayer())
{
// Do not allow these spells to target creatures not tapped by us (Banish, Polymorph, many quest spells)
if (AttributesEx2 & SPELL_ATTR2_CANNOT_CAST_ON_TAPPED)
@@ -1880,14 +1880,14 @@ SpellCastResult SpellInfo::CheckTarget(Unit const* caster, WorldObject const* ta
if (!CheckTargetCreatureType(unitTarget))
{
if (target->GetTypeId() == TYPEID_PLAYER)
if (target->IsPlayer())
return SPELL_FAILED_TARGET_IS_PLAYER;
else
return SPELL_FAILED_BAD_TARGETS;
}
// check GM mode and GM invisibility - only for player casts (npc casts are controlled by AI) and negative spells
if (unitTarget != caster && (caster->IsControlledByPlayer() || !IsPositive()) && unitTarget->GetTypeId() == TYPEID_PLAYER)
if (unitTarget != caster && (caster->IsControlledByPlayer() || !IsPositive()) && unitTarget->IsPlayer())
{
if (!unitTarget->ToPlayer()->IsVisible())
return SPELL_FAILED_BM_OR_INVISGOD;
@@ -1974,7 +1974,7 @@ bool SpellInfo::CheckTargetCreatureType(Unit const* target) const
if (SpellFamilyName == SPELLFAMILY_WARLOCK && GetCategory() == 1179)
{
// not allow cast at player
if (target->GetTypeId() == TYPEID_PLAYER)
if (target->IsPlayer())
return false;
else
return true;