TrinityCore
Loading...
Searching...
No Matches
Spell Class Reference

#include <Spell.h>

Classes

struct  CorpseTargetInfo
 
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 EffectTeleportUnitsWithVisualLoadingScreen ()
 
void EffectApplyAura ()
 
void EffectSendEvent ()
 
void EffectPowerBurn ()
 
void EffectPowerDrain ()
 
void EffectHeal ()
 
void EffectBind ()
 
void EffectTeleportToReturnPoint ()
 
void EffectIncreaseCurrencyCap ()
 
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 EffectPullTowardsDest ()
 
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 EffectRemoveAuraBySpellLabel ()
 
void EffectCreateGarrison ()
 
void EffectCreateConversation ()
 
void EffectCancelConversation ()
 
void EffectAddGarrisonFollower ()
 
void EffectActivateGarrisonBuilding ()
 
void EffectGrantBattlePetLevel ()
 
void EffectGiveExperience ()
 
void EffectGiveRestedExperience ()
 
void EffectHealBattlePetPct ()
 
void EffectEnableBattlePets ()
 
void EffectChangeBattlePetQuality ()
 
void EffectLaunchQuestChoice ()
 
void EffectUncageBattlePet ()
 
void EffectCreateHeirloomItem ()
 
void EffectUpgradeHeirloom ()
 
void EffectApplyEnchantIllusion ()
 
void EffectUpdatePlayerPhase ()
 
void EffectUpdateZoneAurasAndPhases ()
 
void EffectGiveArtifactPower ()
 
void EffectGiveArtifactPowerNoBonus ()
 
void EffectPlaySceneScriptPackage ()
 
void EffectCreateSceneObject ()
 
void EffectCreatePrivateSceneObject ()
 
void EffectPlayScene ()
 
void EffectGiveHonor ()
 
void EffectJumpCharge ()
 
void EffectLearnTransmogSet ()
 
void EffectRespecAzeriteEmpoweredItem ()
 
void EffectLearnAzeriteEssencePower ()
 
void EffectCreatePrivateConversation ()
 
void EffectSendChatMessage ()
 
void EffectGrantBattlePetExperience ()
 
void EffectLearnTransmogIllusion ()
 
void EffectModifyAuraStacks ()
 
void EffectModifyCooldown ()
 
void EffectModifyCooldowns ()
 
void EffectModifyCooldownsByCategory ()
 
void EffectModifySpellCharges ()
 
void EffectCreateTraitTreeConfig ()
 
void EffectChangeActiveCombatTraitConfig ()
 
void EffectTeleportGraveyard ()
 
 Spell (WorldObject *caster, SpellInfo const *info, TriggerCastFlags triggerFlags, ObjectGuid originalCasterGUID=ObjectGuid::Empty, ObjectGuid originalCastId=ObjectGuid::Empty)
 
 ~Spell ()
 
void InitExplicitTargets (SpellCastTargets const &targets)
 
void SelectExplicitTargets ()
 
void SelectSpellTargets ()
 
void SelectEffectImplicitTargets (SpellEffectInfo const &spellEffectInfo, SpellImplicitTargetInfo const &targetType, SpellTargetIndex targetIndex, uint32 &processedEffectMask)
 
void SelectImplicitChannelTargets (SpellEffectInfo const &spellEffectInfo, SpellImplicitTargetInfo const &targetType)
 
void SelectImplicitNearbyTargets (SpellEffectInfo const &spellEffectInfo, SpellImplicitTargetInfo const &targetType, SpellTargetIndex targetIndex, uint32 effMask)
 
void SelectImplicitConeTargets (SpellEffectInfo const &spellEffectInfo, SpellImplicitTargetInfo const &targetType, SpellTargetIndex targetIndex, uint32 effMask)
 
void SelectImplicitAreaTargets (SpellEffectInfo const &spellEffectInfo, SpellImplicitTargetInfo const &targetType, SpellTargetIndex targetIndex, uint32 effMask)
 
void SelectImplicitCasterDestTargets (SpellEffectInfo const &spellEffectInfo, SpellImplicitTargetInfo const &targetType, SpellTargetIndex targetIndex)
 
void SelectImplicitTargetDestTargets (SpellEffectInfo const &spellEffectInfo, SpellImplicitTargetInfo const &targetType, SpellTargetIndex targetIndex)
 
void SelectImplicitDestDestTargets (SpellEffectInfo const &spellEffectInfo, SpellImplicitTargetInfo const &targetType, SpellTargetIndex targetIndex)
 
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, SpellTargetIndex targetIndex, uint32 effMask)
 
void SelectEffectTypeImplicitTargets (SpellEffectInfo const &spellEffectInfo)
 
WorldObjectSearchNearbyTarget (SpellEffectInfo const &spellEffectInfo, float range, SpellTargetObjectTypes objectType, SpellTargetCheckTypes selectionType, ConditionContainer const *condList=nullptr)
 
void SearchAreaTargets (std::list< WorldObject * > &targets, SpellEffectInfo const &spellEffectInfo, float range, Position const *position, WorldObject *referer, SpellTargetObjectTypes objectType, SpellTargetCheckTypes selectionType, ConditionContainer const *condList)
 
void SearchChainTargets (std::list< WorldObject * > &targets, uint32 chainTargets, WorldObject *target, SpellTargetObjectTypes objectType, SpellTargetCheckTypes selectType, SpellEffectInfo const &spellEffectInfo, bool isChainHeal)
 
GameObjectSearchSpellFocus ()
 
SpellCastResult prepare (SpellCastTargets const &targets, AuraEffect const *triggeredByAura=nullptr)
 
void cancel ()
 
void update (uint32 difftime)
 
void cast (bool skipCheck=false)
 
void finish (SpellCastResult result=SPELL_CAST_OK)
 
void TakePower ()
 
void TakeRunePower (bool didHit)
 
void TakeReagents ()
 
void TakeCastItem ()
 
SpellCastResult CheckCast (bool strict, int32 *param1=nullptr, int32 *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 (int32 *param1, int32 *param2) const
 
SpellCastResult CheckRange (bool strict) const
 
SpellCastResult CheckPower () const
 
SpellCastResult CheckRuneCost () const
 
SpellCastResult CheckCasterAuras (int32 *param1) const
 
SpellCastResult CheckArenaAndRatedBattlegroundCastRules ()
 
SpellCastResult CheckMovement () const
 
bool CheckSpellCancelsAuraEffect (AuraType auraType, int32 *param1) const
 
bool CheckSpellCancelsCharm (int32 *param1) const
 
bool CheckSpellCancelsStun (int32 *param1) const
 
bool CheckSpellCancelsSilence (int32 *param1) const
 
bool CheckSpellCancelsPacify (int32 *param1) const
 
bool CheckSpellCancelsFear (int32 *param1) const
 
bool CheckSpellCancelsConfuse (int32 *param1) const
 
bool CheckSpellCancelsNoActions (int32 *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=nullptr)
 
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, int32 *param1=nullptr, int32 *param2=nullptr) const
 
