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

@@ -352,7 +352,7 @@ public:
void KilledUnit(Unit* victim) override
{
if (victim->GetTypeId() == TYPEID_PLAYER)
if (victim->IsPlayer())
Talk(SAY_KELESETH_KILL);
}
@@ -622,7 +622,7 @@ public:
void KilledUnit(Unit* victim) override
{
if (victim->GetTypeId() == TYPEID_PLAYER)
if (victim->IsPlayer())
Talk(SAY_TALDARAM_KILL);
}
@@ -916,7 +916,7 @@ public:
void KilledUnit(Unit* victim) override
{
if (victim->GetTypeId() == TYPEID_PLAYER)
if (victim->IsPlayer())
Talk(SAY_VALANAR_KILL);
}
@@ -1451,7 +1451,7 @@ class spell_blood_council_shadow_prison_aura : public AuraScript
void HandleDummyTick(AuraEffect const* aurEff)
{
if (GetTarget()->GetTypeId() == TYPEID_PLAYER && GetTarget()->isMoving())
if (GetTarget()->IsPlayer() && GetTarget()->isMoving())
{
GetTarget()->CastSpell(GetTarget(), SPELL_SHADOW_PRISON_DAMAGE, true, nullptr, aurEff);
}

View File

@@ -268,7 +268,7 @@ public:
void KilledUnit(Unit* victim) override
{
if (victim->GetTypeId() == TYPEID_PLAYER)
if (victim->IsPlayer())
Talk(SAY_KILL);
}

View File

@@ -341,7 +341,7 @@ public:
void KilledUnit(Unit* victim) override
{
if (victim->GetTypeId() == TYPEID_PLAYER)
if (victim->IsPlayer())
Talk(SAY_KILL);
}

View File

@@ -162,7 +162,7 @@ public:
void KilledUnit(Unit* victim) override
{
if (victim->GetTypeId() == TYPEID_PLAYER)
if (victim->IsPlayer())
Talk(SAY_KILL);
}

View File

@@ -2018,7 +2018,7 @@ class spell_igb_rocket_pack_useable_aura : public AuraScript
bool CheckAreaTarget(Unit* target)
{
return target->GetTypeId() == TYPEID_PLAYER && GetOwner()->GetInstanceScript()->GetBossState(DATA_ICECROWN_GUNSHIP_BATTLE) != DONE;
return target->IsPlayer() && GetOwner()->GetInstanceScript()->GetBossState(DATA_ICECROWN_GUNSHIP_BATTLE) != DONE;
}
void HandleApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
@@ -2571,7 +2571,7 @@ class spell_igb_on_gunship_deck_aura : public AuraScript
bool CheckAreaTarget(Unit* unit)
{
return unit->GetTypeId() == TYPEID_PLAYER;
return unit->IsPlayer();
}
void HandleApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)

View File

@@ -544,7 +544,7 @@ public:
void KilledUnit(Unit* victim) override
{
if (victim->GetTypeId() == TYPEID_PLAYER)
if (victim->IsPlayer())
Talk(SAY_KILL);
}

View File

