AzerothCore 3.3.5a
OpenSource WoW Emulator
Loading...
Searching...
No Matches
Spell Class Reference

#include "Spell.h"

Classes

struct  GOTargetInfo
 
struct  HitTriggerSpell
 
struct  ItemTargetInfo
 

Public Types

typedef std::set< Aura * > UsedSpellMods
 

Public Member Functions

 Spell (Unit *caster, SpellInfo const *info, TriggerCastFlags triggerFlags, ObjectGuid originalCasterGUID=ObjectGuid::Empty, bool skipCheck=false)
 
 ~Spell ()
 
void EffectNULL (SpellEffIndex effIndex)
 
void EffectUnused (SpellEffIndex effIndex)
 
void EffectDistract (SpellEffIndex effIndex)
 
void EffectPull (SpellEffIndex effIndex)
 
void EffectSchoolDMG (SpellEffIndex effIndex)
 
void EffectEnvironmentalDMG (SpellEffIndex effIndex)
 
void EffectInstaKill (SpellEffIndex effIndex)
 
void EffectDummy (SpellEffIndex effIndex)
 
void EffectTeleportUnits (SpellEffIndex effIndex)
 
void EffectApplyAura (SpellEffIndex effIndex)
 
void EffectSendEvent (SpellEffIndex effIndex)
 
void EffectPowerBurn (SpellEffIndex effIndex)
 
void EffectPowerDrain (SpellEffIndex effIndex)
 
void EffectHeal (SpellEffIndex effIndex)
 
void EffectBind (SpellEffIndex effIndex)
 
void EffectHealthLeech (SpellEffIndex effIndex)
 
void EffectQuestComplete (SpellEffIndex effIndex)
 
void EffectCreateItem (SpellEffIndex effIndex)
 
void EffectCreateItem2 (SpellEffIndex effIndex)
 
void EffectCreateRandomItem (SpellEffIndex effIndex)
 
void EffectPersistentAA (SpellEffIndex effIndex)
 
void EffectEnergize (SpellEffIndex effIndex)
 
void EffectOpenLock (SpellEffIndex effIndex)
 
void EffectSummonChangeItem (SpellEffIndex effIndex)
 
void EffectProficiency (SpellEffIndex effIndex)
 
void EffectApplyAreaAura (SpellEffIndex effIndex)
 
void EffectSummonType (SpellEffIndex effIndex)
 
void EffectLearnSpell (SpellEffIndex effIndex)
 
void EffectDispel (SpellEffIndex effIndex)
 
void EffectDualWield (SpellEffIndex effIndex)
 
void EffectPickPocket (SpellEffIndex effIndex)
 
void EffectAddFarsight (SpellEffIndex effIndex)
 
void EffectUntrainTalents (SpellEffIndex effIndex)
 
void EffectHealMechanical (SpellEffIndex effIndex)
 
void EffectJump (SpellEffIndex effIndex)
 
void EffectJumpDest (SpellEffIndex effIndex)
 
void EffectLeapBack (SpellEffIndex effIndex)
 
void EffectQuestClear (SpellEffIndex effIndex)
 
void EffectTeleUnitsFaceCaster (SpellEffIndex effIndex)
 
void EffectLearnSkill (SpellEffIndex effIndex)
 
void EffectAddHonor (SpellEffIndex effIndex)
 
void EffectTradeSkill (SpellEffIndex effIndex)
 
void EffectEnchantItemPerm (SpellEffIndex effIndex)
 
void EffectEnchantItemTmp (SpellEffIndex effIndex)
 
void EffectTameCreature (SpellEffIndex effIndex)
 
void EffectSummonPet (SpellEffIndex effIndex)
 
void EffectLearnPetSpell (SpellEffIndex effIndex)
 
void EffectWeaponDmg (SpellEffIndex effIndex)
 
void EffectForceCast (SpellEffIndex effIndex)
 
void EffectTriggerSpell (SpellEffIndex effIndex)
 
void EffectTriggerMissileSpell (SpellEffIndex effIndex)
 
void EffectThreat (SpellEffIndex effIndex)
 
void EffectHealMaxHealth (SpellEffIndex effIndex)
 
void EffectInterruptCast (SpellEffIndex effIndex)
 
void EffectSummonObjectWild (SpellEffIndex effIndex)
 
void EffectScriptEffect (SpellEffIndex effIndex)
 
void EffectSanctuary (SpellEffIndex effIndex)
 
void EffectAddComboPoints (SpellEffIndex effIndex)
 
void EffectDuel (SpellEffIndex effIndex)
 
void EffectStuck (SpellEffIndex effIndex)
 
void EffectSummonPlayer (SpellEffIndex effIndex)
 
void EffectActivateObject (SpellEffIndex effIndex)
 
void EffectApplyGlyph (SpellEffIndex effIndex)
 
void EffectEnchantHeldItem (SpellEffIndex effIndex)
 
void EffectSummonObject (SpellEffIndex effIndex)
 
void EffectResurrect (SpellEffIndex effIndex)
 
void EffectParry (SpellEffIndex effIndex)
 
void EffectBlock (SpellEffIndex effIndex)
 
void EffectLeap (SpellEffIndex effIndex)
 
void EffectTransmitted (SpellEffIndex effIndex)
 
void EffectDisEnchant (SpellEffIndex effIndex)
 
void EffectInebriate (SpellEffIndex effIndex)
 
void EffectFeedPet (SpellEffIndex effIndex)
 
void EffectDismissPet (SpellEffIndex effIndex)
 
void EffectReputation (SpellEffIndex effIndex)
 
void EffectForceDeselect (SpellEffIndex effIndex)
 
void EffectSelfResurrect (SpellEffIndex effIndex)
 
void EffectSkinning (SpellEffIndex effIndex)
 
void EffectCharge (SpellEffIndex effIndex)
 
void EffectChargeDest (SpellEffIndex effIndex)
 
void EffectProspecting (SpellEffIndex effIndex)
 
void EffectMilling (SpellEffIndex effIndex)
 
void EffectRenamePet (SpellEffIndex effIndex)
 
void EffectSendTaxi (SpellEffIndex effIndex)
 
void EffectSummonCritter (SpellEffIndex effIndex)
 
void EffectKnockBack (SpellEffIndex effIndex)
 
void EffectPullTowards (SpellEffIndex effIndex)
 
void EffectDispelMechanic (SpellEffIndex effIndex)
 
void EffectResurrectPet (SpellEffIndex effIndex)
 
void EffectDestroyAllTotems (SpellEffIndex effIndex)
 
void EffectDurabilityDamage (SpellEffIndex effIndex)
 
void EffectSkill (SpellEffIndex effIndex)
 
void EffectTaunt (SpellEffIndex effIndex)
 
void EffectDurabilityDamagePCT (SpellEffIndex effIndex)
 
void EffectModifyThreatPercent (SpellEffIndex effIndex)
 
void EffectResurrectNew (SpellEffIndex effIndex)
 
void EffectAddExtraAttacks (SpellEffIndex effIndex)
 
void EffectSpiritHeal (SpellEffIndex effIndex)
 
void EffectSkinPlayerCorpse (SpellEffIndex effIndex)
 
void EffectStealBeneficialBuff (SpellEffIndex effIndex)
 
void EffectUnlearnSpecialization (SpellEffIndex effIndex)
 
void EffectHealPct (SpellEffIndex effIndex)
 
void EffectEnergizePct (SpellEffIndex effIndex)
 
void EffectTriggerRitualOfSummoning (SpellEffIndex effIndex)
 
void EffectSummonRaFFriend (SpellEffIndex effIndex)
 
void EffectKillCreditPersonal (SpellEffIndex effIndex)
 
void EffectKillCredit (SpellEffIndex effIndex)
 
void EffectQuestFail (SpellEffIndex effIndex)
 
void EffectQuestStart (SpellEffIndex effIndex)
 
void EffectRedirectThreat (SpellEffIndex effIndex)
 
void EffectGameObjectDamage (SpellEffIndex effIndex)
 
void EffectGameObjectRepair (SpellEffIndex effIndex)
 
void EffectGameObjectSetDestructionState (SpellEffIndex effIndex)
 
void EffectActivateRune (SpellEffIndex effIndex)
 
void EffectCreateTamedPet (SpellEffIndex effIndex)
 
void EffectDiscoverTaxi (SpellEffIndex effIndex)
 
void EffectTitanGrip (SpellEffIndex effIndex)
 
void EffectEnchantItemPrismatic (SpellEffIndex effIndex)
 
void EffectPlayMusic (SpellEffIndex effIndex)
 
void EffectSpecCount (SpellEffIndex effIndex)
 
void EffectActivateSpec (SpellEffIndex effIndex)
 
void EffectPlaySound (SpellEffIndex effIndex)
 
void EffectRemoveAura (SpellEffIndex effIndex)
 
void EffectCastButtons (SpellEffIndex effIndex)
 
void EffectRechargeManaGem (SpellEffIndex effIndex)
 
void InitExplicitTargets (SpellCastTargets const &targets)
 
void SelectExplicitTargets ()
 
void SelectSpellTargets ()
 
void SelectEffectImplicitTargets (SpellEffIndex effIndex, SpellImplicitTargetInfo const &targetType, uint32 &processedEffectMask)
 
void SelectImplicitChannelTargets (SpellEffIndex effIndex, SpellImplicitTargetInfo const &targetType)
 
void SelectImplicitNearbyTargets (SpellEffIndex effIndex, SpellImplicitTargetInfo const &targetType, uint32 effMask)
 
void SelectImplicitConeTargets (SpellEffIndex effIndex, SpellImplicitTargetInfo const &targetType, uint32 effMask)
 
void SelectImplicitAreaTargets (SpellEffIndex effIndex, SpellImplicitTargetInfo const &targetType, uint32 effMask)
 
void SelectImplicitCasterDestTargets (SpellEffIndex effIndex, SpellImplicitTargetInfo const &targetType)
 
void SelectImplicitTargetDestTargets (SpellEffIndex effIndex, SpellImplicitTargetInfo const &targetType)
 
void SelectImplicitDestDestTargets (SpellEffIndex effIndex, SpellImplicitTargetInfo const &targetType)
 
void SelectImplicitCasterObjectTargets (SpellEffIndex effIndex, SpellImplicitTargetInfo const &targetType)
 
void SelectImplicitTargetObjectTargets (SpellEffIndex effIndex, SpellImplicitTargetInfo const &targetType)
 
void SelectImplicitChainTargets (SpellEffIndex effIndex, SpellImplicitTargetInfo const &targetType, WorldObject *target, uint32 effMask)
 
void SelectImplicitTrajTargets (SpellEffIndex effIndex, SpellImplicitTargetInfo const &targetType)
 
void SelectEffectTypeImplicitTargets (uint8 effIndex)
 
uint32 GetSearcherTypeMask (SpellTargetObjectTypes objType, ConditionList *condList)
 
template<class SEARCHER >
void SearchTargets (SEARCHER &searcher, uint32 containerMask, Unit *referer, Position const *pos, float radius)
 
WorldObjectSearchNearbyTarget (float range, SpellTargetObjectTypes objectType, SpellTargetCheckTypes selectionType, ConditionList *condList=nullptr)
 
void SearchAreaTargets (std::list< WorldObject * > &targets, float range, Position const *position, Unit *referer, SpellTargetObjectTypes objectType, SpellTargetCheckTypes selectionType, ConditionList *condList)
 
void SearchChainTargets (std::list< WorldObject * > &targets, uint32 chainTargets, WorldObject *target, SpellTargetObjectTypes objectType, SpellTargetCheckTypes selectType, SpellTargetSelectionCategories selectCategory, ConditionList *condList, bool isChainHeal)
 
SpellCastResult prepare (SpellCastTargets const *targets, AuraEffect const *triggeredByAura=nullptr)
 
void cancel (bool bySelf=false)
 
void update (uint32 difftime)
 
void cast (bool skipCheck=false)
 
void _cast (bool skipCheck)
 
void finish (bool ok=true)
 
void TakePower ()
 
void TakeAmmo ()
 
void TakeRunePower (bool didHit)
 
void TakeReagents ()
 
void TakeCastItem ()
 
SpellCastResult CheckCast (bool strict)
 
SpellCastResult CheckPetCast (Unit *target)
 
void handle_immediate ()
 
uint64 handle_delayed (uint64 t_offset)
 
void _handle_immediate_phase ()
 
void _handle_finish_phase ()
 
void OnSpellLaunch ()
 
SpellCastResult CheckItems ()
 
SpellCastResult CheckSpellFocus ()
 
SpellCastResult CheckRange (bool strict)
 
SpellCastResult CheckPower ()
 
SpellCastResult CheckRuneCost (uint32 RuneCostID)
 
SpellCastResult CheckCasterAuras (bool preventionOnly) const
 
int32 CalculateSpellDamage (uint8 i, Unit const *target) const
 
bool HaveTargetsForEffect (uint8 effect) const
 
void Delayed ()
 
void DelayedChannel ()
 
uint32 getState () const
 
void setState (uint32 state)
 
void DoCreateItem (uint8 effIndex, uint32 itemId)
 
void WriteSpellGoTargets (WorldPacket *data)
 Writes miss and hit targets for a SMSG_SPELL_GO packet. More...
 
void WriteAmmoToPacket (WorldPacket *data)
 
bool CheckEffectTarget (Unit const *target, uint32 eff) const
 
bool CanAutoCast (Unit *target)
 
void CheckSrc ()
 
void CheckDst ()
 
void SendCastResult (SpellCastResult result)
 
void SendPetCastResult (SpellCastResult result)
 
void SendSpellStart ()
 
void SendSpellGo ()
 
void SendSpellCooldown ()
 
void SendLogExecute ()
 
void ExecuteLogEffectTakeTargetPower (uint8 effIndex, Unit *target, uint32 PowerType, uint32 powerTaken, float gainMultiplier)
 
void ExecuteLogEffectExtraAttacks (uint8 effIndex, Unit *victim, uint32 attCount)
 
void ExecuteLogEffectInterruptCast (uint8 effIndex, Unit *victim, uint32 spellId)
 
void ExecuteLogEffectDurabilityDamage (uint8 effIndex, Unit *victim, int32 itemId, int32 slot)
 
void ExecuteLogEffectOpenLock (uint8 effIndex, Object *obj)
 
void ExecuteLogEffectCreateItem (uint8 effIndex, uint32 entry)
 
void ExecuteLogEffectDestroyItem (uint8 effIndex, uint32 entry)
 
void ExecuteLogEffectSummonObject (uint8 effIndex, WorldObject *obj)
 
void ExecuteLogEffectUnsummonObject (uint8 effIndex, WorldObject *obj)
 
void ExecuteLogEffectResurrect (uint8 effIndex, Unit *target)
 
void SendInterrupted (uint8 result)
 
void SendChannelUpdate (uint32 time)
 
void SendChannelStart (uint32 duration)
 
void SendResurrectRequest (Player *target)
 
void HandleEffects (Unit *pUnitTarget, Item *pItemTarget, GameObject *pGOTarget, uint32 i, SpellEffectHandleMode mode)
 
void HandleThreatSpells ()
 
void AddComboPointGain (Unit *target, int8 amount)
 
int32 GetCastTime () const
 
bool IsAutoRepeat () const
 
void SetAutoRepeat (bool rep)
 
void ReSetTimer ()
 
bool IsNextMeleeSwingSpell () const
 
bool IsTriggered () const
 
bool HasTriggeredCastFlag (TriggerCastFlags flag) const
 
bool IsChannelActive () const
 
bool IsAutoActionResetSpell () const
 
bool IsIgnoringCooldowns () 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 GetDelayTrajectory () const
 
uint64 CalculateDelayMomentForDst () const
 
void RecalculateDelayMomentForDst ()
 
bool IsNeedSendToClient (bool go) const
 
CurrentSpellTypes GetCurrentContainer () const
 
UnitGetCaster () const
 
UnitGetOriginalCaster () const
 
SpellInfo const * GetSpellInfo () const
 
int32 GetPowerCost () const
 
bool UpdatePointers ()
 
void CleanupTargetList ()
 
void SetSpellValue (SpellValueMod mod, int32 value)
 
SpellValue const * GetSpellValue ()
 
void LoadScripts ()
 
std::list< TargetInfo > * GetUniqueTargetInfo ()
 
uint32 GetTriggeredByAuraTickNumber () const
 
TriggerCastFlags GetTriggeredCastFlags () const
 
SpellSchoolMask GetSpellSchoolMask () const
 

Static Public Member Functions

static void WriteCastResultInfo (WorldPacket &data, Player *caster, SpellInfo const *spellInfo, uint8 castCount, SpellCastResult result, SpellCustomErrors customError)
 
static void SendCastResult (Player *caster, SpellInfo const *spellInfo, uint8 castCount, SpellCastResult result, SpellCustomErrors customError=SPELL_CUSTOM_ERROR_NONE)
 

Public Attributes

SpellInfo const *const m_spellInfo
 
Itemm_CastItem
 
Itemm_weaponItem
 
ObjectGuid m_castItemGUID
 
uint8 m_cast_count
 
uint32 m_glyphIndex
 
uint32 m_preCastSpell
 
SpellCastTargets m_targets
 
SpellCustomErrors m_customError
 
Unitm_comboTarget
 
int8 m_comboPointGain
 
UsedSpellMods m_appliedMods
 

Protected Types

typedef std::list< HitTriggerSpellHitTriggerSpellList
 

Protected Member Functions

bool HasGlobalCooldown () const
 
void TriggerGlobalCooldown ()
 
void CancelGlobalCooldown ()
 
void SendLoot (ObjectGuid guid, LootType loottype)
 
std::string GetDebugInfo () const
 
bool isDelayableNoMore ()
 
void prepareDataForTriggerSystem (AuraEffect const *triggeredByAura)
 
void AddUnitTarget (Unit *target, uint32 effectMask, bool checkIfValid=true, bool implicit=true)
 
void AddGOTarget (GameObject *target, uint32 effectMask)
 
void AddItemTarget (Item *item, uint32 effectMask)
 
void AddDestTarget (SpellDestination const &dest, uint32 effIndex)
 
void DoAllEffectOnTarget (TargetInfo *target)
 
SpellMissInfo DoSpellHitOnUnit (Unit *unit, uint32 effectMask, bool scaleAura)
 
void DoTriggersOnSpellHit (Unit *unit, uint8 effMask)
 
void DoAllEffectOnTarget (GOTargetInfo *target)
 
void DoAllEffectOnTarget (ItemTargetInfo *target)
 
bool UpdateChanneledTargetList ()
 
bool IsValidDeadOrAliveTarget (Unit const *target) const
 
void HandleLaunchPhase ()
 
void DoAllEffectOnLaunchTarget (TargetInfo &targetInfo, float *multiplier)
 
void PrepareTargetProcessing ()
 
void FinishTargetProcessing ()
 
void InitEffectExecuteData (uint8 effIndex)
 
void CheckEffectExecuteData ()
 
void CallScriptBeforeCastHandlers ()
 
void CallScriptOnCastHandlers ()
 
void CallScriptAfterCastHandlers ()
 
SpellCastResult CallScriptCheckCastHandlers ()
 
void PrepareScriptHitHandlers ()
 
bool CallScriptEffectHandlers (SpellEffIndex effIndex, SpellEffectHandleMode mode)
 
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 (uint8 effMask, SpellInfo const *triggeredByAura=nullptr) const
 
void PrepareTriggersExecutedOnHit ()
 
void SummonGuardian (uint32 i, uint32 entry, SummonPropertiesEntry const *properties, uint32 numSummons, bool personalSpawn)
 
void CalculateJumpSpeeds (uint8 i, float dist, float &speedxy, float &speedz)
 
SpellCastResult CanOpenLock (uint32 effIndex, uint32 lockid, SkillType &skillid, int32 &reqSkillValue, int32 &skillValue)
 

Protected Attributes

Unit *const m_caster
 
SpellValue *const m_spellValue
 
ObjectGuid m_originalCasterGUID
 
Unitm_originalCaster
 
Spell ** m_selfContainer
 
SpellSchoolMask m_spellSchoolMask
 
WeaponAttackType m_attackType
 
int32 m_powerCost
 
int32 m_casttime
 
int32 m_channeledDuration
 
bool m_canReflect
 
uint8 m_spellFlags
 
bool m_autoRepeat
 
uint8 m_runesState
 
uint8 m_delayAtDamageCount
 
uint64 m_delayStart
 
uint64 m_delayMoment
 
uint64 m_delayTrajectory
 
bool m_immediateHandled
 
bool m_referencedFromCurrentSpell
 
bool m_executedCurrently
 
bool m_needComboPoints
 
uint8 m_applyMultiplierMask
 
float m_damageMultipliers [3]
 
UnitunitTarget
 
ItemitemTarget
 
GameObjectgameObjTarget
 
WorldLocationdestTarget
 
int32 damage
 
SpellEffectHandleMode effectHandleMode
 
Auram_spellAura
 
DiminishingLevels m_diminishLevel
 
DiminishingGroup m_diminishGroup
 
GameObjectfocusObject
 
int32 m_damage
 
int32 m_healing
 
uint32 m_procAttacker
 
uint32 m_procVictim
 
uint32 m_procEx
 
std::list< TargetInfom_UniqueTargetInfo
 
uint8 m_channelTargetEffectMask
 
std::list< GOTargetInfom_UniqueGOTargetInfo
 
std::list< ItemTargetInfom_UniqueItemInfo
 
SpellDestination m_destTargets [MAX_SPELL_EFFECTS]
 
bool _scriptsLoaded
 
std::list< SpellScript * > m_loadedScripts
 
HitTriggerSpellList m_hitTriggerSpells
 
uint32 m_spellState
 
int32 m_timer
 
SpellEvent_spellEvent
 
TriggerCastFlags _triggeredCastFlags
 
TriggeredByAuraSpellData m_triggeredByAuraSpell
 
bool m_skipCheck
 
uint8 m_auraScaleMask
 
std::unique_ptr< PathGeneratorm_preGeneratedPath
 
bool _spellTargetsSelected
 
ByteBufferm_effectExecuteData [MAX_SPELL_EFFECTS]
 

Friends

class SpellScript
 
void Unit::SetCurrentCastedSpell (Spell *pSpell)
 

Detailed Description

Member Typedef Documentation

◆ HitTriggerSpellList

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

◆ UsedSpellMods

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

Constructor & Destructor Documentation

◆ Spell()

