TrinityCore
Spell Class Reference

#include <Spell.h>

Classes

struct  GOTargetInfo
 
struct  HitTriggerSpell
 
struct  ItemTargetInfo
 
struct  TargetInfo
 
struct  TargetInfoBase
 

Public Types

typedef std::unordered_set< Aura * > UsedSpellMods
 

Public Member Functions

void EffectNULL ()
 
void EffectUnused ()
 
void EffectDistract ()
 
void EffectSchoolDMG ()
 
void EffectEnvironmentalDMG ()
 
void EffectInstaKill ()
 
void EffectDummy ()
 
void EffectTeleportUnits ()
 
void EffectApplyAura ()
 
void EffectSendEvent ()
 
void EffectPowerBurn ()
 
void EffectPowerDrain ()
 
void EffectHeal ()
 
void EffectBind ()
 
void EffectTeleportToReturnPoint ()
 
void EffectHealthLeech ()
 
void EffectQuestComplete ()
 
void EffectCreateItem ()
 
void EffectCreateItem2 ()
 
void EffectCreateRandomItem ()
 
void EffectPersistentAA ()
 
void EffectEnergize ()
 
void EffectOpenLock ()
 
void EffectSummonChangeItem ()
 
void EffectProficiency ()
 
void EffectSummonType ()
 
void EffectLearnSpell ()
 
void EffectDispel ()
 
void EffectDualWield ()
 
void EffectPickPocket ()
 
void EffectAddFarsight ()
 
void EffectUntrainTalents ()
 
void EffectHealMechanical ()
 
void EffectJump ()
 
void EffectJumpDest ()
 
void EffectLeapBack ()
 
void EffectQuestClear ()
 
void EffectTeleUnitsFaceCaster ()
 
void EffectLearnSkill ()
 
void EffectPlayMovie ()
 
void EffectTradeSkill ()
 
void EffectEnchantItemPerm ()
 
void EffectEnchantItemTmp ()
 
void EffectTameCreature ()
 
void EffectSummonPet ()
 
void EffectLearnPetSpell ()
 
void EffectWeaponDmg ()
 
void EffectForceCast ()
 
void EffectTriggerSpell ()
 
void EffectTriggerMissileSpell ()
 
void EffectThreat ()
 
void EffectHealMaxHealth ()
 
void EffectInterruptCast ()
 
void EffectSummonObjectWild ()
 
void EffectScriptEffect ()
 
void EffectSanctuary ()
 
void EffectDuel ()
 
void EffectStuck ()
 
void EffectSummonPlayer ()
 
void EffectActivateObject ()
 
void EffectApplyGlyph ()
 
void EffectEnchantHeldItem ()
 
void EffectSummonObject ()
 
void EffectChangeRaidMarker ()
 
void EffectResurrect ()
 
void EffectParry ()
 
void EffectBlock ()
 
void EffectLeap ()
 
void EffectTransmitted ()
 
void EffectDisEnchant ()
 
void EffectInebriate ()
 
void EffectFeedPet ()
 
void EffectDismissPet ()
 
void EffectReputation ()
 
void EffectForceDeselect ()
 
void EffectSelfResurrect ()
 
void EffectSkinning ()
 
void EffectCharge ()
 
void EffectChargeDest ()
 
void EffectProspecting ()
 
void EffectMilling ()
 
void EffectRenamePet ()
 
void EffectSendTaxi ()
 
void EffectKnockBack ()
 
void EffectPullTowards ()
 
void EffectDispelMechanic ()
 
void EffectResurrectPet ()
 
void EffectDestroyAllTotems ()
 
void EffectDurabilityDamage ()
 
void EffectSkill ()
 
void EffectTaunt ()
 
void EffectDurabilityDamagePCT ()
 
void EffectModifyThreatPercent ()
 
void EffectResurrectNew ()
 
void EffectAddExtraAttacks ()
 
void EffectSpiritHeal ()
 
void EffectSkinPlayerCorpse ()
 
void EffectStealBeneficialBuff ()
 
void EffectUnlearnSpecialization ()
 
void EffectHealPct ()
 
void EffectEnergizePct ()
 
void EffectTriggerRitualOfSummoning ()
 
void EffectSummonRaFFriend ()
 
void EffectUnlockGuildVaultTab ()
 
void EffectKillCreditPersonal ()
 
void EffectKillCredit ()
 
void EffectQuestFail ()
 
void EffectQuestStart ()
 
void EffectRedirectThreat ()
 
void EffectGameObjectDamage ()
 
void EffectGameObjectRepair ()
 
void EffectGameObjectSetDestructionState ()
 
void EffectCreateTamedPet ()
 
void EffectDiscoverTaxi ()
 
void EffectTitanGrip ()
 
void EffectEnchantItemPrismatic ()
 
void EffectPlayMusic ()
 
void EffectActivateSpec ()
 
void EffectPlaySound ()
 
void EffectRemoveAura ()
 
void EffectDamageFromMaxHealthPCT ()
 
void EffectCastButtons ()
 
void EffectRechargeItem ()
 
void EffectGiveCurrency ()
 
void EffectSummonPersonalGameObject ()
 
void EffectResurrectWithAura ()
 
void EffectCreateAreaTrigger ()
 
void EffectRemoveTalent ()
 
void EffectDestroyItem ()
 
void EffectLearnGarrisonBuilding ()
 
void EffectCreateGarrison ()
 
void EffectCreateConversation ()
 
void EffectAddGarrisonFollower ()
 
void EffectActivateGarrisonBuilding ()
 
void EffectHealBattlePetPct ()
 
void EffectEnableBattlePets ()
 
void EffectLaunchQuestChoice ()
 
void EffectUncageBattlePet ()
 
void EffectCreateHeirloomItem ()
 
void EffectUpgradeHeirloom ()
 
void EffectApplyEnchantIllusion ()
 
void EffectUpdatePlayerPhase ()
 
void EffectUpdateZoneAurasAndPhases ()
 
void EffectGiveArtifactPower ()
 
void EffectGiveArtifactPowerNoBonus ()
 
void EffectPlaySceneScriptPackage ()
 
void EffectPlayScene ()
 
void EffectGiveHonor ()
 
void EffectLearnTransmogSet ()
 
void EffectRespecAzeriteEmpoweredItem ()
 
void EffectLearnAzeriteEssencePower ()
 
void EffectCreatePrivateConversation ()
 
void EffectSendChatMessage ()
 
 Spell (WorldObject *caster, SpellInfo const *info, TriggerCastFlags triggerFlags, ObjectGuid originalCasterGUID=ObjectGuid::Empty)
 
 ~Spell ()
 
void InitExplicitTargets (SpellCastTargets const &targets)
 
void SelectExplicitTargets ()
 
void SelectSpellTargets ()
 
void SelectEffectImplicitTargets (SpellEffectInfo const &spellEffectInfo, SpellImplicitTargetInfo const &targetType, uint32 &processedEffectMask)
 
void SelectImplicitChannelTargets (SpellEffectInfo const &spellEffectInfo, SpellImplicitTargetInfo const &targetType)
 
void SelectImplicitNearbyTargets (SpellEffectInfo const &spellEffectInfo, SpellImplicitTargetInfo const &targetType, uint32 effMask)
 
void SelectImplicitConeTargets (SpellEffectInfo const &spellEffectInfo, SpellImplicitTargetInfo const &targetType, uint32 effMask)
 
void SelectImplicitAreaTargets (SpellEffectInfo const &spellEffectInfo, SpellImplicitTargetInfo const &targetType, uint32 effMask)
 
void SelectImplicitCasterDestTargets (SpellEffectInfo const &spellEffectInfo, SpellImplicitTargetInfo const &targetType)
 
void SelectImplicitTargetDestTargets (SpellEffectInfo const &spellEffectInfo, SpellImplicitTargetInfo const &targetType)
 
void SelectImplicitDestDestTargets (SpellEffectInfo const &spellEffectInfo, SpellImplicitTargetInfo const &targetType)
 
void SelectImplicitCasterObjectTargets (SpellEffectInfo const &spellEffectInfo, SpellImplicitTargetInfo const &targetType)
 
void SelectImplicitTargetObjectTargets (SpellEffectInfo const &spellEffectInfo, SpellImplicitTargetInfo const &targetType)
 
void SelectImplicitChainTargets (SpellEffectInfo const &spellEffectInfo, SpellImplicitTargetInfo const &targetType, WorldObject *target, uint32 effMask)
 
void SelectImplicitTrajTargets (SpellEffectInfo const &spellEffectInfo, SpellImplicitTargetInfo const &targetType)
 
void SelectImplicitLineTargets (SpellEffectInfo const &spellEffectInfo, SpellImplicitTargetInfo const &targetType, uint32 effMask)
 
void SelectEffectTypeImplicitTargets (SpellEffectInfo const &spellEffectInfo)
 
uint32 GetSearcherTypeMask (SpellTargetObjectTypes objType, ConditionContainer *condList)
 
template<class SEARCHER >
void SearchTargets (SEARCHER &searcher, uint32 containerMask, WorldObject *referer, Position const *pos, float radius)
 
WorldObjectSearchNearbyTarget (float range, SpellTargetObjectTypes objectType, SpellTargetCheckTypes selectionType, ConditionContainer *condList=nullptr)
 
void SearchAreaTargets (std::list< WorldObject *> &targets, float range, Position const *position, WorldObject *referer, SpellTargetObjectTypes objectType, SpellTargetCheckTypes selectionType, ConditionContainer *condList)
 
void SearchChainTargets (std::list< WorldObject *> &targets, uint32 chainTargets, WorldObject *target, SpellTargetObjectTypes objectType, SpellTargetCheckTypes selectType, ConditionContainer *condList, bool isChainHeal)
 
GameObjectSearchSpellFocus ()
 
void prepare (SpellCastTargets const &targets, AuraEffect const *triggeredByAura=nullptr)
 
void cancel ()
 
void update (uint32 difftime)
 
void cast (bool skipCheck=false)
 
void finish (bool ok=true)
 
void TakePower ()
 
void TakeRunePower (bool didHit)
 
void TakeReagents ()
 
void TakeCastItem ()
 
SpellCastResult CheckCast (bool strict, uint32 *param1=nullptr, uint32 *param2=nullptr)
 
SpellCastResult CheckPetCast (Unit *target)
 
void handle_immediate ()
 
uint64 handle_delayed (uint64 t_offset)
 
void _handle_immediate_phase ()
 
void _handle_finish_phase ()
 
SpellCastResult CheckItems (uint32 *param1, uint32 *param2) const
 
SpellCastResult CheckRange (bool strict) const
 
SpellCastResult CheckPower () const
 
SpellCastResult CheckRuneCost () const
 
SpellCastResult CheckCasterAuras (uint32 *param1) const
 
SpellCastResult CheckArenaAndRatedBattlegroundCastRules ()
 
bool CheckSpellCancelsAuraEffect (AuraType auraType, uint32 *param1) const
 
bool CheckSpellCancelsCharm (uint32 *param1) const
 
bool CheckSpellCancelsStun (uint32 *param1) const
 
bool CheckSpellCancelsSilence (uint32 *param1) const
 
bool CheckSpellCancelsPacify (uint32 *param1) const
 
bool CheckSpellCancelsFear (uint32 *param1) const
 
bool CheckSpellCancelsConfuse (uint32 *param1) const
 
bool CheckSpellCancelsNoActions (uint32 *param1) const
 
int32 CalculateDamage (SpellEffectInfo const &spellEffectInfo, Unit const *target, float *var=nullptr) const
 
void Delayed ()
 
void DelayedChannel ()
 
uint32 getState () const
 
void setState (uint32 state)
 
void DoCreateItem (uint32 itemId, ItemContext context=ItemContext::NONE, std::vector< int32 > const &bonusListIDs=std::vector< int32 >())
 
bool CheckEffectTarget (Unit const *target, SpellEffectInfo const &spellEffectInfo, Position const *losPosition) const
 
bool CheckEffectTarget (GameObject const *target, SpellEffectInfo const &spellEffectInfo) const
 
bool CheckEffectTarget (Item const *target, SpellEffectInfo const &spellEffectInfo) const
 
bool CanAutoCast (Unit *target)
 
void CheckSrc ()
 
void CheckDst ()
 
void SendCastResult (SpellCastResult result, uint32 *param1=nullptr, uint32 *param2=nullptr) const
 
void SendPetCastResult (SpellCastResult result, uint32 *param1=nullptr, uint32 *param2=nullptr) const
 
void SendMountResult (MountResult result)
 
void SendSpellStart ()
 
void SendSpellGo ()
 
void SendSpellCooldown ()
 
void SendSpellExecuteLog ()
 
SpellLogEffectGetExecuteLogEffect (SpellEffectName effect)
 
template<typename T >
std::vector< T > & GetExecuteLogEffectTargets (SpellEffectName effect, Optional< std::vector< T >> SpellLogEffect::*member)
 
void ExecuteLogEffectTakeTargetPower (SpellEffectName effect, Unit *target, uint32 powerType, uint32 points, float amplitude)
 
void ExecuteLogEffectExtraAttacks (SpellEffectName effect, Unit *victim, uint32 numAttacks)
 
void ExecuteLogEffectDurabilityDamage (SpellEffectName effect, Unit *victim, int32 itemId, int32 amount)
 
void ExecuteLogEffectOpenLock (SpellEffectName effect, Object *obj)
 
void ExecuteLogEffectCreateItem (SpellEffectName effect, uint32 entry)
 
void ExecuteLogEffectDestroyItem (SpellEffectName effect, uint32 entry)
 
void ExecuteLogEffectSummonObject (SpellEffectName effect, WorldObject *obj)
 
void ExecuteLogEffectUnsummonObject (SpellEffectName effect, WorldObject *obj)
 
void ExecuteLogEffectResurrect (SpellEffectName effect, Unit *target)
 
void SendSpellInterruptLog (Unit *victim, uint32 spellId)
 
void SendInterrupted (uint8 result)
 
void SendChannelUpdate (uint32 time)
 
void SendChannelStart (uint32 duration)
 
void SendResurrectRequest (Player *target)
 
void HandleEffects (Unit *pUnitTarget, Item *pItemTarget, GameObject *pGOTarget, SpellEffectInfo const &spellEffectInfo, SpellEffectHandleMode mode)
 
void HandleThreatSpells ()
 
int32 GetCastTime () const
 
bool IsAutoRepeat () const
 
void SetAutoRepeat (bool rep)
 
void ReSetTimer ()
 
bool IsTriggered () const
 
bool IsIgnoringCooldowns () const
 
bool IsFocusDisabled () const
 
bool IsProcDisabled () const
 
bool IsChannelActive () const
 
bool IsAutoActionResetSpell () const
 
bool IsPositive () const
 
bool IsTriggeredByAura (SpellInfo const *auraSpellInfo) const
 
bool IsDeletable () const
 
void SetReferencedFromCurrent (bool yes)
 
bool IsInterruptable () const
 
void SetExecutedCurrently (bool yes)
 
uint64 GetDelayStart () const
 
void SetDelayStart (uint64 m_time)
 
uint64 GetDelayMoment () const
 
uint64 CalculateDelayMomentForDst (float launchDelay) const
 
void RecalculateDelayMomentForDst ()
 
bool IsNeedSendToClient () const
 
CurrentSpellTypes GetCurrentContainer () const
 
WorldObjectGetCaster () const
 
UnitGetOriginalCaster () const
 
SpellInfo const * GetSpellInfo () const
 
Difficulty GetCastDifficulty () const
 
std::vector< SpellPowerCost > const & GetPowerCost () const
 
bool HasPowerTypeCost (Powers power) const
 
bool UpdatePointers ()
 
void CleanupTargetList ()
 
void SetSpellValue (SpellValueMod mod, int32 value)
 
SpellInfo const * GetTriggeredByAuraSpell () const
 
int32 GetTimer () const
 
int64 GetUnitTargetCountForEffect (SpellEffIndex effect) const
 
int64 GetGameObjectTargetCountForEffect (SpellEffIndex effect) const
 
int64 GetItemTargetCountForEffect (SpellEffIndex effect) const
 
void CallScriptCalcCritChanceHandlers (Unit const *victim, float &chance)
 

Static Public Member Functions

static void SendCastResult (Player *caster, SpellInfo const *spellInfo, SpellCastVisual spellVisual, ObjectGuid cast_count, SpellCastResult result, SpellCustomErrors customError=SPELL_CUSTOM_ERROR_NONE, uint32 *param1=nullptr, uint32 *param2=nullptr)
 
static Spell const * ExtractSpellFromEvent (BasicEvent *event)
 

Public Attributes

SpellInfo const *const m_spellInfo
 
Itemm_CastItem
 
ObjectGuid m_castItemGUID
 
uint32 m_castItemEntry
 
int32 m_castItemLevel
 
ObjectGuid m_castId
 
ObjectGuid m_originalCastId
 
bool m_fromClient
 
uint32 m_castFlagsEx
 
union {
   uint32   TalentId
 
   uint32   SpellId
 
   uint32   SpecializationId
 
   struct {
      uint32   Id
 
      uint32   AbilityId
 
   }   GarrFollower
 
   uint32   GarrMissionId
 
   uint32   ItemId
 
   struct {
      uint32   Data [2]
 
   }   Raw
 
m_misc
 
SpellCastVisual m_SpellVisual
 
SpellCastTargets m_targets
 
int8 m_comboPointGain
 
SpellCustomErrors m_customError
 
UsedSpellMods m_appliedMods
 
Spell ** m_selfContainer
 

Protected Types

typedef std::vector< HitTriggerSpellHitTriggerSpellList
 

Protected Member Functions

bool HasGlobalCooldown () const
 
void TriggerGlobalCooldown ()
 
void CancelGlobalCooldown ()
 
void _cast (bool skipCheck=false)
 
void SendLoot (ObjectGuid guid, LootType loottype)
 
std::pair< float, float > GetMinMaxRange (bool strict) const
 
bool IsDelayableNoMore ()
 
void prepareDataForTriggerSystem ()
 
template<class Container >
void DoProcessTargetContainer (Container &targetContainer)
 
void AddUnitTarget (Unit *target, uint32 effectMask, bool checkIfValid=true, bool implicit=true, Position const *losPosition=nullptr)
 
void AddGOTarget (GameObject *target, uint32 effectMask)
 
void AddItemTarget (Item *item, uint32 effectMask)
 
void AddDestTarget (SpellDestination const &dest, uint32 effIndex)
 
SpellMissInfo PreprocessSpellHit (Unit *unit, TargetInfo &targetInfo)
 
void DoSpellEffectHit (Unit *unit, SpellEffectInfo const &spellEffectInfo, TargetInfo &targetInfo)
 
void DoTriggersOnSpellHit (Unit *unit, uint32 effMask)
 
bool UpdateChanneledTargetList ()
 
bool IsValidDeadOrAliveTarget (Unit const *target) const
 
void HandleLaunchPhase ()
 
void DoEffectOnLaunchTarget (TargetInfo &targetInfo, float multiplier, SpellEffectInfo const &spellEffectInfo)
 
void PrepareTargetProcessing ()
 
void FinishTargetProcessing ()
 
void LoadScripts ()
 
void CallScriptBeforeCastHandlers ()
 
void CallScriptOnCastHandlers ()
 
void CallScriptAfterCastHandlers ()
 
SpellCastResult CallScriptCheckCastHandlers ()
 
bool CallScriptEffectHandlers (SpellEffIndex effIndex, SpellEffectHandleMode mode)
 
void CallScriptSuccessfulDispel (SpellEffIndex effIndex)
 
void CallScriptBeforeHitHandlers (SpellMissInfo missInfo)
 
void CallScriptOnHitHandlers ()
 
void CallScriptAfterHitHandlers ()
 
void CallScriptObjectAreaTargetSelectHandlers (std::list< WorldObject *> &targets, SpellEffIndex effIndex, SpellImplicitTargetInfo const &targetType)
 
void CallScriptObjectTargetSelectHandlers (WorldObject *&target, SpellEffIndex effIndex, SpellImplicitTargetInfo const &targetType)
 
void CallScriptDestinationTargetSelectHandlers (SpellDestination &target, SpellEffIndex effIndex, SpellImplicitTargetInfo const &targetType)
 
bool CheckScriptEffectImplicitTargets (uint32 effIndex, uint32 effIndexToCheck)
 
bool CanExecuteTriggersOnHit (uint32 effMask, SpellInfo const *triggeredByAura=nullptr) const
 
void PrepareTriggersExecutedOnHit ()
 
void SummonGuardian (SpellEffectInfo const *effect, uint32 entry, SummonPropertiesEntry const *properties, uint32 numSummons, ObjectGuid privateObjectOwner)
 
void UpdateSpellCastDataTargets (WorldPackets::Spells::SpellCastData &data)
 Writes miss and hit targets for a SMSG_SPELL_GO packet. More...
 
void UpdateSpellCastDataAmmo (WorldPackets::Spells::SpellAmmo &data)
 
SpellCastResult CanOpenLock (SpellEffectInfo const &effect, uint32 lockid, SkillType &skillid, int32 &reqSkillValue, int32 &skillValue)
 