@@ -285,13 +285,13 @@ public:
void KilledUnit(Unit* victim) override
{
if (victim->GetTypeId() == TYPEID_PLAYER)
if (victim->IsPlayer())
Talk(SAY_KILL);
}
void MoveInLineOfSight(Unit* who) override
{
if (!_introDone && me->IsAlive() && who->GetTypeId() == TYPEID_PLAYER && me->GetExactDist2dSq(who) <= 10000.0f) // 100*100, moveinlineofsight limited to 60yd anyway
if (!_introDone && me->IsAlive() && who->IsPlayer() && me->GetExactDist2dSq(who) <= 10000.0f) // 100*100, moveinlineofsight limited to 60yd anyway
{
Talk(SAY_ENTER_ZONE);
_introDone = true;

View File

@@ -333,7 +333,7 @@ public:
void KilledUnit(Unit* victim) override
{
if (victim->GetTypeId() == TYPEID_PLAYER)
if (victim->IsPlayer())
Talk(SAY_KILL);
}

View File

@@ -216,7 +216,7 @@ public:
void KilledUnit(Unit* victim) override
{
if (victim->GetTypeId() == TYPEID_PLAYER)
if (victim->IsPlayer())
Talk(SAY_KILL);
}

View File

@@ -361,7 +361,7 @@ public:
void KilledUnit(Unit* victim) override
{
if (victim->GetTypeId() == TYPEID_PLAYER)
if (victim->IsPlayer())
Talk(SAY_KILL);
}
@@ -488,7 +488,7 @@ public:
void SpellHitTarget(Unit* target, SpellInfo const* spell) override
{
if (target->GetTypeId() == TYPEID_PLAYER)
if (target->IsPlayer())
if (uint32 spellId = sSpellMgr->GetSpellIdForDifficulty(70127, me))
if (spellId == spell->Id)
if (Aura const* mysticBuffet = target->GetAura(spell->Id))
@@ -805,7 +805,7 @@ class spell_sindragosa_s_fury : public SpellScript
{
PreventHitDefaultEffect(effIndex);
if (!GetHitUnit()->IsAlive() || (GetHitUnit()->GetTypeId() == TYPEID_PLAYER && GetHitUnit()->ToPlayer()->IsGameMaster()) || !_targetCount)
if (!GetHitUnit()->IsAlive() || (GetHitUnit()->IsPlayer() && GetHitUnit()->ToPlayer()->IsGameMaster()) || !_targetCount)
return;
float resistance = float(GetHitUnit()->GetResistance(SpellSchoolMask(GetSpellInfo()->SchoolMask)));

View File

@@ -725,7 +725,7 @@ public:
void KilledUnit(Unit* victim) override
{
if (victim->GetTypeId() == TYPEID_PLAYER && !me->IsInEvadeMode() && _phase != PHASE_OUTRO && _lastTalkTimeKill + 5 < GameTime::GetGameTime().count())
if (victim->IsPlayer() && !me->IsInEvadeMode() && _phase != PHASE_OUTRO && _lastTalkTimeKill + 5 < GameTime::GetGameTime().count())
{
_lastTalkTimeKill = GameTime::GetGameTime().count();
Talk(SAY_LK_KILL);
@@ -2229,7 +2229,7 @@ public:
me->CastSpell(me, SPELL_RAGING_SPIRIT_VISUAL, true);
if (TempSummon* summon = me->ToTempSummon())
if (Unit* summoner = summon->GetSummonerUnit())
if (summoner->GetTypeId() == TYPEID_PLAYER && summoner->IsAlive() && !summoner->ToPlayer()->IsBeingTeleported() && summoner->FindMap() == me->GetMap())
if (summoner->IsPlayer() && summoner->IsAlive() && !summoner->ToPlayer()->IsBeingTeleported() && summoner->FindMap() == me->GetMap())
{
valid = true;
summoner->CastSpell(me, SPELL_RAGING_SPIRIT_VISUAL_CLONE, true);
@@ -2290,7 +2290,7 @@ public:
bool valid = false;
if (TempSummon* summon = me->ToTempSummon())
if (Unit* summoner = summon->GetSummonerUnit())
if (summoner->GetTypeId() == TYPEID_PLAYER && summoner->IsAlive() && !summoner->ToPlayer()->IsBeingTeleported() && summoner->FindMap() == me->GetMap())
if (summoner->IsPlayer() && summoner->IsAlive() && !summoner->ToPlayer()->IsBeingTeleported() && summoner->FindMap() == me->GetMap())
{
valid = true;
AttackStart(summoner);
@@ -2957,8 +2957,8 @@ public:
{
if (Unit* summoner = summ->GetSummonerUnit())
{
bool buff = _instance->GetBossState(DATA_THE_LICH_KING) == IN_PROGRESS && summoner->GetTypeId() == TYPEID_PLAYER && (!summoner->IsAlive() || summoner->ToPlayer()->IsBeingTeleported() || summoner->FindMap() != me->GetMap());
if (summoner->GetTypeId() == TYPEID_PLAYER && !summoner->ToPlayer()->IsBeingTeleported() && summoner->FindMap() == me->GetMap())
bool buff = _instance->GetBossState(DATA_THE_LICH_KING) == IN_PROGRESS && summoner->IsPlayer() && (!summoner->IsAlive() || summoner->ToPlayer()->IsBeingTeleported() || summoner->FindMap() != me->GetMap());
if (summoner->IsPlayer() && !summoner->ToPlayer()->IsBeingTeleported() && summoner->FindMap() == me->GetMap())
{
if (buff)
summoner->CastSpell((Unit*)nullptr, SPELL_HARVESTED_SOUL_LK_BUFF, true, nullptr, nullptr, _instance->GetGuidData(DATA_THE_LICH_KING));
@@ -2994,7 +2994,7 @@ public:
if (TempSummon* summ = me->ToTempSummon())
if (Unit* summoner = summ->GetSummonerUnit())
{
if (summoner->IsAlive() && summoner->GetTypeId() == TYPEID_PLAYER)
if (summoner->IsAlive() && summoner->IsPlayer())
{
summoner->CastSpell((Unit*)nullptr, SPELL_HARVEST_SOUL_VISUAL, true);
summoner->ExitVehicle(summoner);
@@ -3487,7 +3487,7 @@ public:
bool CanAIAttack(Unit const* target) const override
{
return me->GetReactState() == REACT_AGGRESSIVE && target->GetTypeId() == TYPEID_PLAYER && target->GetExactDistSq(495.708f, -2523.76f, 1049.95f) < 40.0f * 40.0f;
return me->GetReactState() == REACT_AGGRESSIVE && target->IsPlayer() && target->GetExactDistSq(495.708f, -2523.76f, 1049.95f) < 40.0f * 40.0f;
}
};

View File

@@ -551,7 +551,7 @@ public:
void AttackStart(Unit* target) override
{
if (target->GetTypeId() == TYPEID_PLAYER)
if (target->IsPlayer())
BossAI::AttackStart(target);
}
@@ -564,7 +564,7 @@ public:
bool CanAIAttack(Unit const* target) const override
{
return target->GetTypeId() == TYPEID_PLAYER;
return target->IsPlayer();
}
void JustReachedHome() override
@@ -599,7 +599,7 @@ public:
if (!threatList.empty())
for (ThreatContainer::StorageType::const_iterator itr = threatList.begin(); itr != threatList.end(); ++itr)
if (Unit* target = (*itr)->getTarget())
if (target->IsAlive() && target->GetTypeId() == TYPEID_PLAYER && me->GetExactDist(target) < 200.0f && !target->IsImmunedToDamageOrSchool(SPELL_SCHOOL_MASK_ALL))
if (target->IsAlive() && target->IsPlayer() && me->GetExactDist(target) < 200.0f && !target->IsImmunedToDamageOrSchool(SPELL_SCHOOL_MASK_ALL))
return;
EnterEvadeMode();
}

View File

@@ -1211,7 +1211,7 @@ public:
void KilledUnit(Unit* victim) override
{
if (victim->GetTypeId() == TYPEID_PLAYER)
if (victim->IsPlayer())
Talk(SAY_CAPTAIN_KILL);
}
@@ -1237,7 +1237,7 @@ public:
bool CanAIAttack(Unit const* target) const override
{
// do not see targets inside Frostwing Halls when we are not there
return (me->GetPositionY() > 2660.0f) == (target->GetPositionY() > 2660.0f) && (target->GetTypeId() == TYPEID_PLAYER || target->IsInCombat());
return (me->GetPositionY() > 2660.0f) == (target->GetPositionY() > 2660.0f) && (target->IsPlayer() || target->IsInCombat());
}
void EnterEvadeMode(EvadeReason why) override
@@ -2713,7 +2713,7 @@ public:
void MoveInLineOfSight(Unit* who) override
{
if (me->IsAlive() && !me->IsInCombat() && who->GetTypeId() == TYPEID_PLAYER && who->GetExactDist2d(me) < 35.0f)
if (me->IsAlive() && !me->IsInCombat() && who->IsPlayer() && who->GetExactDist2d(me) < 35.0f)
AttackStart(who);
}
@@ -3085,7 +3085,7 @@ public:
ScriptedAI::MoveInLineOfSight(who);
else
{
if (!me->IsInCombat() && who->GetTypeId() == TYPEID_PLAYER && me->GetExactDist2dSq(who) < 25.0f * 25.0f && me->CanSeeOrDetect(who) && me->IsValidAttackTarget(who))
if (!me->IsInCombat() && who->IsPlayer() && me->GetExactDist2dSq(who) < 25.0f * 25.0f && me->CanSeeOrDetect(who) && me->IsValidAttackTarget(who))
AttackStart(who);
}
}
@@ -3230,7 +3230,7 @@ public:
void MoveInLineOfSight(Unit* who) override
{
if (!_didWebBeam && who->GetTypeId() == TYPEID_PLAYER && me->GetExactDist2d(who) < 70.0f)
if (!_didWebBeam && who->IsPlayer() && me->GetExactDist2d(who) < 70.0f)
{
_didWebBeam = true;
float nx = me->GetPositionX();