Spell::Spell ( Unit caster,
SpellInfo const *  info,
TriggerCastFlags  triggerFlags,
ObjectGuid  originalCasterGUID = ObjectGuid::Empty,
bool  skipCheck = false 
)
568 :
569 m_spellInfo(sSpellMgr->GetSpellForDifficultyFromSpell(info, caster)),
570 m_caster((info->HasAttribute(SPELL_ATTR6_ORIGINATE_FROM_CONTROLLER) && caster->GetCharmerOrOwner()) ? caster->GetCharmerOrOwner() : caster)
572{
574 m_skipCheck = skipCheck;
575 m_selfContainer = nullptr;
577 m_executedCurrently = false;
580 m_comboTarget = nullptr;
581 m_delayStart = 0;
583
585 m_auraScaleMask = 0;
586 memset(m_damageMultipliers, 0, sizeof(m_damageMultipliers));
587
588 // Get data for type of attack
589 switch (m_spellInfo->DmgClass)
590 {
594 else
596 break;
599 break;
600 default:
601 // Wands
604 else
606 break;
607 }
608
609 m_spellSchoolMask = info->GetSchoolMask(); // Can be override for some spell (wand shoot for example)
610
612 // wand case
615 m_spellSchoolMask = SpellSchoolMask(1 << pItem->GetTemplate()->Damage[0].DamageType);
616
617 if (originalCasterGUID)
618 m_originalCasterGUID = originalCasterGUID;
619 else
621
624 else
625 {
628 m_originalCaster = nullptr;
629 }
630
632 _triggeredCastFlags = triggerFlags;
633 if (info->HasAttribute(SPELL_ATTR4_ALLOW_CAST_WHILE_CASTING))
635
636 m_CastItem = nullptr;
637
638 unitTarget = nullptr;
639 itemTarget = nullptr;
640 gameObjTarget = nullptr;
641 destTarget = nullptr;
642 damage = 0;
646 m_damage = 0;
647 m_healing = 0;
648 m_procAttacker = 0;
649 m_procVictim = 0;
650 m_procEx = 0;
651 focusObject = nullptr;
652 m_cast_count = 0;
653 m_glyphIndex = 0;
654 m_preCastSpell = 0;
655 m_spellAura = nullptr;
656 _scriptsLoaded = false;
657
658 //Auto Shot & Shoot (wand)
660
661 m_runesState = 0;
662 m_powerCost = 0; // setup to correct value in Spell::prepare, must not be used before.
663 m_casttime = 0; // setup to correct value in Spell::prepare, must not be used before.
664 m_timer = 0; // will set to castime in prepare
665 m_channeledDuration = 0; // will be setup in Spell::handle_immediate
666 m_immediateHandled = false;
667
669
671
672 // Determine if spell can be reflected back to the caster
673 // Patch 1.2 notes: Spell Reflection no longer reflects abilities
677
679 memset(m_effectExecuteData, 0, MAX_SPELL_EFFECTS * sizeof(ByteBuffer*));
680
681 for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
683
684 // xinef:
685 _spellTargetsSelected = false;
686
687 m_weaponItem = nullptr;
688}
std::uint8_t uint8
Definition: Define.h:109
std::uint32_t uint32
Definition: Define.h:107
@ OFF_ATTACK
Definition: Unit.h:210
@ BASE_ATTACK
Definition: Unit.h:209
@ RANGED_ATTACK
Definition: Unit.h:211
@ DIMINISHING_LEVEL_1
Definition: Unit.h:263
TriggerCastFlags
Definition: SpellDefines.h:130
@ TRIGGERED_CAST_DIRECTLY
Will ignore combo point requirement.
Definition: SpellDefines.h:139
@ TRIGGERED_IGNORE_CAST_IN_PROGRESS
Will ignore aura scaling.
Definition: SpellDefines.h:137
#define sSpellMgr
Definition: SpellMgr.h:825
@ SPELL_EFFECT_HANDLE_LAUNCH
Definition: Spell.h:233
@ SPELL_FLAG_NORMAL
Definition: Spell.h:81
@ SPELL_STATE_NULL
Definition: Spell.h:223
@ DIMINISHING_NONE
Definition: SharedDefines.h:3258
@ SPELL_EFFECT_DISPEL
Definition: SharedDefines.h:816
#define CLASSMASK_WAND_USERS
Definition: SharedDefines.h:174
@ SPELL_ATTR2_AUTO_REPEAT
Definition: SharedDefines.h:461
@ SPELL_ATTR1_NO_REFLECTION
Definition: SharedDefines.h:426
@ SPELL_ATTR3_REQUIRES_OFF_HAND_WEAPON
Definition: SharedDefines.h:517
@ SPELL_DAMAGE_CLASS_RANGED
Definition: SharedDefines.h:1548
@ SPELL_DAMAGE_CLASS_MAGIC
Definition: SharedDefines.h:1546
@ SPELL_DAMAGE_CLASS_MELEE
Definition: SharedDefines.h:1547
@ SPELL_CUSTOM_ERROR_NONE
Definition: SharedDefines.h:1143
@ SPELL_ATTR0_IS_ABILITY
Definition: SharedDefines.h:386
@ SPELL_ATTR0_NO_IMMUNITIES
Definition: SharedDefines.h:411
@ SPELL_ATTR4_ALLOW_CAST_WHILE_CASTING
Definition: SharedDefines.h:537
@ SPELL_ATTR6_ORIGINATE_FROM_CONTROLLER
Definition: SharedDefines.h:622
SpellSchoolMask
Definition: SharedDefines.h:295
#define MAX_SPELL_EFFECTS
Definition: DBCStructure.h:1637
Unit * GetUnit(WorldObject const &, ObjectGuid const guid)
Definition: ObjectAccessor.cpp:202
Definition: Item.h:220
bool IsPlayer() const
Definition: Object.h:197
Player * ToPlayer()
Definition: Object.h:198
bool IsInWorld() const
Definition: Object.h:104
static ObjectGuid GetGUID(Object const *o)
Definition: Object.h:109
Item * GetWeaponForAttack(WeaponAttackType attackType, bool useable=false) const
Definition: PlayerStorage.cpp:494
Unit * GetCharmerOrOwner() const
Definition: Unit.h:1243
uint32 getClassMask() const
Definition: Unit.h:749
Definition: Spell.h:94
Definition: Spell.h:211
Unit * m_comboTarget
Definition: Spell.h:542
int8 m_comboPointGain
Definition: Spell.h:543
GameObject * gameObjTarget
Definition: Spell.h:653
bool m_referencedFromCurrentSpell
Definition: Spell.h:644
bool m_canReflect
Definition: Spell.h:620
uint32 m_procVictim
Definition: Spell.h:675
Unit * m_originalCaster
Definition: Spell.h:608
bool m_needComboPoints
Definition: Spell.h:646
uint64 m_delayStart
Definition: Spell.h:638
bool _scriptsLoaded
Definition: Spell.h:726
TriggerCastFlags _triggeredCastFlags
Definition: Spell.h:767
int32 damage
Definition: Spell.h:655
SpellEffectHandleMode effectHandleMode
Definition: Spell.h:656
int32 m_channeledDuration
Definition: Spell.h:619
Aura * m_spellAura
Definition: Spell.h:658
SpellDestination m_destTargets[MAX_SPELL_EFFECTS]
Definition: Spell.h:701
Unit *const m_caster
Definition: Spell.h:602
uint8 m_delayAtDamageCount
Definition: Spell.h:627
WeaponAttackType m_attackType
Definition: Spell.h:616
bool m_immediateHandled
Definition: Spell.h:641
uint32 m_spellState
Definition: Spell.h:763
ObjectGuid m_originalCasterGUID
Definition: Spell.h:606
void CleanupTargetList()
Definition: Spell.cpp:2372
int32 m_timer
Definition: Spell.h:764
int32 m_casttime
Definition: Spell.h:618
Item * itemTarget
Definition: Spell.h:652
uint8 m_cast_count
Definition: Spell.h:524
int32 m_damage
Definition: Spell.h:668
bool m_executedCurrently
Definition: Spell.h:645
DiminishingLevels m_diminishLevel
Definition: Spell.h:661
float m_damageMultipliers[3]
Definition: Spell.h:648
ByteBuffer * m_effectExecuteData[MAX_SPELL_EFFECTS]
Definition: Spell.h:781
uint8 m_auraScaleMask
Definition: Spell.h:775
SpellCustomErrors m_customError
Definition: Spell.h:528
uint8 m_spellFlags
Definition: Spell.h:622
bool m_skipCheck
Definition: Spell.h:774
int32 m_healing
Definition: Spell.h:669
uint32 m_glyphIndex
Definition: Spell.h:525
uint8 m_channelTargetEffectMask
Definition: Spell.h:683
Item * m_weaponItem
Definition: Spell.h:522
Unit * unitTarget
Definition: Spell.h:651
SpellSchoolMask m_spellSchoolMask
Definition: Spell.h:615
SpellEvent * _spellEvent
Definition: Spell.h:766
bool _spellTargetsSelected
Definition: Spell.h:779
uint32 m_preCastSpell
Definition: Spell.h:526
WorldLocation * destTarget
Definition: Spell.h:654
Spell ** m_selfContainer
Definition: Spell.h:610
uint8 m_applyMultiplierMask
Definition: Spell.h:647
DiminishingGroup m_diminishGroup
Definition: Spell.h:662
uint32 m_procEx
Definition: Spell.h:676
Item * m_CastItem
Definition: Spell.h:521
SpellValue *const m_spellValue
Definition: Spell.h:604
int32 m_powerCost
Definition: Spell.h:617
uint32 m_procAttacker
Definition: Spell.h:674
GameObject * focusObject
Definition: Spell.h:665
SpellInfo const *const m_spellInfo
Definition: Spell.h:520
uint8 m_runesState
Definition: Spell.h:625
bool m_autoRepeat
Definition: Spell.h:624
bool IsPassive() const
Definition: SpellInfo.cpp:1097
bool NeedsComboPoints() const
Definition: SpellInfo.cpp:1265
bool HasAttribute(SpellAttr0 attribute) const
Definition: SpellInfo.h:415
bool HasEffect(SpellEffects effect) const
Definition: SpellInfo.cpp:875
bool IsPositive() const
Definition: SpellInfo.cpp:1236
bool IsAutoRepeatRangedSpell() const
Definition: SpellInfo.cpp:1282
uint32 DmgClass
Definition: SpellInfo.h:389
bool IsRangedWeaponSpell() const
Definition: SpellInfo.cpp:1275
Definition: ByteBuffer.h:70

References _scriptsLoaded, _spellTargetsSelected, _triggeredCastFlags, BASE_ATTACK, CLASSMASK_WAND_USERS, CleanupTargetList(), damage, destTarget, DIMINISHING_LEVEL_1, DIMINISHING_NONE, SpellInfo::DmgClass, effectHandleMode, focusObject, gameObjTarget, Unit::getClassMask(), Object::GetGUID(), SpellInfo::GetSchoolMask(), ObjectAccessor::GetUnit(), Player::GetWeaponForAttack(), SpellInfo::HasAttribute(), SpellInfo::HasEffect(), SpellInfo::IsAutoRepeatRangedSpell(), Object::IsInWorld(), SpellInfo::IsPassive(), Object::IsPlayer(), SpellInfo::IsPositive(), SpellInfo::IsRangedWeaponSpell(), itemTarget, m_applyMultiplierMask, m_attackType, m_auraScaleMask, m_autoRepeat, m_canReflect, m_cast_count, m_caster, m_CastItem, m_casttime, m_channeledDuration, m_channelTargetEffectMask, m_comboPointGain, m_comboTarget, m_customError, m_damage, m_damageMultipliers, m_delayAtDamageCount, m_delayStart, m_destTargets, m_diminishGroup, m_diminishLevel, m_effectExecuteData, m_executedCurrently, m_glyphIndex, m_healing, m_immediateHandled, m_needComboPoints, m_originalCaster, m_originalCasterGUID, m_powerCost, m_preCastSpell, m_procAttacker, m_procEx, m_procVictim, m_referencedFromCurrentSpell, m_runesState, m_selfContainer, m_skipCheck, m_spellAura, m_spellFlags, m_spellInfo, m_spellSchoolMask, m_spellState, m_timer, m_weaponItem, MAX_SPELL_EFFECTS, SpellInfo::NeedsComboPoints(), OFF_ATTACK, RANGED_ATTACK, SPELL_ATTR0_IS_ABILITY, SPELL_ATTR0_NO_IMMUNITIES, SPELL_ATTR1_NO_REFLECTION, SPELL_ATTR2_AUTO_REPEAT, SPELL_ATTR3_REQUIRES_OFF_HAND_WEAPON, SPELL_ATTR4_ALLOW_CAST_WHILE_CASTING, SPELL_CUSTOM_ERROR_NONE, SPELL_DAMAGE_CLASS_MAGIC, SPELL_DAMAGE_CLASS_MELEE, SPELL_DAMAGE_CLASS_RANGED, SPELL_EFFECT_DISPEL, SPELL_EFFECT_HANDLE_LAUNCH, SPELL_FLAG_NORMAL, SPELL_STATE_NULL, Object::ToPlayer(), TRIGGERED_CAST_DIRECTLY, TRIGGERED_IGNORE_CAST_IN_PROGRESS, and unitTarget.

◆ ~Spell()

Spell::~Spell ( )
691{
692 // unload scripts
693 while (!m_loadedScripts.empty())
694 {
695 std::list<SpellScript*>::iterator itr = m_loadedScripts.begin();
696 (*itr)->_Unload();
697 delete (*itr);
698 m_loadedScripts.erase(itr);
699 }
700
702 {
703 // Clean the reference to avoid later crash.
704 // If this error is repeating, we may have to add an ASSERT to better track down how we get into this case.
705 LOG_ERROR("spells", "Spell::~Spell: deleting spell for spell ID {}. However, spell still referenced.", m_spellInfo->Id);
706 *m_selfContainer = nullptr;
707 }
708
709 delete m_spellValue;
710
712}
#define LOG_ERROR(filterType__,...)
Definition: Log.h:156
void CheckEffectExecuteData()
Definition: Spell.cpp:8482
std::list< SpellScript * > m_loadedScripts
Definition: Spell.h:741
uint32 Id
Definition: SpellInfo.h:320

References CheckEffectExecuteData(), SpellInfo::Id, LOG_ERROR, m_loadedScripts, m_referencedFromCurrentSpell, m_selfContainer, m_spellInfo, and m_spellValue.

Member Function Documentation

◆ _cast()

void Spell::_cast ( bool  skipCheck)

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

