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 ()
 
 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, uint32 &processedEffectMask)
 
void SelectImplicitChannelTargets (SpellEffectInfo const &spellEffectInfo, SpellImplicitTargetInfo const &targetType)
 
void SelectImplicitNearbyTargets (SpellEffectInfo const &spellEffectInfo, SpellImplicitTargetInfo const &targetType, uint32 effMask)
 
void SelectImplicitConeTargets (SpellEffectInfo const &spellEffectInfo, SpellImplicitTargetInfo const &targetType, uint32 effMask)
 
void SelectImplicitAreaTargets (SpellEffectInfo const &spellEffectInfo, SpellImplicitTargetInfo const &targetType, uint32 effMask)
 
void SelectImplicitCasterDestTargets (SpellEffectInfo const &spellEffectInfo, SpellImplicitTargetInfo const &targetType)
 
void SelectImplicitTargetDestTargets (SpellEffectInfo const &spellEffectInfo, SpellImplicitTargetInfo const &targetType)
 
void SelectImplicitDestDestTargets (SpellEffectInfo const &spellEffectInfo, SpellImplicitTargetInfo const &targetType)
 
void SelectImplicitCasterObjectTargets (SpellEffectInfo const &spellEffectInfo, SpellImplicitTargetInfo const &targetType)
 
void SelectImplicitTargetObjectTargets (SpellEffectInfo const &spellEffectInfo, SpellImplicitTargetInfo const &targetType)
 
void SelectImplicitChainTargets (SpellEffectInfo const &spellEffectInfo, SpellImplicitTargetInfo const &targetType, WorldObject *target, uint32 effMask)
 
void SelectImplicitTrajTargets (SpellEffectInfo const &spellEffectInfo, SpellImplicitTargetInfo const &targetType)
 
void SelectImplicitLineTargets (SpellEffectInfo const &spellEffectInfo, SpellImplicitTargetInfo const &targetType, uint32 effMask)
 
void SelectEffectTypeImplicitTargets (SpellEffectInfo const &spellEffectInfo)
 
uint32 GetSearcherTypeMask (SpellTargetObjectTypes objType, ConditionContainer *condList)
 
template<class SEARCHER >
void SearchTargets (SEARCHER &searcher, uint32 containerMask, WorldObject *referer, Position const *pos, float radius)
 
WorldObjectSearchNearbyTarget (float range, SpellTargetObjectTypes objectType, SpellTargetCheckTypes selectionType, ConditionContainer *condList=nullptr)
 
void SearchAreaTargets (std::list< WorldObject * > &targets, float range, Position const *position, WorldObject *referer, SpellTargetObjectTypes objectType, SpellTargetCheckTypes selectionType, ConditionContainer *condList)
 
void SearchChainTargets (std::list< WorldObject * > &targets, uint32 chainTargets, WorldObject *target, SpellTargetObjectTypes objectType, SpellTargetCheckTypes selectType, 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=std::vector< int32 >())
 
bool CheckEffectTarget (Unit const *target, SpellEffectInfo const &spellEffectInfo, Position const *losPosition) const
 
bool CheckEffectTarget (GameObject const *target, SpellEffectInfo const &spellEffectInfo) const
 
bool CheckEffectTarget (Item const *target, SpellEffectInfo const &spellEffectInfo) const
 
bool CanAutoCast (Unit *target)
 
void CheckSrc ()
 
void CheckDst ()
 
void SendCastResult (SpellCastResult result, 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
 
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 ()
 
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)
 
void CallScriptCalcCritChanceHandlers (Unit const *victim, float &chance)
 

Static Public Member Functions

static void SendCastResult (Player *caster, SpellInfo const *spellInfo, SpellCastVisual spellVisual, ObjectGuid cast_count, SpellCastResult result, SpellCustomErrors customError=SPELL_CUSTOM_ERROR_NONE, 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
 
int8 m_comboPointGain
 
SpellCustomErrors m_customError
 
UsedSpellMods m_appliedMods
 
Spell ** m_selfContainer
 

Protected Types

typedef std::vector< HitTriggerSpellHitTriggerSpellList
 

Protected Member Functions

bool HasGlobalCooldown () const
 
void TriggerGlobalCooldown ()
 
void CancelGlobalCooldown ()
 
void _cast (bool skipCheck=false)
 
std::pair< float, float > GetMinMaxRange (bool strict) const
 
bool IsDelayableNoMore ()
 
UnitGetUnitCasterForEffectHandlers () const
 
void prepareDataForTriggerSystem ()
 
template<class Container >
void DoProcessTargetContainer (Container &targetContainer)
 
void AddUnitTarget (Unit *target, uint32 effectMask, bool checkIfValid=true, bool implicit=true, Position const *losPosition=nullptr)
 
void AddGOTarget (GameObject *target, uint32 effectMask)
 
void AddItemTarget (Item *item, uint32 effectMask)
 
void 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 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. More...
 
void UpdateSpellCastDataAmmo (WorldPackets::Spells::SpellAmmo &data)
 
SpellCastResult CanOpenLock (SpellEffectInfo const &effect, uint32 lockid, SkillType &skillid, int32 &reqSkillValue, int32 &skillValue)
 
 Spell (Spell const &right)=delete
 
Spelloperator= (Spell const &right)=delete
 

Protected Attributes

WorldObject *const m_caster
 
SpellValue *const m_spellValue
 
ObjectGuid m_originalCasterGUID
 
Unitm_originalCaster
 
SpellSchoolMask m_spellSchoolMask
 
WeaponAttackType m_attackType
 
std::vector< SpellPowerCostm_powerCost
 
int32 m_casttime
 
int32 m_channeledDuration
 
bool m_canReflect
 
bool m_autoRepeat
 
uint8 m_runesState
 
uint8 m_delayAtDamageCount
 
uint64 m_delayStart
 
uint64 m_delayMoment
 
bool m_launchHandled
 
bool m_immediateHandled
 
bool m_referencedFromCurrentSpell
 
bool m_executedCurrently
 
bool m_needComboPoints
 
uint32 m_applyMultiplierMask
 
float m_damageMultipliers [MAX_SPELL_EFFECTS]
 
UnitunitTarget
 
ItemitemTarget
 
GameObjectgameObjTarget
 
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
 
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
 
std::unique_ptr< PathGeneratorm_preGeneratedPath
 
std::vector< SpellLogEffect_executeLogEffects
 

Friends

class SpellScript
 

Member Typedef Documentation

◆ HitTriggerSpellList

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

◆ UsedSpellMods

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

Constructor & Destructor Documentation

◆ Spell() [1/2]

Spell::Spell ( WorldObject caster,
SpellInfo const *  info,
TriggerCastFlags  triggerFlags,
ObjectGuid  originalCasterGUID = ObjectGuid::Empty,
ObjectGuid  originalCastId = ObjectGuid::Empty 
)
497 :
498m_spellInfo(info), m_caster((info->HasAttribute(SPELL_ATTR6_ORIGINATE_FROM_CONTROLLER) && caster->GetCharmerOrOwner()) ? caster->GetCharmerOrOwner() : caster),
499m_spellValue(new SpellValue(m_spellInfo, caster)), _spellEvent(nullptr)
500{
502 m_fromClient = false;
503 m_selfContainer = nullptr;
505 m_executedCurrently = false;
508 m_delayStart = 0;
510
512 memset(m_damageMultipliers, 0, sizeof(m_damageMultipliers));
513
514 // Get data for type of attack
515 m_attackType = info->GetAttackType();
516
517 m_spellSchoolMask = info->GetSchoolMask(); // Can be override for some spell (wand shoot for example)
518
519 if (Player const* playerCaster = m_caster->ToPlayer())
520 {
521 // wand case
523 if ((playerCaster->GetClassMask() & CLASSMASK_WAND_USERS) != 0)
524 if (Item* pItem = playerCaster->GetWeaponForAttack(RANGED_ATTACK))
525 m_spellSchoolMask = SpellSchoolMask(1 << pItem->GetTemplate()->GetDamageType());
526 }
527
528 if (Player const* modOwner = caster->GetSpellModOwner())
529 modOwner->ApplySpellMod(info, SpellModOp::Doses, m_spellValue->AuraStackAmount, this);
530
531 if (!originalCasterGUID.IsEmpty())
532 m_originalCasterGUID = originalCasterGUID;
533 else
535
538 else
539 {
542 m_originalCaster = nullptr;
543 }
544
546 _triggeredCastFlags = triggerFlags;
547
548 if (info->HasAttribute(SPELL_ATTR2_DO_NOT_REPORT_SPELL_FAILURE))
550
551 if (info->HasAttribute(SPELL_ATTR4_ALLOW_CAST_WHILE_CASTING))
553
554 m_CastItem = nullptr;
556 m_castItemEntry = 0;
557 m_castItemLevel = -1;
558 m_castFlagsEx = 0;
559
562
563 unitTarget = nullptr;
564 itemTarget = nullptr;
565 gameObjTarget = nullptr;
566 m_corpseTarget = nullptr;
567 destTarget = nullptr;
568 damage = 0;
570 variance = 0.0f;
572 effectInfo = nullptr;
573 m_damage = 0;
574 m_healing = 0;
576 focusObject = nullptr;
577 m_castId = ObjectGuid::Create<HighGuid::Cast>(SPELL_CAST_SOURCE_NORMAL, m_caster->GetMapId(), m_spellInfo->Id, m_caster->GetMap()->GenerateLowGuid<HighGuid::Cast>());
578 m_originalCastId = originalCastId;
579 memset(m_misc.Raw.Data, 0, sizeof(m_misc.Raw.Data));
581 m_triggeredByAuraSpell = nullptr;
582 _spellAura = nullptr;
583 _dynObjAura = nullptr;
584
585 //Auto Shot & Shoot (wand)
587
588 m_runesState = 0;
589 m_casttime = 0; // setup to correct value in Spell::prepare, must not be used before.
590 m_timer = 0; // will set to castime in prepare
591 m_channeledDuration = 0; // will be setup in Spell::handle_immediate
592 m_launchHandled = false;
593 m_immediateHandled = false;
594
596
597 // Determine if spell can be reflected back to the caster
598 // Patch 1.2 notes: Spell Reflection no longer reflects abilities
601 && !m_spellInfo->IsPassive();
602
604
605 for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
607}
#define MAX_SPELL_EFFECTS
Definition: DBCEnums.h:1752
uint8_t uint8
Definition: Define.h:145
uint32_t uint32
Definition: Define.h:143
#define CLASSMASK_WAND_USERS
Definition: SharedDefines.h:188
@ SPELL_MISS_NONE
Definition: SharedDefines.h:2730
SpellSchoolMask
Definition: SharedDefines.h:318
@ SPELL_ATTR2_DO_NOT_REPORT_SPELL_FAILURE
Definition: SharedDefines.h:495
@ SPELL_ATTR1_NO_REFLECTION
Definition: SharedDefines.h:458
@ SPELL_DAMAGE_CLASS_MAGIC
Definition: SharedDefines.h:2760
@ RANGED_ATTACK
Definition: SharedDefines.h:6789
@ SPELL_CUSTOM_ERROR_NONE
Definition: SharedDefines.h:1767
@ SPELL_ATTR0_IS_ABILITY
Definition: SharedDefines.h:418
@ SPELL_ATTR0_NO_IMMUNITIES
Definition: SharedDefines.h:443
@ SPELL_ATTR4_ALLOW_CAST_WHILE_CASTING
Definition: SharedDefines.h:569
@ SPELL_ATTR6_ORIGINATE_FROM_CONTROLLER
Definition: SharedDefines.h:654
TriggerCastFlags
Definition: SpellDefines.h:240
@ TRIGGERED_IGNORE_CAST_IN_PROGRESS
Will ignore aura scaling.
Definition: SpellDefines.h:247
@ TRIGGERED_DONT_REPORT_CAST_ERROR
Will allow periodic aura timers to keep ticking (instead of resetting)
Definition: SpellDefines.h:260
@ PROC_HIT_NONE
Definition: SpellMgr.h:271
@ SPELL_CAST_SOURCE_NORMAL
Definition: Spell.h:140
@ SPELL_EFFECT_HANDLE_LAUNCH
Definition: Spell.h:228
@ SPELL_STATE_NULL
Definition: Spell.h:218
@ CAST_FLAG_EX_IGNORE_COOLDOWN
Definition: Spell.h:124
Definition: Item.h:170
ObjectGuid::LowType GenerateLowGuid()
Definition: Map.h:495
bool IsEmpty() const
Definition: ObjectGuid.h:309
void Clear()
Definition: ObjectGuid.h:276
static Unit * ToUnit(Object *o)
Definition: Object.h:211
bool IsInWorld() const
Definition: Object.h:152
bool IsUnit() const
Definition: Object.h:210
static ObjectGuid GetGUID(Object const *o)
Definition: Object.h:157
static Player * ToPlayer(Object *o)
Definition: Object.h:199
Definition: Player.h:1125
uint32 const Id
Definition: SpellInfo.h:326
bool IsPassive() const
Definition: SpellInfo.cpp:1559
bool NeedsComboPoints() const
Definition: SpellInfo.cpp:1695
bool HasAttribute(SpellAttr0 attribute) const
Definition: SpellInfo.h:445
bool IsAutoRepeatRangedSpell() const
Definition: SpellInfo.cpp:1712
uint32 DmgClass
Definition: SpellInfo.h:411
float m_damageMultipliers[MAX_SPELL_EFFECTS]
Definition: Spell.h:700
bool m_fromClient
Definition: Spell.h:550
int8 m_comboPointGain
Definition: Spell.h:588
uint32 m_castFlagsEx
Definition: Spell.h:551
GameObject * gameObjTarget
Definition: Spell.h:705
SpellMissInfo targetMissInfo
Definition: Spell.h:709
bool m_referencedFromCurrentSpell
Definition: Spell.h:696
bool m_canReflect
Definition: Spell.h:675
Unit * m_originalCaster
Definition: Spell.h:666
DynObjAura * _dynObjAura
Definition: Spell.h:716
uint32 m_channelTargetEffectMask
Definition: Spell.h:779
bool m_needComboPoints
Definition: Spell.h:698
uint64 m_delayStart
Definition: Spell.h:690
TriggerCastFlags _triggeredCastFlags
Definition: Spell.h:883
int32 damage
Definition: Spell.h:708
SpellEffectHandleMode effectHandleMode
Definition: Spell.h:711
int32 m_channeledDuration
Definition: Spell.h:674
bool IsIgnoringCooldowns() const
Definition: Spell.cpp:7970
SpellDestination m_destTargets[MAX_SPELL_EFFECTS]
Definition: Spell.h:810
ObjectGuid m_originalCastId
Definition: Spell.h:549
uint8 m_delayAtDamageCount
Definition: Spell.h:679
WeaponAttackType m_attackType
Definition: Spell.h:670
bool m_immediateHandled
Definition: Spell.h:693
uint32 m_spellState
Definition: Spell.h:879
ObjectGuid m_originalCasterGUID
Definition: Spell.h:664
WorldObject *const m_caster
Definition: Spell.h:660
void CleanupTargetList()
Definition: Spell.cpp:2252
int32 m_timer
Definition: Spell.h:880
int32 m_casttime
Definition: Spell.h:673
Item * itemTarget
Definition: Spell.h:704
float variance
Definition: Spell.h:710
int32 m_damage
Definition: Spell.h:722
bool m_executedCurrently
Definition: Spell.h:697
SpellCustomErrors m_customError
Definition: Spell.h:589
int32 m_healing
Definition: Spell.h:723
SpellEffectInfo const * effectInfo
Definition: Spell.h:712
SpellInfo const * m_triggeredByAuraSpell
Definition: Spell.h:888
int32 m_castItemLevel
Definition: Spell.h:547
UnitAura * _spellAura
Definition: Spell.h:715
uint32 m_applyMultiplierMask
Definition: Spell.h:699
Unit * unitTarget
Definition: Spell.h:703
SpellSchoolMask m_spellSchoolMask
Definition: Spell.h:669
SpellEvent * _spellEvent
Definition: Spell.h:882
Corpse * m_corpseTarget
Definition: Spell.h:706
union Spell::@333 m_misc
WorldLocation * destTarget
Definition: Spell.h:707
Spell ** m_selfContainer
Definition: Spell.h:638
Item * m_CastItem
Definition: Spell.h:544
uint32 m_castItemEntry
Definition: Spell.h:546
SpellValue *const m_spellValue
Definition: Spell.h:662
ObjectGuid m_castItemGUID
Definition: Spell.h:545
SpellCastVisual m_SpellVisual
Definition: Spell.h:586
GameObject * focusObject
Definition: Spell.h:719
ProcFlagsHit m_hitMask
Definition: Spell.h:730
ObjectGuid m_castId
Definition: Spell.h:548
bool m_launchHandled
Definition: Spell.h:692
SpellInfo const *const m_spellInfo
Definition: Spell.h:543
uint8 m_runesState
Definition: Spell.h:677
bool m_autoRepeat
Definition: Spell.h:676
uint32 GetMapId() const
Definition: Position.h:186
Map * GetMap() const
Definition: Object.h:611
Unit * GetCharmerOrOwner() const
Definition: Object.cpp:2189
Player * GetSpellModOwner() const
Definition: Object.cpp:2227
virtual uint32 GetCastSpellXSpellVisualId(SpellInfo const *spellInfo) const
Definition: Object.cpp:3215
TC_GAME_API Unit * GetUnit(WorldObject const &, ObjectGuid const &guid)
Definition: ObjectAccessor.cpp:206
uint32 SpellXSpellVisualID
Definition: SpellDefines.h:492
Definition: SpellDefines.h:308
Definition: Spell.h:204
int32 AuraStackAmount
Definition: Spell.h:210
+ Here is the call graph for this function:

◆ ~Spell()

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

3532{
3533 // update pointers base at GUIDs to prevent access to non-existed already object
3534 if (!UpdatePointers())
3535 {
3536 // cancel the spell if UpdatePointers() returned false, something wrong happened there
3537 cancel();
3538 return;
3539 }
3540
3541 // cancel at lost explicit target during cast
3543 {
3544 cancel();
3545 return;
3546 }
3547
3548 if (Player* playerCaster = m_caster->ToPlayer())
3549 {
3550 // now that we've done the basic check, now run the scripts
3551 // should be done before the spell is actually executed
3552 sScriptMgr->OnPlayerSpellCast(playerCaster, this, skipCheck);
3553
3554 // As of 3.0.2 pets begin attacking their owner's target immediately
3555 // Let any pets know we've attacked something. Check DmgClass for harmful spells only
3556 // This prevents spells such as Hunter's Mark from triggering pet attack
3557 if (GetSpellInfo()->DmgClass != SPELL_DAMAGE_CLASS_NONE)
3558 if (Unit* target = m_targets.GetUnitTarget())
3559 for (Unit* controlled : playerCaster->m_Controlled)
3560 if (Creature* cControlled = controlled->ToCreature())
3561 if (CreatureAI* controlledAI = cControlled->AI())
3562 controlledAI->OwnerAttacked(target);
3563 }
3564
3566
3567 // Should this be done for original caster?
3568 Player* modOwner = m_caster->GetSpellModOwner();
3569 if (modOwner)
3570 {
3571 // Set spell which will drop charges for triggered cast spells
3572 // if not successfully cast, will be remove in finish(false)
3573 modOwner->SetSpellModTakingSpell(this, true);
3574 }
3575
3577
3578 // skip check if done already (for instant cast spells for example)
3579 if (!skipCheck)
3580 {
3581 auto cleanupSpell = [this, modOwner](SpellCastResult res, int32* p1 = nullptr, int32* p2 = nullptr)
3582 {
3583 SendCastResult(res, p1, p2);
3584 SendInterrupted(0);
3585
3586 if (modOwner)
3587 modOwner->SetSpellModTakingSpell(this, false);
3588
3589 finish(res);
3590 SetExecutedCurrently(false);
3591 };
3592
3593 int32 param1 = 0, param2 = 0;
3594 SpellCastResult castResult = CheckCast(false, &param1, &param2);
3595 if (castResult != SPELL_CAST_OK)
3596 {
3597 cleanupSpell(castResult, &param1, &param2);
3598 return;
3599 }
3600
3601 // additional check after cast bar completes (must not be in CheckCast)
3602 // if trade not complete then remember it in trade data
3604 {
3605 if (modOwner)
3606 {
3607 if (TradeData* my_trade = modOwner->GetTradeData())
3608 {
3609 if (!my_trade->IsInAcceptProcess())
3610 {
3611 // Spell will be cast after completing the trade. Silently ignore at this place
3612 my_trade->SetSpell(m_spellInfo->Id, m_CastItem);
3613 cleanupSpell(SPELL_FAILED_DONT_REPORT);
3614 return;
3615 }
3616 }
3617 }
3618 }
3619
3620 // check diminishing returns (again, only after finish cast bar, tested on retail)
3621 if (Unit* target = m_targets.GetUnitTarget())
3622 {
3623 uint32 aura_effmask = 0;
3624 for (SpellEffectInfo const& spellEffectInfo : m_spellInfo->GetEffects())
3625 if (spellEffectInfo.IsUnitOwnedAuraEffect())
3626 aura_effmask |= 1 << spellEffectInfo.EffectIndex;
3627
3628 if (aura_effmask)
3629 {
3631 {
3633 if (type == DRTYPE_ALL || (type == DRTYPE_PLAYER && target->IsAffectedByDiminishingReturns()))
3634 {
3636 {
3637 if (target->HasStrongerAuraWithDR(m_spellInfo, caster))
3638 {
3639 cleanupSpell(SPELL_FAILED_AURA_BOUNCED);
3640 return;
3641 }
3642 }
3643 }
3644 }
3645 }
3646 }
3647 }
3648 // 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.
3649 if (Creature* creatureCaster = m_caster->ToCreature())
3650 if (!creatureCaster->GetTarget().IsEmpty() && !creatureCaster->HasUnitFlag(UNIT_FLAG_POSSESSED))
3651 if (WorldObject const* target = ObjectAccessor::GetUnit(*creatureCaster, creatureCaster->GetTarget()))
3652 creatureCaster->SetInFront(target);
3653
3655
3656 // Spell may be finished after target map check
3658 {
3659 SendInterrupted(0);
3660
3661 // cleanup after mod system
3662 // triggered spell pointer can be not removed in some cases
3664 m_caster->ToPlayer()->SetSpellModTakingSpell(this, false);
3665
3667 SetExecutedCurrently(false);
3668 return;
3669 }
3670
3671 if (Unit* unitCaster = m_caster->ToUnit())
3673 if (Creature* pet = ObjectAccessor::GetCreature(*m_caster, unitCaster->GetPetGUID()))
3674 pet->DespawnOrUnsummon();
3675
3677
3679
3680 // traded items have trade slot instead of guid in m_itemTargetGUID
3681 // set to real guid to be sent later to the client
3683
3684 if (Player* player = m_caster->ToPlayer())
3685 {
3687 {
3688 player->StartCriteriaTimer(CriteriaStartEvent::UseItem, m_CastItem->GetEntry());
3689 player->UpdateCriteria(CriteriaType::UseItem, m_CastItem->GetEntry());
3690 }
3691
3692 player->UpdateCriteria(CriteriaType::CastSpell, m_spellInfo->Id);
3693 }
3694
3696 {
3697 // Powers have to be taken before SendSpellGo
3698 TakePower();
3699 TakeReagents(); // we must remove reagents before HandleEffects to allow place crafted item in same slot
3700 }
3701 else if (Item* targetItem = m_targets.GetItemTarget())
3702 {
3704 if (targetItem->GetOwnerGUID() != m_caster->GetGUID())
3705 TakeReagents();
3706 }
3707
3708 // CAST SPELL
3711
3713 {
3715 m_launchHandled = true;
3716 }
3717
3718 // we must send smsg_spell_go packet before m_castItem delete in TakeCastItem()...
3719 SendSpellGo();
3720
3721 if (!m_spellInfo->IsChanneled())
3722 if (Creature* creatureCaster = m_caster->ToCreature())
3723 creatureCaster->ReleaseSpellFocus(this);
3724
3725 // Okay, everything is prepared. Now we need to distinguish between immediate and evented delayed spells
3727 {
3728 // Remove used for cast item if need (it can be already NULL after TakeReagents call
3729 // in case delayed spell remove item at cast delay start
3730 TakeCastItem();
3731
3732 // Okay, maps created, now prepare flags
3733 m_immediateHandled = false;
3735 SetDelayStart(0);
3736
3737 if (Unit* unitCaster = m_caster->ToUnit())
3738 if (unitCaster->HasUnitState(UNIT_STATE_CASTING) && !unitCaster->IsNonMeleeSpellCast(false, false, true))
3739 unitCaster->ClearUnitState(UNIT_STATE_CASTING);
3740 }
3741 else
3742 {
3743 // Immediate spell, no big deal
3745 }
3746
3748
3749 if (std::vector<int32> const* spell_triggered = sSpellMgr->GetSpellLinked(SPELL_LINK_CAST, m_spellInfo->Id))
3750 {
3751 for (int32 id : *spell_triggered)
3752 {
3753 if (id < 0)
3754 {
3755 if (Unit* unitCaster = m_caster->ToUnit())
3756 unitCaster->RemoveAurasDueToSpell(-id);
3757 }
3758 else
3760 .SetTriggeringSpell(this));
3761 }
3762 }
3763
3764 if (modOwner)
3765 {
3766 modOwner->SetSpellModTakingSpell(this, false);
3767
3768 //Clear spell cooldowns after every spell is cast if .cheat cooldown is enabled.
3770 {
3773 }
3774 }
3775
3776 SetExecutedCurrently(false);
3777
3778 if (!m_originalCaster)
3779 return;
3780
3781 // Handle procs on cast
3782 ProcFlagsInit procAttacker = m_procAttacker;
3783 if (!procAttacker)
3784 {
3786 {
3787 if (IsPositive())
3788 procAttacker |= PROC_FLAG_DEAL_HELPFUL_PERIODIC;
3789 else
3790 procAttacker |= PROC_FLAG_DEAL_HARMFUL_PERIODIC;
3791 }
3793 {
3794 if (IsPositive())
3795 procAttacker |= PROC_FLAG_DEAL_HELPFUL_ABILITY;
3796 else
3797 procAttacker |= PROC_FLAG_DEAL_HARMFUL_ABILITY;
3798 }
3799 else
3800 {
3801 if (IsPositive())
3802 procAttacker |= PROC_FLAG_DEAL_HELPFUL_SPELL;
3803 else
3804 procAttacker |= PROC_FLAG_DEAL_HARMFUL_SPELL;
3805 }
3806 }
3807
3808 procAttacker |= PROC_FLAG_2_CAST_SUCCESSFUL;
3809
3810 ProcFlagsHit hitMask = m_hitMask;
3811 if (!(hitMask & PROC_HIT_CRITICAL))
3812 hitMask |= PROC_HIT_NORMAL;
3813
3815 m_originalCaster->RemoveAurasWithInterruptFlags(SpellAuraInterruptFlags::ActionDelayed, m_spellInfo);
3816
3818 Unit::ProcSkillsAndAuras(m_originalCaster, nullptr, procAttacker, PROC_FLAG_NONE, PROC_SPELL_TYPE_MASK_ALL, PROC_SPELL_PHASE_CAST, hitMask, this, nullptr, nullptr);
3819
3820 // Call CreatureAI hook OnSpellCast
3821 if (Creature* caster = m_originalCaster->ToCreature())
3822 if (caster->IsAIEnabled())
3823 caster->AI()->OnSpellCast(GetSpellInfo());
3824}
int32_t int32
Definition: Define.h:139
@ CHEAT_COOLDOWN
Definition: Player.h:969
#define sScriptMgr
Definition: ScriptMgr.h:1389
@ SPELL_ATTR2_NOT_AN_ACTION
Definition: SharedDefines.h:516
@ SPELL_ATTR1_DISMISS_PET_FIRST
Definition: SharedDefines.h:451
@ SPELL_ATTR3_TREAT_AS_PERIODIC
Definition: SharedDefines.h:550
@ SPELL_ATTR3_SUPPRESS_CASTER_PROCS
Definition: SharedDefines.h:541
@ SPELL_DAMAGE_CLASS_NONE
Definition: SharedDefines.h:2759
@ SPELL_ATTR12_START_COOLDOWN_ON_CAST_START
Definition: SharedDefines.h:881
DiminishingReturnsType
Definition: SharedDefines.h:5953
@ DRTYPE_PLAYER
Definition: SharedDefines.h:5955
@ DRTYPE_ALL
Definition: SharedDefines.h:5956
@ SPELL_ATTR4_NO_HARMFUL_THREAT
Definition: SharedDefines.h:566
SpellCastResult
Definition: SharedDefines.h:1439
@ SPELL_FAILED_DONT_REPORT
Definition: SharedDefines.h:1472
@ SPELL_FAILED_AURA_BOUNCED
Definition: SharedDefines.h:1450
@ SPELL_CAST_OK
Definition: SharedDefines.h:1762
@ SPELL_FAILED_INTERRUPTED
Definition: SharedDefines.h:1503
@ TARGET_FLAG_TRADE_ITEM
Definition: SpellDefines.h:285
@ TRIGGERED_FULL_MASK
Will return SPELL_FAILED_DONT_REPORT in CheckCast functions.
Definition: SpellDefines.h:261
@ TRIGGERED_IGNORE_POWER_AND_REAGENT_COST
Will ignore Spell and Category cooldowns.
Definition: SpellDefines.h:244
@ TRIGGERED_IGNORE_AURA_INTERRUPT_FLAGS
In Spell::prepare, will be cast directly without setting containers for executed spell.
Definition: SpellDefines.h:250
@ TRIGGERED_IGNORE_CAST_ITEM
Will ignore power and reagent cost.
Definition: SpellDefines.h:245
@ PROC_SPELL_PHASE_CAST
Definition: SpellMgr.h:261
#define sSpellMgr
Definition: SpellMgr.h:824
@ 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:223
@ SPELL_STATE_FINISHED
Definition: Spell.h:221
@ UNIT_FLAG_POSSESSED
Definition: UnitDefines.h:163
@ UNIT_STATE_CASTING
Definition: Unit.h:259
Definition: CreatureAI.h:59
Definition: Creature.h:70
static Creature * ToCreature(Object *o)
Definition: Object.h:205
uint32 GetEntry() const
Definition: Object.h:159
void SetSpellModTakingSpell(Spell *spell, bool apply)
Definition: Player.cpp:22004
bool GetCommandStatus(uint32 command) const
Definition: Player.h:1222
TradeData * GetTradeData() const
Definition: Player.h:1509
Definition: SpellDefines.h:500
WorldObject * GetObjectTarget() const
Definition: Spell.cpp:274
void UpdateTradeSlotItem()
Definition: Spell.cpp:311
ObjectGuid GetObjectTargetGUID() const
Definition: Spell.cpp:279
Item * GetItemTarget() const
Definition: SpellDefines.h:353
uint32 GetTargetMask() const
Definition: SpellDefines.h:332
Unit * GetUnitTarget() const
Definition: Spell.cpp:214
Definition: SpellInfo.h:213
void ResetCooldown(uint32 spellId, bool update=false)
Definition: SpellHistory.cpp:627
void RestoreCharge(uint32 chargeCategoryId)
Definition: SpellHistory.cpp:848
DiminishingReturnsType GetDiminishingReturnsGroupType() const
Definition: SpellInfo.cpp:3231
bool HasHitDelay() const
Definition: SpellInfo.cpp:1722
DiminishingGroup GetDiminishingReturnsGroupForSpell() const
Definition: SpellInfo.cpp:3226
float LaunchDelay
Definition: SpellInfo.h:390
bool IsChanneled() const
Definition: SpellInfo.cpp:1685
uint32 ChargeCategoryId
Definition: SpellInfo.h:415
std::vector< SpellEffectInfo > const & GetEffects() const
Definition: SpellInfo.h:573
SpellInfo const * GetSpellInfo() const
Definition: Spell.h:626
void CallScriptAfterCastHandlers()
Definition: Spell.cpp:8431
void PrepareTriggersExecutedOnHit()
Definition: Spell.cpp:8671
SpellCastTargets m_targets
Definition: Spell.h:587
void handle_immediate()
Definition: Spell.cpp:3841
void SendSpellGo()
Definition: Spell.cpp:4663
void TakeReagents()
Definition: Spell.cpp:5301
void SetExecutedCurrently(bool yes)
Definition: Spell.h:610
void SendInterrupted(uint8 result)
Definition: Spell.cpp:4982
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:4526
void CallScriptOnCastHandlers()
Definition: Spell.cpp:8418
void SendSpellCooldown()
Definition: Spell.cpp:4086
void CallScriptBeforeCastHandlers()
Definition: Spell.cpp:8405
void HandleLaunchPhase()
Definition: Spell.cpp:8154
bool UpdatePointers()
Definition: Spell.cpp:7784
void SetDelayStart(uint64 m_time)
Definition: Spell.h:612
void cancel()
Definition: Spell.cpp:3460
void SelectSpellTargets()
Definition: Spell.cpp:731
SpellCastResult CheckCast(bool strict, int32 *param1=nullptr, int32 *param2=nullptr)
Definition: Spell.cpp:5437
void TakePower()
Definition: Spell.cpp:5184
bool IsPositive() const
Definition: Spell.cpp:8001
void TakeCastItem()
Definition: Spell.cpp:5116
void finish(SpellCastResult result=SPELL_CAST_OK)
Definition: Spell.cpp:4187
ProcFlagsInit m_procAttacker
Definition: Spell.h:728
Definition: TradeData.h:35
Definition: Unit.h:739
ControlList m_Controlled
Definition: Unit.h:1298
void RemoveAurasWithInterruptFlags(InterruptFlags flag, SpellInfo const *source=nullptr)
Definition: Unit.cpp:3981
SpellHistory * GetSpellHistory()
Definition: Unit.h:1544
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:5293
Definition: Object.h:483
SpellCastResult CastSpell(CastSpellTargetArg const &targets, uint32 spellId, CastSpellExtraArgs const &args={ })
Definition: Object.cpp:2832
TC_GAME_API Creature * GetCreature(WorldObject const &u, ObjectGuid const &guid)
Definition: ObjectAccessor.cpp:217
Definition: SpellDefines.h:437
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _handle_finish_phase()

