TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Spell Class Reference

#include <Spell.h>

Classes

struct  GOTargetInfo
 
struct  HitTriggerSpell
 
struct  ItemTargetInfo
 
struct  TargetInfo
 

Public Types

typedef std::set< Aura * > UsedSpellMods
 

Public Member Functions

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 EffectPlayMovie (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 EffectChangeRaidMarker (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 EffectUnlockGuildVaultTab (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 EffectDamageFromMaxHealthPCT (SpellEffIndex effIndex)
 
void EffectCastButtons (SpellEffIndex effIndex)
 
void EffectRechargeManaGem (SpellEffIndex effIndex)
 
void EffectGiveCurrency (SpellEffIndex effIndex)
 
void EffectResurrectWithAura (SpellEffIndex effIndex)
 
void EffectCreateAreaTrigger (SpellEffIndex effIndex)
 
void EffectRemoveTalent (SpellEffIndex effIndex)
 
void EffectDestroyItem (SpellEffIndex effIndex)
 
void EffectLearnGarrisonBuilding (SpellEffIndex effIndex)
 
void EffectCreateGarrison (SpellEffIndex effIndex)
 
void EffectAddGarrisonFollower (SpellEffIndex effIndex)
 
void EffectActivateGarrisonBuilding (SpellEffIndex effIndex)
 
void EffectHealBattlePetPct (SpellEffIndex effIndex)
 
void EffectEnableBattlePets (SpellEffIndex effIndex)
 
void EffectUncageBattlePet (SpellEffIndex effIndex)
 
void EffectCreateHeirloomItem (SpellEffIndex effIndex)
 
void EffectUpgradeHeirloom (SpellEffIndex effIndex)
 
 Spell (Unit *caster, SpellInfo const *info, TriggerCastFlags triggerFlags, ObjectGuid originalCasterGUID=ObjectGuid::Empty, bool skipCheck=false)
 
 ~Spell ()
 
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)
 
void SelectEffectTypeImplicitTargets (uint32 effIndex)
 
uint32 GetSearcherTypeMask (SpellTargetObjectTypes objType, ConditionContainer *condList)
 
template<class SEARCHER >
void SearchTargets (SEARCHER &searcher, uint32 containerMask, Unit *referer, Position const *pos, float radius)
 
WorldObjectSearchNearbyTarget (float range, SpellTargetObjectTypes objectType, SpellTargetCheckTypes selectionType, ConditionContainer *condList=NULL)
 
void SearchAreaTargets (std::list< WorldObject * > &targets, float range, Position const *position, Unit *referer, SpellTargetObjectTypes objectType, SpellTargetCheckTypes selectionType, ConditionContainer *condList)
 
void SearchChainTargets (std::list< WorldObject * > &targets, uint32 chainTargets, WorldObject *target, SpellTargetObjectTypes objectType, SpellTargetCheckTypes selectType, ConditionContainer *condList, bool isChainHeal)
 
GameObjectSearchSpellFocus ()
 
void prepare (SpellCastTargets const *targets, AuraEffect const *triggeredByAura=NULL)
 
void cancel ()
 
void update (uint32 difftime)
 
void cast (bool skipCheck=false)
 
void finish (bool ok=true)
 
void TakePower ()
 
void TakeRunePower (bool didHit)
 
void TakeReagents ()
 
void TakeCastItem ()
 
SpellCastResult CheckCast (bool strict)
 
SpellCastResult CheckPetCast (Unit *target)
 
void handle_immediate ()
 
uint64 handle_delayed (uint64 t_offset)
 
void _handle_immediate_phase ()
 
void _handle_finish_phase ()
 
SpellCastResult CheckItems ()
 
SpellCastResult CheckRange (bool strict)
 
SpellCastResult CheckPower ()
 
SpellCastResult CheckRuneCost (uint32 runeCostID)
 
SpellCastResult CheckCasterAuras () const
 
SpellCastResult CheckArenaAndRatedBattlegroundCastRules ()
 
int32 CalculateDamage (uint8 i, Unit const *target, float *var=nullptr) const
 
bool HaveTargetsForEffect (uint8 effect) const
 
void Delayed ()
 
void DelayedChannel ()
 
uint32 getState () const
 
void setState (uint32 state)
 
void DoCreateItem (uint32 i, uint32 itemtype, std::vector< int32 > const &bonusListIDs=std::vector< int32 >())
 
bool CheckEffectTarget (Unit const *target, SpellEffectInfo const *effect, Position const *losPosition) const
 
bool CheckEffectTarget (GameObject const *target, SpellEffectInfo const *effect) const
 
bool CheckEffectTarget (Item const *target, SpellEffectInfo const *effect) const
 
bool CanAutoCast (Unit *target)
 
void CheckSrc ()
 
void CheckDst ()
 
void SendCastResult (SpellCastResult result)
 
void SendPetCastResult (SpellCastResult result)
 
void SendSpellStart ()
 
void SendSpellGo ()
 
void SendSpellCooldown ()
 
void SendSpellExecuteLog ()
 
void ExecuteLogEffectTakeTargetPower (uint8 effIndex, Unit *target, uint32 powerType, uint32 points, float amplitude)
 
void ExecuteLogEffectExtraAttacks (uint8 effIndex, Unit *victim, uint32 numAttacks)
 
void ExecuteLogEffectInterruptCast (uint8 effIndex, Unit *victim, uint32 spellId)
 
void ExecuteLogEffectDurabilityDamage (uint8 effIndex, Unit *victim, int32 itemId, int32 amount)
 
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 CleanupExecuteLogList ()
 
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 ()
 
int32 GetCastTime () const
 
bool IsAutoRepeat () const
 
void SetAutoRepeat (bool rep)
 
void ReSetTimer ()
 
bool IsNextMeleeSwingSpell () const
 
bool IsTriggered () const
 
bool IsIgnoringCooldowns () const
 
bool IsChannelActive () const
 
bool IsAutoActionResetSpell () 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
 
bool IsNeedSendToClient () const
 
CurrentSpellTypes GetCurrentContainer () const
 
UnitGetCaster () const
 
UnitGetOriginalCaster () const
 
SpellInfo constGetSpellInfo () const
 
std::vector< SpellInfo::CostDataGetPowerCost () const
 
bool UpdatePointers ()
 
void CleanupTargetList ()
 
void SetSpellValue (SpellValueMod mod, int32 value)
 
SpellEffectInfoVector constGetEffects () const
 
SpellEffectInfo constGetEffect (uint32 index) const
 
bool HasEffect (SpellEffectName effect) const
 
SpellInfo constGetTriggeredByAuraSpell () const
 
int32 GetTimer () const
 

Static Public Member Functions

static void SendCastResult (Player *caster, SpellInfo const *spellInfo, uint8 cast_count, SpellCastResult result, SpellCustomErrors customError=SPELL_CUSTOM_ERROR_NONE, OpcodeServer opcode=SMSG_CAST_FAILED, uint32 *misc=nullptr)
 

Public Attributes

SpellInfo const *const m_spellInfo
 
Itemm_CastItem
 
ObjectGuid m_castItemGUID
 
uint32 m_castItemEntry
 
int32 m_castItemLevel
 
uint8 m_cast_count
 
uint32 m_castFlagsEx
 
union {
   uint32   TalentId
 
   uint32   GlyphSlot
 
   struct {
      uint32   Id
 
      uint32   AbilityId
 
   }   GarrFollower
 
   uint32   GarrMissionId
 
   uint32   ItemId
 
   struct {
      uint32   Data [2]
 
   }   Raw
 
m_misc
 
uint32 m_SpellVisual
 
uint32 m_preCastSpell
 
SpellCastTargets m_targets
 
int8 m_comboPointGain
 
SpellCustomErrors m_customError
 
UsedSpellMods m_appliedMods
 
Spell ** m_selfContainer
 

Protected Types

typedef std::list
< HitTriggerSpell
HitTriggerSpellList
 

Protected Member Functions

bool HasGlobalCooldown () const
 
void TriggerGlobalCooldown ()
 
void CancelGlobalCooldown ()
 
void SendLoot (ObjectGuid guid, LootType loottype)
 
bool isDelayableNoMore ()
 
void prepareDataForTriggerSystem (AuraEffect const *triggeredByAura)
 
void AddUnitTarget (Unit *target, uint32 effectMask, bool checkIfValid=true, bool implicit=true, Position const *losPosition=nullptr)
 
void AddGOTarget (GameObject *target, uint32 effectMask)
 
void AddItemTarget (Item *item, uint32 effectMask)
 
void AddDestTarget (SpellDestination const &dest, uint32 effIndex)
 
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 LoadScripts ()
 
void CallScriptBeforeCastHandlers ()
 
void CallScriptOnCastHandlers ()
 
void CallScriptAfterCastHandlers ()
 
SpellCastResult CallScriptCheckCastHandlers ()
 
void PrepareScriptHitHandlers ()
 
bool CallScriptEffectHandlers (SpellEffIndex effIndex, SpellEffectHandleMode mode)
 
void CallScriptSuccessfulDispel (SpellEffIndex effIndex)
 
void CallScriptBeforeHitHandlers ()
 
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=NULL) const
 
void PrepareTriggersExecutedOnHit ()
 
void SummonGuardian (uint32 i, uint32 entry, SummonPropertiesEntry const *properties, uint32 numSummons)
 
void CalculateJumpSpeeds (SpellEffectInfo const *effInfo, float dist, float &speedxy, float &speedz)
 
void UpdateSpellCastDataTargets (WorldPackets::Spells::SpellCastData &data)
 Writes miss and hit targets for a SMSG_SPELL_GO packet. More...
 
SpellCastResult CanOpenLock (uint32 effIndex, uint32 lockid, SkillType &skillid, int32 &reqSkillValue, int32 &skillValue)
 
 Spell (Spell const &right)=delete
 
Spelloperator= (Spell const &right)=delete
 

Protected Attributes

Unit *const m_caster
 
SpellValue *const m_spellValue
 
ObjectGuid m_originalCasterGUID
 
Unitm_originalCaster
 
SpellSchoolMask m_spellSchoolMask
 
WeaponAttackType m_attackType
 
std::vector< SpellInfo::CostDatam_powerCost
 
int32 m_casttime
 
int32 m_channeledDuration
 
bool m_canReflect
 
bool m_autoRepeat
 
bool m_isDelayedInstantCast
 
uint8 m_runesState
 
uint8 m_delayAtDamageCount
 
uint64 m_delayStart
 
uint64 m_delayMoment
 
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
 
float variance
 
SpellEffectHandleMode effectHandleMode
 
SpellEffectInfo consteffectInfo
 
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::vector< TargetInfom_UniqueTargetInfo
 
uint32 m_channelTargetEffectMask
 
std::vector< GOTargetInfom_UniqueGOTargetInfo
 
std::vector< ItemTargetInfom_UniqueItemInfo
 
SpellDestination m_destTargets [MAX_SPELL_EFFECTS]
 
std::list< SpellScript * > m_loadedScripts
 
HitTriggerSpellList m_hitTriggerSpells
 
uint32 m_spellState
 
int32 m_timer
 
TriggerCastFlags _triggeredCastFlags
 
SpellInfo constm_triggeredByAuraSpell
 
bool m_skipCheck
 
uint32 m_auraScaleMask
 
PathGenerator m_preGeneratedPath
 
std::vector
< SpellLogEffectPowerDrainParams
_powerDrainTargets [MAX_SPELL_EFFECTS]
 
std::vector
< SpellLogEffectExtraAttacksParams
_extraAttacksTargets [MAX_SPELL_EFFECTS]
 
std::vector
< SpellLogEffectDurabilityDamageParams
_durabilityDamageTargets [MAX_SPELL_EFFECTS]
 
std::vector
< SpellLogEffectGenericVictimParams
_genericVictimTargets [MAX_SPELL_EFFECTS]
 
std::vector
< SpellLogEffectTradeSkillItemParams
_tradeSkillTargets [MAX_SPELL_EFFECTS]
 
std::vector
< SpellLogEffectFeedPetParams
_feedPetTargets [MAX_SPELL_EFFECTS]
 
SpellEffectInfoVector _effects
 

Friends

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

Member Typedef Documentation

typedef std::list<HitTriggerSpell> Spell::HitTriggerSpellList
protected
typedef std::set<Aura*> Spell::UsedSpellMods

Constructor & Destructor Documentation

Spell::Spell ( Unit caster,
SpellInfo const info,
TriggerCastFlags  triggerFlags,
ObjectGuid  originalCasterGUID = ObjectGuid::Empty,
bool  skipCheck = false 
)
502  :
503 m_spellInfo(info), m_caster((info->HasAttribute(SPELL_ATTR6_CAST_BY_CHARMER) && caster->GetCharmerOrOwner()) ? caster->GetCharmerOrOwner() : caster),
505 {
506  _effects = info->GetEffectsForDifficulty(caster->GetMap()->GetDifficultyID());
507 
509  m_skipCheck = skipCheck;
512  m_executedCurrently = false;
514  m_comboPointGain = 0;
515  m_delayStart = 0;
517 
519  m_auraScaleMask = 0;
520  memset(m_damageMultipliers, 0, sizeof(m_damageMultipliers));
521 
522  // Get data for type of attack
523  switch (m_spellInfo->DmgClass)
524  {
528  else
530  break;
533  break;
534  default:
535  // Wands
538  else
540  break;
541  }
542 
543  m_spellSchoolMask = info->GetSchoolMask(); // Can be override for some spell (wand shoot for example)
544 
546  // wand case
548  if (Item* pItem = m_caster->ToPlayer()->GetWeaponForAttack(RANGED_ATTACK))
549  m_spellSchoolMask = SpellSchoolMask(1 << pItem->GetTemplate()->GetDamageType());
550 
551  if (!originalCasterGUID.IsEmpty())
552  m_originalCasterGUID = originalCasterGUID;
553  else
555 
558  else
559  {
563  }
564 
566  _triggeredCastFlags = triggerFlags;
567  if (info->HasAttribute(SPELL_ATTR4_CAN_CAST_WHILE_CASTING))
569 
570  m_CastItem = NULL;
572  m_castItemEntry = 0;
573  m_castItemLevel = -1;
574  m_castFlagsEx = 0;
575 
576  unitTarget = NULL;
577  itemTarget = NULL;
579  destTarget = NULL;
580  damage = 0;
581  variance = 0.0f;
583  effectInfo = nullptr;
586  m_damage = 0;
587  m_healing = 0;
588  m_procAttacker = 0;
589  m_procVictim = 0;
590  m_procEx = 0;
591  focusObject = NULL;
592  m_cast_count = 0;
593  memset(m_misc.Raw.Data, 0, sizeof(m_misc.Raw.Data));
595  m_preCastSpell = 0;
597  m_spellAura = NULL;
598 
599  //Auto Shot & Shoot (wand)
601 
602  m_isDelayedInstantCast = false;
603 
604  m_runesState = 0;
605  m_casttime = 0; // setup to correct value in Spell::prepare, must not be used before.
606  m_timer = 0; // will set to castime in prepare
607  m_channeledDuration = 0; // will be setup in Spell::handle_immediate
608  m_immediateHandled = false;
609 
611 
612  // Determine if spell can be reflected back to the caster
613  // Patch 1.2 notes: Spell Reflection no longer reflects abilities
617 
620 
621  for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
623 }
union Spell::@326 m_misc
GameObject * focusObject
Definition: Spell.h:706
Definition: Spell.h:276
GameObject * gameObjTarget
Definition: Spell.h:692
SpellInfo const *const m_spellInfo
Definition: Spell.h:547
Unit *const m_caster
Definition: Spell.h:647
uint32 m_spellState
Definition: Spell.h:818
SpellEffectInfo const * effectInfo
Definition: Spell.h:697
bool IsRangedWeaponSpell() const
Definition: SpellInfo.cpp:1529
bool IsPassive() const
Definition: SpellInfo.cpp:1403
Definition: SharedDefines.h:488
Definition: SharedDefines.h:4371
uint32 m_channelTargetEffectMask
Definition: Spell.h:740
TC_GAME_API Unit * GetUnit(WorldObject const &, ObjectGuid const &guid)
Definition: ObjectAccessor.cpp:163
Map * GetMap() const
Definition: Object.h:543
int32 m_casttime
Definition: Spell.h:660
DiminishingLevels m_diminishLevel
Definition: Spell.h:702
int8 m_comboPointGain
Definition: Spell.h:585
bool m_canReflect
Definition: Spell.h:662
uint32 DmgClass
Definition: SpellInfo.h:398
SpellSchoolMask
Definition: SharedDefines.h:285
uint64 m_delayStart
Definition: Spell.h:678
Definition: Unit.h:619
Difficulty GetDifficultyID() const
Definition: Map.h:390
Definition: SharedDefines.h:360
uint32 m_SpellVisual
Definition: Spell.h:582
SpellInfo const * m_triggeredByAuraSpell
Definition: Spell.h:826
uint32 GetSpellXSpellVisualId(Difficulty difficulty) const
Definition: SpellInfo.cpp:2837
Definition: SharedDefines.h:399
bool m_skipCheck
Definition: Spell.h:828
Definition: SharedDefines.h:2052
arena_t NULL
Definition: jemalloc_internal.h:624
bool IsAutoRepeatRangedSpell() const
Definition: SpellInfo.cpp:1535
Definition: Spell.h:265
uint32 m_castItemEntry
Definition: Spell.h:550
WorldLocation * destTarget
Definition: Spell.h:693
int32 m_timer
Definition: Spell.h:819
Definition: SharedDefines.h:4876
bool m_immediateHandled
Definition: Spell.h:680
Item * m_CastItem
Definition: Spell.h:548
SpellValue *const m_spellValue
Definition: Spell.h:649
Will ignore combo point requirement.
Definition: Unit.h:468
uint32 m_auraScaleMask
Definition: Spell.h:829
Player * ToPlayer()
Definition: Object.h:191
uint32 m_procVictim
Definition: Spell.h:716
bool m_autoRepeat
Definition: Spell.h:663
bool NeedsComboPoints() const
Definition: SpellInfo.cpp:1519
SpellEffectInfoVector _effects
Definition: Spell.h:850
Definition: SharedDefines.h:1543
Aura * m_spellAura
Definition: Spell.h:699
TypeID GetTypeId() const
Definition: Object.h:113
Definition: SharedDefines.h:433
Definition: Spell.h:118
Unit * unitTarget
Definition: Spell.h:690
Definition: Unit.h:618
Unit * m_originalCaster
Definition: Spell.h:653
int32 damage
Definition: Spell.h:694
Unit * GetCharmerOrOwner() const
Definition: Unit.cpp:7627
bool IsPositive() const
Definition: SpellInfo.cpp:1495
ObjectGuid m_castItemGUID
Definition: Spell.h:549
PathGenerator m_preGeneratedPath
Definition: Spell.h:830
bool HasAttribute(SpellAttr0 attribute) const
Definition: SpellInfo.h:462
void CleanupExecuteLogList()
Definition: Spell.cpp:4238
Definition: Item.h:259
TriggerCastFlags
Definition: Unit.h:458
uint32 m_procAttacker
Definition: Spell.h:715
Item * itemTarget
Definition: Spell.h:691
uint32 m_preCastSpell
Definition: Spell.h:583
int32 m_damage
Definition: Spell.h:709
void CleanupTargetList()
Definition: Spell.cpp:2034
Definition: PathGenerator.h:52
bool m_isDelayedInstantCast
Definition: Spell.h:664
float variance
Definition: Spell.h:695
Definition: SharedDefines.h:590
WeaponAttackType m_attackType
Definition: Spell.h:657
Definition: SharedDefines.h:2051
uint32 m_procEx
Definition: Spell.h:717
Definition: SharedDefines.h:2050
void Clear()
Definition: ObjectGuid.h:215
ObjectGuid m_originalCasterGUID
Definition: Spell.h:651
float m_damageMultipliers[3]
Definition: Spell.h:687
uint32 getClassMask() const
Definition: Unit.h:1414
ObjectGuid const & GetGUID() const
Definition: Object.h:105
Definition: ObjectGuid.h:33
bool m_executedCurrently
Definition: Spell.h:684
#define CLASSMASK_WAND_USERS
Definition: SharedDefines.h:207
uint8 m_runesState
Definition: Spell.h:665
uint8 m_applyMultiplierMask
Definition: Spell.h:686
uint32 m_castFlagsEx
Definition: Spell.h:553
uint8_t uint8
Definition: Define.h:152
#define MAX_SPELL_EFFECTS
Definition: DBCStructure.h:1026
uint8 m_delayAtDamageCount
Definition: Spell.h:667
SpellSchoolMask m_spellSchoolMask
Definition: Spell.h:656
Will ignore aura scaling.
Definition: Unit.h:466
int32 m_channeledDuration
Definition: Spell.h:661
DiminishingGroup m_diminishGroup
Definition: Spell.h:703
int32 m_castItemLevel
Definition: Spell.h:551
uint32_t uint32
Definition: g3dmath.h:168
Definition: SharedDefines.h:385
SpellCustomErrors m_customError
Definition: Spell.h:586
bool IsInWorld() const
Definition: Object.h:100
uint8 m_cast_count
Definition: Spell.h:552
TriggerCastFlags _triggeredCastFlags
Definition: Spell.h:821
Definition: SharedDefines.h:507
Spell ** m_selfContainer
Definition: Spell.h:634
int32 m_healing
Definition: Spell.h:710
bool m_referencedFromCurrentSpell
Definition: Spell.h:683
bool m_needComboPoints
Definition: Spell.h:685
bool IsEmpty() const
Definition: ObjectGuid.h:242
Definition: Unit.h:617
SpellDestination m_destTargets[MAX_SPELL_EFFECTS]
Definition: Spell.h:758
SpellEffectHandleMode effectHandleMode
Definition: Spell.h:696
Definition: Spell.h:286

+ Here is the call graph for this function:

Spell::~Spell ( )
626 {
627  // unload scripts
628  while (!m_loadedScripts.empty())
629  {
630  std::list<SpellScript*>::iterator itr = m_loadedScripts.begin();
631  (*itr)->_Unload();
632  delete (*itr);
633  m_loadedScripts.erase(itr);
634  }
635 
637  {
638  // Clean the reference to avoid later crash.
639  // If this error is repeating, we may have to add an ASSERT to better track down how we get into this case.
640  TC_LOG_ERROR("spells", "SPELL: deleting spell for spell ID %u. However, spell still referenced.", m_spellInfo->Id);
642  }
643 
645  ASSERT(m_caster->ToPlayer()->m_spellModTakingSpell != this);
646 
647  delete m_spellValue;
649 }
SpellInfo const *const m_spellInfo
Definition: Spell.h:547
Unit *const m_caster
Definition: Spell.h:647
uint32 Id
Definition: SpellInfo.h:329
std::list< SpellScript * > m_loadedScripts
Definition: Spell.h:794
arena_t NULL
Definition: jemalloc_internal.h:624
SpellValue *const m_spellValue
Definition: Spell.h:649
Player * ToPlayer()
Definition: Object.h:191
TypeID GetTypeId() const
Definition: Object.h:113
void CleanupExecuteLogList()
Definition: Spell.cpp:4238
Definition: ObjectGuid.h:33
#define ASSERT
Definition: Errors.h:55
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
Spell ** m_selfContainer
Definition: Spell.h:634
bool m_referencedFromCurrentSpell
Definition: Spell.h:683

+ Here is the call graph for this function:

Spell::Spell ( Spell const right)
protecteddelete

Member Function Documentation

void Spell::_handle_finish_phase ( )
Todo:
trigger proc phase finish here
3509 {
3510  if (m_caster->m_movedPlayer)
3511  {
3512  // Take for real after all targets are processed
3513  if (m_needComboPoints)
3514  m_caster->m_movedPlayer->ClearComboPoints();
3515 
3516  // Real add combo points from effects
3517  if (m_comboPointGain)
3518  m_caster->m_movedPlayer->GainSpellComboPoints(m_comboPointGain);
3519  }
3520 
3522  {
3525  else
3526  m_caster->m_extraAttacks = 0;
3527  }
3528 
3530 }
Unit *const m_caster
Definition: Spell.h:647
TC_GAME_API Unit * GetUnit(WorldObject const &, ObjectGuid const &guid)
Definition: ObjectAccessor.cpp:163
int8 m_comboPointGain
Definition: Spell.h:585
SpellCastTargets m_targets
Definition: Spell.h:584
Definition: SharedDefines.h:1029
bool HasEffect(SpellEffectName effect) const
Definition: Spell.cpp:7410
void HandleProcExtraAttackFor(Unit *victim)
Definition: Unit.cpp:1918
uint32 m_extraAttacks
Definition: Unit.h:1366
Definition: Unit.h:1305
Player * m_movedPlayer
Definition: Unit.h:1753
bool m_needComboPoints
Definition: Spell.h:685
ObjectGuid GetOrigUnitTargetGUID() const
Definition: Spell.cpp:192

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Spell::_handle_immediate_phase ( )
Todo:
finish new proc system:P
3467 {
3468  m_spellAura = NULL;
3469  // initialize Diminishing Returns Data
3472 
3473  // handle some immediate features of the spell here
3475 
3477 
3478  // handle effects with SPELL_EFFECT_HANDLE_HIT mode
3479  for (SpellEffectInfo const* effect : GetEffects())
3480  {
3481  // don't do anything for empty effect
3482  if (!effect || !effect->IsEffect())
3483  continue;
3484 
3485  // call effect handlers to handle destination hit
3486  HandleEffects(NULL, NULL, NULL, effect->EffectIndex, SPELL_EFFECT_HANDLE_HIT);
3487  }
3488 
3489  // process items
3490  for (std::vector<ItemTargetInfo>::iterator ihit = m_UniqueItemInfo.begin(); ihit != m_UniqueItemInfo.end(); ++ihit)
3491  DoAllEffectOnTarget(&(*ihit));
3492 
3493  if (!m_originalCaster)
3494  return;
3495  // Handle procs on cast
3497  if (m_UniqueTargetInfo.empty() && m_targets.HasDst())
3498  {
3499  uint32 procAttacker = m_procAttacker;
3500  if (!procAttacker)
3502 
3503  // Proc the spells that have DEST target
3505  }
3506 }
void PrepareScriptHitHandlers()
Definition: Spell.cpp:7105
SpellInfo const *const m_spellInfo
Definition: Spell.h:547
Definition: SharedDefines.h:4371
DiminishingLevels m_diminishLevel
Definition: Spell.h:702
void HandleEffects(Unit *pUnitTarget, Item *pItemTarget, GameObject *pGOTarget, uint32 i, SpellEffectHandleMode mode)
Definition: Spell.cpp:4711
SpellCastTargets m_targets
Definition: Spell.h:584
SpellInfo const * m_triggeredByAuraSpell
Definition: Spell.h:826
arena_t NULL
Definition: jemalloc_internal.h:624
Definition: SharedDefines.h:4876
void DoAllEffectOnTarget(TargetInfo *target)
Definition: Spell.cpp:2245
Aura * m_spellAura
Definition: Spell.h:699
std::vector< TargetInfo > m_UniqueTargetInfo
Definition: Spell.h:739
std::vector< ItemTargetInfo > m_UniqueItemInfo
Definition: Spell.h:756
Unit * m_originalCaster
Definition: Spell.h:653
Definition: Spell.h:288
bool HasDst() const
Definition: Spell.h:229
Definition: SpellInfo.h:238
uint32_t uint32
Definition: Define.h:150
uint32 m_procAttacker
Definition: Spell.h:715
SpellEffectInfoVector const & GetEffects() const
Definition: Spell.h:623
Definition: SpellMgr.h:199
uint32 m_procEx
Definition: Spell.h:717
void HandleThreatSpells()
Definition: Spell.cpp:4659
void ProcDamageAndSpell(Unit *victim, uint32 procAttacker, uint32 procVictim, uint32 procEx, uint32 amount, WeaponAttackType attType=BASE_ATTACK, SpellInfo const *procSpell=NULL, SpellInfo const *procAura=NULL)
Definition: Unit.cpp:4860
DiminishingGroup m_diminishGroup
Definition: Spell.h:703
Definition: Unit.h:617

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Spell::AddDestTarget ( SpellDestination const dest,
uint32  effIndex 
)
protected
2241 {
2242  m_destTargets[effIndex] = dest;
2243 }
SpellDestination m_destTargets[MAX_SPELL_EFFECTS]
Definition: Spell.h:758

+ Here is the caller graph for this function:

void Spell::AddGOTarget ( GameObject target,
uint32  effectMask 
)
protected
2154 {
2155  uint32 validEffectMask = 0;
2156  for (SpellEffectInfo const* effect : GetEffects())
2157  if (effect && (effectMask & (1 << effect->EffectIndex)) != 0 && CheckEffectTarget(go, effect))
2158  validEffectMask |= 1 << effect->EffectIndex;
2159 
2160  effectMask &= validEffectMask;
2161 
2162  // no effects left
2163  if (!effectMask)
2164  return;
2165 
2166  ObjectGuid targetGUID = go->GetGUID();
2167 
2168  // Lookup target in already in list
2169  for (std::vector<GOTargetInfo>::iterator ihit = m_UniqueGOTargetInfo.begin(); ihit != m_UniqueGOTargetInfo.end(); ++ihit)
2170  {
2171  if (targetGUID == ihit->targetGUID) // Found in list
2172  {
2173  ihit->effectMask |= effectMask; // Add only effect mask
2174  return;
2175  }
2176  }
2177 
2178  // This is new target calculate data for him
2179 
2180  GOTargetInfo target;
2181  target.targetGUID = targetGUID;
2182  target.effectMask = effectMask;
2183  target.processed = false; // Effects not apply on target
2184 
2185  // Spell have speed - need calculate incoming time
2186  if (m_spellInfo->Speed > 0.0f)
2187  {
2188  // calculate spell incoming interval
2189  float dist = m_caster->GetDistance(go->GetPositionX(), go->GetPositionY(), go->GetPositionZ());
2190  if (dist < 5.0f)
2191  dist = 5.0f;
2192 
2194  target.timeDelay = uint64(floor(dist / m_spellInfo->Speed * 1000.0f));
2195  else
2196  target.timeDelay = uint64(m_spellInfo->Speed * 1000.0f);
2197 
2198  if (m_delayMoment == 0 || m_delayMoment > target.timeDelay)
2199  m_delayMoment = target.timeDelay;
2200  }
2201  else
2202  target.timeDelay = 0LL;
2203 
2204  // Add target to list
2205  m_UniqueGOTargetInfo.push_back(target);
2206 }
Definition: SharedDefines.h:684
SpellInfo const *const m_spellInfo
Definition: Spell.h:547
Unit *const m_caster
Definition: Spell.h:647
static Vector3int16 floor(const Vector3 &v)
uint64_t uint64
Definition: g3dmath.h:170
float GetDistance(WorldObject const *obj) const
Definition: Object.cpp:1594
bool HasAttribute(SpellAttr0 attribute) const
Definition: SpellInfo.h:462
uint64 m_delayMoment
Definition: Spell.h:679
Definition: SpellInfo.h:238
uint32_t uint32
Definition: Define.h:150
uint64_t uint64
Definition: Define.h:149
SpellEffectInfoVector const & GetEffects() const
Definition: Spell.h:623
bool CheckEffectTarget(Unit const *target, SpellEffectInfo const *effect, Position const *losPosition) const
Definition: Spell.cpp:6578
float Speed
Definition: SpellInfo.h:380
std::vector< GOTargetInfo > m_UniqueGOTargetInfo
Definition: Spell.h:749
Definition: ObjectGuid.h:189

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Spell::AddItemTarget ( Item item,
uint32  effectMask 
)
protected
2209 {
2210  uint32 validEffectMask = 0;
2211  for (SpellEffectInfo const* effect : GetEffects())
2212  if (effect && (effectMask & (1 << effect->EffectIndex)) != 0 && CheckEffectTarget(item, effect))
2213  validEffectMask |= 1 << effect->EffectIndex;
2214 
2215  effectMask &= validEffectMask;
2216 
2217  // no effects left
2218  if (!effectMask)
2219  return;
2220 
2221  // Lookup target in already in list
2222  for (std::vector<ItemTargetInfo>::iterator ihit = m_UniqueItemInfo.begin(); ihit != m_UniqueItemInfo.end(); ++ihit)
2223  {
2224  if (item == ihit->item) // Found in list
2225  {
2226  ihit->effectMask |= effectMask; // Add only effect mask
2227  return;
2228  }
2229  }
2230 
2231  // This is new target add data
2232 
2233  ItemTargetInfo target;
2234  target.item = item;
2235  target.effectMask = effectMask;
2236 
2237  m_UniqueItemInfo.push_back(target);
2238 }
std::vector< ItemTargetInfo > m_UniqueItemInfo
Definition: Spell.h:756
Definition: SpellInfo.h:238
uint32_t uint32
Definition: Define.h:150
SpellEffectInfoVector const & GetEffects() const
Definition: Spell.h:623
bool CheckEffectTarget(Unit const *target, SpellEffectInfo const *effect, Position const *losPosition) const
Definition: Spell.cpp:6578

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Spell::AddUnitTarget ( Unit target,
uint32  effectMask,
bool  checkIfValid = true,
bool  implicit = true,
Position const losPosition = nullptr 
)
protected
Todo:
this is a hack
2043 {
2044  uint32 validEffectMask = 0;
2045  for (SpellEffectInfo const* effect : GetEffects())
2046  if (effect && (effectMask & (1 << effect->EffectIndex)) != 0 && CheckEffectTarget(target, effect, losPosition))
2047  validEffectMask |= 1 << effect->EffectIndex;
2048 
2049  effectMask &= validEffectMask;
2050 
2051  // no effects left
2052  if (!effectMask)
2053  return;
2054 
2055  if (checkIfValid)
2056  if (m_spellInfo->CheckTarget(m_caster, target, implicit) != SPELL_CAST_OK)
2057  return;
2058 
2059  // Check for effect immune skip if immuned
2060  for (SpellEffectInfo const* effect : GetEffects())
2061  if (effect && target->IsImmunedToSpellEffect(m_spellInfo, effect->EffectIndex))
2062  effectMask &= ~(1 << effect->EffectIndex);
2063 
2064  ObjectGuid targetGUID = target->GetGUID();
2065 
2066  // Lookup target in already in list
2067  for (std::vector<TargetInfo>::iterator ihit = m_UniqueTargetInfo.begin(); ihit != m_UniqueTargetInfo.end(); ++ihit)
2068  {
2069  if (targetGUID == ihit->targetGUID) // Found in list
2070  {
2071  ihit->effectMask |= effectMask; // Immune effects removed from mask
2072  ihit->scaleAura = false;
2073  if (m_auraScaleMask && ihit->effectMask == m_auraScaleMask && m_caster != target)
2074  {
2075  SpellInfo const* auraSpell = m_spellInfo->GetFirstRankSpell();
2076  if (uint32(target->getLevel() + 10) >= auraSpell->SpellLevel)
2077  ihit->scaleAura = true;
2078  }
2079  return;
2080  }
2081  }
2082 
2083  // This is new target calculate data for him
2084 
2085  // Get spell hit result on target
2086  TargetInfo targetInfo;
2087  targetInfo.targetGUID = targetGUID; // Store target GUID
2088  targetInfo.effectMask = effectMask; // Store all effects not immune
2089  targetInfo.processed = false; // Effects not apply on target
2090  targetInfo.alive = target->IsAlive();
2091  targetInfo.damage = 0;
2092  targetInfo.crit = false;
2093  targetInfo.scaleAura = false;
2094  if (m_auraScaleMask && targetInfo.effectMask == m_auraScaleMask && m_caster != target)
2095  {
2096  SpellInfo const* auraSpell = m_spellInfo->GetFirstRankSpell();
2097  if (uint32(target->getLevel() + 10) >= auraSpell->SpellLevel)
2098  targetInfo.scaleAura = true;
2099  }
2100 
2101  // Calculate hit result
2102  if (m_originalCaster)
2103  {
2104  targetInfo.missCondition = m_originalCaster->SpellHitResult(target, m_spellInfo, m_canReflect);
2105  if (m_skipCheck && targetInfo.missCondition != SPELL_MISS_IMMUNE)
2106  targetInfo.missCondition = SPELL_MISS_NONE;
2107  }
2108  else
2109  targetInfo.missCondition = SPELL_MISS_EVADE; //SPELL_MISS_NONE;
2110 
2111  // Spell have speed - need calculate incoming time
2112  // Incoming time is zero for self casts. At least I think so.
2113  if (m_spellInfo->Speed > 0.0f && m_caster != target)
2114  {
2115  // calculate spell incoming interval
2117  float dist = m_caster->GetDistance(target->GetPositionX(), target->GetPositionY(), target->GetPositionZ());
2118 
2119  if (dist < 5.0f)
2120  dist = 5.0f;
2121 
2123  targetInfo.timeDelay = uint64(std::floor(dist / m_spellInfo->Speed * 1000.0f));
2124  else
2125  targetInfo.timeDelay = uint64(m_spellInfo->Speed * 1000.0f);
2126 
2127  // Calculate minimum incoming time
2128  if (m_delayMoment == 0 || m_delayMoment > targetInfo.timeDelay)
2129  m_delayMoment = targetInfo.timeDelay;
2130  }
2131  else
2132  targetInfo.timeDelay = 0LL;
2133 
2134  // If target reflect spell back to caster
2135  if (targetInfo.missCondition == SPELL_MISS_REFLECT)
2136  {
2137  // Calculate reflected spell result on caster
2138  targetInfo.reflectResult = m_caster->SpellHitResult(m_caster, m_spellInfo, m_canReflect);
2139 
2140  if (targetInfo.reflectResult == SPELL_MISS_REFLECT) // Impossible reflect again, so simply deflect spell
2141  targetInfo.reflectResult = SPELL_MISS_PARRY;
2142 
2143  // Increase time interval for reflected spells by 1.5
2144  targetInfo.timeDelay += targetInfo.timeDelay >> 1;
2145  }
2146  else
2147  targetInfo.reflectResult = SPELL_MISS_NONE;
2148 
2149  // Add target to list
2150  m_UniqueTargetInfo.push_back(targetInfo);
2151 }
Definition: SharedDefines.h:684
SpellInfo const *const m_spellInfo
Definition: Spell.h:547
Unit *const m_caster
Definition: Spell.h:647
Definition: SharedDefines.h:2028
virtual bool IsImmunedToSpellEffect(SpellInfo const *spellInfo, uint32 index) const
Definition: Unit.cpp:9339
bool m_canReflect
Definition: Spell.h:662
Definition: SharedDefines.h:2025
uint32 SpellLevel
Definition: SpellInfo.h:375
Definition: SpellInfo.h:326
static Vector3int16 floor(const Vector3 &v)
bool m_skipCheck
Definition: Spell.h:828
Definition: SharedDefines.h:2021
uint64_t uint64
Definition: g3dmath.h:170
uint32 m_auraScaleMask
Definition: Spell.h:829
uint8 getLevel() const
Definition: Unit.h:1408
Definition: SharedDefines.h:2027
std::vector< TargetInfo > m_UniqueTargetInfo
Definition: Spell.h:739
SpellCastResult CheckTarget(Unit const *caster, WorldObject const *target, bool implicit=true) const
Definition: SpellInfo.cpp:1875
SpellMissInfo SpellHitResult(Unit *victim, SpellInfo const *spellInfo, bool canReflect=false)
Definition: Unit.cpp:2477
SpellInfo const * GetFirstRankSpell() const
Definition: SpellInfo.cpp:2753
Unit * m_originalCaster
Definition: Spell.h:653
float GetDistance(WorldObject const *obj) const
Definition: Object.cpp:1594
bool IsAlive() const
Definition: Unit.h:1692
bool HasAttribute(SpellAttr0 attribute) const
Definition: SpellInfo.h:462
float GetPositionY() const
Definition: Position.h:105
uint64 m_delayMoment
Definition: Spell.h:679
Definition: SpellInfo.h:238
float GetPositionZ() const
Definition: Position.h:106
uint32_t uint32
Definition: Define.h:150
uint64_t uint64
Definition: Define.h:149
SpellEffectInfoVector const & GetEffects() const
Definition: Spell.h:623
bool CheckEffectTarget(Unit const *target, SpellEffectInfo const *effect, Position const *losPosition) const
Definition: Spell.cpp:6578
float Speed
Definition: SpellInfo.h:380
Definition: SharedDefines.h:2032
ObjectGuid const & GetGUID() const
Definition: Object.h:105
Definition: ObjectGuid.h:189
uint32_t uint32
Definition: g3dmath.h:168
float GetPositionX() const
Definition: Position.h:104
Definition: SharedDefines.h:1538

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int32 Spell::CalculateDamage ( uint8  i,
Unit const target,
float *  var = nullptr 
) const
inline
SpellInfo const *const m_spellInfo
Definition: Spell.h:547
Unit *const m_caster
Definition: Spell.h:647
static void var(TextOutput &t, const std::string &name, const std::string &val)
Definition: System.cpp:1582
SpellValue *const m_spellValue
Definition: Spell.h:649
int32 CalculateSpellDamage(Unit const *target, SpellInfo const *spellProto, uint8 effect_index, int32 const *basePoints=nullptr, float *variance=nullptr, int32 itemLevel=-1) const
Definition: Unit.cpp:10930
int32 EffectBasePoints[MAX_SPELL_EFFECTS]
Definition: Spell.h:268
int32 m_castItemLevel
Definition: Spell.h:551

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Spell::CalculateJumpSpeeds ( SpellEffectInfo const effInfo,
float  dist,
float &  speedxy,
float &  speedz 
)
protected
947 {
948  if (effInfo->MiscValue)
949  speedZ = float(effInfo->MiscValue) / 10;
950  else if (effInfo->MiscValueB)
951  speedZ = float(effInfo->MiscValueB) / 10;
952  else
953  speedZ = 10.0f;
954 
955  speedXY = dist * 10.0f / speedZ;
956 }

+ Here is the caller graph for this function:

void Spell::CallScriptAfterCastHandlers ( )
protected
7074 {
7075  for (std::list<SpellScript*>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
7076  {
7077  (*scritr)->_PrepareScriptCall(SPELL_SCRIPT_HOOK_AFTER_CAST);
7078  std::list<SpellScript::CastHandler>::iterator hookItrEnd = (*scritr)->AfterCast.end(), hookItr = (*scritr)->AfterCast.begin();
7079  for (; hookItr != hookItrEnd; ++hookItr)
7080  (*hookItr).Call(*scritr);
7081 
7082  (*scritr)->_FinishScriptCall();
7083  }
7084 }
std::list< SpellScript * > m_loadedScripts
Definition: Spell.h:794
Definition: SpellScript.h:143

+ Here is the caller graph for this function:

void Spell::CallScriptAfterHitHandlers ( )
protected
7199 {
7200  for (std::list<SpellScript*>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
7201  {
7202  (*scritr)->_PrepareScriptCall(SPELL_SCRIPT_HOOK_AFTER_HIT);
7203  std::list<SpellScript::HitHandler>::iterator hookItrEnd = (*scritr)->AfterHit.end(), hookItr = (*scritr)->AfterHit.begin();
7204  for (; hookItr != hookItrEnd; ++hookItr)
7205  (*hookItr).Call(*scritr);
7206 
7207  (*scritr)->_FinishScriptCall();
7208  }
7209 }
std::list< SpellScript * > m_loadedScripts
Definition: Spell.h:794
Definition: SpellScript.h:136

+ Here is the caller graph for this function:

void Spell::CallScriptBeforeCastHandlers ( )
protected
7048 {
7049  for (std::list<SpellScript*>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
7050  {
7051  (*scritr)->_PrepareScriptCall(SPELL_SCRIPT_HOOK_BEFORE_CAST);
7052  std::list<SpellScript::CastHandler>::iterator hookItrEnd = (*scritr)->BeforeCast.end(), hookItr = (*scritr)->BeforeCast.begin();
7053  for (; hookItr != hookItrEnd; ++hookItr)
7054  (*hookItr).Call(*scritr);
7055 
7056  (*scritr)->_FinishScriptCall();
7057  }
7058 }
std::list< SpellScript * > m_loadedScripts
Definition: Spell.h:794
Definition: SpellScript.h:141

+ Here is the caller graph for this function:

void Spell::CallScriptBeforeHitHandlers ( )
protected
7173 {
7174  for (std::list<SpellScript*>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
7175  {
7176  (*scritr)->_PrepareScriptCall(SPELL_SCRIPT_HOOK_BEFORE_HIT);
7177  std::list<SpellScript::HitHandler>::iterator hookItrEnd = (*scritr)->BeforeHit.end(), hookItr = (*scritr)->BeforeHit.begin();
7178  for (; hookItr != hookItrEnd; ++hookItr)
7179  (*hookItr).Call(*scritr);
7180 
7181  (*scritr)->_FinishScriptCall();
7182  }
7183 }
std::list< SpellScript * > m_loadedScripts
Definition: Spell.h:794
Definition: SpellScript.h:134

+ Here is the caller graph for this function:

SpellCastResult Spell::CallScriptCheckCastHandlers ( )
protected
7087 {
7088  SpellCastResult retVal = SPELL_CAST_OK;
7089  for (std::list<SpellScript*>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
7090  {
7091  (*scritr)->_PrepareScriptCall(SPELL_SCRIPT_HOOK_CHECK_CAST);
7092  std::list<SpellScript::CheckCastHandler>::iterator hookItrEnd = (*scritr)->OnCheckCast.end(), hookItr = (*scritr)->OnCheckCast.begin();
7093  for (; hookItr != hookItrEnd; ++hookItr)
7094  {
7095  SpellCastResult tempResult = (*hookItr).Call(*scritr);
7096  if (retVal == SPELL_CAST_OK)
7097  retVal = tempResult;
7098  }
7099 
7100  (*scritr)->_FinishScriptCall();
7101  }
7102  return retVal;
7103 }
std::list< SpellScript * > m_loadedScripts
Definition: Spell.h:794
SpellCastResult
Definition: SharedDefines.h:1265
Definition: SharedDefines.h:1538
Definition: SpellScript.h:140

+ Here is the caller graph for this function:

void Spell::CallScriptDestinationTargetSelectHandlers ( SpellDestination target,
SpellEffIndex  effIndex,
SpellImplicitTargetInfo const targetType 
)
protected
7240 {
7241  for (std::list<SpellScript*>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
7242  {
7243  (*scritr)->_PrepareScriptCall(SPELL_SCRIPT_HOOK_DESTINATION_TARGET_SELECT);
7244  std::list<SpellScript::DestinationTargetSelectHandler>::iterator hookItrEnd = (*scritr)->OnDestinationTargetSelect.end(), hookItr = (*scritr)->OnDestinationTargetSelect.begin();
7245  for (; hookItr != hookItrEnd; ++hookItr)
7246  if (hookItr->IsEffectAffected(m_spellInfo, effIndex) && targetType.GetTarget() == hookItr->GetTarget())
7247  hookItr->Call(*scritr, target);
7248 
7249  (*scritr)->_FinishScriptCall();
7250  }
7251 }
SpellInfo const *const m_spellInfo
Definition: Spell.h:547
std::list< SpellScript * > m_loadedScripts
Definition: Spell.h:794
Definition: SpellScript.h:139

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool Spell::CallScriptEffectHandlers ( SpellEffIndex  effIndex,
SpellEffectHandleMode  mode 
)
protected
7112 {
7113  // execute script effect handler hooks and check if effects was prevented
7114  bool preventDefault = false;
7115  for (std::list<SpellScript*>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
7116  {
7117  std::list<SpellScript::EffectHandler>::iterator effItr, effEndItr;
7118  SpellScriptHookType hookType;
7119  switch (mode)
7120  {
7122  effItr = (*scritr)->OnEffectLaunch.begin();
7123  effEndItr = (*scritr)->OnEffectLaunch.end();
7125  break;
7127  effItr = (*scritr)->OnEffectLaunchTarget.begin();
7128  effEndItr = (*scritr)->OnEffectLaunchTarget.end();
7130  break;
7132  effItr = (*scritr)->OnEffectHit.begin();
7133  effEndItr = (*scritr)->OnEffectHit.end();
7134  hookType = SPELL_SCRIPT_HOOK_EFFECT_HIT;
7135  break;
7137  effItr = (*scritr)->OnEffectHitTarget.begin();
7138  effEndItr = (*scritr)->OnEffectHitTarget.end();
7140  break;
7141  default:
7142  ABORT();
7143  return false;
7144  }
7145  (*scritr)->_PrepareScriptCall(hookType);
7146  for (; effItr != effEndItr; ++effItr)
7147  // effect execution can be prevented
7148  if (!(*scritr)->_IsEffectPrevented(effIndex) && (*effItr).IsEffectAffected(m_spellInfo, effIndex))
7149  (*effItr).Call(*scritr, effIndex);
7150 
7151  if (!preventDefault)
7152  preventDefault = (*scritr)->_IsDefaultEffectPrevented(effIndex);
7153 
7154  (*scritr)->_FinishScriptCall();
7155  }
7156  return preventDefault;
7157 }
SpellScriptHookType
Definition: SpellScript.h:127
Definition: SpellScript.h:131
SpellInfo const *const m_spellInfo
Definition: Spell.h:547
std::list< SpellScript * > m_loadedScripts
Definition: Spell.h:794
Definition: SpellScript.h:130
Definition: Spell.h:289
Definition: Spell.h:288
Definition: Spell.h:287
Definition: SpellScript.h:132
#define ABORT
Definition: Errors.h:56
Definition: SpellScript.h:129
Definition: Spell.h:286

+ Here is the caller graph for this function:

void Spell::CallScriptObjectAreaTargetSelectHandlers ( std::list< WorldObject * > &  targets,
SpellEffIndex  effIndex,
SpellImplicitTargetInfo const targetType 
)
protected
7212 {
7213  for (std::list<SpellScript*>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
7214  {
7215  (*scritr)->_PrepareScriptCall(SPELL_SCRIPT_HOOK_OBJECT_AREA_TARGET_SELECT);
7216  std::list<SpellScript::ObjectAreaTargetSelectHandler>::iterator hookItrEnd = (*scritr)->OnObjectAreaTargetSelect.end(), hookItr = (*scritr)->OnObjectAreaTargetSelect.begin();
7217  for (; hookItr != hookItrEnd; ++hookItr)
7218  if (hookItr->IsEffectAffected(m_spellInfo, effIndex) && targetType.GetTarget() == hookItr->GetTarget())
7219  hookItr->Call(*scritr, targets);
7220 
7221  (*scritr)->_FinishScriptCall();
7222  }
7223 }
SpellInfo const *const m_spellInfo
Definition: Spell.h:547
std::list< SpellScript * > m_loadedScripts
Definition: Spell.h:794
Definition: SpellScript.h:137

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Spell::CallScriptObjectTargetSelectHandlers ( WorldObject *&  target,
SpellEffIndex  effIndex,
SpellImplicitTargetInfo const targetType 
)
protected
7226 {
7227  for (std::list<SpellScript*>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
7228  {
7229  (*scritr)->_PrepareScriptCall(SPELL_SCRIPT_HOOK_OBJECT_TARGET_SELECT);
7230  std::list<SpellScript::ObjectTargetSelectHandler>::iterator hookItrEnd = (*scritr)->OnObjectTargetSelect.end(), hookItr = (*scritr)->OnObjectTargetSelect.begin();
7231  for (; hookItr != hookItrEnd; ++hookItr)
7232  if (hookItr->IsEffectAffected(m_spellInfo, effIndex) && targetType.GetTarget() == hookItr->GetTarget())
7233  hookItr->Call(*scritr, target);
7234 
7235  (*scritr)->_FinishScriptCall();
7236  }
7237 }
Definition: SpellScript.h:138
SpellInfo const *const m_spellInfo
Definition: Spell.h:547
std::list< SpellScript * > m_loadedScripts
Definition: Spell.h:794

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Spell::CallScriptOnCastHandlers ( )
protected
7061 {
7062  for (std::list<SpellScript*>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
7063  {
7064  (*scritr)->_PrepareScriptCall(SPELL_SCRIPT_HOOK_ON_CAST);
7065  std::list<SpellScript::CastHandler>::iterator hookItrEnd = (*scritr)->OnCast.end(), hookItr = (*scritr)->OnCast.begin();
7066  for (; hookItr != hookItrEnd; ++hookItr)
7067  (*hookItr).Call(*scritr);
7068 
7069  (*scritr)->_FinishScriptCall();
7070  }
7071 }
std::list< SpellScript * > m_loadedScripts
Definition: Spell.h:794
Definition: SpellScript.h:142

+ Here is the caller graph for this function:

void Spell::CallScriptOnHitHandlers ( )
protected
7186 {
7187  for (std::list<SpellScript*>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
7188  {
7189  (*scritr)->_PrepareScriptCall(SPELL_SCRIPT_HOOK_HIT);
7190  std::list<SpellScript::HitHandler>::iterator hookItrEnd = (*scritr)->OnHit.end(), hookItr = (*scritr)->OnHit.begin();
7191  for (; hookItr != hookItrEnd; ++hookItr)
7192  (*hookItr).Call(*scritr);
7193 
7194  (*scritr)->_FinishScriptCall();
7195  }
7196 }
Definition: SpellScript.h:135
std::list< SpellScript * > m_loadedScripts
Definition: Spell.h:794

+ Here is the caller graph for this function:

void Spell::CallScriptSuccessfulDispel ( SpellEffIndex  effIndex)
protected
7160 {
7161  for (std::list<SpellScript*>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
7162  {
7163  (*scritr)->_PrepareScriptCall(SPELL_SCRIPT_HOOK_EFFECT_SUCCESSFUL_DISPEL);
7164  std::list<SpellScript::EffectHandler>::iterator hookItrEnd = (*scritr)->OnEffectSuccessfulDispel.end(), hookItr = (*scritr)->OnEffectSuccessfulDispel.begin();
7165  for (; hookItr != hookItrEnd; ++hookItr)
7166  hookItr->Call(*scritr, effIndex);
7167 
7168  (*scritr)->_FinishScriptCall();
7169  }
7170 }
std::list< SpellScript * > m_loadedScripts
Definition: Spell.h:794
Definition: SpellScript.h:133

+ Here is the caller graph for this function:

bool Spell::CanAutoCast ( Unit target)
5811 {
5812  ObjectGuid targetguid = target->GetGUID();
5813 
5814  for (SpellEffectInfo const* effect : GetEffects())
5815  {
5816  if (!effect)
5817  continue;
5818 
5819  if (effect->Effect == SPELL_EFFECT_APPLY_AURA)
5820  {
5821  if (m_spellInfo->StackAmount <= 1)
5822  {
5823  if (target->HasAuraEffect(m_spellInfo->Id, effect->EffectIndex))
5824  return false;
5825  }
5826  else
5827  {
5828  if (AuraEffect* aureff = target->GetAuraEffect(m_spellInfo->Id, effect->EffectIndex))
5829  if (aureff->GetBase()->GetStackAmount() >= m_spellInfo->StackAmount)
5830  return false;
5831  }
5832  }
5833  else if (effect->IsAreaAuraEffect())
5834  {
5835  if (target->HasAuraEffect(m_spellInfo->Id, effect->EffectIndex))
5836  return false;
5837  }
5838  }
5839 
5840  SpellCastResult result = CheckPetCast(target);
5841 
5842  if (result == SPELL_CAST_OK || result == SPELL_FAILED_UNIT_NOT_INFRONT)
5843  {
5845  //check if among target units, our WANTED target is as well (->only self cast spells return false)
5846  for (std::vector<TargetInfo>::iterator ihit = m_UniqueTargetInfo.begin(); ihit != m_UniqueTargetInfo.end(); ++ihit)
5847  if (ihit->targetGUID == targetguid)
5848  return true;
5849  }
5850  return false; //target invalid
5851 }
Definition: SpellAuraEffects.h:30
Definition: SharedDefines.h:1421
SpellInfo const *const m_spellInfo
Definition: Spell.h:547
uint32 Id
Definition: SpellInfo.h:329
Definition: SharedDefines.h:1016
bool HasAuraEffect(uint32 spellId, uint8 effIndex, ObjectGuid caster=ObjectGuid::Empty) const
Definition: Unit.cpp:4210
std::vector< TargetInfo > m_UniqueTargetInfo
Definition: Spell.h:739
Definition: SpellInfo.h:238
SpellEffectInfoVector const & GetEffects() const
Definition: Spell.h:623
SpellCastResult CheckPetCast(Unit *target)
Definition: Spell.cpp:5611
ObjectGuid const & GetGUID() const
Definition: Object.h:105
AuraEffect * GetAuraEffect(uint32 spellId, uint8 effIndex, ObjectGuid casterGUID=ObjectGuid::Empty) const
Definition: Unit.cpp:4071
SpellCastResult
Definition: SharedDefines.h:1265
Definition: ObjectGuid.h:189
uint32 StackAmount
Definition: SpellInfo.h:381
void SelectSpellTargets()
Definition: Spell.cpp:750
Definition: SharedDefines.h:1538

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Spell::cancel ( )
3062 {
3064  return;
3065  // delayed instant casts are used for client-side visual orientation; they are treated as instant for all intents and purposes server-side, and thus cannot be interrupted by another cast
3067  return;
3068 
3069  uint32 oldState = m_spellState;
3071 
3072  m_autoRepeat = false;
3073  switch (oldState)
3074  {
3075  case SPELL_STATE_PREPARING:
3077  if (m_caster->GetTypeId() == TYPEID_PLAYER)
3078  m_caster->ToPlayer()->RestoreSpellMods(this);
3079  // no break
3080  case SPELL_STATE_DELAYED:
3081  SendInterrupted(0);
3083  break;
3084 
3085  case SPELL_STATE_CASTING:
3086  for (std::vector<TargetInfo>::const_iterator ihit = m_UniqueTargetInfo.begin(); ihit != m_UniqueTargetInfo.end(); ++ihit)
3087  if ((*ihit).missCondition == SPELL_MISS_NONE)
3088  if (Unit* unit = m_caster->GetGUID() == ihit->targetGUID ? m_caster : ObjectAccessor::GetUnit(*m_caster, ihit->targetGUID))
3089  unit->RemoveOwnedAura(m_spellInfo->Id, m_originalCasterGUID, 0, AURA_REMOVE_BY_CANCEL);
3090 
3091  SendChannelUpdate(0);
3092  SendInterrupted(0);
3094 
3095  // spell is canceled-take mods and clear list
3096  if (m_caster->GetTypeId() == TYPEID_PLAYER)
3097  m_caster->ToPlayer()->RemoveSpellMods(this);
3098 
3099  m_appliedMods.clear();
3100  break;
3101 
3102  default:
3103  break;
3104  }
3105 
3106  SetReferencedFromCurrent(false);
3107  if (m_selfContainer && *m_selfContainer == this)
3108  *m_selfContainer = NULL;
3109 
3111  if (m_spellInfo->IsChanneled()) // if not channeled then the object for the current cast wasn't summoned yet
3113 
3114  //set state back so finish will be processed
3115  m_spellState = oldState;
3116 
3117  finish(false);
3118 }
SpellInfo const *const m_spellInfo
Definition: Spell.h:547
Unit *const m_caster
Definition: Spell.h:647
uint32 m_spellState
Definition: Spell.h:818
uint32 Id
Definition: SpellInfo.h:329
Definition: Spell.h:281
bool IsChanneled() const
Definition: SpellInfo.cpp:1514
TC_GAME_API Unit * GetUnit(WorldObject const &, ObjectGuid const &guid)
Definition: ObjectAccessor.cpp:163
UsedSpellMods m_appliedMods
Definition: Spell.h:588
void CancelGlobalCooldown()
Definition: Spell.cpp:7394
static void SendCastResult(Player *caster, SpellInfo const *spellInfo, uint8 cast_count, SpellCastResult result, SpellCustomErrors customError=SPELL_CUSTOM_ERROR_NONE, OpcodeServer opcode=SMSG_CAST_FAILED, uint32 *misc=nullptr)
Definition: Spell.cpp:3732
arena_t NULL
Definition: jemalloc_internal.h:624
Definition: SharedDefines.h:2021
Definition: Unit.h:452
Player * ToPlayer()
Definition: Object.h:191
bool m_autoRepeat
Definition: Spell.h:663
TypeID GetTypeId() const
Definition: Object.h:113
std::vector< TargetInfo > m_UniqueTargetInfo
Definition: Spell.h:739
void finish(bool ok=true)
Definition: Spell.cpp:3620
void SendChannelUpdate(uint32 time)
Definition: Spell.cpp:4266
uint32_t uint32
Definition: Define.h:150
Definition: Spell.h:278
bool m_isDelayedInstantCast
Definition: Spell.h:664
Definition: Spell.h:277
ObjectGuid m_originalCasterGUID
Definition: Spell.h:651
ObjectGuid const & GetGUID() const
Definition: Object.h:105
void RemoveGameObject(GameObject *gameObj, bool del)
Definition: Unit.cpp:4765
Definition: ObjectGuid.h:33
void SetReferencedFromCurrent(bool yes)
Definition: Spell.h:601
void SendInterrupted(uint8 result)
Definition: Spell.cpp:4248
Spell ** m_selfContainer
Definition: Spell.h:634
void RemoveDynObject(uint32 spellId)
Definition: Unit.cpp:4715
Definition: Unit.h:1305
Definition: Spell.h:279
Definition: SharedDefines.h:1326

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Spell::CancelGlobalCooldown ( )
protected
7395 {
7397  return;
7398 
7399  // Cancel global cooldown when interrupting current cast
7401  return;
7402 
7403  // Only players or controlled units have global cooldown
7405  return;
7406 
7408 }
SpellInfo const *const m_spellInfo
Definition: Spell.h:547
Unit *const m_caster
Definition: Spell.h:647
Definition: Unit.h:1109
void CancelGlobalCooldown(SpellInfo const *spellInfo)
Definition: SpellHistory.cpp:832
CharmInfo * GetCharmInfo()
Definition: Unit.h:1748
TypeID GetTypeId() const
Definition: Object.h:113
SpellHistory * GetSpellHistory()
Definition: Unit.h:1926
Spell * GetCurrentSpell(CurrentSpellTypes spellType) const
Definition: Unit.h:1920
Definition: ObjectGuid.h:33
uint32 StartRecoveryTime
Definition: SpellInfo.h:366

+ Here is the caller graph for this function:

bool Spell::CanExecuteTriggersOnHit ( uint8  effMask,
SpellInfo const triggeredByAura = NULL 
) const
protected
7277 {
7278  bool only_on_caster = (triggeredByAura && (triggeredByAura->HasAttribute(SPELL_ATTR4_PROC_ONLY_ON_CASTER)));
7279  // If triggeredByAura has SPELL_ATTR4_PROC_ONLY_ON_CASTER then it can only proc on a cast spell with TARGET_UNIT_CASTER
7280  for (SpellEffectInfo const* effect : GetEffects())
7281  {
7282  if (effect && ((effMask & (1 << effect->EffectIndex)) && (!only_on_caster || (effect->TargetA.GetTarget() == TARGET_UNIT_CASTER))))
7283  return true;
7284  }
7285  return false;
7286 }
Definition: SpellInfo.h:238
SpellEffectInfoVector const & GetEffects() const
Definition: Spell.h:623
Definition: SharedDefines.h:501
Definition: SharedDefines.h:1875

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

SpellCastResult Spell::CanOpenLock ( uint32  effIndex,
uint32  lockid,
SkillType skillid,
int32 reqSkillValue,
int32 skillValue 
)
protected
6929 {
6930  if (!lockId) // possible case for GO and maybe for items.
6931  return SPELL_CAST_OK;
6932 
6933  // Get LockInfo
6934  LockEntry const* lockInfo = sLockStore.LookupEntry(lockId);
6935 
6936  if (!lockInfo)
6937  return SPELL_FAILED_BAD_TARGETS;
6938 
6939  SpellEffectInfo const* effect = GetEffect(effIndex);
6940  if (!effect)
6941  return SPELL_FAILED_BAD_TARGETS; // no idea about correct error
6942 
6943  bool reqKey = false; // some locks not have reqs
6944 
6945  for (int j = 0; j < MAX_LOCK_CASE; ++j)
6946  {
6947  switch (lockInfo->Type[j])
6948  {
6949  // check key item (many fit cases can be)
6950  case LOCK_KEY_ITEM:
6951  if (lockInfo->Index[j] && m_CastItem && m_CastItem->GetEntry() == lockInfo->Index[j])
6952  return SPELL_CAST_OK;
6953  reqKey = true;
6954  break;
6955  // check key skill (only single first fit case can be)
6956  case LOCK_KEY_SKILL:
6957  {
6958  reqKey = true;
6959 
6960  // wrong locktype, skip
6961  if (uint32(effect->MiscValue) != lockInfo->Index[j])
6962  continue;
6963 
6964  skillId = SkillByLockType(LockType(lockInfo->Index[j]));
6965 
6966  if (skillId != SKILL_NONE)
6967  {
6968  reqSkillValue = lockInfo->Skill[j];
6969 
6970  // castitem check: rogue using skeleton keys. the skill values should not be added in this case.
6971  skillValue = m_CastItem || m_caster->GetTypeId()!= TYPEID_PLAYER ?
6972  0 : m_caster->ToPlayer()->GetSkillValue(skillId);
6973 
6974  // skill bonus provided by casting spell (mostly item spells)
6975  // add the effect base points modifier from the spell cast (cheat lock / skeleton key etc.)
6977  skillValue += effect->CalcValue();
6978 
6979  if (skillValue < reqSkillValue)
6981  }
6982 
6983  return SPELL_CAST_OK;
6984  }
6985  }
6986  }
6987 
6988  if (reqKey)
6989  return SPELL_FAILED_BAD_TARGETS;
6990 
6991  return SPELL_CAST_OK;
6992 }
int32 MiscValue
Definition: SpellInfo.h:253
uint32 Type[MAX_LOCK_CASE]
Definition: DBCStructure.h:818
Unit *const m_caster
Definition: Spell.h:647
Definition: SharedDefines.h:1895
Definition: SharedDefines.h:3883
DBCStorage< LockEntry > sLockStore(Lockfmt)
SpellEffectInfo const * GetEffect(uint32 index) const
Definition: Spell.h:624
Definition: DBCStructure.h:815
Item * m_CastItem
Definition: Spell.h:548
LockType
Definition: SharedDefines.h:3512
Player * ToPlayer()
Definition: Object.h:191
SpellImplicitTargetInfo TargetA
Definition: SpellInfo.h:257
TypeID GetTypeId() const
Definition: Object.h:113
Definition: SharedDefines.h:3507
Definition: SharedDefines.h:3508
Definition: SharedDefines.h:1280
Targets GetTarget() const
Definition: SpellInfo.cpp:121
Definition: SpellInfo.h:238
int32 CalcValue(Unit const *caster=nullptr, int32 const *basePoints=nullptr, Unit const *target=nullptr, float *variance=nullptr, int32 itemLevel=-1) const
Definition: SpellInfo.cpp:455
Definition: ObjectGuid.h:33
SkillType SkillByLockType(LockType locktype)
Definition: SharedDefines.h:4108
#define MAX_LOCK_CASE
Definition: DBCStructure.h:813
SpellImplicitTargetInfo TargetB
Definition: SpellInfo.h:258
uint32 GetEntry() const
Definition: Object.h:107
uint32_t uint32
Definition: g3dmath.h:168
Definition: SharedDefines.h:1335
uint32 Skill[MAX_LOCK_CASE]
Definition: DBCStructure.h:820
Definition: SharedDefines.h:1538
uint32 Index[MAX_LOCK_CASE]
Definition: DBCStructure.h:819

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Spell::cast ( bool  skipCheck = false)

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

3121 {
3122  // update pointers base at GUIDs to prevent access to non-existed already object
3123  if (!UpdatePointers())
3124  {
3125  // cancel the spell if UpdatePointers() returned false, something wrong happened there
3126  cancel();
3127  return;
3128  }
3129 
3130  // cancel at lost explicit target during cast
3132  {
3133  cancel();
3134  return;
3135  }
3136 
3138  SendSpellStart();
3139 
3140  if (Player* playerCaster = m_caster->ToPlayer())
3141  {
3142  // now that we've done the basic check, now run the scripts
3143  // should be done before the spell is actually executed
3144  sScriptMgr->OnPlayerSpellCast(playerCaster, this, skipCheck);
3145 
3146  // As of 3.0.2 pets begin attacking their owner's target immediately
3147  // Let any pets know we've attacked something. Check DmgClass for harmful spells only
3148  // This prevents spells such as Hunter's Mark from triggering pet attack
3149  if (this->GetSpellInfo()->DmgClass != SPELL_DAMAGE_CLASS_NONE)
3150  if (Pet* playerPet = playerCaster->GetPet())
3151  if (playerPet->IsAlive() && playerPet->isControlled() && (m_targets.GetTargetMask() & TARGET_FLAG_UNIT))
3152  playerPet->AI()->OwnerAttacked(m_targets.GetUnitTarget());
3153  }
3154 
3155  SetExecutedCurrently(true);
3156 
3160 
3161  // Should this be done for original caster?
3162  if (m_caster->GetTypeId() == TYPEID_PLAYER)
3163  {
3164  // Set spell which will drop charges for triggered cast spells
3165  // if not successfully cast, will be remove in finish(false)
3166  m_caster->ToPlayer()->SetSpellModTakingSpell(this, true);
3167  }
3168 
3170 
3171  // skip check if done already (for instant cast spells for example)
3172  if (!skipCheck)
3173  {
3174  SpellCastResult castResult = CheckCast(false);
3175  if (castResult != SPELL_CAST_OK)
3176  {
3177  SendCastResult(castResult);
3178  SendInterrupted(0);
3179  //restore spell mods
3180  if (m_caster->GetTypeId() == TYPEID_PLAYER)
3181  {
3182  m_caster->ToPlayer()->RestoreSpellMods(this);
3183  // cleanup after mod system
3184  // triggered spell pointer can be not removed in some cases
3185  m_caster->ToPlayer()->SetSpellModTakingSpell(this, false);
3186  }
3187  finish(false);
3188  SetExecutedCurrently(false);
3189  return;
3190  }
3191 
3192  // additional check after cast bar completes (must not be in CheckCast)
3193  // if trade not complete then remember it in trade data
3195  {
3196  if (m_caster->GetTypeId() == TYPEID_PLAYER)
3197  {
3198  if (TradeData* my_trade = m_caster->ToPlayer()->GetTradeData())
3199  {
3200  if (!my_trade->IsInAcceptProcess())
3201  {
3202  // Spell will be cast after completing the trade. Silently ignore at this place
3203  my_trade->SetSpell(m_spellInfo->Id, m_CastItem);
3205  SendInterrupted(0);
3206  m_caster->ToPlayer()->RestoreSpellMods(this);
3207  // cleanup after mod system
3208  // triggered spell pointer can be not removed in some cases
3209  m_caster->ToPlayer()->SetSpellModTakingSpell(this, false);
3210  finish(false);
3211  SetExecutedCurrently(false);
3212  return;
3213  }
3214  }
3215  }
3216  }
3217  }
3218 
3219  // if the spell allows the creature to turn while casting, then adjust server-side orientation to face the target now
3220  // client-side orientation is handled by the client itself, as the cast target is targeted due to Creature::FocusTarget
3223  if (WorldObject* objTarget = m_targets.GetObjectTarget())
3224  {
3225  m_caster->SetInFront(objTarget);
3226  m_caster->SetFacingToObject(objTarget);
3227  }
3228 
3230 
3231  // Spell may be finished after target map check
3233  {
3234  SendInterrupted(0);
3235  //restore spell mods
3236  if (m_caster->GetTypeId() == TYPEID_PLAYER)
3237  {
3238  m_caster->ToPlayer()->RestoreSpellMods(this);
3239  // cleanup after mod system
3240  // triggered spell pointer can be not removed in some cases
3241  m_caster->ToPlayer()->SetSpellModTakingSpell(this, false);
3242  }
3243  finish(false);
3244  SetExecutedCurrently(false);
3245  return;
3246  }
3247 
3249 
3251 
3252  // traded items have trade slot instead of guid in m_itemTargetGUID
3253  // set to real guid to be sent later to the client
3255 
3256  if (Player* player = m_caster->ToPlayer())
3257  {
3259  {
3260  player->StartTimedAchievement(ACHIEVEMENT_TIMED_TYPE_ITEM, m_CastItem->GetEntry());
3261  player->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_USE_ITEM, m_CastItem->GetEntry());
3262  }
3263 
3264  player->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_CAST_SPELL, m_spellInfo->Id);
3265  }
3266 
3268  {
3269  // Powers have to be taken before SendSpellGo
3270  TakePower();
3271  TakeReagents(); // we must remove reagents before HandleEffects to allow place crafted item in same slot
3272  }
3273  else if (Item* targetItem = m_targets.GetItemTarget())
3274  {
3276  if (targetItem->GetOwnerGUID() != m_caster->GetGUID())
3277  TakeReagents();
3278  }
3279 
3280  // CAST SPELL
3282 
3284 
3286 
3287  // we must send smsg_spell_go packet before m_castItem delete in TakeCastItem()...
3288  SendSpellGo();
3289 
3290  // Okay, everything is prepared. Now we need to distinguish between immediate and evented delayed spells
3292  {
3293  // Remove used for cast item if need (it can be already NULL after TakeReagents call
3294  // in case delayed spell remove item at cast delay start
3295  TakeCastItem();
3296 
3297  // Okay, maps created, now prepare flags
3298  m_immediateHandled = false;
3300  SetDelayStart(0);
3301 
3302  if (m_caster->HasUnitState(UNIT_STATE_CASTING) && !m_caster->IsNonMeleeSpellCast(false, false, true))
3304  }
3305  else
3306  {
3307  // Immediate spell, no big deal
3308  handle_immediate();
3309  }
3310 
3312 
3313  if (const std::vector<int32> *spell_triggered = sSpellMgr->GetSpellLinked(m_spellInfo->Id))
3314  {
3315  for (std::vector<int32>::const_iterator i = spell_triggered->begin(); i != spell_triggered->end(); ++i)
3316  if (*i < 0)
3318  else
3320  }
3321 
3322  if (m_caster->GetTypeId() == TYPEID_PLAYER)
3323  {
3324  m_caster->ToPlayer()->SetSpellModTakingSpell(this, false);
3325 
3326  //Clear spell cooldowns after every spell is cast if .cheat cooldown is enabled.
3327  if (m_caster->ToPlayer()->GetCommandStatus(CHEAT_COOLDOWN))
3328  {
3331  }
3332  }
3333 
3334  SetExecutedCurrently(false);
3335 
3336  if (Creature* creatureCaster = m_caster->ToCreature())
3337  creatureCaster->ReleaseFocus(this);
3338 }
void handle_immediate()
Definition: Spell.cpp:3340
void UpdateTradeSlotItem()
Definition: Spell.cpp:319
void CallScriptAfterCastHandlers()
Definition: Spell.cpp:7073
void PrepareScriptHitHandlers()
Definition: Spell.cpp:7105
SpellInfo const *const m_spellInfo
Definition: Spell.h:547
Unit *const m_caster
Definition: Spell.h:647
uint32 m_spellState
Definition: Spell.h:818
uint32 Id
Definition: SpellInfo.h:329
Definition: Spell.h:281
Unit * GetUnitTarget() const
Definition: Spell.cpp:222
Definition: SpellInfo.h:49
bool IsChanneled() const
Definition: SpellInfo.cpp:1514
Definition: DBCEnums.h:221
Definition: Unit.h:565
SpellCastTargets m_targets
Definition: Spell.h:584
SpellCategoryEntry const * ChargeCategoryEntry
Definition: SpellInfo.h:402
void TakeCastItem()
Definition: Spell.cpp:4338
void SendSpellGo()
Definition: Spell.cpp:3962
void RestoreCharge(SpellCategoryEntry const *chargeCategoryEntry)
Definition: SpellHistory.cpp:721
Definition: DBCEnums.h:188
Item * GetItemTarget() const
Definition: Spell.h:203
static void SendCastResult(Player *caster, SpellInfo const *spellInfo, uint8 cast_count, SpellCastResult result, SpellCustomErrors customError=SPELL_CUSTOM_ERROR_NONE, OpcodeServer opcode=SMSG_CAST_FAILED, uint32 *misc=nullptr)
Definition: Spell.cpp:3732
void SendSpellStart()
Definition: Spell.cpp:3858
Definition: ObjectGuid.h:32
Will ignore Spell and Category cooldowns.
Definition: Unit.h:463
Definition: Object.h:423
Definition: Creature.h:467
bool m_immediateHandled
Definition: Spell.h:680
Item * m_CastItem
Definition: Spell.h:548
bool IsNonMeleeSpellCast(bool withDelayed, bool skipChanneled=false, bool skipAutorepeat=false, bool isAutoshoot=false, bool skipInstant=true) const
Definition: Unit.cpp:2886
Definition: SharedDefines.h:2049
ObjectGuid GetObjectTargetGUID() const
Definition: Spell.cpp:287
void SetExecutedCurrently(bool yes)
Definition: Spell.h:603
Player * ToPlayer()
Definition: Object.h:191
void ClearUnitState(uint32 f)
Definition: Unit.h:1396
TypeID GetTypeId() const
Definition: Object.h:113
WorldObject * GetObjectTarget() const
Definition: Spell.cpp:282
void SetFacingToObject(WorldObject const *object)
Definition: Unit.cpp:15787
Will ignore interruptible aura's at cast.
Definition: Unit.h:470
SpellHistory * GetSpellHistory()
Definition: Unit.h:1926
void finish(bool ok=true)
Definition: Spell.cpp:3620
void TakePower()
Definition: Spell.cpp:4403
Definition: TradeData.h:34
bool HasAttribute(SpellAttr0 attribute) const
Definition: SpellInfo.h:462
Definition: Item.h:259
#define sSpellMgr
Definition: SpellMgr.h:756
Definition: SharedDefines.h:504
SpellInfo const * GetSpellInfo() const
Definition: Spell.h:614
bool m_isDelayedInstantCast
Definition: Spell.h:664
void HandleLaunchPhase()
Definition: Spell.cpp:6849
float Speed
Definition: SpellInfo.h:380
void SendSpellCooldown()
Definition: Spell.cpp:3532
Definition: DBCEnums.h:233
Definition: SharedDefines.h:1297
void RemoveAurasDueToSpell(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, uint32 reqEffMask=0, AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
Definition: Unit.cpp:3586
ObjectGuid const & GetGUID() const
Definition: Object.h:105
Will ignore power and reagent cost.
Definition: Unit.h:464
SpellCastResult CheckCast(bool strict)
Definition: Spell.cpp:4739
void SetDelayStart(uint64 m_time)
Definition: Spell.h:605
void ResetCooldown(uint32 spellId, bool update=false)
Definition: SpellHistory.cpp:549
Definition: ObjectGuid.h:33
uint32 GetTargetMask() const
Definition: Spell.h:179
Definition: UpdateFields.h:109
Creature * ToCreature()
Definition: Object.h:194
void TakeReagents()
Definition: Spell.cpp:4609
void CallScriptBeforeCastHandlers()
Definition: Spell.cpp:7047
Definition: SpellInfo.h:60
bool HasUnitState(const uint32 f) const
Definition: Unit.h:1395
void cancel()
Definition: Spell.cpp:3061
SpellCastResult
Definition: SharedDefines.h:1265
#define sScriptMgr
Definition: ScriptMgr.h:837
uint32 GetEntry() const
Definition: Object.h:107
void SendInterrupted(uint8 result)
Definition: Spell.cpp:4248
bool HasFlag(uint16 index, uint32 flag) const
Definition: Object.cpp:1239
TriggerCastFlags _triggeredCastFlags
Definition: Spell.h:821
void CallScriptOnCastHandlers()
Definition: Spell.cpp:7060
void SetInFront(WorldObject const *target)
Definition: Unit.cpp:15771
Definition: SharedDefines.h:555
Definition: Unit.h:697
void SelectSpellTargets()
Definition: Spell.cpp:750
void CastSpell(SpellCastTargets const &targets, SpellInfo const *spellInfo, CustomSpellValues const *value, TriggerCastFlags triggerFlags=TRIGGERED_NONE, Item *castItem=NULL, AuraEffect const *triggeredByAura=NULL, ObjectGuid originalCaster=ObjectGuid::Empty)
Definition: Unit.cpp:869
Definition: SharedDefines.h:1538
Definition: Spell.h:279
bool IsEmpty() const
Definition: ObjectGuid.h:242
Definition: Pet.h:46
bool UpdatePointers()
Definition: Spell.cpp:6508
void PrepareTriggersExecutedOnHit()
Definition: Spell.cpp:7288

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

SpellCastResult Spell::CheckArenaAndRatedBattlegroundCastRules ( )
5780 {
5781  bool isRatedBattleground = false; // NYI
5782  bool isArena = !isRatedBattleground;
5783 
5784  // check USABLE attributes
5785  // USABLE takes precedence over NOT_USABLE
5787  return SPELL_CAST_OK;
5788 
5790  return SPELL_CAST_OK;
5791 
5792  // check NOT_USABLE attributes
5795 
5798 
5799  // check cooldowns
5800  uint32 spellCooldown = m_spellInfo->GetRecoveryTime();
5801  if (isArena && spellCooldown > 10 * MINUTE * IN_MILLISECONDS) // not sure if still needed
5803 
5804  if (isRatedBattleground && spellCooldown > 15 * MINUTE * IN_MILLISECONDS)
5806 
5807  return SPELL_CAST_OK;
5808 }
SpellInfo const *const m_spellInfo
Definition: Spell.h:547
Definition: SharedDefines.h:694
Definition: SharedDefines.h:689
Definition: Common.h:97
Definition: SharedDefines.h:1439
Definition: SharedDefines.h:517
Definition: SharedDefines.h:516
bool HasAttribute(SpellAttr0 attribute) const
Definition: SpellInfo.h:462
uint32_t uint32
Definition: Define.h:150
uint32 GetRecoveryTime() const
Definition: SpellInfo.cpp:2559
Definition: Common.h:103
Definition: SharedDefines.h:1504
Definition: SharedDefines.h:1538

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

SpellCastResult Spell::CheckCast ( bool  strict)
Todo:
determine if there is some flag to enable/disable the check
4740 {
4741  // check death state
4743  return SPELL_FAILED_CASTER_DEAD;
4744 
4745  // check cooldowns to prevent cheating
4746  if (!m_spellInfo->IsPassive())
4747  {
4748  if (m_caster->GetTypeId() == TYPEID_PLAYER)
4749  {
4750  //can cast triggered (by aura only?) spells while have this flag
4753 
4754  // check if we are using a potion in combat for the 2nd+ time. Cooldown is added only after caster gets out of combat
4755  if (m_caster->ToPlayer()->GetLastPotionId() && m_CastItem && (m_CastItem->IsPotion() || m_spellInfo->IsCooldownStartedOnEvent()))
4756  return SPELL_FAILED_NOT_READY;
4757  }
4758 
4760  {
4762  return SPELL_FAILED_DONT_REPORT;
4763  else
4764  return SPELL_FAILED_NOT_READY;
4765  }
4766  }
4767 
4769  {
4772  }
4773 
4774  // Check global cooldown
4776  return SPELL_FAILED_NOT_READY;
4777 
4778  // only triggered spells can be processed an ended battleground
4779  if (!IsTriggered() && m_caster->GetTypeId() == TYPEID_PLAYER)
4780  if (Battleground* bg = m_caster->ToPlayer()->GetBattleground())
4781  if (bg->GetStatus() == STATUS_WAIT_LEAVE)
4782  return SPELL_FAILED_DONT_REPORT;
4783 
4785  {
4789 
4793  }
4794 
4795  // only check at first call, Stealth auras are already removed at second call
4796  // for now, ignore triggered spells
4798  {
4799  bool checkForm = true;
4800  // Ignore form req aura
4802  for (Unit::AuraEffectList::const_iterator i = ignore.begin(); i != ignore.end(); ++i)
4803  {
4804  if (!(*i)->IsAffectingSpell(m_spellInfo))
4805  continue;
4806  checkForm = false;
4807  break;
4808  }
4809  if (checkForm)
4810  {
4811  // Cannot be used in this stance/form
4813  if (shapeError != SPELL_CAST_OK)
4814  return shapeError;
4815 
4818  }
4819  }
4820 
4822  for (Unit::AuraEffectList::const_iterator blockItr = blockSpells.begin(); blockItr != blockSpells.end(); ++blockItr)
4823  if (uint32((*blockItr)->GetMiscValue()) == m_spellInfo->SpellFamilyName)
4825 
4826  bool reqCombat = true;
4828  for (Unit::AuraEffectList::const_iterator j = stateAuras.begin(); j != stateAuras.end(); ++j)
4829  {
4830  if ((*j)->IsAffectingSpell(m_spellInfo))
4831  {
4832  m_needComboPoints = false;
4833  if ((*j)->GetMiscValue() == 1)
4834  {
4835  reqCombat=false;
4836  break;
4837  }
4838  }
4839  }
4840 
4841  // caster state requirements
4842  // not for triggered spells (needed by execute)
4843  if (!(_triggeredCastFlags & TRIGGERED_IGNORE_CASTER_AURASTATE))
4844  {
4849 
4850  // Note: spell 62473 requres casterAuraSpell = triggering spell
4855 
4856  if (reqCombat && m_caster->IsInCombat() && !m_spellInfo->CanBeUsedInCombat())
4858  }
4859 
4860  // cancel autorepeat spells if cast start when moving
4861  // (not wand currently autorepeat cast delayed to moving stop anyway in spell update code)
4862  // Do not cancel spells which are affected by a SPELL_AURA_CAST_WHILE_WALKING effect
4864  {
4865  // skip stuck spell to allow use it in falling case and apply spell limitations at movement
4866  SpellEffectInfo const* effect = GetEffect(EFFECT_0);
4867  if ((!m_caster->HasUnitMovementFlag(MOVEMENTFLAG_FALLING_FAR) || (effect && effect->Effect != SPELL_EFFECT_STUCK)) &&
4869  return SPELL_FAILED_MOVING;
4870  }
4871 
4872  // Check vehicle flags
4874  {
4876  if (vehicleCheck != SPELL_CAST_OK)
4877  return vehicleCheck;
4878  }
4879 
4880  // check spell cast conditions from database
4881  {
4883  if (!sConditionMgr->IsObjectMeetingNotGroupedConditions(CONDITION_SOURCE_TYPE_SPELL, m_spellInfo->Id, condInfo))
4884  {
4885  // mLastFailedCondition can be NULL if there was an error processing the condition in Condition::Meets (i.e. wrong data for ConditionTarget or others)
4886  if (condInfo.mLastFailedCondition && condInfo.mLastFailedCondition->ErrorType)
4887  {
4891  }
4892  if (!condInfo.mLastFailedCondition || !condInfo.mLastFailedCondition->ConditionTarget)
4894  return SPELL_FAILED_BAD_TARGETS;
4895  }
4896  }
4897 
4898  // Don't check explicit target for passive spells (workaround) (check should be skipped only for learn case)
4899  // those spells may have incorrect target entries or not filled at all (for example 15332)
4900  // such spells when learned are not targeting anyone using targeting system, they should apply directly to caster instead
4901  // also, such casts shouldn't be sent to client
4903  {
4904  // Check explicit target for m_originalCaster - todo: get rid of such workarounds
4906  if (castResult != SPELL_CAST_OK)
4907  return castResult;
4908  }
4909 
4910  if (Unit* target = m_targets.GetUnitTarget())
4911  {
4912  SpellCastResult castResult = m_spellInfo->CheckTarget(m_caster, target, false);
4913  if (castResult != SPELL_CAST_OK)
4914  return castResult;
4915 
4916  if (target != m_caster)
4917  {
4918  // Must be behind the target
4919  if ((m_spellInfo->HasAttribute(SPELL_ATTR0_CU_REQ_CASTER_BEHIND_TARGET)) && target->HasInArc(static_cast<float>(M_PI), m_caster))
4920  return SPELL_FAILED_NOT_BEHIND;
4921 
4922  // Target must be facing you
4923  if ((m_spellInfo->HasAttribute(SPELL_ATTR0_CU_REQ_TARGET_FACING_CASTER)) && !target->HasInArc(static_cast<float>(M_PI), m_caster))
4924  return SPELL_FAILED_NOT_INFRONT;
4925 
4926  if (m_caster->GetEntry() != WORLD_TRIGGER) // Ignore LOS for gameobjects casts (wrongly cast by a trigger)
4927  {
4928  WorldObject* losTarget = m_caster;
4930  if (DynamicObject* dynObj = m_caster->GetDynObject(m_triggeredByAuraSpell->Id))
4931  losTarget = dynObj;
4932 
4935  }
4936  }
4937  }
4938 
4939  // Check for line of sight for spells with dest
4940  if (m_targets.HasDst())
4941  {
4942  float x, y, z;
4943  m_targets.GetDstPos()->GetPosition(x, y, z);
4944 
4947  }
4948 
4949  // check pet presence
4950  for (SpellEffectInfo const* effect : GetEffects())
4951  {
4952  if (effect && effect->TargetA.GetTarget() == TARGET_UNIT_PET)
4953  {
4954  if (!m_caster->GetGuardianPet())
4955  {
4956  if (m_triggeredByAuraSpell) // not report pet not existence for triggered spells
4957  return SPELL_FAILED_DONT_REPORT;
4958  else
4959  return SPELL_FAILED_NO_PET;
4960  }
4961  break;
4962  }
4963  }
4964 
4965  // Spell cast only in battleground
4966  if ((m_spellInfo->HasAttribute(SPELL_ATTR3_BATTLEGROUND)) && m_caster->GetTypeId() == TYPEID_PLAYER)
4967  if (!m_caster->ToPlayer()->InBattleground())
4969 
4970  // do not allow spells to be cast in arenas or rated battlegrounds
4971  if (Player* player = m_caster->ToPlayer())
4972  if (player->InArena()/* || player->InRatedBattleGround() NYI*/)
4973  {
4975  if (castResult != SPELL_CAST_OK)
4976  return castResult;
4977  }
4978 
4979  // zone check
4980  if (m_caster->GetTypeId() == TYPEID_UNIT || !m_caster->ToPlayer()->IsGameMaster())
4981  {
4982  uint32 zone, area;
4983  m_caster->GetZoneAndAreaId(zone, area);
4984 
4985  SpellCastResult locRes = m_spellInfo->CheckLocation(m_caster->GetMapId(), zone, area, m_caster->ToPlayer());
4986  if (locRes != SPELL_CAST_OK)
4987  return locRes;
4988  }
4989 
4990  // not let players cast spells at mount (and let do it to creatures)
4991  if (m_caster->IsMounted() && m_caster->GetTypeId() == TYPEID_PLAYER && !(_triggeredCastFlags & TRIGGERED_IGNORE_CASTER_MOUNTED_OR_ON_VEHICLE) &&
4993  {
4994  if (m_caster->IsInFlight())
4995  return SPELL_FAILED_NOT_ON_TAXI;
4996  else
4997  return SPELL_FAILED_NOT_MOUNTED;
4998  }
4999 
5000  // check spell focus object
5002  {
5004  if (!focusObject)
5006  }
5007 
5008  SpellCastResult castResult = SPELL_CAST_OK;
5009 
5010  // always (except passive spells) check items (only player related checks)
5011  if (!m_spellInfo->IsPassive())
5012  {
5013  castResult = CheckItems();
5014  if (castResult != SPELL_CAST_OK)
5015  return castResult;
5016  }
5017 
5018  // Triggered spells also have range check
5020  castResult = CheckRange(strict);
5021  if (castResult != SPELL_CAST_OK)
5022  return castResult;
5023 
5025  {
5026  castResult = CheckPower();
5027  if (castResult != SPELL_CAST_OK)
5028  return castResult;
5029  }
5030 
5032  {
5033  castResult = CheckCasterAuras();
5034  if (castResult != SPELL_CAST_OK)
5035  return castResult;
5036  }
5037 
5038  // script hook
5039  castResult = CallScriptCheckCastHandlers();
5040  if (castResult != SPELL_CAST_OK)
5041  return castResult;
5042 
5043  for (SpellEffectInfo const* effect : GetEffects())
5044  {
5045  if (!effect)
5046  continue;
5047  // for effects of spells that have only one target
5048  switch (effect->Effect)
5049  {
5050  case SPELL_EFFECT_DUMMY:
5051  {
5052  if (m_spellInfo->Id == 19938) // Awaken Peon
5053  {
5054  Unit* unit = m_targets.GetUnitTarget();
5055  if (!unit || !unit->HasAura(17743))
5056  return SPELL_FAILED_BAD_TARGETS;
5057  }
5058  else if (m_spellInfo->Id == 31789) // Righteous Defense
5059  {
5060  if (m_caster->GetTypeId() != TYPEID_PLAYER)
5061  return SPELL_FAILED_DONT_REPORT;
5062 
5063  Unit* target = m_targets.GetUnitTarget();
5064  if (!target || !target->IsFriendlyTo(m_caster) || target->getAttackers().empty())
5065  return SPELL_FAILED_BAD_TARGETS;
5066 
5067  }
5068  break;
5069  }
5071  {
5072  if (m_caster->GetTypeId() != TYPEID_PLAYER)
5073  return SPELL_FAILED_BAD_TARGETS;
5074 
5075  if (effect->TargetA.GetTarget() != TARGET_UNIT_PET)
5076  break;
5077 
5078  Pet* pet = m_caster->ToPlayer()->GetPet();
5079 
5080  if (!pet)
5081  return SPELL_FAILED_NO_PET;
5082 
5083  SpellInfo const* learn_spellproto = sSpellMgr->GetSpellInfo(effect->TriggerSpell);
5084 
5085  if (!learn_spellproto)
5086  return SPELL_FAILED_NOT_KNOWN;
5087 
5088  if (m_spellInfo->SpellLevel > pet->getLevel())
5089  return SPELL_FAILED_LOWLEVEL;
5090 
5091  break;
5092  }
5094  {
5095  if (m_caster->GetTypeId() != TYPEID_PLAYER)
5096  return SPELL_FAILED_BAD_TARGETS;
5097  if (Guild* guild = m_caster->ToPlayer()->GetGuild())
5098  if (guild->GetLeaderGUID() != m_caster->ToPlayer()->GetGUID())
5100  break;
5101  }
5103  {
5104  // check target only for unit target case
5105  if (Unit* unit = m_targets.GetUnitTarget())
5106  {
5107  if (m_caster->GetTypeId() != TYPEID_PLAYER)
5108  return SPELL_FAILED_BAD_TARGETS;
5109 
5110  Pet* pet = unit->ToPet();
5111  if (!pet || pet->GetOwner() != m_caster)
5112  return SPELL_FAILED_BAD_TARGETS;
5113 
5114  SpellInfo const* learn_spellproto = sSpellMgr->GetSpellInfo(effect->TriggerSpell);
5115 
5116  if (!learn_spellproto)
5117  return SPELL_FAILED_NOT_KNOWN;
5118 
5119  if (m_spellInfo->SpellLevel > pet->getLevel())
5120  return SPELL_FAILED_LOWLEVEL;
5121  }
5122  break;
5123  }
5125  {
5126  uint32 glyphId = effect->MiscValue;
5127  if (GlyphPropertiesEntry const* gp = sGlyphPropertiesStore.LookupEntry(glyphId))
5128  if (m_caster->HasAura(gp->SpellID))
5130  break;
5131  }
5132  case SPELL_EFFECT_FEED_PET:
5133  {
5134  if (m_caster->GetTypeId() != TYPEID_PLAYER)
5135  return SPELL_FAILED_BAD_TARGETS;
5136 
5137  Item* foodItem = m_targets.GetItemTarget();
5138  if (!foodItem)
5139  return SPELL_FAILED_BAD_TARGETS;
5140 
5141  Pet* pet = m_caster->ToPlayer()->GetPet();
5142 
5143  if (!pet)
5144  return SPELL_FAILED_NO_PET;
5145 
5146  if (!pet->HaveInDiet(foodItem->GetTemplate()))
5148 
5149  if (!pet->GetCurrentFoodBenefitLevel(foodItem->GetTemplate()->GetBaseItemLevel()))
5151 
5152  if (m_caster->IsInCombat() || pet->IsInCombat())
5154 
5155  break;
5156  }
5159  {
5160  // Can be area effect, Check only for players and not check if target - caster (spell can have multiply drain/burn effects)
5161  if (m_caster->GetTypeId() ==