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

@@ -1543,7 +1543,7 @@ void AuraEffect::HandleModInvisibilityDetect(AuraApplication const* aurApp, uint
}
// call functions which may have additional effects after chainging state of unit
target->UpdateObjectVisibility(target->GetTypeId() == TYPEID_PLAYER || target->GetOwnerGUID().IsPlayer());
target->UpdateObjectVisibility(target->IsPlayer() || target->GetOwnerGUID().IsPlayer());
}
void AuraEffect::HandleModInvisibility(AuraApplication const* aurApp, uint8 mode, bool apply) const
@@ -1557,7 +1557,7 @@ void AuraEffect::HandleModInvisibility(AuraApplication const* aurApp, uint8 mode
if (apply)
{
// apply glow vision
if (target->GetTypeId() == TYPEID_PLAYER && (type == INVISIBILITY_GENERAL || type == INVISIBILITY_UNK10))
if (target->IsPlayer() && (type == INVISIBILITY_GENERAL || type == INVISIBILITY_UNK10))
target->SetByteFlag(PLAYER_FIELD_BYTES2, PLAYER_FIELD_BYTES_2_OFFSET_AURA_VISION, PLAYER_FIELD_BYTE2_INVISIBILITY_GLOW);
target->m_invisibility.AddFlag(type);
@@ -1569,7 +1569,7 @@ void AuraEffect::HandleModInvisibility(AuraApplication const* aurApp, uint8 mode
{
// if not have different invisibility auras.
// always remove glow vision
if (target->GetTypeId() == TYPEID_PLAYER)
if (target->IsPlayer())
target->RemoveByteFlag(PLAYER_FIELD_BYTES2, 3, PLAYER_FIELD_BYTE2_INVISIBILITY_GLOW);
target->m_invisibility.DelFlag(type);
@@ -1592,7 +1592,7 @@ void AuraEffect::HandleModInvisibility(AuraApplication const* aurApp, uint8 mode
// if not have invisibility auras of type INVISIBILITY_GENERAL
// remove glow vision
if (target->GetTypeId() == TYPEID_PLAYER && !target->m_invisibility.HasFlag(INVISIBILITY_GENERAL) && !target->m_invisibility.HasFlag(INVISIBILITY_UNK10))
if (target->IsPlayer() && !target->m_invisibility.HasFlag(INVISIBILITY_GENERAL) && !target->m_invisibility.HasFlag(INVISIBILITY_UNK10))
{
target->RemoveByteFlag(PLAYER_FIELD_BYTES2, PLAYER_FIELD_BYTES_2_OFFSET_AURA_VISION, PLAYER_FIELD_BYTE2_INVISIBILITY_GLOW);
}
@@ -1609,7 +1609,7 @@ void AuraEffect::HandleModInvisibility(AuraApplication const* aurApp, uint8 mode
target->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_IMMUNE_OR_LOST_SELECTION);
}
target->UpdateObjectVisibility(target->GetTypeId() == TYPEID_PLAYER || target->GetOwnerGUID().IsPlayer() || target->GetMap()->Instanceable(), true);
target->UpdateObjectVisibility(target->IsPlayer() || target->GetOwnerGUID().IsPlayer() || target->GetMap()->Instanceable(), true);
target->bRequestForcedVisibilityUpdate = false;
}
@@ -1635,7 +1635,7 @@ void AuraEffect::HandleModStealthDetect(AuraApplication const* aurApp, uint8 mod
}
// call functions which may have additional effects after chainging state of unit
target->UpdateObjectVisibility(target->GetTypeId() == TYPEID_PLAYER || target->GetOwnerGUID().IsPlayer());
target->UpdateObjectVisibility(target->IsPlayer() || target->GetOwnerGUID().IsPlayer());
}
void AuraEffect::HandleModStealth(AuraApplication const* aurApp, uint8 mode, bool apply) const
@@ -1652,7 +1652,7 @@ void AuraEffect::HandleModStealth(AuraApplication const* aurApp, uint8 mode, boo
target->m_stealth.AddValue(type, GetAmount());
target->SetStandFlags(UNIT_STAND_FLAGS_CREEP);
if (target->GetTypeId() == TYPEID_PLAYER)
if (target->IsPlayer())
target->SetByteFlag(PLAYER_FIELD_BYTES2, 3, PLAYER_FIELD_BYTE2_STEALTH);
// interrupt autoshot
@@ -1671,7 +1671,7 @@ void AuraEffect::HandleModStealth(AuraApplication const* aurApp, uint8 mode, boo
target->m_stealth.DelFlag(type);
target->RemoveStandFlags(UNIT_STAND_FLAGS_CREEP);
if (target->GetTypeId() == TYPEID_PLAYER)
if (target->IsPlayer())
target->RemoveByteFlag(PLAYER_FIELD_BYTES2, 3, PLAYER_FIELD_BYTE2_STEALTH);
}
}
@@ -1683,7 +1683,7 @@ void AuraEffect::HandleModStealth(AuraApplication const* aurApp, uint8 mode, boo
target->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_IMMUNE_OR_LOST_SELECTION);
}
target->UpdateObjectVisibility(target->GetTypeId() == TYPEID_PLAYER || target->GetOwnerGUID().IsPlayer() || target->GetMap()->Instanceable(), true);
target->UpdateObjectVisibility(target->IsPlayer() || target->GetOwnerGUID().IsPlayer() || target->GetMap()->Instanceable(), true);
target->bRequestForcedVisibilityUpdate = false;
}
@@ -1701,7 +1701,7 @@ void AuraEffect::HandleModStealthLevel(AuraApplication const* aurApp, uint8 mode
target->m_stealth.AddValue(type, -GetAmount());
// call functions which may have additional effects after chainging state of unit
target->UpdateObjectVisibility(target->GetTypeId() == TYPEID_PLAYER || target->GetOwnerGUID().IsPlayer());
target->UpdateObjectVisibility(target->IsPlayer() || target->GetOwnerGUID().IsPlayer());
}
void AuraEffect::HandleDetectAmore(AuraApplication const* aurApp, uint8 mode, bool apply) const
@@ -2065,7 +2065,7 @@ void AuraEffect::HandleAuraModShapeshift(AuraApplication const* aurApp, uint8 mo
Rage_val += aurEff->GetAmount() * 10;
}
// Stance mastery + Tactical mastery (both passive, and last have aura only in defense stance, but need apply at any stance switch)
if (target->GetTypeId() == TYPEID_PLAYER)
if (target->IsPlayer())
{
// Stance mastery - trainer spell
PlayerSpellMap const& sp_list = target->ToPlayer()->GetSpellMap();
@@ -2104,7 +2104,7 @@ void AuraEffect::HandleAuraModShapeshift(AuraApplication const* aurApp, uint8 mo
// add/remove the shapeshift aura's boosts
HandleShapeshiftBoosts(target, apply);
if (target->GetTypeId() == TYPEID_PLAYER)
if (target->IsPlayer())
target->ToPlayer()->InitDataForForm();
if (target->IsClass(CLASS_DRUID, CLASS_CONTEXT_ABILITY))
@@ -2142,7 +2142,7 @@ void AuraEffect::HandleAuraModShapeshift(AuraApplication const* aurApp, uint8 mo
if (apply && aurApp->GetRemoveMode())
return;
if (target->GetTypeId() == TYPEID_PLAYER)
if (target->IsPlayer())
{
SpellShapeshiftFormEntry const* shapeInfo = sSpellShapeshiftFormStore.LookupEntry(form);
// Learn spells for shapeshift form - no need to send action bars or add spells to spellbook
@@ -2730,7 +2730,7 @@ void AuraEffect::HandleAuraTransform(AuraApplication const* aurApp, uint8 mode,
target->setTransForm(GetId());
// polymorph case
if ((mode & AURA_EFFECT_HANDLE_REAL) && target->GetTypeId() == TYPEID_PLAYER && target->IsPolymorphed())
if ((mode & AURA_EFFECT_HANDLE_REAL) && target->IsPlayer() && target->IsPolymorphed())
{
// for players, start regeneration after 1s (in polymorph fast regeneration case)
// only if caster is Player (after patch 2.4.2)
@@ -2991,7 +2991,7 @@ void AuraEffect::HandleAuraModDisarm(AuraApplication const* aurApp, uint8 mode,
target->RemoveFlag(field, flag);
// Handle damage modification, shapeshifted druids are not affected
if (target->GetTypeId() == TYPEID_PLAYER && (!target->IsInFeralForm() || target->GetShapeshiftForm() == FORM_GHOSTWOLF))
if (target->IsPlayer() && (!target->IsInFeralForm() || target->GetShapeshiftForm() == FORM_GHOSTWOLF))
{
if (Item* pItem = target->ToPlayer()->GetItemByPos(INVENTORY_SLOT_BAG_0, slot))
{
@@ -3087,7 +3087,7 @@ void AuraEffect::HandleAuraAllowOnlyAbility(AuraApplication const* aurApp, uint8
Unit* target = aurApp->GetTarget();
if (target->GetTypeId() == TYPEID_PLAYER)
if (target->IsPlayer())
{
if (apply)
target->ToPlayer()->SetPlayerFlag(PLAYER_ALLOW_ONLY_ABILITY);
@@ -3174,7 +3174,7 @@ void AuraEffect::HandleAuraModStalked(AuraApplication const* aurApp, uint8 mode,
}
// call functions which may have additional effects after chainging state of unit
target->UpdateObjectVisibility(target->GetTypeId() == TYPEID_PLAYER);
target->UpdateObjectVisibility(target->IsPlayer());
}
void AuraEffect::HandleAuraUntrackable(AuraApplication const* aurApp, uint8 mode, bool apply) const
@@ -3366,7 +3366,7 @@ void AuraEffect::HandleAuraFeatherFall(AuraApplication const* aurApp, uint8 mode
target->SetFeatherFall(apply);
// start fall from current height
if (!apply && target->GetTypeId() == TYPEID_PLAYER)
if (!apply && target->IsPlayer())
target->ToPlayer()->SetFallInformation(GameTime::GetGameTime().count(), target->GetPositionZ());
}
@@ -3400,7 +3400,7 @@ void AuraEffect::HandleWaterBreathing(AuraApplication const* aurApp, uint8 mode,
Unit* target = aurApp->GetTarget();
// update timers in client
if (target->GetTypeId() == TYPEID_PLAYER)
if (target->IsPlayer())
target->ToPlayer()->UpdateMirrorTimers();
}
@@ -3526,7 +3526,7 @@ void AuraEffect::HandlePreventFleeing(AuraApplication const* aurApp, uint8 mode,
Unit* target = aurApp->GetTarget();
// Since patch 3.0.2 this mechanic no longer affects fear effects. It will ONLY prevent humanoids from fleeing due to low health.
if (target->GetTypeId() == TYPEID_PLAYER || !apply || target->HasAuraType(SPELL_AURA_MOD_FEAR))
if (target->IsPlayer() || !apply || target->HasAuraType(SPELL_AURA_MOD_FEAR))
return;
/// @todo: find a way to cancel fleeing for assistance.
/// Currently this will only stop creatures fleeing due to low health that could not find nearby allies to flee towards.
@@ -3733,7 +3733,7 @@ void AuraEffect::HandleAuraModIncreaseFlightSpeed(AuraApplication const* aurApp,
if (mode & AURA_EFFECT_HANDLE_REAL)
{
//Players on flying mounts must be immune to polymorph
if (target->GetTypeId() == TYPEID_PLAYER)
if (target->IsPlayer())
target->ApplySpellImmune(GetId(), IMMUNITY_MECHANIC, MECHANIC_POLYMORPH, apply);
// Dragonmaw Illusion (overwrite mount model, mounted aura already applied)
@@ -4327,7 +4327,7 @@ void AuraEffect::HandleAuraModResistanceExclusive(AuraApplication const* aurApp,
{
float value = float(GetAmount() - amount);
target->HandleStatModifier(UnitMods(UNIT_MOD_RESISTANCE_START + x), BASE_VALUE, value, apply);
if (target->GetTypeId() == TYPEID_PLAYER)
if (target->IsPlayer())
target->ApplyResistanceBuffModsMod(SpellSchools(x), aurApp->IsPositive(), value, apply);
}
}
@@ -4346,7 +4346,7 @@ void AuraEffect::HandleAuraModResistance(AuraApplication const* aurApp, uint8 mo
if (GetMiscValue() & int32(1 << x))
{
target->HandleStatModifier(UnitMods(UNIT_MOD_RESISTANCE_START + x), TOTAL_VALUE, float(GetAmount()), apply);
if (target->GetTypeId() == TYPEID_PLAYER || target->IsPet())
if (target->IsPlayer() || target->IsPet())
target->ApplyResistanceBuffModsMod(SpellSchools(x), GetAmount() > 0, (float)GetAmount(), apply);
}
}
@@ -4379,7 +4379,7 @@ void AuraEffect::HandleModResistancePercent(AuraApplication const* aurApp, uint8
if (GetMiscValue() & int32(1 << i))
{
target->HandleStatModifier(UnitMods(UNIT_MOD_RESISTANCE_START + i), TOTAL_PCT, float(GetAmount()), apply);
if (target->GetTypeId() == TYPEID_PLAYER || target->IsPet())
if (target->IsPlayer() || target->IsPet())
{
target->ApplyResistanceBuffModsPercentMod(SpellSchools(i), true, (float)GetAmount(), apply);
target->ApplyResistanceBuffModsPercentMod(SpellSchools(i), false, (float)GetAmount(), apply);
@@ -4413,11 +4413,11 @@ void AuraEffect::HandleModTargetResistance(AuraApplication const* aurApp, uint8
// applied to damage as HandleNoImmediateEffect in Unit::CalcAbsorbResist and Unit::CalcArmorReducedDamage
// show armor penetration
if (target->GetTypeId() == TYPEID_PLAYER && (GetMiscValue() & SPELL_SCHOOL_MASK_NORMAL))
if (target->IsPlayer() && (GetMiscValue() & SPELL_SCHOOL_MASK_NORMAL))
target->ApplyModInt32Value(PLAYER_FIELD_MOD_TARGET_PHYSICAL_RESISTANCE, GetAmount(), apply);
// show as spell penetration only full spell penetration bonuses (all resistances except armor and holy
if (target->GetTypeId() == TYPEID_PLAYER && (GetMiscValue() & SPELL_SCHOOL_MASK_SPELL) == SPELL_SCHOOL_MASK_SPELL)
if (target->IsPlayer() && (GetMiscValue() & SPELL_SCHOOL_MASK_SPELL) == SPELL_SCHOOL_MASK_SPELL)
target->ApplyModInt32Value(PLAYER_FIELD_MOD_TARGET_RESISTANCE, GetAmount(), apply);
}
@@ -4445,7 +4445,7 @@ void AuraEffect::HandleAuraModStat(AuraApplication const* aurApp, uint8 mode, bo
{
//target->ApplyStatMod(Stats(i), m_amount, apply);
target->HandleStatModifier(UnitMods(UNIT_MOD_STAT_START + i), TOTAL_VALUE, float(GetAmount()), apply);
if (target->GetTypeId() == TYPEID_PLAYER || target->IsPet())
if (target->IsPlayer() || target->IsPet())
target->ApplyStatBuffMod(Stats(i), (float)GetAmount(), apply);
}
}
@@ -4575,12 +4575,12 @@ void AuraEffect::HandleModTotalPercentStat(AuraApplication const* aurApp, uint8
{
if (i == STAT_STRENGTH || i == STAT_STAMINA)
{
if (apply && (target->GetTypeId() == TYPEID_PLAYER || target->IsPet()))
if (apply && (target->IsPlayer() || target->IsPet()))
target->ApplyStatPercentBuffMod(Stats(i), value, apply);
target->HandleStatModifier(UnitMods(UNIT_MOD_STAT_START + i), TOTAL_PCT, value, apply);
if (!apply && (target->GetTypeId() == TYPEID_PLAYER || target->IsPet()))
if (!apply && (target->IsPlayer() || target->IsPet()))
target->ApplyStatPercentBuffMod(Stats(i), value, apply);
}
}
@@ -4591,12 +4591,12 @@ void AuraEffect::HandleModTotalPercentStat(AuraApplication const* aurApp, uint8
{
if (GetMiscValue() == i || GetMiscValue() == -1)
{
if (apply && (target->GetTypeId() == TYPEID_PLAYER || target->IsPet()))
if (apply && (target->IsPlayer() || target->IsPet()))
target->ApplyStatPercentBuffMod(Stats(i), value, apply);
target->HandleStatModifier(UnitMods(UNIT_MOD_STAT_START + i), TOTAL_PCT, value, apply);
if (!apply && (target->GetTypeId() == TYPEID_PLAYER || target->IsPet()))
if (!apply && (target->IsPlayer() || target->IsPet()))
target->ApplyStatPercentBuffMod(Stats(i), value, apply);
}
}
@@ -4892,7 +4892,7 @@ void AuraEffect::HandleModHitChance(AuraApplication const* aurApp, uint8 mode, b
Unit* target = aurApp->GetTarget();
if (target->GetTypeId() == TYPEID_PLAYER)
if (target->IsPlayer())
{
target->ToPlayer()->UpdateMeleeHitChances();
target->ToPlayer()->UpdateRangedHitChances();
@@ -4911,7 +4911,7 @@ void AuraEffect::HandleModSpellHitChance(AuraApplication const* aurApp, uint8 mo
Unit* target = aurApp->GetTarget();
if (target->GetTypeId() == TYPEID_PLAYER)
if (target->IsPlayer())
target->ToPlayer()->UpdateSpellHitChances();
else
target->m_modSpellHitChance += (apply) ? GetAmount() : (-GetAmount());
@@ -4924,7 +4924,7 @@ void AuraEffect::HandleModSpellCritChance(AuraApplication const* aurApp, uint8 m
Unit* target = aurApp->GetTarget();
if (target->GetTypeId() == TYPEID_PLAYER)
if (target->IsPlayer())
target->ToPlayer()->UpdateAllSpellCritChances();
else
target->m_baseSpellCritChance += (apply) ? GetAmount() : -GetAmount();
@@ -5152,7 +5152,7 @@ void AuraEffect::HandleAuraModRangedAttackPowerOfStatPercent(AuraApplication con
Unit* target = aurApp->GetTarget();
// Recalculate bonus
if (target->GetTypeId() == TYPEID_PLAYER && !(target->getClassMask() & CLASSMASK_WAND_USERS))
if (target->IsPlayer() && !(target->getClassMask() & CLASSMASK_WAND_USERS))
target->ToPlayer()->UpdateAttackPowerAndDamage(true);
}
@@ -5169,7 +5169,7 @@ void AuraEffect::HandleAuraModAttackPowerOfArmor(AuraApplication const* aurApp,
Unit* target = aurApp->GetTarget();
// Recalculate bonus
if (target->GetTypeId() == TYPEID_PLAYER)
if (target->IsPlayer())
target->ToPlayer()->UpdateAttackPowerAndDamage(false);
}
/********************************/
@@ -5183,7 +5183,7 @@ void AuraEffect::HandleModDamageDone(AuraApplication const* aurApp, uint8 mode,
Unit* target = aurApp->GetTarget();
// apply item specific bonuses for already equipped weapon
if (target->GetTypeId() == TYPEID_PLAYER)
if (target->IsPlayer())
{
for (int i = 0; i < MAX_ATTACK; ++i)
if (Item* pItem = target->ToPlayer()->GetWeaponForAttack(WeaponAttackType(i), true))
@@ -5208,7 +5208,7 @@ void AuraEffect::HandleModDamageDone(AuraApplication const* aurApp, uint8 mode,
target->HandleStatModifier(UNIT_MOD_DAMAGE_OFFHAND, TOTAL_VALUE, float(GetAmount()), apply);
target->HandleStatModifier(UNIT_MOD_DAMAGE_RANGED, TOTAL_VALUE, float(GetAmount()), apply);
if (target->GetTypeId() == TYPEID_PLAYER)
if (target->IsPlayer())
{
if (GetAmount() > 0)
target->ApplyModInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_POS, GetAmount(), apply);
@@ -5237,7 +5237,7 @@ void AuraEffect::HandleModDamageDone(AuraApplication const* aurApp, uint8 mode,
// Magic damage modifiers implemented in Unit::SpellDamageBonus
// This information for client side use only
if (target->GetTypeId() == TYPEID_PLAYER)
if (target->IsPlayer())
{
if (GetAmount() > 0)
{
@@ -5272,7 +5272,7 @@ void AuraEffect::HandleModDamagePercentDone(AuraApplication const* aurApp, uint8
if (!sScriptMgr->CanModAuraEffectModDamagePercentDone(this, target, aurApp, mode, apply))
return;
if (target->GetTypeId() == TYPEID_PLAYER)
if (target->IsPlayer())
{
for (int i = 0; i < MAX_ATTACK; ++i)
if (Item* item = target->ToPlayer()->GetWeaponForAttack(WeaponAttackType(i), false))
@@ -5285,7 +5285,7 @@ void AuraEffect::HandleModDamagePercentDone(AuraApplication const* aurApp, uint8
target->HandleStatModifier(UNIT_MOD_DAMAGE_OFFHAND, TOTAL_PCT, float(GetAmount()), apply);
target->HandleStatModifier(UNIT_MOD_DAMAGE_RANGED, TOTAL_PCT, float(GetAmount()), apply);
if (target->GetTypeId() == TYPEID_PLAYER)
if (target->IsPlayer())
target->ToPlayer()->ApplyPercentModFloatValue(PLAYER_FIELD_MOD_DAMAGE_DONE_PCT, float (GetAmount()), apply);
}
else
@@ -5315,7 +5315,7 @@ void AuraEffect::HandleShieldBlockValue(AuraApplication const* aurApp, uint8 mod
if (GetAuraType() == SPELL_AURA_MOD_SHIELD_BLOCKVALUE_PCT)
modType = PCT_MOD;
if (target->GetTypeId() == TYPEID_PLAYER)
if (target->IsPlayer())
target->ToPlayer()->HandleBaseModValue(SHIELD_BLOCK_VALUE, modType, float(GetAmount()), apply);
}
@@ -5513,7 +5513,7 @@ void AuraEffect::HandleAuraDummy(AuraApplication const* aurApp, uint8 mode, bool
target->GetMotionMaster()->MoveFall();
break;
case 46699: // Requires No Ammo
if (target->GetTypeId() == TYPEID_PLAYER)
if (target->IsPlayer())
target->ToPlayer()->RemoveAmmo(); // not use ammo and not allow use
break;
case 71563:
@@ -5599,7 +5599,7 @@ void AuraEffect::HandleAuraDummy(AuraApplication const* aurApp, uint8 mode, bool
{
case 2584: // Waiting to Resurrect
// Waiting to resurrect spell cancel, we must remove player from resurrect queue
if (target->GetTypeId() == TYPEID_PLAYER)
if (target->IsPlayer())
{
if (Battleground* bg = target->ToPlayer()->GetBattleground())
bg->RemovePlayerFromResurrectQueue(target->ToPlayer());
@@ -5646,7 +5646,7 @@ void AuraEffect::HandleAuraDummy(AuraApplication const* aurApp, uint8 mode, bool
if (target->isDead() && GetBase() && target->GetTypeId() == TYPEID_UNIT && target->GetEntry() == 24601)
{
auto caster2 = GetBase()->GetCaster();
if (caster2 && caster2->GetTypeId() == TYPEID_PLAYER)
if (caster2 && caster2->IsPlayer())
{
caster2->ToPlayer()->KilledMonsterCredit(25987);
}
@@ -5744,7 +5744,7 @@ void AuraEffect::HandleAuraDummy(AuraApplication const* aurApp, uint8 mode, bool
}
// LK Intro VO (1)
case 58204:
if (target->GetTypeId() == TYPEID_PLAYER)
if (target->IsPlayer())
{
// Play part 1
if (apply)
@@ -5756,7 +5756,7 @@ void AuraEffect::HandleAuraDummy(AuraApplication const* aurApp, uint8 mode, bool
break;
// LK Intro VO (2)
case 58205:
if (target->GetTypeId() == TYPEID_PLAYER)
if (target->IsPlayer())
{
// Play part 2
if (apply)
@@ -5987,13 +5987,13 @@ void AuraEffect::HandleAuraModFaction(AuraApplication const* aurApp, uint8 mode,
if (apply)
{
target->SetFaction(GetMiscValue());
if (target->GetTypeId() == TYPEID_PLAYER)
if (target->IsPlayer())
target->RemoveUnitFlag(UNIT_FLAG_PLAYER_CONTROLLED);
}
else
{
target->RestoreFaction();
if (target->GetTypeId() == TYPEID_PLAYER)
if (target->IsPlayer())
target->SetUnitFlag(UNIT_FLAG_PLAYER_CONTROLLED);
}
}
@@ -6366,7 +6366,7 @@ void AuraEffect::HandlePeriodicTriggerSpellAuraTick(Unit* target, Unit* caster)
case 30427:
{
// move loot to player inventory and despawn target
if (caster && caster->GetTypeId() == TYPEID_PLAYER &&
if (caster && caster->IsPlayer() &&
target->GetTypeId() == TYPEID_UNIT &&
target->ToCreature()->GetCreatureTemplate()->type == CREATURE_TYPE_GAS_CLOUD)
{
@@ -7134,7 +7134,7 @@ void AuraEffect::HandlePeriodicEnergizeAuraTick(Unit* target, Unit* caster) cons
{
Powers PowerType = Powers(GetMiscValue());
if (target->GetTypeId() == TYPEID_PLAYER && !target->HasActivePowerType(PowerType) && !m_spellInfo->HasAttribute(SPELL_ATTR7_ONLY_IN_SPELLBOOK_UNTIL_LEARNED))
if (target->IsPlayer() && !target->HasActivePowerType(PowerType) && !m_spellInfo->HasAttribute(SPELL_ATTR7_ONLY_IN_SPELLBOOK_UNTIL_LEARNED))
return;
if (!target->IsAlive() || !target->GetMaxPower(PowerType))

View File

@@ -486,7 +486,7 @@ AuraObjectType Aura::GetType() const
return UNIT_AURA_TYPE;
}
return (m_owner->GetTypeId() == TYPEID_DYNAMICOBJECT) ? DYNOBJ_AURA_TYPE : UNIT_AURA_TYPE;
return (m_owner->IsDynamicObject()) ? DYNOBJ_AURA_TYPE : UNIT_AURA_TYPE;
}
void Aura::_ApplyForTarget(Unit* target, Unit* caster, AuraApplication* auraApp)
@@ -559,7 +559,7 @@ void Aura::_UnapplyForTarget(Unit* target, Unit* caster, AuraApplication* auraAp
}
}
if (caster && caster->GetTypeId() == TYPEID_PLAYER)
if (caster && caster->IsPlayer())
{
if (GetSpellInfo()->IsCooldownStartedOnEvent() && !m_castItemGuid)
{
@@ -1350,7 +1350,7 @@ void Aura::HandleAuraSpecificMods(AuraApplication const* aurApp, Unit* caster, b
switch (GetId())
{
case 32474: // Buffeting Winds of Susurrus
if (target->GetTypeId() == TYPEID_PLAYER)
if (target->IsPlayer())
target->ToPlayer()->ActivateTaxiPathTo(506, GetId());
break;
case 33572: // Gronn Lord's Grasp, becomes stoned
@@ -1362,7 +1362,7 @@ void Aura::HandleAuraSpecificMods(AuraApplication const* aurApp, Unit* caster, b
target->CastSpell(target, 50812, true);
break;
case 60970: // Heroic Fury (remove Intercept cooldown)
if (target->GetTypeId() == TYPEID_PLAYER)
if (target->IsPlayer())
target->ToPlayer()->RemoveSpellCooldown(20252, true);
break;
}
@@ -1587,7 +1587,7 @@ void Aura::HandleAuraSpecificMods(AuraApplication const* aurApp, Unit* caster, b
break;
case SPELLFAMILY_POTION:
// Alchemy: Mixology
if (caster && caster->HasAura(53042) && caster->GetTypeId() == TYPEID_PLAYER && !caster->ToPlayer()->GetSession()->PlayerLoading())
if (caster && caster->HasAura(53042) && caster->IsPlayer() && !caster->ToPlayer()->GetSession()->PlayerLoading())
{
if (sSpellMgr->GetSpellGroup(GetId()) == 1) /*Elixirs*/
{
@@ -1726,7 +1726,7 @@ void Aura::HandleAuraSpecificMods(AuraApplication const* aurApp, Unit* caster, b
if (Aura const* aura = caster->GetAuraOfRankedSpell(47535))
{
// check cooldown
if (caster->GetTypeId() == TYPEID_PLAYER)
if (caster->IsPlayer())
{
if (caster->ToPlayer()->HasSpellCooldown(aura->GetId()))
{
@@ -2266,7 +2266,7 @@ bool Aura::IsProcTriggeredOnEvent(AuraApplication* aurApp, ProcEventInfo& eventI
// do that only for passive spells
/// @todo: this needs to be unified for all kinds of auras
Unit* target = aurApp->GetTarget();
if (IsPassive() && target->GetTypeId() == TYPEID_PLAYER && GetSpellInfo()->EquippedItemClass != -1)
if (IsPassive() && target->IsPlayer() && GetSpellInfo()->EquippedItemClass != -1)
{
if (!GetSpellInfo()->HasAttribute(SPELL_ATTR3_NO_PROC_EQUIP_REQUIREMENT))
{

View File

@@ -481,7 +481,7 @@ void SpellCastTargets::Update(Unit* caster)
m_objectTarget = m_objectTargetGUID ? ((m_objectTargetGUID == caster->GetGUID()) ? caster : ObjectAccessor::GetWorldObject(*caster, m_objectTargetGUID)) : nullptr;
m_itemTarget = nullptr;
if (caster->GetTypeId() == TYPEID_PLAYER)
if (caster->IsPlayer())
{
Player* player = caster->ToPlayer();
if (m_targetMask & TARGET_FLAG_ITEM)
@@ -609,7 +609,7 @@ Spell::Spell(Unit* caster, SpellInfo const* info, TriggerCastFlags triggerFlags,
if (m_attackType == RANGED_ATTACK)
// wand case
if ((m_caster->getClassMask() & CLASSMASK_WAND_USERS) != 0 && m_caster->GetTypeId() == TYPEID_PLAYER)
if ((m_caster->getClassMask() & CLASSMASK_WAND_USERS) != 0 && m_caster->IsPlayer())
if (Item* pItem = m_caster->ToPlayer()->GetWeaponForAttack(RANGED_ATTACK))
m_spellSchoolMask = SpellSchoolMask(1 << pItem->GetTemplate()->Damage[0].DamageType);
@@ -2031,7 +2031,7 @@ void Spell::SelectEffectTypeImplicitTargets(uint8 effIndex)
{
case SPELL_EFFECT_SUMMON_RAF_FRIEND:
case SPELL_EFFECT_SUMMON_PLAYER:
if (m_caster->GetTypeId() == TYPEID_PLAYER && m_caster->ToPlayer()->GetTarget())
if (m_caster->IsPlayer() && m_caster->ToPlayer()->GetTarget())
{
WorldObject* target = ObjectAccessor::FindPlayer(m_caster->ToPlayer()->GetTarget());
@@ -2718,7 +2718,7 @@ void Spell::DoAllEffectOnTarget(TargetInfo* target)
m_needComboPoints = false;
// Restore spell mods for a miss/dodge/parry Cold Blood
/// @todo: check how broad this rule should be
if (m_caster->GetTypeId() == TYPEID_PLAYER && (missInfo == SPELL_MISS_MISS || missInfo == SPELL_MISS_DODGE || missInfo == SPELL_MISS_PARRY))
if (m_caster->IsPlayer() && (missInfo == SPELL_MISS_MISS || missInfo == SPELL_MISS_DODGE || missInfo == SPELL_MISS_PARRY))
m_caster->ToPlayer()->RestoreSpellMods(this, 14177);
}
@@ -2890,7 +2890,7 @@ void Spell::DoAllEffectOnTarget(TargetInfo* target)
Unit::ProcDamageAndSpell(caster, unitTarget, procAttacker, procVictim, procEx, damageInfo.damage, m_attackType, m_spellInfo, m_triggeredByAuraSpell.spellInfo,
m_triggeredByAuraSpell.effectIndex, this, &dmgInfo);
if (caster->GetTypeId() == TYPEID_PLAYER && m_spellInfo->HasAttribute(SPELL_ATTR0_CANCELS_AUTO_ATTACK_COMBAT) == 0 &&
if (caster->IsPlayer() && m_spellInfo->HasAttribute(SPELL_ATTR0_CANCELS_AUTO_ATTACK_COMBAT) == 0 &&
m_spellInfo->HasAttribute(SPELL_ATTR4_SUPRESS_WEAPON_PROCS) == 0 && (m_spellInfo->DmgClass == SPELL_DAMAGE_CLASS_MELEE || m_spellInfo->DmgClass == SPELL_DAMAGE_CLASS_RANGED))
caster->ToPlayer()->CastItemCombatSpell(unitTarget, m_attackType, procVictim, procEx);
}
@@ -2912,7 +2912,7 @@ void Spell::DoAllEffectOnTarget(TargetInfo* target)
// Xinef: eg. rogue poisons can proc off cheap shot, etc. so this block should be here also
// Xinef: ofc count only spells that HIT the target, little hack used to fool the system
if ((procEx & PROC_EX_NORMAL_HIT || procEx & PROC_EX_CRITICAL_HIT) && caster->GetTypeId() == TYPEID_PLAYER && m_spellInfo->HasAttribute(SPELL_ATTR0_CANCELS_AUTO_ATTACK_COMBAT) == 0 &&
if ((procEx & PROC_EX_NORMAL_HIT || procEx & PROC_EX_CRITICAL_HIT) && caster->IsPlayer() && m_spellInfo->HasAttribute(SPELL_ATTR0_CANCELS_AUTO_ATTACK_COMBAT) == 0 &&
m_spellInfo->HasAttribute(SPELL_ATTR4_SUPRESS_WEAPON_PROCS) == 0 && (m_spellInfo->DmgClass == SPELL_DAMAGE_CLASS_MELEE || m_spellInfo->DmgClass == SPELL_DAMAGE_CLASS_RANGED))
caster->ToPlayer()->CastItemCombatSpell(unitTarget, m_attackType, procVictim | PROC_FLAG_TAKEN_DAMAGE, procEx);
}
@@ -2985,7 +2985,7 @@ void Spell::DoAllEffectOnTarget(TargetInfo* target)
// if target is fallged for pvp also flag caster if a player
// xinef: do not flag spells with aura bind sight (no special attribute)
if (effectUnit->IsPvP() && effectUnit != m_caster && effectUnit->GetOwnerGUID() != m_caster->GetGUID() &&
m_caster->GetTypeId() == TYPEID_PLAYER && !m_spellInfo->HasAttribute(SPELL_ATTR0_CU_NO_PVP_FLAG))
m_caster->IsPlayer() && !m_spellInfo->HasAttribute(SPELL_ATTR0_CU_NO_PVP_FLAG))
{
m_caster->ToPlayer()->UpdatePvP(true);
}
@@ -3033,14 +3033,14 @@ SpellMissInfo Spell::DoSpellHitOnUnit(Unit* unit, uint32 effectMask, bool scaleA
if (!effectMask)
return returnVal;
if (unit->GetTypeId() == TYPEID_PLAYER)
if (unit->IsPlayer())
{
unit->ToPlayer()->StartTimedAchievement(ACHIEVEMENT_TIMED_TYPE_SPELL_TARGET, m_spellInfo->Id);
unit->ToPlayer()->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_BE_SPELL_TARGET, m_spellInfo->Id, 0, m_caster);
unit->ToPlayer()->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_BE_SPELL_TARGET2, m_spellInfo->Id, 0, m_caster);
}
if (m_caster->GetTypeId() == TYPEID_PLAYER)
if (m_caster->IsPlayer())
{
m_caster->ToPlayer()->StartTimedAchievement(ACHIEVEMENT_TIMED_TYPE_SPELL_CASTER, m_spellInfo->Id);
m_caster->ToPlayer()->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_CAST_SPELL2, m_spellInfo->Id, 0, unit);
@@ -3067,14 +3067,14 @@ SpellMissInfo Spell::DoSpellHitOnUnit(Unit* unit, uint32 effectMask, bool scaleA
{
// for delayed spells ignore negative spells (after duel end) for friendly targets
/// @todo: this cause soul transfer bugged
if(!IsTriggered() && m_spellInfo->Speed > 0.0f && unit->GetTypeId() == TYPEID_PLAYER && !m_spellInfo->IsPositive())
if(!IsTriggered() && m_spellInfo->Speed > 0.0f && unit->IsPlayer() && !m_spellInfo->IsPositive())
return SPELL_MISS_EVADE;
// assisting case, healing and resurrection
if (unit->HasUnitState(UNIT_STATE_ATTACK_PLAYER))
{
m_caster->SetContestedPvP();
if (m_caster->GetTypeId() == TYPEID_PLAYER && !m_spellInfo->HasAttribute(SPELL_ATTR0_CU_NO_PVP_FLAG))
if (m_caster->IsPlayer() && !m_spellInfo->HasAttribute(SPELL_ATTR0_CU_NO_PVP_FLAG))
m_caster->ToPlayer()->UpdatePvP(true);
}
@@ -3549,7 +3549,7 @@ SpellCastResult Spell::prepare(SpellCastTargets const* targets, AuraEffect const
// for example bladestorm aura should be removed on disarm as of patch 3.3.5
// channeled periodic spells should be affected by this (arcane missiles, penance, etc)
// a possible alternative sollution for those would be validating aura target on unit state change
if (m_caster->GetTypeId() == TYPEID_PLAYER && triggeredByAura && triggeredByAura->IsPeriodic() && !triggeredByAura->GetBase()->IsPassive())
if (m_caster->IsPlayer() && triggeredByAura && triggeredByAura->IsPeriodic() && !triggeredByAura->GetBase()->IsPassive())
{
SendChannelUpdate(0);
triggeredByAura->GetBase()->SetDuration(0);
@@ -3571,13 +3571,13 @@ SpellCastResult Spell::prepare(SpellCastTargets const* targets, AuraEffect const
// calculate cast time (calculated after first CheckCast check to prevent charge counting for first CheckCast fail)
m_casttime = HasTriggeredCastFlag(TRIGGERED_CAST_DIRECTLY) ? 0 : m_spellInfo->CalcCastTime(m_caster, this);
if (m_caster->GetTypeId() == TYPEID_PLAYER)
if (m_caster->IsPlayer())
if (m_caster->ToPlayer()->GetCommandStatus(CHEAT_CASTTIME))
m_casttime = 0;
// don't allow channeled spells / spells with cast time to be casted while moving
// (even if they are interrupted on moving, spells with almost immediate effect get to have their effect processed before movement interrupter kicks in)
if ((m_spellInfo->IsChanneled() || m_casttime) && m_caster->GetTypeId() == TYPEID_PLAYER && m_caster->isMoving() && m_spellInfo->InterruptFlags & SPELL_INTERRUPT_FLAG_MOVEMENT && !IsTriggered())
if ((m_spellInfo->IsChanneled() || m_casttime) && m_caster->IsPlayer() && m_caster->isMoving() && m_spellInfo->InterruptFlags & SPELL_INTERRUPT_FLAG_MOVEMENT && !IsTriggered())
{
// 1. Has casttime, 2. Or doesn't have flag to allow action during channel
if (m_casttime || !m_spellInfo->IsActionAllowedChannel())
@@ -3722,7 +3722,7 @@ void Spell::cancel(bool bySelf)
CancelGlobalCooldown();
SendCastResult(SPELL_FAILED_INTERRUPTED);
if (m_caster->GetTypeId() == TYPEID_PLAYER)
if (m_caster->IsPlayer())
{
if (m_caster->ToPlayer()->NeedSendSpectatorData())
ArenaSpectator::SendCommand_Spell(m_caster->FindMap(), m_caster->GetGUID(), "SPE", m_spellInfo->Id, bySelf ? 99998 : 99999);
@@ -3747,7 +3747,7 @@ void Spell::cancel(bool bySelf)
SendInterrupted(SPELL_FAILED_INTERRUPTED);
}
if (m_caster->GetTypeId() == TYPEID_PLAYER && m_caster->ToPlayer()->NeedSendSpectatorData())
if (m_caster->IsPlayer() && m_caster->ToPlayer()->NeedSendSpectatorData())
ArenaSpectator::SendCommand_Spell(m_caster->FindMap(), m_caster->GetGUID(), "SPE", m_spellInfo->Id, bySelf ? 99998 : 99999);
// spell is canceled-take mods and clear list
@@ -3816,7 +3816,7 @@ void Spell::_cast(bool skipCheck)
// Xinef: implement attribute SPELL_ATTR1_DISMISS_PET_FIRST, on spell cast current pet is dismissed and charms are removed
if (m_spellInfo->HasAttribute(SPELL_ATTR1_DISMISS_PET_FIRST))
{
if (m_caster->GetTypeId() == TYPEID_PLAYER && !m_spellInfo->HasEffect(SPELL_EFFECT_SUMMON_PET))
if (m_caster->IsPlayer() && !m_spellInfo->HasEffect(SPELL_EFFECT_SUMMON_PET))
if (Pet* pet = m_caster->ToPlayer()->GetPet())
m_caster->ToPlayer()->RemovePet(pet, PET_SAVE_AS_CURRENT);
@@ -3869,7 +3869,7 @@ void Spell::_cast(bool skipCheck)
// if trade not complete then remember it in trade data
if (m_targets.GetTargetMask() & TARGET_FLAG_TRADE_ITEM)
{
if (m_caster->GetTypeId() == TYPEID_PLAYER)
if (m_caster->IsPlayer())
{
if (TradeData* my_trade = m_caster->ToPlayer()->GetTradeData())
{
@@ -3921,7 +3921,7 @@ void Spell::_cast(bool skipCheck)
// set to real guid to be sent later to the client
m_targets.UpdateTradeSlotItem();
if (m_caster->GetTypeId() == TYPEID_PLAYER)
if (m_caster->IsPlayer())
{
if (!HasTriggeredCastFlag(TRIGGERED_IGNORE_CAST_ITEM) && m_CastItem)
{
@@ -4092,11 +4092,11 @@ void Spell::_cast(bool skipCheck)
// xinef: start combat at cast for delayed spells, only for explicit target
if (Unit* target = m_targets.GetUnitTarget())
if (m_caster->GetTypeId() == TYPEID_PLAYER || (m_caster->IsPet() && m_caster->IsControlledByPlayer()))
if (m_caster->IsPlayer() || (m_caster->IsPet() && m_caster->IsControlledByPlayer()))
if (GetDelayMoment() > 0 && !m_caster->IsFriendlyTo(target) && !m_spellInfo->HasAura(SPELL_AURA_BIND_SIGHT) && (!m_spellInfo->IsPositive() || m_spellInfo->HasEffect(SPELL_EFFECT_DISPEL)))
m_caster->CombatStartOnCast(target, !m_spellInfo->HasAttribute(SPELL_ATTR3_SUPRESS_TARGET_PROCS), GetDelayMoment() + 500); // xinef: increase this time so we dont leave and enter combat in a moment
if (m_caster->GetTypeId() == TYPEID_PLAYER)
if (m_caster->IsPlayer())
if (m_caster->ToPlayer()->GetCommandStatus(CHEAT_COOLDOWN))
m_caster->ToPlayer()->RemoveSpellCooldown(m_spellInfo->Id, true);
@@ -4300,7 +4300,7 @@ void Spell::_handle_finish_phase()
{
// Xinef: Properly clear infinite cooldowns in some cases
if (ihit->targetGUID == m_caster->GetGUID() && ihit->missCondition != SPELL_MISS_NONE)
if (m_caster->GetTypeId() == TYPEID_PLAYER && m_spellInfo->IsCooldownStartedOnEvent())
if (m_caster->IsPlayer() && m_spellInfo->IsCooldownStartedOnEvent())
m_caster->ToPlayer()->SendCooldownEvent(m_spellInfo);
}
@@ -4408,7 +4408,7 @@ void Spell::update(uint32 difftime)
// check if the player caster has moved before the spell finished
// xinef: added preparing state (real cast, skip channels as they have other flags for this)
if ((m_caster->GetTypeId() == TYPEID_PLAYER && m_timer != 0) &&
if ((m_caster->IsPlayer() && m_timer != 0) &&
m_caster->isMoving() && (m_spellInfo->InterruptFlags & SPELL_INTERRUPT_FLAG_MOVEMENT) && m_spellState == SPELL_STATE_PREPARING &&
(m_spellInfo->Effects[0].Effect != SPELL_EFFECT_STUCK || !m_caster->HasUnitMovementFlag(MOVEMENTFLAG_FALLING_FAR)))
{
@@ -4486,7 +4486,7 @@ void Spell::finish(bool ok)
m_caster->ClearUnitState(UNIT_STATE_CASTING);
// Unsummon summon as possessed creatures on spell cancel
if (m_spellInfo->IsChanneled() && m_caster->GetTypeId() == TYPEID_PLAYER)
if (m_spellInfo->IsChanneled() && m_caster->IsPlayer())
{
if (Unit* charm = m_caster->GetCharm())
if (charm->GetTypeId() == TYPEID_UNIT
@@ -4500,7 +4500,7 @@ void Spell::finish(bool ok)
if (!ok)
{
if (m_caster->GetTypeId() == TYPEID_PLAYER)
if (m_caster->IsPlayer())
{
// Xinef: Restore spell mods in case of fail cast
m_caster->ToPlayer()->RestoreSpellMods(this);
@@ -4530,7 +4530,7 @@ void Spell::finish(bool ok)
}
// potions disabled by client, send event "not in combat" if need
if (m_caster->GetTypeId() == TYPEID_PLAYER && !m_triggeredByAuraSpell)
if (m_caster->IsPlayer() && !m_triggeredByAuraSpell)
m_caster->ToPlayer()->UpdatePotionCooldown(this);
// Take mods after trigger spell (needed for 14177 to affect 48664)
@@ -4715,7 +4715,7 @@ void Spell::SendSpellStart()
if (m_spellInfo->HasAttribute(SPELL_ATTR0_USES_RANGED_SLOT) || m_spellInfo->HasAttribute(SPELL_ATTR0_CU_NEEDS_AMMO_DATA))
castFlags |= CAST_FLAG_PROJECTILE;
if (m_caster->GetTypeId() == TYPEID_PLAYER || m_caster->IsPet())
if (m_caster->IsPlayer() || m_caster->IsPet())
{
switch (m_spellInfo->PowerType)
{
@@ -4776,7 +4776,7 @@ void Spell::SendSpellStart()
m_caster->SendMessageToSet(&data, true);
if (!m_spellInfo->IsChanneled() && m_caster->GetTypeId() == TYPEID_PLAYER && m_caster->ToPlayer()->NeedSendSpectatorData())
if (!m_spellInfo->IsChanneled() && m_caster->IsPlayer() && m_caster->ToPlayer()->NeedSendSpectatorData())
ArenaSpectator::SendCommand_Spell(m_caster->FindMap(), m_caster->GetGUID(), "SPE", m_spellInfo->Id, m_timer);
}
@@ -4798,7 +4798,7 @@ void Spell::SendSpellGo()
castFlags |= CAST_FLAG_PROJECTILE; // arrows/bullets visual
// should only be sent to self, but the current messaging doesn't make that possible
if (m_caster->GetTypeId() == TYPEID_PLAYER || m_caster->IsPet())
if (m_caster->IsPlayer() || m_caster->IsPet())
{
switch (m_spellInfo->PowerType)
{
@@ -4816,7 +4816,7 @@ void Spell::SendSpellGo()
}
}
if ((m_caster->GetTypeId() == TYPEID_PLAYER)
if ((m_caster->IsPlayer())
&& (m_caster->IsClass(CLASS_DEATH_KNIGHT, CLASS_CONTEXT_ABILITY))
&& m_spellInfo->RuneCostID
&& m_spellInfo->PowerType == POWER_RUNE)
@@ -4916,7 +4916,7 @@ void Spell::WriteAmmoToPacket(WorldPacket* data)
uint32 ammoInventoryType = 0;
uint32 ammoDisplayID = 0;
if (m_caster->GetTypeId() == TYPEID_PLAYER)
if (m_caster->IsPlayer())
{
Item* pItem = m_caster->ToPlayer()->GetWeaponForAttack(RANGED_ATTACK);
if (pItem)
@@ -5203,7 +5203,7 @@ void Spell::SendChannelStart(uint32 duration)
m_caster->SendMessageToSet(&data, true);
if (m_caster->GetTypeId() == TYPEID_PLAYER && m_caster->ToPlayer()->NeedSendSpectatorData())
if (m_caster->IsPlayer() && m_caster->ToPlayer()->NeedSendSpectatorData())
ArenaSpectator::SendCommand_Spell(m_caster->FindMap(), m_caster->GetGUID(), "SPE", m_spellInfo->Id, -((int32)duration));
m_timer = duration;
@@ -5217,7 +5217,7 @@ void Spell::SendResurrectRequest(Player* target)
{
// get resurrector name for creature resurrections, otherwise packet will be not accepted
// for player resurrections the name is looked up by guid
std::string const sentName(m_caster->GetTypeId() == TYPEID_PLAYER
std::string const sentName(m_caster->IsPlayer()
? ""
: m_caster->GetNameForLocaleIdx(target->GetSession()->GetSessionDbLocaleIndex()));
@@ -5228,7 +5228,7 @@ void Spell::SendResurrectRequest(Player* target)
data << sentName;
data << uint8(0); // null terminator
data << uint8(m_caster->GetTypeId() == TYPEID_PLAYER ? 0 : 1); // "you'll be afflicted with resurrection sickness"
data << uint8(m_caster->IsPlayer() ? 0 : 1); // "you'll be afflicted with resurrection sickness"
// override delay sent with SMSG_CORPSE_RECLAIM_DELAY, set instant resurrection for spells with this attribute
if (m_spellInfo->HasAttribute(SPELL_ATTR3_NO_RES_TIMER))
data << uint32(0);
@@ -5304,13 +5304,13 @@ void Spell::TakePower()
return;
//Don't take power if the spell is cast while .cheat power is enabled.
if (m_caster->GetTypeId() == TYPEID_PLAYER)
if (m_caster->IsPlayer())
if (m_caster->ToPlayer()->GetCommandStatus(CHEAT_POWER))
return;
Powers PowerType = Powers(m_spellInfo->PowerType);
bool hit = true;
if (m_caster->GetTypeId() == TYPEID_PLAYER)
if (m_caster->IsPlayer())
{
if (PowerType == POWER_RAGE || PowerType == POWER_ENERGY || PowerType == POWER_RUNE || PowerType == POWER_RUNIC_POWER)
if (ObjectGuid targetGUID = m_targets.GetUnitTargetGUID())
@@ -5364,7 +5364,7 @@ void Spell::TakePower()
void Spell::TakeAmmo()
{
if (m_attackType == RANGED_ATTACK && m_caster->GetTypeId() == TYPEID_PLAYER)
if (m_attackType == RANGED_ATTACK && m_caster->IsPlayer())
{
Item* pItem = m_caster->ToPlayer()->GetWeaponForAttack(RANGED_ATTACK);
@@ -5643,7 +5643,7 @@ SpellCastResult Spell::CheckCast(bool strict)
return SPELL_FAILED_CASTER_DEAD;
// Spectator check
if (m_caster->GetTypeId() == TYPEID_PLAYER)
if (m_caster->IsPlayer())
if (((Player const*)m_caster)->IsSpectator() && m_spellInfo->Id != SPECTATOR_SPELL_BINDSIGHT)
return SPELL_FAILED_NOT_HERE;
@@ -5657,7 +5657,7 @@ SpellCastResult Spell::CheckCast(bool strict)
// check cooldowns to prevent cheating
if (!m_spellInfo->HasAttribute(SPELL_ATTR0_PASSIVE))
{
if (m_caster->GetTypeId() == TYPEID_PLAYER)
if (m_caster->IsPlayer())
{
//can cast triggered (by aura only?) spells while have this flag
if (!HasTriggeredCastFlag(TRIGGERED_IGNORE_CASTER_AURASTATE) && m_caster->ToPlayer()->HasPlayerFlag(PLAYER_ALLOW_ONLY_ABILITY) && !IsNextMeleeSwingSpell())
@@ -5690,12 +5690,12 @@ SpellCastResult Spell::CheckCast(bool strict)
return SPELL_FAILED_NOT_READY;
// only triggered spells can be processed an ended battleground
if (!IsTriggered() && m_caster->GetTypeId() == TYPEID_PLAYER)
if (!IsTriggered() && m_caster->IsPlayer())
if (Battleground* bg = m_caster->ToPlayer()->GetBattleground())
if (bg->GetStatus() == STATUS_WAIT_LEAVE)
return SPELL_FAILED_DONT_REPORT;
if (m_caster->GetTypeId() == TYPEID_PLAYER /*&& VMAP::VMapFactory::createOrGetVMapMgr()->isLineOfSightCalcEnabled()*/) // pussywizard: optimization (commented)
if (m_caster->IsPlayer() /*&& VMAP::VMapFactory::createOrGetVMapMgr()->isLineOfSightCalcEnabled()*/) // pussywizard: optimization (commented)
{
if (m_spellInfo->HasAttribute(SPELL_ATTR0_ONLY_OUTDOORS) &&
!m_caster->IsOutdoors())
@@ -5774,7 +5774,7 @@ SpellCastResult Spell::CheckCast(bool strict)
// Xinef: exploit protection
if (reqCombat && !m_spellInfo->CanBeUsedInCombat() && (m_spellInfo->HasEffect(SPELL_EFFECT_RESURRECT) || m_spellInfo->HasEffect(SPELL_EFFECT_RESURRECT_NEW)))
{
if (m_caster->GetTypeId() == TYPEID_PLAYER && m_caster->GetMap()->IsDungeon())
if (m_caster->IsPlayer() && m_caster->GetMap()->IsDungeon())
if (InstanceScript* instanceScript = m_caster->GetInstanceScript())
if (instanceScript->IsEncounterInProgress())
{
@@ -5795,7 +5795,7 @@ SpellCastResult Spell::CheckCast(bool strict)
// cancel autorepeat spells if cast start when moving
// (not wand currently autorepeat cast delayed to moving stop anyway in spell update code)
if (m_caster->GetTypeId() == TYPEID_PLAYER && m_caster->ToPlayer()->isMoving() && !IsTriggered())
if (m_caster->IsPlayer() && m_caster->ToPlayer()->isMoving() && !IsTriggered())
{
// skip stuck spell to allow use it in falling case and apply spell limitations at movement
if ((!m_caster->HasUnitMovementFlag(MOVEMENTFLAG_FALLING_FAR) || m_spellInfo->Effects[0].Effect != SPELL_EFFECT_STUCK) &&
@@ -5828,7 +5828,7 @@ SpellCastResult Spell::CheckCast(bool strict)
// All creatures should be able to cast as passengers freely, restriction and attribute are only for players
VehicleSeatEntry const* vehicleSeat = vehicle->GetSeatForPassenger(m_caster);
if (!m_spellInfo->HasAttribute(SPELL_ATTR6_ALLOW_WHILE_RIDING_VEHICLE) && !m_spellInfo->HasAttribute(SPELL_ATTR0_ALLOW_WHILE_MOUNTED)
&& (vehicleSeat->m_flags & checkMask) != checkMask && m_caster->GetTypeId() == TYPEID_PLAYER)
&& (vehicleSeat->m_flags & checkMask) != checkMask && m_caster->IsPlayer())
return SPELL_FAILED_DONT_REPORT;
}
@@ -5968,7 +5968,7 @@ SpellCastResult Spell::CheckCast(bool strict)
}
}
// Spell casted only on battleground
if (m_spellInfo->HasAttribute(SPELL_ATTR3_ONLY_BATTLEGROUNDS) && m_caster->GetTypeId() == TYPEID_PLAYER)
if (m_spellInfo->HasAttribute(SPELL_ATTR3_ONLY_BATTLEGROUNDS) && m_caster->IsPlayer())
if (!m_caster->ToPlayer()->InBattleground())
return SPELL_FAILED_ONLY_BATTLEGROUNDS;
@@ -5988,13 +5988,13 @@ SpellCastResult Spell::CheckCast(bool strict)
m_caster->GetZoneAndAreaId(zone, area);
SpellCastResult locRes = m_spellInfo->CheckLocation(m_caster->GetMapId(), zone, area,
m_caster->GetTypeId() == TYPEID_PLAYER ? m_caster->ToPlayer() : nullptr);
m_caster->IsPlayer() ? m_caster->ToPlayer() : nullptr);
if (locRes != SPELL_CAST_OK)
return locRes;
}
// not let players cast spells at mount (and let do it to creatures)
if (m_caster->IsMounted() && m_caster->GetTypeId() == TYPEID_PLAYER && !HasTriggeredCastFlag(TRIGGERED_IGNORE_CASTER_MOUNTED_OR_ON_VEHICLE) &&
if (m_caster->IsMounted() && m_caster->IsPlayer() && !HasTriggeredCastFlag(TRIGGERED_IGNORE_CASTER_MOUNTED_OR_ON_VEHICLE) &&
!m_spellInfo->IsPassive() && !m_spellInfo->HasAttribute(SPELL_ATTR0_ALLOW_WHILE_MOUNTED))
{
if (m_caster->IsInFlight())
@@ -6189,7 +6189,7 @@ SpellCastResult Spell::CheckCast(bool strict)
case SPELL_EFFECT_POWER_DRAIN:
{
// Can be area effect, Check only for players and not check if target - caster (spell can have multiply drain/burn effects)
if (m_caster->GetTypeId() == TYPEID_PLAYER)
if (m_caster->IsPlayer())
if (Unit* target = m_targets.GetUnitTarget())
if (target != m_caster && !target->HasActivePowerType(Powers(m_spellInfo->Effects[i].MiscValue)))
return SPELL_FAILED_BAD_TARGETS;
@@ -6216,7 +6216,7 @@ SpellCastResult Spell::CheckCast(bool strict)
return SPELL_FAILED_ROOTED;
}
}
if (m_caster->GetTypeId() == TYPEID_PLAYER)
if (m_caster->IsPlayer())
if (Unit* target = m_targets.GetUnitTarget())
if (!target->IsAlive())
return SPELL_FAILED_BAD_TARGETS;
@@ -6426,7 +6426,7 @@ SpellCastResult Spell::CheckCast(bool strict)
return SPELL_FAILED_ALREADY_HAVE_CHARM;
}
if (m_caster->GetTypeId() == TYPEID_PLAYER && m_caster->IsClass(CLASS_WARLOCK, CLASS_CONTEXT_PET) && strict)
if (m_caster->IsPlayer() && m_caster->IsClass(CLASS_WARLOCK, CLASS_CONTEXT_PET) && strict)
if (Pet* pet = m_caster->ToPlayer()->GetPet())
pet->CastSpell(pet, 32752, true, nullptr, nullptr, pet->GetGUID()); //starting cast, trigger pet stun (cast by pet so it doesn't attack player)
@@ -6526,7 +6526,7 @@ SpellCastResult Spell::CheckCast(bool strict)
case SPELL_EFFECT_TELEPORT_UNITS_FACE_CASTER:
{
//Do not allow to cast it before BG starts.
if (m_caster->GetTypeId() == TYPEID_PLAYER)
if (m_caster->IsPlayer())
if (Battleground const* bg = m_caster->ToPlayer()->GetBattleground())
if (bg->GetStatus() != STATUS_IN_PROGRESS)
return SPELL_FAILED_TRY_AGAIN;
@@ -6560,7 +6560,7 @@ SpellCastResult Spell::CheckCast(bool strict)
{
if (m_caster->HasUnitState(UNIT_STATE_ROOT))
{
if (m_caster->GetTypeId() == TYPEID_PLAYER)
if (m_caster->IsPlayer())
return SPELL_FAILED_ROOTED;
else
return SPELL_FAILED_DONT_REPORT;
@@ -6579,7 +6579,7 @@ SpellCastResult Spell::CheckCast(bool strict)
if (!sScriptMgr->CanSelectSpecTalent(this))
return SPELL_FAILED_DONT_REPORT;
// can't change during already started arena/battleground
if (m_caster->GetTypeId() == TYPEID_PLAYER)
if (m_caster->IsPlayer())
if (Battleground const* bg = m_caster->ToPlayer()->GetBattleground())
if (bg->GetStatus() == STATUS_IN_PROGRESS)
return SPELL_FAILED_NOT_IN_BATTLEGROUND;
@@ -6665,7 +6665,7 @@ SpellCastResult Spell::CheckCast(bool strict)
InstanceTemplate const* it = sObjectMgr->GetInstanceTemplate(m_caster->GetMapId());
if (it)
allowMount = it->AllowMount;
if (m_caster->GetTypeId() == TYPEID_PLAYER && !allowMount && !m_spellInfo->AreaGroupId)
if (m_caster->IsPlayer() && !allowMount && !m_spellInfo->AreaGroupId)
return SPELL_FAILED_NO_MOUNTS_ALLOWED;
if (m_caster->IsInDisallowedMountForm())
@@ -6700,7 +6700,7 @@ SpellCastResult Spell::CheckCast(bool strict)
// not allow cast fly spells if not have req. skills (all spells is self target)
// allow always ghost flight spells
if (m_originalCaster && m_originalCaster->GetTypeId() == TYPEID_PLAYER && m_originalCaster->IsAlive())
if (m_originalCaster && m_originalCaster->IsPlayer() && m_originalCaster->IsAlive())
{
Battlefield* Bf = sBattlefieldMgr->GetBattlefieldToZoneId(m_originalCaster->GetZoneId());
if (AreaTableEntry const* pArea = sAreaTableStore.LookupEntry(m_originalCaster->GetAreaId()))
@@ -7088,7 +7088,7 @@ SpellCastResult Spell::CheckRange(bool strict)
return SPELL_FAILED_TOO_CLOSE;
}
if (m_caster->GetTypeId() == TYPEID_PLAYER && (m_spellInfo->FacingCasterFlags & SPELL_FACING_FLAG_INFRONT) && !m_caster->HasInArc(static_cast<float>(M_PI), target))
if (m_caster->IsPlayer() && (m_spellInfo->FacingCasterFlags & SPELL_FACING_FLAG_INFRONT) && !m_caster->HasInArc(static_cast<float>(M_PI), target))
return SPELL_FAILED_UNIT_NOT_INFRONT;
}
@@ -7123,7 +7123,7 @@ SpellCastResult Spell::CheckPower()
return SPELL_CAST_OK;
//While .cheat power is enabled dont check if we need power to cast the spell
if (m_caster->GetTypeId() == TYPEID_PLAYER)
if (m_caster->IsPlayer())
{
if (m_caster->ToPlayer()->GetCommandStatus(CHEAT_POWER))
{
@@ -7264,7 +7264,7 @@ SpellCastResult Spell::CheckItems()
{
// Xinef: this is not true in my opinion, in eg bladestorm will not be canceled after disarm
//if (!HasTriggeredCastFlag(TRIGGERED_IGNORE_EQUIPPED_ITEM_REQUIREMENT))
if (m_caster->GetTypeId() == TYPEID_PLAYER && !m_caster->ToPlayer()->HasItemFitToSpellRequirements(m_spellInfo))
if (m_caster->IsPlayer() && !m_caster->ToPlayer()->HasItemFitToSpellRequirements(m_spellInfo))
return SPELL_FAILED_EQUIPPED_ITEM_CLASS;
}
@@ -7358,7 +7358,7 @@ SpellCastResult Spell::CheckItems()
{
// m_targets.GetUnitTarget() means explicit cast, otherwise we dont check for possible equip error
Unit* target = m_targets.GetUnitTarget() ? m_targets.GetUnitTarget() : player;
if (target->GetTypeId() == TYPEID_PLAYER && !IsTriggered())
if (target->IsPlayer() && !IsTriggered())
{
// SPELL_EFFECT_CREATE_ITEM_2 differs from SPELL_EFFECT_CREATE_ITEM in that it picks the random item to create from a pool of potential items,
// so we need to make sure there is at least one free space in the player's inventory
@@ -7855,7 +7855,7 @@ bool Spell::UpdatePointers()
m_originalCaster = nullptr;
}
if (m_castItemGUID && m_caster->GetTypeId() == TYPEID_PLAYER)
if (m_castItemGUID && m_caster->IsPlayer())
{
m_CastItem = m_caster->ToPlayer()->GetItemByGuid(m_castItemGUID);
// cast item not found, somehow the item is no longer where we expected
@@ -8118,7 +8118,7 @@ SpellEvent::~SpellEvent()
else
{
LOG_ERROR("spells", "~SpellEvent: {} {} tried to delete non-deletable spell {}. Was not deleted, causes memory leak.",
(m_Spell->GetCaster()->GetTypeId() == TYPEID_PLAYER ? "Player" : "Creature"), m_Spell->GetCaster()->GetGUID().ToString(), m_Spell->m_spellInfo->Id);
(m_Spell->GetCaster()->IsPlayer() ? "Player" : "Creature"), m_Spell->GetCaster()->GetGUID().ToString(), m_Spell->m_spellInfo->Id);
ABORT();
}
}
@@ -8308,7 +8308,7 @@ void Spell::DoAllEffectOnLaunchTarget(TargetInfo& targetInfo, float* multiplier)
if (m_spellInfo->Effects[i].IsAreaAuraEffect() || m_spellInfo->Effects[i].IsTargetingArea() || (m_spellInfo->Effects[i].ChainTarget > 1 && m_spellInfo->DmgClass != SPELL_DAMAGE_CLASS_MAGIC))
{
m_damage = unit->CalculateAOEDamageReduction(m_damage, m_spellInfo->SchoolMask, m_caster);
if (m_caster->GetTypeId() == TYPEID_PLAYER)
if (m_caster->IsPlayer())
{
uint32 targetAmount = m_UniqueTargetInfo.size();
if (targetAmount > 10)
@@ -8817,7 +8817,7 @@ bool Spell::HasGlobalCooldown() const
// Only player or controlled units have global cooldown
if (m_caster->GetCharmInfo())
return m_caster->GetCharmInfo()->GetGlobalCooldownMgr().HasGlobalCooldown(m_spellInfo);
else if (m_caster->GetTypeId() == TYPEID_PLAYER)
else if (m_caster->IsPlayer())
return m_caster->ToPlayer()->GetGlobalCooldownMgr().HasGlobalCooldown(m_spellInfo);
else
return false;
@@ -8835,7 +8835,7 @@ void Spell::TriggerGlobalCooldown()
return;
}
if (m_caster->GetTypeId() == TYPEID_PLAYER)
if (m_caster->IsPlayer())
if (m_caster->ToPlayer()->GetCommandStatus(CHEAT_COOLDOWN))
return;
@@ -8845,7 +8845,7 @@ void Spell::TriggerGlobalCooldown()
if (m_spellInfo->StartRecoveryTime >= MIN_GCD && m_spellInfo->StartRecoveryTime <= MAX_GCD)
{
// gcd modifier auras are applied only to own spells and only players have such mods
if (m_caster->GetTypeId() == TYPEID_PLAYER)
if (m_caster->IsPlayer())
m_caster->ToPlayer()->ApplySpellMod(m_spellInfo->Id, SPELLMOD_GLOBAL_COOLDOWN, gcd, this);
// Apply haste rating
@@ -8864,7 +8864,7 @@ void Spell::TriggerGlobalCooldown()
// Only players or controlled units have global cooldown
if (m_caster->GetCharmInfo())
m_caster->GetCharmInfo()->GetGlobalCooldownMgr().AddGlobalCooldown(m_spellInfo, gcd);
else if (m_caster->GetTypeId() == TYPEID_PLAYER)
else if (m_caster->IsPlayer())
m_caster->ToPlayer()->GetGlobalCooldownMgr().AddGlobalCooldown(m_spellInfo, gcd);
}
@@ -8880,7 +8880,7 @@ void Spell::CancelGlobalCooldown()
// Only players or controlled units have global cooldown
if (m_caster->GetCharmInfo())
m_caster->GetCharmInfo()->GetGlobalCooldownMgr().CancelGlobalCooldown(m_spellInfo);
else if (m_caster->GetTypeId() == TYPEID_PLAYER)
else if (m_caster->IsPlayer())
m_caster->ToPlayer()->GetGlobalCooldownMgr().CancelGlobalCooldown(m_spellInfo);
}

View File

@@ -283,7 +283,7 @@ void Spell::EffectInstaKill(SpellEffIndex /*effIndex*/)
if (!unitTarget || !unitTarget->IsAlive() || unitTarget->HasAura(27827)) // Spirit of redemption doesn't make you death, but can cause infinite loops
return;
if (unitTarget->GetTypeId() == TYPEID_PLAYER)
if (unitTarget->IsPlayer())
if (unitTarget->ToPlayer()->GetCommandStatus(CHEAT_GOD))
return;
@@ -473,7 +473,7 @@ void Spell::EffectSchoolDMG(SpellEffIndex effIndex)
case SPELLFAMILY_DRUID:
{
// Ferocious Bite
if (m_caster->GetTypeId() == TYPEID_PLAYER && (m_spellInfo->SpellFamilyFlags[0] & 0x000800000) && m_spellInfo->SpellVisual[0] == 6587)
if (m_caster->IsPlayer() && (m_spellInfo->SpellFamilyFlags[0] & 0x000800000) && m_spellInfo->SpellVisual[0] == 6587)
{
// converts each extra point of energy into ($f1+$AP/410) additional damage
float ap = m_caster->GetTotalAttackPowerValue(BASE_ATTACK);
@@ -545,7 +545,7 @@ void Spell::EffectSchoolDMG(SpellEffIndex effIndex)
// Eviscerate
else if (m_spellInfo->SpellFamilyFlags[0] & 0x00020000)
{
if (m_caster->GetTypeId() == TYPEID_PLAYER)
if (m_caster->IsPlayer())
{
if (uint32 combo = m_caster->ToPlayer()->GetComboPoints())
{
@@ -712,7 +712,7 @@ void Spell::EffectDummy(SpellEffIndex effIndex)
// HoL, Arc Weld
case 59086:
{
if( m_caster && m_caster->GetTypeId() == TYPEID_PLAYER && m_caster->ToPlayer()->isMoving() )
if( m_caster && m_caster->IsPlayer() && m_caster->ToPlayer()->isMoving() )
m_caster->CastSpell(m_caster, 59097, true);
return;
@@ -934,7 +934,7 @@ void Spell::EffectTriggerSpell(SpellEffIndex effIndex)
}
// Remove spell cooldown (not category) if spell triggering spell with cooldown and same category
if (m_caster->GetTypeId() == TYPEID_PLAYER && spellInfo->CategoryRecoveryTime && m_spellInfo->GetCategory() == spellInfo->GetCategory())
if (m_caster->IsPlayer() && spellInfo->CategoryRecoveryTime && m_spellInfo->GetCategory() == spellInfo->GetCategory())
{
m_caster->ToPlayer()->RemoveSpellCooldown(spellInfo->Id);
}
@@ -988,7 +988,7 @@ void Spell::EffectTriggerMissileSpell(SpellEffIndex effIndex)
}
// Remove spell cooldown (not category) if spell triggering spell with cooldown and same category
if (m_caster->GetTypeId() == TYPEID_PLAYER && spellInfo->CategoryRecoveryTime && m_spellInfo->GetCategory() == spellInfo->GetCategory())
if (m_caster->IsPlayer() && spellInfo->CategoryRecoveryTime && m_spellInfo->GetCategory() == spellInfo->GetCategory())
{
m_caster->ToPlayer()->RemoveSpellCooldown(spellInfo->Id);
}
@@ -1085,7 +1085,7 @@ void Spell::EffectJump(SpellEffIndex effIndex)
CalculateJumpSpeeds(effIndex, m_caster->GetExactDist2d(unitTarget), speedXY, speedZ);
m_caster->GetMotionMaster()->MoveJump(*unitTarget, speedXY, speedZ);
if (m_caster->GetTypeId() == TYPEID_PLAYER)
if (m_caster->IsPlayer())
{
sScriptMgr->AnticheatSetUnderACKmount(m_caster->ToPlayer());
}
@@ -1124,7 +1124,7 @@ void Spell::EffectJumpDest(SpellEffIndex effIndex)
player->SetCanTeleport(true);
}
if (m_caster->GetTypeId() == TYPEID_PLAYER)
if (m_caster->IsPlayer())
{
sScriptMgr->AnticheatSetUnderACKmount(m_caster->ToPlayer());
}
@@ -1148,7 +1148,7 @@ void Spell::EffectJumpDest(SpellEffIndex effIndex)
}
m_caster->GetMotionMaster()->MoveJump(x, y, z, speedXY, speedZ);
if (m_caster->GetTypeId() == TYPEID_PLAYER)
if (m_caster->IsPlayer())
{
sScriptMgr->AnticheatSetUnderACKmount(m_caster->ToPlayer());
}
@@ -1173,7 +1173,7 @@ void Spell::EffectTeleportUnits(SpellEffIndex /*effIndex*/)
if (!unitTarget || unitTarget->IsInFlight())
return;
if (unitTarget->GetTypeId() == TYPEID_PLAYER)
if (unitTarget->IsPlayer())
{
sScriptMgr->AnticheatSetUnderACKmount(unitTarget->ToPlayer());
}
@@ -1215,13 +1215,13 @@ void Spell::EffectTeleportUnits(SpellEffIndex /*effIndex*/)
unitTarget->GetVehicleKit()->TeleportVehicle(x, y, z, orientation);
else
{
bool withPet = unitTarget->GetTypeId() == TYPEID_PLAYER && m_spellInfo->SpellFamilyName == SPELLFAMILY_GENERIC && unitTarget->GetMap()->IsDungeon() && unitTarget->GetExactDist(x, y, z) > 50.0f;
bool withPet = unitTarget->IsPlayer() && m_spellInfo->SpellFamilyName == SPELLFAMILY_GENERIC && unitTarget->GetMap()->IsDungeon() && unitTarget->GetExactDist(x, y, z) > 50.0f;
unitTarget->NearTeleportTo(x, y, z, orientation, unitTarget == m_caster, false, withPet, true);
if (unitTarget->GetTypeId() == TYPEID_PLAYER) // pussywizard: for units it's done inside NearTeleportTo
if (unitTarget->IsPlayer()) // pussywizard: for units it's done inside NearTeleportTo
unitTarget->UpdateObjectVisibility(true);
}
}
else if (unitTarget->GetTypeId() == TYPEID_PLAYER)
else if (unitTarget->IsPlayer())
unitTarget->ToPlayer()->TeleportTo(mapid, x, y, z, orientation, unitTarget == m_caster ? TELE_TO_SPELL : 0);
else
{
@@ -1878,7 +1878,7 @@ void Spell::EffectEnergize(SpellEffIndex effIndex)
Powers power = Powers(m_spellInfo->Effects[effIndex].MiscValue);
if (unitTarget->GetTypeId() == TYPEID_PLAYER && !unitTarget->HasActivePowerType(power) && m_spellInfo->SpellFamilyName != SPELLFAMILY_POTION
if (unitTarget->IsPlayer() && !unitTarget->HasActivePowerType(power) && m_spellInfo->SpellFamilyName != SPELLFAMILY_POTION
&& !m_spellInfo->HasAttribute(SPELL_ATTR7_ONLY_IN_SPELLBOOK_UNTIL_LEARNED))
return;
@@ -1983,7 +1983,7 @@ void Spell::EffectEnergizePct(SpellEffIndex effIndex)
Powers power = Powers(m_spellInfo->Effects[effIndex].MiscValue);
if (unitTarget->GetTypeId() == TYPEID_PLAYER && !unitTarget->HasActivePowerType(power) && !m_spellInfo->HasAttribute(SPELL_ATTR7_ONLY_IN_SPELLBOOK_UNTIL_LEARNED))
if (unitTarget->IsPlayer() && !unitTarget->HasActivePowerType(power) && !m_spellInfo->HasAttribute(SPELL_ATTR7_ONLY_IN_SPELLBOOK_UNTIL_LEARNED))
return;
uint32 maxPower = unitTarget->GetMaxPower(power);
@@ -2725,7 +2725,7 @@ void Spell::EffectUntrainTalents(SpellEffIndex /*effIndex*/)
if (effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET)
return;
if (!unitTarget || m_caster->GetTypeId() == TYPEID_PLAYER)
if (!unitTarget || m_caster->IsPlayer())
return;
if (ObjectGuid guid = m_caster->GetGUID()) // the trainer is the caster
@@ -3108,7 +3108,7 @@ void Spell::EffectTameCreature(SpellEffIndex /*effIndex*/)
pet->InitTalentForLevel();
if (m_caster->GetTypeId() == TYPEID_PLAYER)
if (m_caster->IsPlayer())
{
pet->SavePetToDB(PET_SAVE_AS_CURRENT);
m_caster->ToPlayer()->PetSpellInitialize();
@@ -3187,7 +3187,7 @@ void Spell::EffectSummonPet(SpellEffIndex effIndex)
return;
}
if (owner->GetTypeId() == TYPEID_PLAYER)
if (owner->IsPlayer())
owner->ToPlayer()->RemovePet(OldSummon, PET_SAVE_NOT_IN_SLOT, false);
else
return;
@@ -3367,7 +3367,7 @@ void Spell::EffectWeaponDmg(SpellEffIndex effIndex)
AddComboPointGain(unitTarget, 1);
}
// 50% more damage with daggers
if (m_caster->GetTypeId() == TYPEID_PLAYER)
if (m_caster->IsPlayer())
if (Item* item = m_caster->ToPlayer()->GetWeaponForAttack(m_attackType, true))
if (item->GetTemplate()->SubClass == ITEM_SUBCLASS_WEAPON_DAGGER)
AddPct(totalDamagePercentMod, 50.0f);
@@ -4018,7 +4018,7 @@ void Spell::EffectSanctuary(SpellEffIndex /*effIndex*/)
if (m_spellInfo->Id != 59646)
unitTarget->getHostileRefMgr().addThreatPercent(-100);
if (unitTarget->GetTypeId() == TYPEID_PLAYER)
if (unitTarget->IsPlayer())
unitTarget->ToPlayer()->SendAttackSwingCancelAttack(); // melee and ranged forced attack cancel
}
else
@@ -4669,7 +4669,7 @@ void Spell::EffectParry(SpellEffIndex /*effIndex*/)
if (effectHandleMode != SPELL_EFFECT_HANDLE_HIT)
return;
if (m_caster->GetTypeId() == TYPEID_PLAYER)
if (m_caster->IsPlayer())
m_caster->ToPlayer()->SetCanParry(true);
}
@@ -4678,7 +4678,7 @@ void Spell::EffectBlock(SpellEffIndex /*effIndex*/)
if (effectHandleMode != SPELL_EFFECT_HANDLE_HIT)
return;
if (m_caster->GetTypeId() == TYPEID_PLAYER)
if (m_caster->IsPlayer())
m_caster->ToPlayer()->SetCanBlock(true);
}
@@ -4949,7 +4949,7 @@ void Spell::EffectChargeDest(SpellEffIndex /*effIndex*/)
m_caster->GetMotionMaster()->MoveCharge(pos.m_positionX, pos.m_positionY, pos.m_positionZ);
if (m_caster->GetTypeId() == TYPEID_PLAYER)
if (m_caster->IsPlayer())
{
sScriptMgr->AnticheatSetUnderACKmount(m_caster->ToPlayer());
}
@@ -5007,7 +5007,7 @@ void Spell::EffectKnockBack(SpellEffIndex effIndex)
unitTarget->KnockbackFrom(x, y, speedxy, speedz);
if (unitTarget->GetTypeId() == TYPEID_PLAYER)
if (unitTarget->IsPlayer())
{
sScriptMgr->AnticheatSetUnderACKmount(unitTarget->ToPlayer());
}
@@ -5026,13 +5026,13 @@ void Spell::EffectLeapBack(SpellEffIndex effIndex)
//1891: Disengage
m_caster->JumpTo(speedxy, speedz, m_spellInfo->SpellFamilyName != SPELLFAMILY_HUNTER);
if (m_caster->GetTypeId() == TYPEID_PLAYER)
if (m_caster->IsPlayer())
{
sScriptMgr->AnticheatSetUnderACKmount(m_caster->ToPlayer());
}
// xinef: changes fall time
if (m_caster->GetTypeId() == TYPEID_PLAYER)
if (m_caster->IsPlayer())
m_caster->ToPlayer()->SetFallInformation(GameTime::GetGameTime().count(), m_caster->GetPositionZ());
}
@@ -5125,7 +5125,7 @@ void Spell::EffectPullTowards(SpellEffIndex effIndex)
unitTarget->GetMotionMaster()->MoveJump(pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), speedXY, speedZ);
if (unitTarget->GetTypeId() == TYPEID_PLAYER)
if (unitTarget->IsPlayer())
{
sScriptMgr->AnticheatSetUnderACKmount(unitTarget->ToPlayer());
}
@@ -5421,7 +5421,7 @@ void Spell::EffectTransmitted(SpellEffIndex effIndex)
}
case GAMEOBJECT_TYPE_SUMMONING_RITUAL:
{
if (m_caster->GetTypeId() == TYPEID_PLAYER)
if (m_caster->IsPlayer())
{
pGameObj->AddUniqueUse(m_caster->ToPlayer());
m_caster->AddGameObject(pGameObj); // will be removed at spell cancel
@@ -5836,7 +5836,7 @@ void Spell::EffectCreateTamedPet(SpellEffIndex effIndex)
pet->InitTalentForLevel();
if (unitTarget->GetTypeId() == TYPEID_PLAYER)
if (unitTarget->IsPlayer())
{
pet->SavePetToDB(PET_SAVE_AS_CURRENT);
unitTarget->ToPlayer()->PetSpellInitialize();
@@ -5867,7 +5867,7 @@ void Spell::EffectTitanGrip(SpellEffIndex /*effIndex*/)
if (effectHandleMode != SPELL_EFFECT_HANDLE_HIT)
return;
if (m_caster->GetTypeId() == TYPEID_PLAYER)
if (m_caster->IsPlayer())
{
if (Aura* aur = m_caster->GetAura(49152))
aur->RecalculateAmountOfEffects();
@@ -5942,7 +5942,7 @@ void Spell::SummonGuardian(uint32 i, uint32 entry, SummonPropertiesEntry const*
uint8 summonLevel = caster->GetLevel();
// level of pet summoned using engineering item based at engineering skill level
if (m_CastItem && caster->GetTypeId() == TYPEID_PLAYER)
if (m_CastItem && caster->IsPlayer())
if (ItemTemplate const* proto = m_CastItem->GetTemplate())
{
// xinef: few special cases

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;