void Spell::_handle_finish_phase ( )
4037{
4038 if (Unit* unitCaster = m_caster->ToUnit())
4039 {
4040 // Take for real after all targets are processed
4042 unitCaster->ClearComboPoints();
4043
4044 // Real add combo points from effects
4045 if (m_comboPointGain)
4046 unitCaster->AddComboPoints(m_comboPointGain);
4047
4049 unitCaster->SetLastExtraAttackSpell(m_spellInfo->Id);
4050 }
4051
4052 // Handle procs on finish
4053 if (!m_originalCaster)
4054 return;
4055
4056 ProcFlagsInit procAttacker = m_procAttacker;
4057 if (!procAttacker)
4058 {
4060 {
4061 if (IsPositive())
4062 procAttacker |= PROC_FLAG_DEAL_HELPFUL_PERIODIC;
4063 else
4064 procAttacker |= PROC_FLAG_DEAL_HARMFUL_PERIODIC;
4065 }
4067 {
4068 if (IsPositive())
4069 procAttacker |= PROC_FLAG_DEAL_HELPFUL_ABILITY;
4070 else
4071 procAttacker |= PROC_FLAG_DEAL_HARMFUL_ABILITY;
4072 }
4073 else
4074 {
4075 if (IsPositive())
4076 procAttacker |= PROC_FLAG_DEAL_HELPFUL_SPELL;
4077 else
4078 procAttacker |= PROC_FLAG_DEAL_HARMFUL_SPELL;
4079 }
4080 }
4081
4084}
@ SPELL_EFFECT_ADD_EXTRA_ATTACKS
Definition: SharedDefines.h:1148
@ PROC_SPELL_PHASE_FINISH
Definition: SpellMgr.h:263
bool HasEffect(SpellEffectName effect) const
Definition: SpellInfo.cpp:1358
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _handle_immediate_phase()

void Spell::_handle_immediate_phase ( )
4017{
4018 // handle some immediate features of the spell here
4020
4021 // handle effects with SPELL_EFFECT_HANDLE_HIT mode
4022 for (SpellEffectInfo const& spellEffectInfo : m_spellInfo->GetEffects())
4023 {
4024 // don't do anything for empty effect
4025 if (!spellEffectInfo.IsEffect())
4026 continue;
4027
4028 // call effect handlers to handle destination hit
4029 HandleEffects(nullptr, nullptr, nullptr, nullptr, spellEffectInfo, SPELL_EFFECT_HANDLE_HIT);
4030 }
4031
4032 // process items
4034}
@ SPELL_EFFECT_HANDLE_HIT
Definition: Spell.h:230
void HandleEffects(Unit *pUnitTarget, Item *pItemTarget, GameObject *pGoTarget, Corpse *pCorpseTarget, SpellEffectInfo const &spellEffectInfo, SpellEffectHandleMode mode)
Definition: Spell.cpp:5411
void DoProcessTargetContainer(Container &targetContainer)
Definition: Spell.cpp:3827
void HandleThreatSpells()
Definition: Spell.cpp:5355
std::vector< ItemTargetInfo > m_UniqueItemInfo
Definition: Spell.h:796
+ 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
2475{
2476 for (SpellEffectInfo const& spellEffectInfo : m_spellInfo->GetEffects())
2477 if (!spellEffectInfo.IsEffect())
2478 effectMask &= ~(1 << spellEffectInfo.EffectIndex);
2479
2480 // no effects left
2481 if (!effectMask)
2482 return;
2483
2484 ObjectGuid targetGUID = corpse->GetGUID();
2485
2486 // Lookup target in already in list
2487 auto ihit = std::find_if(std::begin(m_UniqueCorpseTargetInfo), std::end(m_UniqueCorpseTargetInfo), [targetGUID](CorpseTargetInfo const& target) { return target.TargetGUID == targetGUID; });
2488 if (ihit != std::end(m_UniqueCorpseTargetInfo)) // Found in list
2489 {
2490 // Add only effect mask
2491 ihit->EffectMask |= effectMask;
2492 return;
2493 }
2494
2495 // This is new target calculate data for him
2496 CorpseTargetInfo target;
2497 target.TargetGUID = targetGUID;
2498 target.EffectMask = effectMask;
2499
2500 // Spell have speed - need calculate incoming time
2501 if (m_caster != corpse)
2502 {
2503 float hitDelay = m_spellInfo->LaunchDelay;
2505 hitDelay += m_spellInfo->Speed;
2506 else if (m_spellInfo->Speed > 0.0f)
2507 {
2508 // calculate spell incoming interval
2509 float dist = std::max(m_caster->GetDistance(corpse->GetPositionX(), corpse->GetPositionY(), corpse->GetPositionZ()), 5.0f);
2510 hitDelay += dist / m_spellInfo->Speed;
2511 }
2512
2513 target.TimeDelay = uint64(std::floor(hitDelay * 1000.0f));
2514 }
2515 else
2516 target.TimeDelay = 0LL;
2517
2518 // Calculate minimum incoming time
2519 if (target.TimeDelay && (!m_delayMoment || m_delayMoment > target.TimeDelay))
2520 m_delayMoment = target.TimeDelay;
2521
2522 // Add target to list
2523 m_UniqueCorpseTargetInfo.emplace_back(std::move(target));
2524}
uint64_t uint64
Definition: Define.h:142
@ SPELL_ATTR9_SPECIAL_DELAY_CALCULATION
Definition: SharedDefines.h:751
Definition: ObjectGuid.h:258
float Speed
Definition: SpellInfo.h:389
uint64 m_delayMoment
Definition: Spell.h:691
std::vector< CorpseTargetInfo > m_UniqueCorpseTargetInfo
Definition: Spell.h:805
float GetDistance(WorldObject const *obj) const
Definition: Object.cpp:1050
+ 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
2527{
2528 m_destTargets[effIndex] = dest;
2529}
+ Here is the caller graph for this function:

