mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-17 19:05:42 +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:
@@ -606,7 +606,7 @@ class spell_dk_dancing_rune_weapon : public AuraScript
|
||||
|
||||
bool CheckProc(ProcEventInfo& eventInfo)
|
||||
{
|
||||
if (!eventInfo.GetActor() || !eventInfo.GetActionTarget() || !eventInfo.GetActionTarget()->IsAlive() || eventInfo.GetActor()->GetTypeId() != TYPEID_PLAYER)
|
||||
if (!eventInfo.GetActor() || !eventInfo.GetActionTarget() || !eventInfo.GetActionTarget()->IsAlive() || !eventInfo.GetActor()->IsPlayer())
|
||||
return false;
|
||||
|
||||
SpellInfo const* spellInfo = eventInfo.GetSpellInfo();
|
||||
|
||||
@@ -136,7 +136,7 @@ class spell_the_flag_of_ownership : public SpellScript
|
||||
void HandleScript(SpellEffIndex /*effIndex*/)
|
||||
{
|
||||
Unit* caster = GetCaster();
|
||||
if (!caster || caster->GetTypeId() != TYPEID_PLAYER)
|
||||
if (!caster || !caster->IsPlayer())
|
||||
return;
|
||||
Player* target = GetHitPlayer();
|
||||
if (!target)
|
||||
@@ -155,7 +155,7 @@ class spell_the_flag_of_ownership : public SpellScript
|
||||
{
|
||||
for( std::list<WorldObject*>::iterator itr = targets.begin(); itr != targets.end(); )
|
||||
{
|
||||
if ((*itr)->GetTypeId() != TYPEID_PLAYER || (*itr)->ToPlayer()->IsAlive())
|
||||
if (!(*itr)->IsPlayer() || (*itr)->ToPlayer()->IsAlive())
|
||||
{
|
||||
targets.erase(itr);
|
||||
itr = targets.begin();
|
||||
@@ -1835,7 +1835,7 @@ class spell_gen_feign_death_all_flags : public AuraScript
|
||||
target->SetUnitFlag2(UNIT_FLAG2_FEIGN_DEATH);
|
||||
target->SetUnitFlag(UNIT_FLAG_PREVENT_EMOTES_FROM_CHAT_TEXT);
|
||||
|
||||
if (target->GetTypeId() == TYPEID_UNIT)
|
||||
if (target->IsCreature())
|
||||
target->ToCreature()->SetReactState(REACT_PASSIVE);
|
||||
}
|
||||
|
||||
@@ -1846,7 +1846,7 @@ class spell_gen_feign_death_all_flags : public AuraScript
|
||||
target->RemoveUnitFlag2(UNIT_FLAG2_FEIGN_DEATH);
|
||||
target->RemoveUnitFlag(UNIT_FLAG_PREVENT_EMOTES_FROM_CHAT_TEXT);
|
||||
|
||||
if (target->GetTypeId() == TYPEID_UNIT)
|
||||
if (target->IsCreature())
|
||||
target->ToCreature()->InitializeReactState();
|
||||
}
|
||||
|
||||
@@ -1870,7 +1870,7 @@ class spell_gen_feign_death_no_dyn_flag : public AuraScript
|
||||
target->SetUnitFlag2(UNIT_FLAG2_FEIGN_DEATH);
|
||||
target->SetUnitFlag(UNIT_FLAG_PREVENT_EMOTES_FROM_CHAT_TEXT);
|
||||
|
||||
if (target->GetTypeId() == TYPEID_UNIT)
|
||||
if (target->IsCreature())
|
||||
target->ToCreature()->SetReactState(REACT_PASSIVE);
|
||||
}
|
||||
|
||||
@@ -1880,7 +1880,7 @@ class spell_gen_feign_death_no_dyn_flag : public AuraScript
|
||||
target->RemoveUnitFlag2(UNIT_FLAG2_FEIGN_DEATH);
|
||||
target->RemoveUnitFlag(UNIT_FLAG_PREVENT_EMOTES_FROM_CHAT_TEXT);
|
||||
|
||||
if (target->GetTypeId() == TYPEID_UNIT)
|
||||
if (target->IsCreature())
|
||||
target->ToCreature()->InitializeReactState();
|
||||
}
|
||||
|
||||
@@ -1903,7 +1903,7 @@ class spell_gen_feign_death_no_prevent_emotes : public AuraScript
|
||||
target->SetUnitFlag2(UNIT_FLAG2_FEIGN_DEATH);
|
||||
target->SetUnitFlag(UNIT_FLAG_PREVENT_EMOTES_FROM_CHAT_TEXT);
|
||||
|
||||
if (target->GetTypeId() == TYPEID_UNIT)
|
||||
if (target->IsCreature())
|
||||
target->ToCreature()->SetReactState(REACT_PASSIVE);
|
||||
}
|
||||
|
||||
@@ -1913,7 +1913,7 @@ class spell_gen_feign_death_no_prevent_emotes : public AuraScript
|
||||
target->RemoveUnitFlag2(UNIT_FLAG2_FEIGN_DEATH);
|
||||
target->RemoveUnitFlag(UNIT_FLAG_PREVENT_EMOTES_FROM_CHAT_TEXT);
|
||||
|
||||
if (target->GetTypeId() == TYPEID_UNIT)
|
||||
if (target->IsCreature())
|
||||
target->ToCreature()->InitializeReactState();
|
||||
}
|
||||
|
||||
@@ -1944,7 +1944,7 @@ class spell_gen_teleporting : public SpellScript
|
||||
void HandleScript(SpellEffIndex /* effIndex */)
|
||||
{
|
||||
Unit* target = GetHitUnit();
|
||||
if (target->GetTypeId() != TYPEID_PLAYER)
|
||||
if (!target->IsPlayer())
|
||||
return;
|
||||
|
||||
// return from top
|
||||
@@ -2504,7 +2504,7 @@ class spell_gen_vehicle_scaling_aura: public AuraScript
|
||||
|
||||
bool Load() override
|
||||
{
|
||||
return GetCaster() && GetCaster()->IsPlayer() && GetOwner()->GetTypeId() == TYPEID_UNIT;
|
||||
return GetCaster() && GetCaster()->IsPlayer() && GetOwner()->IsCreature();
|
||||
}
|
||||
|
||||
void CalculateAmount(AuraEffect const* /*aurEff*/, int32& amount, bool& /*canBeRecalculated*/)
|
||||
@@ -3729,7 +3729,7 @@ class spell_gen_despawn_self : public SpellScript
|
||||
|
||||
bool Load() override
|
||||
{
|
||||
return GetCaster()->GetTypeId() == TYPEID_UNIT;
|
||||
return GetCaster()->IsCreature();
|
||||
}
|
||||
|
||||
void HandleDummy(SpellEffIndex effIndex)
|
||||
|
||||
@@ -950,7 +950,7 @@ class spell_hun_tame_beast : public SpellScript
|
||||
SpellCastResult CheckCast()
|
||||
{
|
||||
Unit* caster = GetCaster();
|
||||
if (caster->GetTypeId() != TYPEID_PLAYER)
|
||||
if (!caster->IsPlayer())
|
||||
return SPELL_FAILED_DONT_REPORT;
|
||||
|
||||
Player* player = GetCaster()->ToPlayer();
|
||||
@@ -1136,7 +1136,7 @@ class spell_hun_volley_trigger : public SpellScript
|
||||
{
|
||||
if (Unit* pet = *itr)
|
||||
{
|
||||
if (pet->IsAlive() && pet->GetTypeId() == TYPEID_UNIT)
|
||||
if (pet->IsAlive() && pet->IsCreature())
|
||||
{
|
||||
pet->ToCreature()->AI()->OwnerAttacked(_target->ToUnit());
|
||||
}
|
||||
@@ -1295,7 +1295,7 @@ class spell_hun_bestial_wrath : public SpellScript
|
||||
SpellCastResult CheckCast()
|
||||
{
|
||||
Unit* caster = GetCaster();
|
||||
if (!caster || caster->GetTypeId() != TYPEID_PLAYER)
|
||||
if (!caster || !caster->IsPlayer())
|
||||
{
|
||||
return SPELL_FAILED_NO_VALID_TARGETS;
|
||||
}
|
||||
|
||||
@@ -401,7 +401,7 @@ class spell_item_lil_phylactery : public AuraScript
|
||||
|
||||
bool CheckProc(ProcEventInfo& eventInfo)
|
||||
{
|
||||
return eventInfo.GetActionTarget() && (eventInfo.GetActionTarget()->GetTypeId() != TYPEID_UNIT || eventInfo.GetActionTarget()->ToCreature()->isWorldBoss());
|
||||
return eventInfo.GetActionTarget() && (!eventInfo.GetActionTarget()->IsCreature() || eventInfo.GetActionTarget()->ToCreature()->isWorldBoss());
|
||||
}
|
||||
|
||||
void HandleProc(AuraEffect const* /*aurEff*/, ProcEventInfo& /*eventInfo*/)
|
||||
@@ -501,7 +501,7 @@ class spell_item_lil_xt : public SpellScript
|
||||
Creature* target = GetHitCreature();
|
||||
if (!target)
|
||||
return;
|
||||
if (GetCaster()->GetTypeId() == TYPEID_UNIT && GetCaster()->ToCreature()->AI())
|
||||
if (GetCaster()->IsCreature() && GetCaster()->ToCreature()->AI())
|
||||
GetCaster()->ToCreature()->AI()->Talk(2);
|
||||
target->DespawnOrUnsummon(500);
|
||||
}
|
||||
@@ -2291,7 +2291,7 @@ class spell_item_unsated_craving : public AuraScript
|
||||
bool CheckProc(ProcEventInfo& procInfo)
|
||||
{
|
||||
Unit* caster = procInfo.GetActor();
|
||||
if (!caster || caster->GetTypeId() != TYPEID_PLAYER)
|
||||
if (!caster || !caster->IsPlayer())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -2302,7 +2302,7 @@ class spell_item_unsated_craving : public AuraScript
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!target || target->GetTypeId() != TYPEID_UNIT || target->IsCritter() || target->IsSummon())
|
||||
if (!target || !target->IsCreature() || target->IsCritter() || target->IsSummon())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -884,7 +884,7 @@ class spell_mage_polymorph_cast_visual : public SpellScript
|
||||
void HandleDummy(SpellEffIndex /*effIndex*/)
|
||||
{
|
||||
if (Unit* target = GetCaster()->FindNearestCreature(NPC_AUROSALIA, 30.0f))
|
||||
if (target->GetTypeId() == TYPEID_UNIT)
|
||||
if (target->IsCreature())
|
||||
target->CastSpell(target, PolymorhForms[urand(0, 5)], true);
|
||||
}
|
||||
|
||||
|
||||
@@ -1021,7 +1021,7 @@ class spell_pal_righteous_defense : public SpellScript
|
||||
SpellCastResult CheckCast()
|
||||
{
|
||||
Unit* caster = GetCaster();
|
||||
if (caster->GetTypeId() != TYPEID_PLAYER)
|
||||
if (!caster->IsPlayer())
|
||||
return SPELL_FAILED_DONT_REPORT;
|
||||
|
||||
if (Unit* target = GetExplTargetUnit())
|
||||
|
||||
@@ -379,7 +379,7 @@ class spell_pri_lightwell : public SpellScript
|
||||
|
||||
bool Load() override
|
||||
{
|
||||
return GetCaster()->GetTypeId() == TYPEID_UNIT;
|
||||
return GetCaster()->IsCreature();
|
||||
}
|
||||
|
||||
void HandleScriptEffect(SpellEffIndex /* effIndex */)
|
||||
|
||||
@@ -691,7 +691,7 @@ class spell_q11653_youre_not_so_big_now : public SpellScript
|
||||
{
|
||||
PreventHitDefaultEffect(effIndex);
|
||||
Unit* target = GetHitUnit();
|
||||
if (!target || target->GetTypeId() != TYPEID_UNIT)
|
||||
if (!target || !target->IsCreature())
|
||||
return;
|
||||
|
||||
static uint32 const spellPlayer[5] =
|
||||
@@ -809,7 +809,7 @@ class spell_q1846_bending_shinbone : public SpellScript
|
||||
{
|
||||
Item* target = GetHitItem();
|
||||
Unit* caster = GetCaster();
|
||||
if (!target && caster->GetTypeId() != TYPEID_PLAYER)
|
||||
if (!target && !caster->IsPlayer())
|
||||
return;
|
||||
|
||||
uint32 const spellId = roll_chance_i(20) ? SPELL_BENDING_SHINBONE1 : SPELL_BENDING_SHINBONE2;
|
||||
@@ -1014,7 +1014,7 @@ class spell_q11396_11399_scourging_crystal_controller_dummy : public SpellScript
|
||||
void HandleDummy(SpellEffIndex /*effIndex*/)
|
||||
{
|
||||
if (Unit* target = GetHitUnit())
|
||||
if (target->GetTypeId() == TYPEID_UNIT)
|
||||
if (target->IsCreature())
|
||||
target->RemoveAurasDueToSpell(SPELL_FORCE_SHIELD_ARCANE_PURPLE_X3);
|
||||
}
|
||||
|
||||
@@ -1704,7 +1704,7 @@ class spell_q12277_wintergarde_mine_explosion : public SpellScript
|
||||
{
|
||||
if (Unit* caster = GetCaster())
|
||||
{
|
||||
if (caster->GetTypeId() == TYPEID_UNIT)
|
||||
if (caster->IsCreature())
|
||||
{
|
||||
if (Unit* owner = caster->GetOwner())
|
||||
{
|
||||
@@ -2018,7 +2018,7 @@ enum BearFlankMaster
|
||||
|
||||
bool Load() override
|
||||
{
|
||||
return GetCaster()->GetTypeId() == TYPEID_UNIT;
|
||||
return GetCaster()->IsCreature();
|
||||
}
|
||||
|
||||
void HandleScript(SpellEffIndex /*effIndex*/)
|
||||
@@ -2079,7 +2079,7 @@ class spell_q12690_burst_at_the_seams : public SpellScript
|
||||
|
||||
bool Load() override
|
||||
{
|
||||
return GetCaster()->GetTypeId() == TYPEID_UNIT;
|
||||
return GetCaster()->IsCreature();
|
||||
}
|
||||
|
||||
void HandleKnockBack(SpellEffIndex /*effIndex*/)
|
||||
|
||||
Reference in New Issue
Block a user