 Spell (Spell const &right)=delete
 
Spelloperator= (Spell const &right)=delete
 

Protected Attributes

WorldObject *const m_caster
 
SpellValue *const m_spellValue
 
ObjectGuid m_originalCasterGUID
 
Unitm_originalCaster
 
SpellSchoolMask m_spellSchoolMask
 
WeaponAttackType m_attackType
 
std::vector< SpellPowerCostm_powerCost
 
int32 m_casttime
 
int32 m_channeledDuration
 
bool m_canReflect
 
bool m_autoRepeat
 
uint8 m_runesState
 
uint8 m_delayAtDamageCount
 
uint64 m_delayStart
 
uint64 m_delayMoment
 
bool m_launchHandled
 
bool m_immediateHandled
 
bool m_referencedFromCurrentSpell
 
bool m_executedCurrently
 
bool m_needComboPoints
 
uint32 m_applyMultiplierMask
 
float m_damageMultipliers [MAX_SPELL_EFFECTS]
 
UnitunitTarget
 
ItemitemTarget
 
GameObjectgameObjTarget
 
WorldLocationdestTarget
 
int32 damage
 
SpellMissInfo targetMissInfo
 
float variance
 
SpellEffectHandleMode effectHandleMode
 
SpellEffectInfo const * effectInfo
 
UnitunitCaster
 
UnitAura_spellAura
 
DynObjAura_dynObjAura
 
GameObjectfocusObject
 
int32 m_damage
 
int32 m_healing
 
uint32 m_procAttacker
 
uint32 m_procVictim
 
uint32 m_hitMask
 
std::vector< TargetInfom_UniqueTargetInfo
 
uint32 m_channelTargetEffectMask
 
std::vector< GOTargetInfom_UniqueGOTargetInfo
 
std::vector< ItemTargetInfom_UniqueItemInfo
 
SpellDestination m_destTargets [MAX_SPELL_EFFECTS]
 
std::vector< SpellScript * > m_loadedScripts
 
HitTriggerSpellList m_hitTriggerSpells
 
uint32 m_spellState
 
int32 m_timer
 
SpellEvent_spellEvent
 
TriggerCastFlags _triggeredCastFlags
 
SpellInfo const * m_triggeredByAuraSpell
 
std::unique_ptr< PathGeneratorm_preGeneratedPath
 
std::vector< SpellLogEffect_executeLogEffects
 

Friends

class SpellScript
 
void SetUnitCurrentCastSpell (Unit *unit, Spell *spell)
 

Member Typedef Documentation

◆ HitTriggerSpellList

typedef std::vector<HitTriggerSpell> Spell::HitTriggerSpellList
protected

◆ UsedSpellMods

typedef std::unordered_set<Aura*> Spell::UsedSpellMods

Constructor & Destructor Documentation

◆ Spell() [1/2]

Spell::Spell ( WorldObject caster,
SpellInfo const *  info,
TriggerCastFlags  triggerFlags,
ObjectGuid  originalCasterGUID = ObjectGuid::Empty 
)
502  :
503 m_spellInfo(info), m_caster((info->HasAttribute(SPELL_ATTR6_CAST_BY_CHARMER) && caster->GetCharmerOrOwner()) ? caster->GetCharmerOrOwner() : caster),
504 m_spellValue(new SpellValue(m_spellInfo, caster)), _spellEvent(nullptr)
505 {
507  m_fromClient = false;
508  m_selfContainer = nullptr;
510  m_executedCurrently = false;
512  m_comboPointGain = 0;
513  m_delayStart = 0;
515 
517  memset(m_damageMultipliers, 0, sizeof(m_damageMultipliers));
518 
519  // Get data for type of attack
520  m_attackType = info->GetAttackType();
521 
522  m_spellSchoolMask = info->GetSchoolMask(); // Can be override for some spell (wand shoot for example)
523 
524  if (Player const* playerCaster = m_caster->ToPlayer())
525  {
526  // wand case
528  if ((playerCaster->getClassMask() & CLASSMASK_WAND_USERS) != 0)
529  if (Item* pItem = playerCaster->GetWeaponForAttack(RANGED_ATTACK))
530  m_spellSchoolMask = SpellSchoolMask(1 << pItem->GetTemplate()->GetDamageType());
531  }
532 
533  if (Player const* modOwner = caster->GetSpellModOwner())
534  modOwner->ApplySpellMod(info, SpellModOp::Doses, m_spellValue->AuraStackAmount, this);
535 
536  if (!originalCasterGUID.IsEmpty())
537  m_originalCasterGUID = originalCasterGUID;
538  else
540 
543  else
544  {
547  m_originalCaster = nullptr;
548  }
549 
551  _triggeredCastFlags = triggerFlags;
552  if (info->HasAttribute(SPELL_ATTR4_CAN_CAST_WHILE_CASTING))
554 
555  m_CastItem = nullptr;
557  m_castItemEntry = 0;
558  m_castItemLevel = -1;
559  m_castFlagsEx = 0;
560 
561  unitTarget = nullptr;
562  itemTarget = nullptr;
563  gameObjTarget = nullptr;
564  destTarget = nullptr;
565  damage = 0;
567  variance = 0.0f;
569  effectInfo = nullptr;
570  m_damage = 0;
571  m_healing = 0;
572  m_procAttacker = 0;
573  m_procVictim = 0;
574  m_hitMask = 0;
575  focusObject = nullptr;
577  memset(m_misc.Raw.Data, 0, sizeof(m_misc.Raw.Data));
579  m_triggeredByAuraSpell = nullptr;
580  unitCaster = nullptr;
581  _spellAura = nullptr;
582  _dynObjAura = nullptr;
583 
584  //Auto Shot & Shoot (wand)
586 
587  m_runesState = 0;
588  m_casttime = 0; // setup to correct value in Spell::prepare, must not be used before.
589  m_timer = 0; // will set to castime in prepare
590  m_channeledDuration = 0; // will be setup in Spell::handle_immediate
591  m_launchHandled = false;
592  m_immediateHandled = false;
593 
595 
596  // Determine if spell can be reflected back to the caster
597  // Patch 1.2 notes: Spell Reflection no longer reflects abilities
600  && !m_spellInfo->IsPassive();
601 
603 
604  for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
606 }
GameObject * focusObject
Definition: Spell.h:799
Definition: Spell.h:328
GameObject * gameObjTarget
Definition: Spell.h:786
SpellInfo const *const m_spellInfo
Definition: Spell.h:632
uint32 m_spellState
Definition: Spell.h:945
float m_damageMultipliers[MAX_SPELL_EFFECTS]
Definition: Spell.h:781
SpellMissInfo targetMissInfo
Definition: Spell.h:789
SpellEffectInfo const * effectInfo
Definition: Spell.h:792
uint32 m_channelTargetEffectMask
Definition: Spell.h:859
TC_GAME_API Unit * GetUnit(WorldObject const &, ObjectGuid const &guid)
Definition: ObjectAccessor.cpp:208
int32 m_casttime
Definition: Spell.h:754
int8 m_comboPointGain
Definition: Spell.h:676
TriggerCastFlags
Definition: SpellDefines.h:224
bool m_canReflect
Definition: Spell.h:756
uint32 DmgClass
Definition: SpellInfo.h:456
SpellEvent * _spellEvent
Definition: Spell.h:948
DynObjAura * _dynObjAura
Definition: Spell.h:796
uint64 m_delayStart
Definition: Spell.h:771
union Spell::@325 m_misc
Definition: SharedDefines.h:380
SpellInfo const * m_triggeredByAuraSpell
Definition: Spell.h:954
WorldObject *const m_caster
Definition: Spell.h:741
Definition: SharedDefines.h:419
bool IsInWorld() const
Definition: Object.h:149
Definition: Spell.h:314
int32 AuraStackAmount
Definition: Spell.h:321
uint32 m_castItemEntry
Definition: Spell.h:635
WorldLocation * destTarget
Definition: Spell.h:787
Will ignore combo point requirement.
Definition: SpellDefines.h:234
bool m_launchHandled
Definition: Spell.h:773
bool IsPassive() const
Definition: SpellInfo.cpp:1491
int32 m_timer
Definition: Spell.h:946
bool m_immediateHandled
Definition: Spell.h:774
Item * m_CastItem
Definition: Spell.h:633
SpellValue *const m_spellValue
Definition: Spell.h:743
#define MAX_SPELL_EFFECTS
Definition: DBCEnums.h:1423
Player * ToPlayer()
Definition: Object.h:192
uint32 m_procVictim
Definition: Spell.h:809
bool m_autoRepeat
Definition: Spell.h:757
SpellSchoolMask
Definition: SharedDefines.h:303
Definition: SharedDefines.h:1702
Map * GetMap() const
Definition: Object.h:535
uint32 const Id
Definition: SpellInfo.h:377
ObjectGuid const & GetGUID() const
Definition: Object.h:154
Definition: Spell.h:156
uint32 m_applyMultiplierMask
Definition: Spell.h:780
Unit * unitTarget
Definition: Spell.h:784
Unit * m_originalCaster
Definition: Spell.h:747
bool HasAttribute(SpellAttr0 attribute) const
Definition: SpellInfo.h:486
int32 damage
Definition: Spell.h:788
ObjectGuid m_castItemGUID
Definition: Spell.h:634
Unit * unitCaster
Definition: Spell.h:794
Definition: Item.h:169
uint32 m_hitMask
Definition: Spell.h:810
bool IsAutoRepeatRangedSpell() const
Definition: SpellInfo.cpp:1649
uint32_t uint32
Definition: Define.h:152
uint32 m_procAttacker
Definition: Spell.h:808
ObjectGuid m_castId
Definition: Spell.h:637
Item * itemTarget
Definition: Spell.h:785
int32 m_damage
Definition: Spell.h:802
void CleanupTargetList()
Definition: Spell.cpp:2120
float variance
Definition: Spell.h:790
Definition: SharedDefines.h:610
WeaponAttackType m_attackType
Definition: Spell.h:751
Definition: SharedDefines.h:2573
bool IsUnit() const
Definition: Object.h:199
Definition: SharedDefines.h:2602
void Clear()
Definition: ObjectGuid.h:266
ObjectGuid m_originalCasterGUID
Definition: Spell.h:745
bool IsEmpty() const
Definition: ObjectGuid.h:299
bool m_executedCurrently
Definition: Spell.h:778
uint32 GetMapId() const
Definition: Position.h:252
Definition: SharedDefines.h:6343
virtual uint32 GetCastSpellXSpellVisualId(SpellInfo const *spellInfo) const
Definition: Object.cpp:2946
Unit * GetCharmerOrOwner() const
Definition: Object.cpp:2035
#define CLASSMASK_WAND_USERS
Definition: SharedDefines.h:180
uint8 m_runesState
Definition: Spell.h:758
uint32 m_castFlagsEx
Definition: Spell.h:640
uint8_t uint8
Definition: Define.h:154
uint32 SpellXSpellVisualID
Definition: SpellDefines.h:296
uint8 m_delayAtDamageCount
Definition: Spell.h:760
SpellSchoolMask m_spellSchoolMask
Definition: Spell.h:750
Player * GetSpellModOwner() const
Definition: Object.cpp:2073
int32 m_channeledDuration
Definition: Spell.h:755
int32 m_castItemLevel
Definition: Spell.h:636
Definition: SharedDefines.h:405
Definition: Spell.h:141
SpellCustomErrors m_customError
Definition: Spell.h:677
ObjectGuid::LowType GenerateLowGuid()
Definition: Map.h:562
TriggerCastFlags _triggeredCastFlags
Definition: Spell.h:949
SpellCastVisual m_SpellVisual
Definition: Spell.h:674
Definition: SharedDefines.h:527
Spell ** m_selfContainer
Definition: Spell.h:722
bool NeedsComboPoints() const
Definition: SpellInfo.cpp:1627
Definition: Player.h:1056
int32 m_healing
Definition: Spell.h:803
bool m_referencedFromCurrentSpell
Definition: Spell.h:777
bool m_needComboPoints
Definition: Spell.h:779
Unit * ToUnit()
Definition: Object.h:200
SpellDestination m_destTargets[MAX_SPELL_EFFECTS]
Definition: Spell.h:881
bool m_fromClient
Definition: Spell.h:639
UnitAura * _spellAura
Definition: Spell.h:795
Will ignore aura scaling.
Definition: SpellDefines.h:232
SpellEffectHandleMode effectHandleMode
Definition: Spell.h:791
Definition: Spell.h:338
+ Here is the call graph for this function:

◆ ~Spell()

Spell::~Spell ( )
609 {
610  // unload scripts
611  for (auto itr = m_loadedScripts.begin(); itr != m_loadedScripts.end(); ++itr)
612  {
613  (*itr)->_Unload();
614  delete (*itr);
615  }
616 
618  {
619  // Clean the reference to avoid later crash.
620  // If this error is repeating, we may have to add an ASSERT to better track down how we get into this case.
621  TC_LOG_ERROR("spells", "SPELL: deleting spell for spell ID %u. However, spell still referenced.", m_spellInfo->Id);
622  *m_selfContainer = nullptr;
623  }
624 
627 
628  delete m_spellValue;
629 }
SpellInfo const *const m_spellInfo
Definition: Spell.h:632
TypeID GetTypeId() const
Definition: Object.h:167
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:186
Spell * m_spellModTakingSpell
Definition: Player.h:2514
WorldObject *const m_caster
Definition: Spell.h:741
std::vector< SpellScript * > m_loadedScripts
Definition: Spell.h:918
SpellValue *const m_spellValue
Definition: Spell.h:743
Player * ToPlayer()
Definition: Object.h:192
uint32 const Id
Definition: SpellInfo.h:377
Definition: ObjectGuid.h:40
#define ASSERT
Definition: Errors.h:57
Spell ** m_selfContainer
Definition: Spell.h:722
bool m_referencedFromCurrentSpell
Definition: Spell.h:777
+ Here is the call graph for this function:

◆ Spell() [2/2]

Spell::Spell ( Spell const &  right)
protecteddelete

Member Function Documentation

◆ _cast()

void Spell::_cast ( bool  skipCheck = false)
protected

Not own traded item (in trader trade slot) req. reagents including triggered spell case

3277 {
3278  // update pointers base at GUIDs to prevent access to non-existed already object
3279  if (!UpdatePointers())
3280  {
3281  // cancel the spell if UpdatePointers() returned false, something wrong happened there
3282  cancel();
3283  return;
3284  }
3285 
3286  // cancel at lost explicit target during cast
3288  {
3289  cancel();
3290  return;
3291  }
3292 
3293  if (Player* playerCaster = m_caster->ToPlayer())
3294  {
3295  // now that we've done the basic check, now run the scripts
3296  // should be done before the spell is actually executed
3297  sScriptMgr->OnPlayerSpellCast(playerCaster, this, skipCheck);
3298 
3299  // As of 3.0.2 pets begin attacking their owner's target immediately
3300  // Let any pets know we've attacked something. Check DmgClass for harmful spells only
3301  // This prevents spells such as Hunter's Mark from triggering pet attack
3302  if (GetSpellInfo()->DmgClass != SPELL_DAMAGE_CLASS_NONE)
3303  if (Unit* target = m_targets.GetUnitTarget())
3304  for (Unit* controlled : playerCaster->m_Controlled)
3305  if (Creature* cControlled = controlled->ToCreature())
3306  if (cControlled->IsAIEnabled)
3307  cControlled->AI()->OwnerAttacked(target);
3308  }
3309 
3310  SetExecutedCurrently(true);
3311 
3315 
3316  // Should this be done for original caster?
3317  Player* modOwner = m_caster->GetSpellModOwner();
3318  if (modOwner)
3319  {
3320  // Set spell which will drop charges for triggered cast spells
3321  // if not successfully cast, will be remove in finish(false)
3322  modOwner->SetSpellModTakingSpell(this, true);
3323  }
3324 
3326 
3327  // skip check if done already (for instant cast spells for example)
3328  if (!skipCheck)
3329  {
3330  auto cleanupSpell = [this, modOwner](SpellCastResult res, uint32* p1 = nullptr, uint32* p2 = nullptr)
3331  {
3332  SendCastResult(res, p1, p2);
3333  SendInterrupted(0);
3334 
3335  if (modOwner)
3336  modOwner->SetSpellModTakingSpell(this, false);
3337 
3338  finish(false);
3339  SetExecutedCurrently(false);
3340  };
3341 
3342  uint32 param1 = 0, param2 = 0;
3343  SpellCastResult castResult = CheckCast(false, &param1, &param2);
3344  if (castResult != SPELL_CAST_OK)
3345  {
3346  cleanupSpell(castResult, &param1, &param2);
3347  return;
3348  }
3349 
3350  // additional check after cast bar completes (must not be in CheckCast)
3351  // if trade not complete then remember it in trade data
3353  {
3354  if (modOwner)
3355  {
3356  if (TradeData* my_trade = modOwner->GetTradeData())
3357  {
3358  if (!my_trade->IsInAcceptProcess())
3359  {
3360  // Spell will be cast after completing the trade. Silently ignore at this place
3361  my_trade->SetSpell(m_spellInfo->Id, m_CastItem);
3362  cleanupSpell(SPELL_FAILED_DONT_REPORT);
3363  return;
3364  }
3365  }
3366  }
3367  }
3368 
3369  // check diminishing returns (again, only after finish cast bar, tested on retail)
3370  if (Unit* target = m_targets.GetUnitTarget())
3371  {
3372  uint32 aura_effmask = 0;
3373  for (SpellEffectInfo const& spellEffectInfo : m_spellInfo->GetEffects())
3374  if (spellEffectInfo.IsUnitOwnedAuraEffect())
3375  aura_effmask |= 1 << spellEffectInfo.EffectIndex;
3376 
3377  if (aura_effmask)
3378  {
3380  {
3382  if (type == DRTYPE_ALL || (type == DRTYPE_PLAYER && target->IsAffectedByDiminishingReturns()))
3383  {
3384  if (Unit* caster = m_originalCaster ? m_originalCaster : m_caster->ToUnit())
3385  {
3386  if (target->HasStrongerAuraWithDR(m_spellInfo, caster))
3387  {
3388  cleanupSpell(SPELL_FAILED_AURA_BOUNCED);
3389  return;
3390  }
3391  }
3392  }
3393  }
3394  }
3395  }
3396  }
3397 
3398  // if the spell allows the creature to turn while casting, then adjust server-side orientation to face the target now
3399  // client-side orientation is handled by the client itself, as the cast target is targeted due to Creature::FocusTarget
3402  if (WorldObject* objTarget = m_targets.GetObjectTarget())
3403  m_caster->ToCreature()->SetInFront(objTarget);
3404 
3406 
3407  // Spell may be finished after target map check
3409  {
3410  SendInterrupted(0);
3411 
3412  // cleanup after mod system
3413  // triggered spell pointer can be not removed in some cases
3414  if (m_caster->GetTypeId() == TYPEID_PLAYER)
3415  m_caster->ToPlayer()->SetSpellModTakingSpell(this, false);
3416 
3417  finish(false);
3418  SetExecutedCurrently(false);
3419  return;
3420  }
3421 
3422  if (Unit* unitCaster = m_caster->ToUnit())
3425  pet->DespawnOrUnsummon();
3426 
3428 
3430 
3431  // traded items have trade slot instead of guid in m_itemTargetGUID
3432  // set to real guid to be sent later to the client
3434 
3435  if (Player* player = m_caster->ToPlayer())
3436  {
3438  {
3439  player->StartCriteriaTimer(CriteriaStartEvent::UseItem, m_CastItem->GetEntry());
3440  player->UpdateCriteria(CriteriaType::UseItem, m_CastItem->GetEntry());
3441  }
3442 
3443  player->UpdateCriteria(CriteriaType::CastSpell, m_spellInfo->Id);
3444  }
3445 
3447  {
3448  // Powers have to be taken before SendSpellGo
3449  TakePower();
3450  TakeReagents(); // we must remove reagents before HandleEffects to allow place crafted item in same slot
3451  }
3452  else if (Item* targetItem = m_targets.GetItemTarget())
3453  {
3455  if (targetItem->GetOwnerGUID() != m_caster->GetGUID())
3456  TakeReagents();
3457  }
3458 
3459  // CAST SPELL
3462 
3463  if (!m_spellInfo->LaunchDelay)
3464  {
3466  m_launchHandled = true;
3467  }
3468 
3469  // we must send smsg_spell_go packet before m_castItem delete in TakeCastItem()...
3470  SendSpellGo();
3471 
3472  if (!m_spellInfo->IsChanneled())
3473  if (Creature* creatureCaster = m_caster->ToCreature())
3474  creatureCaster->ReleaseFocus(this);
3475 
3476  // Okay, everything is prepared. Now we need to distinguish between immediate and evented delayed spells
3478  {
3479  // Remove used for cast item if need (it can be already NULL after TakeReagents call
3480  // in case delayed spell remove item at cast delay start
3481  TakeCastItem();
3482 
3483  // Okay, maps created, now prepare flags
3484  m_immediateHandled = false;
3486  SetDelayStart(0);
3487 
3488  if (Unit* unitCaster = m_caster->ToUnit())
3491  }
3492  else
3493  {
3494  // Immediate spell, no big deal
3495  handle_immediate();
3496  }
3497 
3499 
3500  if (std::vector<int32> const* spell_triggered = sSpellMgr->GetSpellLinked(m_spellInfo->Id))
3501  {
3502  for (int32 id : *spell_triggered)
3503  {
3504  if (id < 0)
3505  {
3506  if (Unit* unitCaster = m_caster->ToUnit())
3508  }
3509  else
3511  }
3512  }
3513 
3514  if (modOwner)
3515  {
3516  modOwner->SetSpellModTakingSpell(this, false);
3517 
3518  //Clear spell cooldowns after every spell is cast if .cheat cooldown is enabled.
3520  {
3523  }
3524  }
3525 
3526  SetExecutedCurrently(false);
3527 
3528  if (!m_originalCaster)
3529  return;
3530 
3531  // Handle procs on cast
3532  uint32 procAttacker = m_procAttacker;
3533  if (!procAttacker)
3534  {
3537  else
3539  }
3540 
3541  uint32 hitMask = m_hitMask;
3542  if (!(hitMask & PROC_HIT_CRITICAL))
3543  hitMask |= PROC_HIT_NORMAL;
3544 
3547 
3548  Unit::ProcSkillsAndAuras(m_originalCaster, nullptr, procAttacker, PROC_FLAG_NONE, PROC_SPELL_TYPE_MASK_ALL, PROC_SPELL_PHASE_CAST, hitMask, this, nullptr, nullptr);
3549 
3550  // Call CreatureAI hook OnSuccessfulSpellCast
3551  if (Creature* caster = m_originalCaster->ToCreature())
3552  if (caster->IsAIEnabled)
3553  caster->AI()->OnSuccessfulSpellCast(GetSpellInfo());
3554 }
bool IsChanneled() const
Definition: SpellInfo.cpp:1617
Definition: SharedDefines.h:5677
void handle_immediate()
Definition: Spell.cpp:3571
Item * GetItemTarget() const
Definition: Spell.h:253
void UpdateTradeSlotItem()
Definition: Spell.cpp:317
void CallScriptAfterCastHandlers()
Definition: Spell.cpp:7814
SpellInfo const *const m_spellInfo
Definition: Spell.h:632
uint32 m_spellState
Definition: Spell.h:945
Definition: SpellMgr.h:245
Definition: Spell.h:333
static void SendCastResult(Player *caster, SpellInfo const *spellInfo, SpellCastVisual spellVisual, ObjectGuid cast_count, SpellCastResult result, SpellCustomErrors customError=SPELL_CUSTOM_ERROR_NONE, uint32 *param1=nullptr, uint32 *param2=nullptr)
Definition: Spell.cpp:4204
static void ProcSkillsAndAuras(Unit *actor, Unit *actionTarget, uint32 typeMaskActor, uint32 typeMaskActionTarget, uint32 spellTypeMask, uint32 spellPhaseMask, uint32 hitMask, Spell *spell, DamageInfo *damageInfo, HealInfo *healInfo)
Definition: Unit.cpp:5160
Definition: SpellMgr.h:154
Definition: Player.h:934
TypeID GetTypeId() const
Definition: Object.h:167
bool HasHitDelay() const
Definition: SpellInfo.cpp:1659
bool IsPositive() const
Definition: Spell.cpp:7428
uint32 DmgClass
Definition: SpellInfo.h:456
SpellCastTargets m_targets
Definition: Spell.h:675
void TakeCastItem()
Definition: Spell.cpp:4769
void SendSpellGo()
Definition: Spell.cpp:4341
Definition: SharedDefines.h:1393
WorldObject *const m_caster
Definition: Spell.h:741
Definition: ObjectGuid.h:39
In Spell::prepare, will be cast directly without setting containers for executed spell.
Definition: SpellDefines.h:235
bool m_launchHandled
Definition: Spell.h:773
Definition: Object.h:410
Definition: Creature.h:61
uint32 ChargeCategoryId
Definition: SpellInfo.h:460
Definition: SpellMgr.h:236
bool m_immediateHandled
Definition: Spell.h:774
Item * m_CastItem
Definition: Spell.h:633
Definition: Unit.h:251
Definition: SharedDefines.h:2601
Definition: SpellMgr.h:134
bool HasUnitFlag(UnitFlags flags) const
Definition: Unit.h:925
void SetExecutedCurrently(bool yes)
Definition: Spell.h:698
float LaunchDelay
Definition: SpellInfo.h:436
Player * ToPlayer()
Definition: Object.h:192
void RemoveAurasWithInterruptFlags(InterruptFlags flag, uint32 except=0)
Definition: Unit.cpp:3905
Definition: SharedDefines.h:5678
Definition: SpellInfo.h:59
DiminishingReturnsType GetDiminishingReturnsGroupType() const
Definition: SpellInfo.cpp:3143
void ClearUnitState(uint32 f)
Definition: Unit.h:831
uint32 const Id
Definition: SpellInfo.h:377
ObjectGuid const & GetGUID() const
Definition: Object.h:154
SpellHistory * GetSpellHistory()
Definition: Unit.h:1495
Definition: SharedDefines.h:476
Definition: SpellMgr.h:151
Unit * m_originalCaster
Definition: Spell.h:747
void finish(bool ok=true)
Definition: Spell.cpp:3896
ObjectGuid GetObjectTargetGUID() const
Definition: Spell.cpp:285
bool HasAttribute(SpellAttr0 attribute) const
Definition: SpellInfo.h:486
void TakePower()
Definition: Spell.cpp:4837
Unit * unitCaster
Definition: Spell.h:794
Definition: TradeData.h:34
Unit * GetUnitTarget() const
Definition: Spell.cpp:220
bool HasUnitState(const uint32 f) const
Definition: Unit.h:830
SpellInfo const * GetSpellInfo() const
Definition: Spell.h:711
Definition: SharedDefines.h:412
Definition: Item.h:169
uint32 m_hitMask
Definition: Spell.h:810
#define sSpellMgr
Definition: SpellMgr.h:790
Definition: SpellInfo.h:264
Definition: SharedDefines.h:524
int32_t int32
Definition: Define.h:148
void SetSpellModTakingSpell(Spell *spell, bool apply)
Definition: Player.cpp:22443
uint32_t uint32
Definition: Define.h:152
uint32 m_procAttacker
Definition: Spell.h:808
uint32 GetTargetMask() const
Definition: Spell.h:229
bool GetCommandStatus(uint32 command) const
Definition: Player.h:1154
DiminishingReturnsType
Definition: SharedDefines.h:5674
void RestoreCharge(uint32 chargeCategoryId)
Definition: SpellHistory.cpp:785
Will ignore power and reagent cost.
Definition: SpellDefines.h:230
void HandleLaunchPhase()
Definition: Spell.cpp:7576
std::vector< SpellEffectInfo > const & GetEffects() const
Definition: SpellInfo.h:616
TC_GAME_API Creature * GetCreature(WorldObject const &u, ObjectGuid const &guid)
Definition: ObjectAccessor.cpp:219
ControlList m_Controlled
Definition: Unit.h:1261
Definition: SharedDefines.h:2602
Definition: SharedDefines.h:831
Definition: SpellMgr.h:230
void SendSpellCooldown()
Definition: Spell.cpp:3796
Definition: SharedDefines.h:1415
void RemoveAurasDueToSpell(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, uint32 reqEffMask=0, AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
Definition: Unit.cpp:3654
uint32 GetEntry() const
Definition: Object.h:155
bool IsEmpty() const
Definition: ObjectGuid.h:299
Definition: UnitDefines.h:143
void SetDelayStart(uint64 m_time)
Definition: Spell.h:700
Will ignore Spell and Category cooldowns.
Definition: SpellDefines.h:229
void ResetCooldown(uint32 spellId, bool update=false)
Definition: SpellHistory.cpp:589
ObjectGuid GetPetGUID() const
Definition: Unit.h:1233
Definition: ObjectGuid.h:40
Creature * ToCreature()
Definition: Object.h:196
void TakeReagents()
Definition: Spell.cpp:4954
void CallScriptBeforeCastHandlers()
Definition: Spell.cpp:7788
DiminishingGroup GetDiminishingReturnsGroupForSpell() const
Definition: SpellInfo.cpp:3138
void cancel()
Definition: Spell.cpp:3205
TradeData * GetTradeData() const
Definition: Player.h:1417
bool IsNonMeleeSpellCast(bool withDelayed, bool skipChanneled=false, bool skipAutorepeat=false, bool isAutoshoot=false, bool skipInstant=true) const
Definition: Unit.cpp:2928
Definition: SpellMgr.h:246
void CastSpell(SpellCastTargets const &targets, uint32 spellId, CastSpellExtraArgs const &args={ })
Definition: Object.cpp:2631
SpellCastResult
Definition: SharedDefines.h:1381
Player * GetSpellModOwner() const
Definition: Object.cpp:2073
#define sScriptMgr
Definition: ScriptMgr.h:1221
void SendInterrupted(uint8 result)
Definition: Spell.cpp:4645
TriggerCastFlags _triggeredCastFlags
Definition: Spell.h:949
void CallScriptOnCastHandlers()
Definition: Spell.cpp:7801
void SetInFront(WorldObject const *target)
Definition: Unit.cpp:12302
Definition: SharedDefines.h:575
Definition: Unit.h:736
void SelectSpellTargets()
Definition: Spell.cpp:730
Will ignore interruptible aura&#39;s at cast.
Definition: SpellDefines.h:236
Definition: Player.h:1056
WorldObject * GetObjectTarget() const
Definition: Spell.cpp:280
Definition: SharedDefines.h:1697
Definition: Spell.h:331
Unit * ToUnit()
Definition: Object.h:200
bool UpdatePointers()
Definition: Spell.cpp:7213
SpellCastResult CheckCast(bool strict, uint32 *param1=nullptr, uint32 *param2=nullptr)
Definition: Spell.cpp:5087
void PrepareTriggersExecutedOnHit()
Definition: Spell.cpp:8038
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _handle_finish_phase()

void Spell::_handle_finish_phase ( )
3760 {
3761  if (Unit* unitCaster = m_caster->ToUnit())
3762  {
3763  // Take for real after all targets are processed
3764  if (m_needComboPoints)
3766 
3767  // Real add combo points from effects
3768  if (m_comboPointGain)
3770 
3772  {
3775  else
3777  }
3778  }
3779 
3780  // Handle procs on finish
3781  if (!m_originalCaster)
3782  return;
3783 
3784  uint32 procAttacker = m_procAttacker;
3785  if (!procAttacker)
3786  {
3789  else
3791  }
3792 
3794 }
SpellInfo const *const m_spellInfo
Definition: Spell.h:632
static void ProcSkillsAndAuras(Unit *actor, Unit *actionTarget, uint32 typeMaskActor, uint32 typeMaskActionTarget, uint32 spellTypeMask, uint32 spellPhaseMask, uint32 hitMask, Spell *spell, DamageInfo *damageInfo, HealInfo *healInfo)
Definition: Unit.cpp:5160
Definition: SpellMgr.h:154
TC_GAME_API Unit * GetUnit(WorldObject const &, ObjectGuid const &guid)
Definition: ObjectAccessor.cpp:208
bool IsPositive() const
Definition: Spell.cpp:7428
int8 m_comboPointGain
Definition: Spell.h:676
uint32 DmgClass
Definition: SpellInfo.h:456
Definition: SpellMgr.h:238
bool HasEffect(SpellEffectName effect) const
Definition: SpellInfo.cpp:1282
SpellCastTargets m_targets
Definition: Spell.h:675
void ClearComboPoints()
Definition: Unit.cpp:9977
WorldObject *const m_caster
Definition: Spell.h:741
Definition: SharedDefines.h:1111
Definition: SpellMgr.h:134
Definition: SpellMgr.h:151
Unit * m_originalCaster
Definition: Spell.h:747
Unit * unitCaster
Definition: Spell.h:794
uint32 m_hitMask
Definition: Spell.h:810
uint32_t uint32
Definition: Define.h:152
uint32 m_procAttacker
Definition: Spell.h:808
void HandleProcExtraAttackFor(Unit *victim)
Definition: Unit.cpp:2113
Definition: SharedDefines.h:2602
uint32 m_extraAttacks
Definition: Unit.h:801
Definition: SpellMgr.h:230
ObjectGuid GetOrigUnitTargetGUID() const
Definition: Spell.cpp:190
void AddComboPoints(int8 count, Spell *spell=nullptr)
Definition: Unit.cpp:9943
Definition: Unit.h:736
bool m_needComboPoints
Definition: Spell.h:779
Unit * ToUnit()
Definition: Object.h:200
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _handle_immediate_phase()

void Spell::_handle_immediate_phase ( )
3740 {
3741  // handle some immediate features of the spell here
3743 
3744  // handle effects with SPELL_EFFECT_HANDLE_HIT mode
3745  for (SpellEffectInfo const& spellEffectInfo : m_spellInfo->GetEffects())
3746  {
3747  // don't do anything for empty effect
3748  if (!spellEffectInfo.IsEffect())
3749  continue;
3750 
3751  // call effect handlers to handle destination hit
3752  HandleEffects(nullptr, nullptr, nullptr, spellEffectInfo, SPELL_EFFECT_HANDLE_HIT);
3753  }
3754 
3755  // process items
3757 }
SpellInfo const *const m_spellInfo
Definition: Spell.h:632
std::vector< ItemTargetInfo > m_UniqueItemInfo
Definition: Spell.h:876
Definition: Spell.h:340
Definition: SpellInfo.h:264
std::vector< SpellEffectInfo > const & GetEffects() const
Definition: SpellInfo.h:616
void HandleThreatSpells()
Definition: Spell.cpp:5005
void DoProcessTargetContainer(Container &targetContainer)
Definition: Spell.cpp:3557
void HandleEffects(Unit *pUnitTarget, Item *pItemTarget, GameObject *pGOTarget, SpellEffectInfo const &spellEffectInfo, SpellEffectHandleMode mode)
Definition: Spell.cpp:5061
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ AddDestTarget()

void Spell::AddDestTarget ( SpellDestination const &  dest,
uint32  effIndex 
)
protected
2325 {
2326  m_destTargets[effIndex] = dest;
2327 }
SpellDestination m_destTargets[MAX_SPELL_EFFECTS]
Definition: Spell.h:881
+ Here is the caller graph for this function:

◆ AddGOTarget()

void Spell::AddGOTarget ( GameObject target,
uint32  effectMask 
)
protected
2244 {
2245  for (SpellEffectInfo const& spellEffectInfo : m_spellInfo->GetEffects())
2246  if (!spellEffectInfo.IsEffect() || !CheckEffectTarget(go, spellEffectInfo))
2247  effectMask &= ~(1 << spellEffectInfo.EffectIndex);
2248 
2249  // no effects left
2250  if (!effectMask)
2251  return;
2252 
2253  ObjectGuid targetGUID = go->GetGUID();
2254 
2255  // Lookup target in already in list
2256  auto ihit = std::find_if(std::begin(m_UniqueGOTargetInfo), std::end(m_UniqueGOTargetInfo), [targetGUID](GOTargetInfo const& target) { return target.TargetGUID == targetGUID; });
2257  if (ihit != std::end(m_UniqueGOTargetInfo)) // Found in list
2258  {
2259  // Add only effect mask
2260  ihit->EffectMask |= effectMask;
2261  return;
2262  }
2263 
2264  // This is new target calculate data for him
2265 
2266  GOTargetInfo target;
2267  target.TargetGUID = targetGUID;
2268  target.EffectMask = effectMask;
2269 
2270  // Spell have speed - need calculate incoming time
2271  if (static_cast<WorldObject*>(m_caster) != go)
2272  {
2273  float hitDelay = m_spellInfo->LaunchDelay;
2275  hitDelay += m_spellInfo->Speed;
2276  else if (m_spellInfo->Speed > 0.0f)
2277  {
2278  // calculate spell incoming interval
2279  float dist = std::max(m_caster->GetDistance(go->GetPositionX(), go->GetPositionY(), go->GetPositionZ()), 5.0f);
2280  hitDelay += dist / m_spellInfo->Speed;
2281  }
2282 
2283  target.TimeDelay = uint64(std::floor(hitDelay * 1000.0f));
2284  }
2285  else
2286  target.TimeDelay = 0ULL;
2287 
2288  // Calculate minimum incoming time
2289  if (target.TimeDelay && (!m_delayMoment || m_delayMoment > target.TimeDelay))
2290  m_delayMoment = target.TimeDelay;
2291 
2292  // Add target to list
2293  m_UniqueGOTargetInfo.emplace_back(std::move(target));
2294 }
Definition: SharedDefines.h:704
SpellInfo const *const m_spellInfo
Definition: Spell.h:632
WorldObject *const m_caster
Definition: Spell.h:741
float LaunchDelay
Definition: SpellInfo.h:436
bool HasAttribute(SpellAttr0 attribute) const
Definition: SpellInfo.h:486
uint64 m_delayMoment
Definition: Spell.h:772
Definition: SpellInfo.h:264
uint64_t uint64
Definition: Define.h:151
float GetDistance(WorldObject const *obj) const
Definition: Object.cpp:1025
std::vector< SpellEffectInfo > const & GetEffects() const
Definition: SpellInfo.h:616
float Speed
Definition: SpellInfo.h:435
std::vector< GOTargetInfo > m_UniqueGOTargetInfo
Definition: Spell.h:868
bool CheckEffectTarget(Unit const *target, SpellEffectInfo const &spellEffectInfo, Position const *losPosition) const
Definition: Spell.cpp:7285
Definition: ObjectGuid.h:248
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ AddItemTarget()

void Spell::AddItemTarget ( Item item,
uint32  effectMask 
)
protected
2297 {
2298  for (SpellEffectInfo const& spellEffectInfo : m_spellInfo->GetEffects())
2299  if (!spellEffectInfo.IsEffect() || !CheckEffectTarget(item, spellEffectInfo))
2300  effectMask &= ~(1 << spellEffectInfo.EffectIndex);
2301 
2302  // no effects left
2303  if (!effectMask)
2304  return;
2305 
2306  // Lookup target in already in list
2307  auto ihit = std::find_if(std::begin(m_UniqueItemInfo), std::end(m_UniqueItemInfo), [item](ItemTargetInfo const& target) { return target.TargetItem == item; });
2308  if (ihit != std::end(m_UniqueItemInfo)) // Found in list
2309  {
2310  // Add only effect mask
2311  ihit->EffectMask |= effectMask;
2312  return;
2313  }
2314 
2315  // This is new target add data
2316 
2317  ItemTargetInfo target;
2318  target.TargetItem = item;
2319  target.EffectMask = effectMask;
2320 
2321  m_UniqueItemInfo.emplace_back(std::move(target));
2322 }
SpellInfo const *const m_spellInfo
Definition: Spell.h:632
std::vector< ItemTargetInfo > m_UniqueItemInfo
Definition: Spell.h:876
Definition: SpellInfo.h:264
std::vector< SpellEffectInfo > const & GetEffects() const
Definition: SpellInfo.h:616
bool CheckEffectTarget(Unit const *target, SpellEffectInfo const &spellEffectInfo, Position const *losPosition) const
Definition: Spell.cpp:7285
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ AddUnitTarget()

void Spell::AddUnitTarget ( Unit target,
uint32  effectMask,
bool  checkIfValid = true,
bool  implicit = true,
Position const *  losPosition = nullptr 
)
protected
Todo:
this is a hack
2155 {
2156  for (SpellEffectInfo const& spellEffectInfo : m_spellInfo->GetEffects())
2157  if (!spellEffectInfo.IsEffect() || !CheckEffectTarget(target, spellEffectInfo, losPosition))
2158  effectMask &= ~(1 << spellEffectInfo.EffectIndex);
2159 
2160  // no effects left
2161  if (!effectMask)
2162  return;
2163 
2164  if (checkIfValid)
2165  if (m_spellInfo->CheckTarget(m_caster, target, implicit) != SPELL_CAST_OK) // skip stealth checks for AOE
2166  return;
2167 
2168  // Check for effect immune skip if immuned
2169  for (SpellEffectInfo const& spellEffectInfo : m_spellInfo->GetEffects())
2170  if (target->IsImmunedToSpellEffect(m_spellInfo, spellEffectInfo, m_caster))
2171  effectMask &= ~(1 << spellEffectInfo.EffectIndex);
2172 
2173  ObjectGuid targetGUID = target->GetGUID();
2174 
2175  // Lookup target in already in list
2176  auto ihit = std::find_if(std::begin(m_UniqueTargetInfo), std::end(m_UniqueTargetInfo), [targetGUID](TargetInfo const& target) { return target.TargetGUID == targetGUID; });
2177  if (ihit != std::end(m_UniqueTargetInfo)) // Found in list
2178  {
2179  // Immune effects removed from mask
2180  ihit->EffectMask |= effectMask;
2181  return;
2182  }
2183 
2184  // This is new target calculate data for him
2185 
2186  // Get spell hit result on target
2187  TargetInfo targetInfo;
2188  targetInfo.TargetGUID = targetGUID; // Store target GUID
2189  targetInfo.EffectMask = effectMask; // Store all effects not immune
2190  targetInfo.IsAlive = target->IsAlive();
2191  targetInfo.Damage = 0;
2192  targetInfo.Healing = 0;
2193  targetInfo.IsCrit = false;
2194 
2195  // Calculate hit result
2197  targetInfo.MissCondition = caster->SpellHitResult(target, m_spellInfo, m_canReflect && !(IsPositive() && m_caster->IsFriendlyTo(target)));
2198 
2199  // Spell have speed - need calculate incoming time
2200  // Incoming time is zero for self casts. At least I think so.
2201  if (m_caster != target)
2202  {
2203  float hitDelay = m_spellInfo->LaunchDelay;
2205  hitDelay += m_spellInfo->Speed;
2206  else if (m_spellInfo->Speed > 0.0f)
2207  {
2208  // calculate spell incoming interval
2210  float dist = std::max(m_caster->GetDistance(target->GetPositionX(), target->GetPositionY(), target->GetPositionZ()), 5.0f);
2211  hitDelay += dist / m_spellInfo->Speed;
2212  }
2213 
2214  targetInfo.TimeDelay = uint64(std::floor(hitDelay * 1000.0f));
2215  }
2216  else
2217  targetInfo.TimeDelay = 0ULL;
2218 
2219  // If target reflect spell back to caster
2220  if (targetInfo.MissCondition == SPELL_MISS_REFLECT)
2221  {
2222  // Calculate reflected spell result on caster (shouldn't be able to reflect gameobject spells)
2224  targetInfo.ReflectResult = unitCaster->SpellHitResult(unitCaster, m_spellInfo, false); // can't reflect twice
2225 
2226  // Proc spell reflect aura when missile hits the original target
2227  target->m_Events.AddEvent(new ProcReflectDelayed(target, m_originalCasterGUID), target->m_Events.CalculateTime(targetInfo.TimeDelay));
2228 
2229  // Increase time interval for reflected spells by 1.5
2230  targetInfo.TimeDelay += targetInfo.TimeDelay >> 1;
2231  }
2232  else
2233  targetInfo.ReflectResult = SPELL_MISS_NONE;
2234 
2235  // Calculate minimum incoming time
2236  if (targetInfo.TimeDelay && (!m_delayMoment || m_delayMoment > targetInfo.TimeDelay))
2237  m_delayMoment = targetInfo.TimeDelay;
2238 
2239  // Add target to list
2240  m_UniqueTargetInfo.emplace_back(std::move(targetInfo));
2241 }
Definition: SharedDefines.h:704
SpellMissInfo SpellHitResult(Unit *victim, SpellInfo const *spellInfo, bool canReflect=false) const
Definition: Object.cpp:2384
SpellInfo const *const m_spellInfo
Definition: Spell.h:632
bool IsPositive() const
Definition: Spell.cpp:7428
bool m_canReflect
Definition: Spell.h:756
WorldObject *const m_caster
Definition: Spell.h:741
Definition: Spell.cpp:2128
Definition: Object.h:410
virtual bool IsImmunedToSpellEffect(SpellInfo const *spellInfo, SpellEffectInfo const &spellEffectInfo, WorldObject const *caster) const
Definition: Unit.cpp:7215
#define ASSERT_NOTNULL(pointer)
Definition: Errors.h:69
float LaunchDelay
Definition: SpellInfo.h:436
ObjectGuid const & GetGUID() const
Definition: Object.h:154
std::vector< TargetInfo > m_UniqueTargetInfo
Definition: Spell.h:858
Unit * m_originalCaster
Definition: Spell.h:747
bool HasAttribute(SpellAttr0 attribute) const
Definition: SpellInfo.h:486
Unit * unitCaster
Definition: Spell.h:794
uint64 m_delayMoment
Definition: Spell.h:772
Definition: SpellInfo.h:264
uint64_t uint64
Definition: Define.h:151
SpellCastResult CheckTarget(WorldObject const *caster, WorldObject const *target, bool implicit=true) const
Definition: SpellInfo.cpp:2070
float GetDistance(WorldObject const *obj) const
Definition: Object.cpp:1025
std::vector< SpellEffectInfo > const & GetEffects() const
Definition: SpellInfo.h:616
Definition: SharedDefines.h:2573
float Speed
Definition: SpellInfo.h:435
ObjectGuid m_originalCasterGUID
Definition: Spell.h:745
bool IsFriendlyTo(WorldObject const *target) const
Definition: Object.cpp:2600
Definition: SharedDefines.h:2584
bool CheckEffectTarget(Unit const *target, SpellEffectInfo const &spellEffectInfo, Position const *losPosition) const
Definition: Spell.cpp:7285
Definition: ObjectGuid.h:248
Definition: Unit.h:736
Definition: SharedDefines.h:1697
Unit * ToUnit()
Definition: Object.h:200
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ CalculateDamage()

int32 Spell::CalculateDamage ( SpellEffectInfo const &  spellEffectInfo,
Unit const *  target,
float *  var = nullptr 
) const
6374 {
6375  bool needRecalculateBasePoints = !(m_spellValue->CustomBasePointsMask & (1 << spellEffectInfo.EffectIndex));
6376  return m_caster->CalculateSpellDamage(target, spellEffectInfo, needRecalculateBasePoints ? nullptr : &m_spellValue->EffectBasePoints[spellEffectInfo.EffectIndex], var, m_castItemEntry, m_castItemLevel);
6377 }
int32 CalculateSpellDamage(Unit const *target, SpellEffectInfo const &spellEffectInfo, int32 const *basePoints=nullptr, float *variance=nullptr, uint32 castItemId=0, int32 itemLevel=-1) const
Definition: Object.cpp:2098
WorldObject *const m_caster
Definition: Spell.h:741
uint32 m_castItemEntry
Definition: Spell.h:635
SpellValue *const m_spellValue
Definition: Spell.h:743
uint32 CustomBasePointsMask
Definition: Spell.h:318
int32 EffectBasePoints[MAX_SPELL_EFFECTS]
Definition: Spell.h:317
int32 m_castItemLevel
Definition: Spell.h:636
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ CalculateDelayMomentForDst()

uint64 Spell::CalculateDelayMomentForDst ( float  launchDelay) const
791 {
792  if (m_targets.HasDst())
793  {
794  if (m_targets.HasTraj())
795  {
796  float speed = m_targets.GetSpeedXY();
797  if (speed > 0.0f)
798  return uint64(std::floor((m_targets.GetDist2d() / speed + launchDelay) * 1000.0f));
799  }
801  return uint64(std::floor((m_spellInfo->Speed + launchDelay) * 1000.0f));
802  else if (m_spellInfo->Speed > 0.0f)
803  {
804  // We should not subtract caster size from dist calculation (fixes execution time desync with animation on client, eg. Malleable Goo cast by PP)
805  float dist = m_caster->GetExactDist(*m_targets.GetDstPos());
806  return uint64(std::floor((dist / m_spellInfo->Speed + launchDelay) * 1000.0f));
807  }
808 
809  return uint64(std::floor(launchDelay * 1000.0f));
810  }
811 
812  return 0;
813 }
Definition: SharedDefines.h:704
SpellInfo const *const m_spellInfo
Definition: Spell.h:632
SpellCastTargets m_targets
Definition: Spell.h:675
WorldObject *const m_caster
Definition: Spell.h:741
float GetSpeedXY() const
Definition: Spell.h:288
float GetDist2d() const
Definition: Spell.h:287
bool HasAttribute(SpellAttr0 attribute) const
Definition: SpellInfo.h:486
uint64_t uint64
Definition: Define.h:151
bool HasDst() const
Definition: Spell.cpp:427
float Speed
Definition: SpellInfo.h:435
WorldLocation const * GetDstPos() const
Definition: Spell.cpp:370
bool HasTraj() const
Definition: Spell.h:280
float GetExactDist(float x, float y, float z) const
Definition: Position.cpp:57
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ CallScriptAfterCastHandlers()

void Spell::CallScriptAfterCastHandlers ( )
protected
7815 {
7816  for (auto scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
7817  {
7818  (*scritr)->_PrepareScriptCall(SPELL_SCRIPT_HOOK_AFTER_CAST);
7819  auto hookItrEnd = (*scritr)->AfterCast.end(), hookItr = (*scritr)->AfterCast.begin();
7820  for (; hookItr != hookItrEnd; ++hookItr)
7821  (*hookItr).Call(*scritr);
7822 
7823  (*scritr)->_FinishScriptCall();
7824  }
7825 }
std::vector< SpellScript * > m_loadedScripts
Definition: Spell.h:918
Definition: SpellScript.h:178
+ Here is the caller graph for this function:

◆ CallScriptAfterHitHandlers()

void Spell::CallScriptAfterHitHandlers ( )
protected
7937 {
7938  for (auto scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
7939  {
7940  (*scritr)->_PrepareScriptCall(SPELL_SCRIPT_HOOK_AFTER_HIT);
7941  auto hookItrEnd = (*scritr)->AfterHit.end(), hookItr = (*scritr)->AfterHit.begin();
7942  for (; hookItr != hookItrEnd; ++hookItr)
7943  (*hookItr).Call(*scritr);
7944 
7945  (*scritr)->_FinishScriptCall();
7946  }
7947 }
Definition: SpellScript.h:171
std::vector< SpellScript * > m_loadedScripts
Definition: Spell.h:918
+ Here is the caller graph for this function:

◆ CallScriptBeforeCastHandlers()

void Spell::CallScriptBeforeCastHandlers ( )
protected
7789 {
7790  for (auto scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
7791  {
7792  (*scritr)->_PrepareScriptCall(SPELL_SCRIPT_HOOK_BEFORE_CAST);
7793  auto hookItrEnd = (*scritr)->BeforeCast.end(), hookItr = (*scritr)->BeforeCast.begin();
7794  for (; hookItr != hookItrEnd; ++hookItr)
7795  (*hookItr).Call(*scritr);
7796 
7797  (*scritr)->_FinishScriptCall();
7798  }
7799 }
std::vector< SpellScript * > m_loadedScripts
Definition: Spell.h:918
Definition: SpellScript.h:176
+ Here is the caller graph for this function:

◆ CallScriptBeforeHitHandlers()

void Spell::CallScriptBeforeHitHandlers ( SpellMissInfo  missInfo)
protected
7910 {
7911  for (auto scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
7912  {
7913  (*scritr)->_InitHit();
7914  (*scritr)->_PrepareScriptCall(SPELL_SCRIPT_HOOK_BEFORE_HIT);
7915  auto hookItrEnd = (*scritr)->BeforeHit.end(), hookItr = (*scritr)->BeforeHit.begin();
7916  for (; hookItr != hookItrEnd; ++hookItr)
7917  (*hookItr).Call(*scritr, missInfo);
7918 
7919  (*scritr)->_FinishScriptCall();
7920  }
7921 }
std::vector< SpellScript * > m_loadedScripts
Definition: Spell.h:918
Definition: SpellScript.h:169
+ Here is the caller graph for this function:

◆ CallScriptCalcCritChanceHandlers()

void Spell::CallScriptCalcCritChanceHandlers ( Unit const *  victim,
float &  chance 
)
7950 {
7951  for (SpellScript* loadedScript : m_loadedScripts)
7952  {
7953  loadedScript->_PrepareScriptCall(SPELL_SCRIPT_HOOK_CALC_CRIT_CHANCE);
7954  for (SpellScript::OnCalcCritChanceHandler const& hook : loadedScript->OnCalcCritChance)
7955  hook.Call(loadedScript, victim, critChance);
7956 
7957  loadedScript->_FinishScriptCall();
7958  }
7959 }
std::vector< SpellScript * > m_loadedScripts
Definition: Spell.h:918
Definition: SpellScript.h:185
Definition: SpellScript.h:250
void Call(SpellScript *spellScript, Unit const *victim, float &critChance) const
Definition: SpellScript.cpp:246
Definition: SpellScript.h:179
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ CallScriptCheckCastHandlers()

SpellCastResult Spell::CallScriptCheckCastHandlers ( )
protected
7828 {
7829  SpellCastResult retVal = SPELL_CAST_OK;
7830  for (auto scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
7831  {
7832  (*scritr)->_PrepareScriptCall(SPELL_SCRIPT_HOOK_CHECK_CAST);
7833  auto hookItrEnd = (*scritr)->OnCheckCast.end(), hookItr = (*scritr)->OnCheckCast.begin();
7834  for (; hookItr != hookItrEnd; ++hookItr)
7835  {
7836  SpellCastResult tempResult = (*hookItr).Call(*scritr);
7837  if (retVal == SPELL_CAST_OK)
7838  retVal = tempResult;
7839  }
7840 
7841  (*scritr)->_FinishScriptCall();
7842  }
7843  return retVal;
7844 }
std::vector< SpellScript * > m_loadedScripts
Definition: Spell.h:918
SpellCastResult
Definition: SharedDefines.h:1381
Definition: SharedDefines.h:1697
Definition: SpellScript.h:175
+ Here is the caller graph for this function:

◆ CallScriptDestinationTargetSelectHandlers()

void Spell::CallScriptDestinationTargetSelectHandlers ( SpellDestination target,
SpellEffIndex  effIndex,
SpellImplicitTargetInfo const &  targetType 
)
protected
7990 {
7991  for (auto scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
7992  {
7993  (*scritr)->_PrepareScriptCall(SPELL_SCRIPT_HOOK_DESTINATION_TARGET_SELECT);
7994  auto hookItrEnd = (*scritr)->OnDestinationTargetSelect.end(), hookItr = (*scritr)->OnDestinationTargetSelect.begin();
7995  for (; hookItr != hookItrEnd; ++hookItr)
7996  if (hookItr->IsEffectAffected(m_spellInfo, effIndex) && targetType.GetTarget() == hookItr->GetTarget())
7997  hookItr->Call(*scritr, target);
7998 
7999  (*scritr)->_FinishScriptCall();
8000  }
8001 }
SpellInfo const *const m_spellInfo
Definition: Spell.h:632
std::vector< SpellScript * > m_loadedScripts
Definition: Spell.h:918
Definition: SpellScript.h:174
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ CallScriptEffectHandlers()

bool Spell::CallScriptEffectHandlers ( SpellEffIndex  effIndex,
SpellEffectHandleMode  mode 
)
protected
7847 {
7848  // execute script effect handler hooks and check if effects was prevented
7849  bool preventDefault = false;
7850  for (auto scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
7851  {
7852  (*scritr)->_InitHit();
7853 
7855  SpellScriptHookType hookType;
7856  switch (mode)
7857  {
7859  effItr = (*scritr)->OnEffectLaunch.begin();
7860  effEndItr = (*scritr)->OnEffectLaunch.end();
7862  break;
7864  effItr = (*scritr)->OnEffectLaunchTarget.begin();
7865  effEndItr = (*scritr)->OnEffectLaunchTarget.end();
7867  break;
7869  effItr = (*scritr)->OnEffectHit.begin();
7870  effEndItr = (*scritr)->OnEffectHit.end();
7871  hookType = SPELL_SCRIPT_HOOK_EFFECT_HIT;
7872  break;
7874  effItr = (*scritr)->OnEffectHitTarget.begin();
7875  effEndItr = (*scritr)->OnEffectHitTarget.end();
7877  break;
7878  default:
7879  ABORT();
7880  return false;
7881  }
7882  (*scritr)->_PrepareScriptCall(hookType);
7883  for (; effItr != effEndItr; ++effItr)
7884  // effect execution can be prevented
7885  if (!(*scritr)->_IsEffectPrevented(effIndex) && (*effItr).IsEffectAffected(m_spellInfo, effIndex))
7886  (*effItr).Call(*scritr, effIndex);
7887 
7888  if (!preventDefault)
7889  preventDefault = (*scritr)->_IsDefaultEffectPrevented(effIndex);
7890 
7891  (*scritr)->_FinishScriptCall();
7892  }
7893  return preventDefault;
7894 }
SpellScriptHookType
Definition: SpellScript.h:162
Definition: SpellScript.h:166
SpellInfo const *const m_spellInfo
Definition: Spell.h:632
iterator end()
Definition: Util.h:381
std::vector< SpellScript * > m_loadedScripts
Definition: Spell.h:918
iterator begin()
Definition: Util.h:376
Definition: SpellScript.h:165
Definition: Spell.h:341
Definition: Spell.h:340
Definition: Spell.h:339
Definition: SpellScript.h:167
#define ABORT
Definition: Errors.h:60
Definition: SpellScript.h:164
Definition: Util.h:354
Definition: Spell.h:338
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ CallScriptObjectAreaTargetSelectHandlers()

void Spell::CallScriptObjectAreaTargetSelectHandlers ( std::list< WorldObject *> &  targets,
SpellEffIndex  effIndex,
SpellImplicitTargetInfo const &  targetType 
)
protected
7962 {
7963  for (auto scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
7964  {
7965  (*scritr)->_PrepareScriptCall(SPELL_SCRIPT_HOOK_OBJECT_AREA_TARGET_SELECT);
7966  auto hookItrEnd = (*scritr)->OnObjectAreaTargetSelect.end(), hookItr = (*scritr)->OnObjectAreaTargetSelect.begin();
7967  for (; hookItr != hookItrEnd; ++hookItr)
7968  if (hookItr->IsEffectAffected(m_spellInfo, effIndex) && targetType.GetTarget() == hookItr->GetTarget())
7969  hookItr->Call(*scritr, targets);
7970 
7971  (*scritr)->_FinishScriptCall();
7972  }
7973 }
SpellInfo const *const m_spellInfo
Definition: Spell.h:632
std::vector< SpellScript * > m_loadedScripts
Definition: Spell.h:918
Definition: SpellScript.h:172
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ CallScriptObjectTargetSelectHandlers()

void Spell::CallScriptObjectTargetSelectHandlers ( WorldObject *&  target,
SpellEffIndex  effIndex,
SpellImplicitTargetInfo const &  targetType 
)
protected
7976 {
7977  for (auto scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
7978  {
7979  (*scritr)->_PrepareScriptCall(SPELL_SCRIPT_HOOK_OBJECT_TARGET_SELECT);
7980  auto hookItrEnd = (*scritr)->OnObjectTargetSelect.end(), hookItr = (*scritr)->OnObjectTargetSelect.begin();
7981  for (; hookItr != hookItrEnd; ++hookItr)
7982  if (hookItr->IsEffectAffected(m_spellInfo, effIndex) && targetType.GetTarget() == hookItr->GetTarget())
7983  hookItr->Call(*scritr, target);
7984 
7985  (*scritr)->_FinishScriptCall();
7986  }
7987 }
Definition: SpellScript.h:173
SpellInfo const *const m_spellInfo
Definition: Spell.h:632
std::vector< SpellScript * > m_loadedScripts
Definition: Spell.h:918
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ CallScriptOnCastHandlers()

void Spell::CallScriptOnCastHandlers ( )
protected
7802 {
7803  for (auto scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
7804  {
7805  (*scritr)->_PrepareScriptCall(SPELL_SCRIPT_HOOK_ON_CAST);
7806  auto hookItrEnd = (*scritr)->OnCast.end(), hookItr = (*scritr)->OnCast.begin();
7807  for (; hookItr != hookItrEnd; ++hookItr)
7808  (*hookItr).Call(*scritr);
7809 
7810  (*scritr)->_FinishScriptCall();
7811  }
7812 }
std::vector< SpellScript * > m_loadedScripts
Definition: Spell.h:918
Definition: SpellScript.h:177
+ Here is the caller graph for this function:

◆ CallScriptOnHitHandlers()

void Spell::CallScriptOnHitHandlers ( )
protected
7924 {
7925  for (auto scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
7926  {
7927  (*scritr)->_PrepareScriptCall(SPELL_SCRIPT_HOOK_HIT);
7928  auto hookItrEnd = (*scritr)->OnHit.end(), hookItr = (*scritr)->OnHit.begin();
7929  for (; hookItr != hookItrEnd; ++hookItr)
7930  (*hookItr).Call(*scritr);
7931 
7932  (*scritr)->_FinishScriptCall();
7933  }
7934 }
Definition: SpellScript.h:170
std::vector< SpellScript * > m_loadedScripts
Definition: Spell.h:918
+ Here is the caller graph for this function:

◆ CallScriptSuccessfulDispel()

void Spell::CallScriptSuccessfulDispel ( SpellEffIndex  effIndex)
protected
7897 {
7898  for (auto scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
7899  {
7900  (*scritr)->_PrepareScriptCall(SPELL_SCRIPT_HOOK_EFFECT_SUCCESSFUL_DISPEL);
7901  auto hookItrEnd = (*scritr)->OnEffectSuccessfulDispel.end(), hookItr = (*scritr)->OnEffectSuccessfulDispel.begin();
7902  for (; hookItr != hookItrEnd; ++hookItr)
7903  hookItr->Call(*scritr, effIndex);
7904 
7905  (*scritr)->_FinishScriptCall();
7906  }
7907 }
std::vector< SpellScript * > m_loadedScripts
Definition: Spell.h:918
Definition: SpellScript.h:168
+ Here is the caller graph for this function:

◆ CanAutoCast()

bool Spell::CanAutoCast ( Unit target)
6380 {
6381  if (!target)
6382  return (CheckPetCast(target) == SPELL_CAST_OK);
6383 
6384  ObjectGuid targetguid = target->GetGUID();
6385 
6386  // check if target already has the same or a more powerful aura
6387  for (SpellEffectInfo const& spellEffectInfo : m_spellInfo->GetEffects())
6388  {
6389  if (!spellEffectInfo.IsAura())
6390  continue;
6391 
6392  AuraType const& auraType = spellEffectInfo.ApplyAuraName;
6393  Unit::AuraEffectList const& auras = target->GetAuraEffectsByType(auraType);
6394  for (Unit::AuraEffectList::const_iterator auraIt = auras.begin(); auraIt != auras.end(); ++auraIt)
6395  {
6396  if (GetSpellInfo()->Id == (*auraIt)->GetSpellInfo()->Id)
6397  return false;
6398 
6399  switch (sSpellMgr->CheckSpellGroupStackRules(GetSpellInfo(), (*auraIt)->GetSpellInfo()))
6400  {
6402  return false;
6404  if (GetCaster() == (*auraIt)->GetCaster())
6405  return false;
6406  break;
6407  case SPELL_GROUP_STACK_RULE_EXCLUSIVE_SAME_EFFECT: // this one has further checks, but i don't think they're necessary for autocast logic
6409  if (abs(spellEffectInfo.BasePoints) <= abs((*auraIt)->GetAmount()))
6410  return false;
6411  break;
6413  default:
6414  break;
6415  }
6416  }
6417  }
6418 
6419  SpellCastResult result = CheckPetCast(target);
6420  if (result == SPELL_CAST_OK || result == SPELL_FAILED_UNIT_NOT_INFRONT)
6421  {
6422  // do not check targets for ground-targeted spells (we target them on top of the intended target anyway)
6423  if (GetSpellInfo()->ExplicitTargetMask & TARGET_FLAG_DEST_LOCATION)
6424  return true;
6426  //check if among target units, our WANTED target is as well (->only self cast spells return false)
6427  for (auto ihit = m_UniqueTargetInfo.begin(); ihit != m_UniqueTargetInfo.end(); ++ihit)
6428  if (ihit->TargetGUID == targetguid)
6429  return true;
6430  }
6431  // either the cast failed or the intended target wouldn't be hit
6432  return false;
6433 }
Definition: SharedDefines.h:1538
SpellInfo const *const m_spellInfo
Definition: Spell.h:632
std::list< AuraEffect * > AuraEffectList
Definition: Unit.h:754
AuraType
Definition: SpellAuraDefines.h:86
uint32 const Id
Definition: SpellInfo.h:377
ObjectGuid const & GetGUID() const
Definition: Object.h:154
std::vector< TargetInfo > m_UniqueTargetInfo
Definition: Spell.h:858
AuraEffectList const & GetAuraEffectsByType(AuraType type) const
Definition: Unit.h:1365
SpellInfo const * GetSpellInfo() const
Definition: Spell.h:711
#define sSpellMgr
Definition: SpellMgr.h:790
Definition: SpellInfo.h:264
Definition: SpellMgr.h:342
std::vector< SpellEffectInfo > const & GetEffects() const
Definition: SpellInfo.h:616
SpellCastResult CheckPetCast(Unit *target)
Definition: Spell.cpp:6110
Definition: SpellMgr.h:341
Definition: SpellInfo.h:53
SpellCastResult
Definition: SharedDefines.h:1381
Definition: ObjectGuid.h:248
WorldObject * GetCaster() const
Definition: Spell.h:709
void SelectSpellTargets()
Definition: Spell.cpp:730
Definition: SharedDefines.h:1697
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ cancel()

void Spell::cancel ( )
3206 {
3208  return;
3209 
3210  uint32 oldState = m_spellState;
3212 
3213  m_autoRepeat = false;
3214  switch (oldState)
3215  {
3216  case SPELL_STATE_PREPARING:
3218  /* fallthrough */
3219  case SPELL_STATE_DELAYED:
3220  SendInterrupted(0);
3222  break;
3223 
3224  case SPELL_STATE_CASTING:
3225  for (TargetInfo const& targetInfo : m_UniqueTargetInfo)
3226  if (targetInfo.MissCondition == SPELL_MISS_NONE)
3227  if (Unit* unit = m_caster->GetGUID() == targetInfo.TargetGUID ? m_caster->ToUnit() : ObjectAccessor::GetUnit(*m_caster, targetInfo.TargetGUID))
3228  unit->RemoveOwnedAura(m_spellInfo->Id, m_originalCasterGUID, 0, AURA_REMOVE_BY_CANCEL);
3229 
3230  SendChannelUpdate(0);
3231  SendInterrupted(0);
3233 
3234  m_appliedMods.clear();
3235  break;
3236 
3237  default:
3238  break;
3239  }
3240 
3241  SetReferencedFromCurrent(false);
3242  if (m_selfContainer && *m_selfContainer == this)
3243  *m_selfContainer = nullptr;
3244 
3245  // originalcaster handles gameobjects/dynobjects for gob caster
3246  if (m_originalCaster)
3247  {
3249  if (m_spellInfo->IsChanneled()) // if not channeled then the object for the current cast wasn't summoned yet
3251  }
3252 
3253  //set state back so finish will be processed
3254  m_spellState = oldState;
3255 
3256  finish(false);
3257 }
bool IsChanneled() const
Definition: SpellInfo.cpp:1617
SpellInfo const *const m_spellInfo
Definition: Spell.h:632
uint32 m_spellState
Definition: Spell.h:945
Definition: Spell.h:333
static void SendCastResult(Player *caster, SpellInfo const *spellInfo, SpellCastVisual spellVisual, ObjectGuid cast_count, SpellCastResult result, SpellCustomErrors customError=SPELL_CUSTOM_ERROR_NONE, uint32 *param1=nullptr, uint32 *param2=nullptr)
Definition: Spell.cpp:4204
TC_GAME_API Unit * GetUnit(WorldObject const &, ObjectGuid const &guid)
Definition: ObjectAccessor.cpp:208
UsedSpellMods m_appliedMods
Definition: Spell.h:679
void CancelGlobalCooldown()
Definition: Spell.cpp:8136
WorldObject *const m_caster
Definition: Spell.h:741
bool m_autoRepeat
Definition: Spell.h:757
uint32 const Id
Definition: SpellInfo.h:377
ObjectGuid const & GetGUID() const
Definition: Object.h:154
std::vector< TargetInfo > m_UniqueTargetInfo
Definition: Spell.h:858
Unit * m_originalCaster
Definition: Spell.h:747
void finish(bool ok=true)
Definition: Spell.cpp:3896
void SendChannelUpdate(uint32 time)
Definition: Spell.cpp:4664
uint32_t uint32
Definition: Define.h:152
Definition: Spell.h:330
Definition: SharedDefines.h:2573
Definition: Spell.h:329
ObjectGuid m_originalCasterGUID
Definition: Spell.h:745
void RemoveGameObject(GameObject *gameObj, bool del)
Definition: Unit.cpp:4987
void SetReferencedFromCurrent(bool yes)
Definition: Spell.h:696
void SendInterrupted(uint8 result)
Definition: Spell.cpp:4645
Spell ** m_selfContainer
Definition: Spell.h:722
void RemoveDynObject(uint32 spellId)
Definition: Unit.cpp:4927
Definition: SpellAuraDefines.h:67
Definition: Unit.h:736
Definition: Spell.h:331
Definition: SharedDefines.h:1446
Unit * ToUnit()
Definition: Object.h:200
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ CancelGlobalCooldown()

void Spell::CancelGlobalCooldown ( )
protected
8137 {
8139  return;
8140 
8142  return;
8143 
8144  // Cancel global cooldown when interrupting current cast
8146  return;
8147 
8149 }
SpellInfo const *const m_spellInfo
Definition: Spell.h:632
Definition: Unit.h:580
WorldObject *const m_caster
Definition: Spell.h:741
void CancelGlobalCooldown(SpellInfo const *spellInfo)
Definition: SpellHistory.cpp:882
SpellHistory * GetSpellHistory()
Definition: Unit.h:1495
Spell * GetCurrentSpell(CurrentSpellTypes spellType) const
Definition: Unit.h:1485
bool CanHaveGlobalCooldown(WorldObject const *caster)
Definition: Spell.cpp:8075
uint32 StartRecoveryTime
Definition: SpellInfo.h:417
Unit * ToUnit()
Definition: Object.h:200
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ CanExecuteTriggersOnHit()

bool Spell::CanExecuteTriggersOnHit ( uint32  effMask,
SpellInfo const *  triggeredByAura = nullptr 
) const
protected
8027 {
8028  bool only_on_caster = (triggeredByAura && (triggeredByAura->HasAttribute(SPELL_ATTR4_PROC_ONLY_ON_CASTER)));
8029  // If triggeredByAura has SPELL_ATTR4_PROC_ONLY_ON_CASTER then it can only proc on a cast spell with TARGET_UNIT_CASTER
8030  for (SpellEffectInfo const& spellEffectInfo : m_spellInfo->GetEffects())
8031  {
8032  if ((effMask & (1 << spellEffectInfo.EffectIndex)) && (!only_on_caster || (spellEffectInfo.TargetA.GetTarget() == TARGET_UNIT_CASTER)))
8033  return true;
8034  }
8035  return false;
8036 }
SpellInfo const *const m_spellInfo
Definition: Spell.h:632
Definition: SpellInfo.h:264
std::vector< SpellEffectInfo > const & GetEffects() const
Definition: SpellInfo.h:616
Definition: SharedDefines.h:521
Definition: SharedDefines.h:2422
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ CanOpenLock()

SpellCastResult Spell::CanOpenLock ( SpellEffectInfo const &  effect,
uint32  lockid,
SkillType skillid,
int32 reqSkillValue,
int32 skillValue 
)
protected
7670 {
7671  if (!lockId) // possible case for GO and maybe for items.
7672  return SPELL_CAST_OK;
7673 
7674  Unit const* unitCaster = m_caster->ToUnit();
7675  if (!unitCaster)
7676  return SPELL_FAILED_BAD_TARGETS;
7677 
7678  // Get LockInfo
7679  LockEntry const* lockInfo = sLockStore.LookupEntry(lockId);
7680 
7681  if (!lockInfo)
7682  return SPELL_FAILED_BAD_TARGETS;
7683 
7684  bool reqKey = false; // some locks not have reqs
7685 
7686  for (int j = 0; j < MAX_LOCK_CASE; ++j)
7687  {
7688  switch (lockInfo->Type[j])
7689  {
7690  // check key item (many fit cases can be)
7691  case LOCK_KEY_ITEM:
7692  if (lockInfo->Index[j] && m_CastItem && int32(m_CastItem->GetEntry()) == lockInfo->Index[j])
7693  return SPELL_CAST_OK;
7694  reqKey = true;
7695  break;
7696  // check key skill (only single first fit case can be)
7697  case LOCK_KEY_SKILL:
7698  {
7699  reqKey = true;
7700 
7701  // wrong locktype, skip
7702  if (effect.MiscValue != lockInfo->Index[j])
7703  continue;
7704 
7705  skillId = SkillByLockType(LockType(lockInfo->Index[j]));
7706 
7707  if (skillId != SKILL_NONE || lockInfo->Index[j] == LOCKTYPE_LOCKPICKING)
7708  {
7709  reqSkillValue = lockInfo->Skill[j];
7710 
7711  // castitem check: rogue using skeleton keys. the skill values should not be added in this case.
7712  skillValue = 0;
7713  if (!m_CastItem && unitCaster->GetTypeId() == TYPEID_PLAYER)
7714  skillValue = unitCaster->ToPlayer()->GetSkillValue(skillId);
7715  else if (lockInfo->Index[j] == LOCKTYPE_LOCKPICKING)
7716  skillValue = unitCaster->getLevel() * 5;
7717 
7718  // skill bonus provided by casting spell (mostly item spells)
7719  // add the effect base points modifier from the spell cast (cheat lock / skeleton key etc.)
7720  if (effect.TargetA.GetTarget() == TARGET_GAMEOBJECT_ITEM_TARGET || effect.TargetB.GetTarget() == TARGET_GAMEOBJECT_ITEM_TARGET)
7721  skillValue += effect.CalcValue();
7722 
7723  if (skillValue < reqSkillValue)
7725  }
7726 
7727  return SPELL_CAST_OK;
7728  }
7729  }
7730  }
7731 
7732  if (reqKey)
7733  return SPELL_FAILED_BAD_TARGETS;
7734 
7735  return SPELL_CAST_OK;
7736 }
int32 Index[MAX_LOCK_CASE]
Definition: DB2Structure.h:2331
Definition: SharedDefines.h:2442
TypeID GetTypeId() const
Definition: Object.h:167
Definition: SharedDefines.h:5063
uint8 getLevel() const
Definition: Unit.h:843
WorldObject *const m_caster
Definition: Spell.h:741
Definition: DB2Structure.h:2327
Item * m_CastItem
Definition: Spell.h:633
LockType
Definition: SharedDefines.h:4239
DB2Storage< LockEntry > sLockStore("Lock.db2", LockLoadInfo::Instance())
Player * ToPlayer()
Definition: Object.h:192
Definition: SharedDefines.h:4234
Definition: SharedDefines.h:4235
Definition: SharedDefines.h:1396
Unit * unitCaster
Definition: Spell.h:794
int32_t int32
Definition: Define.h:148
uint8 Type[MAX_LOCK_CASE]
Definition: DB2Structure.h:2333
uint32 GetEntry() const
Definition: Object.h:155
Definition: ObjectGuid.h:40
SkillType SkillByLockType(LockType locktype)
Definition: SharedDefines.h:5398
uint16 Skill[MAX_LOCK_CASE]
Definition: DB2Structure.h:2332
#define MAX_LOCK_CASE
Definition: DB2Structure.h:2325
Definition: SharedDefines.h:1455
Definition: Unit.h:736
Definition: SharedDefines.h:1697
Unit * ToUnit()
Definition: Object.h:200
uint16 GetSkillValue(uint32 skill) const
Definition: Player.cpp:5854
Definition: SharedDefines.h:4241
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ cast()

void Spell::cast ( bool  skipCheck = false)
3260 {
3261  Player* modOwner = m_caster->GetSpellModOwner();
3262  Spell* lastSpellMod = nullptr;
3263  if (modOwner)
3264  {
3265  lastSpellMod = modOwner->m_spellModTakingSpell;
3266  if (lastSpellMod)
3267  modOwner->SetSpellModTakingSpell(lastSpellMod, false);
3268  }
3269 
3270  _cast(skipCheck);
3271 
3272  if (lastSpellMod)
3273  modOwner->SetSpellModTakingSpell(lastSpellMod, true);
3274 }
Spell * m_spellModTakingSpell
Definition: Player.h:2514
WorldObject *const m_caster
Definition: Spell.h:741
void _cast(bool skipCheck=false)
Definition: Spell.cpp:3276
void SetSpellModTakingSpell(Spell *spell, bool apply)
Definition: Player.cpp:22443
Player * GetSpellModOwner() const
Definition: Object.cpp:2073
Definition: Player.h:1056
Definition: Spell.h:348
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ CheckArenaAndRatedBattlegroundCastRules()

SpellCastResult Spell::CheckArenaAndRatedBattlegroundCastRules ( )
6343 {
6344  bool isRatedBattleground = false; // NYI
6345  bool isArena = !isRatedBattleground;
6346 
6347  // check USABLE attributes
6348  // USABLE takes precedence over NOT_USABLE
6350  return SPELL_CAST_OK;
6351 
6353  return SPELL_CAST_OK;
6354 
6355  // check NOT_USABLE attributes
6358 
6361 
6362  // check cooldowns
6363  uint32 spellCooldown = m_spellInfo->GetRecoveryTime();
6364  if (isArena && spellCooldown > 10 * MINUTE * IN_MILLISECONDS) // not sure if still needed
6366 
6367  if (isRatedBattleground && spellCooldown > 15 * MINUTE * IN_MILLISECONDS)
6369 
6370  return SPELL_CAST_OK;
6371 }
SpellInfo const *const m_spellInfo
Definition: Spell.h:632
Definition: SharedDefines.h:714
Definition: SharedDefines.h:709
Definition: SharedDefines.h:1556
Definition: SharedDefines.h:537
Definition: SharedDefines.h:536
Definition: Common.h:62
bool HasAttribute(SpellAttr0 attribute) const
Definition: SpellInfo.h:486
Definition: Common.h:68
uint32_t uint32
Definition: Define.h:152
uint32 GetRecoveryTime() const
Definition: SpellInfo.cpp:3765
Definition: SharedDefines.h:1623
Definition: SharedDefines.h:1697
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ CheckCast()

SpellCastResult Spell::CheckCast ( bool  strict,
uint32 param1 = nullptr,
uint32 param2 = nullptr 
)
Todo:
determine if there is some flag to enable/disable the check
5088 {
5089  // check death state
5091  return SPELL_FAILED_CASTER_DEAD;
5092 
5093  // check cooldowns to prevent cheating
5094  if (!m_spellInfo->IsPassive())
5095  {
5096  if (Player const* playerCaster = m_caster->ToPlayer())
5097  {
5098  //can cast triggered (by aura only?) spells while have this flag
5100  {
5101  // These two auras check SpellFamilyName defined by db2 class data instead of current spell SpellFamilyName
5102  if (playerCaster->HasAuraType(SPELL_AURA_DISABLE_CASTING_EXCEPT_ABILITIES)
5106  && !playerCaster->HasAuraTypeWithFamilyFlags(SPELL_AURA_DISABLE_CASTING_EXCEPT_ABILITIES, sChrClassesStore.AssertEntry(playerCaster->getClass())->SpellClassSet, m_spellInfo->SpellFamilyFlags))
5108 
5109  if (playerCaster->HasAuraType(SPELL_AURA_DISABLE_ATTACKING_EXCEPT_ABILITIES))
5110  {
5111  if (!playerCaster->HasAuraTypeWithFamilyFlags(SPELL_AURA_DISABLE_ATTACKING_EXCEPT_ABILITIES, sChrClassesStore.AssertEntry(playerCaster->getClass())->SpellClassSet, m_spellInfo->SpellFamilyFlags))
5112  {
5123  }
5124  }
5125  }
5126 
5127  // check if we are using a potion in combat for the 2nd+ time. Cooldown is added only after caster gets out of combat
5128  if (!IsIgnoringCooldowns() && playerCaster->GetLastPotionId() && m_CastItem && (m_CastItem->IsPotion() || m_spellInfo->IsCooldownStartedOnEvent()))
5129  return SPELL_FAILED_NOT_READY;
5130  }
5131 
5133  {
5135  return SPELL_FAILED_DONT_REPORT;
5136  else
5137  return SPELL_FAILED_NOT_READY;
5138  }
5139  }
5140 
5142  {
5145  }
5146 
5147  // Check global cooldown
5150 
5151  // only triggered spells can be processed an ended battleground
5152  if (!IsTriggered() && m_caster->GetTypeId() == TYPEID_PLAYER)
5154  if (bg->GetStatus() == STATUS_WAIT_LEAVE)
5155  return SPELL_FAILED_DONT_REPORT;
5156 
5158  {
5160  !m_caster->IsOutdoors())
5162 
5164  m_caster->IsOutdoors())
5166  }
5167 
5168  if (Unit* unitCaster = m_caster->ToUnit())
5169  {
5170  // only check at first call, Stealth auras are already removed at second call
5171  // for now, ignore triggered spells
5173  {
5174  bool checkForm = true;
5175  // Ignore form req aura
5177  for (AuraEffect const* aurEff : ignore)
5178  {
5179  if (!aurEff->IsAffectingSpell(m_spellInfo))
5180  continue;
5181 
5182  checkForm = false;
5183  break;
5184  }
5185 
5186  if (checkForm)
5187  {
5188  // Cannot be used in this stance/form
5190  if (shapeError != SPELL_CAST_OK)
5191  return shapeError;
5192 
5195  }
5196  }
5197 
5198  bool reqCombat = true;
5200  for (Unit::AuraEffectList::const_iterator j = stateAuras.begin(); j != stateAuras.end(); ++j)
5201  {
5202  if ((*j)->IsAffectingSpell(m_spellInfo))
5203  {
5204  m_needComboPoints = false;
5205  if ((*j)->GetMiscValue() == 1)
5206  {
5207  reqCombat = false;
5208  break;
5209  }
5210  }
5211  }
5212 
5213  // caster state requirements
5214  // not for triggered spells (needed by execute)
5215  if (!(_triggeredCastFlags & TRIGGERED_IGNORE_CASTER_AURASTATE))
5216  {
5221 
5222  // Note: spell 62473 requres casterAuraSpell = triggering spell
5227 
5228  if (reqCombat && unitCaster->IsInCombat() && !m_spellInfo->CanBeUsedInCombat())
5230  }
5231 
5232  // cancel autorepeat spells if cast start when moving
5233  // (not wand currently autorepeat cast delayed to moving stop anyway in spell update code)
5234  // Do not cancel spells which are affected by a SPELL_AURA_CAST_WHILE_WALKING effect
5236  {
5237  // skip stuck spell to allow use it in falling case and apply spell limitations at movement
5240  return SPELL_FAILED_MOVING;
5241  }
5242 
5243  // Check vehicle flags
5245  {
5247  if (vehicleCheck != SPELL_CAST_OK)
5248  return vehicleCheck;
5249  }
5250  }
5251 
5252  // check spell cast conditions from database
5253  {
5255  if (!sConditionMgr->IsObjectMeetingNotGroupedConditions(CONDITION_SOURCE_TYPE_SPELL, m_spellInfo->Id, condInfo))
5256  {
5257  // mLastFailedCondition can be NULL if there was an error processing the condition in Condition::Meets (i.e. wrong data for ConditionTarget or others)
5258  if (condInfo.mLastFailedCondition && condInfo.mLastFailedCondition->ErrorType)
5259  {
5263  }
5264 
5265  if (!condInfo.mLastFailedCondition || !condInfo.mLastFailedCondition->ConditionTarget)
5267  return SPELL_FAILED_BAD_TARGETS;
5268  }
5269  }
5270 
5271  // Don't check explicit target for passive spells (workaround) (check should be skipped only for learn case)
5272  // those spells may have incorrect target entries or not filled at all (for example 15332)
5273  // such spells when learned are not targeting anyone using targeting system, they should apply directly to caster instead
5274  // also, such casts shouldn't be sent to client
5276  {
5277  // Check explicit target for m_originalCaster - todo: get rid of such workarounds
5278  WorldObject* caster = m_caster;
5279  if (m_originalCaster)
5280  caster = m_originalCaster;
5281 
5283  if (castResult != SPELL_CAST_OK)
5284  return castResult;
5285  }
5286 
5287  if (Unit* target = m_targets.GetUnitTarget())
5288  {
5289  SpellCastResult castResult = m_spellInfo->CheckTarget(m_caster, target, m_caster->GetTypeId() == TYPEID_GAMEOBJECT); // skip stealth checks for GO casts
5290  if (castResult != SPELL_CAST_OK)
5291  return castResult;
5292 
5293  // If it's not a melee spell, check if vision is obscured by SPELL_AURA_INTERFERE_TARGETTING
5295  {
5296  if (Unit const* unitCaster = m_caster->ToUnit())
5297  {
5299  if (!unitCaster->IsFriendlyTo(auraEff->GetCaster()) && !target->HasAura(auraEff->GetId(), auraEff->GetCasterGUID()))
5301 
5302  for (AuraEffect const* auraEff : target->GetAuraEffectsByType(SPELL_AURA_INTERFERE_TARGETTING))
5303  if (!unitCaster->IsFriendlyTo(auraEff->GetCaster()) && (!target->HasAura(auraEff->GetId(), auraEff->GetCasterGUID()) || !unitCaster->HasAura(auraEff->GetId(), auraEff->GetCasterGUID())))
5305  }
5306  }
5307 
5308  if (target != m_caster)
5309  {
5310  // Must be behind the target
5311  if ((m_spellInfo->HasAttribute(SPELL_ATTR0_CU_REQ_CASTER_BEHIND_TARGET)) && target->HasInArc(static_cast<float>(M_PI), m_caster))
5312  return SPELL_FAILED_NOT_BEHIND;
5313 
5314  // Target must be facing you
5315  if ((m_spellInfo->HasAttribute(SPELL_ATTR0_CU_REQ_TARGET_FACING_CASTER)) && !target->HasInArc(static_cast<float>(M_PI), m_caster))
5316  return SPELL_FAILED_NOT_INFRONT;
5317 
5318  // Ignore LOS for gameobjects casts
5320  {
5321  WorldObject* losTarget = m_caster;
5324  losTarget = dynObj;
5325 
5328  }
5329  }
5330  }
5331 
5332  // Check for line of sight for spells with dest
5333  if (m_targets.HasDst())
5334  {
5335  float x, y, z;
5336  m_targets.GetDstPos()->GetPosition(x, y, z);
5337 
5340  }
5341 
5342  // check pet presence
5343  if (Unit* unitCaster = m_caster->ToUnit())
5344  {
5345  for (SpellEffectInfo const& spellEffectInfo : m_spellInfo->GetEffects())
5346  {
5347  if (spellEffectInfo.TargetA.GetTarget() == TARGET_UNIT_PET)
5348  {
5349  if (!unitCaster->GetGuardianPet())
5350  {
5351  if (m_triggeredByAuraSpell) // not report pet not existence for triggered spells
5352  return SPELL_FAILED_DONT_REPORT;
5353  else
5354  return SPELL_FAILED_NO_PET;
5355  }
5356  break;
5357  }
5358  }
5359  }
5360 
5361  // Spell cast only in battleground
5363  if (!m_caster->ToPlayer()->InBattleground())
5365 
5366  // do not allow spells to be cast in arenas or rated battlegrounds
5367  if (Player* player = m_caster->ToPlayer())
5368  if (player->InArena()/* || player->InRatedBattleGround() NYI*/)
5369  {
5371  if (castResult != SPELL_CAST_OK)
5372  return castResult;
5373  }
5374 
5375  // zone check
5377  {
5378  uint32 zone, area;
5379  m_caster->GetZoneAndAreaId(zone, area);
5380 
5382  if (locRes != SPELL_CAST_OK)
5383  return locRes;
5384  }
5385 
5386  // not let players cast spells at mount (and let do it to creatures)
5387  if (!(_triggeredCastFlags & TRIGGERED_IGNORE_CASTER_MOUNTED_OR_ON_VEHICLE))
5388  {
5390  {
5391  if (m_caster->ToPlayer()->IsInFlight())
5392  return SPELL_FAILED_NOT_ON_TAXI;
5393  else
5394  return SPELL_FAILED_NOT_MOUNTED;
5395  }
5396  }
5397 
5398  // check spell focus object
5400  {
5402  {
5404  if (!focusObject)
5406  }
5407  }
5408 
5409  SpellCastResult castResult = SPELL_CAST_OK;
5410 
5411  // always (except passive spells) check items (only player related checks)
5412  if (!m_spellInfo->IsPassive())
5413  {
5414  castResult = CheckItems(param1, param2);
5415  if (castResult != SPELL_CAST_OK)
5416  return castResult;
5417  }
5418 
5419  // Triggered spells also have range check
5421  castResult = CheckRange(strict);
5422  if (castResult != SPELL_CAST_OK)
5423  return castResult;
5424 
5426  {
5427  castResult = CheckPower();
5428  if (castResult != SPELL_CAST_OK)
5429  return castResult;
5430  }
5431 
5433  {
5434  castResult = CheckCasterAuras(param1);
5435  if (castResult != SPELL_CAST_OK)
5436  return castResult;
5437  }
5438 
5439  // script hook
5440  castResult = CallScriptCheckCastHandlers();
5441  if (castResult != SPELL_CAST_OK)
5442  return castResult;
5443 
5444  for (SpellEffectInfo const& spellEffectInfo : m_spellInfo->GetEffects())
5445  {
5446  // for effects of spells that have only one target
5447  switch (spellEffectInfo.Effect)
5448  {
5449  case SPELL_EFFECT_DUMMY:
5450  {
5451  if (m_spellInfo->Id == 19938) // Awaken Peon
5452  {
5453  Unit* unit = m_targets.GetUnitTarget();
5454  if (!unit || !unit->HasAura(17743))
5455  return SPELL_FAILED_BAD_TARGETS;
5456  }
5457  else if (m_spellInfo->Id == 31789) // Righteous Defense
5458  {
5459  if (m_caster->GetTypeId() != TYPEID_PLAYER)
5460  return SPELL_FAILED_DONT_REPORT;
5461 
5462  Unit* target = m_targets.GetUnitTarget();
5463  if (!target || !target->IsFriendlyTo(m_caster) || target->getAttackers().empty())
5464  return SPELL_FAILED_BAD_TARGETS;
5465 
5466  }
5467  break;
5468  }
5470  {
5471  if (spellEffectInfo.TargetA.GetTarget() != TARGET_UNIT_PET)
5472  break;
5473 
5474  Pet* pet = m_caster->ToPlayer()->GetPet();
5475  if (!pet)
5476  return SPELL_FAILED_NO_PET;
5477 
5478  SpellInfo const* learn_spellproto = sSpellMgr->GetSpellInfo(spellEffectInfo.TriggerSpell, DIFFICULTY_NONE);
5479  if (!learn_spellproto)
5480  return SPELL_FAILED_NOT_KNOWN;
5481 
5482  if (m_spellInfo->SpellLevel > pet->getLevel())
5483  return SPELL_FAILED_LOWLEVEL;
5484 
5485  break;
5486  }
5488  {
5489  if (m_caster->GetTypeId() != TYPEID_PLAYER)
5490  return SPELL_FAILED_BAD_TARGETS;
5491  if (Guild* guild = m_caster->ToPlayer()->GetGuild())
5492  if (guild->GetLeaderGUID() != m_caster->ToPlayer()->GetGUID())
5494  break;
5495  }
5497  {
5498  // check target only for unit target case
5499  if (Unit* unit = m_targets.GetUnitTarget())
5500  {
5501  if (m_caster->GetTypeId() != TYPEID_PLAYER)
5502  return SPELL_FAILED_BAD_TARGETS;
5503 
5504  Pet* pet = unit->ToPet();
5505  if (!pet || pet->GetOwner() != m_caster)
5506  return SPELL_FAILED_BAD_TARGETS;
5507 
5508  SpellInfo const* learn_spellproto = sSpellMgr->GetSpellInfo(spellEffectInfo.TriggerSpell, DIFFICULTY_NONE);
5509 
5510  if (!learn_spellproto)
5511  return SPELL_FAILED_NOT_KNOWN;
5512 
5513  if (m_spellInfo->SpellLevel > pet->getLevel())
5514  return SPELL_FAILED_LOWLEVEL;
5515  }
5516  break;
5517  }
5519  {
5520  if (m_caster->GetTypeId() != TYPEID_PLAYER)
5522 
5523  Player* caster = m_caster->ToPlayer();
5524  if (!caster->HasSpell(m_misc.SpellId))
5525  return SPELL_FAILED_NOT_KNOWN;
5526 
5527  if (uint32 glyphId = spellEffectInfo.MiscValue)
5528  {
5529  GlyphPropertiesEntry const* glyphProperties = sGlyphPropertiesStore.LookupEntry(glyphId);
5530  if (!glyphProperties)
5532 
5533  std::vector<uint32> const* glyphBindableSpells = sDB2Manager.GetGlyphBindableSpells(glyphId);
5534  if (!glyphBindableSpells)
5536 
5537  if (std::find(glyphBindableSpells->begin(), glyphBindableSpells->end(), m_misc.SpellId) == glyphBindableSpells->end())
5539 
5540  if (std::vector<uint32> const* glyphRequiredSpecs = sDB2Manager.GetGlyphRequiredSpecs(glyphId))
5541  {
5542  if (!caster->GetPrimarySpecialization())
5544 
5545  if (std::find(glyphRequiredSpecs->begin(), glyphRequiredSpecs->end(), caster->GetPrimarySpecialization()) == glyphRequiredSpecs->end())
5547  }
5548 
5549  uint32 replacedGlyph = 0;
5550  for (uint32 activeGlyphId : caster->GetGlyphs(caster->GetActiveTalentGroup()))
5551  {
5552  if (std::vector<uint32> const* activeGlyphBindableSpells = sDB2Manager.GetGlyphBindableSpells(activeGlyphId))
5553  {
5554  if (std::find(activeGlyphBindableSpells->begin(), activeGlyphBindableSpells->end(), m_misc.SpellId) != activeGlyphBindableSpells->end())
5555  {
5556  replacedGlyph = activeGlyphId;
5557  break;
5558  }
5559  }
5560  }
5561 
5562  for (uint32 activeGlyphId : caster->GetGlyphs(caster->GetActiveTalentGroup()))
5563  {
5564  if (activeGlyphId == replacedGlyph)
5565  continue;
5566 
5567  if (activeGlyphId == glyphId)
5569 
5570  if (sGlyphPropertiesStore.AssertEntry(activeGlyphId)->GlyphExclusiveCategoryID == glyphProperties->GlyphExclusiveCategoryID)
5572  }
5573  }
5574  break;
5575  }
5576  case SPELL_EFFECT_FEED_PET:
5577  {
5578  if (m_caster->GetTypeId() != TYPEID_PLAYER)
5579  return SPELL_FAILED_BAD_TARGETS;
5580 
5581  Item* foodItem = m_targets.GetItemTarget();
5582  if (!foodItem)
5583  return SPELL_FAILED_BAD_TARGETS;
5584 
5585  Pet* pet = m_caster->ToPlayer()->GetPet();
5586  if (!pet)
5587  return SPELL_FAILED_NO_PET;
5588 
5589  if (!pet->HaveInDiet(foodItem->GetTemplate()))
5591 
5592  if (foodItem->GetTemplate()->GetBaseItemLevel() + 30 <= pet->getLevel())
5594 
5595  if (m_caster->ToPlayer()->IsInCombat() || pet->IsInCombat())
5597 
5598  break;
5599  }
5600  case SPELL_EFFECT_CHARGE:
5601  {
5603  if (!unitCaster)
5604  return SPELL_FAILED_BAD_TARGETS;
5605 
5606  if (!(_triggeredCastFlags & TRIGGERED_IGNORE_CASTER_AURAS) && unitCaster->HasUnitState(UNIT_STATE_ROOT))
5607  return SPELL_FAILED_ROOTED;
5608 
5610  {
5611  Unit* target = m_targets.GetUnitTarget();
5612  if (!target)
5613  return SPELL_FAILED_DONT_REPORT;
5614 
5615  // first we must check to see if the target is in LoS. A path can usually be built but LoS matters for charge spells
5616  if (!target->IsWithinLOSInMap(unitCaster)) //Do full LoS/Path check. Don't exclude m2
5618 
5619  float objSize = target->GetCombatReach();
5620  float range = m_spellInfo->GetMaxRange(true, unitCaster, this) * 1.5f + objSize; // can't be overly strict
5621 
5622  m_preGeneratedPath = std::make_unique<PathGenerator>(unitCaster);
5623  m_preGeneratedPath->SetPathLengthLimit(range);
5624  // first try with raycast, if it fails fall back to normal path
5625  float targetObjectSize = std::min(target->GetCombatReach(), 4.0f);
5626  bool result = m_preGeneratedPath->CalculatePath(target->GetPositionX(), target->GetPositionY(), target->GetPositionZ() + targetObjectSize, false, true);
5627  if (m_preGeneratedPath->GetPathType() & PATHFIND_SHORT)
5629  else if (!result || m_preGeneratedPath->GetPathType() & (PATHFIND_NOPATH | PATHFIND_INCOMPLETE))
5630  {
5631  result = m_preGeneratedPath->CalculatePath(target->GetPositionX(), target->GetPositionY(), target->GetPositionZ() + targetObjectSize, false, false);
5632  if (m_preGeneratedPath->GetPathType() & PATHFIND_SHORT)
5634  else if (!result || m_preGeneratedPath->GetPathType() & (PATHFIND_NOPATH | PATHFIND_INCOMPLETE))
5635  return SPELL_FAILED_NOPATH;
5636  else if (m_preGeneratedPath->IsInvalidDestinationZ(target)) // Check position z, if not in a straight line
5637  return SPELL_FAILED_NOPATH;
5638  }
5639  else if (m_preGeneratedPath->IsInvalidDestinationZ(target)) // Check position z, if in a straight line
5640  return SPELL_FAILED_NOPATH;
5641 
5642  m_preGeneratedPath->ReducePathLenghtByDist(objSize); // move back
5643  }
5644  break;
5645  }
5646  case SPELL_EFFECT_SKINNING:
5647  {
5649  return SPELL_FAILED_BAD_TARGETS;
5650 
5653 
5654  Creature* creature = m_targets.GetUnitTarget()->ToCreature();
5655  if (!creature->IsCritter() && !creature->loot.isLooted())
5657 
5658  uint32 skill = creature->GetCreatureTemplate()->GetRequiredLootSkill();
5659 
5660  int32 skillValue = m_caster->ToPlayer()->GetSkillValue(skill);
5662  int32 ReqValue = (skillValue < 100 ? (TargetLevel-10) * 10 : TargetLevel * 5);
5663  if (ReqValue > skillValue)
5665 
5666  break;
5667  }
5669  {
5670  if (spellEffectInfo.TargetA.GetTarget() != TARGET_GAMEOBJECT_TARGET &&
5671  spellEffectInfo.TargetA.GetTarget() != TARGET_GAMEOBJECT_ITEM_TARGET)
5672  break;
5673 
5674  if (m_caster->GetTypeId() != TYPEID_PLAYER // only players can open locks, gather etc.
5675  // we need a go target in case of TARGET_GAMEOBJECT_TARGET
5676  || (spellEffectInfo.TargetA.GetTarget() == TARGET_GAMEOBJECT_TARGET && !m_targets.GetGOTarget()))
5677  return SPELL_FAILED_BAD_TARGETS;
5678 
5679  Item* pTempItem = nullptr;
5681  {
5682  if (TradeData* pTrade = m_caster->ToPlayer()->GetTradeData())
5683  pTempItem = pTrade->GetTraderData()->GetItem(TRADE_SLOT_NONTRADED);
5684  }
5687 
5688  // we need a go target, or an openable item target in case of TARGET_GAMEOBJECT_ITEM_TARGET
5689  if (spellEffectInfo.TargetA.GetTarget() == TARGET_GAMEOBJECT_ITEM_TARGET &&
5690  !m_targets.GetGOTarget() &&
5691  (!pTempItem || !pTempItem->GetTemplate()->GetLockID() || !pTempItem->IsLocked()))
5692  return SPELL_FAILED_BAD_TARGETS;
5693 
5694  if (m_spellInfo->Id != 1842 || (m_targets.GetGOTarget() &&
5696  if (m_caster->ToPlayer()->InBattleground() && // In Battleground players can use only flags and banners
5698  return SPELL_FAILED_TRY_AGAIN;
5699 
5700  // get the lock entry
5701  uint32 lockId = 0;
5702  if (GameObject* go = m_targets.GetGOTarget())
5703  {
5704  lockId = go->GetGOInfo()->GetLockId();
5705  if (!lockId)
5706  return SPELL_FAILED_BAD_TARGETS;
5707  }
5708  else if (Item* itm = m_targets.GetItemTarget())
5709  lockId = itm->GetTemplate()->GetLockID();
5710 
5711  SkillType skillId = SKILL_NONE;
5712  int32 reqSkillValue = 0;
5713  int32 skillValue = 0;
5714 
5715  // check lock compatibility
5716  SpellCastResult res = CanOpenLock(spellEffectInfo, lockId, skillId, reqSkillValue, skillValue);
5717  if (res != SPELL_CAST_OK)
5718  return res;
5719  break;
5720  }
5722  {
5723  Unit* unitCaster = m_caster->ToUnit();
5724  if (!unitCaster)
5725  return SPELL_FAILED_BAD_TARGETS;
5726 
5727  Creature* pet = unitCaster->GetGuardianPet();
5728  if (pet && pet->IsAlive())
5730  break;
5731  }
5732  // This is generic summon effect
5733  case SPELL_EFFECT_SUMMON:
5734  {
5735  Unit* unitCaster = m_caster->ToUnit();
5736  if (!unitCaster)
5737  break;
5738 
5739  SummonPropertiesEntry const* SummonProperties = sSummonPropertiesStore.LookupEntry(spellEffectInfo.MiscValueB);
5740  if (!SummonProperties)
5741  break;
5742 
5743  switch (SummonProperties->Control)
5744  {
5745  case SUMMON_CATEGORY_PET:
5748  /* fallthrough */
5749  // intentional, check both GetPetGUID() and GetCharmGUID for SUMMON_CATEGORY_PET
5751  if (!unitCaster->GetCharmGUID().IsEmpty())
5753  break;
5754  }
5755  break;
5756  }
5758  {
5759  if (m_targets.GetUnitTarget())
5760  {
5762  return SPELL_FAILED_BAD_TARGETS;
5765  }
5766  break;
5767  }
5769  {
5770  Unit* unitCaster = m_caster->ToUnit();
5771  if (!unitCaster)
5772  return SPELL_FAILED_BAD_TARGETS;
5773 
5774  if (!unitCaster->GetPetGUID().IsEmpty()) //let warlock do a replacement summon
5775  {
5776  if (unitCaster->GetTypeId() == TYPEID_PLAYER)
5777  {
5778  if (strict) //starting cast, trigger pet stun (cast by pet so it doesn't attack player)
5779  if (Pet* pet = unitCaster->ToPlayer()->GetPet())
5780  pet->CastSpell(pet, 32752, pet->GetGUID());
5781  }
5784  }
5785 
5786  if (!unitCaster->GetCharmGUID().IsEmpty())
5788  break;
5789  }
5791  {
5792  if (m_caster->GetTypeId() != TYPEID_PLAYER)
5793  return SPELL_FAILED_BAD_TARGETS;
5794 
5795  if (!m_caster->ToPlayer()->GetTarget())
5796  return SPELL_FAILED_BAD_TARGETS;
5797 
5799  if (!target || m_caster->ToPlayer() == target || (!target->IsInSameRaidWith(m_caster->ToPlayer()) && m_spellInfo->Id != 48955)) // refer-a-friend spell
5800  return SPELL_FAILED_BAD_TARGETS;
5801 
5802  if (target->HasSummonPending())
5804 
5805  // check if our map is dungeon
5806  MapEntry const* map = sMapStore.LookupEntry(m_caster->GetMapId());
5807  if (map->IsDungeon())
5808  {
5809  uint32 mapId = m_caster->GetMap()->GetId();
5810  Difficulty difficulty = m_caster->GetMap()->GetDifficultyID();
5811  if (map->IsRaid())
5812  if (InstancePlayerBind* targetBind = target->GetBoundInstance(mapId, difficulty))
5813  if (InstancePlayerBind* casterBind = m_caster->ToPlayer()->GetBoundInstance(mapId, difficulty))
5814  if (targetBind->perm && targetBind->save != casterBind->save)
5816 
5817  InstanceTemplate const* instance = sObjectMgr->GetInstanceTemplate(mapId);
5818  if (!instance)
5820  if (!target->Satisfy(sObjectMgr->GetAccessRequirement(mapId, difficulty), mapId))
5821  return SPELL_FAILED_BAD_TARGETS;
5822  }
5823  break;
5824  }
5825  // RETURN HERE
5827  {
5828  if (m_caster->GetTypeId() != TYPEID_PLAYER)
5829  return SPELL_FAILED_BAD_TARGETS;
5830 
5831  Player* playerCaster = m_caster->ToPlayer();
5832  if (!playerCaster->GetTarget())
5833  return SPELL_FAILED_BAD_TARGETS;
5834 
5835  Player* target = playerCaster->GetSelectedPlayer();
5836  if (!target ||
5837  !(target->GetSession()->GetRecruiterId() == playerCaster->GetSession()->GetAccountId() || target->GetSession()->GetAccountId() == playerCaster->GetSession()->GetRecruiterId()))
5838  return SPELL_FAILED_BAD_TARGETS;
5839  break;
5840  }
5841  case SPELL_EFFECT_LEAP:
5843  {
5844  //Do not allow to cast it before BG starts.
5845  if (m_caster->GetTypeId() == TYPEID_PLAYER)
5846  if (Battleground const* bg = m_caster->ToPlayer()->GetBattleground())
5847  if (bg->GetStatus() != STATUS_IN_PROGRESS)
5848  return SPELL_FAILED_TRY_AGAIN;
5849  break;
5850  }
5852  {
5854  return SPELL_FAILED_BAD_TARGETS;
5855  break;
5856  }
5858  {
5859  Unit* unitCaster = m_caster->ToUnit();
5860  if (!unitCaster)
5861  return SPELL_FAILED_BAD_TARGETS;
5862 
5863  if (unitCaster->HasUnitState(UNIT_STATE_ROOT))
5864  {
5865  if (unitCaster->GetTypeId() == TYPEID_PLAYER)
5866  return SPELL_FAILED_ROOTED;
5867  else
5868  return SPELL_FAILED_DONT_REPORT;
5869  }
5870  break;
5871  }
5872  case SPELL_EFFECT_JUMP:
5874  {
5875  Unit* unitCaster = m_caster->ToUnit();
5876  if (!unitCaster)
5877  return SPELL_FAILED_BAD_TARGETS;
5878 
5879  if (unitCaster->HasUnitState(UNIT_STATE_ROOT))
5880  return SPELL_FAILED_ROOTED;
5881  break;
5882  }
5884  {
5885  ChrSpecializationEntry const* spec = sChrSpecializationStore.LookupEntry(m_misc.SpecializationId);
5886  Player* player = m_caster->ToPlayer();
5887  if (!player)
5889 
5890  if (!spec || (spec->ClassID != player->getClass() && !spec->IsPetSpecialization()))
5891  return SPELL_FAILED_NO_SPEC;
5892 
5893  if (spec->IsPetSpecialization())
5894  {
5895  Pet* pet = player->GetPet();
5896  if (!pet || pet->getPetType() != HUNTER_PET || !pet->GetCharmInfo())
5897  return SPELL_FAILED_NO_PET;
5898  }
5899 
5900  // can't change during already started arena/battleground
5901  if (Battleground const* bg = player->GetBattleground())
5902  if (bg->GetStatus() == STATUS_IN_PROGRESS)
5904  break;
5905  }
5907  {
5908  Player* playerCaster = m_caster->ToPlayer();
5909  if (!playerCaster)
5910  return SPELL_FAILED_BAD_TARGETS;
5911 
5912  TalentEntry const* talent = sTalentStore.LookupEntry(m_misc.TalentId);
5913  if (!talent)
5914  return SPELL_FAILED_DONT_REPORT;
5915 
5916  if (playerCaster->GetSpellHistory()->HasCooldown(talent->SpellID))
5917  {
5918  if (param1)
5919  *param1 = talent->SpellID;
5921  }
5922  break;
5923  }
5926  {
5927  Player* playerCaster = m_caster->ToPlayer();
5928  if (!playerCaster)
5929  return SPELL_FAILED_BAD_TARGETS;
5930 
5932  if (!artifactAura)
5934 
5935  Item* artifact = playerCaster->GetItemByGuid(artifactAura->GetCastItemGUID());
5936  if (!artifact)
5938 
5939  if (spellEffectInfo.Effect == SPELL_EFFECT_GIVE_ARTIFACT_POWER)
5940  {
5941  ArtifactEntry const* artifactEntry = sArtifactStore.LookupEntry(artifact->GetTemplate()->GetArtifactID());
5942  if (!artifactEntry || artifactEntry->ArtifactCategoryID != spellEffectInfo.MiscValue)
5944  }
5945  break;
5946  }
5947  default:
5948  break;
5949  }
5950  }
5951 
5952  for (SpellEffectInfo const& spellEffectInfo : m_spellInfo->GetEffects())
5953  {
5954  switch (spellEffectInfo.ApplyAuraName)
5955  {
5957  {
5958  if (m_caster->GetTypeId() != TYPEID_PLAYER)
5959  return SPELL_FAILED_NO_PET;
5960 
5961  Pet* pet = m_caster->ToPlayer()->GetPet();
5962  if (!pet)
5963  return SPELL_FAILED_NO_PET;
5964 
5965  if (!pet->GetCharmerGUID().IsEmpty())
5966  return SPELL_FAILED_CHARMED;
5967  break;
5968  }
5970  case SPELL_AURA_MOD_CHARM:
5971  case SPELL_AURA_AOE_CHARM:
5972  {
5973  Unit* unitCaster = (m_originalCaster ? m_originalCaster : m_caster->ToUnit());
5974  if (!unitCaster)
5975  return SPELL_FAILED_BAD_TARGETS;
5976 
5977  if (!unitCaster->GetCharmerGUID().IsEmpty())
5978  return SPELL_FAILED_CHARMED;
5979 
5980  if (spellEffectInfo.ApplyAuraName == SPELL_AURA_MOD_CHARM
5981  || spellEffectInfo.ApplyAuraName == SPELL_AURA_MOD_POSSESS)
5982  {
5985 
5986  if (!unitCaster->GetCharmGUID().IsEmpty())
5988  }
5989 
5990  if (Unit* target = m_targets.GetUnitTarget())
5991  {
5992  if (target->GetTypeId() == TYPEID_UNIT && target->IsVehicle())
5994 
5995  if (target->IsMounted())
5997 
5998  if (!target->GetCharmerGUID().IsEmpty())
5999  return SPELL_FAILED_CHARMED;
6000 
6001  if (target->GetOwner() && target->GetOwner()->GetTypeId() == TYPEID_PLAYER)
6003 
6004  int32 value = CalculateDamage(spellEffectInfo, target);
6005  if (value && int32(target->GetLevelForTarget(m_caster)) > value)
6006  return SPELL_FAILED_HIGHLEVEL;
6007  }
6008 
6009  break;
6010  }
6011  case SPELL_AURA_MOUNTED:
6012  {
6013  Unit* unitCaster = m_caster->ToUnit();
6014  if (!unitCaster)
6015  return SPELL_FAILED_BAD_TARGETS;
6016 
6019 
6020  // Ignore map check if spell have AreaId. AreaId already checked and this prevent special mount spells
6021  bool allowMount = !unitCaster->GetMap()->IsDungeon() || unitCaster->GetMap()->IsBattlegroundOrArena();
6022  InstanceTemplate const* it = sObjectMgr->GetInstanceTemplate(unitCaster->GetMapId());
6023  if (it)
6024  allowMount = it->AllowMount;
6025  if (unitCaster->GetTypeId() == TYPEID_PLAYER && !allowMount && !m_spellInfo->RequiredAreasID)
6027 
6028  if (unitCaster->IsInDisallowedMountForm())
6029  {
6030  SendMountResult(MountResult::Shapeshifted); // mount result gets sent before the cast result
6031  return SPELL_FAILED_DONT_REPORT;
6032  }
6033  break;
6034  }
6036  {
6037  if (!m_targets.GetUnitTarget())
6039 
6040  // can be cast at non-friendly unit or own pet/charm
6043  break;
6044  }
6045  case SPELL_AURA_FLY:
6047  {
6048  // not allow cast fly spells if not have req. skills (all spells is self target)
6049  // allow always ghost flight spells
6051  {
6052  Battlefield* Bf = sBattlefieldMgr->GetBattlefieldToZoneId(m_originalCaster->GetZoneId());
6053  if (AreaTableEntry const* area = sAreaTableStore.LookupEntry(m_originalCaster->GetAreaId()))
6054  if (area->Flags[0] & AREA_FLAG_NO_FLY_ZONE || (Bf && !Bf->CanFlyIn()))
6055  return SPELL_FAILED_NOT_HERE;
6056  }
6057  break;
6058  }
6060  {
6061  if (spellEffectInfo.IsTargetingArea())
6062  break;
6063 
6064  if (!m_targets.GetUnitTarget())
6066 
6068  break;
6069 
6071  return SPELL_FAILED_BAD_TARGETS;
6072  break;
6073  }
6074  default:
6075  break;
6076  }
6077  }
6078 
6079  // check trade slot case (last, for allow catch any another cast problems)
6081  {
6082  if (m_CastItem)
6084 
6085  if (m_caster->GetTypeId() != TYPEID_PLAYER)
6086  return SPELL_FAILED_NOT_TRADING;
6087 
6088  TradeData* my_trade = m_caster->ToPlayer()->GetTradeData();
6089  if (!my_trade)
6090  return SPELL_FAILED_NOT_TRADING;
6091 
6093  return SPELL_FAILED_BAD_TARGETS;
6094 
6095  if (!IsTriggered())
6096  if (my_trade->GetSpell())
6098  }
6099 
6100  // check if caster has at least 1 combo point for spells that require combo points
6101  if (m_needComboPoints)
6102  if (Player* plrCaster = m_caster->ToPlayer())
6103  if (!plrCaster->GetComboPoints())
6105 
6106  // all ok
6107  return SPELL_CAST_OK;
6108 }
Definition: SpellInfo.h:51
GameObject * focusObject
Definition: Spell.h:799
Definition: SharedDefines.h:1187
GameObject * SearchSpellFocus()
Definition: Spell.cpp:2046
Definition: SpellAuraEffects.h:28
float GetCombatReach() const override
Definition: Unit.h:791
Definition: Battleground.h:165
Definition: DB2Structure.h:125
Definition: DBCEnums.h:597
Item * GetItemTarget() const
Definition: Spell.h:253
bool IsOutdoors() const
Definition: Object.h:462
bool HasAuraState(AuraStateType flag, SpellInfo const *spellProto=nullptr, Unit const *Caster=nullptr) const
Definition: Unit.cpp:5693
SpellInfo const *const m_spellInfo
Definition: Spell.h:632
#define sDB2Manager
Definition: DB2Stores.h:445
Definition: SharedDefines.h:2442
Difficulty
Definition: DBCEnums.h:595
ItemTemplate const * GetTemplate() const
Definition: Item.cpp:1107
SpellCastResult CallScriptCheckCastHandlers()
Definition: Spell.cpp:7827
Definition: SharedDefines.h:1609
SpellCastResult CheckRange(bool strict) const
Definition: Spell.cpp:6447
DB2Storage< ArtifactEntry > sArtifactStore("Artifact.db2", ArtifactLoadInfo::Instance())
Definition: SharedDefines.h:1525
Definition: DB2Structure.h:201
Definition: SharedDefines.h:1188
Definition: SharedDefines.h:1595
Definition: SharedDefines.h:450
virtual bool IsInWater() const
Definition: Unit.cpp:3022
Definition: UnitDefines.h:253
bool CanFlyIn()
Return if we can use mount in battlefield.
Definition: Battlefield.h:349
bool HasAura(AuraType aura) const
Definition: SpellInfo.cpp:1291
Definition: SharedDefines.h:1518
Definition: SharedDefines.h:1442
Difficulty GetDifficultyID() const
Definition: Map.h:387
Definition: SharedDefines.h:1494
Definition: ObjectMgr.h:153
Definition: PathGenerator.h:47
Definition: SharedDefines.h:2426
Definition: SharedDefines.h:2439
SpellCastResult CheckArenaAndRatedBattlegroundCastRules()
Definition: Spell.cpp:6342
TypeID GetTypeId() const
Definition: Object.h:167
DB2Storage< ChrClassesEntry > sChrClassesStore("ChrClasses.db2", ChrClassesLoadInfo::Instance())
Definition: SharedDefines.h:1471
bool HasUnitMovementFlag(uint32 f) const
Definition: Unit.h:1701
Definition: SharedDefines.h:468
std::vector< uint32 > const & GetGlyphs(uint8 spec) const
Definition: Player.h:1787
Definition: SharedDefines.h:1629
bool IsCharmed() const
Definition: Unit.h:1265
bool IsMounted() const
Definition: Unit.h:984
ObjectGuid GetCharmerGUID() const
Definition: Unit.h:1229
uint32 DmgClass
Definition: SpellInfo.h:456
Definition: SharedDefines.h:1411
DB2Storage< ChrSpecializationEntry > sChrSpecializationStore("ChrSpecialization.db2", ChrSpecializationLoadInfo::Instance())
SpellCustomErrors
Definition: SharedDefines.h:1700
uint32 SpellLevel
Definition: SpellInfo.h:431
Definition: SharedDefines.h:5063
Definition: SpellInfo.h:372
Definition: SharedDefines.h:1390
Definition: SharedDefines.h:1135
ObjectGuid GetCastItemGUID() const
Definition: SpellAuras.h:140
uint8 getLevel() const
Definition: Unit.h:843
SpellCastResult CheckCasterAuras(uint32 *param1) const
Definition: Spell.cpp:6144
Definition: SharedDefines.h:1498
Definition: SharedDefines.h:1121
Definition: SharedDefines.h:1500
bool HasEffect(SpellEffectName effect) const
Definition: SpellInfo.cpp:1282
SpellCastTargets m_targets
Definition: Spell.h:675
bool isLooted() const
Definition: Loot.h:240
Definition: SharedDefines.h:1166
Pet * ToPet()
Definition: Unit.h:1789
WorldSession * GetSession() const
Definition: Player.h:1990
bool HasSummonPending() const
Definition: Player.cpp:25114
Definition: SpellAuraDefines.h:166
bool InBattleground() const
Definition: Player.h:2263
union Spell::@325 m_misc
bool HasAura(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, ObjectGuid itemCasterGUID=ObjectGuid::Empty, uint32 reqEffMask=0) const
Definition: Unit.cpp:4418
Definition: SharedDefines.h:1767
AuraStateType
Definition: SharedDefines.h:2300
flag128 SpellFamilyFlags
Definition: SpellInfo.h:455
uint32 ExcludeCasterAuraSpell
Definition: SpellInfo.h:411
Definition: SharedDefines.h:1230
SpellCastResult CheckPower() const
Definition: Spell.cpp:6548
bool IsInCombat() const
Definition: Unit.h:1108
Definition: SharedDefines.h:1384
SpellInfo const * m_triggeredByAuraSpell
Definition: Spell.h:954
ObjectGuid GetItemTargetGUID() const
Definition: Spell.h:252
bool HasCooldown(SpellInfo const *spellInfo, uint32 itemId=0, bool ignoreCategoryCooldown=false) const
Definition: SpellHistory.cpp:631
Definition: SharedDefines.h:400
WorldObject *const m_caster
Definition: Spell.h:741
bool HasAuraInterruptFlag(SpellAuraInterruptFlags flag) const
Definition: SpellInfo.h:506
bool IsInDisallowedMountForm() const
Definition: Unit.cpp:8467
GameObject * GetGOTarget() const
Definition: Spell.cpp:246
Definition: SpellAuraDefines.h:90
int32 Control
Definition: DB2Structure.h:3412
Loot loot
Definition: Creature.h:206
uint32 RequiresSpellFocus
Definition: SpellInfo.h:403
std::list< AuraEffect * > AuraEffectList
Definition: Unit.h:754
Definition: SpellAuraDefines.h:363
Definition: DB2Structure.h:2343
Definition: ObjectGuid.h:39
Definition: DisableMgr.h:48
Definition: SharedDefines.h:1218
Definition: SharedDefines.h:1120
bool NeedsExplicitUnitTarget() const
Definition: SpellInfo.cpp:1450
CreatureTemplate const * GetCreatureTemplate() const
Definition: Creature.h:187
Definition: SharedDefines.h:1588
Definition: SharedDefines.h:1594
uint32 m_castItemEntry
Definition: Spell.h:635
bool IsBattlegroundOrArena() const
Definition: Map.cpp:4282
bool IsLocked() const
Definition: Item.h:244
Definition: SharedDefines.h:1506
bool IsDungeon() const
Definition: Map.cpp:4240
bool HasSpell(uint32 spell) const override
Definition: Player.cpp:3698
bool IsCreature() const
Definition: ObjectGuid.h:300
bool HasAuraTypeWithMiscvalue(AuraType auratype, int32 miscvalue) const
Definition: Unit.cpp:4442
ObjectGuid GetCharmGUID() const
Definition: Unit.h:1231
DynamicObject * GetDynObject(uint32 spellId) const
Definition: Unit.cpp:4911
bool IsPassive() const
Definition: SpellInfo.cpp:1491
Definition: Object.h:410
Definition: Creature.h:61
bool IsPotion() const
Definition: Item.h:323
SpellCastResult CheckShapeshift(uint32 form) const
Definition: SpellInfo.cpp:1850
Definition: SharedDefines.h:1540
Battleground * GetBattleground() const
Definition: Player.cpp:24820
bool IsInSameRaidWith(Player const *p) const
Definition: Player.cpp:2184
Definition: SharedDefines.h:390
#define M_PI
Definition: Common.h:134
Item * m_CastItem
Definition: Spell.h:633
Definition: SharedDefines.h:5702
Definition: SpellAuraDefines.h:152
Definition: SharedDefines.h:1470
bool HasUnitFlag2(UnitFlags2 flags) const
Definition: Unit.h:929
Definition: Unit.h:246
Definition: SharedDefines.h:1493
Definition: SharedDefines.h:1128
#define sObjectMgr
Definition: ObjectMgr.h:1847
uint32 ErrorTextId
Definition: ConditionMgr.h:223
std::unique_ptr< PathGenerator > m_preGeneratedPath
Definition: Spell.h:956
Definition: SharedDefines.h:1530
bool CanUseBattlegroundObject(GameObject *gameobject) const
Definition: Player.cpp:26005
CharmInfo * GetCharmInfo()
Definition: Unit.h:1271
Definition: SpellAuraDefines.h:215
bool HasUnitFlag(UnitFlags flags) const
Definition: Unit.h:925
uint32 GetId() const
Definition: Map.cpp:4230
uint32 GetZoneId() const
Definition: Object.h:459
Definition: SharedDefines.h:1496
uint8 GetArtifactID() const
Definition: ItemTemplate.h:786
Definition: PetDefines.h:26
Definition: SharedDefines.h:1463
bool IsIgnoringCooldowns() const
Definition: Spell.cpp:7397
Definition: DBCEnums.h:139
Player * ToPlayer()
Definition: Object.h:192
Definition: SharedDefines.h:1489
Definition: SharedDefines.h:1109
Definition: SharedDefines.h:1601
int8 ClassID
Definition: DB2Structure.h:802
Definition: SharedDefines.h:1522
bool IsPetSpecialization() const
Definition: DB2Structure.h:812
bool HasStealthAura() const
Definition: Unit.h:1130
Definition: SpellInfo.h:59
Definition: SharedDefines.h:631
float GetPositionY() const
Definition: Position.h:102
Map * GetMap() const
Definition: Object.h:535
uint8 ArtifactCategoryID
Definition: DB2Structure.h:211
Definition: SharedDefines.h:1334
#define ARTIFACTS_ALL_WEAPONS_GENERAL_WEAPON_EQUIPPED_PASSIVE
Definition: Unit.h:36
bool HasGlobalCooldown() const
Definition: Spell.cpp:8084
Definition: DynamicObject.h:35
ShapeshiftForm GetShapeshiftForm() const
Definition: Unit.h:1501
Definition: SharedDefines.h:495
void SendMountResult(MountResult result)
Definition: Spell.cpp:4215
ObjectGuid GetTarget() const
Definition: Unit.h:1798
uint32 const Id
Definition: SpellInfo.h:377
TC_GAME_API Player * FindPlayer(ObjectGuid const &)
Definition: ObjectAccessor.cpp:254
Definition: SharedDefines.h:1454
ObjectGuid const & GetGUID() const
Definition: Object.h:154
Definition: SpellAuraDefines.h:352
Definition: SharedDefines.h:1488
Definition: SharedDefines.h:1193
bool Satisfy(AccessRequirement const *ar, uint32 target_map, bool report=false)
Definition: Player.cpp:20036
bool HasAuraTypeWithAffectMask(AuraType auratype, SpellInfo const *affectedSpell) const
Definition: Unit.cpp:4451
uint32 ErrorType
Definition: ConditionMgr.h:222
Definition: SharedDefines.h:1505
SpellHistory * GetSpellHistory()
Definition: Unit.h:1495
Definition: DB2Structure.h:796
bool isLineOfSightCalcEnabled() const
Definition: IVMapManager.h:116
Definition: UnitDefines.h:175
Definition: SharedDefines.h:1148
Definition: SpellAuraDefines.h:369
Definition: SharedDefines.h:1409
Definition: SharedDefines.h:1396
bool IsDungeon() const
Definition: DB2Structure.h:2373
Player * GetOwner() const
Definition: Pet.cpp:1745
Unit * m_originalCaster
Definition: Spell.h:747
Definition: SharedDefines.h:1602
bool HasAttribute(SpellAttr0 attribute) const
Definition: SpellInfo.h:486
AuraEffectList const & GetAuraEffectsByType(AuraType type) const
Definition: Unit.h:1365
uint32 ExcludeCasterAuraState
Definition: SpellInfo.h:407
DB2Storage< TalentEntry > sTalentStore("Talent.db2", TalentLoadInfo::Instance())
SpellCastResult CheckVehicle(Unit const *caster) const
Definition: SpellInfo.cpp:2260
Definition: SharedDefines.h:391
Unit * unitCaster
Definition: Spell.h:794
int32 RequiredAreasID
Definition: SpellInfo.h:458
Unit * GetOwner() const
Definition: Object.cpp:2030
Definition: SharedDefines.h:1668
uint32 GetPrimarySpecialization() const
Definition: Player.h:1752
Definition: SharedDefines.h:1245
bool IsRaid() const
Definition: DB2Structure.h:2376
Definition: TradeData.h:34
bool IsAlive() const
Definition: Unit.h:1217
Definition: SharedDefines.h:1542
SpellCastResult CheckItems(uint32 *param1, uint32 *param2) const
Definition: Spell.cpp:6590
Guild * GetGuild()
Definition: Player.cpp:28269
Definition: SharedDefines.h:1170
Unit * GetUnitTarget() const
Definition: Spell.cpp:220
bool HasUnitState(const uint32 f) const
Definition: Unit.h:830
void GetZoneAndAreaId(uint32 &zoneid, uint32 &areaid) const
Definition: Object.h:461
Definition: SharedDefines.h:1265
SpellInfo const * GetSpellInfo() const
Definition: Spell.h:711
bool IsGameMaster() const
Definition: Player.h:1128
Definition: SpellAuraDefines.h:295
Definition: SharedDefines.h:412
uint8 getClass() const
Definition: Unit.h:849
Definition: TradeData.h:27
uint32 GetSpell() const
Definition: TradeData.h:49
Definition: Item.h:169
bool IsVehicle() const
Definition: Unit.h:841
Definition: SharedDefines.h:1457
Definition: SpellAuraDefines.h:289
Definition: ObjectGuid.h:42
#define sSpellMgr
Definition: SpellMgr.h:790
Definition: SpellInfo.h:264
int32_t int32
Definition: Define.h:148
uint8 ConditionTarget
Definition: ConditionMgr.h:226
Will not adjust facing to target (if any)
Definition: SpellDefines.h:237
InstancePlayerBind * GetBoundInstance(uint32 mapid, Difficulty difficulty, bool withExpired=false)
Definition: Player.cpp:19826
uint32_t uint32
Definition: Define.h:152
Definition: SpellAuraDefines.h:410
Definition: SharedDefines.h:1150
Definition: SharedDefines.h:1462
bool HaveInDiet(ItemTemplate const *item) const
Definition: Pet.cpp:1021
bool HasDst() const
Definition: Spell.cpp:427
Definition: Battlefield.h:210
Definition: SpellAuraDefines.h:351
uint32 GetTargetMask() const
Definition: Spell.h:229
Definition: SharedDefines.h:1133
Definition: SharedDefines.h:817
SpellCastResult CheckTarget(WorldObject const *caster, WorldObject const *target, bool implicit=true) const
Definition: SpellInfo.cpp:2070
Definition: ConditionMgr.h:198
Pet * GetPet() const
Definition: Player.cpp:21781
Definition: SharedDefines.h:5701
Definition: GameObject.h:81
Definition: DisableMgr.h:27
#define sConditionMgr
Definition: ConditionMgr.h:326
Will ignore shapeshift checks.
Definition: SpellDefines.h:238
Player * GetSelectedPlayer() const
Definition: Player.cpp:24081
float GetPositionZ() const
Definition: Position.h:103
SkillType GetRequiredLootSkill() const
Definition: CreatureData.h:450
Definition: SpellAuraDefines.h:350
GameObjectTemplate const * GetGOInfo() const
Definition: GameObject.h:107
DB2Storage< AreaTableEntry > sAreaTableStore("AreaTable.db2", AreaTableLoadInfo::Instance())
bool IsTriggered() const
Definition: Spell.cpp:7392
uint32 GetLockID() const
Definition: ItemTemplate.h:772
Definition: SharedDefines.h:1597
PetType getPetType() const
Definition: Pet.h:56
Definition: SharedDefines.h:2603
Definition: SharedDefines.h:399
Definition: SharedDefines.h:1466
Definition: DB2Structure.h:1710
std::vector< SpellEffectInfo > const & GetEffects() const
Definition: SpellInfo.h:616
Definition: SharedDefines.h:6363
Definition: SharedDefines.h:1125
Definition: SharedDefines.h:401
Definition: PathGenerator.h:46
Definition: SpellAuraDefines.h:466
Definition: SharedDefines.h:1539
Definition: SharedDefines.h:1600
bool IsUnit() const
Definition: Object.h:199
bool AllowMount
Definition: ObjectMgr.h:157
bool IsInFlight() const
Definition: Unit.h:1083
uint32 CasterAuraState
Definition: SpellInfo.h:405
uint32 GetRecruiterId() const
Definition: WorldSession.h:1132
#define sBattlefieldMgr
Definition: BattlefieldMgr.h:67
Definition: SharedDefines.h:1608
DB2Storage< GlyphPropertiesEntry > sGlyphPropertiesStore("GlyphProperties.db2", GlyphPropertiesLoadInfo::Instance())
bool IsFriendlyTo(WorldObject const *target) const
Definition: Object.cpp:2600
Definition: SharedDefines.h:1415
Definition: PathGenerator.h:49
Definition: SharedDefines.h:1244
Definition: SpellAuraDefines.h:265
float GetPositionX() const
Definition: Position.h:101
Item * GetItemByGuid(ObjectGuid guid) const
Definition: Player.cpp:10087
bool IsEmpty() const
Definition: ObjectGuid.h:299
int32 CalculateDamage(SpellEffectInfo const &spellEffectInfo, Unit const *target, float *var=nullptr) const
Definition: Spell.cpp:6373
Will ignore Spell and Category cooldowns.
Definition: SpellDefines.h:229
Definition: SharedDefines.h:1591
SpellCastResult CheckLocation(uint32 map_id, uint32 zone_id, uint32 area_id, Player const *player=nullptr) const
Definition: SpellInfo.cpp:1899
Definition: SharedDefines.h:1095
ObjectGuid GetPetGUID() const
Definition: Unit.h:1233
Definition: ObjectGuid.h:40
uint32 GetMapId() const
Definition: Position.h:252
Definition: SharedDefines.h:1467
Definition: SharedDefines.h:1254
WorldLocation const * GetDstPos() const
Definition: Spell.cpp:370
static ObjectGuid const TradeItem
Definition: ObjectGuid.h:256
Creature * ToCreature()
Definition: Object.h:196
Definition: SharedDefines.h:1389
Guardian * GetGuardianPet() const
Definition: Unit.cpp:5764
bool IsCooldownStartedOnEvent() const
Definition: SpellInfo.cpp:1548
Definition: Battleground.h:166
uint8 GetLevelForTarget(WorldObject const *) const override
Definition: Unit.h:844
DB2Storage< SummonPropertiesEntry > sSummonPropertiesStore("SummonProperties.db2", SummonPropertiesLoadInfo::Instance())
Definition: SharedDefines.h:1410
Definition: SharedDefines.h:1123
uint32 GetBaseItemLevel() const
Definition: ItemTemplate.h:751
Definition: SharedDefines.h:1536
uint32 CasterAuraSpell
Definition: SpellInfo.h:409
Definition: SharedDefines.h:1134
static IVMapManager * createOrGetVMapManager()
Definition: VMapFactory.cpp:27
Definition: SharedDefines.h:1332
Definition: SharedDefines.h:1469
TradeData * GetTradeData() const
Definition: Player.h:1417
bool IsDisabledFor(DisableType type, uint32 entry, WorldObject const *ref, uint8 flags)
Definition: DisableMgr.cpp:275
uint8 GetActiveTalentGroup() const
Definition: Player.h:1754
Definition: SharedDefines.h:1526
Definition: Battleground.h:259
void CastSpell(SpellCastTargets const &targets, uint32 spellId, CastSpellExtraArgs const &args={ })
Definition: Object.cpp:2631
Definition: Player.h:886
SpellCastResult
Definition: SharedDefines.h:1381
uint32 GetAreaId() const
Definition: Object.h:460
bool IsCritter() const
Definition: Unit.h:1081
SkillType
Definition: SharedDefines.h:5061
bool IsAutoRepeat() const
Definition: Spell.h:682
Definition: SharedDefines.h:1273
Definition: SharedDefines.h:1477
Not triggered.
Definition: SpellDefines.h:227
Definition: ConditionMgr.h:160
Definition: SharedDefines.h:1598
SpellCustomErrors m_customError
Definition: Spell.h:677
Definition: SharedDefines.h:1483
Aura * GetAura(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, ObjectGuid itemCasterGUID=ObjectGuid::Empty, uint32 reqEffMask=0) const
Definition: Unit.cpp:4314
Definition: SharedDefines.h:1453
bool IsReady(SpellInfo const *spellInfo, uint32 itemId=0, bool ignoreCategoryCooldown=false) const
Definition: SpellHistory.cpp:272
uint32 GetAccountId() const
Definition: WorldSession.h:977
Definition: SharedDefines.h:265
Definition: SharedDefines.h:1176
Definition: SpellAuras.h:118
Disallows proc events from triggered spell (default)
Definition: SpellDefines.h:240
void GetPosition(float &x, float &y) const
Definition: Position.h:106
Will ignore mounted/on vehicle restrictions.
Definition: SpellDefines.h:243
Definition: SharedDefines.h:1149
DB2Storage< MapEntry > sMapStore("Map.db2", MapLoadInfo::Instance())
TriggerCastFlags _triggeredCastFlags
Definition: Spell.h:949
uint8 GlyphExclusiveCategoryID
Definition: DB2Structure.h:1715
Definition: SharedDefines.h:1473
Definition: SpellAuraDefines.h:94
Definition: SharedDefines.h:1667
Definition: SharedDefines.h:1455
Definition: Guild.h:305
AttackerSet const & getAttackers() const
Definition: Unit.h:811
Definition: UnitDefines.h:145
Definition: DB2Structure.h:3427
Definition: SharedDefines.h:1424
Definition: Unit.h:736
Definition: SharedDefines.h:1201
SpellCastResult CheckExplicitTarget(WorldObject const *caster, WorldObject const *target, Item const *itemTarget=nullptr) const
Definition: SpellInfo.cpp:2224
Definition: SharedDefines.h:582
Definition: SharedDefines.h:377
bool IsNextMeleeSwingSpell() const
Definition: SpellInfo.cpp:1632
Definition: Player.h:1056
WorldObject * GetObjectTarget() const
Definition: Spell.cpp:280
Definition: SharedDefines.h:2622
bool isMoving() const
Definition: Unit.h:1769
Definition: SharedDefines.h:1697
bool IsWithinLOSInMap(WorldObject const *obj, LineOfSightChecks checks=LINEOFSIGHT_ALL_CHECKS, VMAP::ModelIgnoreFlags ignoreFlags=VMAP::ModelIgnoreFlags::Nothing) const
Definition: Object.cpp:1128
Definition: SharedDefines.h:1213
Definition: SharedDefines.h:1408
uint32 type
Definition: GameObjectData.h:33
Definition: SharedDefines.h:1395
Definition: SpellInfo.h:205
bool m_needComboPoints
Definition: Spell.h:779
Definition: SharedDefines.h:1448
Definition: SharedDefines.h:1398
Unit * ToUnit()
Definition: Object.h:200
SpellCastResult CanOpenLock(SpellEffectInfo const &effect, uint32 lockid, SkillType &skillid, int32 &reqSkillValue, int32 &skillValue)
Definition: Spell.cpp:7669
Definition: SharedDefines.h:1177
uint16 GetSkillValue(uint32 skill) const
Definition: Player.cpp:5854
Definition: SharedDefines.h:393
Definition: SpellAuraDefines.h:418
Condition const * mLastFailedCondition
Definition: ConditionMgr.h:201
Definition: Pet.h:45
bool IsWithinLOS(float x, float y, float z, LineOfSightChecks checks=LINEOFSIGHT_ALL_CHECKS, VMAP::ModelIgnoreFlags ignoreFlags=VMAP::ModelIgnoreFlags::Nothing) const
Definition: Object.cpp:1108
bool CanBeUsedInCombat() const
Definition: SpellInfo.cpp:1602
float GetMaxRange(bool positive=false, WorldObject *caster=nullptr, Spell *spell=nullptr) const
Definition: SpellInfo.cpp:3668
Definition: SpellInfo.h:204
Definition: SharedDefines.h:421
uint32 SpellID
Definition: DB2Structure.h:3436
Definition: DB2Structure.h:3409
Powers GetPowerType() const
Definition: Unit.h:893
Definition: SharedDefines.h:1547
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ CheckCasterAuras()

SpellCastResult Spell::CheckCasterAuras ( uint32 param1) const
6145 {
6147  if