◆ AddGOTarget()

void Spell::AddGOTarget ( GameObject target,
uint32  effectMask 
)
protected
2394{
2395 for (SpellEffectInfo const& spellEffectInfo : m_spellInfo->GetEffects())
2396 if (!spellEffectInfo.IsEffect() || !CheckEffectTarget(go, spellEffectInfo))
2397 effectMask &= ~(1 << spellEffectInfo.EffectIndex);
2398
2399 // no effects left
2400 if (!effectMask)
2401 return;
2402
2403 ObjectGuid targetGUID = go->GetGUID();
2404
2405 // Lookup target in already in list
2406 auto ihit = std::find_if(std::begin(m_UniqueGOTargetInfo), std::end(m_UniqueGOTargetInfo), [targetGUID](GOTargetInfo const& target) { return target.TargetGUID == targetGUID; });
2407 if (ihit != std::end(m_UniqueGOTargetInfo)) // Found in list
2408 {
2409 // Add only effect mask
2410 ihit->EffectMask |= effectMask;
2411 return;
2412 }
2413
2414 // This is new target calculate data for him
2415
2416 GOTargetInfo target;
2417 target.TargetGUID = targetGUID;
2418 target.EffectMask = effectMask;
2419
2420 // Spell have speed - need calculate incoming time
2421 if (static_cast<WorldObject*>(m_caster) != go)
2422 {
2423 float hitDelay = m_spellInfo->LaunchDelay;
2425 hitDelay += m_spellInfo->Speed;
2426 else if (m_spellInfo->Speed > 0.0f)
2427 {
2428 // calculate spell incoming interval
2429 float dist = std::max(m_caster->GetDistance(go->GetPositionX(), go->GetPositionY(), go->GetPositionZ()), 5.0f);
2430 hitDelay += dist / m_spellInfo->Speed;
2431 }
2432
2433 target.TimeDelay = uint64(std::floor(hitDelay * 1000.0f));
2434 }
2435 else
2436 target.TimeDelay = 0ULL;
2437
2438 // Calculate minimum incoming time
2439 if (target.TimeDelay && (!m_delayMoment || m_delayMoment > target.TimeDelay))
2440 m_delayMoment = target.TimeDelay;
2441
2442 // Add target to list
2443 m_UniqueGOTargetInfo.emplace_back(std::move(target));
2444}
std::vector< GOTargetInfo > m_UniqueGOTargetInfo
Definition: Spell.h:788
bool CheckEffectTarget(Unit const *target, SpellEffectInfo const &spellEffectInfo, Position const *losPosition) const
Definition: Spell.cpp:7856
+ 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
2447{
2448 for (SpellEffectInfo const& spellEffectInfo : m_spellInfo->GetEffects())
2449 if (!spellEffectInfo.IsEffect() || !CheckEffectTarget(item, spellEffectInfo))
2450 effectMask &= ~(1 << spellEffectInfo.EffectIndex);
2451
2452 // no effects left
2453 if (!effectMask)
2454 return;
2455
2456 // Lookup target in already in list
2457 auto ihit = std::find_if(std::begin(m_UniqueItemInfo), std::end(m_UniqueItemInfo), [item](ItemTargetInfo const& target) { return target.TargetItem == item; });
2458 if (ihit != std::end(m_UniqueItemInfo)) // Found in list
2459 {
2460 // Add only effect mask
2461 ihit->EffectMask |= effectMask;
2462 return;
2463 }
2464
2465 // This is new target add data
2466
2467 ItemTargetInfo target;
2468 target.TargetItem = item;
2469 target.EffectMask = effectMask;
2470
2471 m_UniqueItemInfo.emplace_back(std::move(target));
2472}
+ 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
2287{
2288 for (SpellEffectInfo const& spellEffectInfo : m_spellInfo->GetEffects())
2289 if (!spellEffectInfo.IsEffect() || !CheckEffectTarget(target, spellEffectInfo, losPosition))
2290 effectMask &= ~(1 << spellEffectInfo.EffectIndex);
2291
2292 // no effects left
2293 if (!effectMask)
2294 return;
2295
2296 if (checkIfValid)
2297 if (m_spellInfo->CheckTarget(m_caster, target, implicit) != SPELL_CAST_OK) // skip stealth checks for AOE
2298 return;
2299
2300 // Check for effect immune skip if immuned
2301 for (SpellEffectInfo const& spellEffectInfo : m_spellInfo->GetEffects())
2302 if (target->IsImmunedToSpellEffect(m_spellInfo, spellEffectInfo, m_caster))
2303 effectMask &= ~(1 << spellEffectInfo.EffectIndex);
2304
2305 ObjectGuid targetGUID = target->GetGUID();
2306
2307 // Lookup target in already in list
2308 auto ihit = std::find_if(std::begin(m_UniqueTargetInfo), std::end(m_UniqueTargetInfo), [targetGUID](TargetInfo const& target) { return target.TargetGUID == targetGUID; });
2309 if (ihit != std::end(m_UniqueTargetInfo)) // Found in list
2310 {
2311 // Immune effects removed from mask
2312 ihit->EffectMask |= effectMask;
2313 return;
2314 }
2315
2316 // This is new target calculate data for him
2317
2318 // Get spell hit result on target
2319 TargetInfo targetInfo;
2320 targetInfo.TargetGUID = targetGUID; // Store target GUID
2321 targetInfo.EffectMask = effectMask; // Store all effects not immune
2322 targetInfo.IsAlive = target->IsAlive();
2323 targetInfo.Damage = 0;
2324 targetInfo.Healing = 0;
2325 targetInfo.IsCrit = false;
2326
2327 // Calculate hit result
2329 targetInfo.MissCondition = caster->SpellHitResult(target, m_spellInfo, m_canReflect && !(IsPositive() && m_caster->IsFriendlyTo(target)));
2330
2331 // Spell have speed - need calculate incoming time
2332 // Incoming time is zero for self casts. At least I think so.
2333 if (m_caster != target)
2334 {
2335 float hitDelay = m_spellInfo->LaunchDelay;
2336 WorldObject const* missileSource = m_caster;
2338 {
2339 auto previousTargetItr = std::find_if(m_UniqueTargetInfo.rbegin(), m_UniqueTargetInfo.rend(), [effectMask](TargetInfo const& target)
2340 {
2341 return (target.EffectMask & effectMask) != 0;
2342 });
2343 if (previousTargetItr != std::rend(m_UniqueTargetInfo))
2344 {
2345 hitDelay = 0.0f; // this is not the first target in chain, LaunchDelay was already included
2346
2347 if (WorldObject* previousTarget = ObjectAccessor::GetWorldObject(*m_caster, previousTargetItr->TargetGUID))
2348 missileSource = previousTarget;
2349
2350 targetInfo.TimeDelay += previousTargetItr->TimeDelay;
2351 }
2352 }
2353
2355 hitDelay += m_spellInfo->Speed;
2356 else if (m_spellInfo->Speed > 0.0f)
2357 {
2358 // calculate spell incoming interval
2360 float dist = std::max(missileSource->GetDistance(target->GetPositionX(), target->GetPositionY(), target->GetPositionZ()), 5.0f);
2361 hitDelay += dist / m_spellInfo->Speed;
2362 }
2363
2364 targetInfo.TimeDelay += uint64(std::floor(hitDelay * 1000.0f));
2365 }
2366 else
2367 targetInfo.TimeDelay = 0ULL;
2368
2369 // If target reflect spell back to caster
2370 if (targetInfo.MissCondition == SPELL_MISS_REFLECT)
2371 {
2372 // Calculate reflected spell result on caster (shouldn't be able to reflect gameobject spells)
2373 Unit* unitCaster = ASSERT_NOTNULL(m_caster->ToUnit());
2374 targetInfo.ReflectResult = unitCaster->SpellHitResult(unitCaster, m_spellInfo, false); // can't reflect twice
2375
2376 // Proc spell reflect aura when missile hits the original target
2377 target->m_Events.AddEvent(new ProcReflectDelayed(target, m_originalCasterGUID), target->m_Events.CalculateTime(Milliseconds(targetInfo.TimeDelay)));
2378
2379 // Increase time interval for reflected spells by 1.5
2380 targetInfo.TimeDelay += targetInfo.TimeDelay >> 1;
2381 }
2382 else
2383 targetInfo.ReflectResult = SPELL_MISS_NONE;
2384
2385 // Calculate minimum incoming time
2386 if (targetInfo.TimeDelay && (!m_delayMoment || m_delayMoment > targetInfo.TimeDelay))
2387 m_delayMoment = targetInfo.TimeDelay;
2388
2389 // Add target to list
2390 m_UniqueTargetInfo.emplace_back(std::move(targetInfo));
2391}
std::chrono::milliseconds Milliseconds
Milliseconds shorthand typedef.
Definition: Duration.h:29
#define ASSERT_NOTNULL(pointer)
Definition: Errors.h:84
@ SPELL_MISS_REFLECT
Definition: SharedDefines.h:2741
@ SPELL_ATTR4_BOUNCY_CHAIN_MISSILES
Definition: SharedDefines.h:580
Definition: Spell.cpp:2261
SpellCastResult CheckTarget(WorldObject const *caster, WorldObject const *target, bool implicit=true) const
Definition: SpellInfo.cpp:2136
std::vector< TargetInfo > m_UniqueTargetInfo
Definition: Spell.h:778
virtual bool IsImmunedToSpellEffect(SpellInfo const *spellInfo, SpellEffectInfo const &spellEffectInfo, WorldObject const *caster, bool requireImmunityPurgesEffectAttribute=false) const
Definition: Unit.cpp:7372
SpellMissInfo SpellHitResult(Unit *victim, SpellInfo const *spellInfo, bool canReflect=false) const
Definition: Object.cpp:2557
bool IsFriendlyTo(WorldObject const *target) const
Definition: Object.cpp:2801
TC_GAME_API WorldObject * GetWorldObject(WorldObject const &, ObjectGuid const &)
Definition: ObjectAccessor.cpp:101
+ 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
6898{
6899 bool needRecalculateBasePoints = !(m_spellValue->CustomBasePointsMask & (1 << spellEffectInfo.EffectIndex));
6900 return m_caster->CalculateSpellDamage(target, spellEffectInfo, needRecalculateBasePoints ? nullptr : &m_spellValue->EffectBasePoints[spellEffectInfo.EffectIndex], var, m_castItemEntry, m_castItemLevel);
6901}
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:2252
int32 EffectBasePoints[MAX_SPELL_EFFECTS]
Definition: Spell.h:206
uint32 CustomBasePointsMask
Definition: Spell.h:207
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ CalculateDelayMomentForDst()

uint64 Spell::CalculateDelayMomentForDst ( float  launchDelay) const
827{
828 if (m_targets.HasDst())
829 {
830 if (m_targets.HasTraj())
831 {
832 float speed = m_targets.GetSpeedXY();
833 if (speed > 0.0f)
834 return uint64(std::floor((m_targets.GetDist2d() / speed + launchDelay) * 1000.0f));
835 }
837 return uint64(std::floor((m_spellInfo->Speed + launchDelay) * 1000.0f));
838 else if (m_spellInfo->Speed > 0.0f)
839 {
840 // We should not subtract caster size from dist calculation (fixes execution time desync with animation on client, eg. Malleable Goo cast by PP)
841 float dist = m_caster->GetExactDist(*m_targets.GetDstPos());
842 return uint64(std::floor((dist / m_spellInfo->Speed + launchDelay) * 1000.0f));
843 }
844
845 return uint64(std::floor(launchDelay * 1000.0f));
846 }
847
848 return 0;
849}
bool HasTraj() const
Definition: SpellDefines.h:380
bool HasDst() const
Definition: Spell.cpp:421
float GetSpeedXY() const
Definition: SpellDefines.h:388
float GetDist2d() const
Definition: SpellDefines.h:387
WorldLocation const * GetDstPos() const
Definition: Spell.cpp:364
float GetExactDist(float x, float y, float z) const
Definition: Position.h:119
+ 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
830{
831 Unit* unitCaster = GetUnitCasterForEffectHandlers();
832 ASSERT(unitCaster);
833
834 float multiplier = effInfo->Amplitude;
835 if (multiplier <= 0.0f)
836 multiplier = 1.0f;
837
838 float minHeight = effInfo->MiscValue ? effInfo->MiscValue / 10.0f : 0.5f; // Lower bound is blizzlike
839 float maxHeight = effInfo->MiscValueB ? effInfo->MiscValueB / 10.0f : 1000.0f; // Upper bound is unknown
840
841 unitCaster->GetMotionMaster()->CalculateJumpSpeeds(dist, MOVE_RUN, multiplier, minHeight, maxHeight, speedXY, speedZ);
842}
@ MOVE_RUN
Definition: UnitDefines.h:113
void CalculateJumpSpeeds(float dist, UnitMoveType moveType, float speedMultiplier, float minHeight, float maxHeight, float &speedXY, float &speedZ) const
Definition: MotionMaster.cpp:1134
Unit * GetUnitCasterForEffectHandlers() const
Definition: Spell.cpp:8012
MotionMaster * GetMotionMaster()
Definition: Unit.h:1741
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ CallScriptAfterCastHandlers()