void SendPetCastResult (SpellCastResult result, int32 *param1=nullptr, int32 *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, Corpse *pCorpseTarget, 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
 
int32 GetProcChainLength () 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 ()
 
void UpdateDelayMomentForDst (uint64 hitDelay)
 
void UpdateDelayMomentForUnitTarget (Unit *unit, uint64 hitDelay)
 
uint8 GetRuneState () const
 
void SetRuneState (uint8 value)
 
bool IsNeedSendToClient () const
 
CurrentSpellTypes GetCurrentContainer () const
 
WorldObjectGetCaster () const
 
ObjectGuid GetOriginalCasterGUID () const
 
UnitGetOriginalCaster () const
 
SpellInfo const * GetSpellInfo () const
 
Difficulty GetCastDifficulty () const
 
std::vector< SpellPowerCost > const & GetPowerCost () const
 
bool HasPowerTypeCost (Powers power) const
 
Optional< int32GetPowerTypeCostAmount (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
 
int64 GetCorpseTargetCountForEffect (SpellEffIndex effect) const
 
std::string GetDebugInfo () const
 
void CallScriptOnResistAbsorbCalculateHandlers (DamageInfo const &damageInfo, uint32 &resistAmount, int32 &absorbAmount)
 
bool IsWithinLOS (WorldObject const *source, WorldObject const *target, bool targetAsSourceLocation, VMAP::ModelIgnoreFlags ignoreFlags) const
 
bool IsWithinLOS (WorldObject const *source, Position const &target, VMAP::ModelIgnoreFlags ignoreFlags) const
 
void CallScriptCalcCritChanceHandlers (Unit const *victim, float &chance)
 
void CallScriptCalcDamageHandlers (Unit *victim, int32 &damage, int32 &flatMod, float &pctMod)
 
void CallScriptCalcHealingHandlers (Unit *victim, int32 &healing, int32 &flatMod, float &pctMod)
 

Static Public Member Functions

static uint32 GetSearcherTypeMask (SpellInfo const *spellInfo, SpellEffectInfo const &spellEffectInfo, SpellTargetObjectTypes objType, ConditionContainer const *condList)
 
template<class SEARCHER >
static void SearchTargets (SEARCHER &searcher, uint32 containerMask, WorldObject *referer, Position const *pos, float radius)
 
static void SendCastResult (Player *caster, SpellInfo const *spellInfo, SpellCastVisual spellVisual, ObjectGuid cast_count, SpellCastResult result, SpellCustomErrors customError=SPELL_CUSTOM_ERROR_NONE, int32 *param1=nullptr, int32 *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
 
std::any m_customArg
 
SpellCastVisual m_SpellVisual
 
SpellCastTargets m_targets
 
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)
 
std::pair< float, float > GetMinMaxRange (bool strict) const
 
bool IsDelayableNoMore ()
 
UnitGetUnitCasterForEffectHandlers () const
 
void prepareDataForTriggerSystem ()
 
template<class Container >
void DoProcessTargetContainer (Container &targetContainer)
 
int32 GetUnitTargetIndexForEffect (ObjectGuid const &target, SpellEffIndex effect) const
 
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 AddCorpseTarget (Corpse *target, uint32 effectMask)
 
void AddDestTarget (SpellDestination const &dest, uint32 effIndex)
 
void PreprocessSpellLaunch (TargetInfo &targetInfo)
 
SpellMissInfo PreprocessSpellHit (Unit *unit, TargetInfo &targetInfo)
 
void DoSpellEffectHit (Unit *unit, SpellEffectInfo const &spellEffectInfo, TargetInfo &targetInfo)
 
void DoTriggersOnSpellHit (Unit *unit)
 
bool UpdateChanneledTargetList ()
 
bool IsValidDeadOrAliveTarget (Unit const *target) const
 
void HandleLaunchPhase ()
 
void DoEffectOnLaunchTarget (TargetInfo &targetInfo, float multiplier, SpellEffectInfo const &spellEffectInfo)
 
void ResetCombatTimers ()
 
void PrepareTargetProcessing ()
 
void FinishTargetProcessing ()
 
void LoadScripts ()
 
void CallScriptOnPrecastHandler ()
 
void CallScriptBeforeCastHandlers ()
 
void CallScriptOnCastHandlers ()
 
void CallScriptAfterCastHandlers ()
 
SpellCastResult CallScriptCheckCastHandlers ()
 
int32 CallScriptCalcCastTimeHandlers (int32 originalCastTime)
 
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 (Unit *unit, SpellInfo const *triggeredByAura=nullptr) const
 
void PrepareTriggersExecutedOnHit ()
 
void SummonGuardian (SpellEffectInfo const *effect, uint32 entry, SummonPropertiesEntry const *properties, uint32 numSummons, ObjectGuid privateObjectOwner)
 
void CalculateJumpSpeeds (SpellEffectInfo const *effInfo, float dist, float &speedXY, float &speedZ)
 
void UpdateSpellCastDataTargets (WorldPackets::Spells::SpellCastData &data)
 Writes miss and hit targets for a SMSG_SPELL_GO packet.
 
int32 GetSpellCastDataAmmo ()
 
void UpdateSpellHealPrediction (WorldPackets::Spells::SpellHealPrediction &healPrediction, bool withPeriodic)
 
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
 
uint32 m_applyMultiplierMask
 
float m_damageMultipliers [MAX_SPELL_EFFECTS]
 
UnitunitTarget
 
ItemitemTarget
 
GameObjectgameObjTarget
 
Corpsem_corpseTarget
 
WorldLocationdestTarget
 
int32 damage
 
SpellMissInfo targetMissInfo
 
float variance
 
SpellEffectHandleMode effectHandleMode
 
SpellEffectInfo const * effectInfo
 
UnitAura_spellAura
 
DynObjAura_dynObjAura
 
GameObjectfocusObject
 
int32 m_damage
 
int32 m_healing
 
ProcFlagsInit m_procAttacker
 
ProcFlagsInit m_procVictim
 
ProcFlagsHit m_hitMask
 
ProcFlagsSpellType m_procSpellType
 
std::vector< TargetInfom_UniqueTargetInfo
 
uint32 m_channelTargetEffectMask
 
std::vector< GOTargetInfom_UniqueGOTargetInfo
 
std::vector< ItemTargetInfom_UniqueItemInfo
 
std::vector< CorpseTargetInfom_UniqueCorpseTargetInfo
 
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
 
int32 m_procChainLength
 
std::unique_ptr< PathGeneratorm_preGeneratedPath
 
std::vector< SpellLogEffect_executeLogEffects
 

Friends

class SpellScript
 

Detailed Description

Definition at line 248 of file Spell.h.

Member Typedef Documentation

◆ HitTriggerSpellList

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

Definition at line 888 of file Spell.h.

◆ UsedSpellMods

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

Definition at line 429 of file Spell.h.

Constructor & Destructor Documentation

◆ Spell() [1/2]

Spell::Spell ( WorldObject caster,
SpellInfo const *  info,
TriggerCastFlags  triggerFlags,
ObjectGuid  originalCasterGUID = ObjectGuid::Empty,
ObjectGuid  originalCastId = ObjectGuid::Empty 
)

Definition at line 500 of file Spell.cpp.

501 :
502m_spellInfo(info), m_caster((info->HasAttribute(SPELL_ATTR6_ORIGINATE_FROM_CONTROLLER) && caster->GetCharmerOrOwner()) ? caster->GetCharmerOrOwner() : caster),
503m_spellValue(new SpellValue(m_spellInfo, caster)), _spellEvent(nullptr)
504{
506 m_fromClient = false;
507 m_selfContainer = nullptr;
509 m_executedCurrently = false;
510 m_delayStart = 0;
512
514 memset(m_damageMultipliers, 0, sizeof(m_damageMultipliers));
515
516 // Get data for type of attack
517 m_attackType = info->GetAttackType();
518
519 m_spellSchoolMask = info->GetSchoolMask(); // Can be override for some spell (wand shoot for example)
520
521 if (Player const* playerCaster = m_caster->ToPlayer())
522 {
523 // wand case
525 if ((playerCaster->GetClassMask() & CLASSMASK_WAND_USERS) != 0)
526 if (Item* pItem = playerCaster->GetWeaponForAttack(RANGED_ATTACK))
527 m_spellSchoolMask = SpellSchoolMask(1 << pItem->GetTemplate()->GetDamageType());
528 }
529
530 if (Player const* modOwner = caster->GetSpellModOwner())
531 modOwner->ApplySpellMod(info, SpellModOp::Doses, m_spellValue->AuraStackAmount, this);
532
533 if (!originalCasterGUID.IsEmpty())
534 m_originalCasterGUID = originalCasterGUID;
535 else
537
540 else
541 {
544 m_originalCaster = nullptr;
545 }
546
548 _triggeredCastFlags = triggerFlags;
549
550 if (info->HasAttribute(SPELL_ATTR2_DO_NOT_REPORT_SPELL_FAILURE))
552
553 if (info->HasAttribute(SPELL_ATTR4_ALLOW_CAST_WHILE_CASTING))
555
556 m_CastItem = nullptr;
558 m_castItemEntry = 0;
559 m_castItemLevel = -1;
560 m_castFlagsEx = 0;
561
564
565 unitTarget = nullptr;
566 itemTarget = nullptr;
567 gameObjTarget = nullptr;
568 m_corpseTarget = nullptr;
569 destTarget = nullptr;
570 damage = 0;
572 variance = 0.0f;
574 effectInfo = nullptr;
575 m_damage = 0;
576 m_healing = 0;
579 focusObject = nullptr;
580 m_castId = ObjectGuid::Create<HighGuid::Cast>(SPELL_CAST_SOURCE_NORMAL, m_caster->GetMapId(), m_spellInfo->Id, m_caster->GetMap()->GenerateLowGuid<HighGuid::Cast>());
581 m_originalCastId = originalCastId;
582 memset(m_misc.Raw.Data, 0, sizeof(m_misc.Raw.Data));
584 m_triggeredByAuraSpell = nullptr;
585 m_procChainLength = caster->IsUnit() ? caster->ToUnit()->GetProcChainLength() : 0;
586 _spellAura = nullptr;
587 _dynObjAura = nullptr;
588
589 //Auto Shot & Shoot (wand)
591
592 m_runesState = 0;
593 m_casttime = 0; // setup to correct value in Spell::prepare, must not be used before.
594 m_timer = 0; // will set to castime in prepare
595 m_channeledDuration = 0; // will be setup in Spell::handle_immediate
596 m_launchHandled = false;
597 m_immediateHandled = false;
598
600
601 // Determine if spell can be reflected back to the caster
602 // Patch 1.2 notes: Spell Reflection no longer reflects abilities
603 m_canReflect = caster->IsUnit()
606 && !m_spellInfo->IsPassive();
607
609
610 for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
612}
#define MAX_SPELL_EFFECTS
Definition: DBCEnums.h:1951
uint8_t uint8
Definition: Define.h:145
@ SPELL_ATTR7_ALLOW_SPELL_REFLECTION
#define CLASSMASK_WAND_USERS
@ SPELL_MISS_NONE
SpellSchoolMask
@ SPELL_ATTR2_DO_NOT_REPORT_SPELL_FAILURE
@ SPELL_ATTR1_NO_REFLECTION
@ SPELL_DAMAGE_CLASS_MAGIC
@ RANGED_ATTACK
@ SPELL_CUSTOM_ERROR_NONE
@ SPELL_ATTR0_IS_ABILITY
@ SPELL_ATTR0_NO_IMMUNITIES
@ SPELL_ATTR4_ALLOW_CAST_WHILE_CASTING
@ SPELL_ATTR6_ORIGINATE_FROM_CONTROLLER
@ TRIGGERED_IGNORE_CAST_IN_PROGRESS
Will not check if a current cast is in progress.
Definition: SpellDefines.h:252
@ TRIGGERED_DONT_REPORT_CAST_ERROR
Will return SPELL_FAILED_DONT_REPORT in CheckCast functions.
Definition: SpellDefines.h:265
@ PROC_SPELL_TYPE_NONE
Definition: SpellMgr.h:249
@ PROC_HIT_NONE
Definition: SpellMgr.h:271
@ SPELL_CAST_SOURCE_NORMAL
Definition: Spell.h:140
@ CAST_FLAG_EX_IGNORE_COOLDOWN
Definition: Spell.h:124
@ SPELL_EFFECT_HANDLE_LAUNCH
Definition: Spell.h:238
@ SPELL_STATE_NULL
Definition: Spell.h:228
Definition: Item.h:170
ObjectGuid::LowType GenerateLowGuid()
Definition: Map.h:515
bool IsEmpty() const
Definition: ObjectGuid.h:317
void Clear()
Definition: ObjectGuid.h:284
static Unit * ToUnit(Object *o)
Definition: Object.h:212
bool IsInWorld() const
Definition: Object.h:153
bool IsUnit() const
Definition: Object.h:211
static ObjectGuid GetGUID(Object const *o)
Definition: Object.h:158
static Player * ToPlayer(Object *o)
Definition: Object.h:200
uint32 const Id
Definition: SpellInfo.h:325
bool IsPassive() const
Definition: SpellInfo.cpp:1582
bool HasAttribute(SpellAttr0 attribute) const
Definition: SpellInfo.h:449
bool IsAutoRepeatRangedSpell() const
Definition: SpellInfo.cpp:1731
uint32 DmgClass
Definition: SpellInfo.h:410
float m_damageMultipliers[MAX_SPELL_EFFECTS]
Definition: Spell.h:716
bool m_fromClient
Definition: Spell.h:561
uint32 m_castFlagsEx
Definition: Spell.h:562
GameObject * gameObjTarget
Definition: Spell.h:721
SpellMissInfo targetMissInfo
Definition: Spell.h:725
bool m_referencedFromCurrentSpell
Definition: Spell.h:713
bool m_canReflect
Definition: Spell.h:692
Unit * m_originalCaster
Definition: Spell.h:683
DynObjAura * _dynObjAura
Definition: Spell.h:732
uint32 m_channelTargetEffectMask
Definition: Spell.h:796
uint64 m_delayStart
Definition: Spell.h:707
int32 m_procChainLength
Definition: Spell.h:912
TriggerCastFlags _triggeredCastFlags
Definition: Spell.h:906
int32 damage
Definition: Spell.h:724
SpellEffectHandleMode effectHandleMode
Definition: Spell.h:727
int32 m_channeledDuration
Definition: Spell.h:691
bool IsIgnoringCooldowns() const
Definition: Spell.cpp:8145
SpellDestination m_destTargets[MAX_SPELL_EFFECTS]
Definition: Spell.h:827
ObjectGuid m_originalCastId
Definition: Spell.h:560
uint8 m_delayAtDamageCount
Definition: Spell.h:696
ProcFlagsSpellType m_procSpellType
Definition: Spell.h:747
WeaponAttackType m_attackType
Definition: Spell.h:687
bool m_immediateHandled
Definition: Spell.h:710
uint32 m_spellState
Definition: Spell.h:902
ObjectGuid m_originalCasterGUID
Definition: Spell.h:681
WorldObject *const m_caster
Definition: Spell.h:677
void CleanupTargetList()
Definition: Spell.cpp:2366
int32 m_timer
Definition: Spell.h:903
int32 m_casttime
Definition: Spell.h:690
Item * itemTarget
Definition: Spell.h:720
float variance
Definition: Spell.h:726
int32 m_damage
Definition: Spell.h:738
bool m_executedCurrently
Definition: Spell.h:714
SpellCustomErrors m_customError
Definition: Spell.h:599
int32 m_healing
Definition: Spell.h:739
SpellEffectInfo const * effectInfo
Definition: Spell.h:728
SpellInfo const * m_triggeredByAuraSpell
Definition: Spell.h:911
int32 m_castItemLevel
Definition: Spell.h:558
UnitAura * _spellAura
Definition: Spell.h:731
uint32 m_applyMultiplierMask
Definition: Spell.h:715
Unit * unitTarget
Definition: Spell.h:719
SpellSchoolMask m_spellSchoolMask
Definition: Spell.h:686
SpellEvent * _spellEvent
Definition: Spell.h:905
Corpse * m_corpseTarget
Definition: Spell.h:722
WorldLocation * destTarget
Definition: Spell.h:723
Spell ** m_selfContainer
Definition: Spell.h:652
Item * m_CastItem
Definition: Spell.h:555
uint32 m_castItemEntry
Definition: Spell.h:557
union Spell::@329 m_misc
SpellValue *const m_spellValue
Definition: Spell.h:679
ObjectGuid m_castItemGUID
Definition: Spell.h:556
SpellCastVisual m_SpellVisual
Definition: Spell.h:597
GameObject * focusObject
Definition: Spell.h:735
ProcFlagsHit m_hitMask
Definition: Spell.h:746
ObjectGuid m_castId
Definition: Spell.h:559
bool m_launchHandled
Definition: Spell.h:709
SpellInfo const *const m_spellInfo
Definition: Spell.h:554
uint8 m_runesState
Definition: Spell.h:694
bool m_autoRepeat
Definition: Spell.h:693
int32 GetProcChainLength() const
Definition: Unit.h:1808
uint32 GetMapId() const
Definition: Position.h:185
Map * GetMap() const
Definition: Object.h:604
Unit * GetCharmerOrOwner() const
Definition: Object.cpp:2221
Player * GetSpellModOwner() const
Definition: Object.cpp:2259
virtual uint32 GetCastSpellXSpellVisualId(SpellInfo const *spellInfo) const
Definition: Object.cpp:3273
TC_GAME_API Unit * GetUnit(WorldObject const &, ObjectGuid const &guid)
uint32 SpellXSpellVisualID
Definition: SpellDefines.h:504
int32 AuraStackAmount
Definition: Spell.h:218
+ Here is the call graph for this function:

◆ ~Spell()

Spell::~Spell ( )

Definition at line 614 of file Spell.cpp.

615{
616 // unload scripts
617 for (auto itr = m_loadedScripts.begin(); itr != m_loadedScripts.end(); ++itr)
618 {
619 (*itr)->_Unload();
620 delete (*itr);
621 }
622
624 {
625 // Clean the reference to avoid later crash.
626 // If this error is repeating, we may have to add an ASSERT to better track down how we get into this case.
627 TC_LOG_ERROR("spells", "SPELL: deleting spell for spell ID {}. However, spell still referenced.", m_spellInfo->Id);
628 *m_selfContainer = nullptr;
629 }
630
633
634 delete m_spellValue;
635}
#define ASSERT
Definition: Errors.h:68
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:165
@ TYPEID_PLAYER
Definition: ObjectGuid.h:41
TypeID GetTypeId() const
Definition: Object.h:172
Spell * m_spellModTakingSpell
Definition: Player.h:2660
std::vector< SpellScript * > m_loadedScripts
Definition: Spell.h:873
+ 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

Definition at line 3654 of file Spell.cpp.

3655{
3656 // update pointers base at GUIDs to prevent access to non-existed already object
3657 if (!UpdatePointers())
3658 {
3659 // cancel the spell if UpdatePointers() returned false, something wrong happened there
3660 cancel();
3661 return;
3662 }
3663
3664 // cancel at lost explicit target during cast
3666 {
3667 cancel();
3668 return;
3669 }
3670
3671 if (Player* playerCaster = m_caster->ToPlayer())
3672 {
3673 // now that we've done the basic check, now run the scripts
3674 // should be done before the spell is actually executed
3675 sScriptMgr->OnPlayerSpellCast(playerCaster, this, skipCheck);
3676
3677 // As of 3.0.2 pets begin attacking their owner's target immediately
3678 // Let any pets know we've attacked something. Check DmgClass for harmful spells only
3679 // This prevents spells such as Hunter's Mark from triggering pet attack
3680 if (GetSpellInfo()->DmgClass != SPELL_DAMAGE_CLASS_NONE)
3681 if (Unit* target = m_targets.GetUnitTarget())
3682 for (Unit* controlled : playerCaster->m_Controlled)
3683 if (Creature* cControlled = controlled->ToCreature())
3684 if (CreatureAI* controlledAI = cControlled->AI())
3685 controlledAI->OwnerAttacked(target);
3686 }
3687
3689
3690 // Should this be done for original caster?
3691 Player* modOwner = m_caster->GetSpellModOwner();
3692 if (modOwner)
3693 {
3694 // Set spell which will drop charges for triggered cast spells
3695 // if not successfully cast, will be remove in finish(false)
3696 modOwner->SetSpellModTakingSpell(this, true);
3697 }
3698
3700
3701 // skip check if done already (for instant cast spells for example)
3702 if (!skipCheck)
3703 {
3704 auto cleanupSpell = [this, modOwner](SpellCastResult res, int32* p1 = nullptr, int32* p2 = nullptr)
3705 {
3706 SendCastResult(res, p1, p2);
3707 SendInterrupted(0);
3708
3709 if (modOwner)
3710 modOwner->SetSpellModTakingSpell(this, false);
3711
3712 finish(res);
3713 SetExecutedCurrently(false);
3714 };
3715
3716 int32 param1 = 0, param2 = 0;
3717 SpellCastResult castResult = CheckCast(false, &param1, &param2);
3718 if (castResult != SPELL_CAST_OK)
3719 {
3720 cleanupSpell(castResult, &param1, &param2);
3721 return;
3722 }
3723
3724 // additional check after cast bar completes (must not be in CheckCast)
3725 // if trade not complete then remember it in trade data
3727 {
3728 if (modOwner)
3729 {
3730 if (TradeData* my_trade = modOwner->GetTradeData())
3731 {
3732 if (!my_trade->IsInAcceptProcess())
3733 {
3734 // Spell will be cast after completing the trade. Silently ignore at this place
3735 my_trade->SetSpell(m_spellInfo->Id, m_CastItem);
3736 cleanupSpell(SPELL_FAILED_DONT_REPORT);
3737 return;
3738 }
3739 }
3740 }
3741 }
3742
3743 // check diminishing returns (again, only after finish cast bar, tested on retail)
3744 if (Unit* target = m_targets.GetUnitTarget())
3745 {
3746 uint32 aura_effmask = 0;
3747 for (SpellEffectInfo const& spellEffectInfo : m_spellInfo->GetEffects())
3748 if (spellEffectInfo.IsUnitOwnedAuraEffect())
3749 aura_effmask |= 1 << spellEffectInfo.EffectIndex;
3750
3751 if (aura_effmask)
3752 {
3754 {
3756 if (type == DRTYPE_ALL || (type == DRTYPE_PLAYER && target->IsAffectedByDiminishingReturns()))
3757 {
3759 {
3760 if (target->HasStrongerAuraWithDR(m_spellInfo, caster))
3761 {
3762 cleanupSpell(SPELL_FAILED_AURA_BOUNCED);
3763 return;
3764 }
3765 }
3766 }
3767 }
3768 }
3769 }
3770 }
3771 // The spell focusing is making sure that we have a valid cast target guid when we need it so only check for a guid value here.
3772 if (Creature* creatureCaster = m_caster->ToCreature())
3773 if (!creatureCaster->GetTarget().IsEmpty() && !creatureCaster->HasUnitFlag(UNIT_FLAG_POSSESSED))
3774 if (WorldObject const* target = ObjectAccessor::GetUnit(*creatureCaster, creatureCaster->GetTarget()))
3775 creatureCaster->SetInFront(target);
3776
3778
3779 // Spell may be finished after target map check
3781 {
3782 SendInterrupted(0);
3783
3784 // cleanup after mod system
3785 // triggered spell pointer can be not removed in some cases
3787 m_caster->ToPlayer()->SetSpellModTakingSpell(this, false);
3788
3790 SetExecutedCurrently(false);
3791 return;
3792 }
3793
3794 if (Unit* unitCaster = m_caster->ToUnit())
3796 if (Creature* pet = ObjectAccessor::GetCreature(*m_caster, unitCaster->GetPetGUID()))
3797 pet->DespawnOrUnsummon();
3798
3800
3802
3803 // traded items have trade slot instead of guid in m_itemTargetGUID
3804 // set to real guid to be sent later to the client
3806
3807 if (Player* player = m_caster->ToPlayer())
3808 {
3810 {
3811 player->StartCriteria(CriteriaStartEvent::UseItem, m_CastItem->GetEntry());
3812 player->UpdateCriteria(CriteriaType::UseItem, m_CastItem->GetEntry());
3813 }
3814
3815 player->FailCriteria(CriteriaFailEvent::CastSpell, m_spellInfo->Id);
3816 player->StartCriteria(CriteriaStartEvent::CastSpell, m_spellInfo->Id);
3817 player->UpdateCriteria(CriteriaType::CastSpell, m_spellInfo->Id);
3818 }
3819
3821 {
3822 // Powers have to be taken before SendSpellGo
3823 TakePower();
3824 TakeReagents(); // we must remove reagents before HandleEffects to allow place crafted item in same slot
3825 }
3826 else if (Item* targetItem = m_targets.GetItemTarget())
3827 {
3829 if (targetItem->GetOwnerGUID() != m_caster->GetGUID())
3830 TakeReagents();
3831 }
3832
3833 // CAST SPELL
3836
3838 {
3840 m_launchHandled = true;
3841 }
3842
3845
3846 // we must send smsg_spell_go packet before m_castItem delete in TakeCastItem()...
3847 SendSpellGo();
3848
3849 if (!m_spellInfo->IsChanneled())
3850 if (Creature* creatureCaster = m_caster->ToCreature())
3851 creatureCaster->ReleaseSpellFocus(this);
3852
3853 // Okay, everything is prepared. Now we need to distinguish between immediate and evented delayed spells
3855 {
3856 // Remove used for cast item if need (it can be already NULL after TakeReagents call
3857 // in case delayed spell remove item at cast delay start
3858 TakeCastItem();
3859
3860 // Okay, maps created, now prepare flags
3861 m_immediateHandled = false;
3863 SetDelayStart(0);
3864
3865 if (Unit* unitCaster = m_caster->ToUnit())
3866 if (unitCaster->HasUnitState(UNIT_STATE_CASTING) && !unitCaster->IsNonMeleeSpellCast(false, false, true))
3867 unitCaster->ClearUnitState(UNIT_STATE_CASTING);
3868 }
3869 else
3870 {
3871 // Immediate spell, no big deal
3873 }
3874
3876
3877 if (std::vector<int32> const* spell_triggered = sSpellMgr->GetSpellLinked(SPELL_LINK_CAST, m_spellInfo->Id))
3878 {
3879 for (int32 id : *spell_triggered)
3880 {
3881 if (id < 0)
3882 {
3883 if (Unit* unitCaster = m_caster->ToUnit())
3884 unitCaster->RemoveAurasDueToSpell(-id);
3885 }
3886 else
3888 .SetTriggeringSpell(this));
3889 }
3890 }
3891
3892 if (modOwner)
3893 {
3894 modOwner->SetSpellModTakingSpell(this, false);
3895
3896 //Clear spell cooldowns after every spell is cast if .cheat cooldown is enabled.
3898 {
3901 }
3902 }
3903
3904 SetExecutedCurrently(false);
3905
3906 if (!m_originalCaster)
3907 return;
3908
3909 // Handle procs on cast
3910 ProcFlagsInit procAttacker = m_procAttacker;
3911 if (!procAttacker)
3912 {
3914 {
3915 if (IsPositive())
3916 procAttacker |= PROC_FLAG_DEAL_HELPFUL_PERIODIC;
3917 else
3918 procAttacker |= PROC_FLAG_DEAL_HARMFUL_PERIODIC;
3919 }
3921 {
3922 if (IsPositive())
3923 procAttacker |= PROC_FLAG_DEAL_HELPFUL_ABILITY;
3924 else
3925 procAttacker |= PROC_FLAG_DEAL_HARMFUL_ABILITY;
3926 }
3927 else
3928 {
3929 if (IsPositive())
3930 procAttacker |= PROC_FLAG_DEAL_HELPFUL_SPELL;
3931 else
3932 procAttacker |= PROC_FLAG_DEAL_HARMFUL_SPELL;
3933 }
3934 }
3935
3936 procAttacker |= PROC_FLAG_2_CAST_SUCCESSFUL;
3937
3938 ProcFlagsHit hitMask = m_hitMask;
3939 if (!(hitMask & PROC_HIT_CRITICAL))
3940 hitMask |= PROC_HIT_NORMAL;
3941
3943 m_originalCaster->RemoveAurasWithInterruptFlags(SpellAuraInterruptFlags::ActionDelayed, m_spellInfo);
3944
3945 Unit::ProcSkillsAndAuras(m_originalCaster, nullptr, procAttacker, PROC_FLAG_NONE, PROC_SPELL_TYPE_MASK_ALL, PROC_SPELL_PHASE_CAST, hitMask, this, nullptr, nullptr);
3946
3947 // Call CreatureAI hook OnSpellCast
3948 if (Creature* caster = m_originalCaster->ToCreature())
3949 if (caster->IsAIEnabled())
3950 caster->AI()->OnSpellCast(GetSpellInfo());
3951}
int32_t int32
Definition: Define.h:139
uint32_t uint32
Definition: Define.h:143
@ CHEAT_COOLDOWN
Definition: Player.h:947
#define sScriptMgr
Definition: ScriptMgr.h:1418
@ SPELL_ATTR7_RESET_SWING_TIMER_AT_SPELL_START
@ SPELL_ATTR2_NOT_AN_ACTION
@ SPELL_ATTR1_DISMISS_PET_FIRST
@ SPELL_ATTR3_TREAT_AS_PERIODIC
@ SPELL_DAMAGE_CLASS_NONE
@ SPELL_ATTR12_START_COOLDOWN_ON_CAST_START
SpellCastResult
@ SPELL_FAILED_DONT_REPORT
@ SPELL_FAILED_AURA_BOUNCED
@ SPELL_CAST_OK
@ SPELL_FAILED_INTERRUPTED
DiminishingReturnsType
@ DRTYPE_PLAYER
@ DRTYPE_ALL
@ SPELL_ATTR4_NO_HARMFUL_THREAT
@ TARGET_FLAG_TRADE_ITEM
Definition: SpellDefines.h:292
@ TRIGGERED_FULL_MASK
Used when doing CastSpell with triggered == true.
Definition: SpellDefines.h:266
@ TRIGGERED_IGNORE_POWER_AND_REAGENT_COST
Will ignore power and reagent cost.
Definition: SpellDefines.h:249
@ TRIGGERED_IGNORE_CAST_ITEM
Will not take away cast item or update related achievement criteria.
Definition: SpellDefines.h:250
@ PROC_SPELL_PHASE_CAST
Definition: SpellMgr.h:261
#define sSpellMgr
Definition: SpellMgr.h:825
@ PROC_SPELL_TYPE_MASK_ALL
Definition: SpellMgr.h:253
@ SPELL_LINK_CAST
Definition: SpellMgr.h:124
@ PROC_FLAG_DEAL_HELPFUL_ABILITY
Definition: SpellMgr.h:150
@ PROC_FLAG_DEAL_HARMFUL_ABILITY
Definition: SpellMgr.h:153
@ PROC_FLAG_DEAL_HARMFUL_PERIODIC
Definition: SpellMgr.h:162
@ PROC_FLAG_DEAL_HELPFUL_SPELL
Definition: SpellMgr.h:156
@ PROC_FLAG_DEAL_HELPFUL_PERIODIC
Definition: SpellMgr.h:167
@ PROC_FLAG_DEAL_HARMFUL_SPELL
Definition: SpellMgr.h:159
@ PROC_FLAG_NONE
Definition: SpellMgr.h:133
@ PROC_FLAG_2_CAST_SUCCESSFUL
Definition: SpellMgr.h:233
ProcFlagsHit
Definition: SpellMgr.h:270
@ PROC_HIT_CRITICAL
Definition: SpellMgr.h:273
@ PROC_HIT_NORMAL
Definition: SpellMgr.h:272
@ SPELL_STATE_DELAYED
Definition: Spell.h:233
@ SPELL_STATE_FINISHED
Definition: Spell.h:231
@ UNIT_FLAG_POSSESSED
Definition: UnitDefines.h:168
@ UNIT_STATE_CASTING
Definition: Unit.h:267
static Creature * ToCreature(Object *o)
Definition: Object.h:206
uint32 GetEntry() const
Definition: Object.h:160
void SetSpellModTakingSpell(Spell *spell, bool apply)
Definition: Player.cpp:22190
bool GetCommandStatus(uint32 command) const
Definition: Player.h:1202
TradeData * GetTradeData() const
Definition: Player.h:1494
WorldObject * GetObjectTarget() const
Definition: Spell.cpp:276
void UpdateTradeSlotItem()
Definition: Spell.cpp:313
ObjectGuid GetObjectTargetGUID() const
Definition: Spell.cpp:281
Item * GetItemTarget() const
Definition: SpellDefines.h:360
uint32 GetTargetMask() const
Definition: SpellDefines.h:339
Unit * GetUnitTarget() const
Definition: Spell.cpp:216
void ResetCooldown(uint32 spellId, bool update=false)
void RestoreCharge(uint32 chargeCategoryId)
DiminishingReturnsType GetDiminishingReturnsGroupType() const
Definition: SpellInfo.cpp:3279
bool HasHitDelay() const
Definition: SpellInfo.cpp:1741
DiminishingGroup GetDiminishingReturnsGroupForSpell() const
Definition: SpellInfo.cpp:3274
float LaunchDelay
Definition: SpellInfo.h:389
bool IsChanneled() const
Definition: SpellInfo.cpp:1709
uint32 ChargeCategoryId
Definition: SpellInfo.h:414
std::vector< SpellEffectInfo > const & GetEffects() const
Definition: SpellInfo.h:576
SpellInfo const * GetSpellInfo() const
Definition: Spell.h:640
void CallScriptAfterCastHandlers()
Definition: Spell.cpp:8651
void PrepareTriggersExecutedOnHit()
Definition: Spell.cpp:8912
SpellCastTargets m_targets
Definition: Spell.h:598
void handle_immediate()
Definition: Spell.cpp:3968
void SendSpellGo()
Definition: Spell.cpp:4767
void TakeReagents()
Definition: Spell.cpp:5492
void SetExecutedCurrently(bool yes)
Definition: Spell.h:622
void SendInterrupted(uint8 result)
Definition: Spell.cpp:5163
static void SendCastResult(Player *caster, SpellInfo const *spellInfo, SpellCastVisual spellVisual, ObjectGuid cast_count, SpellCastResult result, SpellCustomErrors customError=SPELL_CUSTOM_ERROR_NONE, int32 *param1=nullptr, int32 *param2=nullptr)
Definition: Spell.cpp:4632
void CallScriptOnCastHandlers()
Definition: Spell.cpp:8639
void SendSpellCooldown()
Definition: Spell.cpp:4199
void CallScriptBeforeCastHandlers()
Definition: Spell.cpp:8627
void HandleLaunchPhase()
Definition: Spell.cpp:8330
bool UpdatePointers()
Definition: Spell.cpp:7958
void SetDelayStart(uint64 m_time)
Definition: Spell.h:624
void ResetCombatTimers()
Definition: Spell.cpp:8472
void cancel()
Definition: Spell.cpp:3583
void SelectSpellTargets()
Definition: Spell.cpp:736
SpellCastResult CheckCast(bool strict, int32 *param1=nullptr, int32 *param2=nullptr)
Definition: Spell.cpp:5628
void TakePower()
Definition: Spell.cpp:5375
bool IsPositive() const
Definition: Spell.cpp:8176
void TakeCastItem()
Definition: Spell.cpp:5307
void finish(SpellCastResult result=SPELL_CAST_OK)
Definition: Spell.cpp:4300
bool IsAutoActionResetSpell() const
Definition: Spell.cpp:8165
ProcFlagsInit m_procAttacker
Definition: Spell.h:744
Definition: Unit.h:747
ControlList m_Controlled
Definition: Unit.h:1318
void RemoveAurasWithInterruptFlags(InterruptFlags flag, SpellInfo const *source=nullptr)
Definition: Unit.cpp:4010
SpellHistory * GetSpellHistory()
Definition: Unit.h:1564
static void ProcSkillsAndAuras(Unit *actor, Unit *actionTarget, ProcFlagsInit const &typeMaskActor, ProcFlagsInit const &typeMaskActionTarget, ProcFlagsSpellType spellTypeMask, ProcFlagsSpellPhase spellPhaseMask, ProcFlagsHit hitMask, Spell *spell, DamageInfo *damageInfo, HealInfo *healInfo)
Definition: Unit.cpp:5318
SpellCastResult CastSpell(CastSpellTargetArg const &targets, uint32 spellId, CastSpellExtraArgs const &args={ })
Definition: Object.cpp:2883
TC_GAME_API Creature * GetCreature(WorldObject const &u, ObjectGuid const &guid)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _handle_finish_phase()

void Spell::_handle_finish_phase ( )

Definition at line 4160 of file Spell.cpp.

4161{
4162 if (Unit* unitCaster = m_caster->ToUnit())
4164 unitCaster->SetLastExtraAttackSpell(m_spellInfo->Id);
4165
4166 // Handle procs on finish
4167 if (!m_originalCaster)
4168 return;
4169
4170 ProcFlagsInit procAttacker = m_procAttacker;
4171 if (!procAttacker)
4172 {
4174 {
4175 if (IsPositive())
4176 procAttacker |= PROC_FLAG_DEAL_HELPFUL_PERIODIC;
4177 else
4178 procAttacker |= PROC_FLAG_DEAL_HARMFUL_PERIODIC;
4179 }
4181 {
4182 if (IsPositive())
4183 procAttacker |= PROC_FLAG_DEAL_HELPFUL_ABILITY;
4184 else
4185 procAttacker |= PROC_FLAG_DEAL_HARMFUL_ABILITY;
4186 }
4187 else
4188 {
4189 if (IsPositive())
4190 procAttacker |= PROC_FLAG_DEAL_HELPFUL_SPELL;
4191 else
4192 procAttacker |= PROC_FLAG_DEAL_HARMFUL_SPELL;
4193 }
4194 }
4195
4197}
@ SPELL_EFFECT_ADD_EXTRA_ATTACKS
@ PROC_SPELL_PHASE_FINISH
Definition: SpellMgr.h:263
bool HasEffect(SpellEffectName effect) const
Definition: SpellInfo.cpp:1381
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _handle_immediate_phase()

void Spell::_handle_immediate_phase ( )

Definition at line 4140 of file Spell.cpp.

4141{
4142 // handle some immediate features of the spell here
4144
4145 // handle effects with SPELL_EFFECT_HANDLE_HIT mode
4146 for (SpellEffectInfo const& spellEffectInfo : m_spellInfo->GetEffects())
4147 {
4148 // don't do anything for empty effect
4149 if (!spellEffectInfo.IsEffect())
4150 continue;
4151
4152 // call effect handlers to handle destination hit
4153 HandleEffects(nullptr, nullptr, nullptr, nullptr, spellEffectInfo, SPELL_EFFECT_HANDLE_HIT);
4154 }
4155
4156 // process items
4158}
@ SPELL_EFFECT_HANDLE_HIT
Definition: Spell.h:240
void HandleEffects(Unit *pUnitTarget, Item *pItemTarget, GameObject *pGoTarget, Corpse *pCorpseTarget, SpellEffectInfo const &spellEffectInfo, SpellEffectHandleMode mode)
Definition: Spell.cpp:5602
void DoProcessTargetContainer(Container &targetContainer)
Definition: Spell.cpp:3954
void HandleThreatSpells()
Definition: Spell.cpp:5546
std::vector< ItemTargetInfo > m_UniqueItemInfo
Definition: Spell.h:813
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ AddCorpseTarget()

void Spell::AddCorpseTarget ( Corpse target,
uint32  effectMask 
)
protected

Definition at line 2588 of file Spell.cpp.

2589{
2590 for (SpellEffectInfo const& spellEffectInfo : m_spellInfo->GetEffects())
2591 if (!spellEffectInfo.IsEffect())
2592 effectMask &= ~(1 << spellEffectInfo.EffectIndex);
2593
2594 // no effects left
2595 if (!effectMask)
2596 return;
2597
2598 ObjectGuid targetGUID = corpse->GetGUID();
2599
2600 // Lookup target in already in list
2601 auto ihit = std::find_if(std::begin(m_UniqueCorpseTargetInfo), std::end(m_UniqueCorpseTargetInfo), [targetGUID](CorpseTargetInfo const& target) { return target.TargetGUID == targetGUID; });
2602 if (ihit != std::end(m_UniqueCorpseTargetInfo)) // Found in list
2603 {
2604 // Add only effect mask
2605 ihit->EffectMask |= effectMask;
2606 return;
2607 }
2608
2609 // This is new target calculate data for him
2610 CorpseTargetInfo target;
2611 target.TargetGUID = targetGUID;
2612 target.EffectMask = effectMask;
2613
2614 // Spell have speed - need calculate incoming time
2615 if (m_caster != corpse)
2616 {
2617 float hitDelay = m_spellInfo->LaunchDelay;
2619 hitDelay += m_spellInfo->Speed;
2620 else if (m_spellInfo->Speed > 0.0f)
2621 {
2622 // calculate spell incoming interval
2623 float dist = std::max(m_caster->GetDistance(corpse->GetPositionX(), corpse->GetPositionY(), corpse->GetPositionZ()), 5.0f);
2624 hitDelay += dist / m_spellInfo->Speed;
2625 }
2626
2627 target.TimeDelay = uint64(std::floor(hitDelay * 1000.0f));
2628 }
2629 else
2630 target.TimeDelay = 0LL;
2631
2632 // Calculate minimum incoming time
2633 if (target.TimeDelay && (!m_delayMoment || m_delayMoment > target.TimeDelay))
2634 m_delayMoment = target.TimeDelay;
2635
2636 // Add target to list
2637 m_UniqueCorpseTargetInfo.emplace_back(std::move(target));
2638}
uint64_t uint64
Definition: Define.h:142
@ SPELL_ATTR9_SPECIAL_DELAY_CALCULATION
float Speed
Definition: SpellInfo.h:388
uint64 m_delayMoment
Definition: Spell.h:708
std::vector< CorpseTargetInfo > m_UniqueCorpseTargetInfo
Definition: Spell.h:822
float GetDistance(WorldObject const *obj) const
Definition: Object.cpp:1069
+ 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

Definition at line 2640 of file Spell.cpp.

2641{
2642 m_destTargets[effIndex] = dest;
2643}
+ Here is the caller graph for this function:

◆ AddGOTarget()

void Spell::AddGOTarget ( GameObject target,
uint32  effectMask 
)
protected

Definition at line 2507 of file Spell.cpp.

2508{
2509 for (SpellEffectInfo const& spellEffectInfo : m_spellInfo->GetEffects())
2510 if (!spellEffectInfo.IsEffect() || !CheckEffectTarget(go, spellEffectInfo))
2511 effectMask &= ~(1 << spellEffectInfo.EffectIndex);
2512
2513 // no effects left
2514 if (!effectMask)
2515 return;
2516
2517 ObjectGuid targetGUID = go->GetGUID();
2518
2519 // Lookup target in already in list
2520 auto ihit = std::find_if(std::begin(m_UniqueGOTargetInfo), std::end(m_UniqueGOTargetInfo), [targetGUID](GOTargetInfo const& target) { return target.TargetGUID == targetGUID; });
2521 if (ihit != std::end(m_UniqueGOTargetInfo)) // Found in list
2522 {
2523 // Add only effect mask
2524 ihit->EffectMask |= effectMask;
2525 return;
2526 }
2527
2528 // This is new target calculate data for him
2529
2530 GOTargetInfo target;
2531 target.TargetGUID = targetGUID;
2532 target.EffectMask = effectMask;
2533
2534 // Spell have speed - need calculate incoming time
2535 if (static_cast<WorldObject*>(m_caster) != go)
2536 {
2537 float hitDelay = m_spellInfo->LaunchDelay;
2539 hitDelay += m_spellInfo->Speed;
2540 else if (m_spellInfo->Speed > 0.0f)
2541 {
2542 // calculate spell incoming interval
2543 float dist = std::max(m_caster->GetDistance(go->GetPositionX(), go->GetPositionY(), go->GetPositionZ()), 5.0f);
2544 hitDelay += dist / m_spellInfo->Speed;
2545 }
2546
2547 target.TimeDelay = uint64(std::floor(hitDelay * 1000.0f));
2548 }
2549 else
2550 target.TimeDelay = 0ULL;
2551
2552 // Calculate minimum incoming time
2553 if (target.TimeDelay && (!m_delayMoment || m_delayMoment > target.TimeDelay))
2554 m_delayMoment = target.TimeDelay;
2555
2556 // Add target to list
2557 m_UniqueGOTargetInfo.emplace_back(std::move(target));
2558}
std::vector< GOTargetInfo > m_UniqueGOTargetInfo
Definition: Spell.h:805
bool CheckEffectTarget(Unit const *target, SpellEffectInfo const &spellEffectInfo, Position const *losPosition) const
Definition: Spell.cpp:8030
+ 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

Definition at line 2560 of file Spell.cpp.

2561{
2562 for (SpellEffectInfo const& spellEffectInfo : m_spellInfo->GetEffects())
2563 if (!spellEffectInfo.IsEffect() || !CheckEffectTarget(item, spellEffectInfo))
2564 effectMask &= ~(1 << spellEffectInfo.EffectIndex);
2565
2566 // no effects left
2567 if (!effectMask)
2568 return;
2569
2570 // Lookup target in already in list
2571 auto ihit = std::find_if(std::begin(m_UniqueItemInfo), std::end(m_UniqueItemInfo), [item](ItemTargetInfo const& target) { return target.TargetItem == item; });
2572 if (ihit != std::end(m_UniqueItemInfo)) // Found in list
2573 {
2574 // Add only effect mask
2575 ihit->EffectMask |= effectMask;
2576 return;
2577 }
2578
2579 // This is new target add data
2580
2581 ItemTargetInfo target;
2582 target.TargetItem = item;
2583 target.EffectMask = effectMask;
2584
2585 m_UniqueItemInfo.emplace_back(std::move(target));
2586}
+ 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

Definition at line 2400 of file Spell.cpp.

2401{
2402 for (SpellEffectInfo const& spellEffectInfo : m_spellInfo->GetEffects())
2403 if (!spellEffectInfo.IsEffect() || !CheckEffectTarget(target, spellEffectInfo, losPosition))
2404 effectMask &= ~(1 << spellEffectInfo.EffectIndex);
2405
2406 // no effects left
2407 if (!effectMask)
2408 return;
2409
2410 if (checkIfValid)
2411 if (m_spellInfo->CheckTarget(m_caster, target, implicit) != SPELL_CAST_OK) // skip stealth checks for AOE
2412 return;
2413
2414 // Check for effect immune skip if immuned
2415 for (SpellEffectInfo const& spellEffectInfo : m_spellInfo->GetEffects())
2416 if (target->IsImmunedToSpellEffect(m_spellInfo, spellEffectInfo, m_caster))
2417 effectMask &= ~(1 << spellEffectInfo.EffectIndex);
2418
2419 ObjectGuid targetGUID = target->GetGUID();
2420
2421 // Lookup target in already in list
2422 auto ihit = std::find_if(std::begin(m_UniqueTargetInfo), std::end(m_UniqueTargetInfo), [targetGUID](TargetInfo const& target) { return target.TargetGUID == targetGUID; });
2423 if (ihit != std::end(m_UniqueTargetInfo)) // Found in list
2424 {
2425 // Immune effects removed from mask
2426 ihit->EffectMask |= effectMask;
2427 return;
2428 }
2429
2430 // This is new target calculate data for him
2431
2432 // Get spell hit result on target
2433 TargetInfo targetInfo;
2434 targetInfo.TargetGUID = targetGUID; // Store target GUID
2435 targetInfo.EffectMask = effectMask; // Store all effects not immune
2436 targetInfo.IsAlive = target->IsAlive();
2437 targetInfo.Damage = 0;
2438 targetInfo.Healing = 0;
2439 targetInfo.IsCrit = false;
2440
2441 // Calculate hit result
2443 targetInfo.MissCondition = caster->SpellHitResult(target, m_spellInfo, m_canReflect && !(IsPositive() && m_caster->IsFriendlyTo(target)));
2444
2445 // Spell have speed - need calculate incoming time
2446 // Incoming time is zero for self casts. At least I think so.
2447 if (m_caster != target)
2448 {
2449 float hitDelay = m_spellInfo->LaunchDelay;
2450 WorldObject const* missileSource = m_caster;
2452 {
2453 auto previousTargetItr = std::find_if(m_UniqueTargetInfo.rbegin(), m_UniqueTargetInfo.rend(), [effectMask](TargetInfo const& target)
2454 {
2455 return (target.EffectMask & effectMask) != 0;
2456 });
2457 if (previousTargetItr != std::rend(m_UniqueTargetInfo))
2458 {
2459 hitDelay = 0.0f; // this is not the first target in chain, LaunchDelay was already included
2460
2461 if (WorldObject* previousTarget = ObjectAccessor::GetWorldObject(*m_caster, previousTargetItr->TargetGUID))
2462 missileSource = previousTarget;
2463
2464 targetInfo.TimeDelay += previousTargetItr->TimeDelay;
2465 }
2466 }
2467
2469 hitDelay += m_spellInfo->Speed;
2470 else if (m_spellInfo->Speed > 0.0f)
2471 {
2472 // calculate spell incoming interval
2474 float dist = std::max(missileSource->GetDistance(target->GetPositionX(), target->GetPositionY(), target->GetPositionZ()), 5.0f);
2475 hitDelay += dist / m_spellInfo->Speed;
2476 }
2477
2478 targetInfo.TimeDelay += uint64(std::floor(hitDelay * 1000.0f));
2479 }
2480 else
2481 targetInfo.TimeDelay = 0ULL;
2482
2483 // If target reflect spell back to caster
2484 if (targetInfo.MissCondition == SPELL_MISS_REFLECT)
2485 {
2486 // Calculate reflected spell result on caster (shouldn't be able to reflect gameobject spells)
2487 Unit* unitCaster = ASSERT_NOTNULL(m_caster->ToUnit());
2488 targetInfo.ReflectResult = unitCaster->SpellHitResult(unitCaster, m_spellInfo, false); // can't reflect twice
2489
2490 // Proc spell reflect aura when missile hits the original target
2491 target->m_Events.AddEvent(new ProcReflectDelayed(target, m_originalCasterGUID), target->m_Events.CalculateTime(Milliseconds(targetInfo.TimeDelay)));
2492
2493 // Increase time interval for reflected spells by 1.5
2494 targetInfo.TimeDelay += targetInfo.TimeDelay >> 1;
2495 }
2496 else
2497 targetInfo.ReflectResult = SPELL_MISS_NONE;
2498
2499 // Calculate minimum incoming time
2500 if (targetInfo.TimeDelay && (!m_delayMoment || m_delayMoment > targetInfo.TimeDelay))
2501 m_delayMoment = targetInfo.TimeDelay;
2502
2503 // Add target to list
2504 m_UniqueTargetInfo.emplace_back(std::move(targetInfo));
2505}
std::chrono::milliseconds Milliseconds
Milliseconds shorthand typedef.
Definition: Duration.h:29
#define ASSERT_NOTNULL(pointer)
Definition: Errors.h:84
@ SPELL_MISS_REFLECT
@ SPELL_ATTR4_BOUNCY_CHAIN_MISSILES
SpellCastResult CheckTarget(WorldObject const *caster, WorldObject const *target, bool implicit=true) const
Definition: SpellInfo.cpp:2165
std::vector< TargetInfo > m_UniqueTargetInfo
Definition: Spell.h:795
virtual bool IsImmunedToSpellEffect(SpellInfo const *spellInfo, SpellEffectInfo const &spellEffectInfo, WorldObject const *caster, bool requireImmunityPurgesEffectAttribute=false) const
Definition: Unit.cpp:7438
SpellMissInfo SpellHitResult(Unit *victim, SpellInfo const *spellInfo, bool canReflect=false) const
Definition: Object.cpp:2608
bool IsFriendlyTo(WorldObject const *target) const
Definition: Object.cpp:2852
TC_GAME_API WorldObject * GetWorldObject(WorldObject const &, ObjectGuid const &)
+ 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

Definition at line 7072 of file Spell.cpp.

7073{
7074 bool needRecalculateBasePoints = !(m_spellValue->CustomBasePointsMask & (1 << spellEffectInfo.EffectIndex));
7075 return m_caster->CalculateSpellDamage(target, spellEffectInfo, needRecalculateBasePoints ? nullptr : &m_spellValue->EffectBasePoints[spellEffectInfo.EffectIndex], var, m_castItemEntry, m_castItemLevel);
7076}
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:2284
int32 EffectBasePoints[MAX_SPELL_EFFECTS]
Definition: Spell.h:214
uint32 CustomBasePointsMask
Definition: Spell.h:215
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ CalculateDelayMomentForDst()

uint64 Spell::CalculateDelayMomentForDst ( float  launchDelay) const

Definition at line 847 of file Spell.cpp.

848{
849 if (m_targets.HasDst())
850 {
851 if (m_targets.HasTraj())
852 {
853 float speed = m_targets.GetSpeedXY();
854 if (speed > 0.0f)
855 return uint64(std::floor((m_targets.GetDist2d() / speed + launchDelay) * 1000.0f));
856 }
858 return uint64(std::floor((m_spellInfo->Speed + launchDelay) * 1000.0f));
859 else if (m_spellInfo->Speed > 0.0f)
860 {
861 // We should not subtract caster size from dist calculation (fixes execution time desync with animation on client, eg. Malleable Goo cast by PP)
862 float dist = m_caster->GetExactDist(*m_targets.GetDstPos());
863 return uint64(std::floor((dist / m_spellInfo->Speed + launchDelay) * 1000.0f));
864 }
865
866 return uint64(std::floor(launchDelay * 1000.0f));
867 }
868
869 return 0;
870}
bool HasTraj() const
Definition: SpellDefines.h:387
bool HasDst() const
Definition: Spell.cpp:423
float GetSpeedXY() const
Definition: SpellDefines.h:395
float GetDist2d() const
Definition: SpellDefines.h:394
WorldLocation const * GetDstPos() const
Definition: Spell.cpp:366
float GetExactDist(float x, float y, float z) const
Definition: Position.h:118
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ CalculateJumpSpeeds()

void Spell::CalculateJumpSpeeds ( SpellEffectInfo const *  effInfo,
float  dist,
float &  speedXY,
float &  speedZ 
)
protected

Definition at line 861 of file SpellEffects.cpp.

862{
863 Unit* unitCaster = GetUnitCasterForEffectHandlers();
864 ASSERT(unitCaster);
865
866 float multiplier = effInfo->Amplitude;
867 if (multiplier <= 0.0f)
868 multiplier = 1.0f;
869
870 float minHeight = effInfo->MiscValue ? effInfo->MiscValue / 10.0f : 0.5f; // Lower bound is blizzlike
871 float maxHeight = effInfo->MiscValueB ? effInfo->MiscValueB / 10.0f : 1000.0f; // Upper bound is unknown
872
873 unitCaster->GetMotionMaster()->CalculateJumpSpeeds(dist, MOVE_RUN, multiplier, minHeight, maxHeight, speedXY, speedZ);
874}
@ MOVE_RUN
Definition: UnitDefines.h:118
void CalculateJumpSpeeds(float dist, UnitMoveType moveType, float speedMultiplier, float minHeight, float maxHeight, float &speedXY, float &speedZ) const
Unit * GetUnitCasterForEffectHandlers() const
Definition: Spell.cpp:8188
MotionMaster * GetMotionMaster()
Definition: Unit.h:1757
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ CallScriptAfterCastHandlers()

void Spell::CallScriptAfterCastHandlers ( )
protected

Definition at line 8651 of file Spell.cpp.

8652{
8653 for (SpellScript* script : m_loadedScripts)
8654 {
8655 script->_PrepareScriptCall(SPELL_SCRIPT_HOOK_AFTER_CAST);
8656 for (SpellScript::CastHandler const& afterCast : script->AfterCast)
8657 afterCast.Call(script);
8658
8659 script->_FinishScriptCall();
8660 }
8661}
@ SPELL_SCRIPT_HOOK_AFTER_CAST
Definition: SpellScript.h:235
void Call(SpellScript *spellScript) const
Definition: SpellScript.h:276
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ CallScriptAfterHitHandlers()

void Spell::CallScriptAfterHitHandlers ( )
protected

Definition at line 8775 of file Spell.cpp.

8776{
8777 for (SpellScript* script : m_loadedScripts)
8778 {
8779 script->_PrepareScriptCall(SPELL_SCRIPT_HOOK_AFTER_HIT);
8780 for (SpellScript::HitHandler const& afterHit : script->AfterHit)
8781 afterHit.Call(script);
8782
8783 script->_FinishScriptCall();
8784 }
8785}
@ SPELL_SCRIPT_HOOK_AFTER_HIT
Definition: SpellScript.h:227
void Call(SpellScript *spellScript) const
Definition: SpellScript.h:446
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ CallScriptBeforeCastHandlers()

void Spell::CallScriptBeforeCastHandlers ( )
protected

Definition at line 8627 of file Spell.cpp.

8628{
8629 for (SpellScript* script : m_loadedScripts)
8630 {
8631 script->_PrepareScriptCall(SPELL_SCRIPT_HOOK_BEFORE_CAST);
8632 for (SpellScript::CastHandler const& beforeCast : script->BeforeCast)
8633 beforeCast.Call(script);
8634
8635 script->_FinishScriptCall();
8636 }
8637}
@ SPELL_SCRIPT_HOOK_BEFORE_CAST
Definition: SpellScript.h:232
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ CallScriptBeforeHitHandlers()

void Spell::CallScriptBeforeHitHandlers ( SpellMissInfo  missInfo)
protected

Definition at line 8750 of file Spell.cpp.

8751{
8752 for (SpellScript* script : m_loadedScripts)
8753 {
8754 script->_InitHit();
8755 script->_PrepareScriptCall(SPELL_SCRIPT_HOOK_BEFORE_HIT);
8756 for (SpellScript::BeforeHitHandler const& beforeHit : script->BeforeHit)
8757 beforeHit.Call(script, missInfo);
8758
8759 script->_FinishScriptCall();
8760 }
8761}
@ SPELL_SCRIPT_HOOK_BEFORE_HIT
Definition: SpellScript.h:225
void Call(SpellScript *spellScript, SpellMissInfo missInfo) const
Definition: SpellScript.h:412
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ CallScriptCalcCastTimeHandlers()

int32 Spell::CallScriptCalcCastTimeHandlers ( int32  originalCastTime)
protected

Definition at line 8681 of file Spell.cpp.

8682{
8683 for (SpellScript* script : m_loadedScripts)
8684 {
8685 script->_PrepareScriptCall(SPELL_SCRIPT_HOOK_CALC_CAST_TIME);
8686 castTime = script->CalcCastTime(castTime);
8687 script->_FinishScriptCall();
8688 }
8689 return castTime;
8690}
@ SPELL_SCRIPT_HOOK_CALC_CAST_TIME
Definition: SpellScript.h:240
+ Here is the caller graph for this function:

◆ CallScriptCalcCritChanceHandlers()

void Spell::CallScriptCalcCritChanceHandlers ( Unit const *  victim,
float &  chance 
)

Definition at line 8787 of file Spell.cpp.

8788{
8789 for (SpellScript* script : m_loadedScripts)
8790 {
8791 script->_PrepareScriptCall(SPELL_SCRIPT_HOOK_CALC_CRIT_CHANCE);
8792 for (SpellScript::OnCalcCritChanceHandler const& calcCritChance : script->OnCalcCritChance)
8793 calcCritChance.Call(script, victim, critChance);
8794
8795 script->_FinishScriptCall();
8796 }
8797}
@ SPELL_SCRIPT_HOOK_CALC_CRIT_CHANCE
Definition: SpellScript.h:236
void Call(SpellScript *spellScript, Unit const *victim, float &critChance) const
Definition: SpellScript.h:498
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ CallScriptCalcDamageHandlers()

void Spell::CallScriptCalcDamageHandlers ( Unit victim,
int32 damage,
int32 flatMod,
float &  pctMod 
)

Definition at line 8799 of file Spell.cpp.

8800{
8801 for (SpellScript* script : m_loadedScripts)
8802 {
8803 script->_PrepareScriptCall(SPELL_SCRIPT_HOOK_CALC_DAMAGE);
8804 for (SpellScript::DamageAndHealingCalcHandler const& calcDamage : script->CalcDamage)
8805 calcDamage.Call(script, victim, damage, flatMod, pctMod);
8806
8807 script->_FinishScriptCall();
8808 }
8809}
@ SPELL_SCRIPT_HOOK_CALC_DAMAGE
Definition: SpellScript.h:237
void Call(SpellScript *spellScript, Unit *victim, int32 &damageOrHealing, int32 &flatMod, float &pctMod) const
Definition: SpellScript.h:727
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ CallScriptCalcHealingHandlers()

void Spell::CallScriptCalcHealingHandlers ( Unit victim,
int32 healing,
int32 flatMod,
float &  pctMod 
)

Definition at line 8811 of file Spell.cpp.

8812{
8813 for (SpellScript* script : m_loadedScripts)
8814 {
8815 script->_PrepareScriptCall(SPELL_SCRIPT_HOOK_CALC_HEALING);
8816 for (SpellScript::DamageAndHealingCalcHandler const& calcHealing : script->CalcHealing)
8817 calcHealing.Call(script, victim, healing, flatMod, pctMod);
8818
8819 script->_FinishScriptCall();
8820 }
8821}
@ SPELL_SCRIPT_HOOK_CALC_HEALING
Definition: SpellScript.h:238
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ CallScriptCheckCastHandlers()

SpellCastResult Spell::CallScriptCheckCastHandlers ( )
protected

Definition at line 8663 of file Spell.cpp.

8664{
8666 for (SpellScript* script : m_loadedScripts)
8667 {
8668 script->_PrepareScriptCall(SPELL_SCRIPT_HOOK_CHECK_CAST);
8669 for (SpellScript::CheckCastHandler const& checkCast : script->OnCheckCast)
8670 {
8671 SpellCastResult tempResult = checkCast.Call(script);
8672 if (retVal == SPELL_CAST_OK)
8673 retVal = tempResult;
8674 }
8675
8676 script->_FinishScriptCall();
8677 }
8678 return retVal;
8679}
@ SPELL_SCRIPT_HOOK_CHECK_CAST
Definition: SpellScript.h:231
SpellCastResult Call(SpellScript *spellScript) const
Definition: SpellScript.h:328
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ CallScriptDestinationTargetSelectHandlers()

void Spell::CallScriptDestinationTargetSelectHandlers ( SpellDestination target,
SpellEffIndex  effIndex,
SpellImplicitTargetInfo const &  targetType 
)
protected

Definition at line 8849 of file Spell.cpp.

8850{
8851 for (SpellScript* script : m_loadedScripts)
8852 {
8853 script->_PrepareScriptCall(SPELL_SCRIPT_HOOK_DESTINATION_TARGET_SELECT);
8854 for (SpellScript::DestinationTargetSelectHandler const& destinationTargetSelect : script->OnDestinationTargetSelect)
8855 if (destinationTargetSelect.IsEffectAffected(m_spellInfo, effIndex) && targetType.GetTarget() == destinationTargetSelect.GetTarget())
8856 destinationTargetSelect.Call(script, target);
8857
8858 script->_FinishScriptCall();
8859 }
8860}
@ SPELL_SCRIPT_HOOK_DESTINATION_TARGET_SELECT
Definition: SpellScript.h:230
bool IsEffectAffected(SpellInfo const *spellInfo, uint8 effIndex) const
void Call(SpellScript *spellScript, SpellDestination &target) const
Definition: SpellScript.h:675
uint16 GetTarget() const
Definition: SpellScript.h:518
+ 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

Definition at line 8692 of file Spell.cpp.

8693{
8694 // execute script effect handler hooks and check if effects was prevented
8695 bool preventDefault = false;
8696 for (SpellScript* script : m_loadedScripts)
8697 {
8698 script->_InitHit();
8699
8701 SpellScriptHookType hookType;
8702 switch (mode)
8703 {
8705 effectHandlers = Trinity::Containers::MakeIteratorPair(script->OnEffectLaunch.begin(), script->OnEffectLaunch.end());
8707 break;
8709 effectHandlers = Trinity::Containers::MakeIteratorPair(script->OnEffectLaunchTarget.begin(), script->OnEffectLaunchTarget.end());
8711 break;
8713 effectHandlers = Trinity::Containers::MakeIteratorPair(script->OnEffectHit.begin(), script->OnEffectHit.end());
8715 break;
8717 effectHandlers = Trinity::Containers::MakeIteratorPair(script->OnEffectHitTarget.begin(), script->OnEffectHitTarget.end());
8719 break;
8720 default:
8721 ABORT();
8722 return false;
8723 }
8724 script->_PrepareScriptCall(hookType);
8725 for (SpellScript::EffectHandler const& effectHandler : effectHandlers)
8726 // effect execution can be prevented
8727 if (!script->_IsEffectPrevented(effIndex) && effectHandler.IsEffectAffected(m_spellInfo, effIndex))
8728 effectHandler.Call(script, effIndex);
8729
8730 if (!preventDefault)
8731 preventDefault = script->_IsDefaultEffectPrevented(effIndex);
8732
8733 script->_FinishScriptCall();
8734 }
8735 return preventDefault;
8736}
#define ABORT
Definition: Errors.h:74
SpellScriptHookType
Definition: SpellScript.h:219
@ SPELL_SCRIPT_HOOK_EFFECT_HIT
Definition: SpellScript.h:222
@ SPELL_SCRIPT_HOOK_EFFECT_LAUNCH
Definition: SpellScript.h:220
@ SPELL_SCRIPT_HOOK_EFFECT_LAUNCH_TARGET
Definition: SpellScript.h:221
@ SPELL_SCRIPT_HOOK_EFFECT_HIT_TARGET
Definition: SpellScript.h:223
@ SPELL_EFFECT_HANDLE_LAUNCH_TARGET
Definition: Spell.h:239
@ SPELL_EFFECT_HANDLE_HIT_TARGET
Definition: Spell.h:241
Utility class to enable range for loop syntax for multimap.equal_range uses.
Definition: IteratorPair.h:32
constexpr IteratorPair< iterator, end_iterator > MakeIteratorPair(iterator first, end_iterator second)
Definition: IteratorPair.h:48
+ 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

Definition at line 8823 of file Spell.cpp.

8824{
8825 for (SpellScript* script : m_loadedScripts)
8826 {
8827 script->_PrepareScriptCall(SPELL_SCRIPT_HOOK_OBJECT_AREA_TARGET_SELECT);
8828 for (SpellScript::ObjectAreaTargetSelectHandler const& objectAreaTargetSelect : script->OnObjectAreaTargetSelect)
8829 if (objectAreaTargetSelect.IsEffectAffected(m_spellInfo, effIndex) && targetType.GetTarget() == objectAreaTargetSelect.GetTarget())
8830 objectAreaTargetSelect.Call(script, targets);
8831
8832 script->_FinishScriptCall();
8833 }
8834}
@ SPELL_SCRIPT_HOOK_OBJECT_AREA_TARGET_SELECT
Definition: SpellScript.h:228
void Call(SpellScript *spellScript, std::list< WorldObject * > &targets) const
Definition: SpellScript.h:569
+ 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

Definition at line 8836 of file Spell.cpp.

8837{
8838 for (SpellScript* script : m_loadedScripts)
8839 {
8840 script->_PrepareScriptCall(SPELL_SCRIPT_HOOK_OBJECT_TARGET_SELECT);
8841 for (SpellScript::ObjectTargetSelectHandler const& objectTargetSelect : script->OnObjectTargetSelect)
8842 if (objectTargetSelect.IsEffectAffected(m_spellInfo, effIndex) && targetType.GetTarget() == objectTargetSelect.GetTarget())
8843 objectTargetSelect.Call(script, target);
8844
8845 script->_FinishScriptCall();
8846 }
8847}
@ SPELL_SCRIPT_HOOK_OBJECT_TARGET_SELECT
Definition: SpellScript.h:229
void Call(SpellScript *spellScript, WorldObject *&target) const
Definition: SpellScript.h:622
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ CallScriptOnCastHandlers()

void Spell::CallScriptOnCastHandlers ( )
protected

Definition at line 8639 of file Spell.cpp.

8640{
8641 for (SpellScript* script : m_loadedScripts)
8642 {
8643 script->_PrepareScriptCall(SPELL_SCRIPT_HOOK_ON_CAST);
8644 for (SpellScript::CastHandler const& onCast : script->OnCast)
8645 onCast.Call(script);
8646
8647 script->_FinishScriptCall();
8648 }
8649}
@ SPELL_SCRIPT_HOOK_ON_CAST
Definition: SpellScript.h:233
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ CallScriptOnHitHandlers()

void Spell::CallScriptOnHitHandlers ( )
protected

Definition at line 8763 of file Spell.cpp.

8764{
8765 for (SpellScript* script : m_loadedScripts)
8766 {
8767 script->_PrepareScriptCall(SPELL_SCRIPT_HOOK_HIT);
8768 for (SpellScript::HitHandler const& onHit : script->OnHit)
8769 onHit.Call(script);
8770
8771 script->_FinishScriptCall();
8772 }
8773}
@ SPELL_SCRIPT_HOOK_HIT
Definition: SpellScript.h:226
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ CallScriptOnPrecastHandler()

void Spell::CallScriptOnPrecastHandler ( )
protected

Definition at line 8617 of file Spell.cpp.

8618{
8619 for (SpellScript* script : m_loadedScripts)
8620 {
8621 script->_PrepareScriptCall(SPELL_SCRIPT_HOOK_ON_PRECAST);
8622 script->OnPrecast();
8623 script->_FinishScriptCall();
8624 }
8625}
@ SPELL_SCRIPT_HOOK_ON_PRECAST
Definition: SpellScript.h:239
+ Here is the caller graph for this function:

◆ CallScriptOnResistAbsorbCalculateHandlers()

void Spell::CallScriptOnResistAbsorbCalculateHandlers ( DamageInfo const &  damageInfo,
uint32 resistAmount,
int32 absorbAmount 
)

Definition at line 8862 of file Spell.cpp.

8863{
8864 for (SpellScript* script : m_loadedScripts)
8865 {
8866 script->_PrepareScriptCall(SPELL_SCRIPT_HOOK_ON_RESIST_ABSORB_CALCULATION);
8867 for (SpellScript::OnCalculateResistAbsorbHandler const& calculateResistAbsorb : script->OnCalculateResistAbsorb)
8868 calculateResistAbsorb.Call(script, damageInfo, resistAmount, absorbAmount);
8869
8870 script->_FinishScriptCall();
8871 }
8872}
@ SPELL_SCRIPT_HOOK_ON_RESIST_ABSORB_CALCULATION
Definition: SpellScript.h:234
void Call(SpellScript *spellScript, DamageInfo const &damageInfo, uint32 &resistAmount, int32 &absorbAmount) const
Definition: SpellScript.h:779
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ CallScriptSuccessfulDispel()

void Spell::CallScriptSuccessfulDispel ( SpellEffIndex  effIndex)
protected

Definition at line 8738 of file Spell.cpp.

8739{
8740 for (SpellScript* script : m_loadedScripts)
8741 {
8742 script->_PrepareScriptCall(SPELL_SCRIPT_HOOK_EFFECT_SUCCESSFUL_DISPEL);
8743 for (SpellScript::EffectHandler const& onDispel : script->OnEffectSuccessfulDispel)
8744 onDispel.Call(script, effIndex);
8745
8746 script->_FinishScriptCall();
8747 }
8748}
@ SPELL_SCRIPT_HOOK_EFFECT_SUCCESSFUL_DISPEL
Definition: SpellScript.h:224
void Call(SpellScript *spellScript, SpellEffIndex effIndex) const
Definition: SpellScript.h:378
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ CanAutoCast()

bool Spell::CanAutoCast ( Unit target)

Definition at line 7078 of file Spell.cpp.

7079{
7080 if (!target)
7081 return (CheckPetCast(target) == SPELL_CAST_OK);
7082
7083 ObjectGuid targetguid = target->GetGUID();
7084
7085 // check if target already has the same or a more powerful aura
7086 for (SpellEffectInfo const& spellEffectInfo : m_spellInfo->GetEffects())
7087 {
7088 if (!spellEffectInfo.IsAura())
7089 continue;
7090
7091 AuraType const& auraType = spellEffectInfo.ApplyAuraName;
7092 Unit::AuraEffectList const& auras = target->GetAuraEffectsByType(auraType);
7093 for (Unit::AuraEffectList::const_iterator auraIt = auras.begin(); auraIt != auras.end(); ++auraIt)
7094 {
7095 if (GetSpellInfo()->Id == (*auraIt)->GetSpellInfo()->Id)
7096 return false;
7097
7098 switch (sSpellMgr->CheckSpellGroupStackRules(GetSpellInfo(), (*auraIt)->GetSpellInfo()))
7099 {
7101 return false;
7103 if (GetCaster() == (*auraIt)->GetCaster())
7104 return false;
7105 break;
7106 case SPELL_GROUP_STACK_RULE_EXCLUSIVE_SAME_EFFECT: // this one has further checks, but i don't think they're necessary for autocast logic
7108 if (abs(spellEffectInfo.CalcBaseValue(m_caster, target, 0, -1)) <= abs((*auraIt)->GetAmount()))
7109 return false;
7110 break;
7112 default:
7113 break;
7114 }
7115 }
7116 }
7117
7118 SpellCastResult result = CheckPetCast(target);
7119 if (result == SPELL_CAST_OK || result == SPELL_FAILED_UNIT_NOT_INFRONT)
7120 {
7121 // do not check targets for ground-targeted spells (we target them on top of the intended target anyway)
7122 if (GetSpellInfo()->ExplicitTargetMask & TARGET_FLAG_DEST_LOCATION)
7123 return true;
7125 //check if among target units, our WANTED target is as well (->only self cast spells return false)
7126 for (auto ihit = m_UniqueTargetInfo.begin(); ihit != m_UniqueTargetInfo.end(); ++ihit)
7127 if (ihit->TargetGUID == targetguid)
7128 return true;
7129 }
7130 // either the cast failed or the intended target wouldn't be hit
7131 return false;
7132}
@ SPELL_FAILED_UNIT_NOT_INFRONT
AuraType
@ TARGET_FLAG_DEST_LOCATION
Definition: SpellDefines.h:286
@ SPELL_GROUP_STACK_RULE_EXCLUSIVE_FROM_SAME_CASTER
Definition: SpellMgr.h:383
@ SPELL_GROUP_STACK_RULE_EXCLUSIVE
Definition: SpellMgr.h:382
@ SPELL_GROUP_STACK_RULE_DEFAULT
Definition: SpellMgr.h:381
@ SPELL_GROUP_STACK_RULE_EXCLUSIVE_SAME_EFFECT
Definition: SpellMgr.h:384
@ SPELL_GROUP_STACK_RULE_EXCLUSIVE_HIGHEST
Definition: SpellMgr.h:385
uint32 Id
Definition: Spell.h:581
WorldObject * GetCaster() const
Definition: Spell.h:637
SpellCastResult CheckPetCast(Unit *target)
Definition: Spell.cpp:6774
AuraEffectList const & GetAuraEffectsByType(AuraType type) const
Definition: Unit.h:1428
std::forward_list< AuraEffect * > AuraEffectList
Definition: Unit.h:764
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ cancel()

void Spell::cancel ( )

Definition at line 3583 of file Spell.cpp.

3584{
3586 return;
3587
3588 uint32 oldState = m_spellState;
3590
3591 m_autoRepeat = false;
3592 switch (oldState)
3593 {
3596 [[fallthrough]];
3598 SendInterrupted(0);
3600 break;
3601
3603 for (TargetInfo const& targetInfo : m_UniqueTargetInfo)
3604 if (targetInfo.MissCondition == SPELL_MISS_NONE)
3605 if (Unit* unit = m_caster->GetGUID() == targetInfo.TargetGUID ? m_caster->ToUnit() : ObjectAccessor::GetUnit(*m_caster, targetInfo.TargetGUID))
3606 unit->RemoveOwnedAura(m_spellInfo->Id, m_originalCasterGUID, 0, AURA_REMOVE_BY_CANCEL);
3607
3609 SendInterrupted(0);
3611
3612 m_appliedMods.clear();
3613 break;
3614
3615 default:
3616 break;
3617 }
3618
3620 if (m_selfContainer && *m_selfContainer == this)
3621 *m_selfContainer = nullptr;
3622
3623 // originalcaster handles gameobjects/dynobjects for gob caster
3624 if (m_originalCaster)
3625 {
3627 if (m_spellInfo->IsChanneled()) // if not channeled then the object for the current cast wasn't summoned yet
3629 }
3630
3631 //set state back so finish will be processed
3632 m_spellState = oldState;
3633
3635}
@ AURA_REMOVE_BY_CANCEL
@ SPELL_STATE_PREPARING
Definition: Spell.h:229
@ SPELL_STATE_CASTING
Definition: Spell.h:230
void SendChannelUpdate(uint32 time)
Definition: Spell.cpp:5182
void CancelGlobalCooldown()
Definition: Spell.cpp:9011
void SetReferencedFromCurrent(bool yes)
Definition: Spell.h:620
UsedSpellMods m_appliedMods
Definition: Spell.h:601
void RemoveGameObject(GameObject *gameObj, bool del)
Definition: Unit.cpp:5149
void RemoveDynObject(uint32 spellId)
Definition: Unit.cpp:5089
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ CancelGlobalCooldown()

void Spell::CancelGlobalCooldown ( )
protected

Definition at line 9011 of file Spell.cpp.

9012{
9014 return;
9015
9017 return;
9018
9019 // Cancel global cooldown when interrupting current cast
9021 return;
9022
9024}
bool CanHaveGlobalCooldown(WorldObject const *caster)
Definition: Spell.cpp:8943
@ CURRENT_GENERIC_SPELL
Definition: Unit.h:587
void CancelGlobalCooldown(SpellInfo const *spellInfo)
uint32 StartRecoveryTime
Definition: SpellInfo.h:369
Spell * GetCurrentSpell(CurrentSpellTypes spellType) const
Definition: Unit.h:1549
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ CanExecuteTriggersOnHit()

bool Spell::CanExecuteTriggersOnHit ( Unit unit,
SpellInfo const *  triggeredByAura = nullptr 
) const
protected

Definition at line 8895 of file Spell.cpp.

8896{
8897 bool onlyOnTarget = (triggeredByAura && (triggeredByAura->HasAttribute(SPELL_ATTR4_CLASS_TRIGGER_ONLY_ON_TARGET)));
8898 if (!onlyOnTarget)
8899 return true;
8900
8901 // If triggeredByAura has SPELL_ATTR4_CLASS_TRIGGER_ONLY_ON_TARGET then it can only proc on either noncaster units...
8902 if (unit != m_caster)
8903 return true;
8904
8905 // ... or caster if it is the only target
8906 if (m_UniqueTargetInfo.size() == 1)
8907 return true;
8908
8909 return false;
8910}
@ SPELL_ATTR4_CLASS_TRIGGER_ONLY_ON_TARGET
+ 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

Definition at line 8484 of file Spell.cpp.

8485{
8486 if (!lockId) // possible case for GO and maybe for items.
8487 return SPELL_CAST_OK;
8488
8489 Unit const* unitCaster = m_caster->ToUnit();
8490 if (!unitCaster)
8492
8493 // Get LockInfo
8494 LockEntry const* lockInfo = sLockStore.LookupEntry(lockId);
8495
8496 if (!lockInfo)
8498
8499 bool reqKey = false; // some locks not have reqs
8500
8501 for (int j = 0; j < MAX_LOCK_CASE; ++j)
8502 {
8503 switch (lockInfo->Type[j])
8504 {
8505 // check key item (many fit cases can be)
8506 case LOCK_KEY_ITEM:
8507 if (lockInfo->Index[j] && m_CastItem && int32(m_CastItem->GetEntry()) == lockInfo->Index[j])
8508 return SPELL_CAST_OK;
8509 reqKey = true;
8510 break;
8511 // check key skill (only single first fit case can be)
8512 case LOCK_KEY_SKILL:
8513 {
8514 reqKey = true;
8515
8516 // wrong locktype, skip
8517 if (effect.MiscValue != lockInfo->Index[j])
8518 continue;
8519
8520 skillId = SkillByLockType(LockType(lockInfo->Index[j]));
8521
8522 if (skillId != SKILL_NONE || lockInfo->Index[j] == LOCKTYPE_LOCKPICKING)
8523 {
8524 reqSkillValue = lockInfo->Skill[j];
8525
8526 // castitem check: rogue using skeleton keys. the skill values should not be added in this case.
8527 skillValue = 0;
8528 if (!m_CastItem && unitCaster->GetTypeId() == TYPEID_PLAYER)
8529 skillValue = unitCaster->ToPlayer()->GetSkillValue(skillId);
8530 else if (lockInfo->Index[j] == LOCKTYPE_LOCKPICKING)
8531 skillValue = unitCaster->GetLevel() * 5;
8532
8533 // skill bonus provided by casting spell (mostly item spells)
8534 // add the effect base points modifier from the spell cast (cheat lock / skeleton key etc.)
8535 if (effect.TargetA.GetTarget() == TARGET_GAMEOBJECT_ITEM_TARGET || effect.TargetB.GetTarget() == TARGET_GAMEOBJECT_ITEM_TARGET)
8536 skillValue += effect.CalcValue();
8537
8538 if (skillValue < reqSkillValue)
8540 }
8541
8542 return SPELL_CAST_OK;
8543 }
8544 case LOCK_KEY_SPELL:
8545 if (m_spellInfo->Id == uint32(lockInfo->Index[j]))
8546 return SPELL_CAST_OK;
8547 reqKey = true;
8548 break;
8549 }
8550 }
8551
8552 if (reqKey)
8554
8555 return SPELL_CAST_OK;
8556}
DB2Storage< LockEntry > sLockStore("Lock.db2", &LockLoadInfo::Instance)
#define MAX_LOCK_CASE
@ TARGET_GAMEOBJECT_ITEM_TARGET
LockType
@ LOCKTYPE_LOCKPICKING
@ LOCK_KEY_ITEM
@ LOCK_KEY_SKILL
@ LOCK_KEY_SPELL
@ SPELL_FAILED_BAD_TARGETS
@ SPELL_FAILED_LOW_CASTLEVEL
constexpr SkillType SkillByLockType(LockType locktype)
@ SKILL_NONE
uint16 GetSkillValue(uint32 skill) const
Definition: Player.cpp:6103
uint8 GetLevel() const
Definition: Unit.h:866
std::array< uint8, MAX_LOCK_CASE > Type
std::array< uint16, MAX_LOCK_CASE > Skill
std::array< int32, MAX_LOCK_CASE > Index
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ cast()

void Spell::cast ( bool  skipCheck = false)

Definition at line 3637 of file Spell.cpp.

3638{
3639 Player* modOwner = m_caster->GetSpellModOwner();
3640 Spell* lastSpellMod = nullptr;
3641 if (modOwner)
3642 {
3643 lastSpellMod = modOwner->m_spellModTakingSpell;
3644 if (lastSpellMod)
3645 modOwner->SetSpellModTakingSpell(lastSpellMod, false);
3646 }
3647
3648 _cast(skipCheck);
3649
3650 if (lastSpellMod)
3651 modOwner->SetSpellModTakingSpell(lastSpellMod, true);
3652}
Definition: Spell.h:249
void _cast(bool skipCheck=false)
Definition: Spell.cpp:3654
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ CheckArenaAndRatedBattlegroundCastRules()

SpellCastResult Spell::CheckArenaAndRatedBattlegroundCastRules ( )

Definition at line 7011 of file Spell.cpp.

7012{
7013 bool isRatedBattleground = false; // NYI
7014 bool isArena = !isRatedBattleground;
7015
7016 // check USABLE attributes
7017 // USABLE takes precedence over NOT_USABLE
7019 return SPELL_CAST_OK;
7020
7022 return SPELL_CAST_OK;
7023
7024 // check NOT_USABLE attributes
7027
7030
7031 // check cooldowns
7032 uint32 spellCooldown = m_spellInfo->GetRecoveryTime();
7033 if (isArena && spellCooldown > 10 * MINUTE * IN_MILLISECONDS) // not sure if still needed
7035
7036 if (isRatedBattleground && spellCooldown > 15 * MINUTE * IN_MILLISECONDS)
7038
7039 return SPELL_CAST_OK;
7040}
@ IN_MILLISECONDS
Definition: Common.h:35
@ MINUTE
Definition: Common.h:29
@ SPELL_ATTR9_USABLE_IN_RATED_BATTLEGROUNDS
@ SPELL_ATTR9_NOT_USABLE_IN_ARENA
@ SPELL_FAILED_NOT_IN_RATED_BATTLEGROUND
@ SPELL_FAILED_NOT_IN_ARENA
@ SPELL_ATTR4_IGNORE_DEFAULT_ARENA_RESTRICTIONS
@ SPELL_ATTR4_NOT_IN_ARENA_OR_RATED_BATTLEGROUND
uint32 GetRecoveryTime() const
Definition: SpellInfo.cpp:3994
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ CheckCast()

SpellCastResult Spell::CheckCast ( bool  strict,
int32 param1 = nullptr,
int32 param2 = nullptr 
)
Todo:
determine if there is some flag to enable/disable the check

Definition at line 5628 of file Spell.cpp.

5629{
5630 // check death state
5633
5634 // Prevent cheating in case the player has an immunity effect and tries to interact with a non-allowed gameobject. The error message is handled by the client so we don't report anything here
5636 {
5639 }
5640
5641 // check cooldowns to prevent cheating
5642 if (!m_spellInfo->IsPassive())
5643 {
5644 if (Player const* playerCaster = m_caster->ToPlayer())
5645 {
5646 //can cast triggered (by aura only?) spells while have this flag
5648 {
5649 // These two auras check SpellFamilyName defined by db2 class data instead of current spell SpellFamilyName
5650 if (playerCaster->HasAuraType(SPELL_AURA_DISABLE_CASTING_EXCEPT_ABILITIES)
5654 && !playerCaster->HasAuraTypeWithFamilyFlags(SPELL_AURA_DISABLE_CASTING_EXCEPT_ABILITIES, sChrClassesStore.AssertEntry(playerCaster->GetClass())->SpellClassSet, m_spellInfo->SpellFamilyFlags))
5656
5657 if (playerCaster->HasAuraType(SPELL_AURA_DISABLE_ATTACKING_EXCEPT_ABILITIES))
5658 {
5659 if (!playerCaster->HasAuraTypeWithFamilyFlags(SPELL_AURA_DISABLE_ATTACKING_EXCEPT_ABILITIES, sChrClassesStore.AssertEntry(playerCaster->GetClass())->SpellClassSet, m_spellInfo->SpellFamilyFlags))
5660 {
5671 }
5672 }
5673 }
5674
5675 // check if we are using a potion in combat for the 2nd+ time. Cooldown is added only after caster gets out of combat
5676 if (!IsIgnoringCooldowns() && playerCaster->GetLastPotionId() && m_CastItem && (m_CastItem->IsPotion() || m_spellInfo->IsCooldownStartedOnEvent()))
5678 }
5679
5681 {
5683 {
5686 else
5688 }
5689
5692 }
5693 }
5694
5696 {
5699 }
5700
5703
5704 // Check global cooldown
5707
5708 // only triggered spells can be processed an ended battleground
5711 if (bg->GetStatus() == STATUS_WAIT_LEAVE)
5713
5715 {
5717 !m_caster->IsOutdoors())
5719
5723 }
5724
5725 if (Unit* unitCaster = m_caster->ToUnit())
5726 {
5727 if (m_spellInfo->HasAttribute(SPELL_ATTR5_NOT_AVAILABLE_WHILE_CHARMED) && unitCaster->IsCharmed())
5728 return SPELL_FAILED_CHARMED;
5729
5730 // only check at first call, Stealth auras are already removed at second call
5731 // for now, ignore triggered spells
5733 {
5734 bool checkForm = true;
5735 // Ignore form req aura
5736 Unit::AuraEffectList const& ignore = unitCaster->GetAuraEffectsByType(SPELL_AURA_MOD_IGNORE_SHAPESHIFT);
5737 for (AuraEffect const* aurEff : ignore)
5738 {
5739 if (!aurEff->IsAffectingSpell(m_spellInfo))
5740 continue;
5741
5742 checkForm = false;
5743 break;
5744 }
5745
5746 if (checkForm)
5747 {
5748 // Cannot be used in this stance/form
5749 SpellCastResult shapeError = m_spellInfo->CheckShapeshift(unitCaster->GetShapeshiftForm());
5750 if (shapeError != SPELL_CAST_OK)
5751 return shapeError;
5752
5753 if (m_spellInfo->HasAttribute(SPELL_ATTR0_ONLY_STEALTHED) && !(unitCaster->HasStealthAura()))
5755 }
5756 }
5757
5758 // caster state requirements
5759 // not for triggered spells (needed by execute)
5761 {
5762 if (m_spellInfo->CasterAuraState && !unitCaster->HasAuraState(AuraStateType(m_spellInfo->CasterAuraState), m_spellInfo, unitCaster))
5764 if (m_spellInfo->ExcludeCasterAuraState && unitCaster->HasAuraState(AuraStateType(m_spellInfo->ExcludeCasterAuraState), m_spellInfo, unitCaster))
5766
5767 // Note: spell 62473 requres casterAuraSpell = triggering spell
5768 if (m_spellInfo->CasterAuraSpell && !unitCaster->HasAura(m_spellInfo->CasterAuraSpell))
5772
5773 if (m_spellInfo->CasterAuraType && !unitCaster->HasAuraType(m_spellInfo->CasterAuraType))
5775 if (m_spellInfo->ExcludeCasterAuraType && unitCaster->HasAuraType(m_spellInfo->ExcludeCasterAuraType))
5777
5778 if (unitCaster->IsInCombat() && !m_spellInfo->CanBeUsedInCombat(unitCaster))
5780 }
5781
5782 // Check vehicle flags
5784 {
5785 SpellCastResult vehicleCheck = m_spellInfo->CheckVehicle(unitCaster);
5786 if (vehicleCheck != SPELL_CAST_OK)
5787 return vehicleCheck;
5788 }
5789 }
5790
5791 // check spell cast conditions from database
5792 {
5794 if (!sConditionMgr->IsObjectMeetingNotGroupedConditions(CONDITION_SOURCE_TYPE_SPELL, m_spellInfo->Id, condInfo))
5795 {
5796 // mLastFailedCondition can be NULL if there was an error processing the condition in Condition::Meets (i.e. wrong data for ConditionTarget or others)
5797 if (condInfo.mLastFailedCondition && condInfo.mLastFailedCondition->ErrorType)
5798 {
5802 }
5803
5804 if (!condInfo.mLastFailedCondition || !condInfo.mLastFailedCondition->ConditionTarget)
5807 }
5808 }
5809
5810 // Don't check explicit target for passive spells (workaround) (check should be skipped only for learn case)
5811 // those spells may have incorrect target entries or not filled at all (for example 15332)
5812 // such spells when learned are not targeting anyone using targeting system, they should apply directly to caster instead
5813 // also, such casts shouldn't be sent to client
5815 {
5816 // Check explicit target for m_originalCaster - todo: get rid of such workarounds
5817 WorldObject* caster = m_caster;
5818 // in case of gameobjects like traps, we need the gameobject itself to check target validity
5819 // otherwise, if originalCaster is far away and cannot detect the target, the trap would not hit the target
5820 if (m_originalCaster && !caster->ToGameObject())
5821 caster = m_originalCaster;
5822
5824 if (castResult != SPELL_CAST_OK)
5825 return castResult;
5826 }
5827
5828 if (Unit* target = m_targets.GetUnitTarget())
5829 {
5830 SpellCastResult castResult = m_spellInfo->CheckTarget(m_caster, target, m_caster->GetTypeId() == TYPEID_GAMEOBJECT); // skip stealth checks for GO casts
5831 if (castResult != SPELL_CAST_OK)
5832 return castResult;
5833
5834 // If it's not a melee spell, check if vision is obscured by SPELL_AURA_INTERFERE_TARGETTING
5836 {
5837 if (Unit const* unitCaster = m_caster->ToUnit())
5838 {
5839 for (AuraEffect const* auraEff : unitCaster->GetAuraEffectsByType(SPELL_AURA_INTERFERE_TARGETTING))
5840 if (!unitCaster->IsFriendlyTo(auraEff->GetCaster()) && !target->HasAura(auraEff->GetId(), auraEff->GetCasterGUID()))
5842
5843 for (AuraEffect const* auraEff : target->GetAuraEffectsByType(SPELL_AURA_INTERFERE_TARGETTING))
5844 if (!unitCaster->IsFriendlyTo(auraEff->GetCaster()) && (!target->HasAura(auraEff->GetId(), auraEff->GetCasterGUID()) || !unitCaster->HasAura(auraEff->GetId(), auraEff->GetCasterGUID())))
5846 }
5847 }
5848
5849 if (target != m_caster)
5850 {
5851 // Must be behind the target
5852 if ((m_spellInfo->HasAttribute(SPELL_ATTR0_CU_REQ_CASTER_BEHIND_TARGET)) && target->HasInArc(static_cast<float>(M_PI), m_caster))
5854
5855 // Target must be facing you
5856 if ((m_spellInfo->HasAttribute(SPELL_ATTR0_CU_REQ_TARGET_FACING_CASTER)) && !target->HasInArc(static_cast<float>(M_PI), m_caster))
5858
5859 // Ignore LOS for gameobjects casts
5861 {
5862 WorldObject* losTarget = m_caster;
5865 losTarget = dynObj;
5866
5867 if (!IsWithinLOS(losTarget, target, true, VMAP::ModelIgnoreFlags::M2))
5869 }
5870 }
5871 }
5872
5873 // Check for line of sight for spells with dest
5874 if (m_targets.HasDst())
5877
5878 // check pet presence
5879 if (Unit* unitCaster = m_caster->ToUnit())
5880 {
5882 if (!unitCaster->GetPetGUID().IsEmpty())
5884
5885 for (SpellEffectInfo const& spellEffectInfo : m_spellInfo->GetEffects())
5886 {
5887 if (spellEffectInfo.TargetA.GetTarget() == TARGET_UNIT_PET)
5888 {
5889 if (!unitCaster->GetGuardianPet())
5890 {
5891 if (m_triggeredByAuraSpell) // not report pet not existence for triggered spells
5893 else
5894 return SPELL_FAILED_NO_PET;
5895 }
5896 break;
5897 }
5898 }
5899 }
5900
5901 // Spell cast only in battleground
5903 if (!m_caster->GetMap()->IsBattleground())
5905
5906 // do not allow spells to be cast in arenas or rated battlegrounds
5907 if (Player* player = m_caster->ToPlayer())
5908 if (player->InArena()/* || player->InRatedBattleGround() NYI*/)
5909 {
5911 if (castResult != SPELL_CAST_OK)
5912 return castResult;
5913 }
5914
5915 // zone check
5917 {
5918 uint32 zone, area;
5919 m_caster->GetZoneAndAreaId(zone, area);
5920
5922 if (locRes != SPELL_CAST_OK)
5923 return locRes;
5924 }
5925
5926 // not let players cast spells at mount (and let do it to creatures)
5928 {
5930 {
5931 if (m_caster->ToPlayer()->IsInFlight())
5933 else
5935 }
5936 }
5937
5938 // check spell focus object
5940 {
5942 {
5944 if (!focusObject)
5946 }
5947 }
5948
5949 SpellCastResult castResult = SPELL_CAST_OK;
5950
5951 // always (except passive spells) check items (only player related checks)
5952 if (!m_spellInfo->IsPassive())
5953 {
5954 castResult = CheckItems(param1, param2);
5955 if (castResult != SPELL_CAST_OK)
5956 return castResult;
5957 }
5958
5959 // Triggered spells also have range check
5961 castResult = CheckRange(strict);
5962 if (castResult != SPELL_CAST_OK)
5963 return castResult;
5964
5966 {
5967 castResult = CheckPower();
5968 if (castResult != SPELL_CAST_OK)
5969 return castResult;
5970 }
5971
5973 {
5974 castResult = CheckCasterAuras(param1);
5975 if (castResult != SPELL_CAST_OK)
5976 return castResult;
5977 }
5978
5979 // script hook
5980 castResult = CallScriptCheckCastHandlers();
5981 if (castResult != SPELL_CAST_OK)
5982 return castResult;
5983
5984 uint32 approximateAuraEffectMask = 0;
5985 uint32 nonAuraEffectMask = 0;
5986 for (SpellEffectInfo const& spellEffectInfo : m_spellInfo->GetEffects())
5987 {
5988 // for effects of spells that have only one target
5989 switch (spellEffectInfo.Effect)
5990 {
5991 case SPELL_EFFECT_DUMMY:
5992 {
5993 if (m_spellInfo->Id == 19938) // Awaken Peon
5994 {
5995 Unit* unit = m_targets.GetUnitTarget();
5996 if (!unit || !unit->HasAura(17743))
5998 }
5999 else if (m_spellInfo->Id == 31789) // Righteous Defense
6000 {
6003
6004 Unit* target = m_targets.GetUnitTarget();
6005 if (!target || !target->IsFriendlyTo(m_caster) || target->getAttackers().empty())
6007
6008 }
6009 break;
6010 }
6012 {
6013 if (spellEffectInfo.TargetA.GetTarget() != TARGET_UNIT_PET)
6014 break;
6015
6016 Pet* pet = m_caster->ToPlayer()->GetPet();
6017 if (!pet)
6018 return SPELL_FAILED_NO_PET;
6019
6020 SpellInfo const* learn_spellproto = sSpellMgr->GetSpellInfo(spellEffectInfo.TriggerSpell, DIFFICULTY_NONE);
6021 if (!learn_spellproto)
6023
6024 if (m_spellInfo->SpellLevel > pet->GetLevel())
6025 return SPELL_FAILED_LOWLEVEL;
6026
6027 break;
6028 }
6030 {
6033 if (Guild* guild = m_caster->ToPlayer()->GetGuild())
6034 if (guild->GetLeaderGUID() != m_caster->ToPlayer()->GetGUID())
6036 break;
6037 }
6039 {
6040 // check target only for unit target case
6041 if (Unit* unit = m_targets.GetUnitTarget())
6042 {
6045
6046 Pet* pet = unit->ToPet();
6047 if (!pet || pet->GetOwner() != m_caster)
6049
6050 SpellInfo const* learn_spellproto = sSpellMgr->GetSpellInfo(spellEffectInfo.TriggerSpell, DIFFICULTY_NONE);
6051
6052 if (!learn_spellproto)
6054
6055 if (m_spellInfo->SpellLevel > pet->GetLevel())
6056 return SPELL_FAILED_LOWLEVEL;
6057 }
6058 break;
6059 }
6061 {
6064
6065 Player* caster = m_caster->ToPlayer();
6066 if (!caster->HasSpell(m_misc.SpellId))
6068
6069 if (uint32 glyphId = spellEffectInfo.MiscValue)
6070 {
6071 GlyphPropertiesEntry const* glyphProperties = sGlyphPropertiesStore.LookupEntry(glyphId);
6072 if (!glyphProperties)
6074
6075 std::vector<uint32> const* glyphBindableSpells = sDB2Manager.GetGlyphBindableSpells(glyphId);
6076 if (!glyphBindableSpells)
6078
6079 if (std::find(glyphBindableSpells->begin(), glyphBindableSpells->end(), m_misc.SpellId) == glyphBindableSpells->end())
6081
6082 if (std::vector<ChrSpecialization> const* glyphRequiredSpecs = sDB2Manager.GetGlyphRequiredSpecs(glyphId))
6083 {
6084 if (caster->GetPrimarySpecialization() == ChrSpecialization::None)
6086
6087 if (std::find(glyphRequiredSpecs->begin(), glyphRequiredSpecs->end(), caster->GetPrimarySpecialization()) == glyphRequiredSpecs->end())
6089 }
6090
6091 uint32 replacedGlyph = 0;
6092 for (uint32 activeGlyphId : caster->GetGlyphs(caster->GetActiveTalentGroup()))
6093 {
6094 if (std::vector<uint32> const* activeGlyphBindableSpells = sDB2Manager.GetGlyphBindableSpells(activeGlyphId))
6095 {
6096 if (std::find(activeGlyphBindableSpells->begin(), activeGlyphBindableSpells->end(), m_misc.SpellId) != activeGlyphBindableSpells->end())
6097 {
6098 replacedGlyph = activeGlyphId;
6099 break;
6100 }
6101 }
6102 }
6103
6104 for (uint32 activeGlyphId : caster->GetGlyphs(caster->GetActiveTalentGroup()))
6105 {
6106 if (activeGlyphId == replacedGlyph)
6107 continue;
6108
6109 if (activeGlyphId == glyphId)
6111
6112 if (sGlyphPropertiesStore.AssertEntry(activeGlyphId)->GlyphExclusiveCategoryID == glyphProperties->GlyphExclusiveCategoryID)
6114 }
6115 }
6116 break;
6117 }
6119 {
6122
6123 Item* foodItem = m_targets.GetItemTarget();
6124 if (!foodItem)
6126
6127 Pet* pet = m_caster->ToPlayer()->GetPet();
6128 if (!pet)
6129 return SPELL_FAILED_NO_PET;
6130
6131 if (!pet->HaveInDiet(foodItem->GetTemplate()))
6133
6134 if (foodItem->GetTemplate()->GetBaseItemLevel() + 30 <= pet->GetLevel())
6136
6137 if (m_caster->ToPlayer()->IsInCombat() || pet->IsInCombat())
6139
6140 break;
6141 }
6143 {
6144 Unit* unitCaster = m_caster->ToUnit();
6145 if (!unitCaster)
6147
6149 return SPELL_FAILED_ROOTED;
6150
6151 if (GetSpellInfo()->NeedsExplicitUnitTarget())
6152 {
6153 Unit* target = m_targets.GetUnitTarget();
6154 if (!target)
6156
6157 // first we must check to see if the target is in LoS. A path can usually be built but LoS matters for charge spells
6158 if (!IsWithinLOS(unitCaster, target, true, VMAP::ModelIgnoreFlags::Nothing)) //Do full LoS/Path check. Don't exclude m2
6160
6161 float objSize = target->GetCombatReach();
6162 float range = m_spellInfo->GetMaxRange(true, unitCaster, this) * 1.5f + objSize; // can't be overly strict
6163
6164 m_preGeneratedPath = std::make_unique<PathGenerator>(unitCaster);
6165 m_preGeneratedPath->SetPathLengthLimit(range);
6166
6167 // first try with raycast, if it fails fall back to normal path
6168 bool result = m_preGeneratedPath->CalculatePath(target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), false);
6169 if (m_preGeneratedPath->GetPathType() & PATHFIND_SHORT)
6170 return SPELL_FAILED_NOPATH;
6171 else if (!result || m_preGeneratedPath->GetPathType() & (PATHFIND_NOPATH | PATHFIND_INCOMPLETE))
6172 return SPELL_FAILED_NOPATH;
6173 else if (m_preGeneratedPath->IsInvalidDestinationZ(target)) // Check position z, if not in a straight line
6174 return SPELL_FAILED_NOPATH;
6175
6176 m_preGeneratedPath->ShortenPathUntilDist(PositionToVector3(target), objSize); // move back
6177 }
6178 break;
6179 }
6181 {
6184
6187
6188 Creature* creature = m_targets.GetUnitTarget()->ToCreature();
6189 Loot* loot = creature->GetLootForPlayer(m_caster->ToPlayer());
6190 if (loot && (!loot->isLooted() || loot->loot_type == LOOT_SKINNING))
6192
6193 break;
6194 }
6196 {
6197 if (spellEffectInfo.TargetA.GetTarget() != TARGET_GAMEOBJECT_TARGET &&
6198 spellEffectInfo.TargetA.GetTarget() != TARGET_GAMEOBJECT_ITEM_TARGET)
6199 break;
6200
6201 if (m_caster->GetTypeId() != TYPEID_PLAYER // only players can open locks, gather etc.
6202 // we need a go target in case of TARGET_GAMEOBJECT_TARGET
6203 || (spellEffectInfo.TargetA.GetTarget() == TARGET_GAMEOBJECT_TARGET && !m_targets.GetGOTarget()))
6205
6206 Item* pTempItem = nullptr;
6208 {
6209 if (TradeData* pTrade = m_caster->ToPlayer()->GetTradeData())
6210 pTempItem = pTrade->GetTraderData()->GetItem(TRADE_SLOT_NONTRADED);
6211 }
6214
6215 // we need a go target, or an openable item target in case of TARGET_GAMEOBJECT_ITEM_TARGET
6216 if (spellEffectInfo.TargetA.GetTarget() == TARGET_GAMEOBJECT_ITEM_TARGET &&
6218 (!pTempItem || !pTempItem->GetTemplate()->GetLockID() || !pTempItem->IsLocked()))
6220
6221 if (m_spellInfo->Id != 1842 || (m_targets.GetGOTarget() &&
6223 if (m_caster->ToPlayer()->InBattleground() && // In Battleground players can use only flags and banners
6226
6227 // get the lock entry
6228 uint32 lockId = 0;
6229 if (GameObject* go = m_targets.GetGOTarget())
6230 {
6231 lockId = go->GetGOInfo()->GetLockId();
6232 if (!lockId)
6234
6235 if (go->GetGOInfo()->GetNotInCombat() && m_caster->ToUnit()->IsInCombat())
6237 }
6238 else if (Item* itm = m_targets.GetItemTarget())
6239 lockId = itm->GetTemplate()->GetLockID();
6240
6241 SkillType skillId = SKILL_NONE;
6242 int32 reqSkillValue = 0;
6243 int32 skillValue = 0;
6244
6245 // check lock compatibility
6246 SpellCastResult res = CanOpenLock(spellEffectInfo, lockId, skillId, reqSkillValue, skillValue);
6247 if (res != SPELL_CAST_OK)
6248 return res;
6249 break;
6250 }
6252 {
6253 Player* playerCaster = m_caster->ToPlayer();
6254 if (!playerCaster || !playerCaster->GetPetStable())
6256
6257 Pet* pet = playerCaster->GetPet();
6258 if (pet && pet->IsAlive())
6260
6261 PetStable const* petStable = playerCaster->GetPetStable();
6262 auto deadPetItr = std::find_if(petStable->ActivePets.begin(), petStable->ActivePets.end(), [](Optional<PetStable::PetInfo> const& petInfo)
6263 {
6264 return petInfo && !petInfo->Health;
6265 });
6266
6267 if (deadPetItr == petStable->ActivePets.end())
6269
6270 break;
6271 }
6272 // This is generic summon effect
6274 {
6275 Unit* unitCaster = m_caster->ToUnit();
6276 if (!unitCaster)
6277 break;
6278
6279 SummonPropertiesEntry const* SummonProperties = sSummonPropertiesStore.LookupEntry(spellEffectInfo.MiscValueB);
6280 if (!SummonProperties)
6281 break;
6282
6283 switch (SummonProperties->Control)
6284 {
6288 [[fallthrough]]; // check both GetPetGUID() and GetCharmGUID for SUMMON_CATEGORY_PET
6290 if (!unitCaster->GetCharmedGUID().IsEmpty())
6292 break;
6293 }
6294 break;
6295 }
6297 {
6299 {
6304 }
6305 break;
6306 }
6308 {
6309 Unit* unitCaster = m_caster->ToUnit();
6310 if (!unitCaster)
6312
6313 if (!unitCaster->GetPetGUID().IsEmpty()) //let warlock do a replacement summon
6314 {
6315 if (unitCaster->GetTypeId() == TYPEID_PLAYER)
6316 {
6317 if (strict) //starting cast, trigger pet stun (cast by pet so it doesn't attack player)
6318 if (Pet* pet = unitCaster->ToPlayer()->GetPet())
6320 .SetOriginalCaster(pet->GetGUID())
6321 .SetTriggeringSpell(this));
6322 }
6325 }
6326
6327 if (!unitCaster->GetCharmedGUID().IsEmpty())
6329
6330 Player* playerCaster = unitCaster->ToPlayer();
6331 if (playerCaster && playerCaster->GetPetStable())
6332 {
6333 Optional<PetSaveMode> petSlot;
6334 if (!spellEffectInfo.MiscValue)
6335 {
6336 petSlot = PetSaveMode(spellEffectInfo.CalcValue());
6337
6338 // No pet can be summoned if any pet is dead
6339 for (Optional<PetStable::PetInfo> const& activePet : playerCaster->GetPetStable()->ActivePets)
6340 {
6341 if (activePet && !activePet->Health)
6342 {
6343 playerCaster->SendTameFailure(PetTameResult::Dead);
6345 }
6346 }
6347 }
6348
6349 std::pair<PetStable::PetInfo const*, PetSaveMode> info = Pet::GetLoadPetInfo(*playerCaster->GetPetStable(), spellEffectInfo.MiscValue, 0, petSlot);
6350 if (info.first)
6351 {
6352 if (info.first->Type == HUNTER_PET)
6353 {
6354 CreatureTemplate const* creatureInfo = sObjectMgr->GetCreatureTemplate(info.first->CreatureId);
6355 CreatureDifficulty const* creatureDifficulty = creatureInfo->GetDifficulty(DIFFICULTY_NONE);
6356 if (!creatureInfo || !creatureInfo->IsTameable(playerCaster->CanTameExoticPets(), creatureDifficulty))
6357 {
6358 // if problem in exotic pet
6359 if (creatureInfo && creatureInfo->IsTameable(true, creatureDifficulty))
6360 playerCaster->SendTameFailure(PetTameResult::CantControlExotic);
6361 else
6362 playerCaster->SendTameFailure(PetTameResult::NoPetAvailable);
6363
6365 }
6366 }
6367 }
6368 else if (!spellEffectInfo.MiscValue) // when miscvalue is present it is allowed to create new pets
6369 {
6370 playerCaster->SendTameFailure(PetTameResult::NoPetAvailable);
6372 }
6373 }
6374
6375 break;
6376 }
6378 {
6379 Player* playerCaster = m_caster->ToPlayer();
6380 if (!playerCaster)
6382
6383 Pet* pet = playerCaster->GetPet();
6384 if (!pet)
6385 return SPELL_FAILED_NO_PET;
6386
6387 if (!pet->IsAlive())
6389
6390 break;
6391 }
6393 {
6396
6397 if (!m_caster->ToPlayer()->GetTarget())
6399
6401 if (!target || m_caster->ToPlayer() == target || (!target->IsInSameRaidWith(m_caster->ToPlayer()) && m_spellInfo->Id != 48955)) // refer-a-friend spell
6403
6404 if (target->HasSummonPending())
6406
6407 // check if our map is dungeon
6408 if (InstanceMap const* map = m_caster->GetMap()->ToInstanceMap())
6409 {
6410 uint32 mapId = map->GetId();
6411 Difficulty difficulty = map->GetDifficultyID();
6412 if (InstanceLock const* mapLock = map->GetInstanceLock())
6413 if (sInstanceLockMgr.CanJoinInstanceLock(target->GetGUID(), { mapId, difficulty }, mapLock) != TRANSFER_ABORT_NONE)
6415
6416 if (!target->Satisfy(sObjectMgr->GetAccessRequirement(mapId, difficulty), mapId))
6418 }
6419 break;
6420 }
6421 // RETURN HERE
6423 {
6426
6427 Player* playerCaster = m_caster->ToPlayer();
6428 if (!playerCaster->GetTarget())
6430
6431 Player* target = playerCaster->GetSelectedPlayer();
6432 if (!target ||
6433 !(target->GetSession()->GetRecruiterId() == playerCaster->GetSession()->GetAccountId() || target->GetSession()->GetAccountId() == playerCaster->GetSession()->GetRecruiterId()))
6435 break;
6436 }
6437 case SPELL_EFFECT_LEAP:
6439 {
6440 //Do not allow to cast it before BG starts.
6442 if (Battleground const* bg = m_caster->ToPlayer()->GetBattleground())
6443 if (bg->GetStatus() != STATUS_IN_PROGRESS)
6445 break;
6446 }
6448 {
6451 break;
6452 }
6454 {
6455 Unit* unitCaster = m_caster->ToUnit();
6456 if (!unitCaster)
6458
6459 if (unitCaster->HasUnitState(UNIT_STATE_ROOT))
6460 {
6461 if (unitCaster->GetTypeId() == TYPEID_PLAYER)
6462 return SPELL_FAILED_ROOTED;
6463 else
6465 }
6466 break;
6467 }
6468 case SPELL_EFFECT_JUMP:
6470 {
6471 Unit* unitCaster = m_caster->ToUnit();
6472 if (!unitCaster)
6474
6475 if (unitCaster->HasUnitState(UNIT_STATE_ROOT))
6476 return SPELL_FAILED_ROOTED;
6477 break;
6478 }
6480 {
6481 ChrSpecializationEntry const* spec = sChrSpecializationStore.LookupEntry(m_misc.SpecializationId);
6482 Player* player = m_caster->ToPlayer();
6483 if (!player)
6485
6486 if (!spec || (spec->ClassID != player->GetClass() && !spec->IsPetSpecialization()))
6487 return SPELL_FAILED_NO_SPEC;
6488
6489 if (spec->IsPetSpecialization())
6490 {
6491 Pet* pet = player->GetPet();
6492 if (!pet || pet->getPetType() != HUNTER_PET || !pet->GetCharmInfo())
6493 return SPELL_FAILED_NO_PET;
6494 }
6495
6496 // can't change during already started arena/battleground
6497 if (Battleground const* bg = player->GetBattleground())
6498 if (bg->GetStatus() == STATUS_IN_PROGRESS)
6500 break;
6501 }
6503 {
6504 Player* playerCaster = m_caster->ToPlayer();
6505 if (!playerCaster)
6507
6508 TalentEntry const* talent = sTalentStore.LookupEntry(m_misc.TalentId);
6509 if (!talent)
6511
6512 if (playerCaster->GetSpellHistory()->HasCooldown(talent->SpellID))
6513 {
6514 if (param1)
6515 *param1 = talent->SpellID;
6517 }
6518 break;
6519 }
6521 {
6522 if (!m_caster->IsPlayer())
6524
6525 if (!m_caster->ToPlayer()->GetSession()->GetCollectionMgr()->HasHeirloom(m_misc.Raw.Data[0]))
6527
6528 break;
6529 }
6532 {
6533 Player* playerCaster = m_caster->ToPlayer();
6534 if (!playerCaster)
6536
6538 if (!artifactAura)
6540
6541 Item* artifact = playerCaster->GetItemByGuid(artifactAura->GetCastItemGUID());
6542 if (!artifact)
6544
6545 if (spellEffectInfo.Effect == SPELL_EFFECT_GIVE_ARTIFACT_POWER)
6546 {
6547 ArtifactEntry const* artifactEntry = sArtifactStore.LookupEntry(artifact->GetTemplate()->GetArtifactID());
6548 if (!artifactEntry || artifactEntry->ArtifactCategoryID != spellEffectInfo.MiscValue)
6550 }
6551 break;
6552 }
6556 {
6557 Player* playerCaster = m_caster->ToPlayer();
6558 if (!playerCaster || !m_targets.GetUnitTarget() || !m_targets.GetUnitTarget()->IsCreature())
6560
6561 BattlePets::BattlePetMgr* battlePetMgr = playerCaster->GetSession()->GetBattlePetMgr();
6562 if (!battlePetMgr->HasJournalLock())
6564
6565 if (Creature* creature = m_targets.GetUnitTarget()->ToCreature())
6566 {
6567 if (playerCaster->GetSummonedBattlePetGUID().IsEmpty() || creature->GetBattlePetCompanionGUID().IsEmpty())
6568 return SPELL_FAILED_NO_PET;
6569
6570 if (playerCaster->GetSummonedBattlePetGUID() != creature->GetBattlePetCompanionGUID())
6572
6573 if (BattlePets::BattlePet* battlePet = battlePetMgr->GetPet(creature->GetBattlePetCompanionGUID()))
6574 {
6575 if (BattlePetSpeciesEntry const* battlePetSpecies = sBattlePetSpeciesStore.LookupEntry(battlePet->PacketInfo.Species))
6576 {
6577 if (uint32 battlePetType = spellEffectInfo.MiscValue)
6578 if (!(battlePetType & (1 << battlePetSpecies->PetTypeEnum)))
6580
6581 if (spellEffectInfo.Effect == SPELL_EFFECT_CHANGE_BATTLEPET_QUALITY)
6582 {
6583 auto qualityItr = std::lower_bound(sBattlePetBreedQualityStore.begin(), sBattlePetBreedQualityStore.end(), spellEffectInfo.CalcBaseValue(m_caster, creature, m_castItemEntry, m_castItemLevel), [](BattlePetBreedQualityEntry const* a1, int32 selector)
6584 {
6585 return a1->MaxQualityRoll < selector;
6586 });
6587
6589 if (qualityItr != sBattlePetBreedQualityStore.end())
6590 quality = BattlePets::BattlePetBreedQuality(qualityItr->QualityEnum);
6591
6592 if (battlePet->PacketInfo.Quality >= AsUnderlyingType(quality))
6594 }
6595
6596 if (spellEffectInfo.Effect == SPELL_EFFECT_GRANT_BATTLEPET_LEVEL || spellEffectInfo.Effect == SPELL_EFFECT_GRANT_BATTLEPET_EXPERIENCE)
6597 if (battlePet->PacketInfo.Level >= BattlePets::MAX_BATTLE_PET_LEVEL)
6598 return GRANT_PET_LEVEL_FAIL;
6599
6600 if (battlePetSpecies->GetFlags().HasFlag(BattlePetSpeciesFlags::CantBattle))
6602 }
6603 }
6604 }
6605 break;
6606 }
6607 default:
6608 break;
6609 }
6610
6611 if (spellEffectInfo.IsAura())
6612 approximateAuraEffectMask |= 1 << spellEffectInfo.EffectIndex;
6613 else if (spellEffectInfo.IsEffect())
6614 nonAuraEffectMask |= 1 << spellEffectInfo.EffectIndex;
6615 }
6616
6617 for (SpellEffectInfo const& spellEffectInfo : m_spellInfo->GetEffects())
6618 {
6619 switch (spellEffectInfo.ApplyAuraName)
6620 {
6622 {
6624 return SPELL_FAILED_NO_PET;
6625
6626 Pet* pet = m_caster->ToPlayer()->GetPet();
6627 if (!pet)
6628 return SPELL_FAILED_NO_PET;
6629
6630 if (!pet->GetCharmerGUID().IsEmpty())
6632 break;
6633 }
6637 {
6638 Unit* unitCaster = (m_originalCaster ? m_originalCaster : m_caster->ToUnit());
6639 if (!unitCaster)
6641
6642 if (!unitCaster->GetCharmerGUID().IsEmpty())
6643 return SPELL_FAILED_CHARMED;
6644
6645 if (spellEffectInfo.ApplyAuraName == SPELL_AURA_MOD_CHARM
6646 || spellEffectInfo.ApplyAuraName == SPELL_AURA_MOD_POSSESS)
6647 {
6650
6651 if (!unitCaster->GetCharmedGUID().IsEmpty())
6653 }
6654
6655 if (Unit* target = m_targets.GetUnitTarget())
6656 {
6657 if (target->GetTypeId() == TYPEID_UNIT && target->IsVehicle())
6659
6660 if (target->IsMounted())
6662
6663 if (!target->GetCharmerGUID().IsEmpty())
6665
6666 if (target->GetOwner() && target->GetOwner()->GetTypeId() == TYPEID_PLAYER)
6668
6669 int32 value = CalculateDamage(spellEffectInfo, target);
6670 if (value && int32(target->GetLevelForTarget(m_caster)) > value)
6672 }
6673
6674 break;
6675 }
6676 case SPELL_AURA_MOUNTED:
6677 {
6678 Unit* unitCaster = m_caster->ToUnit();
6679 if (!unitCaster)
6681
6684
6685 if (unitCaster->IsInDisallowedMountForm())
6686 {
6687 SendMountResult(MountResult::Shapeshifted); // mount result gets sent before the cast result
6689 }
6690 break;
6691 }
6693 {
6694 if (!m_targets.GetUnitTarget())
6696
6697 // can be cast at non-friendly unit or own pet/charm
6700 break;
6701 }
6702 case SPELL_AURA_FLY:
6704 {
6705 // not allow cast fly spells if not have req. skills (all spells is self target)
6706 // allow always ghost flight spells
6708 {
6709 Battlefield* Bf = sBattlefieldMgr->GetBattlefieldToZoneId(m_originalCaster->GetMap(), m_originalCaster->GetZoneId());
6710 if (Bf && !Bf->CanFlyIn())
6711 return SPELL_FAILED_NOT_HERE;
6712 }
6713 break;
6714 }
6716 {
6717 if (spellEffectInfo.IsTargetingArea())
6718 break;
6719
6720 if (!m_targets.GetUnitTarget())
6722
6724 break;
6725
6728 break;
6729 }
6730 default:
6731 break;
6732 }
6733
6734 // check if target already has the same type, but more powerful aura
6737 && (approximateAuraEffectMask & (1 << spellEffectInfo.EffectIndex))
6739 if (Unit* target = m_targets.GetUnitTarget())
6740 if (!target->IsHighestExclusiveAuraEffect(m_spellInfo, spellEffectInfo.ApplyAuraName,
6741 spellEffectInfo.CalcValue(m_caster, &m_spellValue->EffectBasePoints[spellEffectInfo.EffectIndex], nullptr, nullptr, m_castItemEntry, m_castItemLevel),
6742 approximateAuraEffectMask, false))
6744 }
6745
6746 // check trade slot case (last, for allow catch any another cast problems)
6748 {
6749 if (m_CastItem)
6751
6754
6757
6758 TradeData* my_trade = m_caster->ToPlayer()->GetTradeData();
6759 if (!my_trade)
6761
6764
6765 if (!IsTriggered())
6766 if (my_trade->GetSpell())
6768 }
6769
6770 // all ok
6771 return SPELL_CAST_OK;
6772}
#define sBattlefieldMgr
@ STATUS_WAIT_LEAVE
Definition: Battleground.h:166
@ STATUS_IN_PROGRESS
Definition: Battleground.h:165
#define M_PI
Definition: Common.h:115
#define sConditionMgr
Definition: ConditionMgr.h:353
@ CONDITION_SOURCE_TYPE_SPELL
Definition: ConditionMgr.h:169
DB2Storage< BattlePetBreedQualityEntry > sBattlePetBreedQualityStore("BattlePetBreedQuality.db2", &BattlePetBreedQualityLoadInfo::Instance)
DB2Storage< ArtifactEntry > sArtifactStore("Artifact.db2", &ArtifactLoadInfo::Instance)
DB2Storage< ChrClassesEntry > sChrClassesStore("ChrClasses.db2", &ChrClassesLoadInfo::Instance)
DB2Storage< ChrSpecializationEntry > sChrSpecializationStore("ChrSpecialization.db2", &ChrSpecializationLoadInfo::Instance)
DB2Storage< BattlePetSpeciesEntry > sBattlePetSpeciesStore("BattlePetSpecies.db2", &BattlePetSpeciesLoadInfo::Instance)
DB2Storage< SummonPropertiesEntry > sSummonPropertiesStore("SummonProperties.db2", &SummonPropertiesLoadInfo::Instance)
DB2Storage< GlyphPropertiesEntry > sGlyphPropertiesStore("GlyphProperties.db2", &GlyphPropertiesLoadInfo::Instance)
DB2Storage< TalentEntry > sTalentStore("Talent.db2", &TalentLoadInfo::Instance)
#define sDB2Manager
Definition: DB2Stores.h:533
Difficulty
Definition: DBCEnums.h:871
@ DIFFICULTY_NONE
Definition: DBCEnums.h:872
#define sInstanceLockMgr
@ LOOT_SKINNING
Definition: Loot.h:106
@ TRANSFER_ABORT_NONE
Definition: Map.h:85
@ TYPEID_GAMEOBJECT
Definition: ObjectGuid.h:43
@ TYPEID_UNIT
Definition: ObjectGuid.h:40
#define sObjectMgr
Definition: ObjectMgr.h:1946
std::optional< T > Optional
Optional helper class to wrap optional values within.
Definition: Optional.h:25
@ PATHFIND_NOPATH
Definition: PathGenerator.h:47
@ PATHFIND_SHORT
Definition: PathGenerator.h:49
@ PATHFIND_INCOMPLETE
Definition: PathGenerator.h:46
@ HUNTER_PET
Definition: PetDefines.h:32
constexpr uint32 PET_SUMMONING_DISORIENTATION
Definition: PetDefines.h:131
PetSaveMode
Definition: PetDefines.h:41
@ SPELL_ATTR7_DEBUG_SPELL
@ GAMEOBJECT_TYPE_TRAP
@ SPELL_ATTR5_NOT_AVAILABLE_WHILE_CHARMED
@ TARGET_UNIT_PET
@ TARGET_GAMEOBJECT_TARGET
@ SPELL_ATTR2_ENCHANT_OWN_ITEM_ONLY
@ SPELL_ATTR2_INITIATE_COMBAT_POST_CAST_ENABLES_AUTO_ATTACK
@ SPELL_ATTR2_NO_ACTIVE_PETS
@ SPELL_ATTR1_INITIATES_COMBAT_ENABLES_AUTO_ATTACK
@ SPELL_ATTR3_ONLY_BATTLEGROUNDS
@ SPELL_DAMAGE_CLASS_MELEE
@ SPELL_EFFECT_DUMMY
@ SPELL_EFFECT_LEAP
@ SPELL_EFFECT_CREATE_HEIRLOOM_ITEM
@ SPELL_EFFECT_SUMMON_PET
@ SPELL_EFFECT_GIVE_ARTIFACT_POWER_NO_BONUS
@ SPELL_EFFECT_SUMMON_RAF_FRIEND
@ SPELL_EFFECT_WEAPON_DAMAGE
@ SPELL_EFFECT_APPLY_GLYPH
@ SPELL_EFFECT_NORMALIZED_WEAPON_DMG
@ SPELL_EFFECT_FEED_PET
@ SPELL_EFFECT_SUMMON_PLAYER
@ SPELL_EFFECT_JUMP_DEST
@ SPELL_EFFECT_TELEPORT_UNITS_FACE_CASTER
@ SPELL_EFFECT_ATTACK
@ SPELL_EFFECT_RESURRECT_PET
@ SPELL_EFFECT_CHANGE_BATTLEPET_QUALITY
@ SPELL_EFFECT_WEAPON_PERCENT_DAMAGE
@ SPELL_EFFECT_GRANT_BATTLEPET_LEVEL
@ SPELL_EFFECT_WEAPON_DAMAGE_NOSCHOOL
@ SPELL_EFFECT_LEAP_BACK
@ SPELL_EFFECT_SUMMON
@ SPELL_EFFECT_UNLOCK_GUILD_VAULT_TAB
@ SPELL_EFFECT_CHARGE
@ SPELL_EFFECT_DISMISS_PET
@ SPELL_EFFECT_TALENT_SPEC_SELECT
@ SPELL_EFFECT_GRANT_BATTLEPET_EXPERIENCE
@ SPELL_EFFECT_LEARN_SPELL
@ SPELL_EFFECT_GIVE_ARTIFACT_POWER
@ SPELL_EFFECT_JUMP
@ SPELL_EFFECT_SKINNING
@ SPELL_EFFECT_REMOVE_TALENT
@ SPELL_EFFECT_CREATE_TAMED_PET
@ SPELL_EFFECT_OPEN_LOCK
@ SPELL_EFFECT_STEAL_BENEFICIAL_BUFF
@ SPELL_EFFECT_LEARN_PET_SPELL
SpellCustomErrors
@ SPELL_CUSTOM_ERROR_GM_ONLY
@ POWER_MANA
@ SPELL_ATTR0_ONLY_INDOORS
@ SPELL_ATTR0_ONLY_OUTDOORS
@ SPELL_ATTR0_ALLOW_WHILE_MOUNTED
@ SPELL_ATTR0_COOLDOWN_ON_EVENT
@ SPELL_ATTR0_USES_RANGED_SLOT
@ SPELL_ATTR0_ALLOW_CAST_WHILE_DEAD
@ SPELL_ATTR0_ONLY_STEALTHED
@ SPELL_ATTR12_IGNORE_CASTING_DISABLED
@ SPELL_FAILED_TARGET_NOT_LOOTED
@ SPELL_FAILED_NOT_INFRONT
@ GRANT_PET_LEVEL_FAIL
@ SPELL_FAILED_NOT_MOUNTED
@ SPELL_FAILED_AFFECTING_COMBAT
@ SPELL_FAILED_CASTER_AURASTATE
@ SPELL_FAILED_WRONG_ARTIFACT_EQUIPPED
@ SPELL_FAILED_TARGET_NOT_PLAYER
@ SPELL_FAILED_CANT_UNTALENT
@ SPELL_FAILED_NOT_KNOWN
@ SPELL_FAILED_FOOD_LOWLEVEL
@ SPELL_FAILED_NO_SPEC
@ SPELL_FAILED_NOT_HERE
@ SPELL_FAILED_ROOTED
@ SPELL_FAILED_GLYPH_INVALID_SPEC
@ SPELL_FAILED_ALREADY_HAVE_PET
@ SPELL_FAILED_WRONG_PET_FOOD
@ SPELL_FAILED_CUSTOM_ERROR
@ SPELL_FAILED_SUMMON_PENDING
@ SPELL_FAILED_BAD_IMPLICIT_TARGETS
@ SPELL_FAILED_TRY_AGAIN
@ SPELL_FAILED_CANT_UPGRADE_BATTLE_PET
@ SPELL_FAILED_ALREADY_HAVE_SUMMON
@ SPELL_FAILED_NOT_TRADING
@ SPELL_FAILED_NOT_IN_BATTLEGROUND
@ SPELL_FAILED_NOT_BEHIND
@ SPELL_FAILED_ALREADY_HAVE_CHARM
@ SPELL_FAILED_HIGHLEVEL
@ SPELL_FAILED_LOWLEVEL
@ SPELL_FAILED_NOT_READY
@ SPELL_FAILED_WRONG_BATTLE_PET_TYPE
@ SPELL_FAILED_ONLY_BATTLEGROUNDS
@ SPELL_FAILED_ITEM_ALREADY_ENCHANTED
@ SPELL_FAILED_ONLY_STEALTHED
@ SPELL_FAILED_CANT_DO_THAT_RIGHT_NOW
@ SPELL_FAILED_TARGET_IS_PLAYER_CONTROLLED
@ SPELL_FAILED_NO_ARTIFACT_EQUIPPED
@ SPELL_FAILED_ONLY_ABOVEWATER
@ SPELL_FAILED_TARGETS_DEAD
@ SPELL_FAILED_GLYPH_NO_SPEC
@ SPELL_FAILED_CANT_BE_CHARMED
@ SPELL_FAILED_CASTER_DEAD
@ SPELL_FAILED_ITEM_ENCHANT_TRADE_WINDOW
@ SPELL_FAILED_GLYPH_EXCLUSIVE_CATEGORY
@ SPELL_FAILED_TARGET_UNSKINNABLE
@ SPELL_FAILED_UNIQUE_GLYPH
@ SPELL_FAILED_ONLY_OUTDOORS
@ SPELL_FAILED_CHARMED
@ SPELL_FAILED_INVALID_GLYPH
@ SPELL_FAILED_LINE_OF_SIGHT
@ SPELL_FAILED_VISION_OBSCURED
@ SPELL_FAILED_NO_PET
@ SPELL_FAILED_TARGET_LOCKED_TO_RAID_INSTANCE
@ SPELL_FAILED_REQUIRES_SPELL_FOCUS
@ SPELL_FAILED_NOPATH
@ SPELL_FAILED_ONLY_INDOORS
@ SPELL_FAILED_NOT_ON_TAXI
@ SPELL_FAILED_TARGET_FRIENDLY
AuraStateType
@ SPELL_ATTR4_AURA_NEVER_BOUNCES
@ SPELL_ATTR4_AURA_BOUNCE_FAILS_SPELL
@ SUMMON_CATEGORY_PET
@ SUMMON_CATEGORY_PUPPET
@ SPELL_ATTR8_ONLY_PLAYERS_CAN_CAST_THIS_SPELL
SkillType
@ SPELL_AURA_DISABLE_CASTING_EXCEPT_ABILITIES
@ SPELL_AURA_DISABLE_ATTACKING_EXCEPT_ABILITIES
@ SPELL_AURA_MOD_IGNORE_SHAPESHIFT
@ SPELL_AURA_PERIODIC_MANA_LEECH
@ SPELL_AURA_MOD_POSSESS_PET
@ SPELL_AURA_RANGED_ATTACK_POWER_ATTACKER_BONUS
@ SPELL_AURA_FLY
@ SPELL_AURA_MOD_CHARM
@ SPELL_AURA_MOUNTED
@ SPELL_AURA_AOE_CHARM
@ SPELL_AURA_PROVIDE_SPELL_FOCUS
@ SPELL_AURA_MOD_POSSESS
@ SPELL_AURA_INTERFERE_TARGETTING
@ SPELL_AURA_MOD_INCREASE_MOUNTED_FLIGHT_SPEED
@ TARGET_FLAG_ITEM
Definition: SpellDefines.h:284
@ TRIGGERED_IGNORE_CASTER_AURASTATE
Will ignore caster aura states including combat requirements and death state.
Definition: SpellDefines.h:271
@ TRIGGERED_IGNORE_CASTER_MOUNTED_OR_ON_VEHICLE
Will ignore mounted/on vehicle restrictions.
Definition: SpellDefines.h:260
@ TRIGGERED_IGNORE_SHAPESHIFT
Will ignore shapeshift checks.
Definition: SpellDefines.h:257
@ TRIGGERED_IGNORE_GCD
Will ignore GCD.
Definition: SpellDefines.h:247
@ TRIGGERED_IGNORE_CASTER_AURAS
Will ignore caster aura restrictions or requirements.
Definition: SpellDefines.h:263
@ SPELL_ATTR0_CU_REQ_TARGET_FACING_CASTER
Definition: SpellInfo.h:164
@ SPELL_ATTR0_CU_REQ_CASTER_BEHIND_TARGET
Definition: SpellInfo.h:165
@ TRADE_SLOT_NONTRADED
Definition: TradeData.h:27
@ UNIT_FLAG2_ALLOW_CHEAT_SPELLS
Definition: UnitDefines.h:212
@ UNIT_FLAG_IMMUNE
Definition: UnitDefines.h:175
@ UNIT_FLAG_SKINNABLE
Definition: UnitDefines.h:170
@ UNIT_STATE_ROOT
Definition: Unit.h:262
#define ARTIFACTS_ALL_WEAPONS_GENERAL_WEAPON_EQUIPPED_PASSIVE
Definition: Unit.h:37
constexpr std::underlying_type< E >::type AsUnderlyingType(E enumValue)
Definition: Util.h:489
ObjectGuid GetCastItemGUID() const
Definition: SpellAuras.h:139
BattlePet * GetPet(ObjectGuid guid)
bool HasJournalLock() const
Definition: BattlePetMgr.h:201
bool CanFlyIn()
Return if we can use mount in battlefield.
Definition: Battlefield.h:277
bool HasHeirloom(uint32 itemId) const
Loot * GetLootForPlayer(Player const *player) const override
Definition: Creature.cpp:1373
GameObjectTemplate const * GetGOInfo() const
Definition: GameObject.h:197