mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-30 09:03:47 +00:00
refactor(Core): Make more use of helpers. (#19835)
* Init. * Reword. * Update codestyle script. Co-Authored-By: Kitzunu <24550914+Kitzunu@users.noreply.github.com> * Add gameobject type ID check, reorder checks. * Add helper/codestyle check for unit type. * `IsUnit()` -> `IsCreature()` * Add `IsUnit()` method. * Use type mask. https: //github.com/TrinityCore/TrinityCore/commit/cc71da35b5dc74abf71f8691161525a23d870bb5 Co-Authored-By: Giacomo Pozzoni <giacomopoz@gmail.com> Co-Authored-By: Ovahlord <18347559+Ovahlord@users.noreply.github.com> * Replace instances of `isType` with `IsUnit`. --------- Co-authored-by: Kitzunu <24550914+Kitzunu@users.noreply.github.com> Co-authored-by: Giacomo Pozzoni <giacomopoz@gmail.com> Co-authored-by: Ovahlord <18347559+Ovahlord@users.noreply.github.com>
This commit is contained in:
@@ -343,7 +343,7 @@ public:
|
||||
|
||||
void DamageDealt(Unit* target, uint32& damage, DamageEffectType /*damageType*/) override
|
||||
{
|
||||
if (target->GetTypeId() != TYPEID_PLAYER)
|
||||
if (!target->IsPlayer())
|
||||
return;
|
||||
|
||||
if (damage > RAID_MODE<uint32>(23000, 25000, 23000, 25000))
|
||||
@@ -613,7 +613,7 @@ public:
|
||||
|
||||
void DamageDealt(Unit* target, uint32& damage, DamageEffectType /*damageType*/) override
|
||||
{
|
||||
if (target->GetTypeId() != TYPEID_PLAYER)
|
||||
if (!target->IsPlayer())
|
||||
return;
|
||||
|
||||
if (damage > RAID_MODE<uint32>(23000, 25000, 23000, 25000))
|
||||
@@ -907,7 +907,7 @@ public:
|
||||
|
||||
void DamageDealt(Unit* target, uint32& damage, DamageEffectType /*damageType*/) override
|
||||
{
|
||||
if (target->GetTypeId() != TYPEID_PLAYER)
|
||||
if (!target->IsPlayer())
|
||||
return;
|
||||
|
||||
if (damage > RAID_MODE<uint32>(23000, 25000, 23000, 25000))
|
||||
@@ -1102,7 +1102,7 @@ public:
|
||||
if (_introDone)
|
||||
return;
|
||||
|
||||
if (who->GetTypeId() != TYPEID_PLAYER || me->GetExactDist2d(who) > 100.0f)
|
||||
if (!who->IsPlayer() || me->GetExactDist2d(who) > 100.0f)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -1335,7 +1335,7 @@ public:
|
||||
|
||||
void DamageDealt(Unit* target, uint32& damage, DamageEffectType /*damageType*/) override
|
||||
{
|
||||
if (target->GetTypeId() != TYPEID_PLAYER)
|
||||
if (!target->IsPlayer())
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -1506,7 +1506,7 @@ class spell_taldaram_summon_flame_ball : public SpellScript
|
||||
|
||||
bool Load() override
|
||||
{
|
||||
if (GetCaster()->GetTypeId() != TYPEID_UNIT)
|
||||
if (!GetCaster()->IsCreature())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -1573,7 +1573,7 @@ class spell_valanar_kinetic_bomb_aura : public AuraScript
|
||||
void HandleDummyTick(AuraEffect const* /*aurEff*/)
|
||||
{
|
||||
Unit* target = GetTarget();
|
||||
if (target->GetTypeId() != TYPEID_UNIT)
|
||||
if (!target->IsCreature())
|
||||
return;
|
||||
|
||||
if (Creature* bomb = target->FindNearestCreature(NPC_KINETIC_BOMB, 1.0f, true))
|
||||
|
||||
@@ -823,7 +823,7 @@ class spell_blood_queen_vampiric_bite : public SpellScript
|
||||
return;
|
||||
}
|
||||
|
||||
if (GetCaster()->GetTypeId() != TYPEID_PLAYER || GetCaster()->GetMapId() != 631)
|
||||
if (!GetCaster()->IsPlayer() || GetCaster()->GetMapId() != 631)
|
||||
return;
|
||||
InstanceScript* instance = GetCaster()->GetInstanceScript();
|
||||
if (!instance || instance->GetBossState(DATA_BLOOD_QUEEN_LANA_THEL) != IN_PROGRESS)
|
||||
|
||||
@@ -1259,7 +1259,7 @@ class spell_deathbringer_boiling_blood : public SpellScript
|
||||
|
||||
bool Load() override
|
||||
{
|
||||
return GetCaster()->GetTypeId() == TYPEID_UNIT;
|
||||
return GetCaster()->IsCreature();
|
||||
}
|
||||
|
||||
void FilterTargets(std::list<WorldObject*>& targets)
|
||||
|
||||
@@ -290,13 +290,13 @@ class spell_festergut_pungent_blight : public SpellScript
|
||||
|
||||
bool Load() override
|
||||
{
|
||||
return GetCaster()->GetTypeId() == TYPEID_UNIT;
|
||||
return GetCaster()->IsCreature();
|
||||
}
|
||||
|
||||
void HandleScript(SpellEffIndex /*effIndex*/)
|
||||
{
|
||||
Unit* caster = GetCaster();
|
||||
if (caster->GetTypeId() != TYPEID_UNIT)
|
||||
if (!caster->IsCreature())
|
||||
return;
|
||||
|
||||
// Get Inhaled Blight id for our difficulty
|
||||
@@ -383,7 +383,7 @@ public:
|
||||
|
||||
bool OnCheck(Player* /*source*/, Unit* target, uint32 /*criteria_id*/) override
|
||||
{
|
||||
if (target && target->GetTypeId() == TYPEID_UNIT)
|
||||
if (target && target->IsCreature())
|
||||
return target->ToCreature()->AI()->GetData(DATA_INOCULATED_STACK) < 3;
|
||||
|
||||
return false;
|
||||
|
||||
@@ -602,7 +602,7 @@ public:
|
||||
Transport::PassengerSet const& passengers = t->GetStaticPassengers();
|
||||
for (Transport::PassengerSet::const_iterator itr = passengers.begin(); itr != passengers.end(); ++itr)
|
||||
{
|
||||
if ((*itr)->GetTypeId() != TYPEID_UNIT || (*itr)->GetEntry() != NPC_GUNSHIP_HULL)
|
||||
if (!(*itr)->IsCreature() || (*itr)->GetEntry() != NPC_GUNSHIP_HULL)
|
||||
continue;
|
||||
(*itr)->ToCreature()->CastSpell((*itr)->ToCreature(), explosionSpell, true);
|
||||
}
|
||||
@@ -615,7 +615,7 @@ public:
|
||||
Transport::PassengerSet const& passengers = t->GetStaticPassengers();
|
||||
for (Transport::PassengerSet::const_iterator itr = passengers.begin(); itr != passengers.end(); ++itr)
|
||||
{
|
||||
if ((*itr)->GetTypeId() != TYPEID_UNIT || (*itr)->GetEntry() != cannonEntry)
|
||||
if (!(*itr)->IsCreature() || (*itr)->GetEntry() != cannonEntry)
|
||||
continue;
|
||||
Creature* cannon = (*itr)->ToCreature();
|
||||
cannon->CastSpell(cannon, SPELL_EJECT_ALL_PASSENGERS, true);
|
||||
@@ -661,7 +661,7 @@ public:
|
||||
Transport::PassengerSet const& passengers = t->GetPassengers();
|
||||
for (Transport::PassengerSet::const_iterator itr = passengers.begin(); itr != passengers.end(); ++itr)
|
||||
{
|
||||
if ((*itr)->GetTypeId() != TYPEID_UNIT)
|
||||
if (!(*itr)->IsCreature())
|
||||
continue;
|
||||
Creature* c = (*itr)->ToCreature();
|
||||
if (c->GetEntry() == NPC_SKYBREAKER_MARINE || c->GetEntry() == NPC_SKYBREAKER_SERGEANT || c->GetEntry() == NPC_KOR_KRON_REAVER || c->GetEntry() == NPC_KOR_KRON_SERGEANT)
|
||||
@@ -2080,7 +2080,7 @@ class spell_igb_check_for_players : public SpellScript
|
||||
bool Load() override
|
||||
{
|
||||
_playerCount = 0;
|
||||
return GetCaster()->GetTypeId() == TYPEID_UNIT;
|
||||
return GetCaster()->IsCreature();
|
||||
}
|
||||
|
||||
void CountTargets(std::list<WorldObject*>& targets)
|
||||
@@ -2302,7 +2302,7 @@ class spell_igb_cannon_blast : public SpellScript
|
||||
|
||||
bool Load() override
|
||||
{
|
||||
return GetCaster()->GetTypeId() == TYPEID_UNIT;
|
||||
return GetCaster()->IsCreature();
|
||||
}
|
||||
|
||||
void CalculatePower()
|
||||
@@ -2467,7 +2467,7 @@ public:
|
||||
|
||||
bool operator()(WorldObject* unit)
|
||||
{
|
||||
return unit->GetTypeId() != TYPEID_PLAYER || unit->GetPositionZ() > 478.0f || !unit->GetTransport() || unit->GetTransport()->GetEntry() != _entry
|
||||
return !unit->IsPlayer() || unit->GetPositionZ() > 478.0f || !unit->GetTransport() || unit->GetTransport()->GetEntry() != _entry
|
||||
|| unit->GetMapHeight(unit->GetPhaseMask(), unit->GetPositionX(), unit->GetPositionY(), unit->GetPositionZ()) < 465.0f;
|
||||
}
|
||||
|
||||
|
||||
@@ -84,7 +84,7 @@ public:
|
||||
if (target->GetExactDist(_source) > 175.0f)
|
||||
return false;
|
||||
|
||||
if (target->GetTypeId() != TYPEID_PLAYER)
|
||||
if (!target->IsPlayer())
|
||||
return false;
|
||||
|
||||
if (target->GetPositionX() > -337.0f)
|
||||
@@ -415,7 +415,7 @@ public:
|
||||
{
|
||||
if (Unit* u = v->GetBase())
|
||||
{
|
||||
if (u->GetEntry() == NPC_BONE_SPIKE && u->GetTypeId() == TYPEID_UNIT)
|
||||
if (u->GetEntry() == NPC_BONE_SPIKE && u->IsCreature())
|
||||
{
|
||||
u->ToCreature()->AI()->DoAction(-1337);
|
||||
}
|
||||
|
||||
@@ -209,7 +209,7 @@ public:
|
||||
|
||||
bool operator()(Unit const* target) const
|
||||
{
|
||||
if (!me || !target || target->GetTypeId() != TYPEID_PLAYER)
|
||||
if (!me || !target || !target->IsPlayer())
|
||||
return false;
|
||||
|
||||
if (me->IsWithinCombatRange(target, 7.0f))
|
||||
@@ -952,7 +952,7 @@ class spell_putricide_unstable_experiment : public SpellScript
|
||||
void HandleScript(SpellEffIndex effIndex)
|
||||
{
|
||||
PreventHitDefaultEffect(effIndex);
|
||||
if (GetCaster()->GetTypeId() != TYPEID_UNIT)
|
||||
if (!GetCaster()->IsCreature())
|
||||
return;
|
||||
|
||||
Creature* creature = GetCaster()->ToCreature();
|
||||
@@ -1044,7 +1044,7 @@ class spell_putricide_ooze_channel : public SpellScript
|
||||
bool Load() override
|
||||
{
|
||||
_target = nullptr;
|
||||
return GetCaster()->GetTypeId() == TYPEID_UNIT;
|
||||
return GetCaster()->IsCreature();
|
||||
}
|
||||
|
||||
void SelectTarget(std::list<WorldObject*>& targets)
|
||||
@@ -1318,7 +1318,7 @@ class spell_putricide_mutation_init : public SpellScript
|
||||
if (!GetExplTargetUnit())
|
||||
return SPELL_FAILED_BAD_TARGETS;
|
||||
|
||||
if (GetExplTargetUnit()->GetTypeId() != TYPEID_PLAYER)
|
||||
if (!GetExplTargetUnit()->IsPlayer())
|
||||
return SPELL_FAILED_TARGET_NOT_PLAYER;
|
||||
|
||||
SpellCustomErrors extension = SPELL_CUSTOM_ERROR_NONE;
|
||||
|
||||
@@ -360,7 +360,7 @@ public:
|
||||
if (!summoner)
|
||||
return;
|
||||
|
||||
if (summoner->GetTypeId() != TYPEID_UNIT)
|
||||
if (!summoner->IsCreature())
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -651,7 +651,7 @@ class spell_rotface_large_ooze_combine : public SpellScript
|
||||
if (Creature* rotface = ObjectAccessor::GetCreature(*GetCaster(), instance->GetGuidData(DATA_ROTFACE)))
|
||||
if (rotface->IsAlive())
|
||||
{
|
||||
if (GetCaster()->GetTypeId() == TYPEID_UNIT)
|
||||
if (GetCaster()->IsCreature())
|
||||
GetCaster()->ToCreature()->AI()->Talk(EMOTE_UNSTABLE_EXPLOSION);
|
||||
rotface->AI()->Talk(SAY_UNSTABLE_EXPLOSION);
|
||||
}
|
||||
@@ -708,7 +708,7 @@ class spell_rotface_large_ooze_buff_combine : public SpellScript
|
||||
if (Creature* rotface = ObjectAccessor::GetCreature(*GetCaster(), instance->GetGuidData(DATA_ROTFACE)))
|
||||
if (rotface->IsAlive())
|
||||
{
|
||||
if (GetCaster()->GetTypeId() == TYPEID_UNIT)
|
||||
if (GetCaster()->IsCreature())
|
||||
GetCaster()->ToCreature()->AI()->Talk(EMOTE_UNSTABLE_EXPLOSION);
|
||||
rotface->AI()->Talk(SAY_UNSTABLE_EXPLOSION);
|
||||
}
|
||||
@@ -792,7 +792,7 @@ class spell_rotface_unstable_ooze_explosion_suicide_aura : public AuraScript
|
||||
{
|
||||
PreventDefaultAction();
|
||||
Unit* target = GetTarget();
|
||||
if (target->GetTypeId() != TYPEID_UNIT)
|
||||
if (!target->IsCreature())
|
||||
return;
|
||||
|
||||
target->SetVisible(false);
|
||||
|
||||
@@ -252,7 +252,7 @@ public:
|
||||
if (target->GetExactDist(_source) > 80.0f)
|
||||
return false;
|
||||
|
||||
if (target->GetTypeId() != TYPEID_PLAYER)
|
||||
if (!target->IsPlayer())
|
||||
return false;
|
||||
|
||||
if (target->HasAura(SPELL_FROST_IMBUED_BLADE))
|
||||
@@ -1154,7 +1154,7 @@ class spell_sindragosa_soul_preservation_aura : public AuraScript
|
||||
{
|
||||
s->CastSpell(s, 72466, true);
|
||||
s->RemoveAurasDueToSpell(72424);
|
||||
if (s->GetTypeId() == TYPEID_UNIT) s->ToCreature()->SetLootMode(3);
|
||||
if (s->IsCreature()) s->ToCreature()->SetLootMode(3);
|
||||
SetDuration(1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -386,7 +386,7 @@ public:
|
||||
return false;
|
||||
if (!target->IsAlive())
|
||||
return false;
|
||||
if (_playerOnly && target->GetTypeId() != TYPEID_PLAYER)
|
||||
if (_playerOnly && !target->IsPlayer())
|
||||
return false;
|
||||
if (_maxDist && _source->GetExactDist(target) > _maxDist)
|
||||
return false;
|
||||
@@ -412,7 +412,7 @@ public:
|
||||
return false;
|
||||
if (!target->IsAlive())
|
||||
return false;
|
||||
if (_playerOnly && target->GetTypeId() != TYPEID_PLAYER)
|
||||
if (_playerOnly && !target->IsPlayer())
|
||||
return false;
|
||||
if (target == _source->GetVictim())
|
||||
return false;
|
||||
@@ -446,7 +446,7 @@ public:
|
||||
return false;
|
||||
if (!target->IsAlive())
|
||||
return false;
|
||||
if (target->GetTypeId() != TYPEID_PLAYER)
|
||||
if (!target->IsPlayer())
|
||||
return false;
|
||||
if (_source->GetExactDist(target) > 100.0f)
|
||||
return false;
|
||||
@@ -600,7 +600,7 @@ public:
|
||||
|
||||
bool operator()(Unit* unit) const
|
||||
{
|
||||
if (!unit || unit->GetTypeId() != TYPEID_PLAYER || unit == _sourceObj || _sourceObj->GetVictim() == unit || !unit->isTargetableForAttack())
|
||||
if (!unit || !unit->IsPlayer() || unit == _sourceObj || _sourceObj->GetVictim() == unit || !unit->isTargetableForAttack())
|
||||
return false;
|
||||
if (unit->HasAura(SPELL_PLAGUE_AVOIDANCE) || unit->HasAura(SPELL_BOSS_HITTIN_YA_AURA) || unit->HasAura(_notAura1) || unit->HasAura(_notAura2))
|
||||
return false;
|
||||
@@ -2078,7 +2078,7 @@ class spell_the_lich_king_shadow_trap_periodic : public SpellScript
|
||||
GetCaster()->CastSpell((Unit*)nullptr, SPELL_SHADOW_TRAP_KNOCKBACK, true);
|
||||
if (Aura* a = GetCaster()->GetAura(SPELL_SHADOW_TRAP_AURA))
|
||||
a->SetDuration(0);
|
||||
if (GetCaster()->GetTypeId() == TYPEID_UNIT)
|
||||
if (GetCaster()->IsCreature())
|
||||
GetCaster()->ToCreature()->DespawnOrUnsummon(3000);
|
||||
}
|
||||
|
||||
@@ -2102,7 +2102,7 @@ class spell_the_lich_king_ice_burst_target_search : public SpellScript
|
||||
if (unitList.empty())
|
||||
return;
|
||||
|
||||
if (GetCaster()->GetTypeId() == TYPEID_UNIT)
|
||||
if (GetCaster()->IsCreature())
|
||||
GetCaster()->ToCreature()->AI()->DoAction(-1);
|
||||
}
|
||||
|
||||
@@ -2336,7 +2336,7 @@ class VehicleCheck
|
||||
public:
|
||||
bool operator()(WorldObject* unit)
|
||||
{
|
||||
return (unit->GetTypeId() != TYPEID_UNIT && unit->GetTypeId() != TYPEID_PLAYER) || unit->ToUnit()->GetVehicle();
|
||||
return (!unit->IsCreature() && !unit->IsPlayer()) || unit->ToUnit()->GetVehicle();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -2804,7 +2804,7 @@ class spell_the_lich_king_vile_spirit_move_target_search : public SpellScript
|
||||
bool Load() override
|
||||
{
|
||||
_target = nullptr;
|
||||
return GetCaster()->GetTypeId() == TYPEID_UNIT;
|
||||
return GetCaster()->IsCreature();
|
||||
}
|
||||
|
||||
void SelectTarget(std::list<WorldObject*>& targets)
|
||||
|
||||
@@ -967,7 +967,7 @@ public:
|
||||
bool CanAIAttack(Unit const* target) const override
|
||||
{
|
||||
// do not see targets inside Frostwing Halls when we are not there
|
||||
return target->GetTypeId() != TYPEID_PLAYER && (me->GetPositionY() > 2660.0f) == (target->GetPositionY() > 2660.0f) && target->GetEntry() != NPC_SINDRAGOSA;
|
||||
return !target->IsPlayer() && (me->GetPositionY() > 2660.0f) == (target->GetPositionY() > 2660.0f) && target->GetEntry() != NPC_SINDRAGOSA;
|
||||
}
|
||||
|
||||
private:
|
||||
@@ -1757,7 +1757,7 @@ public:
|
||||
|
||||
void SpellHitTarget(Unit* c, SpellInfo const* spell) override
|
||||
{
|
||||
if (spell->Id == 71306 && c->GetTypeId() == TYPEID_UNIT) // Twisted Winds
|
||||
if (spell->Id == 71306 && c->IsCreature()) // Twisted Winds
|
||||
{
|
||||
Position myPos = me->GetPosition();
|
||||
me->NearTeleportTo(c->GetPositionX(), c->GetPositionY(), c->GetPositionZ(), c->GetOrientation());
|
||||
|
||||
Reference in New Issue
Block a user