void Spell::CallScriptAfterCastHandlers ( )
protected
8432{
8433 for (auto scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
8434 {
8435 (*scritr)->_PrepareScriptCall(SPELL_SCRIPT_HOOK_AFTER_CAST);
8436 auto hookItrEnd = (*scritr)->AfterCast.end(), hookItr = (*scritr)->AfterCast.begin();
8437 for (; hookItr != hookItrEnd; ++hookItr)
8438 (*hookItr).Call(*scritr);
8439
8440 (*scritr)->_FinishScriptCall();
8441 }
8442}
@ SPELL_SCRIPT_HOOK_AFTER_CAST
Definition: SpellScript.h:217
+ Here is the caller graph for this function:

◆ CallScriptAfterHitHandlers()

void Spell::CallScriptAfterHitHandlers ( )
protected
8565{
8566 for (auto scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
8567 {
8568 (*scritr)->_PrepareScriptCall(SPELL_SCRIPT_HOOK_AFTER_HIT);
8569 auto hookItrEnd = (*scritr)->AfterHit.end(), hookItr = (*scritr)->AfterHit.begin();
8570 for (; hookItr != hookItrEnd; ++hookItr)
8571 (*hookItr).Call(*scritr);
8572
8573 (*scritr)->_FinishScriptCall();
8574 }
8575}
@ SPELL_SCRIPT_HOOK_AFTER_HIT
Definition: SpellScript.h:209
+ Here is the caller graph for this function:

◆ CallScriptBeforeCastHandlers()

void Spell::CallScriptBeforeCastHandlers ( )
protected
8406{
8407 for (auto scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
8408 {
8409 (*scritr)->_PrepareScriptCall(SPELL_SCRIPT_HOOK_BEFORE_CAST);
8410 auto hookItrEnd = (*scritr)->BeforeCast.end(), hookItr = (*scritr)->BeforeCast.begin();
8411 for (; hookItr != hookItrEnd; ++hookItr)
8412 (*hookItr).Call(*scritr);
8413
8414 (*scritr)->_FinishScriptCall();
8415 }
8416}
@ SPELL_SCRIPT_HOOK_BEFORE_CAST
Definition: SpellScript.h:214
+ Here is the caller graph for this function:

◆ CallScriptBeforeHitHandlers()

void Spell::CallScriptBeforeHitHandlers ( SpellMissInfo  missInfo)
protected
8538{
8539 for (auto scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
8540 {
8541 (*scritr)->_InitHit();
8542 (*scritr)->_PrepareScriptCall(SPELL_SCRIPT_HOOK_BEFORE_HIT);
8543 auto hookItrEnd = (*scritr)->BeforeHit.end(), hookItr = (*scritr)->BeforeHit.begin();
8544 for (; hookItr != hookItrEnd; ++hookItr)
8545 (*hookItr).Call(*scritr, missInfo);
8546
8547 (*scritr)->_FinishScriptCall();
8548 }
8549}
@ SPELL_SCRIPT_HOOK_BEFORE_HIT
Definition: SpellScript.h:207
+ Here is the caller graph for this function:

◆ CallScriptCalcCastTimeHandlers()

int32 Spell::CallScriptCalcCastTimeHandlers ( int32  originalCastTime)
protected
8464{
8465 for (auto scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
8466 {
8467 (*scritr)->_PrepareScriptCall(SPELL_SCRIPT_HOOK_CALC_CAST_TIME);
8468 castTime = (*scritr)->CalcCastTime(castTime);
8469 (*scritr)->_FinishScriptCall();
8470 }
8471 return castTime;
8472}
@ SPELL_SCRIPT_HOOK_CALC_CAST_TIME
Definition: SpellScript.h:220
+ Here is the caller graph for this function:

◆ CallScriptCalcCritChanceHandlers()

void Spell::CallScriptCalcCritChanceHandlers ( Unit const *  victim,
float &  chance 
)
8578{
8579 for (SpellScript* loadedScript : m_loadedScripts)
8580 {
8581 loadedScript->_PrepareScriptCall(SPELL_SCRIPT_HOOK_CALC_CRIT_CHANCE);
8582 for (SpellScript::OnCalcCritChanceHandler const& hook : loadedScript->OnCalcCritChance)
8583 hook.Call(loadedScript, victim, critChance);
8584
8585 loadedScript->_FinishScriptCall();
8586 }
8587}
@ SPELL_SCRIPT_HOOK_CALC_CRIT_CHANCE
Definition: SpellScript.h:218
Definition: SpellScript.h:318
void Call(SpellScript *spellScript, Unit const *victim, float &critChance) const
Definition: SpellScript.cpp:300
Definition: SpellScript.h:227
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ CallScriptCheckCastHandlers()

SpellCastResult Spell::CallScriptCheckCastHandlers ( )
protected
8445{
8447 for (auto scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
8448 {
8449 (*scritr)->_PrepareScriptCall(SPELL_SCRIPT_HOOK_CHECK_CAST);
8450 auto hookItrEnd = (*scritr)->OnCheckCast.end(), hookItr = (*scritr)->OnCheckCast.begin();
8451 for (; hookItr != hookItrEnd; ++hookItr)
8452 {
8453 SpellCastResult tempResult = (*hookItr).Call(*scritr);
8454 if (retVal == SPELL_CAST_OK)
8455 retVal = tempResult;
8456 }
8457
8458 (*scritr)->_FinishScriptCall();
8459 }
8460 return retVal;
8461}
@ SPELL_SCRIPT_HOOK_CHECK_CAST
Definition: SpellScript.h:213
+ Here is the caller graph for this function:

◆ CallScriptDestinationTargetSelectHandlers()

void Spell::CallScriptDestinationTargetSelectHandlers ( SpellDestination target,
SpellEffIndex  effIndex,
SpellImplicitTargetInfo const &  targetType 
)
protected
8618{
8619 for (auto scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
8620 {
8621 (*scritr)->_PrepareScriptCall(SPELL_SCRIPT_HOOK_DESTINATION_TARGET_SELECT);
8622 auto hookItrEnd = (*scritr)->OnDestinationTargetSelect.end(), hookItr = (*scritr)->OnDestinationTargetSelect.begin();
8623 for (; hookItr != hookItrEnd; ++hookItr)
8624 if (hookItr->IsEffectAffected(m_spellInfo, effIndex) && targetType.GetTarget() == hookItr->GetTarget())
8625 hookItr->Call(*scritr, target);
8626
8627 (*scritr)->_FinishScriptCall();
8628 }
8629}
@ SPELL_SCRIPT_HOOK_DESTINATION_TARGET_SELECT
Definition: SpellScript.h:212
+ 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
8475{
8476 // execute script effect handler hooks and check if effects was prevented
8477 bool preventDefault = false;
8478 for (auto scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
8479 {
8480 (*scritr)->_InitHit();
8481
8483 SpellScriptHookType hookType;
8484 switch (mode)
8485 {
8487 effItr = (*scritr)->OnEffectLaunch.begin();
8488 effEndItr = (*scritr)->OnEffectLaunch.end();
8490 break;
8492 effItr = (*scritr)->OnEffectLaunchTarget.begin();
8493 effEndItr = (*scritr)->OnEffectLaunchTarget.end();
8495 break;
8497 effItr = (*scritr)->OnEffectHit.begin();
8498 effEndItr = (*scritr)->OnEffectHit.end();
8500 break;
8502 effItr = (*scritr)->OnEffectHitTarget.begin();
8503 effEndItr = (*scritr)->OnEffectHitTarget.end();
8505 break;
8506 default:
8507 ABORT();
8508 return false;
8509 }
8510 (*scritr)->_PrepareScriptCall(hookType);
8511 for (; effItr != effEndItr; ++effItr)
8512 // effect execution can be prevented
8513 if (!(*scritr)->_IsEffectPrevented(effIndex) && (*effItr).IsEffectAffected(m_spellInfo, effIndex))
8514 (*effItr).Call(*scritr, effIndex);
8515
8516 if (!preventDefault)
8517 preventDefault = (*scritr)->_IsDefaultEffectPrevented(effIndex);
8518
8519 (*scritr)->_FinishScriptCall();
8520 }
8521 return preventDefault;
8522}
#define ABORT
Definition: Errors.h:74
SpellScriptHookType
Definition: SpellScript.h:201
@ SPELL_SCRIPT_HOOK_EFFECT_HIT
Definition: SpellScript.h:204
@ SPELL_SCRIPT_HOOK_EFFECT_LAUNCH
Definition: SpellScript.h:202
@ SPELL_SCRIPT_HOOK_EFFECT_LAUNCH_TARGET
Definition: SpellScript.h:203
@ SPELL_SCRIPT_HOOK_EFFECT_HIT_TARGET
Definition: SpellScript.h:205
@ SPELL_EFFECT_HANDLE_LAUNCH_TARGET
Definition: Spell.h:229
@ SPELL_EFFECT_HANDLE_HIT_TARGET
Definition: Spell.h:231
iterator end()
Definition: Util.h:426
ContainerType::iterator iterator
Definition: Util.h:408
iterator begin()
Definition: Util.h:421
+ 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
8590{
8591 for (auto scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
8592 {
8593 (*scritr)->_PrepareScriptCall(SPELL_SCRIPT_HOOK_OBJECT_AREA_TARGET_SELECT);
8594 auto hookItrEnd = (*scritr)->OnObjectAreaTargetSelect.end(), hookItr = (*scritr)->OnObjectAreaTargetSelect.begin();
8595 for (; hookItr != hookItrEnd; ++hookItr)
8596 if (hookItr->IsEffectAffected(m_spellInfo, effIndex) && targetType.GetTarget() == hookItr->GetTarget())
8597 hookItr->Call(*scritr, targets);
8598
8599 (*scritr)->_FinishScriptCall();
8600 }
8601}
@ SPELL_SCRIPT_HOOK_OBJECT_AREA_TARGET_SELECT
Definition: SpellScript.h:210
+ 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
8604{
8605 for (auto scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
8606 {
8607 (*scritr)->_PrepareScriptCall(SPELL_SCRIPT_HOOK_OBJECT_TARGET_SELECT);
8608 auto hookItrEnd = (*scritr)->OnObjectTargetSelect.end(), hookItr = (*scritr)->OnObjectTargetSelect.begin();
8609 for (; hookItr != hookItrEnd; ++hookItr)
8610 if (hookItr->IsEffectAffected(m_spellInfo, effIndex) && targetType.GetTarget() == hookItr->GetTarget())
8611 hookItr->Call(*scritr, target);
8612
8613 (*scritr)->_FinishScriptCall();
8614 }
8615}
@ SPELL_SCRIPT_HOOK_OBJECT_TARGET_SELECT
Definition: SpellScript.h:211
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ CallScriptOnCastHandlers()

void Spell::CallScriptOnCastHandlers ( )
protected
8419{
8420 for (auto scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
8421 {
8422 (*scritr)->_PrepareScriptCall(SPELL_SCRIPT_HOOK_ON_CAST);
8423 auto hookItrEnd = (*scritr)->OnCast.end(), hookItr = (*scritr)->OnCast.begin();
8424 for (; hookItr != hookItrEnd; ++hookItr)
8425 (*hookItr).Call(*scritr);
8426
8427 (*scritr)->_FinishScriptCall();
8428 }
8429}
@ SPELL_SCRIPT_HOOK_ON_CAST
Definition: SpellScript.h:215
+ Here is the caller graph for this function:

◆ CallScriptOnHitHandlers()

void Spell::CallScriptOnHitHandlers ( )
protected
8552{
8553 for (auto scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
8554 {
8555 (*scritr)->_PrepareScriptCall(SPELL_SCRIPT_HOOK_HIT);
8556 auto hookItrEnd = (*scritr)->OnHit.end(), hookItr = (*scritr)->OnHit.begin();
8557 for (; hookItr != hookItrEnd; ++hookItr)
8558 (*hookItr).Call(*scritr);
8559
8560 (*scritr)->_FinishScriptCall();
8561 }
8562}
@ SPELL_SCRIPT_HOOK_HIT
Definition: SpellScript.h:208
+ Here is the caller graph for this function:

◆ CallScriptOnPrecastHandler()

void Spell::CallScriptOnPrecastHandler ( )
protected
8396{
8397 for (auto scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
8398 {
8399 (*scritr)->_PrepareScriptCall(SPELL_SCRIPT_HOOK_ON_PRECAST);
8400 (*scritr)->OnPrecast();
8401 (*scritr)->_FinishScriptCall();
8402 }
8403}
@ SPELL_SCRIPT_HOOK_ON_PRECAST
Definition: SpellScript.h:219
+ Here is the caller graph for this function:

◆ CallScriptOnResistAbsorbCalculateHandlers()

void Spell::CallScriptOnResistAbsorbCalculateHandlers ( DamageInfo const &  damageInfo,
uint32 resistAmount,
int32 absorbAmount 
)
8795{
8796 for (auto scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
8797 {
8798 (*scritr)->_PrepareScriptCall(SPELL_SCRIPT_HOOK_ON_RESIST_ABSORB_CALCULATION);
8799 auto hookItrEnd = (*scritr)->OnCalculateResistAbsorb.end(), hookItr = (*scritr)->OnCalculateResistAbsorb.begin();
8800 for (; hookItr != hookItrEnd; ++hookItr)
8801 hookItr->Call(*scritr, damageInfo, resistAmount, absorbAmount);
8802
8803 (*scritr)->_FinishScriptCall();
8804 }
8805}
@ SPELL_SCRIPT_HOOK_ON_RESIST_ABSORB_CALCULATION
Definition: SpellScript.h:216
+ Here is the caller graph for this function:

◆ CallScriptSuccessfulDispel()

void Spell::CallScriptSuccessfulDispel ( SpellEffIndex  effIndex)
protected
8525{
8526 for (auto scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
8527 {
8528 (*scritr)->_PrepareScriptCall(SPELL_SCRIPT_HOOK_EFFECT_SUCCESSFUL_DISPEL);
8529 auto hookItrEnd = (*scritr)->OnEffectSuccessfulDispel.end(), hookItr = (*scritr)->OnEffectSuccessfulDispel.begin();
8530 for (; hookItr != hookItrEnd; ++hookItr)
8531 hookItr->Call(*scritr, effIndex);
8532
8533 (*scritr)->_FinishScriptCall();
8534 }
8535}
@ SPELL_SCRIPT_HOOK_EFFECT_SUCCESSFUL_DISPEL
Definition: SpellScript.h:206
+ Here is the caller graph for this function:

◆ CanAutoCast()

bool Spell::CanAutoCast ( Unit target)
6904{
6905 if (!target)
6906 return (CheckPetCast(target) == SPELL_CAST_OK);
6907
6908 ObjectGuid targetguid = target->GetGUID();
6909
6910 // check if target already has the same or a more powerful aura
6911 for (SpellEffectInfo const& spellEffectInfo : m_spellInfo->GetEffects())
6912 {
6913 if (!spellEffectInfo.IsAura())
6914 continue;
6915
6916 AuraType const& auraType = spellEffectInfo.ApplyAuraName;
6917 Unit::AuraEffectList const& auras = target->GetAuraEffectsByType(auraType);
6918 for (Unit::AuraEffectList::const_iterator auraIt = auras.begin(); auraIt != auras.end(); ++auraIt)
6919 {
6920 if (GetSpellInfo()->Id == (*auraIt)->GetSpellInfo()->Id)
6921 return false;
6922
6923 switch (sSpellMgr->CheckSpellGroupStackRules(GetSpellInfo(), (*auraIt)->GetSpellInfo()))
6924 {
6926 return false;
6928 if (GetCaster() == (*auraIt)->GetCaster())
6929 return false;
6930 break;
6931 case SPELL_GROUP_STACK_RULE_EXCLUSIVE_SAME_EFFECT: // this one has further checks, but i don't think they're necessary for autocast logic
6933 if (abs(spellEffectInfo.BasePoints) <= abs((*auraIt)->GetAmount()))
6934 return false;
6935 break;
6937 default:
6938 break;
6939 }
6940 }
6941 }
6942
6943 SpellCastResult result = CheckPetCast(target);
6944 if (result == SPELL_CAST_OK || result == SPELL_FAILED_UNIT_NOT_INFRONT)
6945 {
6946 // do not check targets for ground-targeted spells (we target them on top of the intended target anyway)
6947 if (GetSpellInfo()->ExplicitTargetMask & TARGET_FLAG_DEST_LOCATION)
6948 return true;
6950 //check if among target units, our WANTED target is as well (->only self cast spells return false)
6951 for (auto ihit = m_UniqueTargetInfo.begin(); ihit != m_UniqueTargetInfo.end(); ++ihit)
6952 if (ihit->TargetGUID == targetguid)
6953 return true;
6954 }
6955 // either the cast failed or the intended target wouldn't be hit
6956 return false;
6957}
@ SPELL_FAILED_UNIT_NOT_INFRONT
Definition: SharedDefines.h:1597
AuraType
Definition: SpellAuraDefines.h:93
@ TARGET_FLAG_DEST_LOCATION
Definition: SpellDefines.h:279
@ SPELL_GROUP_STACK_RULE_EXCLUSIVE_FROM_SAME_CASTER
Definition: SpellMgr.h:382
@ SPELL_GROUP_STACK_RULE_EXCLUSIVE
Definition: SpellMgr.h:381
@ SPELL_GROUP_STACK_RULE_DEFAULT
Definition: SpellMgr.h:380
@ SPELL_GROUP_STACK_RULE_EXCLUSIVE_SAME_EFFECT
Definition: SpellMgr.h:383
@ SPELL_GROUP_STACK_RULE_EXCLUSIVE_HIGHEST
Definition: SpellMgr.h:384
uint32 Id
Definition: Spell.h:570
WorldObject * GetCaster() const
Definition: Spell.h:623
SpellCastResult CheckPetCast(Unit *target)
Definition: Spell.cpp:6605
AuraEffectList const & GetAuraEffectsByType(AuraType type) const
Definition: Unit.h:1408
std::list< AuraEffect * > AuraEffectList
Definition: Unit.h:756
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ cancel()

void Spell::cancel ( )
3461{
3463 return;
3464
3465 uint32 oldState = m_spellState;
3467
3468 m_autoRepeat = false;
3469 switch (oldState)
3470 {
3473 [[fallthrough]];
3475 SendInterrupted(0);
3477 break;
3478
3480 for (TargetInfo const& targetInfo : m_UniqueTargetInfo)
3481 if (targetInfo.MissCondition == SPELL_MISS_NONE)
3482 if (Unit* unit = m_caster->GetGUID() == targetInfo.TargetGUID ? m_caster->ToUnit() : ObjectAccessor::GetUnit(*m_caster, targetInfo.TargetGUID))
3483 unit->RemoveOwnedAura(m_spellInfo->Id, m_originalCasterGUID, 0, AURA_REMOVE_BY_CANCEL);
3484
3486 SendInterrupted(0);
3488
3489 m_appliedMods.clear();
3490 break;
3491
3492 default:
3493 break;
3494 }
3495
3497 if (m_selfContainer && *m_selfContainer == this)
3498 *m_selfContainer = nullptr;
3499
3500 // originalcaster handles gameobjects/dynobjects for gob caster
3501 if (m_originalCaster)
3502 {
3504 if (m_spellInfo->IsChanneled()) // if not channeled then the object for the current cast wasn't summoned yet
3506 }
3507
3508 //set state back so finish will be processed
3509 m_spellState = oldState;
3510
3512}
@ AURA_REMOVE_BY_CANCEL
Definition: SpellAuraDefines.h:67
@ SPELL_STATE_PREPARING
Definition: Spell.h:219
@ SPELL_STATE_CASTING
Definition: Spell.h:220
void SendChannelUpdate(uint32 time)
Definition: Spell.cpp:5001
void CancelGlobalCooldown()
Definition: Spell.cpp:8770
void SetReferencedFromCurrent(bool yes)
Definition: Spell.h:608
UsedSpellMods m_appliedMods
Definition: Spell.h:591
void RemoveGameObject(GameObject *gameObj, bool del)
Definition: Unit.cpp:5120
void RemoveDynObject(uint32 spellId)
Definition: Unit.cpp:5060
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ CancelGlobalCooldown()

void Spell::CancelGlobalCooldown ( )
protected
8771{
8773 return;
8774
8776 return;
8777
8778 // Cancel global cooldown when interrupting current cast
8780 return;
8781
8783}
bool CanHaveGlobalCooldown(WorldObject const *caster)
Definition: Spell.cpp:8702
@ CURRENT_GENERIC_SPELL
Definition: Unit.h:579
void CancelGlobalCooldown(SpellInfo const *spellInfo)
Definition: SpellHistory.cpp:945
uint32 StartRecoveryTime
Definition: SpellInfo.h:370
Spell * GetCurrentSpell(CurrentSpellTypes spellType) const
Definition: Unit.h:1529
+ 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
8655{
8656 bool onlyOnTarget = (triggeredByAura && (triggeredByAura->HasAttribute(SPELL_ATTR4_CLASS_TRIGGER_ONLY_ON_TARGET)));
8657 if (!onlyOnTarget)
8658 return true;
8659
8660 // If triggeredByAura has SPELL_ATTR4_CLASS_TRIGGER_ONLY_ON_TARGET then it can only proc on either noncaster units...
8661 if (unit != m_caster)
8662 return true;
8663
8664 // ... or caster if it is the only target
8665 if (m_UniqueTargetInfo.size() == 1)
8666 return true;
8667
8668 return false;
8669}
@ SPELL_ATTR4_CLASS_TRIGGER_ONLY_ON_TARGET
Definition: SharedDefines.h:563
+ 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
8269{
8270 if (!lockId) // possible case for GO and maybe for items.
8271 return SPELL_CAST_OK;
8272
8273 Unit const* unitCaster = m_caster->ToUnit();
8274 if (!unitCaster)
8276
8277 // Get LockInfo
8278 LockEntry const* lockInfo = sLockStore.LookupEntry(lockId);
8279
8280 if (!lockInfo)
8282
8283 bool reqKey = false; // some locks not have reqs
8284
8285 for (int j = 0; j < MAX_LOCK_CASE; ++j)
8286 {
8287 switch (lockInfo->Type[j])
8288 {
8289 // check key item (many fit cases can be)
8290 case LOCK_KEY_ITEM:
8291 if (lockInfo->Index[j] && m_CastItem && int32(m_CastItem->GetEntry()) == lockInfo->Index[j])
8292 return SPELL_CAST_OK;
8293 reqKey = true;
8294 break;
8295 // check key skill (only single first fit case can be)
8296 case LOCK_KEY_SKILL:
8297 {
8298 reqKey = true;
8299
8300 // wrong locktype, skip
8301 if (effect.MiscValue != lockInfo->Index[j])
8302 continue;
8303
8304 skillId = SkillByLockType(LockType(lockInfo->Index[j]));
8305
8306 if (skillId != SKILL_NONE || lockInfo->Index[j] == LOCKTYPE_LOCKPICKING)
8307 {
8308 reqSkillValue = lockInfo->Skill[j];
8309
8310 // castitem check: rogue using skeleton keys. the skill values should not be added in this case.
8311 skillValue = 0;
8312 if (!m_CastItem && unitCaster->GetTypeId() == TYPEID_PLAYER)
8313 skillValue = unitCaster->ToPlayer()->GetSkillValue(skillId);
8314 else if (lockInfo->Index[j] == LOCKTYPE_LOCKPICKING)
8315 skillValue = unitCaster->GetLevel() * 5;
8316
8317 // skill bonus provided by casting spell (mostly item spells)
8318 // add the effect base points modifier from the spell cast (cheat lock / skeleton key etc.)
8319 if (effect.TargetA.GetTarget() == TARGET_GAMEOBJECT_ITEM_TARGET || effect.TargetB.GetTarget() == TARGET_GAMEOBJECT_ITEM_TARGET)
8320 skillValue += effect.CalcValue();
8321
8322 if (skillValue < reqSkillValue)
8324 }
8325
8326 return SPELL_CAST_OK;
8327 }
8328 case LOCK_KEY_SPELL:
8329 if (m_spellInfo->Id == uint32(lockInfo->Index[j]))
8330 return SPELL_CAST_OK;
8331 reqKey = true;
8332 break;
8333 }
8334 }
8335
8336 if (reqKey)
8338
8339 return SPELL_CAST_OK;
8340}
DB2Storage< LockEntry > sLockStore("Lock.db2", &LockLoadInfo::Instance)
#define MAX_LOCK_CASE
Definition: DB2Structure.h:2572
@ TARGET_GAMEOBJECT_ITEM_TARGET
Definition: SharedDefines.h:2598
LockType
Definition: SharedDefines.h:4430
@ LOCKTYPE_LOCKPICKING
Definition: SharedDefines.h:4431
@ LOCK_KEY_ITEM
Definition: SharedDefines.h:4423
@ LOCK_KEY_SKILL
Definition: SharedDefines.h:4424
@ LOCK_KEY_SPELL
Definition: SharedDefines.h:4425
constexpr SkillType SkillByLockType(LockType locktype)
Definition: SharedDefines.h:5641
@ SKILL_NONE
Definition: SharedDefines.h:5280
@ SPELL_FAILED_BAD_TARGETS
Definition: SharedDefines.h:1453
@ SPELL_FAILED_LOW_CASTLEVEL
Definition: SharedDefines.h:1513
uint16 GetSkillValue(uint32 skill) const
Definition: Player.cpp:6037
uint8 GetLevel() const
Definition: Unit.h:855
Definition: DB2Structure.h:2575
std::array< uint8, MAX_LOCK_CASE > Type
Definition: DB2Structure.h:2580
std::array< uint16, MAX_LOCK_CASE > Skill
Definition: DB2Structure.h:2579
std::array< int32, MAX_LOCK_CASE > Index
Definition: DB2Structure.h:2578
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ cast()

void Spell::cast ( bool  skipCheck = false)
3515{
3516 Player* modOwner = m_caster->GetSpellModOwner();
3517 Spell* lastSpellMod = nullptr;
3518 if (modOwner)
3519 {
3520 lastSpellMod = modOwner->m_spellModTakingSpell;
3521 if (lastSpellMod)
3522 modOwner->SetSpellModTakingSpell(lastSpellMod, false);
3523 }
3524
3525 _cast(skipCheck);
3526
3527 if (lastSpellMod)
3528 modOwner->SetSpellModTakingSpell(lastSpellMod, true);
3529}
Definition: Spell.h:239
void _cast(bool skipCheck=false)
Definition: Spell.cpp:3531
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ CheckArenaAndRatedBattlegroundCastRules()

SpellCastResult Spell::CheckArenaAndRatedBattlegroundCastRules ( )
6843{
6844 bool isRatedBattleground = false; // NYI
6845 bool isArena = !isRatedBattleground;
6846
6847 // check USABLE attributes
6848 // USABLE takes precedence over NOT_USABLE
6850 return SPELL_CAST_OK;
6851
6853 return SPELL_CAST_OK;
6854
6855 // check NOT_USABLE attributes
6858
6861
6862 // check cooldowns
6863 uint32 spellCooldown = m_spellInfo->GetRecoveryTime();
6864 if (isArena && spellCooldown > 10 * MINUTE * IN_MILLISECONDS) // not sure if still needed
6866
6867 if (isRatedBattleground && spellCooldown > 15 * MINUTE * IN_MILLISECONDS)
6869
6870 return SPELL_CAST_OK;
6871}
@ IN_MILLISECONDS
Definition: Common.h:51
@ MINUTE
Definition: Common.h:45
@ SPELL_ATTR9_USABLE_IN_RATED_BATTLEGROUNDS
Definition: SharedDefines.h:761
@ SPELL_ATTR9_NOT_USABLE_IN_ARENA
Definition: SharedDefines.h:756
@ SPELL_ATTR4_IGNORE_DEFAULT_ARENA_RESTRICTIONS
Definition: SharedDefines.h:579
@ SPELL_ATTR4_NOT_IN_ARENA_OR_RATED_BATTLEGROUND
Definition: SharedDefines.h:578
@ SPELL_FAILED_NOT_IN_RATED_BATTLEGROUND
Definition: SharedDefines.h:1616
@ SPELL_FAILED_NOT_IN_ARENA
Definition: SharedDefines.h:1683
uint32 GetRecoveryTime() const
Definition: SpellInfo.cpp:3911
+ 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
5438{
5439 // check death state
5442
5443 // 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
5445 {
5448 }
5449
5450 // check cooldowns to prevent cheating
5451 if (!m_spellInfo->IsPassive())
5452 {
5453 if (Player const* playerCaster = m_caster->ToPlayer())
5454 {
5455 //can cast triggered (by aura only?) spells while have this flag
5457 {
5458 // These two auras check SpellFamilyName defined by db2 class data instead of current spell SpellFamilyName
5459 if (playerCaster->HasAuraType(SPELL_AURA_DISABLE_CASTING_EXCEPT_ABILITIES)
5463 && !playerCaster->HasAuraTypeWithFamilyFlags(SPELL_AURA_DISABLE_CASTING_EXCEPT_ABILITIES, sChrClassesStore.AssertEntry(playerCaster->GetClass())->SpellClassSet, m_spellInfo->SpellFamilyFlags))
5465
5466 if (playerCaster->HasAuraType(SPELL_AURA_DISABLE_ATTACKING_EXCEPT_ABILITIES))
5467 {
5468 if (!playerCaster->HasAuraTypeWithFamilyFlags(SPELL_AURA_DISABLE_ATTACKING_EXCEPT_ABILITIES, sChrClassesStore.AssertEntry(playerCaster->GetClass())->SpellClassSet, m_spellInfo->SpellFamilyFlags))
5469 {
5480 }
5481 }
5482 }
5483
5484 // check if we are using a potion in combat for the 2nd+ time. Cooldown is added only after caster gets out of combat
5485 if (!IsIgnoringCooldowns() && playerCaster->GetLastPotionId() && m_CastItem && (m_CastItem->IsPotion() || m_spellInfo->IsCooldownStartedOnEvent()))
5487 }
5488
5489 if (!IsIgnoringCooldowns() && m_caster->ToUnit())
5490 {
5492 {
5495 else
5497 }
5498
5501 }
5502 }
5503
5505 {
5508 }
5509
5510 // Check global cooldown
5513
5514 // only triggered spells can be processed an ended battleground
5517 if (bg->GetStatus() == STATUS_WAIT_LEAVE)
5519
5521 {
5523 !m_caster->IsOutdoors())
5525
5529 }
5530
5531 if (Unit* unitCaster = m_caster->ToUnit())
5532 {
5533 if (m_spellInfo->HasAttribute(SPELL_ATTR5_NOT_AVAILABLE_WHILE_CHARMED) && unitCaster->IsCharmed())
5534 return SPELL_FAILED_CHARMED;
5535
5536 // only check at first call, Stealth auras are already removed at second call
5537 // for now, ignore triggered spells
5539 {
5540 bool checkForm = true;
5541 // Ignore form req aura
5542 Unit::AuraEffectList const& ignore = unitCaster->GetAuraEffectsByType(SPELL_AURA_MOD_IGNORE_SHAPESHIFT);
5543 for (AuraEffect const* aurEff : ignore)
5544 {
5545 if (!aurEff->IsAffectingSpell(m_spellInfo))
5546 continue;
5547
5548 checkForm = false;
5549 break;
5550 }
5551
5552 if (checkForm)
5553 {
5554 // Cannot be used in this stance/form
5555 SpellCastResult shapeError = m_spellInfo->CheckShapeshift(unitCaster->GetShapeshiftForm());
5556 if (shapeError != SPELL_CAST_OK)
5557 return shapeError;
5558
5559 if (m_spellInfo->HasAttribute(SPELL_ATTR0_ONLY_STEALTHED) && !(unitCaster->HasStealthAura()))
5561 }
5562 }
5563
5564 bool reqCombat = true;
5565 Unit::AuraEffectList const& stateAuras = unitCaster->GetAuraEffectsByType(SPELL_AURA_ABILITY_IGNORE_AURASTATE);
5566 for (Unit::AuraEffectList::const_iterator j = stateAuras.begin(); j != stateAuras.end(); ++j)
5567 {
5568 if ((*j)->IsAffectingSpell(m_spellInfo))
5569 {
5570 m_needComboPoints = false;
5571 if ((*j)->GetMiscValue() == 1)
5572 {
5573 reqCombat = false;
5574 break;
5575 }
5576 }
5577 }
5578
5579 // caster state requirements
5580 // not for triggered spells (needed by execute)
5582 {
5583 if (m_spellInfo->CasterAuraState && !unitCaster->HasAuraState(AuraStateType(m_spellInfo->CasterAuraState), m_spellInfo, unitCaster))
5585 if (m_spellInfo->ExcludeCasterAuraState && unitCaster->HasAuraState(AuraStateType(m_spellInfo->ExcludeCasterAuraState), m_spellInfo, unitCaster))
5587
5588 // Note: spell 62473 requres casterAuraSpell = triggering spell
5589 if (m_spellInfo->CasterAuraSpell && !unitCaster->HasAura(m_spellInfo->CasterAuraSpell))
5593
5594 if (m_spellInfo->CasterAuraType && !unitCaster->HasAuraType(m_spellInfo->CasterAuraType))
5596 if (m_spellInfo->ExcludeCasterAuraType && unitCaster->HasAuraType(m_spellInfo->ExcludeCasterAuraType))
5598
5599 if (reqCombat && unitCaster->IsInCombat() && !m_spellInfo->CanBeUsedInCombat())
5601 }
5602
5603 // Check vehicle flags
5605 {
5606 SpellCastResult vehicleCheck = m_spellInfo->CheckVehicle(unitCaster);
5607 if (vehicleCheck != SPELL_CAST_OK)
5608 return vehicleCheck;
5609 }
5610 }
5611
5612 // check spell cast conditions from database
5613 {
5615 if (!sConditionMgr->IsObjectMeetingNotGroupedConditions(CONDITION_SOURCE_TYPE_SPELL, m_spellInfo->Id, condInfo))
5616 {
5617 // mLastFailedCondition can be NULL if there was an error processing the condition in Condition::Meets (i.e. wrong data for ConditionTarget or others)
5618 if (condInfo.mLastFailedCondition && condInfo.mLastFailedCondition->ErrorType)
5619 {
5623 }
5624
5625 if (!condInfo.mLastFailedCondition || !condInfo.mLastFailedCondition->ConditionTarget)
5628 }
5629 }
5630
5631 // Don't check explicit target for passive spells (workaround) (check should be skipped only for learn case)
5632 // those spells may have incorrect target entries or not filled at all (for example 15332)
5633 // such spells when learned are not targeting anyone using targeting system, they should apply directly to caster instead
5634 // also, such casts shouldn't be sent to client
5636 {
5637 // Check explicit target for m_originalCaster - todo: get rid of such workarounds
5638 WorldObject* caster = m_caster;
5639 // in case of gameobjects like traps, we need the gameobject itself to check target validity
5640 // otherwise, if originalCaster is far away and cannot detect the target, the trap would not hit the target
5641 if (m_originalCaster && !caster->ToGameObject())
5642 caster = m_originalCaster;
5643
5645 if (castResult != SPELL_CAST_OK)
5646 return castResult;
5647 }
5648
5649 if (Unit* target = m_targets.GetUnitTarget())
5650 {
5651 SpellCastResult castResult = m_spellInfo->CheckTarget(m_caster, target, m_caster->GetTypeId() == TYPEID_GAMEOBJECT); // skip stealth checks for GO casts
5652 if (castResult != SPELL_CAST_OK)
5653 return castResult;
5654
5655 // If it's not a melee spell, check if vision is obscured by SPELL_AURA_INTERFERE_TARGETTING
5657 {
5658 if (Unit const* unitCaster = m_caster->ToUnit())
5659 {
5660 for (AuraEffect const* auraEff : unitCaster->GetAuraEffectsByType(SPELL_AURA_INTERFERE_TARGETTING))
5661 if (!unitCaster->IsFriendlyTo(auraEff->GetCaster()) && !target->HasAura(auraEff->GetId(), auraEff->GetCasterGUID()))
5663
5664 for (AuraEffect const* auraEff : target->GetAuraEffectsByType(SPELL_AURA_INTERFERE_TARGETTING))
5665 if (!unitCaster->IsFriendlyTo(auraEff->GetCaster()) && (!target->HasAura(auraEff->GetId(), auraEff->GetCasterGUID()) || !unitCaster->HasAura(auraEff->GetId(), auraEff->GetCasterGUID())))
5667 }
5668 }
5669
5670 if (target != m_caster)
5671 {
5672 // Must be behind the target
5673 if ((m_spellInfo->HasAttribute(SPELL_ATTR0_CU_REQ_CASTER_BEHIND_TARGET)) && target->HasInArc(static_cast<float>(M_PI), m_caster))
5675
5676 // Target must be facing you
5677 if ((m_spellInfo->HasAttribute(SPELL_ATTR0_CU_REQ_TARGET_FACING_CASTER)) && !target->HasInArc(static_cast<float>(M_PI), m_caster))
5679
5680 // Ignore LOS for gameobjects casts
5682 {
5683 WorldObject* losTarget = m_caster;
5686 losTarget = dynObj;
5687
5690 }
5691 }
5692 }
5693
5694 // Check for line of sight for spells with dest
5695 if (m_targets.HasDst())
5696 {
5697 float x, y, z;
5698 m_targets.GetDstPos()->GetPosition(x, y, z);
5699
5702 }
5703
5704 // check pet presence
5705 if (Unit* unitCaster = m_caster->ToUnit())
5706 {
5708 if (!unitCaster->GetPetGUID().IsEmpty())
5710
5711 for (SpellEffectInfo const& spellEffectInfo : m_spellInfo->GetEffects())
5712 {
5713 if (spellEffectInfo.TargetA.GetTarget() == TARGET_UNIT_PET)
5714 {
5715 if (!unitCaster->GetGuardianPet())
5716 {
5717 if (m_triggeredByAuraSpell) // not report pet not existence for triggered spells
5719 else
5720 return SPELL_FAILED_NO_PET;
5721 }
5722 break;
5723 }
5724 }
5725 }
5726
5727 // Spell cast only in battleground
5729 if (!m_caster->GetMap()->IsBattleground())
5731
5732 // do not allow spells to be cast in arenas or rated battlegrounds
5733 if (Player* player = m_caster->ToPlayer())
5734 if (player->InArena()/* || player->InRatedBattleGround() NYI*/)
5735 {
5737 if (castResult != SPELL_CAST_OK)
5738 return castResult;
5739 }
5740
5741 // zone check
5743 {
5744 uint32 zone, area;
5745 m_caster->GetZoneAndAreaId(zone, area);
5746
5748 if (locRes != SPELL_CAST_OK)
5749 return locRes;
5750 }
5751
5752 // not let players cast spells at mount (and let do it to creatures)
5754 {
5756 {
5757 if (m_caster->ToPlayer()->IsInFlight())
5759 else
5761 }
5762 }
5763
5764 // check spell focus object
5766 {
5768 {
5770 if (!focusObject)
5772 }
5773 }
5774
5775 SpellCastResult castResult = SPELL_CAST_OK;
5776
5777 // always (except passive spells) check items (only player related checks)
5778 if (!m_spellInfo->IsPassive())
5779 {
5780 castResult = CheckItems(param1, param2);
5781 if (castResult != SPELL_CAST_OK)
5782 return castResult;
5783 }
5784
5785 // Triggered spells also have range check
5787 castResult = CheckRange(strict);
5788 if (castResult != SPELL_CAST_OK)
5789 return castResult;
5790
5792 {
5793 castResult = CheckPower();
5794 if (castResult != SPELL_CAST_OK)
5795 return castResult;
5796 }
5797
5799 {
5800 castResult = CheckCasterAuras(param1);
5801 if (castResult != SPELL_CAST_OK)
5802 return castResult;
5803 }
5804
5805 // script hook
5806 castResult = CallScriptCheckCastHandlers();
5807 if (castResult != SPELL_CAST_OK)
5808 return castResult;
5809
5810 uint32 approximateAuraEffectMask = 0;
5811 uint32 nonAuraEffectMask = 0;
5812 for (SpellEffectInfo const& spellEffectInfo : m_spellInfo->GetEffects())
5813 {
5814 // for effects of spells that have only one target
5815 switch (spellEffectInfo.Effect)
5816 {
5817 case SPELL_EFFECT_DUMMY:
5818 {
5819 if (m_spellInfo->Id == 19938) // Awaken Peon
5820 {
5821 Unit* unit = m_targets.GetUnitTarget();
5822 if (!unit || !unit->HasAura(17743))
5824 }
5825 else if (m_spellInfo->Id == 31789) // Righteous Defense
5826 {
5829
5830 Unit* target = m_targets.GetUnitTarget();
5831 if (!target || !target->IsFriendlyTo(m_caster) || target->getAttackers().empty())
5833
5834 }
5835 break;
5836 }
5838 {
5839 if (spellEffectInfo.TargetA.GetTarget() != TARGET_UNIT_PET)
5840 break;
5841
5842 Pet* pet = m_caster->ToPlayer()->GetPet();
5843 if (!pet)
5844 return SPELL_FAILED_NO_PET;
5845
5846 SpellInfo const* learn_spellproto = sSpellMgr->GetSpellInfo(spellEffectInfo.TriggerSpell, DIFFICULTY_NONE);
5847 if (!learn_spellproto)
5849
5850 if (m_spellInfo->SpellLevel > pet->GetLevel())
5851 return SPELL_FAILED_LOWLEVEL;
5852
5853 break;
5854 }
5856 {
5859 if (Guild* guild = m_caster->ToPlayer()->GetGuild())
5860 if (guild->GetLeaderGUID() != m_caster->ToPlayer()->GetGUID())
5862 break;
5863 }
5865 {
5866 // check target only for unit target case
5867 if (Unit* unit = m_targets.GetUnitTarget())
5868 {
5871
5872 Pet* pet = unit->ToPet();
5873 if (!pet || pet->GetOwner() != m_caster)
5875
5876 SpellInfo const* learn_spellproto = sSpellMgr->GetSpellInfo(spellEffectInfo.TriggerSpell, DIFFICULTY_NONE);
5877
5878 if (!learn_spellproto)
5880
5881 if (m_spellInfo->SpellLevel > pet->GetLevel())
5882 return SPELL_FAILED_LOWLEVEL;
5883 }
5884 break;
5885 }
5887 {
5890
5891 Player* caster = m_caster->ToPlayer();
5892 if (!caster->HasSpell(m_misc.SpellId))
5894
5895 if (uint32 glyphId = spellEffectInfo.MiscValue)
5896 {
5897 GlyphPropertiesEntry const* glyphProperties = sGlyphPropertiesStore.LookupEntry(glyphId);
5898 if (!glyphProperties)
5900
5901 std::vector<uint32> const* glyphBindableSpells = sDB2Manager.GetGlyphBindableSpells(glyphId);
5902 if (!glyphBindableSpells)
5904
5905 if (std::find(glyphBindableSpells->begin(), glyphBindableSpells->end(), m_misc.SpellId) == glyphBindableSpells->end())
5907
5908 if (std::vector<uint32> const* glyphRequiredSpecs = sDB2Manager.GetGlyphRequiredSpecs(glyphId))
5909 {
5910 if (!caster->GetPrimarySpecialization())
5912
5913 if (std::find(glyphRequiredSpecs->begin(), glyphRequiredSpecs->end(), caster->GetPrimarySpecialization()) == glyphRequiredSpecs->end())
5915 }
5916
5917 uint32 replacedGlyph = 0;
5918 for (uint32 activeGlyphId : caster->GetGlyphs(caster->GetActiveTalentGroup()))
5919 {
5920 if (std::vector<uint32> const* activeGlyphBindableSpells = sDB2Manager.GetGlyphBindableSpells(activeGlyphId))
5921 {
5922 if (std::find(activeGlyphBindableSpells->begin(), activeGlyphBindableSpells->end(), m_misc.SpellId) != activeGlyphBindableSpells->end())
5923 {
5924 replacedGlyph = activeGlyphId;
5925 break;
5926 }
5927 }
5928 }
5929
5930 for (uint32 activeGlyphId : caster->GetGlyphs(caster->GetActiveTalentGroup()))
5931 {
5932 if (activeGlyphId == replacedGlyph)
5933 continue;
5934
5935 if (activeGlyphId == glyphId)
5937
5938 if (sGlyphPropertiesStore.AssertEntry(activeGlyphId)->GlyphExclusiveCategoryID == glyphProperties->GlyphExclusiveCategoryID)
5940 }
5941 }
5942 break;
5943 }
5945 {
5948
5949 Item* foodItem = m_targets.GetItemTarget();
5950 if (!foodItem)
5952
5953 Pet* pet = m_caster->ToPlayer()->GetPet();
5954 if (!pet)
5955 return SPELL_FAILED_NO_PET;
5956
5957 if (!pet->HaveInDiet(foodItem->GetTemplate()))
5959
5960 if (foodItem->GetTemplate()->GetBaseItemLevel() + 30 <= pet->GetLevel())
5962
5963 if (m_caster->ToPlayer()->IsInCombat() || pet->IsInCombat())
5965
5966 break;
5967 }
5969 {
5970 Unit* unitCaster = m_caster->ToUnit();
5971 if (!unitCaster)
5973
5975 return SPELL_FAILED_ROOTED;
5976
5977 if (GetSpellInfo()->NeedsExplicitUnitTarget())
5978 {
5979 Unit* target = m_targets.GetUnitTarget();
5980 if (!target)
5982
5983 // first we must check to see if the target is in LoS. A path can usually be built but LoS matters for charge spells
5984 if (!target->IsWithinLOSInMap(unitCaster)) //Do full LoS/Path check. Don't exclude m2
5986
5987 float objSize = target->GetCombatReach();
5988 float range = m_spellInfo->GetMaxRange(true, unitCaster, this) * 1.5f + objSize; // can't be overly strict
5989
5990 m_preGeneratedPath = std::make_unique<PathGenerator>(unitCaster);
5991 m_preGeneratedPath->SetPathLengthLimit(range);
5992
5993 // first try with raycast, if it fails fall back to normal path
5994 bool result = m_preGeneratedPath->CalculatePath(target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), false);
5995 if (m_preGeneratedPath->GetPathType() & PATHFIND_SHORT)
5996 return SPELL_FAILED_NOPATH;
5997 else if (!result || m_preGeneratedPath->GetPathType() & (PATHFIND_NOPATH | PATHFIND_INCOMPLETE))
5998 return SPELL_FAILED_NOPATH;
5999 else if (m_preGeneratedPath->IsInvalidDestinationZ(target)) // Check position z, if not in a straight line
6000 return SPELL_FAILED_NOPATH;
6001
6002 m_preGeneratedPath->ShortenPathUntilDist(PositionToVector3(target), objSize); // move back
6003 }
6004 break;
6005 }
6007 {
6010
6013
6014 Creature* creature = m_targets.GetUnitTarget()->ToCreature();
6015 Loot* loot = creature->GetLootForPlayer(m_caster->ToPlayer());
6016 if (loot && (!loot->isLooted() || loot->loot_type == LOOT_SKINNING))
6018
6019 uint32 skill = creature->GetCreatureTemplate()->GetRequiredLootSkill();
6020
6021 int32 skillValue = m_caster->ToPlayer()->GetSkillValue(skill);
6023 int32 ReqValue = (skillValue < 100 ? (TargetLevel-10) * 10 : TargetLevel * 5);
6024 if (ReqValue > skillValue)
6026
6027 break;
6028 }
6030 {
6031 if (spellEffectInfo.TargetA.GetTarget() != TARGET_GAMEOBJECT_TARGET &&
6032 spellEffectInfo.TargetA.GetTarget() != TARGET_GAMEOBJECT_ITEM_TARGET)
6033 break;
6034
6035 if (m_caster->GetTypeId() != TYPEID_PLAYER // only players can open locks, gather etc.
6036 // we need a go target in case of TARGET_GAMEOBJECT_TARGET
6037 || (spellEffectInfo.TargetA.GetTarget() == TARGET_GAMEOBJECT_TARGET && !m_targets.GetGOTarget()))
6039
6040 Item* pTempItem = nullptr;
6042 {
6043 if (TradeData* pTrade = m_caster->ToPlayer()->GetTradeData())
6044 pTempItem = pTrade->GetTraderData()->GetItem(TRADE_SLOT_NONTRADED);
6045 }
6048
6049 // we need a go target, or an openable item target in case of TARGET_GAMEOBJECT_ITEM_TARGET
6050 if (spellEffectInfo.TargetA.GetTarget() == TARGET_GAMEOBJECT_ITEM_TARGET &&
6052 (!pTempItem || !pTempItem->GetTemplate()->GetLockID() || !pTempItem->IsLocked()))
6054
6055 if (m_spellInfo->Id != 1842 || (m_targets.GetGOTarget() &&
6057 if (m_caster->ToPlayer()->InBattleground() && // In Battleground players can use only flags and banners
6060
6061 // get the lock entry
6062 uint32 lockId = 0;
6063 if (GameObject* go = m_targets.GetGOTarget())
6064 {
6065 lockId = go->GetGOInfo()->GetLockId();
6066 if (!lockId)
6068
6069 if (go->GetGOInfo()->GetNotInCombat() && m_caster->ToUnit()->IsInCombat())
6071 }
6072 else if (Item* itm = m_targets.GetItemTarget())
6073 lockId = itm->GetTemplate()->GetLockID();
6074
6075 SkillType skillId = SKILL_NONE;
6076 int32 reqSkillValue = 0;
6077 int32 skillValue = 0;
6078
6079 // check lock compatibility
6080 SpellCastResult res = CanOpenLock(spellEffectInfo, lockId, skillId, reqSkillValue, skillValue);
6081 if (res != SPELL_CAST_OK)
6082 return res;
6083 break;
6084 }
6086 {
6087 Player* playerCaster = m_caster->ToPlayer();
6088 if (!playerCaster || !playerCaster->GetPetStable())
6090
6091 Pet* pet = playerCaster->GetPet();
6092 if (pet && pet->IsAlive())
6094
6095 PetStable const* petStable = playerCaster->GetPetStable();
6096 auto deadPetItr = std::find_if(petStable->ActivePets.begin(), petStable->ActivePets.end(), [](Optional<PetStable::PetInfo> const& petInfo)
6097 {
6098 return petInfo && !petInfo->Health;
6099 });
6100
6101 if (deadPetItr == petStable->ActivePets.end())
6103
6104 break;
6105 }
6106 // This is generic summon effect
6108 {
6109 Unit* unitCaster = m_caster->ToUnit();
6110 if (!unitCaster)
6111 break;
6112
6113 SummonPropertiesEntry const* SummonProperties = sSummonPropertiesStore.LookupEntry(spellEffectInfo.MiscValueB);
6114 if (!SummonProperties)
6115 break;
6116
6117 switch (SummonProperties->Control)
6118 {
6122 [[fallthrough]]; // check both GetPetGUID() and GetCharmGUID for SUMMON_CATEGORY_PET
6124 if (!unitCaster->GetCharmedGUID().IsEmpty())
6126 break;
6127 }
6128 break;
6129 }
6131 {
6133 {
6138 }
6139 break;
6140 }
6142 {
6143 Unit* unitCaster = m_caster->ToUnit();
6144 if (!unitCaster)
6146
6147 if (!unitCaster->GetPetGUID().IsEmpty()) //let warlock do a replacement summon
6148 {
6149 if (unitCaster->GetTypeId() == TYPEID_PLAYER)
6150 {
6151 if (strict) //starting cast, trigger pet stun (cast by pet so it doesn't attack player)
6152 if (Pet* pet = unitCaster->ToPlayer()->GetPet())
6154 .SetOriginalCaster(pet->GetGUID())
6155 .SetTriggeringSpell(this));
6156 }
6159 }
6160
6161 if (!unitCaster->GetCharmedGUID().IsEmpty())
6163
6164 Player* playerCaster = unitCaster->ToPlayer();
6165 if (playerCaster && playerCaster->GetPetStable())
6166 {
6167 Optional<PetSaveMode> petSlot;
6168 if (!spellEffectInfo.MiscValue)
6169 {
6170 petSlot = PetSaveMode(spellEffectInfo.CalcValue());
6171
6172 // No pet can be summoned if any pet is dead
6173 for (Optional<PetStable::PetInfo> const& activePet : playerCaster->GetPetStable()->ActivePets)
6174 {
6175 if (activePet && !activePet->Health)
6176 {
6177 playerCaster->SendTameFailure(PetTameResult::Dead);
6179 }
6180 }
6181 }
6182
6183 std::pair<PetStable::PetInfo const*, PetSaveMode> info = Pet::GetLoadPetInfo(*playerCaster->GetPetStable(), spellEffectInfo.MiscValue, 0, petSlot);
6184 if (info.first)
6185 {
6186 if (info.first->Type == HUNTER_PET)
6187 {
6188 CreatureTemplate const* creatureInfo = sObjectMgr->GetCreatureTemplate(info.first->CreatureId);
6189 if (!creatureInfo || !creatureInfo->IsTameable(playerCaster->CanTameExoticPets()))
6190 {
6191 // if problem in exotic pet
6192 if (creatureInfo && creatureInfo->IsTameable(true))
6193 playerCaster->SendTameFailure(PetTameResult::CantControlExotic);
6194 else
6195 playerCaster->SendTameFailure(PetTameResult::NoPetAvailable);
6196
6198 }
6199 }
6200 }
6201 else if (!spellEffectInfo.MiscValue) // when miscvalue is present it is allowed to create new pets
6202 {
6203 playerCaster->SendTameFailure(PetTameResult::NoPetAvailable);
6205 }
6206 }
6207
6208 break;
6209 }
6211 {
6212 Player* playerCaster = m_caster->ToPlayer();
6213 if (!playerCaster)
6215
6216 Pet* pet = playerCaster->GetPet();
6217 if (!pet)
6218 return SPELL_FAILED_NO_PET;
6219
6220 if (!pet->IsAlive())
6222
6223 break;
6224 }
6226 {
6229
6230 if (!m_caster->ToPlayer()->GetTarget())
6232
6234 if (!target || m_caster->ToPlayer() == target || (!target->IsInSameRaidWith(m_caster->ToPlayer()) && m_spellInfo->Id != 48955)) // refer-a-friend spell
6236
6237 if (target->HasSummonPending())
6239
6240 // check if our map is dungeon
6241 if (InstanceMap const* map = m_caster->GetMap()->ToInstanceMap())
6242 {
6243 uint32 mapId = map->GetId();
6244 Difficulty difficulty = map->GetDifficultyID();
6245 if (InstanceLock const* mapLock = map->GetInstanceLock())
6246 if (sInstanceLockMgr.CanJoinInstanceLock(target->GetGUID(), { mapId, difficulty }, mapLock) != TRANSFER_ABORT_NONE)
6248
6249 if (!target->Satisfy(sObjectMgr->GetAccessRequirement(mapId, difficulty), mapId))
6251 }
6252 break;
6253 }
6254 // RETURN HERE
6256 {
6259
6260 Player* playerCaster = m_caster->ToPlayer();
6261 if (!playerCaster->GetTarget())
6263
6264 Player* target = playerCaster->GetSelectedPlayer();
6265 if (!target ||
6266 !(target->GetSession()->GetRecruiterId() == playerCaster->GetSession()->GetAccountId() || target->GetSession()->GetAccountId() == playerCaster->GetSession()->GetRecruiterId()))
6268 break;
6269 }
6270 case SPELL_EFFECT_LEAP:
6272 {
6273 //Do not allow to cast it before BG starts.
6275 if (Battleground const* bg = m_caster->ToPlayer()->GetBattleground())
6276 if (bg->GetStatus() != STATUS_IN_PROGRESS)
6278 break;
6279 }
6281 {
6284 break;
6285 }
6287 {
6288 Unit* unitCaster = m_caster->ToUnit();
6289 if (!unitCaster)
6291
6292 if (unitCaster->HasUnitState(UNIT_STATE_ROOT))
6293 {
6294 if (unitCaster->GetTypeId() == TYPEID_PLAYER)
6295 return SPELL_FAILED_ROOTED;
6296 else
6298 }
6299 break;
6300 }
6301 case SPELL_EFFECT_JUMP:
6303 {
6304 Unit* unitCaster = m_caster->ToUnit();
6305 if (!unitCaster)
6307
6308 if (unitCaster->HasUnitState(UNIT_STATE_ROOT))
6309 return SPELL_FAILED_ROOTED;
6310 break;
6311 }
6313 {
6314 ChrSpecializationEntry const* spec = sChrSpecializationStore.LookupEntry(m_misc.SpecializationId);
6315 Player* player = m_caster->ToPlayer();
6316 if (!player)
6318
6319 if (!spec || (spec->ClassID != player->GetClass() && !spec->IsPetSpecialization()))
6320 return SPELL_FAILED_NO_SPEC;
6321
6322 if (spec->IsPetSpecialization())
6323 {
6324 Pet* pet = player->GetPet();
6325 if (!pet || pet->getPetType() != HUNTER_PET || !pet->GetCharmInfo())
6326 return SPELL_FAILED_NO_PET;
6327 }
6328
6329 // can't change during already started arena/battleground
6330 if (Battleground const* bg = player->GetBattleground())
6331 if (bg->GetStatus() == STATUS_IN_PROGRESS)
6333 break;
6334 }
6336 {
6337 Player* playerCaster = m_caster->ToPlayer();
6338 if (!playerCaster)
6340
6341 TalentEntry const* talent = sTalentStore.LookupEntry(m_misc.TalentId);
6342 if (!talent)
6344
6345 if (playerCaster->GetSpellHistory()->HasCooldown(talent->SpellID))
6346 {
6347 if (param1)
6348 *param1 = talent->SpellID;
6350 }
6351 break;
6352 }
6355 {
6356 Player* playerCaster = m_caster->ToPlayer();
6357 if (!playerCaster)
6359
6361 if (!artifactAura)
6363
6364 Item* artifact = playerCaster->GetItemByGuid(artifactAura->GetCastItemGUID());
6365 if (!artifact)
6367
6368 if (spellEffectInfo.Effect == SPELL_EFFECT_GIVE_ARTIFACT_POWER)
6369 {
6370 ArtifactEntry const* artifactEntry = sArtifactStore.LookupEntry(artifact->GetTemplate()->GetArtifactID());
6371 if (!artifactEntry || artifactEntry->ArtifactCategoryID != spellEffectInfo.MiscValue)
6373 }
6374 break;
6375 }
6379 {
6380 Player* playerCaster = m_caster->ToPlayer();
6381 if (!playerCaster || !m_targets.GetUnitTarget() || !m_targets.GetUnitTarget()->IsCreature())
6383
6384 BattlePets::BattlePetMgr* battlePetMgr = playerCaster->GetSession()->GetBattlePetMgr();
6385 if (!battlePetMgr->HasJournalLock())
6387
6388 Creature* creature = m_targets.GetUnitTarget()->ToCreature();
6389 if (creature)
6390 {
6391 if (playerCaster->GetSummonedBattlePetGUID().IsEmpty() || creature->GetBattlePetCompanionGUID().IsEmpty())
6392 return SPELL_FAILED_NO_PET;
6393
6394 if (playerCaster->GetSummonedBattlePetGUID() != creature->GetBattlePetCompanionGUID())
6396
6397 if (BattlePets::BattlePet* battlePet = battlePetMgr->GetPet(creature->GetBattlePetCompanionGUID()))
6398 {
6399 if (BattlePetSpeciesEntry const* battlePetSpecies = sBattlePetSpeciesStore.LookupEntry(battlePet->PacketInfo.Species))
6400 {
6401 if (uint32 battlePetType = spellEffectInfo.MiscValue)
6402 if (!(battlePetType & (1 << battlePetSpecies->PetTypeEnum)))
6404
6405 if (spellEffectInfo.Effect == SPELL_EFFECT_CHANGE_BATTLEPET_QUALITY)
6406 {
6407 auto qualityItr = std::lower_bound(sBattlePetBreedQualityStore.begin(), sBattlePetBreedQualityStore.end(), spellEffectInfo.BasePoints, [](BattlePetBreedQualityEntry const* a1, int32 selector)
6408 {
6409 return a1->MaxQualityRoll < selector;
6410 });
6411
6413 if (qualityItr != sBattlePetBreedQualityStore.end())
6414 quality = BattlePets::BattlePetBreedQuality(qualityItr->QualityEnum);
6415
6416 if (battlePet->PacketInfo.Quality >= AsUnderlyingType(quality))
6418 }
6419
6420 if (spellEffectInfo.Effect == SPELL_EFFECT_GRANT_BATTLEPET_LEVEL || spellEffectInfo.Effect == SPELL_EFFECT_GRANT_BATTLEPET_EXPERIENCE)
6421 if (battlePet->PacketInfo.Level >= BattlePets::MAX_BATTLE_PET_LEVEL)
6422 return GRANT_PET_LEVEL_FAIL;
6423
6424 if (battlePetSpecies->GetFlags().HasFlag(BattlePetSpeciesFlags::CantBattle))
6426 }
6427 }
6428 }
6429 break;
6430 }
6431 default:
6432 break;
6433 }
6434
6435 if (spellEffectInfo.IsAura())
6436 approximateAuraEffectMask |= 1 << spellEffectInfo.EffectIndex;
6437 else if (spellEffectInfo.IsEffect())
6438 nonAuraEffectMask |= 1 << spellEffectInfo.EffectIndex;
6439 }
6440
6441 for (SpellEffectInfo const& spellEffectInfo : m_spellInfo->GetEffects())
6442 {
6443 switch (spellEffectInfo.ApplyAuraName)
6444 {
6446 {
6448 return SPELL_FAILED_NO_PET;
6449
6450 Pet* pet = m_caster->ToPlayer()->GetPet();
6451 if (!pet)
6452 return SPELL_FAILED_NO_PET;
6453
6454 if (!pet->GetCharmerGUID().IsEmpty())
6456 break;
6457 }
6461 {
6462 Unit* unitCaster = (m_originalCaster ? m_originalCaster : m_caster->ToUnit());
6463 if (!unitCaster)
6465
6466 if (!unitCaster->GetCharmerGUID().IsEmpty())
6467 return SPELL_FAILED_CHARMED;
6468
6469 if (spellEffectInfo.ApplyAuraName == SPELL_AURA_MOD_CHARM
6470 || spellEffectInfo.ApplyAuraName == SPELL_AURA_MOD_POSSESS)
6471 {
6474
6475 if (!unitCaster->GetCharmedGUID().IsEmpty())
6477 }
6478
6479 if (Unit* target = m_targets.GetUnitTarget())
6480 {
6481 if (target->GetTypeId() == TYPEID_UNIT && target->IsVehicle())
6483
6484 if (target->IsMounted())
6486
6487 if (!target->GetCharmerGUID().IsEmpty())
6489
6490 if (target->GetOwner() && target->GetOwner()->GetTypeId() == TYPEID_PLAYER)
6492
6493 int32 value = CalculateDamage(spellEffectInfo, target);
6494 if (value && int32(target->GetLevelForTarget(m_caster)) > value)
6496 }
6497
6498 break;
6499 }
6500 case SPELL_AURA_MOUNTED:
6501 {
6502 Unit* unitCaster = m_caster->ToUnit();
6503 if (!unitCaster)
6505
6508
6509 if (unitCaster->IsInDisallowedMountForm())
6510 {
6511 SendMountResult(MountResult::Shapeshifted); // mount result gets sent before the cast result
6513 }
6514 break;
6515 }
6517 {
6518 if (!m_targets.GetUnitTarget())
6520
6521 // can be cast at non-friendly unit or own pet/charm
6524 break;
6525 }
6526 case SPELL_AURA_FLY:
6528 {
6529 // not allow cast fly spells if not have req. skills (all spells is self target)
6530 // allow always ghost flight spells
6532 {
6533 Battlefield* Bf = sBattlefieldMgr->GetBattlefieldToZoneId(m_originalCaster->GetMap(), m_originalCaster->GetZoneId());
6534 if (AreaTableEntry const* area = sAreaTableStore.LookupEntry(m_originalCaster->GetAreaId()))
6535 if (area->Flags[0] & AREA_FLAG_NO_FLY_ZONE || (Bf && !Bf->CanFlyIn()))
6536 return SPELL_FAILED_NOT_HERE;
6537 }
6538 break;
6539 }
6541 {
6542 if (spellEffectInfo.IsTargetingArea())
6543 break;
6544
6545 if (!m_targets.GetUnitTarget())
6547
6549 break;
6550
6553 break;
6554 }
6555 default:
6556 break;
6557 }
6558
6559 // check if target already has the same type, but more powerful aura
6562 && (approximateAuraEffectMask & (1 << spellEffectInfo.EffectIndex))
6564 if (Unit* target = m_targets.GetUnitTarget())
6565 if (!target->IsHighestExclusiveAuraEffect(m_spellInfo, spellEffectInfo.ApplyAuraName,
6566 spellEffectInfo.CalcValue(m_caster, &m_spellValue->EffectBasePoints[spellEffectInfo.EffectIndex], nullptr, nullptr, m_castItemEntry, m_castItemLevel),
6567 approximateAuraEffectMask, false))
6569 }
6570
6571 // check trade slot case (last, for allow catch any another cast problems)
6573 {
6574 if (m_CastItem)
6576
6579
6582
6583 TradeData* my_trade = m_caster->ToPlayer()->GetTradeData();
6584 if (!my_trade)
6586
6589
6590 if (!IsTriggered())
6591 if (my_trade->GetSpell())
6593 }
6594
6595 // check if caster has at least 1 combo point for spells that require combo points
6597 if (Player* plrCaster = m_caster->ToPlayer())
6598 if (!plrCaster->GetComboPoints())
6600
6601 // all ok
6602 return SPELL_CAST_OK;
6603}
#define sBattlefieldMgr
Definition: BattlefieldMgr.h:80
@ STATUS_WAIT_LEAVE
Definition: Battleground.h:161
@ STATUS_IN_PROGRESS
Definition: Battleground.h:160
#define M_PI
Definition: Common.h:140
#define sConditionMgr
Definition: ConditionMgr.h:351
@ CONDITION_SOURCE_TYPE_SPELL
Definition: ConditionMgr.h:168
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)
DB2Storage< AreaTableEntry > sAreaTableStore("AreaTable.db2", &AreaTableLoadInfo::Instance)
#define sDB2Manager
Definition: DB2Stores.h:502
Difficulty
Definition: DBCEnums.h:732
@ DIFFICULTY_NONE
Definition: DBCEnums.h:733
@ AREA_FLAG_NO_FLY_ZONE
Definition: DBCEnums.h:139
@ SPELL_DISABLE_LOS
Definition: DisableMgr.h:48
@ DISABLE_TYPE_SPELL
Definition: DisableMgr.h:27
#define sInstanceLockMgr
Definition: InstanceLockMgr.h:318
@ LOOT_SKINNING
Definition: Loot.h:104
@ TRANSFER_ABORT_NONE
Definition: Map.h:85
@ TYPEID_GAMEOBJECT
Definition: ObjectGuid.h:41
@ TYPEID_UNIT
Definition: ObjectGuid.h:38
#define sObjectMgr
Definition: ObjectMgr.h:1976
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
PetSaveMode
Definition: PetDefines.h:41
@ SPELL_ATTR7_IS_CHEAT_SPELL
Definition: SharedDefines.h:676
@ GAMEOBJECT_TYPE_TRAP
Definition: SharedDefines.h:2782
@ SPELL_ATTR5_NOT_AVAILABLE_WHILE_CHARMED
Definition: SharedDefines.h:613
@ TARGET_UNIT_PET
Definition: SharedDefines.h:2582
@ TARGET_GAMEOBJECT_TARGET
Definition: SharedDefines.h:2595
@ SPELL_ATTR2_ENCHANT_OWN_ITEM_ONLY
Definition: SharedDefines.h:501
@ SPELL_ATTR2_INITIATE_COMBAT_POST_CAST_ENABLES_AUTO_ATTACK
Definition: SharedDefines.h:508
@ SPELL_ATTR2_NO_ACTIVE_PETS
Definition: SharedDefines.h:504
@ SPELL_ATTR2_IGNORE_LINE_OF_SIGHT
Definition: SharedDefines.h:490
@ SPELL_ATTR1_INITIATES_COMBAT_ENABLES_AUTO_ATTACK
Definition: SharedDefines.h:460
@ SPELL_ATTR3_ONLY_BATTLEGROUNDS
Definition: SharedDefines.h:536
@ SPELL_DAMAGE_CLASS_MELEE
Definition: SharedDefines.h:2761
@ SPELL_EFFECT_DUMMY
Definition: SharedDefines.h:1132
@ SPELL_EFFECT_LEAP
Definition: SharedDefines.h:1158
@ SPELL_EFFECT_SUMMON_PET
Definition: SharedDefines.h:1185
@ SPELL_EFFECT_GIVE_ARTIFACT_POWER_NO_BONUS
Definition: SharedDefines.h:1371
@ SPELL_EFFECT_SUMMON_RAF_FRIEND
Definition: SharedDefines.h:1281
@ SPELL_EFFECT_WEAPON_DAMAGE
Definition: SharedDefines.h:1187
@ SPELL_EFFECT_APPLY_GLYPH
Definition: SharedDefines.h:1203
@ SPELL_EFFECT_NORMALIZED_WEAPON_DMG
Definition: SharedDefines.h:1250
@ SPELL_EFFECT_FEED_PET
Definition: SharedDefines.h:1230
@ SPELL_EFFECT_SUMMON_PLAYER
Definition: SharedDefines.h:1214
@ SPELL_EFFECT_JUMP_DEST
Definition: SharedDefines.h:1171
@ SPELL_EFFECT_TELEPORT_UNITS_FACE_CASTER
Definition: SharedDefines.h:1172
@ SPELL_EFFECT_ATTACK
Definition: SharedDefines.h:1207
@ SPELL_EFFECT_RESURRECT_PET
Definition: SharedDefines.h:1238
@ SPELL_EFFECT_CHANGE_BATTLEPET_QUALITY
Definition: SharedDefines.h:1333
@ SPELL_EFFECT_WEAPON_PERCENT_DAMAGE
Definition: SharedDefines.h:1160
@ SPELL_EFFECT_GRANT_BATTLEPET_LEVEL
Definition: SharedDefines.h:1354
@ SPELL_EFFECT_WEAPON_DAMAGE_NOSCHOOL
Definition: SharedDefines.h:1146
@ SPELL_EFFECT_LEAP_BACK
Definition: SharedDefines.h:1267
@ SPELL_EFFECT_SUMMON
Definition: SharedDefines.h:1157
@ SPELL_EFFECT_UNLOCK_GUILD_VAULT_TAB
Definition: SharedDefines.h:1302
@ SPELL_EFFECT_CHARGE
Definition: SharedDefines.h:1225
@ SPELL_EFFECT_DISMISS_PET
Definition: SharedDefines.h:1231
@ SPELL_EFFECT_TALENT_SPEC_SELECT
Definition: SharedDefines.h:1291
@ SPELL_EFFECT_GRANT_BATTLEPET_EXPERIENCE
Definition: SharedDefines.h:1415
@ SPELL_EFFECT_LEARN_SPELL
Definition: SharedDefines.h:1165
@ SPELL_EFFECT_GIVE_ARTIFACT_POWER
Definition: SharedDefines.h:1369
@ SPELL_EFFECT_JUMP
Definition: SharedDefines.h:1170
@ SPELL_EFFECT_SKINNING
Definition: SharedDefines.h:1224
@ SPELL_EFFECT_REMOVE_TALENT
Definition: SharedDefines.h:1310
@ SPELL_EFFECT_CREATE_TAMED_PET
Definition: SharedDefines.h:1282
@ SPELL_EFFECT_OPEN_LOCK
Definition: SharedDefines.h:1162
@ SPELL_EFFECT_STEAL_BENEFICIAL_BUFF
Definition: SharedDefines.h:1255
@ SPELL_EFFECT_LEARN_PET_SPELL
Definition: SharedDefines.h:1186
SpellCustomErrors
Definition: SharedDefines.h:1766
@ SPELL_CUSTOM_ERROR_GM_ONLY
Definition: SharedDefines.h:1832
@ POWER_MANA
Definition: SharedDefines.h:278
@ SPELL_ATTR0_ONLY_INDOORS
Definition: SharedDefines.h:428
@ SPELL_ATTR0_ONLY_OUTDOORS
Definition: SharedDefines.h:429
@ SPELL_ATTR0_ALLOW_WHILE_MOUNTED
Definition: SharedDefines.h:438
@ SPELL_ATTR0_COOLDOWN_ON_EVENT
Definition: SharedDefines.h:439
@ SPELL_ATTR0_USES_RANGED_SLOT
Definition: SharedDefines.h:415
@ SPELL_ATTR0_ALLOW_CAST_WHILE_DEAD
Definition: SharedDefines.h:437
@ SPELL_ATTR0_ONLY_STEALTHED
Definition: SharedDefines.h:431
@ LINEOFSIGHT_ALL_CHECKS
Definition: SharedDefines.h:6809
@ SPELL_ATTR12_IGNORE_CASTING_DISABLED
Definition: SharedDefines.h:867
AuraStateType
Definition: SharedDefines.h:2453
@ SPELL_ATTR4_AURA_NEVER_BOUNCES
Definition: SharedDefines.h:582
@ SPELL_ATTR4_AURA_BOUNCE_FAILS_SPELL
Definition: SharedDefines.h:591
@ SUMMON_CATEGORY_PET
Definition: SharedDefines.h:5979
@ SUMMON_CATEGORY_PUPPET
Definition: SharedDefines.h:5980
SkillType
Definition: SharedDefines.h:5279
@ SPELL_FAILED_TARGET_NOT_LOOTED
Definition: SharedDefines.h:1583
@ SPELL_FAILED_NOT_INFRONT
Definition: SharedDefines.h:1525
@ GRANT_PET_LEVEL_FAIL
Definition: SharedDefines.h:1697
@ SPELL_FAILED_NOT_MOUNTED
Definition: SharedDefines.h:1528
@ SPELL_FAILED_AFFECTING_COMBAT
Definition: SharedDefines.h:1441
@ SPELL_FAILED_CASTER_AURASTATE
Definition: SharedDefines.h:1466
@ SPELL_FAILED_WRONG_ARTIFACT_EQUIPPED
Definition: SharedDefines.h:1728
@ SPELL_FAILED_TARGET_NOT_PLAYER
Definition: SharedDefines.h:1584
@ SPELL_FAILED_CANT_UNTALENT
Definition: SharedDefines.h:1465
@ SPELL_FAILED_NOT_KNOWN
Definition: SharedDefines.h:1527
@ SPELL_FAILED_FOOD_LOWLEVEL
Definition: SharedDefines.h:1481
@ SPELL_FAILED_NO_SPEC
Definition: SharedDefines.h:1689
@ SPELL_FAILED_NOT_HERE
Definition: SharedDefines.h:1524
@ SPELL_FAILED_ROOTED
Definition: SharedDefines.h:1564
@ SPELL_FAILED_GLYPH_INVALID_SPEC
Definition: SharedDefines.h:1661
@ SPELL_FAILED_ALREADY_HAVE_PET
Definition: SharedDefines.h:1448
@ SPELL_FAILED_WRONG_PET_FOOD
Definition: SharedDefines.h:1599
@ SPELL_FAILED_CUSTOM_ERROR
Definition: SharedDefines.h:1654
@ SPELL_FAILED_SUMMON_PENDING
Definition: SharedDefines.h:1669
@ SPELL_FAILED_BAD_IMPLICIT_TARGETS
Definition: SharedDefines.h:1452
@ SPELL_FAILED_TRY_AGAIN
Definition: SharedDefines.h:1595
@ SPELL_FAILED_NO_COMBO_POINTS
Definition: SharedDefines.h:1541
@ SPELL_FAILED_CANT_UPGRADE_BATTLE_PET
Definition: SharedDefines.h:1691
@ SPELL_FAILED_ALREADY_HAVE_SUMMON
Definition: SharedDefines.h:1447
@ SPELL_FAILED_NOT_TRADING
Definition: SharedDefines.h:1535
@ SPELL_FAILED_NOT_IN_BATTLEGROUND
Definition: SharedDefines.h:1648
@ SPELL_FAILED_NOT_BEHIND
Definition: SharedDefines.h:1521
@ SPELL_FAILED_ALREADY_HAVE_CHARM
Definition: SharedDefines.h:1446
@ SPELL_FAILED_HIGHLEVEL
Definition: SharedDefines.h:1499
@ SPELL_FAILED_LOWLEVEL
Definition: SharedDefines.h:1512
@ SPELL_FAILED_NOT_READY
Definition: SharedDefines.h:1531
@ SPELL_FAILED_WRONG_BATTLE_PET_TYPE
Definition: SharedDefines.h:1692
@ SPELL_FAILED_ONLY_BATTLEGROUNDS
Definition: SharedDefines.h:1606
@ SPELL_FAILED_ITEM_ALREADY_ENCHANTED
Definition: SharedDefines.h:1505
@ SPELL_FAILED_ONLY_STEALTHED
Definition: SharedDefines.h:1556
@ SPELL_FAILED_CANT_DO_THAT_RIGHT_NOW
Definition: SharedDefines.h:1655
@ SPELL_FAILED_TARGET_IS_PLAYER_CONTROLLED
Definition: SharedDefines.h:1580
@ SPELL_FAILED_NO_ARTIFACT_EQUIPPED
Definition: SharedDefines.h:1727
@ SPELL_FAILED_ONLY_ABOVEWATER
Definition: SharedDefines.h:1551
@ SPELL_FAILED_TARGETS_DEAD
Definition: SharedDefines.h:1570
@ SPELL_FAILED_GLYPH_NO_SPEC
Definition: SharedDefines.h:1662
@ SPELL_FAILED_CANT_BE_CHARMED
Definition: SharedDefines.h:1455
@ SPELL_FAILED_CASTER_DEAD
Definition: SharedDefines.h:1467
@ SPELL_FAILED_ITEM_ENCHANT_TRADE_WINDOW
Definition: SharedDefines.h:1668
@ SPELL_FAILED_GLYPH_EXCLUSIVE_CATEGORY
Definition: SharedDefines.h:1660
@ SPELL_FAILED_TARGET_UNSKINNABLE
Definition: SharedDefines.h:1588
@ SPELL_FAILED_UNIQUE_GLYPH
Definition: SharedDefines.h:1658
@ SPELL_FAILED_ONLY_OUTDOORS
Definition: SharedDefines.h:1554
@ SPELL_FAILED_CHARMED
Definition: SharedDefines.h:1468
@ SPELL_FAILED_INVALID_GLYPH
Definition: SharedDefines.h:1657
@ SPELL_FAILED_LINE_OF_SIGHT
Definition: SharedDefines.h:1511
@ SPELL_FAILED_VISION_OBSCURED
Definition: SharedDefines.h:1598
@ SPELL_FAILED_NO_PET
Definition: SharedDefines.h:1547
@ SPELL_FAILED_TARGET_LOCKED_TO_RAID_INSTANCE
Definition: SharedDefines.h:1651
@ SPELL_FAILED_REQUIRES_SPELL_FOCUS
Definition: SharedDefines.h:1563
@ SPELL_FAILED_NOPATH
Definition: SharedDefines.h:1520
@ SPELL_FAILED_ONLY_INDOORS
Definition: SharedDefines.h:1552
@ SPELL_FAILED_NOT_ON_TAXI
Definition: SharedDefines.h:1529
@ SPELL_FAILED_TARGET_FRIENDLY
Definition: SharedDefines.h:1576
@ SPELL_AURA_ABILITY_IGNORE_AURASTATE
Definition: SpellAuraDefines.h:356
@ SPELL_AURA_DISABLE_CASTING_EXCEPT_ABILITIES
Definition: SpellAuraDefines.h:357
@ SPELL_AURA_DISABLE_ATTACKING_EXCEPT_ABILITIES
Definition: SpellAuraDefines.h:358
@ SPELL_AURA_MOD_IGNORE_SHAPESHIFT
Definition: SpellAuraDefines.h:369
@ SPELL_AURA_PERIODIC_MANA_LEECH
Definition: SpellAuraDefines.h:158
@ SPELL_AURA_MOD_POSSESS_PET
Definition: SpellAuraDefines.h:472
@ SPELL_AURA_RANGED_ATTACK_POWER_ATTACKER_BONUS
Definition: SpellAuraDefines.h:221
@ SPELL_AURA_FLY
Definition: SpellAuraDefines.h:295
@ SPELL_AURA_MOD_CHARM
Definition: SpellAuraDefines.h:100
@ SPELL_AURA_MOUNTED
Definition: SpellAuraDefines.h:172
@ SPELL_AURA_AOE_CHARM
Definition: SpellAuraDefines.h:271
@ SPELL_AURA_PROVIDE_SPELL_FOCUS
Definition: SpellAuraDefines.h:375
@ SPELL_AURA_MOD_POSSESS
Definition: SpellAuraDefines.h:96
@ SPELL_AURA_INTERFERE_TARGETTING
Definition: SpellAuraDefines.h:416
@ SPELL_AURA_MOD_INCREASE_MOUNTED_FLIGHT_SPEED
Definition: SpellAuraDefines.h:301
@ TARGET_FLAG_ITEM
Definition: SpellDefines.h:277
@ TRIGGERED_IGNORE_CASTER_AURASTATE
Will ignore most target checks (mostly DBC target checks)
Definition: SpellDefines.h:266
@ TRIGGERED_IGNORE_CASTER_MOUNTED_OR_ON_VEHICLE
Disallows proc events from triggered spell (default)
Definition: SpellDefines.h:255
@ TRIGGERED_IGNORE_SHAPESHIFT
Will not adjust facing to target (if any)
Definition: SpellDefines.h:252
@ TRIGGERED_IGNORE_GCD
Not triggered.
Definition: SpellDefines.h:242
@ TRIGGERED_IGNORE_CASTER_AURAS
Will ignore mounted/on vehicle restrictions.
Definition: SpellDefines.h:258
@ 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:207
@ UNIT_FLAG_IMMUNE
Definition: UnitDefines.h:170
@ UNIT_FLAG_SKINNABLE
Definition: UnitDefines.h:165
@ UNIT_STATE_ROOT
Definition: Unit.h:254
#define ARTIFACTS_ALL_WEAPONS_GENERAL_WEAPON_EQUIPPED_PASSIVE
Definition: Unit.h:36
constexpr std::underlying_type< E >::type AsUnderlyingType(E enumValue)
Definition: Util.h:475
Definition: SpellAuraEffects.h:29
Definition: SpellAuras.h:123
ObjectGuid GetCastItemGUID() const
Definition: SpellAuras.h:144
Definition: BattlePetMgr.h:147
BattlePet * GetPet(ObjectGuid guid)
Definition: BattlePetMgr.cpp:444
bool HasJournalLock() const
Definition: BattlePetMgr.h:201
Definition: Battlefield.h:210
bool CanFlyIn()
Return if we can use mount in battlefield.
Definition: Battlefield.h:347
Definition: Battleground.h:256
Loot * GetLootForPlayer(Player const *player) const override
Definition: Creature.cpp:1367
CreatureTemplate const * GetCreatureTemplate() const
Definition: Creature.h:214
Definition: DynamicObject.h:37
Definition: GameObject.h:125
GameObjectTemplate const * GetGOInfo() const
Definition: GameObject.h:161
Definition: Guild.h:306
Definition: InstanceLockMgr.h:84
Definition: Map.h:819
bool IsLocked() const
Definition: Item.h:251
ItemTemplate const * GetTemplate() const
Definition: Item.cpp:1140
bool IsPotion() const
Definition: Item.h:333
bool IsBattleground() const
Definition: Map.cpp:3222
InstanceMap * ToInstanceMap()
Definition: Map.h:430
static ObjectGuid const TradeItem
Definition: ObjectGuid.h:266
static GameObject * ToGameObject(Object *o)
Definition: Object.h:217
bool IsCreature() const
Definition: Object.h:204
Definition: PetDefines.h:116
std::array< Optional< PetInfo >, MAX_ACTIVE_PETS > ActivePets
Definition: PetDefines.h:140
Definition: Pet.h:46
Player * GetOwner() const
Definition: Pet.cpp:1811
static std::pair< PetStable::PetInfo const *, PetSaveMode > GetLoadPetInfo(PetStable const &stable, uint32 petEntry, uint32 petnumber, Optional< PetSaveMode > slot)
Definition: Pet.cpp:104
PetType getPetType() const
Definition: Pet.h:57
bool HaveInDiet(ItemTemplate const *item) const
Definition: Pet.cpp:1110
bool Satisfy(AccessRequirement const *ar, uint32 target_map, TransferAbortParams *params=nullptr, bool report=false)
Definition: Player.cpp:19358
bool IsInSameRaidWith(Player const *p) const
Definition: Player.cpp:2208
ObjectGuid GetSummonedBattlePetGUID() const
Definition: Player.h:2814
bool CanTameExoticPets() const
Definition: Player.h:2308
bool CanUseBattlegroundObject(GameObject *gameobject) const
Definition: Player.cpp:25647
bool InBattleground() const
Definition: Player.h:2396
std::vector< uint32 > const & GetGlyphs(uint8 spec) const
Definition: Player.h:1880
PetStable * GetPetStable()
Definition: Player.h:1238
Pet * GetPet() const
Definition: Player.cpp:21152
Guild * GetGuild()
Definition: Player.cpp:28563
bool HasSummonPending() const
Definition: Player.cpp:24750
WorldSession * GetSession() const
Definition: Player.h:2103
void SendTameFailure(PetTameResult result)
Definition: Player.cpp:21252
Battleground * GetBattleground() const
Definition: Player.cpp:24457
bool IsGameMaster() const
Definition: Player.h:1194
uint8 GetActiveTalentGroup() const
Definition: Player.h:1847
Player * GetSelectedPlayer() const
Definition: Player.cpp:23712
bool HasSpell(uint32 spell) const override
Definition: Player.cpp:3766
Item * GetItemByGuid(ObjectGuid guid) const
Definition: Player.cpp:9469
uint32 GetPrimarySpecialization() const
Definition: Player.h:1845
GameObject * GetGOTarget() const
Definition: Spell.cpp:240
ObjectGuid GetItemTargetGUID() const
Definition: SpellDefines.h:352
bool IsReady(SpellInfo const *spellInfo, uint32 itemId=0) const
Definition: SpellHistory.cpp:278
bool HasCooldown(SpellInfo const *spellInfo, uint32 itemId=0) const
Definition: SpellHistory.cpp:669
Definition: SpellInfo.h:322
uint32 RequiresSpellFocus
Definition: SpellInfo.h:352
uint32 SpellLevel
Definition: SpellInfo.h:385
uint32 CasterAuraSpell
Definition: SpellInfo.h:358
float GetMaxRange(bool positive=false, WorldObject *caster=nullptr, Spell *spell=nullptr) const
Definition: SpellInfo.cpp:3814
SpellCastResult CheckShapeshift(uint32 form) const
Definition: SpellInfo.cpp:1917
bool IsCooldownStartedOnEvent() const
Definition: SpellInfo.cpp:1616
SpellCastResult CheckLocation(uint32 map_id, uint32 zone_id, uint32 area_id, Player const *player=nullptr) const
Definition: SpellInfo.cpp:1966
uint32 ExcludeCasterAuraState
Definition: SpellInfo.h:356
uint32 CasterAuraState
Definition: SpellInfo.h:354
bool CanBeUsedInCombat() const
Definition: SpellInfo.cpp:1670
flag128 SpellFamilyFlags
Definition: SpellInfo.h:410
bool IsNextMeleeSwingSpell() const
Definition: SpellInfo.cpp:1700
SpellCastResult CheckVehicle(Unit const *caster) const
Definition: SpellInfo.cpp:2334
SpellCastResult CheckExplicitTarget(WorldObject const *caster, WorldObject const *target, Item const *itemTarget=nullptr) const
Definition: SpellInfo.cpp:2298
AuraType ExcludeCasterAuraType
Definition: SpellInfo.h:364
AuraType CasterAuraType
Definition: SpellInfo.h:362
uint32 ExcludeCasterAuraSpell
Definition: SpellInfo.h:360
bool HasAura(AuraType aura) const
Definition: SpellInfo.cpp:1367
bool IsTargetingArea() const
Definition: SpellInfo.cpp:1509
uint32 CategoryId
Definition: SpellInfo.h:328
int32 CalculateDamage(SpellEffectInfo const &spellEffectInfo, Unit const *target, float *var=nullptr) const
Definition: Spell.cpp:6897
SpellCastResult CheckItems(int32 *param1, int32 *param2) const
Definition: Spell.cpp:7120
GameObject * SearchSpellFocus()
Definition: Spell.cpp:2198
std::unique_ptr< PathGenerator > m_preGeneratedPath
Definition: Spell.h:890
SpellCastResult CanOpenLock(SpellEffectInfo const &effect, uint32 lockid, SkillType &skillid, int32 &reqSkillValue, int32 &skillValue)
Definition: Spell.cpp:8268
bool IsAutoRepeat() const
Definition: Spell.h:594
void SendMountResult(MountResult result)
Definition: Spell.cpp:4537
SpellCastResult CallScriptCheckCastHandlers()
Definition: Spell.cpp:8444
bool IsTriggered() const
Definition: Spell.cpp:7965
SpellCastResult CheckCasterAuras(int32 *param1) const
Definition: Spell.cpp:6639
SpellCastResult CheckPower() const
Definition: Spell.cpp:7078
bool HasGlobalCooldown() const
Definition: Spell.cpp:8711
SpellCastResult CheckRange(bool strict) const
Definition: Spell.cpp:6971
SpellCastResult CheckArenaAndRatedBattlegroundCastRules()
Definition: Spell.cpp:6842
uint32 GetSpell() const
Definition: TradeData.h:49
bool IsVehicle() const
Definition: Unit.h:853
Pet * ToPet()
Definition: Unit.h:1846
bool HasAuraTypeWithMiscvalue(AuraType auraType, int32 miscValue) const
Definition: Unit.cpp:4567
uint8 GetClass() const
Definition: Unit.h:861
bool IsInDisallowedMountForm() const
Definition: Unit.cpp:8676
Powers GetPowerType() const
Definition: Unit.h:908
bool HasUnitFlag(UnitFlags flags) const
Definition: Unit.h:940
ObjectGuid GetCharmedGUID() const
Definition: Unit.h:1277
bool HasUnitFlag2(UnitFlags2 flags) const
Definition: Unit.h:945
bool IsAlive() const
Definition: Unit.h:1253
float GetCombatReach() const override
Definition: Unit.h:804
CharmInfo * GetCharmInfo()
Definition: Unit.h:1308
bool IsInFlight() const
Definition: Unit.h:1118
Aura * GetAura(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, ObjectGuid itemCasterGUID=ObjectGuid::Empty, uint32 reqEffMask=0) const
Definition: Unit.cpp:4440
bool IsInWater() const
Definition: Unit.cpp:3078
AttackerSet const & getAttackers() const
Definition: Unit.h:823
uint8 GetLevelForTarget(WorldObject const *) const override
Definition: Unit.h:856
bool IsMounted() const
Definition: Unit.h:1006
bool HasUnitState(const uint32 f) const
Definition: Unit.h:842
DynamicObject * GetDynObject(uint32 spellId) const
Definition: Unit.cpp:5044
bool HasAura(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, ObjectGuid itemCasterGUID=ObjectGuid::Empty, uint32 reqEffMask=0) const
Definition: Unit.cpp:4544
ObjectGuid GetCharmerGUID() const
Definition: Unit.h:1274
bool isAttackReady(WeaponAttackType type=BASE_ATTACK) const
Definition: Unit.h:800
ObjectGuid GetBattlePetCompanionGUID() const
Definition: Unit.h:1269
bool IsHighestExclusiveAuraEffect(SpellInfo const *spellInfo, AuraType auraType, int32 effectAmount, uint32 auraEffectMask, bool removeOtherAuraApplications=false)
Definition: Unit.cpp:13477
ObjectGuid GetTarget() const
Definition: Unit.h:1855
bool IsInCombat() const
Definition: Unit.h:1143
ObjectGuid GetPetGUID() const
Definition: Unit.h:1265
bool isLineOfSightCalcEnabled() const
Definition: IVMapManager.h:109
static VMapManager2 * createOrGetVMapManager()
Definition: VMapFactory.cpp:27
bool IsWithinLOS(float x, float y, float z, LineOfSightChecks checks=LINEOFSIGHT_ALL_CHECKS, VMAP::ModelIgnoreFlags ignoreFlags=VMAP::ModelIgnoreFlags::Nothing) const
Definition: Object.cpp:1133
Unit * GetOwner() const
Definition: Object.cpp:2184
bool IsOutdoors() const
Definition: Object.h:539
bool IsWithinLOSInMap(WorldObject const *obj, LineOfSightChecks checks=LINEOFSIGHT_ALL_CHECKS, VMAP::ModelIgnoreFlags ignoreFlags=VMAP::ModelIgnoreFlags::Nothing) const
Definition: Object.cpp:1153
uint32 GetAreaId() const
Definition: Object.h:536
uint32 GetZoneId() const
Definition: Object.h:535
void GetZoneAndAreaId(uint32 &zoneid, uint32 &areaid) const
Definition: Object.h:537
uint32 GetRecruiterId() const
Definition: WorldSession.h:1152
uint32 GetAccountId() const
Definition: WorldSession.h:990
BattlePets::BattlePetMgr * GetBattlePetMgr() const
Definition: WorldSession.h:1165
BattlePetBreedQuality
Definition: BattlePetMgr.h:44
static constexpr uint16 MAX_BATTLE_PET_LEVEL
Definition: BattlePetMgr.h:41
bool IsDisabledFor(DisableType type, uint32 entry, WorldObject const *ref, uint8 flags)
Definition: DisableMgr.cpp:285
TC_GAME_API Player * FindPlayer(ObjectGuid const &)
Definition: ObjectAccessor.cpp:252
Definition: DB2Structure.h:126
Definition: DB2Structure.h:200
uint8 ArtifactCategoryID
Definition: DB2Structure.h:209
Definition: DB2Structure.h:452
Definition: DB2Structure.h:468
Definition: BattlePetMgr.h:137
CastSpellExtraArgs & SetTriggeringSpell(Spell const *triggeringSpell)
Definition: Spell.cpp:9118
Definition: DB2Structure.h:816
bool IsPetSpecialization() const
Definition: DB2Structure.h:831
int8 ClassID
Definition: DB2Structure.h:821
Definition: ConditionMgr.h:213
Condition const * mLastFailedCondition
Definition: ConditionMgr.h:216
uint32 ErrorType
Definition: ConditionMgr.h:232
uint8 ConditionTarget
Definition: ConditionMgr.h:236
uint32 ErrorTextId
Definition: ConditionMgr.h:233
Definition: CreatureData.h:471
SkillType GetRequiredLootSkill() const
Definition: CreatureData.h:551
bool IsTameable(bool canTameExotic) const
Definition: CreatureData.h:568
uint32 type
Definition: GameObjectData.h:33
uint32 GetNoDamageImmune() const
Definition: GameObjectData.h:1009
Definition: DB2Structure.h:1866
uint8 GlyphExclusiveCategoryID
Definition: DB2Structure.h:1870
uint32 GetBaseItemLevel() const
Definition: ItemTemplate.h:771
uint8 GetArtifactID() const
Definition: ItemTemplate.h:806
uint32 GetLockID() const
Definition: ItemTemplate.h:792
Definition: Loot.h:279
bool isLooted() const
Definition: Loot.h:305
LootType loot_type
Definition: Loot.h:286
float GetPositionZ() const
Definition: Position.h:79
float GetPositionX() const
Definition: Position.h:77
void GetPosition(float &x, float &y) const
Definition: Position.h:82
float GetPositionY() const
Definition: Position.h:78
Definition: DB2Structure.h:3833
int32 Control
Definition: DB2Structure.h:3835
Definition: DB2Structure.h:3853
uint32 SpellID
Definition: DB2Structure.h:3861
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ CheckCasterAuras()

SpellCastResult Spell::CheckCasterAuras ( int32 param1) const
6640{
6641 Unit* unitCaster = (m_originalCaster ? m_originalCaster : m_caster->ToUnit());
6642 if (!unitCaster)
6643 return SPELL_CAST_OK;
6644
6645 // these attributes only show the spell as usable on the client when it has related aura applied
6646 // still they need to be checked against certain mechanics
6647
6648 // SPELL_ATTR5_USABLE_WHILE_STUNNED by default only MECHANIC_STUN (ie no sleep, knockout, freeze, etc.)
6649 bool usableWhileStunned = m_spellInfo->HasAttribute(SPELL_ATTR5_ALLOW_WHILE_STUNNED);
6650
6651 // SPELL_ATTR5_USABLE_WHILE_FEARED by default only fear (ie no horror)
6652 bool usableWhileFeared = m_spellInfo->HasAttribute(SPELL_ATTR5_ALLOW_WHILE_FLEEING);
6653
6654 // SPELL_ATTR5_USABLE_WHILE_CONFUSED by default only disorient (ie no polymorph)
6655 bool usableWhileConfused = m_spellInfo->HasAttribute(SPELL_ATTR5_ALLOW_WHILE_CONFUSED);
6656
6657 // Check whether the cast should be prevented by any state you might have.
6659
6660 // Get unit state
6661 uint32 const unitflag = unitCaster->m_unitData->Flags;
6662
6663 // this check should only be done when player does cast directly
6664 // (ie not when it's called from a script) Breaks for example PlayerAI when charmed
6665 /*
6666 if (!unitCaster->GetCharmerGUID().IsEmpty())
6667 {
6668 if (Unit* charmer = unitCaster->GetCharmer())
6669 if (charmer->GetUnitBeingMoved() != unitCaster && !CheckSpellCancelsCharm(param1))
6670 result = SPELL_FAILED_CHARMED;
6671 }
6672 */
6673
6674 // spell has attribute usable while having a cc state, check if caster has allowed mechanic auras, another mechanic types must prevent cast spell
6675 auto mechanicCheck = [&](AuraType type) -> SpellCastResult
6676 {
6677 bool foundNotMechanic = false;
6678 Unit::AuraEffectList const& auras = unitCaster->GetAuraEffectsByType(type);
6679 for (AuraEffect const* aurEff : auras)
6680 {
6681 uint64 const mechanicMask = aurEff->GetSpellInfo()->GetAllEffectsMechanicMask();
6682 if (mechanicMask && !(mechanicMask & GetSpellInfo()->GetAllowedMechanicMask()))
6683 {
6684 foundNotMechanic = true;
6685
6686 // fill up aura mechanic info to send client proper error message
6687 if (param1)
6688 {
6689 *param1 = aurEff->GetSpellEffectInfo().Mechanic;
6690 if (!*param1)
6691 *param1 = aurEff->GetSpellInfo()->Mechanic;
6692 }
6693
6694 break;
6695 }
6696 }
6697
6698 if (foundNotMechanic)
6699 {
6700 switch (type)
6701 {
6704 return SPELL_FAILED_STUNNED;
6706 return SPELL_FAILED_FLEEING;
6708 return SPELL_FAILED_CONFUSED;
6709 default:
6710 ABORT();
6711