mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-16 10:30:27 +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:
@@ -257,7 +257,7 @@ void Spell::EffectResurrectNew(SpellEffIndex effIndex)
|
||||
if (!unitTarget || unitTarget->IsAlive())
|
||||
return;
|
||||
|
||||
if (unitTarget->GetTypeId() != TYPEID_PLAYER)
|
||||
if (!unitTarget->IsPlayer())
|
||||
return;
|
||||
|
||||
if (!unitTarget->IsInWorld())
|
||||
@@ -435,7 +435,7 @@ void Spell::EffectSchoolDMG(SpellEffIndex effIndex)
|
||||
// Shadow Bite
|
||||
else if (m_spellInfo->SpellFamilyFlags[1] & 0x400000)
|
||||
{
|
||||
if (m_caster->GetTypeId() == TYPEID_UNIT && m_caster->IsPet())
|
||||
if (m_caster->IsCreature() && m_caster->IsPet())
|
||||
{
|
||||
if (Player* owner = m_caster->GetOwner()->ToPlayer())
|
||||
{
|
||||
@@ -776,7 +776,7 @@ void Spell::EffectDummy(SpellEffIndex effIndex)
|
||||
{
|
||||
sScriptMgr->OnDummyEffect(m_caster, m_spellInfo->Id, effIndex, gameObjTarget);
|
||||
}
|
||||
else if (unitTarget && unitTarget->GetTypeId() == TYPEID_UNIT)
|
||||
else if (unitTarget && unitTarget->IsCreature())
|
||||
{
|
||||
sScriptMgr->OnDummyEffect(m_caster, m_spellInfo->Id, effIndex, unitTarget->ToCreature());
|
||||
}
|
||||
@@ -2065,7 +2065,7 @@ void Spell::EffectOpenLock(SpellEffIndex effIndex)
|
||||
if (effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET)
|
||||
return;
|
||||
|
||||
if (m_caster->GetTypeId() != TYPEID_PLAYER)
|
||||
if (!m_caster->IsPlayer())
|
||||
{
|
||||
LOG_DEBUG("spells.aura", "WORLD: Open Lock - No Player Caster!");
|
||||
return;
|
||||
@@ -2182,7 +2182,7 @@ void Spell::EffectSummonChangeItem(SpellEffIndex effIndex)
|
||||
if (effectHandleMode != SPELL_EFFECT_HANDLE_HIT)
|
||||
return;
|
||||
|
||||
if (m_caster->GetTypeId() != TYPEID_PLAYER)
|
||||
if (!m_caster->IsPlayer())
|
||||
return;
|
||||
|
||||
Player* player = m_caster->ToPlayer();
|
||||
@@ -2291,7 +2291,7 @@ void Spell::EffectProficiency(SpellEffIndex /*effIndex*/)
|
||||
if (effectHandleMode != SPELL_EFFECT_HANDLE_HIT)
|
||||
return;
|
||||
|
||||
if (m_caster->GetTypeId() != TYPEID_PLAYER)
|
||||
if (!m_caster->IsPlayer())
|
||||
return;
|
||||
Player* p_target = m_caster->ToPlayer();
|
||||
|
||||
@@ -2524,7 +2524,7 @@ void Spell::EffectLearnSpell(SpellEffIndex effIndex)
|
||||
if (!unitTarget)
|
||||
return;
|
||||
|
||||
if (unitTarget->GetTypeId() != TYPEID_PLAYER)
|
||||
if (!unitTarget->IsPlayer())
|
||||
{
|
||||
if (unitTarget->ToPet())
|
||||
EffectLearnPetSpell(effIndex);
|
||||
@@ -2686,7 +2686,7 @@ void Spell::EffectPickPocket(SpellEffIndex /*effIndex*/)
|
||||
if (effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET)
|
||||
return;
|
||||
|
||||
if (m_caster->GetTypeId() != TYPEID_PLAYER)
|
||||
if (!m_caster->IsPlayer())
|
||||
return;
|
||||
|
||||
m_caster->ToPlayer()->SendLoot(unitTarget->GetGUID(), LOOT_PICKPOCKETING);
|
||||
@@ -2697,7 +2697,7 @@ void Spell::EffectAddFarsight(SpellEffIndex effIndex)
|
||||
if (effectHandleMode != SPELL_EFFECT_HANDLE_HIT)
|
||||
return;
|
||||
|
||||
if (m_caster->GetTypeId() != TYPEID_PLAYER)
|
||||
if (!m_caster->IsPlayer())
|
||||
return;
|
||||
|
||||
float radius = m_spellInfo->Effects[effIndex].CalcRadius();
|
||||
@@ -2751,7 +2751,7 @@ void Spell::EffectLearnSkill(SpellEffIndex effIndex)
|
||||
if (effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET)
|
||||
return;
|
||||
|
||||
if (unitTarget->GetTypeId() != TYPEID_PLAYER)
|
||||
if (!unitTarget->IsPlayer())
|
||||
return;
|
||||
|
||||
if (damage < 0)
|
||||
@@ -2767,7 +2767,7 @@ void Spell::EffectAddHonor(SpellEffIndex /*effIndex*/)
|
||||
if (effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET)
|
||||
return;
|
||||
|
||||
if (unitTarget->GetTypeId() != TYPEID_PLAYER)
|
||||
if (!unitTarget->IsPlayer())
|
||||
return;
|
||||
|
||||
// not scale value for item based reward (/10 value expected)
|
||||
@@ -2801,7 +2801,7 @@ void Spell::EffectTradeSkill(SpellEffIndex /*effIndex*/)
|
||||
if (effectHandleMode != SPELL_EFFECT_HANDLE_HIT)
|
||||
return;
|
||||
|
||||
if (m_caster->GetTypeId() != TYPEID_PLAYER)
|
||||
if (!m_caster->IsPlayer())
|
||||
return;
|
||||
// uint32 skillid = m_spellInfo->Effects[i].MiscValue;
|
||||
// uint16 skillmax = unitTarget->ToPlayer()->(skillid);
|
||||
@@ -2813,7 +2813,7 @@ void Spell::EffectEnchantItemPerm(SpellEffIndex effIndex)
|
||||
if (effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET)
|
||||
return;
|
||||
|
||||
if (m_caster->GetTypeId() != TYPEID_PLAYER)
|
||||
if (!m_caster->IsPlayer())
|
||||
return;
|
||||
if (!itemTarget)
|
||||
return;
|
||||
@@ -2869,7 +2869,7 @@ void Spell::EffectEnchantItemPrismatic(SpellEffIndex effIndex)
|
||||
if (effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET)
|
||||
return;
|
||||
|
||||
if (m_caster->GetTypeId() != TYPEID_PLAYER)
|
||||
if (!m_caster->IsPlayer())
|
||||
return;
|
||||
if (!itemTarget)
|
||||
return;
|
||||
@@ -2923,7 +2923,7 @@ void Spell::EffectEnchantItemTmp(SpellEffIndex effIndex)
|
||||
if (effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET)
|
||||
return;
|
||||
|
||||
if (m_caster->GetTypeId() != TYPEID_PLAYER)
|
||||
if (!m_caster->IsPlayer())
|
||||
return;
|
||||
|
||||
Player* p_caster = m_caster->ToPlayer();
|
||||
@@ -3070,7 +3070,7 @@ void Spell::EffectTameCreature(SpellEffIndex /*effIndex*/)
|
||||
if (!unitTarget)
|
||||
return;
|
||||
|
||||
if (unitTarget->GetTypeId() != TYPEID_UNIT)
|
||||
if (!unitTarget->IsCreature())
|
||||
return;
|
||||
|
||||
Creature* creatureTarget = unitTarget->ToCreature();
|
||||
@@ -3199,7 +3199,7 @@ void Spell::EffectSummonPet(SpellEffIndex effIndex)
|
||||
if (!pet)
|
||||
return;
|
||||
|
||||
if (m_caster->GetTypeId() == TYPEID_UNIT)
|
||||
if (m_caster->IsCreature())
|
||||
{
|
||||
if (m_caster->ToCreature()->IsTotem())
|
||||
pet->SetReactState(REACT_AGGRESSIVE);
|
||||
@@ -3831,7 +3831,7 @@ void Spell::EffectScriptEffect(SpellEffIndex effIndex)
|
||||
/*// Mug Transformation
|
||||
case 41931:
|
||||
{
|
||||
if (m_caster->GetTypeId() != TYPEID_PLAYER)
|
||||
if (!m_caster->IsPlayer())
|
||||
return;
|
||||
|
||||
uint8 bag = 19;
|
||||
@@ -3874,12 +3874,12 @@ void Spell::EffectScriptEffect(SpellEffIndex effIndex)
|
||||
}
|
||||
case 52173: // Coyote Spirit Despawn
|
||||
case 60243: // Blood Parrot Despawn
|
||||
if (unitTarget->GetTypeId() == TYPEID_UNIT && unitTarget->ToCreature()->IsSummon())
|
||||
if (unitTarget->IsCreature() && unitTarget->ToCreature()->IsSummon())
|
||||
unitTarget->ToTempSummon()->UnSummon();
|
||||
return;
|
||||
case 57347: // Retrieving (Wintergrasp RP-GG pickup spell)
|
||||
{
|
||||
if (!unitTarget || unitTarget->GetTypeId() != TYPEID_UNIT || m_caster->GetTypeId() != TYPEID_PLAYER)
|
||||
if (!unitTarget || !unitTarget->IsCreature() || !m_caster->IsPlayer())
|
||||
return;
|
||||
|
||||
unitTarget->ToCreature()->DespawnOrUnsummon();
|
||||
@@ -3888,7 +3888,7 @@ void Spell::EffectScriptEffect(SpellEffIndex effIndex)
|
||||
}
|
||||
case 57349: // Drop RP-GG (Wintergrasp RP-GG at death drop spell)
|
||||
{
|
||||
if (m_caster->GetTypeId() != TYPEID_PLAYER)
|
||||
if (!m_caster->IsPlayer())
|
||||
return;
|
||||
|
||||
// Delete item from inventory at death
|
||||
@@ -3899,7 +3899,7 @@ void Spell::EffectScriptEffect(SpellEffIndex effIndex)
|
||||
case 58418: // Portal to Orgrimmar
|
||||
case 58420: // Portal to Stormwind
|
||||
{
|
||||
if (!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER || effIndex != 0)
|
||||
if (!unitTarget || !unitTarget->IsPlayer() || effIndex != 0)
|
||||
return;
|
||||
|
||||
uint32 spellID = m_spellInfo->Effects[EFFECT_0].CalcValue();
|
||||
@@ -4041,7 +4041,7 @@ void Spell::EffectSanctuary(SpellEffIndex /*effIndex*/)
|
||||
if ((*iter)->GetCurrentSpell(i) && (*iter)->GetCurrentSpell(i)->m_targets.GetUnitTargetGUID() == unitTarget->GetGUID())
|
||||
{
|
||||
SpellInfo const* si = (*iter)->GetCurrentSpell(i)->GetSpellInfo();
|
||||
if (si->HasAttribute(SPELL_ATTR6_IGNORE_PHASE_SHIFT) && (*iter)->GetTypeId() == TYPEID_UNIT)
|
||||
if (si->HasAttribute(SPELL_ATTR6_IGNORE_PHASE_SHIFT) && (*iter)->IsCreature())
|
||||
{
|
||||
Creature* c = (*iter)->ToCreature();
|
||||
if ((!c->IsPet() && c->GetCreatureTemplate()->rank == CREATURE_ELITE_WORLDBOSS) || c->isWorldBoss() || c->IsDungeonBoss())
|
||||
@@ -4085,7 +4085,7 @@ void Spell::EffectDuel(SpellEffIndex effIndex)
|
||||
if (effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET)
|
||||
return;
|
||||
|
||||
if (!unitTarget || m_caster->GetTypeId() != TYPEID_PLAYER || unitTarget->GetTypeId() != TYPEID_PLAYER)
|
||||
if (!unitTarget || !m_caster->IsPlayer() || !unitTarget->IsPlayer())
|
||||
return;
|
||||
|
||||
Player* caster = m_caster->ToPlayer();
|
||||
@@ -4161,7 +4161,7 @@ void Spell::EffectStuck(SpellEffIndex /*effIndex*/)
|
||||
if (effectHandleMode != SPELL_EFFECT_HANDLE_HIT)
|
||||
return;
|
||||
|
||||
if (m_caster->GetTypeId() != TYPEID_PLAYER)
|
||||
if (!m_caster->IsPlayer())
|
||||
return;
|
||||
|
||||
Player* target = m_caster->ToPlayer();
|
||||
@@ -4311,7 +4311,7 @@ void Spell::EffectApplyGlyph(SpellEffIndex effIndex)
|
||||
if (effectHandleMode != SPELL_EFFECT_HANDLE_HIT)
|
||||
return;
|
||||
|
||||
if (m_caster->GetTypeId() != TYPEID_PLAYER || m_glyphIndex >= MAX_GLYPH_SLOT_INDEX)
|
||||
if (!m_caster->IsPlayer() || m_glyphIndex >= MAX_GLYPH_SLOT_INDEX)
|
||||
return;
|
||||
|
||||
Player* player = m_caster->ToPlayer();
|
||||
@@ -4770,7 +4770,7 @@ void Spell::EffectForceDeselect(SpellEffIndex /*effIndex*/)
|
||||
// xinef: we should also force pets to remove us from current target
|
||||
Unit::AttackerSet attackerSet;
|
||||
for (Unit::AttackerSet::const_iterator itr = m_caster->getAttackers().begin(); itr != m_caster->getAttackers().end(); ++itr)
|
||||
if ((*itr)->GetTypeId() == TYPEID_UNIT && !(*itr)->CanHaveThreatList())
|
||||
if ((*itr)->IsCreature() && !(*itr)->CanHaveThreatList())
|
||||
attackerSet.insert(*itr);
|
||||
|
||||
for (Unit::AttackerSet::const_iterator itr = attackerSet.begin(); itr != attackerSet.end(); ++itr)
|
||||
@@ -4801,7 +4801,7 @@ void Spell::EffectForceDeselect(SpellEffIndex /*effIndex*/)
|
||||
if (spell->m_targets.GetUnitTargetGUID() == m_caster->GetGUID())
|
||||
{
|
||||
SpellInfo const* si = spell->GetSpellInfo();
|
||||
if (si->HasAttribute(SPELL_ATTR6_IGNORE_PHASE_SHIFT) && (*iter)->GetTypeId() == TYPEID_UNIT)
|
||||
if (si->HasAttribute(SPELL_ATTR6_IGNORE_PHASE_SHIFT) && (*iter)->IsCreature())
|
||||
{
|
||||
Creature* c = (*iter)->ToCreature();
|
||||
if ((!c->IsPet() && c->GetCreatureTemplate()->rank == CREATURE_ELITE_WORLDBOSS) || c->isWorldBoss() || c->IsDungeonBoss())
|
||||
@@ -4832,7 +4832,7 @@ void Spell::EffectSelfResurrect(SpellEffIndex effIndex)
|
||||
|
||||
if (!m_caster || m_caster->IsAlive())
|
||||
return;
|
||||
if (m_caster->GetTypeId() != TYPEID_PLAYER)
|
||||
if (!m_caster->IsPlayer())
|
||||
return;
|
||||
if (!m_caster->IsInWorld())
|
||||
return;
|
||||
@@ -4870,9 +4870,9 @@ void Spell::EffectSkinning(SpellEffIndex /*effIndex*/)
|
||||
if (effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET)
|
||||
return;
|
||||
|
||||
if (unitTarget->GetTypeId() != TYPEID_UNIT)
|
||||
if (!unitTarget->IsCreature())
|
||||
return;
|
||||
if (m_caster->GetTypeId() != TYPEID_PLAYER)
|
||||
if (!m_caster->IsPlayer())
|
||||
return;
|
||||
|
||||
Creature* creature = unitTarget->ToCreature();
|
||||
@@ -5472,7 +5472,7 @@ void Spell::EffectProspecting(SpellEffIndex /*effIndex*/)
|
||||
if (effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET)
|
||||
return;
|
||||
|
||||
if (m_caster->GetTypeId() != TYPEID_PLAYER)
|
||||
if (!m_caster->IsPlayer())
|
||||
return;
|
||||
|
||||
Player* p_caster = m_caster->ToPlayer();
|
||||
@@ -5497,7 +5497,7 @@ void Spell::EffectMilling(SpellEffIndex /*effIndex*/)
|
||||
if (effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET)
|
||||
return;
|
||||
|
||||
if (m_caster->GetTypeId() != TYPEID_PLAYER)
|
||||
if (!m_caster->IsPlayer())
|
||||
return;
|
||||
|
||||
Player* p_caster = m_caster->ToPlayer();
|
||||
@@ -5535,7 +5535,7 @@ void Spell::EffectSpiritHeal(SpellEffIndex /*effIndex*/)
|
||||
return;
|
||||
|
||||
/*
|
||||
if (unitTarget->GetTypeId() != TYPEID_PLAYER)
|
||||
if (!unitTarget->IsPlayer())
|
||||
return;
|
||||
if (!unitTarget->IsInWorld())
|
||||
return;
|
||||
@@ -5554,7 +5554,7 @@ void Spell::EffectSkinPlayerCorpse(SpellEffIndex /*effIndex*/)
|
||||
return;
|
||||
|
||||
LOG_DEBUG("spells.aura", "Effect: SkinPlayerCorpse");
|
||||
if ((m_caster->GetTypeId() != TYPEID_PLAYER) || (unitTarget->GetTypeId() != TYPEID_PLAYER) || (unitTarget->IsAlive()))
|
||||
if ((!m_caster->IsPlayer()) || (!unitTarget->IsPlayer()) || (unitTarget->IsAlive()))
|
||||
return;
|
||||
|
||||
unitTarget->ToPlayer()->RemovedInsignia(m_caster->ToPlayer());
|
||||
@@ -5747,7 +5747,7 @@ void Spell::EffectActivateRune(SpellEffIndex effIndex)
|
||||
if (effectHandleMode != SPELL_EFFECT_HANDLE_LAUNCH)
|
||||
return;
|
||||
|
||||
if (m_caster->GetTypeId() != TYPEID_PLAYER)
|
||||
if (!m_caster->IsPlayer())
|
||||
return;
|
||||
|
||||
Player* player = m_caster->ToPlayer();
|
||||
@@ -5820,7 +5820,7 @@ void Spell::EffectCreateTamedPet(SpellEffIndex effIndex)
|
||||
if (effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET)
|
||||
return;
|
||||
|
||||
if (!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER || unitTarget->GetPetGUID() || !unitTarget->IsClass(CLASS_HUNTER, CLASS_CONTEXT_PET))
|
||||
if (!unitTarget || !unitTarget->IsPlayer() || unitTarget->GetPetGUID() || !unitTarget->IsClass(CLASS_HUNTER, CLASS_CONTEXT_PET))
|
||||
return;
|
||||
|
||||
uint32 creatureEntry = m_spellInfo->Effects[effIndex].MiscValue;
|
||||
@@ -6088,7 +6088,7 @@ void Spell::EffectRenamePet(SpellEffIndex /*effIndex*/)
|
||||
if (effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET)
|
||||
return;
|
||||
|
||||
if (!unitTarget || unitTarget->GetTypeId() != TYPEID_UNIT ||
|
||||
if (!unitTarget || !unitTarget->IsCreature() ||
|
||||
!unitTarget->IsPet() || unitTarget->ToPet()->getPetType() != HUNTER_PET)
|
||||
return;
|
||||
|
||||
@@ -6199,7 +6199,7 @@ void Spell::EffectCastButtons(SpellEffIndex effIndex)
|
||||
if (effectHandleMode != SPELL_EFFECT_HANDLE_HIT)
|
||||
return;
|
||||
|
||||
if (m_caster->GetTypeId() != TYPEID_PLAYER)
|
||||
if (!m_caster->IsPlayer())
|
||||
return;
|
||||
|
||||
Player* p_caster = m_caster->ToPlayer();
|
||||
@@ -6242,7 +6242,7 @@ void Spell::EffectRechargeManaGem(SpellEffIndex /*effIndex*/)
|
||||
if (effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET)
|
||||
return;
|
||||
|
||||
if (!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER)
|
||||
if (!unitTarget || !unitTarget->IsPlayer())
|
||||
return;
|
||||
|
||||
Player* player = m_caster->ToPlayer();
|
||||
@@ -6319,7 +6319,7 @@ void Spell::EffectSummonRaFFriend(SpellEffIndex /*effIndex*/)
|
||||
if (effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET)
|
||||
return;
|
||||
|
||||
if (m_caster->GetTypeId() != TYPEID_PLAYER)
|
||||
if (!m_caster->IsPlayer())
|
||||
return;
|
||||
|
||||
if (!unitTarget)
|
||||
|
||||
Reference in New Issue
Block a user