mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-18 19:35:42 +00:00
refactor(Core/Object): adds consistency in the use of type object check (#19671)
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user