3801{
3802 // update pointers base at GUIDs to prevent access to non-existed already object
3803 if (!UpdatePointers())
3804 {
3805 // cancel the spell if UpdatePointers() returned false, something wrong happened there
3806 cancel();
3807 return;
3808 }
3809
3810 // cancel at lost explicit target during cast
3812 {
3813 cancel();
3814 return;
3815 }
3816
3817 // Xinef: implement attribute SPELL_ATTR1_DISMISS_PET_FIRST, on spell cast current pet is dismissed and charms are removed
3819 {
3821 if (Pet* pet = m_caster->ToPlayer()->GetPet())
3823
3824 if (Unit* charm = m_caster->GetCharm())
3825 charm->RemoveAurasByType(SPELL_AURA_MOD_CHARM, m_caster->GetGUID());
3826 }
3827
3828 if (Player* playerCaster = m_caster->ToPlayer())
3829 {
3830 // now that we've done the basic check, now run the scripts
3831 // should be done before the spell is actually executed
3832 sScriptMgr->OnPlayerSpellCast(playerCaster, this, skipCheck);
3833
3834 // As of 3.0.2 pets begin attacking their owner's target immediately
3835 // Let any pets know we've attacked something. Check DmgClass for harmful spells only
3836 // This prevents spells such as Hunter's Mark from triggering pet attack
3837 // xinef: take into account SPELL_ATTR3_SUPRESS_TARGET_PROCS
3839 if (!playerCaster->m_Controlled.empty())
3840 for (Unit::ControlSet::iterator itr = playerCaster->m_Controlled.begin(); itr != playerCaster->m_Controlled.end(); ++itr)
3841 if (Unit* pet = *itr)
3842 if (pet->IsAlive() && pet->IsCreature())
3843 pet->ToCreature()->AI()->OwnerAttacked(m_targets.GetUnitTarget());
3844 }
3845
3847
3851
3853
3854 Player* modOwner = m_caster->GetSpellModOwner();
3855 // skip check if done already (for instant cast spells for example)
3856 if (!skipCheck)
3857 {
3858 SpellCastResult castResult = CheckCast(false);
3859 if (castResult != SPELL_CAST_OK)
3860 {
3861 SendCastResult(castResult);
3862 SendInterrupted(0);
3863
3864 finish(false);
3865 SetExecutedCurrently(false);
3866 return;
3867 }
3868
3869 // additional check after cast bar completes (must not be in CheckCast)
3870 // if trade not complete then remember it in trade data
3872 {
3873 if (m_caster->IsPlayer())
3874 {
3875 if (TradeData* my_trade = m_caster->ToPlayer()->GetTradeData())
3876 {
3877 if (!my_trade->IsInAcceptProcess())
3878 {
3879 // Spell will be casted at completing the trade. Silently ignore at this place
3880 my_trade->SetSpell(m_spellInfo->Id, m_CastItem);
3882 SendInterrupted(0);
3883
3884 finish(false);
3885 SetExecutedCurrently(false);
3886 return;
3887 }
3888 }
3889 }
3890 }
3891 }
3892
3893 if (modOwner)
3894 modOwner->SetSpellModTakingSpell(this, true);
3895
3898
3899 if (modOwner)
3900 modOwner->SetSpellModTakingSpell(this, false);
3901
3902 // Spell may be finished after target map check
3904 {
3905 SendInterrupted(0);
3906 finish(false);
3907 SetExecutedCurrently(false);
3908 return;
3909 }
3910
3911 if (modOwner)
3912 modOwner->SetSpellModTakingSpell(this, true);
3913
3915
3917
3918 if (modOwner)
3919 modOwner->SetSpellModTakingSpell(this, false);
3920
3921 // traded items have trade slot instead of guid in m_itemTargetGUID
3922 // set to real guid to be sent later to the client
3924
3925 if (m_caster->IsPlayer())
3926 {
3928 {
3931 }
3932
3934 }
3935
3937 {
3938 // Powers have to be taken before SendSpellGo
3939 TakePower();
3940 TakeReagents(); // we must remove reagents before HandleEffects to allow place crafted item in same slot
3941 }
3942 else if (Item* targetItem = m_targets.GetItemTarget())
3943 {
3945 if (targetItem->GetOwnerGUID() != m_caster->GetGUID())
3946 TakeReagents();
3947 }
3948
3950
3951 // CAST SPELL
3952 if (modOwner)
3953 modOwner->SetSpellModTakingSpell(this, true);
3954
3956
3958
3959 // we must send smsg_spell_go packet before m_castItem delete in TakeCastItem()...
3960 SendSpellGo();
3961
3962 if (modOwner)
3963 modOwner->SetSpellModTakingSpell(this, false);
3964
3965 if (m_originalCaster)
3966 {
3967 // Handle procs on cast
3968 uint32 procAttacker = m_procAttacker;
3969 if (!procAttacker)
3970 {
3971 bool IsPositive = m_spellInfo->IsPositive();
3973 {
3975 }
3976 else
3977 {
3979 }
3980 }
3981
3982 uint32 procEx = PROC_EX_NORMAL_HIT;
3983
3984 for (std::list<TargetInfo>::iterator ihit = m_UniqueTargetInfo.begin(); ihit != m_UniqueTargetInfo.end(); ++ihit)
3985 {
3986 if (ihit->missCondition != SPELL_MISS_NONE)
3987 {
3988 continue;
3989 }
3990
3991 if (!ihit->crit)
3992 {
3993 continue;
3994 }
3995
3996 procEx |= PROC_EX_CRITICAL_HIT;
3997 break;
3998 }
3999
4002 }
4003
4004 if (modOwner)
4005 modOwner->SetSpellModTakingSpell(this, true);
4006
4008 if (resetAttackTimers)
4009 {
4011 for (Unit::AuraEffectList::const_iterator i = vIgnoreReset.begin(); i != vIgnoreReset.end(); ++i)
4012 {
4013 if ((*i)->IsAffectedOnSpell(m_spellInfo))
4014 {
4015 resetAttackTimers = false;
4016 break;
4017 }
4018 }
4019 }
4020
4021 // Okay, everything is prepared. Now we need to distinguish between immediate and evented delayed spells
4022 if ((m_spellInfo->Speed > 0.0f && !m_spellInfo->IsChanneled())/* xinef: we dont need this || m_spellInfo->Id == 14157*/)
4023 {
4024 // Remove used for cast item if need (it can be already nullptr after TakeReagents call
4025 // in case delayed spell remove item at cast delay start
4026 TakeCastItem();
4027
4028 // Okay, maps created, now prepare flags
4029 m_immediateHandled = false;
4031 SetDelayStart(0);
4032
4035
4036 // remove all applied mods at this point
4037 // dont allow user to use them twice in case spell did not reach current target
4038 if (modOwner)
4039 modOwner->RemoveSpellMods(this);
4040
4041 // Xinef: why do we keep focus after spell is sent to air?
4042 // Xinef: Because of this, in the middle of some animation after setting targetguid to 0 etc
4043 // Xinef: we get focused to it out of nowhere...
4044 if (Creature* creatureCaster = m_caster->ToCreature())
4045 creatureCaster->ReleaseFocus(this);
4046 }
4047 else
4048 {
4049 // Immediate spell, no big deal
4051 }
4052
4053 if (resetAttackTimers)
4054 {
4055 if (m_casttime == 0 && m_spellInfo->CalcCastTime())
4056 {
4057 resetAttackTimers = false;
4058 }
4059
4060 if (resetAttackTimers)
4061 {
4063
4065 {
4067 }
4068
4070 }
4071 }
4072
4074
4075 if (modOwner)
4076 modOwner->SetSpellModTakingSpell(this, false);
4077
4078 if (const std::vector<int32>* spell_triggered = sSpellMgr->GetSpellLinked(m_spellInfo->Id))
4079 {
4080 for (std::vector<int32>::const_iterator i = spell_triggered->begin(); i != spell_triggered->end(); ++i)
4081 if (*i < 0)
4083 else
4085 }
4086
4087 // Interrupt Spell casting
4088 // handle this here, in other places SpellHitTarget can be set to nullptr, if there is an error in this function
4090 if (Unit* target = m_targets.GetUnitTarget())
4091 if (target->IsCreature())
4092 m_caster->CastSpell(target, 32747, true);
4093
4094 // xinef: start combat at cast for delayed spells, only for explicit target
4095 if (Unit* target = m_targets.GetUnitTarget())
4098 m_caster->CombatStartOnCast(target, !m_spellInfo->HasAttribute(SPELL_ATTR3_SUPRESS_TARGET_PROCS), GetDelayMoment() + 500); // xinef: increase this time so we dont leave and enter combat in a moment
4099
4100 if (m_caster->IsPlayer())
4103
4104 SetExecutedCurrently(false);
4105}
#define sScriptMgr
Definition: ScriptMgr.h:708
@ UNIT_STATE_CASTING
Definition: UnitDefines.h:164
@ CHEAT_COOLDOWN
Definition: Player.h:1001
@ PET_SAVE_AS_CURRENT
Definition: PetDefines.h:42
@ SPELL_AURA_MOD_CHARM
Definition: SpellAuraDefines.h:69
@ SPELL_AURA_IGNORE_MELEE_RESET
Definition: SpellAuraDefines.h:335
@ SPELL_AURA_BIND_SIGHT
Definition: SpellAuraDefines.h:64
@ TRIGGERED_IGNORE_POWER_AND_REAGENT_COST
Will ignore Spell and Category cooldowns.
Definition: SpellDefines.h:134
@ TRIGGERED_IGNORE_CAST_ITEM
Will ignore power and reagent cost.
Definition: SpellDefines.h:135
@ TRIGGERED_IGNORE_SET_FACING
Will ignore interruptible aura's at cast.
Definition: SpellDefines.h:141
@ PROC_EX_CRITICAL_HIT
Definition: SpellMgr.h:195
@ PROC_EX_NORMAL_HIT
Definition: SpellMgr.h:194
@ PROC_SPELL_PHASE_CAST
Definition: SpellMgr.h:243
@ PROC_FLAG_DONE_SPELL_MAGIC_DMG_CLASS_POS
Definition: SpellMgr.h:128
@ PROC_FLAG_DONE_SPELL_NONE_DMG_CLASS_POS
Definition: SpellMgr.h:122
@ PROC_FLAG_DONE_SPELL_NONE_DMG_CLASS_NEG
Definition: SpellMgr.h:125
@ PROC_FLAG_NONE
Definition: SpellMgr.h:105
@ PROC_FLAG_DONE_SPELL_MAGIC_DMG_CLASS_NEG
Definition: SpellMgr.h:131
@ TARGET_FLAG_TRADE_ITEM
Definition: SpellInfo.h:58
@ TARGET_FLAG_UNIT
Definition: SpellInfo.h:47
@ SPELL_STATE_DELAYED
Definition: Spell.h:228
@ SPELL_STATE_FINISHED
Definition: Spell.h:226
@ SPELL_ATTR7_CAN_CAUSE_INTERRUPT
Definition: SharedDefines.h:652
@ SPELL_EFFECT_SUMMON_PET
Definition: SharedDefines.h:834
@ SPELL_ATTR2_DO_NOT_RESET_COMBAT_TIMERS
Definition: SharedDefines.h:473
@ SPELL_ATTR1_DISMISS_PET_FIRST
Definition: SharedDefines.h:419
@ SPELL_ATTR3_SUPRESS_TARGET_PROCS
Definition: SharedDefines.h:510
@ SPELL_DAMAGE_CLASS_NONE
Definition: SharedDefines.h:1545
@ SPELL_MISS_NONE
Definition: SharedDefines.h:1519
SpellCastResult
Definition: SharedDefines.h:948
@ SPELL_FAILED_DONT_REPORT
Definition: SharedDefines.h:976
@ SPELL_CAST_OK
Definition: SharedDefines.h:1138
@ ACHIEVEMENT_TIMED_TYPE_ITEM
Definition: DBCEnums.h:115
@ ACHIEVEMENT_CRITERIA_TYPE_USE_ITEM
Definition: DBCEnums.h:155
@ ACHIEVEMENT_CRITERIA_TYPE_CAST_SPELL
Definition: DBCEnums.h:143
Definition: Creature.h:46
uint32 GetEntry() const
Definition: Object.h:112
bool IsCreature() const
Definition: Object.h:201
Creature * ToCreature()
Definition: Object.h:202
Definition: Pet.h:41
Definition: Player.h:1064
void UpdateAchievementCriteria(AchievementCriteriaTypes type, uint32 miscValue1=0, uint32 miscValue2=0, Unit *unit=nullptr)
Definition: PlayerUpdates.cpp:2127
void SetSpellModTakingSpell(Spell *spell, bool apply)
Definition: Player.cpp:10077
void StartTimedAchievement(AchievementCriteriaTimedTypes type, uint32 entry, uint32 timeLost=0)
Definition: Player.cpp:13920
void RemoveSpellMods(Spell *spell)
Definition: Player.cpp:10009
Pet * GetPet() const
Definition: Player.cpp:8906
bool GetCommandStatus(uint32 command) const
Definition: Player.h:1178
void RemovePet(Pet *pet, PetSaveMode mode, bool returnreagent=false)
Definition: Player.cpp:9057
TradeData * GetTradeData() const
Definition: Player.h:1368
void RemoveSpellCooldown(uint32 spell_id, bool update=false)
Definition: Player.cpp:3503
Definition: TradeData.h:36
Definition: Unit.h:630
void ClearUnitState(uint32 f)
Definition: Unit.h:674
AuraEffectList const & GetAuraEffectsByType(AuraType type) const
Definition: Unit.h:1362
Unit * GetCharm() const
Definition: Unit.cpp:10628
Player * GetSpellModOwner() const
Definition: Unit.cpp:16533
void CombatStartOnCast(Unit *target, bool initialAggro=true, uint32 duration=0)
Definition: Unit.cpp:13662
bool haveOffhandWeapon() const
Definition: Unit.cpp:522
bool IsPet() const
Definition: Unit.h:710
bool IsNonMeleeSpellCast(bool withDelayed, bool skipChanneled=false, bool skipAutorepeat=false, bool isAutoshoot=false, bool skipInstant=true) const
Definition: Unit.cpp:4081
SpellCastResult CastSpell(SpellCastTargets const &targets, SpellInfo const *spellInfo, CustomSpellValues const *value, TriggerCastFlags triggerFlags=TRIGGERED_NONE, Item *castItem=nullptr, AuraEffect const *triggeredByAura=nullptr, ObjectGuid originalCaster=ObjectGuid::Empty)
Definition: Unit.cpp:1168
void RemoveAurasDueToSpell(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, uint8 reqEffMask=0, AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
Definition: Unit.cpp:4891
static void ProcDamageAndSpell(Unit *actor, Unit *victim, uint32 procAttacker, uint32 procVictim, uint32 procEx, uint32 amount, WeaponAttackType attType=BASE_ATTACK, SpellInfo const *procSpellInfo=nullptr, SpellInfo const *procAura=nullptr, int8 procAuraEffectIndex=-1, Spell const *procSpell=nullptr, DamageInfo *damageInfo=nullptr, HealInfo *healInfo=nullptr, uint32 procPhase=2)
Definition: Unit.cpp:6349
bool HasUnitState(const uint32 f) const
Definition: Unit.h:673
bool IsFriendlyTo(Unit const *unit) const
Definition: Unit.cpp:10203
bool IsControlledByPlayer() const
Definition: Unit.h:1224
std::list< AuraEffect * > AuraEffectList
Definition: Unit.h:646
void SetInFront(WorldObject const *target)
Definition: Unit.cpp:20477
void resetAttackTimer(WeaponAttackType type=BASE_ATTACK)
Definition: Unit.cpp:643
WorldObject * GetObjectTarget() const
Definition: Spell.cpp:312
void UpdateTradeSlotItem()
Definition: Spell.cpp:349
ObjectGuid GetObjectTargetGUID() const
Definition: Spell.cpp:317
Item * GetItemTarget() const
Definition: Spell.h:139
uint32 GetTargetMask() const
Definition: Spell.h:117
Unit * GetUnitTarget() const
Definition: Spell.cpp:233
int8 effectIndex
Definition: Spell.h:279
SpellInfo const * spellInfo
Definition: Spell.h:278
SpellInfo const * GetSpellInfo() const
Definition: Spell.h:575
void CallScriptAfterCastHandlers()
Definition: Spell.cpp:8536
void PrepareTriggersExecutedOnHit()
Definition: Spell.cpp:8742
bool HasTriggeredCastFlag(TriggerCastFlags flag) const
Definition: Spell.h:553
SpellCastTargets m_targets
Definition: Spell.h:527
TriggeredByAuraSpellData m_triggeredByAuraSpell
Definition: Spell.h:772
void handle_immediate()
Definition: Spell.cpp:4107
void SendSpellGo()
Definition: Spell.cpp:4789
void TakeReagents()
Definition: Spell.cpp:5523
void SetExecutedCurrently(bool yes)
Definition: Spell.h:561
void SendInterrupted(uint8 result)
Definition: Spell.cpp:5166
void PrepareScriptHitHandlers()
Definition: Spell.cpp:8568
void CallScriptOnCastHandlers()
Definition: Spell.cpp:8523
void cancel(bool bySelf=false)
Definition: Spell.cpp:3712
void SendSpellCooldown()
Definition: Spell.cpp:4347
void CallScriptBeforeCastHandlers()
Definition: Spell.cpp:8510
void HandleLaunchPhase()
Definition: Spell.cpp:8223
bool UpdatePointers()
Definition: Spell.cpp:7853
void SetDelayStart(uint64 m_time)
Definition: Spell.h:563
std::list< TargetInfo > m_UniqueTargetInfo
Definition: Spell.h:682
void SelectSpellTargets()
Definition: Spell.cpp:816
void TakePower()
Definition: Spell.cpp:5307
SpellCastResult CheckCast(bool strict)
Definition: Spell.cpp:5645
static void SendCastResult(Player *caster, SpellInfo const *spellInfo, uint8 castCount, SpellCastResult result, SpellCustomErrors customError=SPELL_CUSTOM_ERROR_NONE)
Definition: Spell.cpp:4661
uint64 GetDelayMoment() const
Definition: Spell.h:564
void TakeCastItem()
Definition: Spell.cpp:5244
bool IsAutoActionResetSpell() const
Definition: Spell.cpp:8067
void finish(bool ok=true)
Definition: Spell.cpp:4474
float Speed
Definition: SpellInfo.h:370
bool IsChanneled() const
Definition: SpellInfo.cpp:1255
uint32 CalcCastTime(Unit *caster=nullptr, Spell *spell=nullptr) const
Definition: SpellInfo.cpp:2351
bool HasAura(AuraType aura) const
Definition: SpellInfo.cpp:892

References _spellTargetsSelected, ACHIEVEMENT_CRITERIA_TYPE_CAST_SPELL, ACHIEVEMENT_CRITERIA_TYPE_USE_ITEM, ACHIEVEMENT_TIMED_TYPE_ITEM, BASE_ATTACK, SpellInfo::CalcCastTime(), CallScriptAfterCastHandlers(), CallScriptBeforeCastHandlers(), CallScriptOnCastHandlers(), cancel(), Unit::CastSpell(), CHEAT_COOLDOWN, CheckCast(), Unit::ClearUnitState(), Unit::CombatStartOnCast(), SpellInfo::DmgClass, TriggeredByAuraSpellData::effectIndex, finish(), Unit::GetAuraEffectsByType(), Unit::GetCharm(), Player::GetCommandStatus(), GetDelayMoment(), Object::GetEntry(), Object::GetGUID(), SpellCastTargets::GetItemTarget(), SpellCastTargets::GetObjectTarget(), SpellCastTargets::GetObjectTargetGUID(), Player::GetPet(), GetSpellInfo(), Unit::GetSpellModOwner(), SpellCastTargets::GetTargetMask(), Player::GetTradeData(), SpellCastTargets::GetUnitTarget(), handle_immediate(), HandleLaunchPhase(), SpellInfo::HasAttribute(), SpellInfo::HasAura(), SpellInfo::HasEffect(), HasTriggeredCastFlag(), Unit::HasUnitState(), Unit::haveOffhandWeapon(), SpellInfo::Id, IsAutoActionResetSpell(), SpellInfo::IsChanneled(), Unit::IsControlledByPlayer(), Object::IsCreature(), Unit::IsFriendlyTo(), Unit::IsNonMeleeSpellCast(), Unit::IsPet(), Object::IsPlayer(), SpellInfo::IsPositive(), m_caster, m_CastItem, m_casttime, m_immediateHandled, m_originalCaster, m_procAttacker, m_spellInfo, m_spellState, m_targets, m_triggeredByAuraSpell, m_UniqueTargetInfo, OFF_ATTACK, PET_SAVE_AS_CURRENT, PrepareScriptHitHandlers(), PrepareTriggersExecutedOnHit(), PROC_EX_CRITICAL_HIT, PROC_EX_NORMAL_HIT, PROC_FLAG_DONE_SPELL_MAGIC_DMG_CLASS_NEG, PROC_FLAG_DONE_SPELL_MAGIC_DMG_CLASS_POS, PROC_FLAG_DONE_SPELL_NONE_DMG_CLASS_NEG, PROC_FLAG_DONE_SPELL_NONE_DMG_CLASS_POS, PROC_FLAG_NONE, PROC_SPELL_PHASE_CAST, Unit::ProcDamageAndSpell(), RANGED_ATTACK, Unit::RemoveAurasDueToSpell(), Player::RemovePet(), Player::RemoveSpellCooldown(), Player::RemoveSpellMods(), Unit::resetAttackTimer(), SelectSpellTargets(), SendCastResult(), SendInterrupted(), SendSpellCooldown(), SendSpellGo(), SetDelayStart(), SetExecutedCurrently(), Unit::SetInFront(), Player::SetSpellModTakingSpell(), SpellInfo::Speed, SPELL_ATTR1_DISMISS_PET_FIRST, SPELL_ATTR2_DO_NOT_RESET_COMBAT_TIMERS, SPELL_ATTR3_SUPRESS_TARGET_PROCS, SPELL_ATTR7_CAN_CAUSE_INTERRUPT, SPELL_AURA_BIND_SIGHT, SPELL_AURA_IGNORE_MELEE_RESET, SPELL_AURA_MOD_CHARM, SPELL_CAST_OK, SPELL_DAMAGE_CLASS_MAGIC, SPELL_DAMAGE_CLASS_NONE, SPELL_EFFECT_DISPEL, SPELL_EFFECT_SUMMON_PET, SPELL_FAILED_DONT_REPORT, SPELL_MISS_NONE, SPELL_STATE_DELAYED, SPELL_STATE_FINISHED, TriggeredByAuraSpellData::spellInfo, sScriptMgr, sSpellMgr, Player::StartTimedAchievement(), TakeCastItem(), TakePower(), TakeReagents(), TARGET_FLAG_TRADE_ITEM, TARGET_FLAG_UNIT, Object::ToCreature(), Object::ToPlayer(), TRIGGERED_IGNORE_CAST_ITEM, TRIGGERED_IGNORE_POWER_AND_REAGENT_COST, TRIGGERED_IGNORE_SET_FACING, UNIT_STATE_CASTING, Player::UpdateAchievementCriteria(), UpdatePointers(), and SpellCastTargets::UpdateTradeSlotItem().

Referenced by cast().

◆ _handle_finish_phase()

void Spell::_handle_finish_phase ( )
4273{
4274 // Take for real after all targets are processed
4276 {
4278 }
4279
4280 // Real add combo points from effects
4282 {
4283 // remove Premed-like effects unless they were caused by ourselves
4284 // (this Aura removes the already-added CP when it expires from duration - now that we've added CP, this shouldn't happen anymore!)
4286 {
4288 }
4289
4291 }
4292
4294 {
4296 }
4297
4300 for (std::list<TargetInfo>::iterator ihit = m_UniqueTargetInfo.begin(); ihit != m_UniqueTargetInfo.end(); ++ihit)
4301 {
4302 // Xinef: Properly clear infinite cooldowns in some cases
4303 if (ihit->targetGUID == m_caster->GetGUID() && ihit->missCondition != SPELL_MISS_NONE)
4306 }
4307
4308 // Handle procs on finish
4309 if (m_originalCaster)
4310 {
4311 uint32 procAttacker = m_procAttacker;
4312 if (!procAttacker)
4313 {
4314 bool IsPositive = m_spellInfo->IsPositive();
4316 {
4318 }
4319 else
4320 {
4322 }
4323 }
4324
4325 uint32 procEx = PROC_EX_NORMAL_HIT;
4326 for (std::list<TargetInfo>::iterator ihit = m_UniqueTargetInfo.begin(); ihit != m_UniqueTargetInfo.end(); ++ihit)
4327 {
4328 if (ihit->missCondition != SPELL_MISS_NONE)
4329 {
4330 continue;
4331 }
4332
4333 if (!ihit->crit)
4334 {
4335 continue;
4336 }
4337
4338 procEx |= PROC_EX_CRITICAL_HIT;
4339 break;
4340 }
4341
4344 }
4345}
@ SPELL_AURA_RETAIN_COMBO_POINTS
Definition: SpellAuraDefines.h:211
@ PROC_SPELL_PHASE_FINISH
Definition: SpellMgr.h:245
@ SPELL_EFFECT_ADD_EXTRA_ATTACKS
Definition: SharedDefines.h:797
void SendCooldownEvent(SpellInfo const *spellInfo, uint32 itemId=0, Spell *spell=nullptr, bool setCooldown=true)
Definition: Player.cpp:11105
void SetLastExtraAttackSpell(uint32 spellId)
Definition: Unit.h:1017
Player * GetCharmerOrOwnerPlayerOrPlayerItself() const
Definition: Unit.cpp:10578
void ClearComboPoints()
Definition: Unit.cpp:16820
void AddComboPoints(Unit *target, int8 count)
Definition: Unit.cpp:16794
void RemoveAurasByType(AuraType auraType, ObjectGuid casterGUID=ObjectGuid::Empty, Aura *except=nullptr, bool negative=true, bool positive=true)
Definition: Unit.cpp:5081
bool IsAutoRepeat() const
Definition: Spell.h:548
bool IsNextMeleeSwingSpell() const
Definition: Spell.cpp:8057
bool IsCooldownStartedOnEvent() const
Definition: SpellInfo.cpp:1211

References Unit::AddComboPoints(), BASE_ATTACK, Unit::ClearComboPoints(), SpellInfo::DmgClass, TriggeredByAuraSpellData::effectIndex, Unit::GetCharmerOrOwnerPlayerOrPlayerItself(), Object::GetGUID(), SpellInfo::HasAura(), SpellInfo::HasEffect(), SpellInfo::Id, IsAutoRepeat(), SpellInfo::IsCooldownStartedOnEvent(), IsNextMeleeSwingSpell(), Object::IsPlayer(), SpellInfo::IsPositive(), m_caster, m_comboPointGain, m_comboTarget, m_needComboPoints, m_originalCaster, m_procAttacker, m_spellInfo, m_triggeredByAuraSpell, m_UniqueTargetInfo, PROC_EX_CRITICAL_HIT, PROC_EX_NORMAL_HIT, PROC_FLAG_DONE_SPELL_MAGIC_DMG_CLASS_NEG, PROC_FLAG_DONE_SPELL_MAGIC_DMG_CLASS_POS, PROC_FLAG_DONE_SPELL_NONE_DMG_CLASS_NEG, PROC_FLAG_DONE_SPELL_NONE_DMG_CLASS_POS, PROC_FLAG_NONE, PROC_SPELL_PHASE_FINISH, Unit::ProcDamageAndSpell(), Unit::RemoveAurasByType(), Player::SendCooldownEvent(), Unit::SetLastExtraAttackSpell(), SPELL_AURA_RETAIN_COMBO_POINTS, SPELL_DAMAGE_CLASS_MAGIC, SPELL_EFFECT_ADD_EXTRA_ATTACKS, SPELL_MISS_NONE, TriggeredByAuraSpellData::spellInfo, and Object::ToPlayer().

Referenced by handle_delayed(), and handle_immediate().

◆ _handle_immediate_phase()

void Spell::_handle_immediate_phase ( )
4245{
4246 m_spellAura = nullptr;
4247 // initialize Diminishing Returns Data
4250
4251 // handle some immediate features of the spell here
4253
4255
4256 // handle effects with SPELL_EFFECT_HANDLE_HIT mode
4257 for (uint32 j = 0; j < MAX_SPELL_EFFECTS; ++j)
4258 {
4259 // don't do anything for empty effect
4260 if (!m_spellInfo->Effects[j].IsEffect())
4261 continue;
4262
4263 // call effect handlers to handle destination hit
4264 HandleEffects(nullptr, nullptr, nullptr, j, SPELL_EFFECT_HANDLE_HIT);
4265 }
4266
4267 // process items
4268 for (std::list<ItemTargetInfo>::iterator ihit = m_UniqueItemInfo.begin(); ihit != m_UniqueItemInfo.end(); ++ihit)
4269 DoAllEffectOnTarget(&(*ihit));
4270}
@ SPELL_EFFECT_HANDLE_HIT
Definition: Spell.h:235
void HandleThreatSpells()
Definition: Spell.cpp:5572
void HandleEffects(Unit *pUnitTarget, Item *pItemTarget, GameObject *pGOTarget, uint32 i, SpellEffectHandleMode mode)
Definition: Spell.cpp:5619
std::list< ItemTargetInfo > m_UniqueItemInfo
Definition: Spell.h:699
void DoAllEffectOnTarget(TargetInfo *target)
Definition: Spell.cpp:2610
std::array< SpellEffectInfo, MAX_SPELL_EFFECTS > Effects
Definition: SpellInfo.h:393

References DIMINISHING_LEVEL_1, DIMINISHING_NONE, DoAllEffectOnTarget(), SpellInfo::Effects, HandleEffects(), HandleThreatSpells(), m_diminishGroup, m_diminishLevel, m_spellAura, m_spellInfo, m_UniqueItemInfo, MAX_SPELL_EFFECTS, PrepareScriptHitHandlers(), and SPELL_EFFECT_HANDLE_HIT.

Referenced by handle_delayed(), and handle_immediate().

◆ AddComboPointGain()

void Spell::AddComboPointGain ( Unit target,
int8  amount 
)
inline
531 {
532 if (target != m_comboTarget)
533 {
534 m_comboTarget = target;
535 m_comboPointGain = amount;
536 }
537 else
538 {
539 m_comboPointGain += amount;
540 }
541 }

References m_comboPointGain, and m_comboTarget.

Referenced by EffectAddComboPoints(), and EffectWeaponDmg().

◆ AddDestTarget()

void Spell::AddDestTarget ( SpellDestination const &  dest,
uint32  effIndex 
)
protected
2606{
2607 m_destTargets[effIndex] = dest;
2608}

References m_destTargets.

Referenced by SelectSpellTargets().

◆ AddGOTarget()

void Spell::AddGOTarget ( GameObject target,
uint32  effectMask 
)
protected
2515{
2516 for (uint32 effIndex = 0; effIndex < MAX_SPELL_EFFECTS; ++effIndex)
2517 {
2518 if (!m_spellInfo->Effects[effIndex].IsEffect())
2519 effectMask &= ~(1 << effIndex);
2520 else
2521 {
2522 switch (m_spellInfo->Effects[effIndex].Effect)
2523 {
2527 if (go->GetGoType() != GAMEOBJECT_TYPE_DESTRUCTIBLE_BUILDING)
2528 effectMask &= ~(1 << effIndex);
2529 break;
2530 default:
2531 break;
2532 }
2533 }
2534 }
2535
2536 if (!effectMask)
2537 return;
2538
2539 ObjectGuid targetGUID = go->GetGUID();
2540
2541 // Lookup target in already in list
2542 for (std::list<GOTargetInfo>::iterator ihit = m_UniqueGOTargetInfo.begin(); ihit != m_UniqueGOTargetInfo.end(); ++ihit)
2543 {
2544 if (targetGUID == ihit->targetGUID) // Found in list
2545 {
2546 ihit->effectMask |= effectMask; // Add only effect mask
2547 return;
2548 }
2549 }
2550
2551 // This is new target calculate data for him
2552
2553 GOTargetInfo target;
2554 target.targetGUID = targetGUID;
2555 target.effectMask = effectMask;
2556 target.processed = false; // Effects not apply on target
2557
2558 // Spell have speed - need calculate incoming time
2559 if (m_spellInfo->Speed > 0.0f)
2560 {
2561 // calculate spell incoming interval
2562 float dist = m_caster->GetDistance(go->GetPositionX(), go->GetPositionY(), go->GetPositionZ());
2563 if (dist < 5.0f)
2564 dist = 5.0f;
2565 target.timeDelay = uint64(std::floor(dist / m_spellInfo->Speed * 1000.0f));
2566 if (m_delayMoment == 0 || m_delayMoment > target.timeDelay)
2567 m_delayMoment = target.timeDelay;
2568 }
2569 else
2570 target.timeDelay = 0LL;
2571
2572 // Add target to list
2573 m_UniqueGOTargetInfo.push_back(target);
2574}
std::uint64_t uint64
Definition: Define.h:106
@ GAMEOBJECT_TYPE_DESTRUCTIBLE_BUILDING
Definition: SharedDefines.h:1593
@ SPELL_EFFECT_GAMEOBJECT_REPAIR
Definition: SharedDefines.h:866
@ SPELL_EFFECT_GAMEOBJECT_SET_DESTRUCTION_STATE
Definition: SharedDefines.h:867
@ SPELL_EFFECT_GAMEOBJECT_DAMAGE
Definition: SharedDefines.h:865
float GetDistance(WorldObject const *obj) const
Definition: Object.cpp:1245
Definition: ObjectGuid.h:118
uint64 m_delayMoment
Definition: Spell.h:639
std::list< GOTargetInfo > m_UniqueGOTargetInfo
Definition: Spell.h:692

References Spell::GOTargetInfo::effectMask, SpellInfo::Effects, GAMEOBJECT_TYPE_DESTRUCTIBLE_BUILDING, WorldObject::GetDistance(), GameObject::GetGoType(), Object::GetGUID(), Position::GetPositionX(), Position::GetPositionY(), Position::GetPositionZ(), m_caster, m_delayMoment, m_spellInfo, m_UniqueGOTargetInfo, MAX_SPELL_EFFECTS, Spell::GOTargetInfo::processed, SpellInfo::Speed, SPELL_EFFECT_GAMEOBJECT_DAMAGE, SPELL_EFFECT_GAMEOBJECT_REPAIR, SPELL_EFFECT_GAMEOBJECT_SET_DESTRUCTION_STATE, Spell::GOTargetInfo::targetGUID, and Spell::GOTargetInfo::timeDelay.

Referenced by SelectEffectTypeImplicitTargets(), SelectImplicitAreaTargets(), SelectImplicitConeTargets(), SelectImplicitNearbyTargets(), and SelectImplicitTargetObjectTargets().

◆ AddItemTarget()

void Spell::AddItemTarget ( Item item,
uint32  effectMask 
)
protected
2577{
2578 for (uint32 effIndex = 0; effIndex < MAX_SPELL_EFFECTS; ++effIndex)
2579 if (!m_spellInfo->Effects[effIndex].IsEffect())
2580 effectMask &= ~(1 << effIndex);
2581
2582 // no effects left
2583 if (!effectMask)
2584 return;
2585
2586 // Lookup target in already in list
2587 for (std::list<ItemTargetInfo>::iterator ihit = m_UniqueItemInfo.begin(); ihit != m_UniqueItemInfo.end(); ++ihit)
2588 {
2589 if (item == ihit->item) // Found in list
2590 {
2591 ihit->effectMask |= effectMask; // Add only effect mask
2592 return;
2593 }
2594 }
2595
2596 // This is new target add data
2597
2598 ItemTargetInfo target;
2599 target.item = item;
2600 target.effectMask = effectMask;
2601
2602 m_UniqueItemInfo.push_back(target);
2603}

References Spell::ItemTargetInfo::effectMask, SpellInfo::Effects, Spell::ItemTargetInfo::item, m_spellInfo, m_UniqueItemInfo, and MAX_SPELL_EFFECTS.

Referenced by SelectEffectTypeImplicitTargets(), and SelectImplicitTargetObjectTargets().

◆ AddUnitTarget()

void Spell::AddUnitTarget ( Unit target,
uint32  effectMask,
bool  checkIfValid = true,
bool  implicit = true 
)
protected
Todo:
: this is a hack
Todo:
: seduction should be casted only on humanoids (not demons)
2382{
2383 for (uint32 effIndex = 0; effIndex < MAX_SPELL_EFFECTS; ++effIndex)
2384 if (!m_spellInfo->Effects[effIndex].IsEffect() || !CheckEffectTarget(target, effIndex))
2385 effectMask &= ~(1 << effIndex);
2386
2387 // no effects left
2388 if (!effectMask)
2389 return;
2390
2391 if (checkIfValid)
2392 {
2393 SpellCastResult res = m_spellInfo->CheckTarget(m_caster, target, implicit);
2394 if (res != SPELL_CAST_OK)
2395 return;
2396 }
2397
2398 // Check for effect immune skip if immuned
2399 for (uint32 effIndex = 0; effIndex < MAX_SPELL_EFFECTS; ++effIndex)
2400 if (target->IsImmunedToSpellEffect(m_spellInfo, effIndex))
2401 effectMask &= ~(1 << effIndex);
2402
2403 ObjectGuid targetGUID = target->GetGUID();
2404
2405 // Lookup target in already in list
2406 for (std::list<TargetInfo>::iterator ihit = m_UniqueTargetInfo.begin(); ihit != m_UniqueTargetInfo.end(); ++ihit)
2407 {
2408 if (targetGUID == ihit->targetGUID) // Found in list
2409 {
2410 ihit->effectMask |= effectMask; // Immune effects removed from mask
2411 ihit->scaleAura = false;
2412 if (m_auraScaleMask && ihit->effectMask == m_auraScaleMask && m_caster != target)
2413 {
2414 SpellInfo const* auraSpell = m_spellInfo->GetFirstRankSpell();
2415 if (uint32(target->GetLevel() + 10) >= auraSpell->SpellLevel)
2416 ihit->scaleAura = true;
2417 }
2418
2419 sScriptMgr->OnScaleAuraUnitAdd(this, target, effectMask, checkIfValid, implicit, m_auraScaleMask, *ihit);
2420 return;
2421 }
2422 }
2423
2424 // This is new target calculate data for him
2425
2426 // Get spell hit result on target
2427 TargetInfo targetInfo;
2428 targetInfo.targetGUID = targetGUID; // Store target GUID
2429 targetInfo.effectMask = effectMask; // Store all effects not immune
2430 targetInfo.processed = false; // Effects not apply on target
2431 targetInfo.alive = target->IsAlive();
2432 targetInfo.damage = 0;
2433 targetInfo.crit = false;
2434 targetInfo.scaleAura = false;
2435 if (m_auraScaleMask && targetInfo.effectMask == m_auraScaleMask && m_caster != target)
2436 {
2437 SpellInfo const* auraSpell = m_spellInfo->GetFirstRankSpell();
2438 if (uint32(target->GetLevel() + 10) >= auraSpell->SpellLevel)
2439 targetInfo.scaleAura = true;
2440 }
2441
2442 sScriptMgr->OnScaleAuraUnitAdd(this, target, effectMask, checkIfValid, implicit, m_auraScaleMask, targetInfo);
2443
2444 // Calculate hit result
2445 if (m_originalCaster)
2446 {
2447 targetInfo.missCondition = m_originalCaster->SpellHitResult(target, this, m_canReflect);
2448 if (m_skipCheck && targetInfo.missCondition != SPELL_MISS_IMMUNE)
2449 {
2450 targetInfo.missCondition = SPELL_MISS_NONE;
2451 }
2452 }
2453 else
2454 targetInfo.missCondition = SPELL_MISS_EVADE; //SPELL_MISS_NONE;
2455
2456 // Spell have speed - need calculate incoming time
2457 // Incoming time is zero for self casts. At least I think so.
2458 if (m_spellInfo->Speed > 0.0f && m_caster != target)
2459 {
2460 // calculate spell incoming interval
2462 float dist = m_caster->GetDistance(target->GetPositionX(), target->GetPositionY(), target->GetPositionZ());
2463
2464 if (dist < 5.0f)
2465 dist = 5.0f;
2466 targetInfo.timeDelay = (uint64) std::floor(dist / m_spellInfo->Speed * 1000.0f);
2467
2468 // Calculate minimum incoming time
2469 if (m_delayMoment == 0 || m_delayMoment > targetInfo.timeDelay)
2470 m_delayMoment = targetInfo.timeDelay;
2471 }
2472 else
2473 targetInfo.timeDelay = 0LL;
2474
2475 // If target reflect spell back to caster
2476 if (targetInfo.missCondition == SPELL_MISS_REFLECT)
2477 {
2478 // Calculate reflected spell result on caster
2480
2481 if (targetInfo.reflectResult == SPELL_MISS_REFLECT) // Impossible reflect again, so simply deflect spell
2482 targetInfo.reflectResult = SPELL_MISS_PARRY;
2483
2484 // Increase time interval for reflected spells by 1.5
2486 targetInfo.timeDelay += targetInfo.timeDelay >> 1;
2487
2489
2490 // HACK: workaround check for succubus seduction case
2492 if (m_caster->IsPet())
2493 {
2494 CreatureTemplate const* ci = sObjectMgr->GetCreatureTemplate(m_caster->GetEntry());
2495 switch (ci->family)
2496 {
2498 {
2499 if (m_spellInfo->SpellIconID != 694) // Soothing Kiss
2500 cancel();
2501 }
2502 break;
2503 return;
2504 }
2505 }
2506 }
2507 else
2508 targetInfo.reflectResult = SPELL_MISS_NONE;
2509
2510 // Add target to list
2511 m_UniqueTargetInfo.push_back(targetInfo);
2512}
#define sObjectMgr
Definition: ObjectMgr.h:1623
@ SPELL_FLAG_REFLECTED
Definition: Spell.h:82
@ CREATURE_FAMILY_SUCCUBUS
Definition: SharedDefines.h:2664
@ SPELL_MISS_PARRY
Definition: SharedDefines.h:1523
@ SPELL_MISS_IMMUNE
Definition: SharedDefines.h:1526
@ SPELL_MISS_EVADE
Definition: SharedDefines.h:1525
@ SPELL_MISS_REFLECT
Definition: SharedDefines.h:1530
void AddEvent(BasicEvent *Event, uint64 e_time, bool set_addtime=true)
Definition: EventProcessor.h:103
uint64 CalculateTime(uint64 t_offset) const
Definition: EventProcessor.cpp:159
Definition: CreatureData.h:189
uint32 family
Definition: CreatureData.h:220
float GetPositionZ() const
Definition: Position.h:119
float GetPositionX() const
Definition: Position.h:117
float GetPositionY() const
Definition: Position.h:118
bool IsAlive() const
Definition: Unit.h:1204
SpellMissInfo SpellHitResult(Unit *victim, SpellInfo const *spell, bool canReflect=false)
Definition: Unit.cpp:3454
EventProcessor m_Events
Definition: Unit.h:1792
virtual bool IsImmunedToSpellEffect(SpellInfo const *spellInfo, uint32 index) const
Definition: Unit.cpp:12963
uint8 GetLevel() const
Definition: Unit.h:855
Definition: Spell.h:254
bool processed
Definition: Spell.h:260
int32 damage
Definition: Spell.h:264
SpellMissInfo missCondition
Definition: Spell.h:257
bool scaleAura
Definition: Spell.h:263
bool crit
Definition: Spell.h:262
uint64 timeDelay
Definition: Spell.h:256
ObjectGuid targetGUID
Definition: Spell.h:255
SpellMissInfo reflectResult
Definition: Spell.h:258
bool alive
Definition: Spell.h:261
uint8 effectMask
Definition: Spell.h:259
bool CheckEffectTarget(Unit const *target, uint32 eff) const
Definition: Spell.cpp:7915
Definition: Spell.h:846
Definition: SpellInfo.h:316
uint32 SpellLevel
Definition: SpellInfo.h:360
SpellInfo const * GetFirstRankSpell() const
Definition: SpellInfo.cpp:2500
uint32 SpellIconID
Definition: SpellInfo.h:380
SpellCastResult CheckTarget(Unit const *caster, WorldObject const *target, bool implicit=true) const
Definition: SpellInfo.cpp:1758

References EventProcessor::AddEvent(), TargetInfo::alive, EventProcessor::CalculateTime(), cancel(), CheckEffectTarget(), SpellInfo::CheckTarget(), CREATURE_FAMILY_SUCCUBUS, TargetInfo::crit, TargetInfo::damage, TargetInfo::effectMask, SpellInfo::Effects, CreatureTemplate::family, WorldObject::GetDistance(), Object::GetEntry(), SpellInfo::GetFirstRankSpell(), Object::GetGUID(), Unit::GetLevel(), Position::GetPositionX(), Position::GetPositionY(), Position::GetPositionZ(), Unit::IsAlive(), Unit::IsImmunedToSpellEffect(), Unit::IsPet(), m_auraScaleMask, m_canReflect, m_caster, m_delayMoment, Unit::m_Events, m_originalCaster, m_skipCheck, m_spellFlags, m_spellInfo, m_UniqueTargetInfo, MAX_SPELL_EFFECTS, TargetInfo::missCondition, TargetInfo::processed, TargetInfo::reflectResult, TargetInfo::scaleAura, sObjectMgr, SpellInfo::Speed, SPELL_CAST_OK, SPELL_FLAG_REFLECTED, SPELL_MISS_EVADE, SPELL_MISS_IMMUNE, SPELL_MISS_NONE, SPELL_MISS_PARRY, SPELL_MISS_REFLECT, Unit::SpellHitResult(), SpellInfo::SpellIconID, SpellInfo::SpellLevel, sScriptMgr, TargetInfo::targetGUID, and TargetInfo::timeDelay.

Referenced by SelectEffectTypeImplicitTargets(), SelectImplicitAreaTargets(), SelectImplicitCasterObjectTargets(), SelectImplicitChainTargets(), SelectImplicitChannelTargets(), SelectImplicitConeTargets(), SelectImplicitNearbyTargets(), and SelectImplicitTargetObjectTargets().

◆ CalculateDelayMomentForDst()

uint64 Spell::CalculateDelayMomentForDst ( ) const
897{
898 if (m_targets.HasDst())
899 {
900 if (m_targets.HasTraj())
901 {
902 float speed = m_targets.GetSpeedXY();
903 if (speed > 0.0f)
904 return (uint64)std::floor(m_targets.GetDist2d() / speed * 1000.0f);
905 }
906 else if (m_spellInfo->Speed > 0.0f)
907 {
908 // We should not subtract caster size from dist calculation (fixes execution time desync with animation on client, eg. Malleable Goo cast by PP)
909 float dist = m_caster->GetExactDist(*m_targets.GetDstPos());
910 return (uint64)std::floor(dist / m_spellInfo->Speed * 1000.0f);
911 }
912 }
913
914 return 0;
915}
float GetExactDist(float x, float y, float z) const
Definition: Position.h:178
bool HasTraj() const
Definition: Spell.h:166
bool HasDst() const
Definition: Spell.h:165
float GetSpeedXY() const
Definition: Spell.h:174
float GetDist2d() const
Definition: Spell.h:173
WorldLocation const * GetDstPos() const
Definition: Spell.cpp:402

References SpellCastTargets::GetDist2d(), SpellCastTargets::GetDstPos(), Position::GetExactDist(), SpellCastTargets::GetSpeedXY(), SpellCastTargets::HasDst(), SpellCastTargets::HasTraj(), m_caster, m_spellInfo, m_targets, and SpellInfo::Speed.

Referenced by RecalculateDelayMomentForDst(), and SelectSpellTargets().

◆ CalculateJumpSpeeds()

void Spell::CalculateJumpSpeeds ( uint8  i,
float  dist,
float &  speedxy,
float &  speedz 
)
protected
1158{
1159 if (m_spellInfo->Effects[i].MiscValue)
1160 speedZ = float(m_spellInfo->Effects[i].MiscValue) / 10;
1161 else if (m_spellInfo->Effects[i].MiscValueB)
1162 speedZ = float(m_spellInfo->Effects[i].MiscValueB) / 10;
1163 else
1164 speedZ = 10.0f;
1165 speedXY = dist * 10.0f / speedZ;
1166}

References SpellInfo::Effects, and m_spellInfo.

Referenced by EffectJump(), and EffectJumpDest().

◆ CalculateSpellDamage()

int32 Spell::CalculateSpellDamage ( uint8  i,
Unit const *  target 
) const
inline
int32 CalculateSpellDamage(Unit const *target, SpellInfo const *spellProto, uint8 effect_index, int32 const *basePoints=nullptr) const
Definition: Unit.cpp:14806
int32 EffectBasePoints[MAX_SPELL_EFFECTS]
Definition: Spell.h:213

References Unit::CalculateSpellDamage(), SpellValue::EffectBasePoints, m_caster, m_spellInfo, and m_spellValue.

Referenced by CheckCast(), CheckEffectTarget(), EffectWeaponDmg(), and HandleEffects().

◆ CallScriptAfterCastHandlers()

void Spell::CallScriptAfterCastHandlers ( )
protected
8537{
8538 for (std::list<SpellScript*>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
8539 {
8540 (*scritr)->_PrepareScriptCall(SPELL_SCRIPT_HOOK_AFTER_CAST);
8541 std::list<SpellScript::CastHandler>::iterator hookItrEnd = (*scritr)->AfterCast.end(), hookItr = (*scritr)->AfterCast.begin();
8542 for (; hookItr != hookItrEnd; ++hookItr)
8543 (*hookItr).Call(*scritr);
8544
8545 (*scritr)->_FinishScriptCall();
8546 }
8547}
@ SPELL_SCRIPT_HOOK_AFTER_CAST
Definition: SpellScript.h:172

References m_loadedScripts, and SPELL_SCRIPT_HOOK_AFTER_CAST.

Referenced by _cast().

◆ CallScriptAfterHitHandlers()

void Spell::CallScriptAfterHitHandlers ( )
protected
8649{
8650 for (std::list<SpellScript*>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
8651 {
8652 (*scritr)->_PrepareScriptCall(SPELL_SCRIPT_HOOK_AFTER_HIT);
8653 std::list<SpellScript::HitHandler>::iterator hookItrEnd = (*scritr)->AfterHit.end(), hookItr = (*scritr)->AfterHit.begin();
8654 for (; hookItr != hookItrEnd; ++hookItr)
8655 (*hookItr).Call(*scritr);
8656
8657 (*scritr)->_FinishScriptCall();
8658 }
8659}
@ SPELL_SCRIPT_HOOK_AFTER_HIT
Definition: SpellScript.h:165

References m_loadedScripts, and SPELL_SCRIPT_HOOK_AFTER_HIT.

Referenced by DoAllEffectOnTarget().

◆ CallScriptBeforeCastHandlers()

void Spell::CallScriptBeforeCastHandlers ( )
protected
8511{
8512 for (std::list<SpellScript*>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
8513 {
8514 (*scritr)->_PrepareScriptCall(SPELL_SCRIPT_HOOK_BEFORE_CAST);
8515 std::list<SpellScript::CastHandler>::iterator hookItrEnd = (*scritr)->BeforeCast.end(), hookItr = (*scritr)->BeforeCast.begin();
8516 for (; hookItr != hookItrEnd; ++hookItr)
8517 (*hookItr).Call(*scritr);
8518
8519 (*scritr)->_FinishScriptCall();
8520 }
8521}
@ SPELL_SCRIPT_HOOK_BEFORE_CAST
Definition: SpellScript.h:170

References m_loadedScripts, and SPELL_SCRIPT_HOOK_BEFORE_CAST.

Referenced by _cast().

◆ CallScriptBeforeHitHandlers()

void Spell::CallScriptBeforeHitHandlers ( SpellMissInfo  missInfo)
protected
8623{
8624 for (std::list<SpellScript*>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
8625 {
8626 (*scritr)->_PrepareScriptCall(SPELL_SCRIPT_HOOK_BEFORE_HIT);
8627 std::list<SpellScript::BeforeHitHandler>::iterator hookItrEnd = (*scritr)->BeforeHit.end(), hookItr = (*scritr)->BeforeHit.begin();
8628 for (; hookItr != hookItrEnd; ++hookItr)
8629 (*hookItr).Call(*scritr, missInfo);
8630
8631 (*scritr)->_FinishScriptCall();
8632 }
8633}
@ SPELL_SCRIPT_HOOK_BEFORE_HIT
Definition: SpellScript.h:163

References m_loadedScripts, and SPELL_SCRIPT_HOOK_BEFORE_HIT.

Referenced by DoAllEffectOnTarget().

◆ CallScriptCheckCastHandlers()

SpellCastResult Spell::CallScriptCheckCastHandlers ( )
protected
8550{
8552 for (std::list<SpellScript*>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
8553 {
8554 (*scritr)->_PrepareScriptCall(SPELL_SCRIPT_HOOK_CHECK_CAST);
8555 std::list<SpellScript::CheckCastHandler>::iterator hookItrEnd = (*scritr)->OnCheckCast.end(), hookItr = (*scritr)->OnCheckCast.begin();
8556 for (; hookItr != hookItrEnd; ++hookItr)
8557 {
8558 SpellCastResult tempResult = (*hookItr).Call(*scritr);
8559 if (retVal == SPELL_CAST_OK)
8560 retVal = tempResult;
8561 }
8562
8563 (*scritr)->_FinishScriptCall();
8564 }
8565 return retVal;
8566}
@ SPELL_SCRIPT_HOOK_CHECK_CAST
Definition: SpellScript.h:169

References m_loadedScripts, SPELL_CAST_OK, and SPELL_SCRIPT_HOOK_CHECK_CAST.

Referenced by CheckCast().

◆ CallScriptDestinationTargetSelectHandlers()

void Spell::CallScriptDestinationTargetSelectHandlers ( SpellDestination target,
SpellEffIndex  effIndex,
SpellImplicitTargetInfo const &  targetType 
)
protected
8690{
8691 for (std::list<SpellScript*>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
8692 {
8693 (*scritr)->_PrepareScriptCall(SPELL_SCRIPT_HOOK_DESTINATION_TARGET_SELECT);
8694 std::list<SpellScript::DestinationTargetSelectHandler>::iterator hookItrEnd = (*scritr)->OnDestinationTargetSelect.end(), hookItr = (*scritr)->OnDestinationTargetSelect.begin();
8695 for (; hookItr != hookItrEnd; ++hookItr)
8696 if (hookItr->IsEffectAffected(m_spellInfo, effIndex) && targetType.GetTarget() == hookItr->GetTarget())
8697 hookItr->Call(*scritr, target);
8698
8699 (*scritr)->_FinishScriptCall();
8700 }
8701}
@ SPELL_SCRIPT_HOOK_DESTINATION_TARGET_SELECT
Definition: SpellScript.h:168

References SpellImplicitTargetInfo::GetTarget(), m_loadedScripts, m_spellInfo, and SPELL_SCRIPT_HOOK_DESTINATION_TARGET_SELECT.

Referenced by SelectImplicitCasterDestTargets(), SelectImplicitDestDestTargets(), SelectImplicitTargetDestTargets(), and SelectImplicitTrajTargets().

◆ CallScriptEffectHandlers()

bool Spell::CallScriptEffectHandlers ( SpellEffIndex  effIndex,
SpellEffectHandleMode  mode 
)
protected
8575{
8576 // execute script effect handler hooks and check if effects was prevented
8577 bool preventDefault = false;
8578 for (std::list<SpellScript*>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
8579 {
8580 std::list<SpellScript::EffectHandler>::iterator effItr, effEndItr;
8581 SpellScriptHookType hookType;
8582 switch (mode)
8583 {
8585 effItr = (*scritr)->OnEffectLaunch.begin();
8586 effEndItr = (*scritr)->OnEffectLaunch.end();
8588 break;
8590 effItr = (*scritr)->OnEffectLaunchTarget.begin();
8591 effEndItr = (*scritr)->OnEffectLaunchTarget.end();
8593 break;
8595 effItr = (*scritr)->OnEffectHit.begin();
8596 effEndItr = (*scritr)->OnEffectHit.end();
8598 break;
8600 effItr = (*scritr)->OnEffectHitTarget.begin();
8601 effEndItr = (*scritr)->OnEffectHitTarget.end();
8603 break;
8604 default:
8605 ABORT();
8606 return false;
8607 }
8608 (*scritr)->_PrepareScriptCall(hookType);
8609 for (; effItr != effEndItr; ++effItr)
8610 // effect execution can be prevented
8611 if (!(*scritr)->_IsEffectPrevented(effIndex) && (*effItr).IsEffectAffected(m_spellInfo, effIndex))
8612 (*effItr).Call(*scritr, effIndex);
8613
8614 if (!preventDefault)
8615 preventDefault = (*scritr)->_IsDefaultEffectPrevented(effIndex);
8616
8617 (*scritr)->_FinishScriptCall();
8618 }
8619 return preventDefault;
8620}
#define ABORT
Definition: Errors.h:76
@ SPELL_EFFECT_HANDLE_LAUNCH_TARGET
Definition: Spell.h:234
@ SPELL_EFFECT_HANDLE_HIT_TARGET
Definition: Spell.h:236
SpellScriptHookType
Definition: SpellScript.h:158
@ SPELL_SCRIPT_HOOK_EFFECT_HIT
Definition: SpellScript.h:161
@ SPELL_SCRIPT_HOOK_EFFECT_LAUNCH
Definition: SpellScript.h:159
@ SPELL_SCRIPT_HOOK_EFFECT_LAUNCH_TARGET
Definition: SpellScript.h:160
@ SPELL_SCRIPT_HOOK_EFFECT_HIT_TARGET
Definition: SpellScript.h:162

References ABORT, m_loadedScripts, m_spellInfo, SPELL_EFFECT_HANDLE_HIT, SPELL_EFFECT_HANDLE_HIT_TARGET, SPELL_EFFECT_HANDLE_LAUNCH, SPELL_EFFECT_HANDLE_LAUNCH_TARGET, SPELL_SCRIPT_HOOK_EFFECT_HIT, SPELL_SCRIPT_HOOK_EFFECT_HIT_TARGET, SPELL_SCRIPT_HOOK_EFFECT_LAUNCH, and SPELL_SCRIPT_HOOK_EFFECT_LAUNCH_TARGET.

Referenced by HandleEffects().

◆ CallScriptObjectAreaTargetSelectHandlers()

void Spell::CallScriptObjectAreaTargetSelectHandlers ( std::list< WorldObject * > &  targets,
SpellEffIndex  effIndex,
SpellImplicitTargetInfo const &  targetType 
)
protected
8662{
8663 for (std::list<SpellScript*>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
8664 {
8665 (*scritr)->_PrepareScriptCall(SPELL_SCRIPT_HOOK_OBJECT_AREA_TARGET_SELECT);
8666 std::list<SpellScript::ObjectAreaTargetSelectHandler>::iterator hookItrEnd = (*scritr)->OnObjectAreaTargetSelect.end(), hookItr = (*scritr)->OnObjectAreaTargetSelect.begin();
8667 for (; hookItr != hookItrEnd; ++hookItr)
8668 if (hookItr->IsEffectAffected(m_spellInfo, effIndex) && targetType.GetTarget() == hookItr->GetTarget())
8669 hookItr->Call(*scritr, targets);
8670
8671 (*scritr)->_FinishScriptCall();
8672 }
8673}
@ SPELL_SCRIPT_HOOK_OBJECT_AREA_TARGET_SELECT
Definition: SpellScript.h:166

References SpellImplicitTargetInfo::GetTarget(), m_loadedScripts, m_spellInfo, and SPELL_SCRIPT_HOOK_OBJECT_AREA_TARGET_SELECT.

Referenced by SelectImplicitAreaTargets(), SelectImplicitChainTargets(), and SelectImplicitConeTargets().

◆ CallScriptObjectTargetSelectHandlers()

void Spell::CallScriptObjectTargetSelectHandlers ( WorldObject *&  target,
SpellEffIndex  effIndex,
SpellImplicitTargetInfo const &  targetType 
)
protected
8676{
8677 for (std::list<SpellScript*>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
8678 {
8679 (*scritr)->_PrepareScriptCall(SPELL_SCRIPT_HOOK_OBJECT_TARGET_SELECT);
8680 std::list<SpellScript::ObjectTargetSelectHandler>::iterator hookItrEnd = (*scritr)->OnObjectTargetSelect.end(), hookItr = (*scritr)->OnObjectTargetSelect.begin();
8681 for (; hookItr != hookItrEnd; ++hookItr)
8682 if (hookItr->IsEffectAffected(m_spellInfo, effIndex) && targetType.GetTarget() == hookItr->GetTarget())
8683 hookItr->Call(*scritr, target);
8684
8685 (*scritr)->_FinishScriptCall();
8686 }
8687}
@ SPELL_SCRIPT_HOOK_OBJECT_TARGET_SELECT
Definition: SpellScript.h:167

References SpellImplicitTargetInfo::GetTarget(), m_loadedScripts, m_spellInfo, and SPELL_SCRIPT_HOOK_OBJECT_TARGET_SELECT.

Referenced by SelectEffectTypeImplicitTargets(), SelectImplicitCasterObjectTargets(), SelectImplicitChannelTargets(), SelectImplicitNearbyTargets(), and SelectImplicitTargetObjectTargets().

◆ CallScriptOnCastHandlers()

void Spell::CallScriptOnCastHandlers ( )
protected
8524{
8525 for (std::list<SpellScript*>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
8526 {
8527 (*scritr)->_PrepareScriptCall(SPELL_SCRIPT_HOOK_ON_CAST);
8528 std::list<SpellScript::CastHandler>::iterator hookItrEnd = (*scritr)->OnCast.end(), hookItr = (*scritr)->OnCast.begin();
8529 for (; hookItr != hookItrEnd; ++hookItr)
8530 (*hookItr).Call(*scritr);
8531
8532 (*scritr)->_FinishScriptCall();
8533 }
8534}
@ SPELL_SCRIPT_HOOK_ON_CAST
Definition: SpellScript.h:171

References m_loadedScripts, and SPELL_SCRIPT_HOOK_ON_CAST.

Referenced by _cast().

◆ CallScriptOnHitHandlers()

void Spell::CallScriptOnHitHandlers ( )
protected
8636{
8637 for (std::list<SpellScript*>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
8638 {
8639 (*scritr)->_PrepareScriptCall(SPELL_SCRIPT_HOOK_HIT);
8640 std::list<SpellScript::HitHandler>::iterator hookItrEnd = (*scritr)->OnHit.end(), hookItr = (*scritr)->OnHit.begin();
8641 for (; hookItr != hookItrEnd; ++hookItr)
8642 (*hookItr).Call(*scritr);
8643
8644 (*scritr)->_FinishScriptCall();
8645 }
8646}
@ SPELL_SCRIPT_HOOK_HIT
Definition: SpellScript.h:164

References m_loadedScripts, and SPELL_SCRIPT_HOOK_HIT.

Referenced by DoAllEffectOnTarget().

◆ CanAutoCast()

bool Spell::CanAutoCast ( Unit target)
7000{
7001 ObjectGuid targetguid = target->GetGUID();
7002
7003 for (uint32 j = 0; j < MAX_SPELL_EFFECTS; ++j)
7004 {
7006 {
7007 if (m_spellInfo->StackAmount <= 1)
7008 {
7009 if (target->HasAuraEffect(m_spellInfo->Id, j))
7010 return false;
7011 }
7012 else
7013 {
7014 if (AuraEffect* aureff = target->GetAuraEffect(m_spellInfo->Id, j))
7015 if (aureff->GetBase()->GetStackAmount() >= m_spellInfo->StackAmount)
7016 return false;
7017 }
7018 }
7019 else if (m_spellInfo->Effects[j].IsAreaAuraEffect())
7020 {
7021 if (target->HasAuraEffect(m_spellInfo->Id, j))
7022 return false;
7023 }
7024 }
7025
7026 SpellCastResult result = CheckPetCast(target);
7027
7028 if (result == SPELL_CAST_OK || result == SPELL_FAILED_UNIT_NOT_INFRONT)
7029 {
7031 //check if among target units, our WANTED target is as well (->only self cast spells return false)
7032 for (std::list<TargetInfo>::iterator ihit = m_UniqueTargetInfo.begin(); ihit != m_UniqueTargetInfo.end(); ++ihit)
7033 if (ihit->targetGUID == targetguid)
7034 return true;
7035 }
7036 return false; //target invalid
7037}
@ SPELL_EFFECT_APPLY_AURA
Definition: SharedDefines.h:784
@ SPELL_FAILED_UNIT_NOT_INFRONT
Definition: SharedDefines.h:1083
AuraEffect * GetAuraEffect(uint32 spellId, uint8 effIndex, ObjectGuid casterGUID=ObjectGuid::Empty) const
Definition: Unit.cpp:5465
bool HasAuraEffect(uint32 spellId, uint8 effIndex, ObjectGuid caster=ObjectGuid::Empty) const
Definition: Unit.cpp:5639
Definition: SpellAuraEffects.h:39
SpellCastResult CheckPetCast(Unit *target)
Definition: Spell.cpp:6806
uint32 StackAmount
Definition: SpellInfo.h:371

References CheckPetCast(), SpellInfo::Effects, Unit::GetAuraEffect(), Object::GetGUID(), Unit::HasAuraEffect(), SpellInfo::Id, m_spellInfo, m_UniqueTargetInfo, MAX_SPELL_EFFECTS, SelectSpellTargets(), SPELL_CAST_OK, SPELL_EFFECT_APPLY_AURA, SPELL_FAILED_UNIT_NOT_INFRONT, and SpellInfo::StackAmount.

Referenced by PetAI::UpdateAI().

◆ cancel()

void Spell::cancel ( bool  bySelf = false)
3713{
3715 return;
3716
3717 uint32 oldState = m_spellState;
3719
3720 m_autoRepeat = false;
3721 switch (oldState)
3722 {
3726
3727 if (m_caster->IsPlayer())
3728 {
3730 ArenaSpectator::SendCommand_Spell(m_caster->FindMap(), m_caster->GetGUID(), "SPE", m_spellInfo->Id, bySelf ? 99998 : 99999);
3731 }
3732 [[fallthrough]];
3735 break;
3737 if (!bySelf)
3738 {
3739 for (std::list<TargetInfo>::const_iterator ihit = m_UniqueTargetInfo.begin(); ihit != m_UniqueTargetInfo.end(); ++ihit)
3740 if ((*ihit).missCondition == SPELL_MISS_NONE)
3741 if (Unit* unit = m_caster->GetGUID() == ihit->targetGUID ? m_caster : ObjectAccessor::GetUnit(*m_caster, ihit->targetGUID))
3742 unit->RemoveOwnedAura(m_spellInfo->Id, m_originalCasterGUID, 0, AURA_REMOVE_BY_CANCEL);
3743
3746
3749 }
3750
3752 ArenaSpectator::SendCommand_Spell(m_caster->FindMap(), m_caster->GetGUID(), "SPE", m_spellInfo->Id, bySelf ? 99998 : 99999);
3753
3754 // spell is canceled-take mods and clear list
3755 if (Player* player = m_caster->GetSpellModOwner())
3756 player->RemoveSpellMods(this);
3757
3758 m_appliedMods.clear();
3759 break;
3760 default:
3761 break;
3762 }
3763
3765 if (m_selfContainer && *m_selfContainer == this)
3766 *m_selfContainer = nullptr;
3767
3768 // Do not remove current far sight object (already done in Spell::EffectAddFarsight) to prevent from reset viewpoint to player
3770 {
3772 }
3773
3774 if (m_spellInfo->IsChanneled()) // if not channeled then the object for the current cast wasn't summoned yet
3776
3777 //set state back so finish will be processed
3778 m_spellState = oldState;
3779
3780 finish(false);
3781}
@ AURA_REMOVE_BY_CANCEL
Definition: SpellAuraDefines.h:393
@ SPELL_STATE_PREPARING
Definition: Spell.h:224
@ SPELL_STATE_CASTING
Definition: Spell.h:225
@ SPELL_EFFECT_ADD_FARSIGHT
Definition: SharedDefines.h:850
@ SPELL_FAILED_INTERRUPTED
Definition: SharedDefines.h:989
void SendCommand_Spell(T *o, ObjectGuid targetGUID, const char *prefix, uint32 id, int32 casttime)
Definition: ArenaSpectator.h:80
Map * FindMap() const
Definition: Object.h:532
bool NeedSendSpectatorData() const
Definition: Player.cpp:15402
void RemoveGameObject(GameObject *gameObj, bool del)
Definition: Unit.cpp:6168
bool RemoveDynObject(uint32 spellId)
Definition: Unit.cpp:6112
void SendChannelUpdate(uint32 time)
Definition: Spell.cpp:5183
void CancelGlobalCooldown()
Definition: Spell.cpp:8877
void SetReferencedFromCurrent(bool yes)
Definition: Spell.h:559
UsedSpellMods m_appliedMods
Definition: Spell.h:545

References AURA_REMOVE_BY_CANCEL, CancelGlobalCooldown(), WorldObject::FindMap(), finish(), Object::GetGUID(), Unit::GetSpellModOwner(), ObjectAccessor::GetUnit(), SpellInfo::HasEffect(), SpellInfo::Id, SpellInfo::IsChanneled(), SpellInfo::IsCooldownStartedOnEvent(), Object::IsPlayer(), m_appliedMods, m_autoRepeat, m_caster, m_originalCasterGUID, m_selfContainer, m_spellInfo, m_spellState, m_UniqueTargetInfo, Player::NeedSendSpectatorData(), Unit::RemoveDynObject(), Unit::RemoveGameObject(), Player::RemoveSpellCooldown(), SendCastResult(), SendChannelUpdate(), ArenaSpectator::SendCommand_Spell(), SendInterrupted(), SetReferencedFromCurrent(), SPELL_EFFECT_ADD_FARSIGHT, SPELL_FAILED_INTERRUPTED, SPELL_MISS_NONE, SPELL_STATE_CASTING, SPELL_STATE_DELAYED, SPELL_STATE_FINISHED, SPELL_STATE_PREPARING, and Object::ToPlayer().

Referenced by _cast(), SpellEvent::Abort(), AddUnitTarget(), SpellScript::Cancel(), Unit::InterruptSpell(), update(), and SpellEvent::~SpellEvent().

◆ CancelGlobalCooldown()

void Spell::CancelGlobalCooldown ( )
protected
8878{
8880 return;
8881
8882 // Cancel global cooldown when interrupting current cast
8884 return;
8885
8886 // Only players or controlled units have global cooldown
8887 if (m_caster->GetCharmInfo())
8889 else if (m_caster->IsPlayer())
8891}
@ CURRENT_GENERIC_SPELL
Definition: Unit.h:538
GlobalCooldownMgr & GetGlobalCooldownMgr()
Definition: Player.h:1785
void CancelGlobalCooldown(SpellInfo const *spellInfo)
Definition: CharmInfo.cpp:415
GlobalCooldownMgr & GetGlobalCooldownMgr()
Definition: CharmInfo.h:158
CharmInfo * GetCharmInfo()
Definition: Unit.h:1278
Spell * GetCurrentSpell(CurrentSpellTypes spellType) const
Definition: Unit.h:1456
uint32 StartRecoveryTime
Definition: SpellInfo.h:351

References GlobalCooldownMgr::CancelGlobalCooldown(), CURRENT_GENERIC_SPELL, Unit::GetCharmInfo(), Unit::GetCurrentSpell(), Player::GetGlobalCooldownMgr(), CharmInfo::GetGlobalCooldownMgr(), Object::IsPlayer(), m_caster, m_spellInfo, SpellInfo::StartRecoveryTime, and Object::ToPlayer().

Referenced by cancel().

◆ CanExecuteTriggersOnHit()

bool Spell::CanExecuteTriggersOnHit ( uint8  effMask,
SpellInfo const *  triggeredByAura = nullptr 
) const
protected
8727{
8728 // Relentless strikes, proc only from first effect
8729 if (triggeredByAura && triggeredByAura->SpellIconID == 559)
8730 return effMask & (1 << EFFECT_0);
8731
8732 bool only_on_caster = (triggeredByAura && triggeredByAura->HasAttribute(SPELL_ATTR4_CLASS_TRIGGER_ONLY_ON_TARGET));
8733 // If triggeredByAura has SPELL_ATTR4_CLASS_TRIGGER_ONLY_ON_TARGET then it can only proc on a casted spell with TARGET_UNIT_CASTER
8734 for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
8735 {
8736 if ((effMask & (1 << i)) && (!only_on_caster || (m_spellInfo->Effects[i].TargetA.GetTarget() == TARGET_UNIT_CASTER)))
8737 return true;
8738 }
8739 return effMask;
8740}
@ EFFECT_0
Definition: SharedDefines.h:31
@ TARGET_UNIT_CASTER
Definition: SharedDefines.h:1410
@ SPELL_ATTR4_CLASS_TRIGGER_ONLY_ON_TARGET
Definition: SharedDefines.h:531

References EFFECT_0, SpellInfo::Effects, SpellInfo::HasAttribute(), m_spellInfo, MAX_SPELL_EFFECTS, SPELL_ATTR4_CLASS_TRIGGER_ONLY_ON_TARGET, SpellInfo::SpellIconID, and TARGET_UNIT_CASTER.

Referenced by DoAllEffectOnTarget(), and DoTriggersOnSpellHit().

◆ CanOpenLock()

SpellCastResult Spell::CanOpenLock ( uint32  effIndex,
uint32  lockid,
SkillType skillid,
int32 reqSkillValue,
int32 skillValue 
)
protected
8351{
8352 if (!lockId) // possible case for GO and maybe for items.
8353 return SPELL_CAST_OK;
8354
8355 // Get LockInfo
8356 LockEntry const* lockInfo = sLockStore.LookupEntry(lockId);
8357
8358 if (!lockInfo)
8360
8361 bool reqKey = false; // some locks not have reqs
8362
8363 for (int j = 0; j < MAX_LOCK_CASE; ++j)
8364 {
8365 switch (lockInfo->Type[j])
8366 {
8367 // check key item (many fit cases can be)
8368 case LOCK_KEY_ITEM:
8369 if (lockInfo->Index[j] && m_CastItem && m_CastItem->GetEntry() == lockInfo->Index[j])
8370 return SPELL_CAST_OK;
8371 reqKey = true;
8372 break;
8373 // check key skill (only single first fit case can be)
8374 case LOCK_KEY_SKILL:
8375 {
8376 reqKey = true;
8377
8378 // wrong locktype, skip
8379 if (uint32(m_spellInfo->Effects[effIndex].MiscValue) != lockInfo->Index[j])
8380 continue;
8381
8382 skillId = SkillByLockType(LockType(lockInfo->Index[j]));
8383
8384 if (skillId != SKILL_NONE)
8385 {
8386 reqSkillValue = lockInfo->Skill[j];
8387
8388 // castitem check: rogue using skeleton keys. the skill values should not be added in this case.
8389 skillValue = m_CastItem || !m_caster->IsPlayer() ?
8390 0 : m_caster->ToPlayer()->GetSkillValue(skillId);
8391
8392 // skill bonus provided by casting spell (mostly item spells)
8393 // add the effect base points modifier from the spell casted (cheat lock / skeleton key etc.)
8394 if ((m_spellInfo->Effects[effIndex].TargetA.GetTarget() == TARGET_GAMEOBJECT_ITEM_TARGET || m_spellInfo->Effects[effIndex].TargetB.GetTarget() == TARGET_GAMEOBJECT_ITEM_TARGET)
8396 {
8397 skillValue += m_spellInfo->Effects[effIndex].CalcValue();
8398 }
8399
8400 if (skillValue < reqSkillValue)
8402 }
8403
8404 return SPELL_CAST_OK;
8405 }
8406 case LOCK_KEY_SPELL:
8407 {
8408 if (m_spellInfo->Id == lockInfo->Index[j])
8409 {
8410 return SPELL_CAST_OK;
8411 }
8412 reqKey = true;
8413 break;
8414 }
8415 }
8416 }
8417
8418 if (reqKey)
8420
8421 return SPELL_CAST_OK;
8422}
DBCStorage< LockEntry > sLockStore(LockEntryfmt)
@ TARGET_GAMEOBJECT_ITEM_TARGET
Definition: SharedDefines.h:1430
LockType
Definition: SharedDefines.h:2591
@ LOCK_KEY_ITEM
Definition: SharedDefines.h:2585
@ LOCK_KEY_SKILL
Definition: SharedDefines.h:2586
@ LOCK_KEY_SPELL
Definition: SharedDefines.h:2587
@ SPELL_FAILED_BAD_TARGETS
Definition: SharedDefines.h:961
@ SPELL_FAILED_LOW_CASTLEVEL
Definition: SharedDefines.h:998
SkillType SkillByLockType(LockType locktype)
Definition: SharedDefines.h:3020
@ SKILL_NONE
Definition: SharedDefines.h:2864
@ SKILL_LOCKPICKING
Definition: SharedDefines.h:2975
#define MAX_LOCK_CASE
Definition: DBCStructure.h:1305
uint16 GetSkillValue(uint32 skill) const
Definition: Player.cpp:5437
bool IsAbilityOfSkillType(uint32 skillType) const
Definition: SpellInfo.cpp:1004
Definition: DBCStructure.h:1308
uint32 Type[MAX_LOCK_CASE]
Definition: DBCStructure.h:1310
uint32 Index[MAX_LOCK_CASE]
Definition: DBCStructure.h:1311
uint32 Skill[MAX_LOCK_CASE]
Definition: DBCStructure.h:1312

References SpellInfo::Effects, Object::GetEntry(), Player::GetSkillValue(), SpellInfo::Id, LockEntry::Index, SpellInfo::IsAbilityOfSkillType(), Object::IsPlayer(), LOCK_KEY_ITEM, LOCK_KEY_SKILL, LOCK_KEY_SPELL, m_caster, m_CastItem, m_spellInfo, MAX_LOCK_CASE, LockEntry::Skill, SKILL_LOCKPICKING, SKILL_NONE, SkillByLockType(), sLockStore, SPELL_CAST_OK, SPELL_FAILED_BAD_TARGETS, SPELL_FAILED_LOW_CASTLEVEL, TARGET_GAMEOBJECT_ITEM_TARGET, Object::ToPlayer(), and LockEntry::Type.

Referenced by CheckCast(), and EffectOpenLock().

◆ cast()

void Spell::cast ( bool  skipCheck = false)
3784{
3785 Player* modOwner = m_caster->GetSpellModOwner();
3786 Spell* lastMod = nullptr;
3787 if (modOwner)
3788 {
3789 lastMod = modOwner->m_spellModTakingSpell;
3790 if (lastMod)
3791 modOwner->SetSpellModTakingSpell(lastMod, false);
3792 }
3793
3794 _cast(skipCheck);
3795
3796 if (lastMod)
3797 modOwner->SetSpellModTakingSpell(lastMod, true);
3798}
Spell * m_spellModTakingSpell
Definition: Player.h:2532
Definition: Spell.h:284
void _cast(bool skipCheck)
Definition: Spell.cpp:3800

References _cast(), Unit::GetSpellModOwner(), m_caster, Player::m_spellModTakingSpell, and Player::SetSpellModTakingSpell().

Referenced by Unit::AttackerStateUpdate(), prepare(), and update().

◆ CheckCast()

SpellCastResult Spell::CheckCast ( bool  strict)
Todo:
: determine if there is some flag to enable/disable the check
5646{
5647 // check death state
5650
5651 // Spectator check
5652 if (m_caster->IsPlayer())
5653 if (((Player const*)m_caster)->IsSpectator() && m_spellInfo->Id != SPECTATOR_SPELL_BINDSIGHT)
5654 return SPELL_FAILED_NOT_HERE;
5655
5657
5658 sScriptMgr->OnSpellCheckCast(this, strict, res);
5659
5660 if (res != SPELL_CAST_OK)
5661 return res;
5662
5663 // check cooldowns to prevent cheating
5665 {
5666 if (m_caster->IsPlayer())
5667 {
5668 //can cast triggered (by aura only?) spells while have this flag
5671
5673 {
5676 else
5678 }
5679
5680 // check if we are using a potion in combat for the 2nd+ time. Cooldown is added only after caster gets out of combat
5683 }
5686 }
5687
5689 {
5692 }
5693
5694 // Check global cooldown
5697
5698 // only triggered spells can be processed an ended battleground
5699 if (!IsTriggered() && m_caster->IsPlayer())
5701 if (bg->GetStatus() == STATUS_WAIT_LEAVE)
5703
5704 if (m_caster->IsPlayer() /*&& VMAP::VMapFactory::createOrGetVMapMgr()->isLineOfSightCalcEnabled()*/) // pussywizard: optimization (commented)
5705 {
5707 !m_caster->IsOutdoors())
5709
5713 }
5714
5715 // only check at first call, Stealth auras are already removed at second call
5716 // for now, ignore triggered spells
5718 {
5719 bool checkForm = true;
5720 // Ignore form req aura
5722 for (Unit::AuraEffectList::const_iterator i = ignore.begin(); i != ignore.end(); ++i)
5723 {
5724 if (!(*i)->IsAffectedOnSpell(m_spellInfo))
5725 continue;
5726 checkForm = false;
5727 break;
5728 }
5729 if (checkForm)
5730 {
5731 // Cannot be used in this stance/form
5733 if (shapeError != SPELL_CAST_OK)
5734 return shapeError;
5735
5738 }
5739 }
5740
5742 for (Unit::AuraEffectList::const_iterator blockItr = blockSpells.begin(); blockItr != blockSpells.end(); ++blockItr)
5743 if (uint32((*blockItr)->GetMiscValue()) == m_spellInfo->SpellFamilyName)
5745
5746 bool reqCombat = true;
5748 for (Unit::AuraEffectList::const_iterator j = stateAuras.begin(); j != stateAuras.end(); ++j)
5749 {
5750 if ((*j)->IsAffectedOnSpell(m_spellInfo))
5751 {
5752 m_needComboPoints = false;
5753 if ((*j)->GetMiscValue() == 1)
5754 {
5755 reqCombat = false;
5756 break;
5757 }
5758 }
5759 }
5760
5761 // caster state requirements
5762 // not for triggered spells (needed by execute)
5764 {
5769
5770 // Note: spell 62473 requres CasterAuraSpell = triggering spell
5775
5776 if (reqCombat && m_caster->IsInCombat() && !m_spellInfo->CanBeUsedInCombat())
5778 }
5779
5780 // Xinef: exploit protection
5782 {
5783 if (m_caster->IsPlayer() && m_caster->GetMap()->IsDungeon())
5784 if (InstanceScript* instanceScript = m_caster->GetInstanceScript())
5785 if (instanceScript->IsEncounterInProgress())
5786 {
5787 if (Group* group = m_caster->ToPlayer()->GetGroup())
5788 for (GroupReference* itr = group->GetFirstMember(); itr != nullptr; itr = itr->next())
5789 if (Player* member = itr->GetSource())
5790 if (member->IsInMap(m_caster))
5791 if (Unit* victim = member->GetVictim())
5792 if (victim->IsInCombat() && m_caster->GetDistance(victim) < m_caster->GetVisibilityRange())
5793 {
5794 m_caster->CombatStart(victim);
5795 victim->AddThreat(m_caster, 1.0f);
5796 break;
5797 }
5799 }
5800 }
5801
5802 // cancel autorepeat spells if cast start when moving
5803 // (not wand currently autorepeat cast delayed to moving stop anyway in spell update code)
5804 if (m_caster->IsPlayer() && m_caster->ToPlayer()->isMoving() && !IsTriggered())
5805 {
5806 // skip stuck spell to allow use it in falling case and apply spell limitations at movement
5809 return SPELL_FAILED_MOVING;
5810 }
5811
5812 Vehicle* vehicle = m_caster->GetVehicle();
5814 {
5815 uint16 checkMask = 0;
5816 for (uint8 effIndex = EFFECT_0; effIndex < MAX_SPELL_EFFECTS; ++effIndex)
5817 {
5818 SpellEffectInfo const* effInfo = &m_spellInfo->Effects[effIndex];
5820 {
5821 SpellShapeshiftFormEntry const* shapeShiftEntry = sSpellShapeshiftFormStore.LookupEntry(effInfo->MiscValue);
5822 if (shapeShiftEntry && (shapeShiftEntry->flags1 & 1) == 0) // unk flag
5823 checkMask |= VEHICLE_SEAT_FLAG_UNCONTROLLED;
5824 break;
5825 }
5826 }
5827
5830
5831 if (!checkMask)
5832 checkMask = VEHICLE_SEAT_FLAG_CAN_ATTACK;
5833
5834 // All creatures should be able to cast as passengers freely, restriction and attribute are only for players
5835 VehicleSeatEntry const* vehicleSeat = vehicle->GetSeatForPassenger(m_caster);
5837 && (vehicleSeat->m_flags & checkMask) != checkMask && m_caster->IsPlayer())
5839 }
5840
5841 // check spell cast conditions from database
5842 {
5845 ConditionList conditions = sConditionMgr->GetConditionsForNotGroupedEntry(CONDITION_SOURCE_TYPE_SPELL, m_spellInfo->Id);
5846 if (!conditions.empty() && !sConditionMgr->IsObjectMeetToConditions(condInfo, conditions))
5847 {
5848 // mLastFailedCondition can be nullptr if there was an error processing the condition in Condition::Meets (i.e. wrong data for ConditionTarget or others)
5849 if (condInfo.mLastFailedCondition && condInfo.mLastFailedCondition->ErrorType)
5850 {
5854 }
5855 if (!condInfo.mLastFailedCondition || !condInfo.mLastFailedCondition->ConditionTarget)
5858 }
5859 }
5860
5861 // Don't check explicit target for passive spells (workaround) (check should be skipped only for learn case)
5862 // those spells may have incorrect target entries or not filled at all (for example 15332)
5863 // such spells when learned are not targeting anyone using targeting system, they should apply directly to caster instead
5864 // also, such casts shouldn't be sent to client
5865 // Xinef: do not check explicit casts for self cast of triggered spells (eg. reflect case)
5867 {
5868 // Check explicit target for m_originalCaster - todo: get rid of such workarounds
5869 // Xinef: do not check explicit target for triggered spell casted on self with targetflag enemy
5871 {
5873 if (castResult != SPELL_CAST_OK)
5874 return castResult;
5875 }
5876 }
5877
5878 if (Unit* target = m_targets.GetUnitTarget())
5879 {
5880 SpellCastResult castResult = m_spellInfo->CheckTarget(m_caster, target, false);
5881 if (castResult != SPELL_CAST_OK)
5882 return castResult;
5883
5884 if (target != m_caster)
5885 {
5886 // Must be behind the target
5887 if (m_spellInfo->HasAttribute(SPELL_ATTR0_CU_REQ_CASTER_BEHIND_TARGET) && target->HasInArc(static_cast<float>(M_PI), m_caster))
5889
5890 // Target must be facing you
5891 if (m_spellInfo->HasAttribute(SPELL_ATTR0_CU_REQ_TARGET_FACING_CASTER) && !target->HasInArc(static_cast<float>(M_PI), m_caster))
5893
5896 {
5897 bool castedByGameobject = false;
5898 uint32 losChecks = LINEOFSIGHT_ALL_CHECKS;
5900 {
5901 castedByGameobject = m_caster->GetMap()->GetGameObject(m_originalCasterGUID) != nullptr;
5902 }
5903 else if (m_caster->GetEntry() == WORLD_TRIGGER)
5904 {
5905 if (TempSummon* tempSummon = m_caster->ToTempSummon())
5906 {
5907 castedByGameobject = tempSummon->GetSummonerGameObject() != nullptr;
5908 }
5909 }
5910
5911 if (castedByGameobject)
5912 {
5913 // If spell casted by gameobject then ignore M2 models
5914 losChecks &= ~LINEOFSIGHT_CHECK_GOBJECT_M2;
5915 }
5916
5918 {
5920 }
5921 }
5922 }
5923 }
5924
5925 // Check for line of sight for spells with dest
5926 if (m_targets.HasDst())
5927 {
5928 float x, y, z;
5929 m_targets.GetDstPos()->GetPosition(x, y, z);
5930
5933 {
5934 bool castedByGameobject = false;
5935 uint32 losChecks = LINEOFSIGHT_ALL_CHECKS;
5937 {
5938 castedByGameobject = m_caster->GetMap()->GetGameObject(m_originalCasterGUID) != nullptr;
5939 }
5940 else if (m_caster->GetEntry() == WORLD_TRIGGER)
5941 {
5942 if (TempSummon* tempSummon = m_caster->ToTempSummon())
5943 {
5944 castedByGameobject = tempSummon->GetSummonerGameObject() != nullptr;
5945 }
5946 }
5947
5948 if (castedByGameobject)
5949 {
5950 // If spell casted by gameobject then ignore M2 models
5951 losChecks &= ~LINEOFSIGHT_CHECK_GOBJECT_M2;
5952 }
5953
5955 {
5957 }
5958 }
5959 }
5960
5961 // check pet presence
5962 for (int j = 0; j < MAX_SPELL_EFFECTS; ++j)
5963 {
5964 if (m_spellInfo->Effects[j].TargetA.GetTarget() == TARGET_UNIT_PET)
5965 {
5967 {
5968 if (m_triggeredByAuraSpell.spellInfo) // not report pet not existence for triggered spells
5970 else
5971 return SPELL_FAILED_NO_PET;
5972 }
5973 break;
5974 }
5975 }
5976 // Spell casted only on battleground
5978 if (!m_caster->ToPlayer()->InBattleground())
5980
5981 // do not allow spells to be cast in arenas
5982 // - with greater than 10 min CD without SPELL_ATTR4_IGNORE_DEFAULT_ARENA_RESTRICTIONS flag
5983 // - with SPELL_ATTR4_NOT_IN_ARENA_OR_RATED_BATTLEGROUND flag
5986 if (MapEntry const* mapEntry = sMapStore.LookupEntry(m_caster->GetMapId()))
5987 if (mapEntry->IsBattleArena())
5989
5990 // zone check
5992 {
5993 uint32 zone, area;
5994 m_caster->GetZoneAndAreaId(zone, area);
5995
5997 m_caster->IsPlayer() ? m_caster->ToPlayer() : nullptr);
5998 if (locRes != SPELL_CAST_OK)
5999 return locRes;
6000 }
6001
6002 // not let players cast spells at mount (and let do it to creatures)
6005 {
6006 if (m_caster->IsInFlight())
6008 else
6010 }
6011
6012 SpellCastResult castResult = SPELL_CAST_OK;
6013
6014 // always (except passive spells) check items (focus object can be required for any type casts)
6015 if (!m_spellInfo->IsPassive())
6016 {
6017 // spell focus needs to be checked not only for players! there are vehicle spells that require spell focus
6018 castResult = CheckSpellFocus();
6019 if (castResult != SPELL_CAST_OK)
6020 return castResult;
6021
6022 castResult = CheckItems();
6023 if (castResult != SPELL_CAST_OK)
6024 return castResult;
6025 }
6026
6027 // Triggered spells also have range check
6029 castResult = CheckRange(strict);
6030 if (castResult != SPELL_CAST_OK)
6031 return castResult;
6032
6034 {
6035 castResult = CheckPower();
6036 if (castResult != SPELL_CAST_OK)
6037 return castResult;
6038 }
6039
6041 {
6042 return SPELL_CAST_OK;
6043 }
6044
6045 // xinef: do not skip triggered spells if they posses prevention type (eg. Bladestorm vs Hand of Protection)
6047 {
6049 if (castResult != SPELL_CAST_OK)
6050 return castResult;
6051
6052 // xinef: Enraged Regeneration: While this is active, the warrior is blocked from using abilities that trigger being enraged (which would do nothing and waste the cooldowns).
6054 {
6056 for (SpellImmuneList::const_iterator itr = mechanicList.begin(); itr != mechanicList.end(); ++itr)
6057 if (itr->type == m_spellInfo->Mechanic)
6059 }
6060 }
6061
6062 // script hook
6063 castResult = CallScriptCheckCastHandlers();
6064 if (castResult != SPELL_CAST_OK)
6065 return castResult;
6066
6067 bool hasDispellableAura = false;
6068 bool hasNonDispelEffect = false;
6069 uint32 dispelMask = 0;
6070 for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
6071 if (m_spellInfo->Effects[i].Effect == SPELL_EFFECT_DISPEL)
6072 {
6074 {
6075 hasDispellableAura = true;
6076 break;
6077 }
6078
6079 dispelMask |= SpellInfo::GetDispelMask(DispelType(m_spellInfo->Effects[i].MiscValue));
6080 }
6081 else if (m_spellInfo->Effects[i].IsEffect())
6082 {
6083 hasNonDispelEffect = true;
6084 break;
6085 }
6086
6087 if (!hasNonDispelEffect && !hasDispellableAura && dispelMask && !IsTriggered())
6088 {
6089 if (Unit* target = m_targets.GetUnitTarget())
6090 {
6091 // Xinef: do not allow to cast on hostile targets in sanctuary
6092 if (!m_caster->IsFriendlyTo(target))
6093 {
6094 if (m_caster->IsInSanctuary() || target->IsInSanctuary())
6095 {
6096 // Xinef: fix for duels
6097 Player* player = m_caster->ToPlayer();
6098 if (!player || !player->duel || target != player->duel->Opponent)
6100 }
6101 }
6102
6103 DispelChargesList dispelList;
6104 target->GetDispellableAuraList(m_caster, dispelMask, dispelList, m_spellInfo);
6105
6106 if (dispelList.empty())
6108 }
6109 }
6110
6111 for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
6112 {
6113 // for effects of spells that have only one target
6114 switch (m_spellInfo->Effects[i].Effect)
6115 {
6117 {
6118 if (!m_caster->IsPlayer())
6120
6121 if (m_spellInfo->Effects[i].TargetA.GetTarget() != TARGET_UNIT_PET)
6122 break;
6123
6124 Pet* pet = m_caster->ToPlayer()->GetPet();
6125
6126 if (!pet)
6127 return SPELL_FAILED_NO_PET;
6128
6129 SpellInfo const* learn_spellproto = sSpellMgr->GetSpellInfo(m_spellInfo->Effects[i].TriggerSpell);
6130
6131 if (!learn_spellproto)
6133
6134 if (m_spellInfo->SpellLevel > pet->GetLevel())
6135 return SPELL_FAILED_LOWLEVEL;
6136
6137 break;
6138 }
6140 {
6141 // check target only for unit target case
6143 {
6144 if (!m_caster->IsPlayer())
6146
6147 Pet* pet = unitTarget->ToPet();
6148 if (!pet || pet->GetOwner() != m_caster)
6150
6151 SpellInfo const* learn_spellproto = sSpellMgr->GetSpellInfo(m_spellInfo->Effects[i].TriggerSpell);
6152
6153 if (!learn_spellproto)
6155
6156 if (m_spellInfo->SpellLevel > pet->GetLevel())
6157 return SPELL_FAILED_LOWLEVEL;
6158 }
6159 break;
6160 }
6162 {
6163 uint32 glyphId = m_spellInfo->Effects[i].MiscValue;
6164 if (GlyphPropertiesEntry const* gp = sGlyphPropertiesStore.LookupEntry(glyphId))
6165 if (m_caster->HasAura(gp->SpellId))
6167 break;
6168 }
6170 {
6171 if (!m_caster->IsPlayer())
6173
6174 Item* foodItem = m_targets.GetItemTarget();
6175 if (!foodItem)
6177
6178 Pet* pet = m_caster->ToPlayer()->GetPet();
6179
6180 if (!pet)
6181 return SPELL_FAILED_NO_PET;
6182
6183 if (!pet->HaveInDiet(foodItem->GetTemplate()))
6185
6186 if (!pet->GetCurrentFoodBenefitLevel(foodItem->GetTemplate()->ItemLevel))
6188
6189 if (m_caster->IsInCombat() || pet->IsInCombat())
6191
6192 break;
6193 }
6196 {
6197 // Can be area effect, Check only for players and not check if target - caster (spell can have multiply drain/burn effects)
6198 if (m_caster->IsPlayer())
6199 if (Unit* target = m_targets.GetUnitTarget())
6200 if (target != m_caster && !target->HasActivePowerType(Powers(m_spellInfo->Effects[i].MiscValue)))
6202 break;
6203 }
6205 {
6207 {
6209 }
6210
6212 {
6213 // Warbringer - can't be handled in proc system - should be done before checkcast root check and charge effect process
6214 if (strict && m_caster->IsScriptOverriden(m_spellInfo, 6953))
6216 }
6218 {
6219 // Exception for Master's Call
6220 if (m_spellInfo->Id != 54216)
6221 {
6222 return SPELL_FAILED_ROOTED;
6223 }
6224 }
6225 if (m_caster->IsPlayer())
6226 if (Unit* target = m_targets.GetUnitTarget())
6227 if (!target->IsAlive())
6229 // Xinef: Pass only explicit unit target spells
6230 // pussywizard:
6232 {
6233 Unit* target = m_targets.GetUnitTarget();
6234 if (!target)
6236
6237 // first we must check to see if the target is in LoS. A path can usually be built but LoS matters for charge spells
6238 if (!target->IsWithinLOSInMap(m_caster)) //Do full LoS/Path check. Don't exclude m2
6240
6241 float objSize = target->GetCombatReach();
6242 float range = m_spellInfo->GetMaxRange(true, m_caster, this) * 1.5f + objSize; // can't be overly strict
6243
6244 m_preGeneratedPath = std::make_unique<PathGenerator>(m_caster);
6245 m_preGeneratedPath->SetPathLengthLimit(range);
6246
6247 // first try with raycast, if it fails fall back to normal path
6248 bool result = m_preGeneratedPath->CalculatePath(target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), false);
6249 if (m_preGeneratedPath->GetPathType() & PATHFIND_SHORT)
6250 return SPELL_FAILED_NOPATH;
6251 else if (!result || m_preGeneratedPath->GetPathType() & (PATHFIND_NOPATH | PATHFIND_INCOMPLETE))
6252 return SPELL_FAILED_NOPATH;
6253 else if (m_preGeneratedPath->IsInvalidDestinationZ(target)) // Check position z, if not in a straight line
6254 return SPELL_FAILED_NOPATH;
6255
6256 m_preGeneratedPath->ShortenPathUntilDist(G3D::Vector3(target->GetPositionX(), target->GetPositionY(), target->GetPositionZ()), objSize); // move back
6257 }
6258 if (Player* player = m_caster->ToPlayer())
6259 player->SetCanTeleport(true);
6260 break;
6261 }
6263 {
6266
6269
6270 Creature* creature = m_targets.GetUnitTarget()->ToCreature();
6271 if (!creature->IsCritter() && !creature->loot.isLooted())
6273
6274 uint32 skill = creature->GetCreatureTemplate()->GetRequiredLootSkill();
6275
6276 int32 skillValue = m_caster->ToPlayer()->GetSkillValue(skill);
6277 int32 TargetLevel = m_targets.GetUnitTarget()->GetLevel();
6278 int32 ReqValue = (skillValue < 100 ? (TargetLevel - 10) * 10 : TargetLevel * 5);
6279 if (ReqValue > skillValue)
6281
6282 break;
6283 }
6285 {
6286 if (m_spellInfo->Effects[i].TargetA.GetTarget() != TARGET_GAMEOBJECT_TARGET &&
6287 m_spellInfo->Effects[i].TargetA.GetTarget() != TARGET_GAMEOBJECT_ITEM_TARGET)
6288 break;
6289
6290 if (!m_caster->IsPlayer() // only players can open locks, gather etc.
6291 // we need a go target in case of TARGET_GAMEOBJECT_TARGET
6292 || (m_spellInfo->Effects[i].TargetA.GetTarget() == TARGET_GAMEOBJECT_TARGET && !m_targets.GetGOTarget()))
6294
6295 Item* pTempItem = nullptr;
6297 {
6298 if (TradeData* pTrade = m_caster->ToPlayer()->GetTradeData())
6299 pTempItem = pTrade->GetTraderData()->GetItem(TradeSlots(m_targets.GetItemTargetGUID().GetRawValue()));
6300 }
6303
6304 // we need a go target, or an openable item target in case of TARGET_GAMEOBJECT_ITEM_TARGET
6305 if (m_spellInfo->Effects[i].TargetA.GetTarget() == TARGET_GAMEOBJECT_ITEM_TARGET &&
6307 (!pTempItem || !pTempItem->GetTemplate()->LockID || !pTempItem->IsLocked()))
6309
6310 // We must also ensure the gameobject we are opening is still closed by the time the spell finishes.
6311 if (GameObject* go = m_targets.GetGOTarget())
6312 {
6313 if (go->GetGoType() == GAMEOBJECT_TYPE_DOOR && go->GetGoState() != GO_STATE_READY)
6314 {
6316 }
6317 }
6318 if (m_spellInfo->Id != 1842 || (m_targets.GetGOTarget() &&
6320 {
6321 if (m_targets.GetGOTarget() && m_targets.GetGOTarget()->GetEntry() == 179697)
6322 {
6323 if (!m_caster->ToPlayer()->CanUseBattlegroundObject(nullptr))
6325 }
6326 else if (m_caster->ToPlayer()->InBattleground() && // In Battleground players can use only flags and banners, or Gurubashi chest
6329 }
6330
6331 // get the lock entry
6332 uint32 lockId = 0;
6333 if (GameObject* go = m_targets.GetGOTarget())
6334 {
6335 lockId = go->GetGOInfo()->GetLockId();
6336 if (!lockId)
6338 }
6339 else if (Item* itm = m_targets.GetItemTarget())
6340 lockId = itm->GetTemplate()->LockID;
6341
6342 SkillType skillId = SKILL_NONE;
6343 int32 reqSkillValue = 0;
6344 int32 skillValue = 0;
6345
6346 // check lock compatibility
6347 SpellCastResult res = CanOpenLock(i, lockId, skillId, reqSkillValue, skillValue);
6348 if (res != SPELL_CAST_OK)
6349 return res;
6350
6351 // chance for fail at lockpicking attempt
6352 // second check prevent fail at rechecks
6353 // herbalism and mining cannot fail as of patch 3.1.0
6354 if (skillId != SKILL_NONE && skillId != SKILL_HERBALISM && skillId != SKILL_MINING && (!m_selfContainer || ((*m_selfContainer) != this)))
6355 {
6356 // chance for failure in orange lockpick
6357 if (skillId == SKILL_LOCKPICKING && reqSkillValue > irand(skillValue - 25, skillValue + 37))
6358 {
6360 }
6361 }
6362 break;
6363 }
6365 {
6366 Unit* unitCaster = m_caster->ToUnit();
6367 if (!unitCaster)
6368 {
6370 }
6371
6372 Creature* pet = unitCaster->GetGuardianPet();
6373 if (pet)
6374 {
6375 if (pet->IsAlive())
6376 {
6378 }
6379 }
6380 else if (Player* playerCaster = m_caster->ToPlayer())
6381 {
6382 PetStable& petStable = playerCaster->GetOrInitPetStable();
6383 if (!petStable.CurrentPet && petStable.UnslottedPets.empty())
6384 {
6385 return SPELL_FAILED_NO_PET;
6386 }
6387 }
6388
6389 break;
6390 }
6391 // This is generic summon effect
6393 {
6394 SummonPropertiesEntry const* SummonProperties = sSummonPropertiesStore.LookupEntry(m_spellInfo->Effects[i].MiscValueB);
6395 if (!SummonProperties || m_spellInfo->HasAttribute(SPELL_ATTR1_DISMISS_PET_FIRST))
6396 break;
6397 switch (SummonProperties->Category)
6398 {
6400 if (m_caster->GetPetGUID())
6402 [[fallthrough]];
6404 if (m_caster->GetCharmGUID())
6406 break;
6407 }
6408 break;
6409 }
6411 {
6413 {
6418 }
6419 break;
6420 }
6422 {
6423 Unit* unitCaster = m_caster->ToUnit();
6424 if (!unitCaster)
6426
6428 {
6429 if (m_caster->GetPetGUID())
6431 if (m_caster->GetCharmGUID())
6433 }
6434
6436 if (Pet* pet = m_caster->ToPlayer()->GetPet())
6437 pet->CastSpell(pet, 32752, true, nullptr, nullptr, pet->GetGUID()); //starting cast, trigger pet stun (cast by pet so it doesn't attack player)
6438
6439 Player* playerCaster = unitCaster->ToPlayer();
6440 if (playerCaster && playerCaster->GetPetStable())
6441 {
6442 std::pair<PetStable::PetInfo const*, PetSaveMode> info = Pet::GetLoadPetInfo(*playerCaster->GetPetStable(), m_spellInfo->Effects[i].MiscValue, 0, false);
6443 if (info.first)
6444 {
6445 if (info.first->Type == HUNTER_PET)
6446 {
6447 if (!info.first->Health)
6448 {
6449 playerCaster->SendTameFailure(PET_TAME_DEAD);
6451 }
6452
6453 CreatureTemplate const* creatureInfo = sObjectMgr->GetCreatureTemplate(info.first->CreatureId);
6454 if (!creatureInfo || !creatureInfo->IsTameable(playerCaster->CanTameExoticPets()))
6455 {
6456 // if problem in exotic pet
6457 if (creatureInfo && creatureInfo->IsTameable(true))
6459 else
6461
6463 }
6464 }
6465 }
6466 else if (!m_spellInfo->Effects[i].MiscValue) // when miscvalue is present it is allowed to create new pets
6467 {
6470 }
6471 }
6472 break;
6473 }
6475 {
6476 if (!m_caster->IsPlayer())
6478 if (!m_caster->GetTarget())
6480
6482 if (!target || (!target->IsInSameRaidWith(m_caster->ToPlayer()) && m_spellInfo->Id != 48955)) // refer-a-friend spell
6484
6485 // Xinef: Implement summon pending error
6486 if (target->GetSummonExpireTimer() > GameTime::GetGameTime().count())
6488
6489 // check if our map is dungeon
6490 MapEntry const* map = sMapStore.LookupEntry(m_caster->GetMapId());
6491 if (map->IsDungeon())
6492 {
6493 uint32 mapId = m_caster->GetMap()->GetId();
6494 Difficulty difficulty = m_caster->GetMap()->GetDifficulty();
6495 /*if (map->IsRaid())
6496 if (InstancePlayerBind* targetBind = target->GetBoundInstance(mapId, difficulty))
6497 if (targetBind->perm && targetBind != m_caster->ToPlayer()->GetBoundInstance(mapId, difficulty))
6498 return SPELL_FAILED_TARGET_LOCKED_TO_RAID_INSTANCE;*/
6499
6500 InstanceTemplate const* instance = sObjectMgr->GetInstanceTemplate(mapId);
6501 if (!instance)
6503 if (!target->Satisfy(sObjectMgr->GetAccessRequirement(mapId, difficulty), mapId))
6505 }
6506 break;
6507 }
6508 // RETURN HERE
6510 {
6511 if (!m_caster->IsPlayer())
6513
6514 Player* playerCaster = m_caster->ToPlayer();
6515 //
6516 if (!(playerCaster->GetTarget()))
6518
6520
6521 if (!target ||
6522 !(target->GetSession()->GetRecruiterId() == playerCaster->GetSession()->GetAccountId() || target->GetSession()->GetAccountId() == playerCaster->GetSession()->GetRecruiterId()))
6524
6525 // Xinef: Implement summon pending error
6526 if (target->GetSummonExpireTimer() > GameTime::GetGameTime().count())
6528
6529 break;
6530 }
6531 case SPELL_EFFECT_LEAP:
6533 {
6534 //Do not allow to cast it before BG starts.
6535 if (m_caster->IsPlayer())
6536 if (Battleground const* bg = m_caster->ToPlayer()->GetBattleground())
6537 if (bg->GetStatus() != STATUS_IN_PROGRESS)
6539 break;
6540 }
6542 {
6545
6546 bool found = false;
6548 for(Unit::VisibleAuraMap::const_iterator itr = visibleAuras->begin(); itr != visibleAuras->end(); ++itr)
6549 {
6550 if (itr->second->GetBase()->IsPassive())
6551 continue;
6552
6553 if (!itr->second->IsPositive())
6554 continue;
6555
6556 found = true;
6557 break;
6558 }
6559
6560 if (!found)
6562
6563 break;
6564 }
6566 {
6568 {
6569 if (m_caster->IsPlayer())
6570 return SPELL_FAILED_ROOTED;
6571 else
6573 }
6574 break;
6575 }
6576 // xinef: do not allow to use leaps while rooted
6577 case SPELL_EFFECT_JUMP:
6579 {
6581 return SPELL_FAILED_ROOTED;
6582 break;
6583 }
6585 if (!sScriptMgr->CanSelectSpecTalent(this))
6587 // can't change during already started arena/battleground
6588 if (m_caster->IsPlayer())
6589 if (Battleground const* bg = m_caster->ToPlayer()->GetBattleground())
6590 if (bg->GetStatus() == STATUS_IN_PROGRESS)
6592 break;
6593 default:
6594 break;
6595 }
6596 }
6597
6598 for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
6599 {
6600 switch (m_spellInfo->Effects[i].ApplyAuraName)
6601 {
6602 case SPELL_AURA_DUMMY:
6603 break;
6605 {
6606 if (!m_caster->IsPlayer())
6607 return SPELL_FAILED_NO_PET;
6608
6609 Pet* pet = m_caster->ToPlayer()->GetPet();
6610 if (!pet)
6611 return SPELL_FAILED_NO_PET;
6612
6613 if (pet->GetCharmerGUID())
6614 return SPELL_FAILED_CHARMED;
6615 break;
6616 }
6620 {
6621 if (m_caster->GetCharmerGUID())
6622 return SPELL_FAILED_CHARMED;
6623
6624 // Xinef: allow SPELL_AURA_MOD_POSSESS to posses target if caster has some pet
6626 {
6627 if (m_caster->GetPetGUID())
6629
6630 if (m_caster->GetCharmGUID())
6632 }
6633 else if (m_spellInfo->Effects[i].ApplyAuraName == SPELL_AURA_MOD_POSSESS)
6634 {
6635 if (m_caster->GetCharmGUID())
6637 }
6638
6639 if (Unit* target = m_targets.GetUnitTarget())
6640 {
6641 if (target->IsCreature() && target->ToCreature()->IsVehicle())
6643
6644 if (target->IsMounted())
6646
6647 if (target->GetCharmerGUID())
6648 return SPELL_FAILED_CHARMED;
6649
6650 if (target->GetOwnerGUID() && target->GetOwnerGUID().IsPlayer())
6652
6653 if (target->IsPet() && (!target->GetOwner() || target->GetOwner()->ToPlayer()))
6655
6656 int32 damage = CalculateSpellDamage(i, target);
6657 if (damage && int32(target->GetLevel()) > damage)
6659 }
6660
6661 break;
6662 }
6663 case SPELL_AURA_MOUNTED:
6664 {
6665 // Disallow casting flying mounts in water
6668
6669 // Ignore map check if spell have AreaId. AreaId already checked and this prevent special mount spells
6670 bool allowMount = !m_caster->GetMap()->IsDungeon() || m_caster->GetMap()->IsBattlegroundOrArena();
6671 InstanceTemplate const* it = sObjectMgr->GetInstanceTemplate(m_caster->GetMapId());
6672 if (it)
6673 allowMount = it->AllowMount;
6674 if (m_caster->IsPlayer() && !allowMount && !m_spellInfo->AreaGroupId)
6676
6679
6680 // xinef: dont allow to cast mounts in specific transforms
6681 if (m_caster->getTransForm())
6682 if (SpellInfo const* transformSpellInfo = sSpellMgr->GetSpellInfo(m_caster->getTransForm()))
6683 if (transformSpellInfo->HasAttribute(SPELL_ATTR0_NO_IMMUNITIES) &&
6684 !transformSpellInfo->HasAttribute(SpellAttr0(SPELL_ATTR0_ALLOW_WHILE_MOUNTED | SPELL_ATTR0_AURA_IS_DEBUFF)))
6686
6687 break;
6688 }
6690 {
6691 if (!m_targets.GetUnitTarget())
6693
6694 // can be casted at non-friendly unit or own pet/charm
6697
6698 break;
6699 }
6700 case SPELL_AURA_FLY:
6702 {
6703 // Xinef: added water check
6704 if (m_caster->IsInWater())
6706
6707 // not allow cast fly spells if not have req. skills (all spells is self target)
6708 // allow always ghost flight spells
6710 {
6711 Battlefield* Bf = sBattlefieldMgr->GetBattlefieldToZoneId(m_originalCaster->GetZoneId());
6712 if (AreaTableEntry const* pArea = sAreaTableStore.LookupEntry(m_originalCaster->GetAreaId()))
6713 if ((pArea->flags & AREA_FLAG_NO_FLY_ZONE) || (Bf && !Bf->CanFlyIn()))
6714 return SPELL_FAILED_NOT_HERE;
6715 }
6716 break;
6717 }
6719 {
6720 if (m_spellInfo->Effects[i].IsTargetingArea())
6721 break;
6722
6723 if (!m_caster->IsPlayer() || m_CastItem)
6724 break;
6725
6726 if (!m_targets.GetUnitTarget())
6728
6731
6732 break;
6733 }
6734 case SPELL_AURA_HOVER:
6735 {
6737 {
6739 }
6740 break;
6741 }
6743 {
6744 if (m_caster && m_caster->HasAura(23397)) // Nefarian Class Call (Warrior): Berserk -- Nefertum: I don't really like this but I didn't find another way.
6745 {
6747 }
6748 break;
6749 }
6750 default:
6751 break;
6752 }
6753 }
6754
6755 // check trade slot case (last, for allow catch any another cast problems)
6757 {
6758 if (m_CastItem)
6760
6761 if (!m_caster->IsPlayer())
6763
6764 TradeData* my_trade = m_caster->ToPlayer()->GetTradeData();
6765
6766 if (!my_trade)
6768
6770 if (slot != TRADE_SLOT_NONTRADED)
6772
6773 if (!IsTriggered())
6774 if (my_trade->GetSpell())
6776 }
6777
6778 // check if caster has at least 1 combo point on target for spells that require combo points
6780 {
6782 {
6784 {
6786 }
6787 }
6788 else
6789 {
6790 if (!m_caster->GetComboPoints())
6791 {
6793 }
6794 }
6795 }
6796
6797 // xinef: check relic cooldown
6801
6802 // all ok
6803 return SPELL_CAST_OK;
6804}
constexpr auto IN_MILLISECONDS
Definition: Common.h:53
constexpr auto MINUTE
Definition: Common.h:47
int32 irand(int32 min, int32 max)
Definition: Random.cpp:37
std::int32_t int32
Definition: Define.h:103
std::uint16_t uint16
Definition: Define.h:108
#define sConditionMgr
Definition: ConditionMgr.h:289
@ CONDITION_SOURCE_TYPE_SPELL
Definition: ConditionMgr.h:139
std::list< Condition * > ConditionList
Definition: ConditionMgr.h:236
@ STATUS_WAIT_LEAVE
Definition: Battleground.h:198
@ STATUS_IN_PROGRESS
Definition: Battleground.h:197
LineOfSightChecks
Definition: Map.h:191
@ LINEOFSIGHT_ALL_CHECKS
Definition: Map.h:198
#define sBattlefieldMgr
Definition: BattlefieldMgr.h:77
@ PATHFIND_NOPATH
Definition: PathGenerator.h:51
@ PATHFIND_SHORT
Definition: PathGenerator.h:53
@ PATHFIND_INCOMPLETE
Definition: PathGenerator.h:50
DBCStorage< SummonPropertiesEntry > sSummonPropertiesStore(SummonPropertiesfmt)
DBCStorage< SpellShapeshiftFormEntry > sSpellShapeshiftFormStore(SpellShapeshiftFormEntryfmt)
DBCStorage< MapEntry > sMapStore(MapEntryfmt)
DBCStorage< GlyphPropertiesEntry > sGlyphPropertiesStore(GlyphPropertiesfmt)
DBCStorage< AreaTableEntry > sAreaTableStore(AreaTableEntryfmt)
#define SPECTATOR_SPELL_BINDSIGHT
Definition: ArenaSpectator.h:38
#define WORLD_TRIGGER
Definition: Unit.h:37
std::list< std::pair< Aura *, uint8 > > DispelChargesList
Definition: Unit.h:77
@ MOVEMENTFLAG_FALLING_FAR
Definition: UnitDefines.h:357
@ CLASS_CONTEXT_PET
Definition: UnitDefines.h:215
@ UNIT_FLAG2_ALLOW_CHEAT_SPELLS
Definition: UnitDefines.h:285
@ UNIT_STATE_ROOT
Definition: UnitDefines.h:159
@ UNIT_STATE_CHARGING
Definition: UnitDefines.h:166
@ UNIT_FLAG_SKINNABLE
Definition: UnitDefines.h:255
TradeSlots
Definition: TradeData.h:28
@ TRADE_SLOT_NONTRADED
Definition: TradeData.h:31
@ PLAYER_ALLOW_ONLY_ABILITY
Definition: Player.h:497
@ GO_STATE_READY
Definition: GameObjectData.h:691
@ INVTYPE_RELIC
Definition: ItemTemplate.h:284
@ HUNTER_PET
Definition: PetDefines.h:32
@ SPELL_AURA_ABILITY_IGNORE_AURASTATE
Definition: SpellAuraDefines.h:325
@ SPELL_AURA_MOD_SHAPESHIFT
Definition: SpellAuraDefines.h:99
@ SPELL_AURA_MOD_IGNORE_SHAPESHIFT
Definition: SpellAuraDefines.h:338
@ SPELL_AURA_PERIODIC_MANA_LEECH
Definition: SpellAuraDefines.h:127
@ SPELL_AURA_MOD_POSSESS_PET
Definition: SpellAuraDefines.h:191
@ SPELL_AURA_RANGED_ATTACK_POWER_ATTACKER_BONUS
Definition: SpellAuraDefines.h:190
@ SPELL_AURA_DUMMY
Definition: SpellAuraDefines.h:67
@ SPELL_AURA_FLY
Definition: SpellAuraDefines.h:264
@ SPELL_AURA_HOVER
Definition: SpellAuraDefines.h:169
@ SPELL_AURA_MOUNTED
Definition: SpellAuraDefines.h:141
@ SPELL_AURA_AOE_CHARM
Definition: SpellAuraDefines.h:240
@ SPELL_AURA_MOD_POSSESS
Definition: SpellAuraDefines.h:65
@ SPELL_AURA_MOD_INCREASE_MOUNTED_FLIGHT_SPEED
Definition: SpellAuraDefines.h:270
@ SPELL_AURA_BLOCK_SPELL_FAMILY
Definition: SpellAuraDefines.h:360
@ AURA_INTERRUPT_FLAG_NOT_SEATED
Definition: SpellDefines.h:62
@ AURA_INTERRUPT_FLAG_MOUNT
Definition: SpellDefines.h:61
@ TRIGGERED_IGNORE_SPELL_AND_CATEGORY_CD
Will ignore GCD.
Definition: SpellDefines.h:133
@ TRIGGERED_IGNORE_CASTER_AURASTATE
Will ignore shapeshift checks.
Definition: SpellDefines.h:143
@ TRIGGERED_IGNORE_CASTER_MOUNTED_OR_ON_VEHICLE
Will ignore caster aura states including combat requirements and death state.
Definition: SpellDefines.h:144
@ TRIGGERED_IGNORE_SHAPESHIFT
Will not adjust facing to target (if any)
Definition: SpellDefines.h:142
@ TRIGGERED_IGNORE_GCD
Not triggered.
Definition: SpellDefines.h:132
@ TRIGGERED_IGNORE_EFFECTS
Periodic aura tick wont be reset on override.
Definition: SpellDefines.h:151
@ TRIGGERED_IGNORE_CASTER_AURAS
Will ignore mounted/on vehicle restrictions.
Definition: SpellDefines.h:145
std::vector< SpellImmune > SpellImmuneList
Definition: SpellDefines.h:180
#define SPELL_RELIC_COOLDOWN
Definition: SpellMgr.h:34
@ TARGET_FLAG_UNIT_ENEMY
Definition: SpellInfo.h:53
@ TARGET_FLAG_ITEM
Definition: SpellInfo.h:50
@ SPELL_ATTR0_CU_REQ_TARGET_FACING_CASTER
Definition: SpellInfo.h:192
@ SPELL_ATTR0_CU_REQ_CASTER_BEHIND_TARGET
Definition: SpellInfo.h:193
@ SPELL_FLAG_REDIRECTED
Definition: Spell.h:83
@ GAMEOBJECT_TYPE_TRAP
Definition: SharedDefines.h:1566
@ GAMEOBJECT_TYPE_DOOR
Definition: SharedDefines.h:1560
Powers
Definition: SharedDefines.h:268
@ POWER_MANA
Definition: SharedDefines.h:269
@ SPELL_ATTR7_DEBUG_SPELL
Definition: SharedDefines.h:644
@ SPELL_EFFECT_LEAP
Definition: SharedDefines.h:807
@ SPELL_EFFECT_POWER_BURN
Definition: SharedDefines.h:840
@ SPELL_EFFECT_STUCK
Definition: SharedDefines.h:862
@ SPELL_EFFECT_SUMMON_RAF_FRIEND
Definition: SharedDefines.h:930
@ SPELL_EFFECT_APPLY_GLYPH
Definition: SharedDefines.h:852
@ SPELL_EFFECT_FEED_PET
Definition: SharedDefines.h:879
@ SPELL_EFFECT_SUMMON_PLAYER
Definition: SharedDefines.h:863
@ SPELL_EFFECT_JUMP_DEST
Definition: SharedDefines.h:820
@ SPELL_EFFECT_TELEPORT_UNITS_FACE_CASTER
Definition: SharedDefines.h:821
@ SPELL_EFFECT_RESURRECT_PET
Definition: SharedDefines.h:887
@ SPELL_EFFECT_LEAP_BACK
Definition: SharedDefines.h:916
@ SPELL_EFFECT_SUMMON
Definition: SharedDefines.h:806
@ SPELL_EFFECT_POWER_DRAIN
Definition: SharedDefines.h:786
@ SPELL_EFFECT_RESURRECT
Definition: SharedDefines.h:796
@ SPELL_EFFECT_CHARGE
Definition: SharedDefines.h:874
@ SPELL_EFFECT_RESURRECT_NEW
Definition: SharedDefines.h:891
@ SPELL_EFFECT_TALENT_SPEC_SELECT
Definition: SharedDefines.h:940
@ SPELL_EFFECT_LEARN_SPELL
Definition: SharedDefines.h:814
@ SPELL_EFFECT_JUMP
Definition: SharedDefines.h:819
@ SPELL_EFFECT_SKINNING
Definition: SharedDefines.h:873
@ SPELL_EFFECT_CREATE_TAMED_PET
Definition: SharedDefines.h:931
@ SPELL_EFFECT_OPEN_LOCK
Definition: SharedDefines.h:811
@ SPELL_EFFECT_STEAL_BENEFICIAL_BUFF
Definition: SharedDefines.h:904
@ SPELL_EFFECT_LEARN_PET_SPELL
Definition: SharedDefines.h:835
@ SPELL_PREVENTION_TYPE_NONE
Definition: SharedDefines.h:1553
@ SPELL_ATTR5_ALWAYS_AOE_LINE_OF_SIGHT
Definition: SharedDefines.h:593
@ TARGET_UNIT_PET
Definition: SharedDefines.h:1414
@ TARGET_GAMEOBJECT_TARGET
Definition: SharedDefines.h:1427
@ SPELL_ATTR2_IGNORE_LINE_OF_SIGHT
Definition: SharedDefines.h:458
@ SPELL_ATTR1_INITIATE_COMBAT
Definition: SharedDefines.h:428
@ SPELL_ATTR3_ONLY_BATTLEGROUNDS
Definition: SharedDefines.h:504
@ PET_TAME_NOPET_AVAILABLE
Definition: SharedDefines.h:3683
@ PET_TAME_DEAD
Definition: SharedDefines.h:3686
@ PET_TAME_CANT_CONTROL_EXOTIC
Definition: SharedDefines.h:3688
@ CLASS_WARLOCK
Definition: SharedDefines.h:149
@ IMMUNITY_MECHANIC
Definition: SharedDefines.h:1399
@ SPELLFAMILY_WARRIOR
Definition: SharedDefines.h:3532
SpellCustomErrors
Definition: SharedDefines.h:1142
@ SPELL_CUSTOM_ERROR_GM_ONLY
Definition: SharedDefines.h:1208
SpellAttr0
Definition: SharedDefines.h:381
@ SPELL_ATTR0_ONLY_INDOORS
Definition: SharedDefines.h:396
@ SPELL_ATTR0_AURA_IS_DEBUFF
Definition: SharedDefines.h:408
@ SPELL_ATTR0_ONLY_OUTDOORS
Definition: SharedDefines.h:397
@ SPELL_ATTR0_ALLOW_WHILE_MOUNTED
Definition: SharedDefines.h:406
@ SPELL_ATTR0_PASSIVE
Definition: SharedDefines.h:388
@ SPELL_ATTR0_ALLOW_CAST_WHILE_DEAD
Definition: SharedDefines.h:405
@ SPELL_ATTR0_ONLY_STEALTHED
Definition: SharedDefines.h:399
AuraStateType
Definition: SharedDefines.h:1288
DispelType
Definition: SharedDefines.h:1371
@ SPELL_FAILED_TARGET_NOT_LOOTED
Definition: SharedDefines.h:1070
@ SPELL_FAILED_NOT_INFRONT
Definition: SharedDefines.h:1010
@ SPELL_FAILED_MOVING
Definition: SharedDefines.h:1000
@ SPELL_FAILED_NOT_MOUNTED
Definition: SharedDefines.h:1013
@ SPELL_FAILED_AFFECTING_COMBAT
Definition: SharedDefines.h:950
@ SPELL_FAILED_CASTER_AURASTATE
Definition: SharedDefines.h:971
@ SPELL_FAILED_NOTHING_TO_DISPEL
Definition: SharedDefines.h:1035
@ SPELL_FAILED_NOT_KNOWN
Definition: SharedDefines.h:1012
@ SPELL_FAILED_FOOD_LOWLEVEL
Definition: SharedDefines.h:984
@ SPELL_FAILED_NOT_HERE
Definition: SharedDefines.h:1009
@ SPELL_FAILED_ROOTED
Definition: SharedDefines.h:1052
@ SPELL_FAILED_WRONG_PET_FOOD
Definition: SharedDefines.h:1084
@ SPELL_FAILED_CUSTOM_ERROR
Definition: SharedDefines.h:1121
@ SPELL_FAILED_SUMMON_PENDING
Definition: SharedDefines.h:1132
@ SPELL_FAILED_DAMAGE_IMMUNE
Definition: SharedDefines.h:1095
@ SPELL_FAILED_BAD_IMPLICIT_TARGETS
Definition: SharedDefines.h:960
@ SPELL_FAILED_TRY_AGAIN
Definition: SharedDefines.h:1081
@ SPELL_FAILED_NO_COMBO_POINTS
Definition: SharedDefines.h:1027
@ SPELL_FAILED_ALREADY_HAVE_SUMMON
Definition: SharedDefines.h:956
@ SPELL_FAILED_ALREADY_OPEN
Definition: SharedDefines.h:957
@ SPELL_FAILED_NOT_TRADING
Definition: SharedDefines.h:1020
@ SPELL_FAILED_NOTHING_TO_STEAL
Definition: SharedDefines.h:1036
@ SPELL_FAILED_NO_MOUNTS_ALLOWED
Definition: SharedDefines.h:1032
@ SPELL_FAILED_NOT_IN_BATTLEGROUND
Definition: SharedDefines.h:1115
@ SPELL_FAILED_NOT_BEHIND
Definition: SharedDefines.h:1006
@ SPELL_FAILED_ALREADY_HAVE_CHARM
Definition: SharedDefines.h:955
@ SPELL_FAILED_TARGET_NOT_IN_INSTANCE
Definition: SharedDefines.h:1086
@ SPELL_FAILED_HIGHLEVEL
Definition: SharedDefines.h:985
@ SPELL_FAILED_LOWLEVEL
Definition: SharedDefines.h:997
@ SPELL_FAILED_NOT_READY
Definition: SharedDefines.h:1016
@ SPELL_FAILED_ONLY_BATTLEGROUNDS
Definition: SharedDefines.h:1091
@ SPELL_FAILED_NOT_IN_ARENA
Definition: SharedDefines.h:1100
@ SPELL_FAILED_ITEM_ALREADY_ENCHANTED
Definition: SharedDefines.h:991
@ SPELL_FAILED_ONLY_STEALTHED
Definition: SharedDefines.h:1044
@ SPELL_FAILED_TARGET_IS_PLAYER_CONTROLLED
Definition: SharedDefines.h:1067
@ SPELL_FAILED_ONLY_ABOVEWATER
Definition: SharedDefines.h:1037
@ SPELL_FAILED_CANT_BE_CHARMED
Definition: SharedDefines.h:962
@ SPELL_FAILED_CASTER_DEAD
Definition: SharedDefines.h:972
@ SPELL_FAILED_NOT_ON_MOUNTED
Definition: SharedDefines.h:1104
@ SPELL_FAILED_ITEM_ENCHANT_TRADE_WINDOW
Definition: SharedDefines.h:1131
@ SPELL_FAILED_TARGET_CANNOT_BE_RESURRECTED
Definition: SharedDefines.h:1135
@ SPELL_FAILED_TARGET_UNSKINNABLE
Definition: SharedDefines.h:1075
@ SPELL_FAILED_NOT_SHAPESHIFT
Definition: SharedDefines.h:1017
@ SPELL_FAILED_UNIQUE_GLYPH
Definition: SharedDefines.h:1125
@ SPELL_FAILED_ONLY_OUTDOORS
Definition: SharedDefines.h:1042
@ SPELL_FAILED_CHARMED
Definition: SharedDefines.h:973
@ SPELL_FAILED_LINE_OF_SIGHT
Definition: SharedDefines.h:996
@ SPELL_FAILED_SPELL_IN_PROGRESS
Definition: SharedDefines.h:1054
@ SPELL_FAILED_NO_PET
Definition: SharedDefines.h:1033
@ SPELL_FAILED_NOPATH
Definition: SharedDefines.h:1005
@ SPELL_FAILED_SPELL_UNAVAILABLE
Definition: SharedDefines.h:1056
@ SPELL_FAILED_ONLY_INDOORS
Definition: SharedDefines.h:1039
@ SPELL_FAILED_NOT_ON_TAXI
Definition: SharedDefines.h:1014
@ SPELL_FAILED_TARGET_FRIENDLY
Definition: SharedDefines.h:1064
@ SPELL_ATTR4_IGNORE_DEFAULT_ARENA_RESTRICTIONS
Definition: SharedDefines.h:547
@ SPELL_ATTR4_NOT_IN_ARENA_OR_RATED_BATTLEGROUND
Definition: SharedDefines.h:546
@ SUMMON_CATEGORY_PET
Definition: SharedDefines.h:3285
@ SUMMON_CATEGORY_PUPPET
Definition: SharedDefines.h:3286
SkillType
Definition: SharedDefines.h:2863
@ SKILL_MINING
Definition: SharedDefines.h:2919
@ SKILL_HERBALISM
Definition: SharedDefines.h:2915
@ SPELL_ATTR6_ALLOW_WHILE_RIDING_VEHICLE
Definition: SharedDefines.h:616
@ VEHICLE_SEAT_FLAG_CAN_CAST_MOUNT_SPELL
Definition: DBCEnums.h:456
@ VEHICLE_SEAT_FLAG_UNCONTROLLED
Definition: DBCEnums.h:457
@ VEHICLE_SEAT_FLAG_CAN_ATTACK
Definition: DBCEnums.h:458
Difficulty
Definition: DBCEnums.h:266
@ AREA_FLAG_NO_FLY_ZONE
Definition: DBCEnums.h:262
bool IsPathfindingEnabled(const Map *map)
Definition: DisableMgr.cpp:411
Player * FindPlayer(ObjectGuid const guid)
Definition: ObjectAccessor.cpp:248
Seconds GetGameTime()
Definition: GameTime.cpp:38
Definition: Battlefield.h:206
bool CanFlyIn()
Return if we can use mount in battlefield.
Definition: Battlefield.h:342
Definition: Battleground.h:298
Definition: ConditionMgr.h:181
Condition * mLastFailedCondition
Definition: ConditionMgr.h:183
WorldObject * mConditionTargets[MAX_CONDITION_TARGETS]
Definition: ConditionMgr.h:182
uint32 ErrorType
Definition: ConditionMgr.h:204
uint8 ConditionTarget
Definition: ConditionMgr.h:208
uint32 ErrorTextId
Definition: ConditionMgr.h:205
Loot loot
Definition: Creature.h:227
CreatureTemplate const * GetCreatureTemplate() const
Definition: Creature.h:206
bool IsSpellProhibited(SpellSchoolMask idSchoolMask) const
Definition: Creature.cpp:2823
SkillType GetRequiredLootSkill() const
Definition: CreatureData.h:260
bool IsTameable(bool exotic) const
Definition: CreatureData.h:277
Definition: TemporarySummon.h:40
Definition: GameObject.h:121
GameObjectTemplate const * GetGOInfo() const
Definition: GameObject.h:137
uint32 type
Definition: GameObjectData.h:34
bool IsLocked() const
Definition: Item.h:253
ItemTemplate const * GetTemplate() const
Definition: Item.cpp:545
bool IsPotion() const
Definition: Item.h:337
uint32 ItemLevel
Definition: ItemTemplate.h:635
uint32 LockID
Definition: ItemTemplate.h:669
uint32 InventoryType
Definition: ItemTemplate.h:632
Unit * ToUnit()
Definition: Object.h:206
Map * GetMap() const
Definition: Object.h:531
InstanceScript * GetInstanceScript() const
Definition: Object.cpp:1192
bool IsWithinLOSInMap(WorldObject const *obj, VMAP::ModelIgnoreFlags ignoreFlags=VMAP::ModelIgnoreFlags::Nothing, LineOfSightChecks checks=LINEOFSIGHT_ALL_CHECKS, Optional< float > collisionHeight={ }, Optional< float > combatReach={ }) const
Definition: Object.cpp:1347
bool IsOutdoors() const
Definition: Object.cpp:3169
bool IsWithinLOS(float x, float y, float z, VMAP::ModelIgnoreFlags ignoreFlags=VMAP::ModelIgnoreFlags::Nothing, LineOfSightChecks checks=LINEOFSIGHT_ALL_CHECKS) const
Definition: Object.cpp:1326
float GetVisibilityRange() const
Definition: Object.cpp:1645
uint32 GetAreaId() const
Definition: Object.cpp:3152
uint32 GetZoneId() const
Definition: Object.cpp:3144
void GetZoneAndAreaId(uint32 &zoneid, uint32 &areaid) const
Definition: Object.cpp:3160
uint64 GetRawValue() const
Definition: ObjectGuid.h:142
bool IsPlayer() const
Definition: ObjectGuid.h:168
bool IsGameObject() const
Definition: ObjectGuid.h:171
void GetPosition(float &x, float &y) const
Definition: Position.h:122
uint32 GetMapId() const
Definition: Position.h:276
Player * GetOwner() const
Definition: Pet.cpp:2493
bool HaveInDiet(ItemTemplate const *item) const
Definition: Pet.cpp:1439
uint32 GetCurrentFoodBenefitLevel(uint32 itemlevel) const
Definition: Pet.cpp:1457
static std::pair< PetStable::PetInfo const *, PetSaveMode > GetLoadPetInfo(PetStable const &stable, uint32 petEntry, uint32 petnumber, bool current)
Definition: Pet.cpp:170
Definition: PetDefines.h:202
Optional< PetInfo > CurrentPet
Definition: PetDefines.h:225
std::vector< PetInfo > UnslottedPets
Definition: PetDefines.h:228
void SetCanTeleport(bool value)
Definition: Player.h:2478
bool IsInSameRaidWith(Player const *p) const
Definition: Player.h:1866
bool CanTameExoticPets() const
Definition: Player.h:2169
bool CanUseBattlegroundObject(GameObject *gameobject) const
Definition: Player.cpp:13218
bool InBattleground() const
Definition: Player.h:2232
PetStable * GetPetStable()
Definition: Player.h:1202
Battleground * GetBattleground(bool create=false) const
Definition: Player.cpp:12192
WorldSession * GetSession() const
Definition: Player.h:1978
bool HasSpellCooldown(uint32 spell_id) const override
Definition: Player.cpp:16334
uint32 GetLastPotionId()
Definition: Player.h:1792
Group * GetGroup()
Definition: Player.h:2448
bool IsGameMaster() const
Definition: Player.h:1158
time_t GetSummonExpireTimer() const
Definition: Player.h:1101
bool Satisfy(DungeonProgressionRequirements const *ar, uint32 target_map, bool report=false)
Definition: PlayerStorage.cpp:6711
bool HasPlayerFlag(PlayerFlags flags) const
Definition: Player.h:1108
std::unique_ptr< DuelInfo > duel
Definition: Player.h:1858
Item * GetItemByGuid(ObjectGuid guid) const
Definition: PlayerStorage.cpp:413
uint32 GetSpell() const
Definition: TradeData.h:49
bool IsVehicle() const
Definition: Unit.h:713
Vehicle * GetVehicle() const
Definition: Unit.h:1673
Unit * GetOwner() const
Definition: Unit.cpp:10562
Pet * ToPet()
Definition: Unit.h:1714
virtual bool HasSpellCooldown(uint32) const
Definition: Unit.h:1727
ShapeshiftForm GetShapeshiftForm() const
Definition: Unit.h:1463
virtual bool HasSpellItemCooldown(uint32, uint32) const
Definition: Unit.h:1728
bool IsInDisallowedMountForm() const
Definition: Unit.cpp:21201
void CombatStart(Unit *target, bool initialAggro=true)
Definition: Unit.cpp:13586
bool HasUnitFlag2(UnitFlags2 flags) const
Definition: Unit.h:688
bool IsInSanctuary() const
Definition: Unit.h:964
virtual bool IsClass(Classes unitClass, ClassContext context=CLASS_CONTEXT_NONE) const
Definition: Unit.h:748
AuraEffect * IsScriptOverriden(SpellInfo const *spell, int32 script) const
Definition: Unit.cpp:5780
float GetCombatReach() const override
Definition: Unit.h:770
UnitFlags GetUnitFlags() const
Definition: Unit.h:681
TempSummon * ToTempSummon()
Definition: Unit.h:1716
bool HasStealthAura() const
Definition: Unit.h:1103
bool HasAura(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, ObjectGuid itemCasterGUID=ObjectGuid::Empty, uint8 reqEffMask=0) const
Definition: Unit.cpp:5669
std::map< uint8, AuraApplication * > VisibleAuraMap
Definition: Unit.h:652
bool IsInFlight() const
Definition: Unit.h:1096
SpellImmuneList m_spellImmune[MAX_SPELL_IMMUNITY]
Definition: Unit.h:1794
void SendTameFailure(uint8 result)
Definition: Unit.cpp:19957
bool HasUnitMovementFlag(uint32 f) const
Definition: Unit.h:1613
virtual bool IsInWater() const
Definition: Unit.cpp:4321
bool HasAuraState(AuraStateType flag, SpellInfo const *spellProto=nullptr, Unit const *Caster=nullptr) const
Definition: Unit.cpp:10509
bool isMoving() const
Definition: Unit.h:1696
ObjectGuid GetCharmGUID() const
Definition: Unit.h:1218
VisibleAuraMap const * GetVisibleAuras()
Definition: Unit.h:1490
bool IsMounted() const
Definition: Unit.h:990
Unit * GetVictim() const
Definition: Unit.h:789
bool IsCritter() const
Definition: Unit.h:1094
ObjectGuid GetOwnerGUID() const
Definition: Unit.h:1210
uint8 GetComboPoints(Unit const *who=nullptr) const
--------—Combo point system----------------—
Definition: Unit.h:1629
ObjectGuid GetCharmerGUID() const
Definition: Unit.h:1216
uint32 getTransForm() const
Definition: Unit.h:1513
virtual bool HasActivePowerType(Powers power)
Definition: Unit.h:890
void RemoveMovementImpairingAuras(bool withRoot)
Definition: Unit.cpp:5205
bool IsTotem() const
Definition: Unit.h:712
Guardian * GetGuardianPet() const
Definition: Unit.cpp:10613
ObjectGuid GetTarget() const
Definition: Unit.h:1742
bool IsInCombat() const
Definition: Unit.h:820
ObjectGuid GetPetGUID() const
Definition: Unit.h:1220
Definition: Vehicle.h:28
VehicleSeatEntry const * GetSeatForPassenger(Unit const *passenger)
Definition: Vehicle.cpp:580
Definition: Group.h:169
Definition: GroupReference.h:27
GroupReference * next()
Definition: GroupReference.h:36
Definition: InstanceScript.h:142
bool isLooted() const
Definition: LootMgr.h:368
Definition: Map.h:274
bool AllowMount
Definition: Map.h:277
bool IsDungeon() const
Definition: Map.h:448
bool IsBattlegroundOrArena() const
Definition: Map.h:456
GameObject * GetGameObject(ObjectGuid const guid)
Definition: Map.cpp:3319
uint32 GetId() const
Definition: Map.h:379
Difficulty GetDifficulty() const
Definition: Map.h:443
uint32 GetRecruiterId() const
Definition: WorldSession.h:526
uint32 GetAccountId() const
Definition: WorldSession.h:361
GameObject * GetGOTarget() const
Definition: Spell.cpp:265
ObjectGuid GetItemTargetGUID() const
Definition: Spell.h:138
std::unique_ptr< PathGenerator > m_preGeneratedPath
Definition: Spell.h:776
SpellCastResult CheckSpellFocus()
Definition: Spell.cpp:7738
SpellCastResult CanOpenLock(uint32 effIndex, uint32 lockid, SkillType &skillid, int32 &reqSkillValue, int32 &skillValue)
Definition: Spell.cpp:8350
SpellCastResult CheckItems()
Definition: Spell.cpp:7170
int32 CalculateSpellDamage(uint8 i, Unit const *target) const
Definition: Spell.h:477
SpellCastResult CheckPower()
Definition: Spell.cpp:7125
SpellCastResult CheckCasterAuras(bool preventionOnly) const
Definition: Spell.cpp:6842
SpellCastResult CallScriptCheckCastHandlers()
Definition: Spell.cpp:8549
bool IsTriggered() const
Definition: Spell.h:552
SpellCastResult CheckRange(bool strict)
Definition: Spell.cpp:7039
bool HasGlobalCooldown() const
Definition: Spell.cpp:8821
Definition: SpellInfo.h:249
int32 MiscValue
Definition: SpellInfo.h:263
uint32 ApplyAuraName
Definition: SpellInfo.h:254
uint32 PreventionType
Definition: SpellInfo.h:390
uint32 CasterAuraSpell
Definition: SpellInfo.h:343
SpellCastResult CheckShapeshift(uint32 form) const
Definition: SpellInfo.cpp:1433
uint32 Mechanic
Definition: SpellInfo.h:323
uint32 GetDispelMask() const
Definition: SpellInfo.cpp:2040
uint32 GetRecoveryTime() const
Definition: SpellInfo.cpp:2395
bool IsSelfCast() const
Definition: SpellInfo.cpp:1089
uint32 CasterAuraState
Definition: SpellInfo.h:339
bool CanBeUsedInCombat() const
Definition: SpellInfo.cpp:1231
uint32 CasterAuraStateNot
Definition: SpellInfo.h:341
SpellCastResult CheckLocation(uint32 map_id, uint32 zone_id, uint32 area_id, Player *player=nullptr, bool strict=true) const
Definition: SpellInfo.cpp:1488
SpellSchoolMask GetSchoolMask() const
Definition: SpellInfo.cpp:1986
int32 AreaGroupId
Definition: SpellInfo.h:391
float GetMaxRange(bool positive=false, Unit *caster=nullptr, Spell *spell=nullptr) const
Definition: SpellInfo.cpp:2322
uint32 GetExplicitTargetMask() const
Definition: SpellInfo.cpp:2054
bool NeedsExplicitUnitTarget() const
Definition: SpellInfo.cpp:1032
uint32 ExcludeCasterAuraSpell
Definition: SpellInfo.h:345
uint32 SpellFamilyName
Definition: SpellInfo.h:387
uint32 AuraInterruptFlags
Definition: SpellInfo.h:353
SpellCastResult CheckExplicitTarget(Unit const *caster, WorldObject const *target, Item const *itemTarget=nullptr) const
Definition: SpellInfo.cpp:1936
Definition: DBCStructure.h:519
Definition: DBCStructure.h:1021
Definition: DBCStructure.h:1325
bool IsDungeon() const
Definition: DBCStructure.h:1351
Definition: DBCStructure.h:1817
uint32 flags1
Definition: DBCStructure.h:1822
Definition: DBCStructure.h:1909
uint32 Category
Definition: DBCStructure.h:1911
Definition: DBCStructure.h:2064
uint32 m_flags
Definition: DBCStructure.h:2066

References InstanceTemplate::AllowMount, SpellEffectInfo::ApplyAuraName, AREA_FLAG_NO_FLY_ZONE, SpellInfo::AreaGroupId, AURA_INTERRUPT_FLAG_MOUNT, AURA_INTERRUPT_FLAG_NOT_SEATED, SpellInfo::AuraInterruptFlags, CalculateSpellDamage(), CallScriptCheckCastHandlers(), SpellInfo::CanBeUsedInCombat(), Battlefield::CanFlyIn(), CanOpenLock(), Player::CanTameExoticPets(), Player::CanUseBattlegroundObject(), SpellInfo::CasterAuraSpell, SpellInfo::CasterAuraState, SpellInfo::CasterAuraStateNot, SummonPropertiesEntry::Category, CheckCasterAuras(), SpellInfo::CheckExplicitTarget(), CheckItems(), SpellInfo::CheckLocation(), CheckPower(), CheckRange(), SpellInfo::CheckShapeshift(), CheckSpellFocus(), SpellInfo::CheckTarget(), CLASS_CONTEXT_PET, CLASS_WARLOCK, Unit::CombatStart(), CONDITION_SOURCE_TYPE_SPELL, Condition::ConditionTarget, PetStable::CurrentPet, damage, Player::duel, EFFECT_0, SpellInfo::Effects, Condition::ErrorTextId, Condition::ErrorType, SpellInfo::ExcludeCasterAuraSpell, WorldObject::FindMap(), ObjectAccessor::FindPlayer(), SpellShapeshiftFormEntry::flags1, GAMEOBJECT_TYPE_DOOR, GAMEOBJECT_TYPE_TRAP, WorldSession::GetAccountId(), WorldObject::GetAreaId(), Unit::GetAuraEffectsByType(), Player::GetBattleground(), Unit::GetCharm(), Unit::GetCharmerGUID(), Unit::GetCharmGUID(), Unit::GetCombatReach(), Unit::GetComboPoints(), Creature::GetCreatureTemplate(), Pet::GetCurrentFoodBenefitLevel(), Map::GetDifficulty(), SpellInfo::GetDispelMask(), WorldObject::GetDistance(), SpellCastTargets::GetDstPos(), Object::GetEntry(), SpellInfo::GetExplicitTargetMask(), Map::GetGameObject(), GameTime::GetGameTime(), GameObject::GetGOInfo(), SpellCastTargets::GetGOTarget(), Player::GetGroup(), Unit::GetGuardianPet(), Map::GetId(), WorldObject::GetInstanceScript(), Player::GetItemByGuid(), SpellCastTargets::GetItemTarget(), SpellCastTargets::GetItemTargetGUID(), Player::GetLastPotionId(), Unit::GetLevel(), Pet::GetLoadPetInfo(), WorldObject::GetMap(), WorldLocation::GetMapId(), SpellInfo::GetMaxRange(), SpellCastTargets::GetObjectTarget(), Pet::GetOwner(), Player::GetPet(), Unit::GetPetGUID(), Player::GetPetStable(), Position::GetPosition(), Position::GetPositionX(), Position::GetPositionY(), Position::GetPositionZ(), ObjectGuid::GetRawValue(), SpellInfo::GetRecoveryTime(), WorldSession::GetRecruiterId(), CreatureTemplate::GetRequiredLootSkill(), SpellInfo::GetSchoolMask(), Vehicle::GetSeatForPassenger(), Player::GetSession(), Unit::GetShapeshiftForm(), Player::GetSkillValue(), TradeData::GetSpell(), Player::GetSummonExpireTimer(), Unit::GetTarget(), SpellCastTargets::GetTargetMask(), Item::GetTemplate(), Player::GetTradeData(), Unit::getTransForm(), Unit::GetUnitFlags(), SpellCastTargets::GetUnitTarget(), Unit::GetVehicle(), Unit::GetVictim(), WorldObject::GetVisibilityRange(), Unit::GetVisibleAuras(), WorldObject::GetZoneAndAreaId(), WorldObject::GetZoneId(), GO_STATE_READY, Unit::HasActivePowerType(), SpellInfo::HasAttribute(), SpellInfo::HasAura(), Unit::HasAura(), Unit::HasAuraState(), SpellCastTargets::HasDst(), SpellInfo::HasEffect(), HasGlobalCooldown(), Player::HasPlayerFlag(), Player::HasSpellCooldown(), Unit::HasSpellCooldown(), Unit::HasSpellItemCooldown(), Unit::HasStealthAura(), HasTriggeredCastFlag(), Unit::HasUnitFlag2(), Unit::HasUnitMovementFlag(), Unit::HasUnitState(), Pet::HaveInDiet(), HUNTER_PET, SpellInfo::Id, IMMUNITY_MECHANIC, IN_MILLISECONDS, Player::InBattleground(), ItemTemplate::InventoryType, INVTYPE_RELIC, irand(), Unit::IsAlive(), IsAutoRepeat(), Map::IsBattlegroundOrArena(), Unit::IsClass(), SpellInfo::IsCooldownStartedOnEvent(), Object::IsCreature(), Unit::IsCritter(), Map::IsDungeon(), MapEntry::IsDungeon(), Unit::IsFriendlyTo(), Player::IsGameMaster(), ObjectGuid::IsGameObject(), Unit::IsInCombat(), Unit::IsInDisallowedMountForm(), Unit::IsInFlight(), Player::IsInSameRaidWith(), Unit::IsInSanctuary(), Unit::IsInWater(), Item::IsLocked(), Loot::isLooted(), Unit::IsMounted(), Unit::isMoving(), IsNextMeleeSwingSpell(), WorldObject::IsOutdoors(), SpellInfo::IsPassive(), DisableMgr::IsPathfindingEnabled(), Object::IsPlayer(), SpellInfo::IsPositive(), Item::IsPotion(), Unit::IsScriptOverriden(), SpellInfo::IsSelfCast(), Creature::IsSpellProhibited(), CreatureTemplate::IsTameable(), Unit::IsTotem(), IsTriggered(), WorldObject::IsWithinLOS(), WorldObject::IsWithinLOSInMap(), ItemTemplate::ItemLevel, LINEOFSIGHT_ALL_CHECKS, ItemTemplate::LockID, Creature::loot, VMAP::M2, m_caster, m_CastItem, m_customError, VehicleSeatEntry::m_flags, m_needComboPoints, m_originalCaster, m_originalCasterGUID, m_preGeneratedPath, m_selfContainer, m_spellFlags, Unit::m_spellImmune, m_spellInfo, m_targets, m_triggeredByAuraSpell, MAX_SPELL_EFFECTS, ConditionSourceInfo::mConditionTargets, SpellInfo::Mechanic, MINUTE, SpellEffectInfo::MiscValue, ConditionSourceInfo::mLastFailedCondition, MOVEMENTFLAG_FALLING_FAR, SpellInfo::NeedsExplicitUnitTarget(), GroupReference::next(), PATHFIND_INCOMPLETE, PATHFIND_NOPATH, PATHFIND_SHORT, PET_TAME_CANT_CONTROL_EXOTIC, PET_TAME_DEAD, PET_TAME_NOPET_AVAILABLE, PLAYER_ALLOW_ONLY_ABILITY, POWER_MANA, SpellInfo::PreventionType, Unit::RemoveMovementImpairingAuras(), sAreaTableStore, Player::Satisfy(), sBattlefieldMgr, sConditionMgr, Unit::SendTameFailure(), sGlyphPropertiesStore, SKILL_HERBALISM, SKILL_LOCKPICKING, SKILL_MINING, SKILL_NONE, sMapStore, sObjectMgr, SPECTATOR_SPELL_BINDSIGHT, SPELL_ATTR0_ALLOW_CAST_WHILE_DEAD, SPELL_ATTR0_ALLOW_WHILE_MOUNTED, SPELL_ATTR0_AURA_IS_DEBUFF, SPELL_ATTR0_CU_REQ_CASTER_BEHIND_TARGET, SPELL_ATTR0_CU_REQ_TARGET_FACING_CASTER, SPELL_ATTR0_NO_IMMUNITIES, SPELL_ATTR0_ONLY_INDOORS, SPELL_ATTR0_ONLY_OUTDOORS, SPELL_ATTR0_ONLY_STEALTHED, SPELL_ATTR0_PASSIVE, SPELL_ATTR1_DISMISS_PET_FIRST, SPELL_ATTR1_INITIATE_COMBAT, SPELL_ATTR2_IGNORE_LINE_OF_SIGHT, SPELL_ATTR3_ONLY_BATTLEGROUNDS, SPELL_ATTR4_IGNORE_DEFAULT_ARENA_RESTRICTIONS, SPELL_ATTR4_NOT_IN_ARENA_OR_RATED_BATTLEGROUND, SPELL_ATTR5_ALWAYS_AOE_LINE_OF_SIGHT, SPELL_ATTR6_ALLOW_WHILE_RIDING_VEHICLE, SPELL_ATTR7_DEBUG_SPELL, SPELL_AURA_ABILITY_IGNORE_AURASTATE, SPELL_AURA_AOE_CHARM, SPELL_AURA_BLOCK_SPELL_FAMILY, SPELL_AURA_DUMMY, SPELL_AURA_FLY, SPELL_AURA_HOVER, SPELL_AURA_MOD_CHARM, SPELL_AURA_MOD_IGNORE_SHAPESHIFT, SPELL_AURA_MOD_INCREASE_MOUNTED_FLIGHT_SPEED, SPELL_AURA_MOD_POSSESS, SPELL_AURA_MOD_POSSESS_PET, SPELL_AURA_MOD_SHAPESHIFT, SPELL_AURA_MOUNTED, SPELL_AURA_PERIODIC_MANA_LEECH, SPELL_AURA_RANGED_ATTACK_POWER_ATTACKER_BONUS, SPELL_CAST_OK, SPELL_CUSTOM_ERROR_GM_ONLY, SPELL_EFFECT_APPLY_GLYPH, SPELL_EFFECT_CHARGE, SPELL_EFFECT_CREATE_TAMED_PET, SPELL_EFFECT_DISPEL, SPELL_EFFECT_FEED_PET, SPELL_EFFECT_JUMP, SPELL_EFFECT_JUMP_DEST, SPELL_EFFECT_LEAP, SPELL_EFFECT_LEAP_BACK, SPELL_EFFECT_LEARN_PET_SPELL, SPELL_EFFECT_LEARN_SPELL, SPELL_EFFECT_OPEN_LOCK, SPELL_EFFECT_POWER_BURN, SPELL_EFFECT_POWER_DRAIN, SPELL_EFFECT_RESURRECT, SPELL_EFFECT_RESURRECT_NEW, SPELL_EFFECT_RESURRECT_PET, SPELL_EFFECT_SKINNING, SPELL_EFFECT_STEAL_BENEFICIAL_BUFF, SPELL_EFFECT_STUCK, SPELL_EFFECT_SUMMON, SPELL_EFFECT_SUMMON_PET, SPELL_EFFECT_SUMMON_PLAYER, SPELL_EFFECT_SUMMON_RAF_FRIEND, SPELL_EFFECT_TALENT_SPEC_SELECT, SPELL_EFFECT_TELEPORT_UNITS_FACE_CASTER, SPELL_FAILED_AFFECTING_COMBAT, SPELL_FAILED_ALREADY_HAVE_CHARM, SPELL_FAILED_ALREADY_HAVE_SUMMON, SPELL_FAILED_ALREADY_OPEN, SPELL_FAILED_BAD_IMPLICIT_TARGETS, SPELL_FAILED_BAD_TARGETS, SPELL_FAILED_CANT_BE_CHARMED, SPELL_FAILED_CASTER_AURASTATE, SPELL_FAILED_CASTER_DEAD, SPELL_FAILED_CHARMED, SPELL_FAILED_CUSTOM_ERROR, SPELL_FAILED_DAMAGE_IMMUNE, SPELL_FAILED_DONT_REPORT, SPELL_FAILED_FOOD_LOWLEVEL, SPELL_FAILED_HIGHLEVEL, SPELL_FAILED_ITEM_ALREADY_ENCHANTED, SPELL_FAILED_ITEM_ENCHANT_TRADE_WINDOW, SPELL_FAILED_LINE_OF_SIGHT, SPELL_FAILED_LOW_CASTLEVEL, SPELL_FAILED_LOWLEVEL, SPELL_FAILED_MOVING, SPELL_FAILED_NO_COMBO_POINTS, SPELL_FAILED_NO_MOUNTS_ALLOWED, SPELL_FAILED_NO_PET, SPELL_FAILED_NOPATH, SPELL_FAILED_NOT_BEHIND, SPELL_FAILED_NOT_HERE, SPELL_FAILED_NOT_IN_ARENA, SPELL_FAILED_NOT_IN_BATTLEGROUND, SPELL_FAILED_NOT_INFRONT, SPELL_FAILED_NOT_KNOWN, SPELL_FAILED_NOT_MOUNTED, SPELL_FAILED_NOT_ON_MOUNTED, SPELL_FAILED_NOT_ON_TAXI, SPELL_FAILED_NOT_READY, SPELL_FAILED_NOT_SHAPESHIFT, SPELL_FAILED_NOT_TRADING, SPELL_FAILED_NOTHING_TO_DISPEL, SPELL_FAILED_NOTHING_TO_STEAL, SPELL_FAILED_ONLY_ABOVEWATER, SPELL_FAILED_ONLY_BATTLEGROUNDS, SPELL_FAILED_ONLY_INDOORS, SPELL_FAILED_ONLY_OUTDOORS, SPELL_FAILED_ONLY_STEALTHED, SPELL_FAILED_ROOTED, SPELL_FAILED_SPELL_IN_PROGRESS, SPELL_FAILED_SPELL_UNAVAILABLE, SPELL_FAILED_SUMMON_PENDING, SPELL_FAILED_TARGET_CANNOT_BE_RESURRECTED, SPELL_FAILED_TARGET_FRIENDLY, SPELL_FAILED_TARGET_IS_PLAYER_CONTROLLED, SPELL_FAILED_TARGET_NOT_IN_INSTANCE, SPELL_FAILED_TARGET_NOT_LOOTED, SPELL_FAILED_TARGET_UNSKINNABLE, SPELL_FAILED_TRY_AGAIN, SPELL_FAILED_UNIQUE_GLYPH, SPELL_FAILED_WRONG_PET_FOOD, SPELL_FLAG_REDIRECTED, SPELL_PREVENTION_TYPE_NONE, SPELL_RELIC_COOLDOWN, SPELLFAMILY_WARRIOR, SpellInfo::SpellFamilyName, TriggeredByAuraSpellData::spellInfo, SpellInfo::SpellLevel, sScriptMgr, sSpellMgr, sSpellShapeshiftFormStore, sSummonPropertiesStore, STATUS_IN_PROGRESS, STATUS_WAIT_LEAVE, SUMMON_CATEGORY_PET, SUMMON_CATEGORY_PUPPET, TARGET_FLAG_ITEM, TARGET_FLAG_TRADE_ITEM, TARGET_FLAG_UNIT_ENEMY, TARGET_GAMEOBJECT_ITEM_TARGET, TARGET_GAMEOBJECT_TARGET, TARGET_UNIT_PET, Object::ToCreature(), Unit::ToPet(), Object::ToPlayer(), Unit::ToTempSummon(), Object::ToUnit(), TRADE_SLOT_NONTRADED, TRIGGERED_IGNORE_CASTER_AURAS, TRIGGERED_IGNORE_CASTER_AURASTATE, TRIGGERED_IGNORE_CASTER_MOUNTED_OR_ON_VEHICLE, TRIGGERED_IGNORE_EFFECTS, TRIGGERED_IGNORE_GCD, TRIGGERED_IGNORE_POWER_AND_REAGENT_COST, TRIGGERED_IGNORE_SHAPESHIFT, TRIGGERED_IGNORE_SPELL_AND_CATEGORY_CD, GameObjectTemplate::type, UNIT_FLAG2_ALLOW_CHEAT_SPELLS, UNIT_FLAG_SKINNABLE, UNIT_STATE_CHARGING, UNIT_STATE_ROOT, unitTarget, PetStable::UnslottedPets, VEHICLE_SEAT_FLAG_CAN_ATTACK, VEHICLE_SEAT_FLAG_CAN_CAST_MOUNT_SPELL, VEHICLE_SEAT_FLAG_UNCONTROLLED, and WORLD_TRIGGER.

Referenced by _cast(), Unit::_UpdateAutoRepeatSpell(), Unit::AttackerStateUpdate(), Player::CastItemUseSpell(), CheckPetCast(), WorldSession::HandleAcceptTradeOpcode(), prepare(), and go_wind_stone::go_wind_stoneAI::SummonNPC().

◆ CheckCasterAuras()

SpellCastResult Spell::CheckCasterAuras ( bool  preventionOnly) const
6843{
6844 // spells totally immuned to caster auras (wsg flag drop, give marks etc)
6846 return SPELL_CAST_OK;
6847
6848 uint8 school_immune = 0;
6849 uint32 mechanic_immune = 0;
6850 uint32 dispel_immune = 0;
6851
6852 // Check if the spell grants school or mechanic immunity.
6853 // We use bitmasks so the loop is done only once and not on every aura check below.
6855 {
6856 for (int i = 0; i < MAX_SPELL_EFFECTS; ++i)
6857 {
6858 if (m_spellInfo->Effects[i].ApplyAuraName == SPELL_AURA_SCHOOL_IMMUNITY)
6859 school_immune |= uint32(m_spellInfo->Effects[i].MiscValue);
6860 else if (m_spellInfo->Effects[i].ApplyAuraName == SPELL_AURA_MECHANIC_IMMUNITY)
6861 mechanic_immune |= 1 << uint32(m_spellInfo->Effects[i].MiscValue);
6862 else if (m_spellInfo->Effects[i].ApplyAuraName == SPELL_AURA_DISPEL_IMMUNITY)
6863 dispel_immune |= SpellInfo::GetDispelMask(DispelType(m_spellInfo->Effects[i].MiscValue));
6864 }
6865 // immune movement impairment and loss of control
6866 // PVP trinket EMFH TOC PVP trinket Bullheaded Bestial Wrath // Beath Within // Medalion of Immunity
6867 if (m_spellInfo->Id == 42292 || m_spellInfo->Id == 59752 || m_spellInfo->Id == 65547 || m_spellInfo->Id == 53490 || m_spellInfo->Id == 19574 || m_spellInfo->Id == 34471 || m_spellInfo->Id == 46227)
6869 }
6870
6872
6873 // Glyph of Pain Suppression
6874 // there is no other way to handle it
6875 if (m_spellInfo->