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() == TYPEID_PLAYER)
5162  if (Unit* target = m_targets.GetUnitTarget())
5163  if (target != m_caster && target->getPowerType() != Powers(effect->MiscValue))
5164  return SPELL_FAILED_BAD_TARGETS;
5165  break;
5166  }
5167  case SPELL_EFFECT_CHARGE:
5168 
5170  {
5171  // Warbringer - can't be handled in proc system - should be done before checkcast root check and charge effect process
5172  if (strict && m_caster->IsScriptOverriden(m_spellInfo, 6953))
5173  m_caster->RemoveMovementImpairingAuras();
5174  }
5175 
5176  if (m_caster->HasUnitState(UNIT_STATE_ROOT))
5177  return SPELL_FAILED_ROOTED;
5178 
5180  {
5181  Unit* target = m_targets.GetUnitTarget();
5182  if (!target)
5183  return SPELL_FAILED_DONT_REPORT;
5184 
5185  float objSize = target->GetObjectSize();
5186  float range = m_spellInfo->GetMaxRange(true, m_caster, this) * 1.5f + objSize; // can't be overly strict
5187 
5189  // first try with raycast, if it fails fall back to normal path
5190  float targetObjectSize = std::min(target->GetObjectSize(), 4.0f);
5191  bool result = m_preGeneratedPath.CalculatePath(target->GetPositionX(), target->GetPositionY(), target->GetPositionZ() + targetObjectSize, false, true);
5195  {
5196  result = m_preGeneratedPath.CalculatePath(target->GetPositionX(), target->GetPositionY(), target->GetPositionZ() + targetObjectSize, false, false);
5200  return SPELL_FAILED_NOPATH;
5201  }
5202 
5203  m_preGeneratedPath.ReducePathLenghtByDist(objSize); // move back
5204  }
5205  break;
5206  }
5207  case SPELL_EFFECT_SKINNING:
5208  {
5209  if (m_caster->GetTypeId() != TYPEID_PLAYER || !m_targets.GetUnitTarget() || m_targets.GetUnitTarget()->GetTypeId() != TYPEID_UNIT)
5210  return SPELL_FAILED_BAD_TARGETS;
5211 
5214 
5215  Creature* creature = m_targets.GetUnitTarget()->ToCreature();
5216  if (!creature->IsCritter() && !creature->loot.isLooted())
5218 
5219  uint32 skill = creature->GetCreatureTemplate()->GetRequiredLootSkill();
5220 
5221  int32 skillValue = m_caster->ToPlayer()->GetSkillValue(skill);
5222  int32 TargetLevel = m_targets.GetUnitTarget()->getLevel();
5223  int32 ReqValue = (skillValue < 100 ? (TargetLevel-10) * 10 : TargetLevel * 5);
5224  if (ReqValue > skillValue)
5226 
5227  // chance for fail at orange skinning attempt
5228  if ((m_selfContainer && (*m_selfContainer) == this) &&
5229  skillValue < sWorld->GetConfigMaxSkillValue() &&
5230  (ReqValue < 0 ? 0 : ReqValue) > irand(skillValue - 25, skillValue + 37))
5231  return SPELL_FAILED_TRY_AGAIN;
5232 
5233  break;
5234  }
5236  {
5237  if (effect->TargetA.GetTarget() != TARGET_GAMEOBJECT_TARGET &&
5239  break;
5240 
5241  if (m_caster->GetTypeId() != TYPEID_PLAYER // only players can open locks, gather etc.
5242  // we need a go target in case of TARGET_GAMEOBJECT_TARGET
5244  return SPELL_FAILED_BAD_TARGETS;
5245 
5246  Item* pTempItem = NULL;
5248  {
5249  if (TradeData* pTrade = m_caster->ToPlayer()->GetTradeData())
5250  pTempItem = pTrade->GetTraderData()->GetItem(TradeSlots(m_targets.GetItemTargetGUID().GetRawValue().at(0))); // at this point item target guid contains the trade slot
5251  }
5253  pTempItem = m_caster->ToPlayer()->GetItemByGuid(m_targets.GetItemTargetGUID());
5254 
5255  // we need a go target, or an openable item target in case of TARGET_GAMEOBJECT_ITEM_TARGET
5256  if (effect->TargetA.GetTarget() == TARGET_GAMEOBJECT_ITEM_TARGET &&
5257  !m_targets.GetGOTarget() &&
5258  (!pTempItem || !pTempItem->GetTemplate()->GetLockID() || !pTempItem->IsLocked()))
5259  return SPELL_FAILED_BAD_TARGETS;
5260 
5261  if (m_spellInfo->Id != 1842 || (m_targets.GetGOTarget() &&
5263  if (m_caster->ToPlayer()->InBattleground() && // In Battleground players can use only flags and banners
5264  !m_caster->ToPlayer()->CanUseBattlegroundObject(m_targets.GetGOTarget()))
5265  return SPELL_FAILED_TRY_AGAIN;
5266 
5267  // get the lock entry
5268  uint32 lockId = 0;
5269  if (GameObject* go = m_targets.GetGOTarget())
5270  {
5271  lockId = go->GetGOInfo()->GetLockId();
5272  if (!lockId)
5273  return SPELL_FAILED_BAD_TARGETS;
5274  }
5275  else if (Item* itm = m_targets.GetItemTarget())
5276  lockId = itm->GetTemplate()->GetLockID();
5277 
5278  SkillType skillId = SKILL_NONE;
5279  int32 reqSkillValue = 0;
5280  int32 skillValue = 0;
5281 
5282  // check lock compatibility
5283  SpellCastResult res = CanOpenLock(effect->EffectIndex, lockId, skillId, reqSkillValue, skillValue);
5284  if (res != SPELL_CAST_OK)
5285  return res;
5286 
5287  // chance for fail at orange mining/herb/LockPicking gathering attempt
5288  // second check prevent fail at rechecks
5289  if (skillId != SKILL_NONE && (!m_selfContainer || ((*m_selfContainer) != this)))
5290  {
5291  bool canFailAtMax = skillId != SKILL_HERBALISM && skillId != SKILL_MINING;
5292 
5293  // chance for failure in orange gather / lockpick (gathering skill can't fail at maxskill)
5294  if ((canFailAtMax || skillValue < sWorld->GetConfigMaxSkillValue()) && reqSkillValue > irand(skillValue - 25, skillValue + 37))
5295  return SPELL_FAILED_TRY_AGAIN;
5296  }
5297  break;
5298  }
5300  {
5301  Creature* pet = m_caster->GetGuardianPet();
5302 
5303  if (pet && pet->IsAlive())
5305 
5306  break;
5307  }
5308  // This is generic summon effect
5309  case SPELL_EFFECT_SUMMON:
5310  {
5311  SummonPropertiesEntry const* SummonProperties = sSummonPropertiesStore.LookupEntry(effect->MiscValueB);
5312  if (!SummonProperties)
5313  break;
5314  switch (SummonProperties->Category)
5315  {
5316  case SUMMON_CATEGORY_PET:
5317  if (!m_caster->GetPetGUID().IsEmpty())
5319  // intentional missing break, check both GetPetGUID() and GetCharmGUID for SUMMON_CATEGORY_PET
5321  if (!m_caster->GetCharmGUID().IsEmpty())
5323  break;
5324  }
5325  break;
5326  }
5328  {
5329  if (m_targets.GetUnitTarget())
5330  {
5332  return SPELL_FAILED_BAD_TARGETS;
5335  }
5336  break;
5337  }
5339  {
5340  if (!m_caster->GetPetGUID().IsEmpty()) //let warlock do a replacement summon
5341  {
5342  if (m_caster->GetTypeId() == TYPEID_PLAYER && m_caster->getClass() == CLASS_WARLOCK)
5343  {
5344  if (strict) //starting cast, trigger pet stun (cast by pet so it doesn't attack player)
5345  if (Pet* pet = m_caster->ToPlayer()->GetPet())
5346  pet->CastSpell(pet, 32752, true, NULL, NULL, pet->GetGUID());
5347  }
5348  else
5350  }
5351 
5352  if (!m_caster->GetCharmGUID().IsEmpty())
5354  break;
5355  }
5357  {
5358  if (m_caster->GetTypeId() != TYPEID_PLAYER)
5359  return SPELL_FAILED_BAD_TARGETS;
5360  if (!m_caster->GetTarget())
5361  return SPELL_FAILED_BAD_TARGETS;
5362 
5363  Player* target = ObjectAccessor::FindPlayer(m_caster->ToPlayer()->GetTarget());
5364  if (!target || m_caster->ToPlayer() == target || (!target->IsInSameRaidWith(m_caster->ToPlayer()) && m_spellInfo->Id != 48955)) // refer-a-friend spell
5365  return SPELL_FAILED_BAD_TARGETS;
5366 
5367  // check if our map is dungeon
5368  MapEntry const* map = sMapStore.LookupEntry(m_caster->GetMapId());
5369  if (map->IsDungeon())
5370  {
5371  uint32 mapId = m_caster->GetMap()->GetId();
5372  Difficulty difficulty = m_caster->GetMap()->GetDifficultyID();
5373  if (map->IsRaid())
5374  if (InstancePlayerBind* targetBind = target->GetBoundInstance(mapId, difficulty))
5375  if (InstancePlayerBind* casterBind = m_caster->ToPlayer()->GetBoundInstance(mapId, difficulty))
5376  if (targetBind->perm && targetBind->save != casterBind->save)
5378 
5379  InstanceTemplate const* instance = sObjectMgr->GetInstanceTemplate(mapId);
5380  if (!instance)
5382  if (!target->Satisfy(sObjectMgr->GetAccessRequirement(mapId, difficulty), mapId))
5383  return SPELL_FAILED_BAD_TARGETS;
5384  }
5385  break;
5386  }
5387  // RETURN HERE
5389  {
5390  if (m_caster->GetTypeId() != TYPEID_PLAYER)
5391  return SPELL_FAILED_BAD_TARGETS;
5392 
5393  Player* playerCaster = m_caster->ToPlayer();
5394  //
5395  if (!(playerCaster->GetTarget()))
5396  return SPELL_FAILED_BAD_TARGETS;
5397 
5398  Player* target = playerCaster->GetSelectedPlayer();
5399 
5400  if (!target ||
5401  !(target->GetSession()->GetRecruiterId() == playerCaster->GetSession()->GetAccountId() || target->GetSession()->GetAccountId() == playerCaster->GetSession()->GetRecruiterId()))
5402  return SPELL_FAILED_BAD_TARGETS;
5403 
5404  break;
5405  }
5406  case SPELL_EFFECT_LEAP:
5408  {
5409  //Do not allow to cast it before BG starts.
5410  if (m_caster->GetTypeId() == TYPEID_PLAYER)
5411  if (Battleground const* bg = m_caster->ToPlayer()->GetBattleground())
5412  if (bg->GetStatus() != STATUS_IN_PROGRESS)
5413  return SPELL_FAILED_TRY_AGAIN;
5414  break;
5415  }
5417  {
5418  if (m_targets.GetUnitTarget() == m_caster)
5419  return SPELL_FAILED_BAD_TARGETS;
5420  break;
5421  }
5423  {
5424  if (m_caster->HasUnitState(UNIT_STATE_ROOT))
5425  {
5426  if (m_caster->GetTypeId() == TYPEID_PLAYER)
5427  return SPELL_FAILED_ROOTED;
5428  else
5429  return SPELL_FAILED_DONT_REPORT;
5430  }
5431  break;
5432  }
5434  {
5435  // can't change during already started arena/battleground
5436  if (m_caster->GetTypeId() == TYPEID_PLAYER)
5437  if (Battleground const* bg = m_caster->ToPlayer()->GetBattleground())
5438  if (bg->GetStatus() == STATUS_IN_PROGRESS)
5440  break;
5441  }
5443  {
5444  if (m_caster->GetTypeId() != TYPEID_PLAYER)
5445  return SPELL_FAILED_BAD_TARGETS;
5446  TalentEntry const* talent = sTalentStore.LookupEntry(m_misc.TalentId);
5447  if (!talent)
5448  return SPELL_FAILED_DONT_REPORT;
5449  if (m_caster->GetSpellHistory()->HasCooldown(talent->SpellID))
5451  break;
5452  }
5453  default:
5454  break;
5455  }
5456  }
5457 
5458  for (SpellEffectInfo const* effect : GetEffects())
5459  {
5460  if (!effect)
5461  continue;
5462  switch (effect->ApplyAuraName)
5463  {
5465  {
5466  if (m_caster->GetTypeId() != TYPEID_PLAYER)
5467  return SPELL_FAILED_NO_PET;
5468 
5469  Pet* pet = m_caster->ToPlayer()->GetPet();
5470  if (!pet)
5471  return SPELL_FAILED_NO_PET;
5472 
5473  if (!pet->GetCharmerGUID().IsEmpty())
5474  return SPELL_FAILED_CHARMED;
5475  break;
5476  }
5478  case SPELL_AURA_MOD_CHARM:
5479  case SPELL_AURA_AOE_CHARM:
5480  {
5481  if (!m_caster->GetCharmerGUID().IsEmpty())
5482  return SPELL_FAILED_CHARMED;
5483 
5484  if (effect->ApplyAuraName == SPELL_AURA_MOD_CHARM
5485  || effect->ApplyAuraName == SPELL_AURA_MOD_POSSESS)
5486  {
5487  if (!m_caster->GetPetGUID().IsEmpty())
5489 
5490  if (!m_caster->GetCharmGUID().IsEmpty())
5492  }
5493 
5494  if (Unit* target = m_targets.GetUnitTarget())
5495  {
5496  if (target->GetTypeId() == TYPEID_UNIT && target->IsVehicle())
5498 
5499  if (target->IsMounted())
5501 
5502  if (!target->GetCharmerGUID().IsEmpty())
5503  return SPELL_FAILED_CHARMED;
5504 
5505  if (target->GetOwner() && target->GetOwner()->GetTypeId() == TYPEID_PLAYER)
5507 
5508  int32 value = CalculateDamage(effect->EffectIndex, target);
5509  if (value && int32(target->getLevel()) > value)
5510  return SPELL_FAILED_HIGHLEVEL;
5511  }
5512 
5513  break;
5514  }
5515  case SPELL_AURA_MOUNTED:
5516  {
5517  if (m_caster->IsInWater())
5519 
5520  // Ignore map check if spell have AreaId. AreaId already checked and this prevent special mount spells
5521  bool allowMount = !m_caster->GetMap()->IsDungeon() || m_caster->GetMap()->IsBattlegroundOrArena();
5522  InstanceTemplate const* it = sObjectMgr->GetInstanceTemplate(m_caster->GetMapId());
5523  if (it)
5524  allowMount = it->AllowMount;
5525  if (m_caster->GetTypeId() == TYPEID_PLAYER && !allowMount && !m_spellInfo->RequiredAreasID)
5527 
5528  if (m_caster->IsInDisallowedMountForm())
5530 
5531  break;
5532  }
5534  {
5535  if (!m_targets.GetUnitTarget())
5537 
5538  // can be cast at non-friendly unit or own pet/charm
5539  if (m_caster->IsFriendlyTo(m_targets.GetUnitTarget()))
5541 
5542  break;
5543  }
5544  case SPELL_AURA_FLY:
5546  {
5547  // not allow cast fly spells if not have req. skills (all spells is self target)
5548  // allow always ghost flight spells
5550  {
5551  Battlefield* Bf = sBattlefieldMgr->GetBattlefieldToZoneId(m_originalCaster->GetZoneId());
5552  if (AreaTableEntry const* area = sAreaTableStore.LookupEntry(m_originalCaster->GetAreaId()))
5553  if (area->Flags[0] & AREA_FLAG_NO_FLY_ZONE || (Bf && !Bf->CanFlyIn()))
5555  }
5556  break;
5557  }
5559  {
5560  if (effect->IsTargetingArea())
5561  break;
5562 
5563  if (!m_targets.GetUnitTarget())
5565 
5566  if (m_caster->GetTypeId() != TYPEID_PLAYER || m_CastItem)
5567  break;
5568 
5570  return SPELL_FAILED_BAD_TARGETS;
5571 
5572  break;
5573  }
5574  default:
5575  break;
5576  }
5577  }
5578 
5579  // check trade slot case (last, for allow catch any another cast problems)
5581  {
5582  if (m_CastItem)
5584 
5585  if (m_caster->GetTypeId() != TYPEID_PLAYER)
5586  return SPELL_FAILED_NOT_TRADING;
5587 
5588  TradeData* my_trade = m_caster->ToPlayer()->GetTradeData();
5589 
5590  if (!my_trade)
5591  return SPELL_FAILED_NOT_TRADING;
5592 
5594  return SPELL_FAILED_BAD_TARGETS;
5595 
5596  if (!IsTriggered())
5597  if (my_trade->GetSpell())
5599  }
5600 
5601  // check if caster has at least 1 combo point for spells that require combo points
5602  if (m_needComboPoints)
5603  if (Player* plrCaster = m_caster->ToPlayer())
5604  if (!plrCaster->GetComboPoints())
5606 
5607  // all ok
5608  return SPELL_CAST_OK;
5609 }
uint32 GetBaseItemLevel() const
Definition: ItemTemplate.h:667
union Spell::@326 m_misc
bool HasStealthAura() const
Definition: Unit.h:1597
GameObject * focusObject
Definition: Spell.h:706
Definition: SharedDefines.h:1105
GameObject * SearchSpellFocus()
Definition: Spell.cpp:1945
Definition: Battleground.h:159
int32 MiscValue
Definition: SpellInfo.h:253
Definition: DBCStructure.h:37
uint32 GetLockID() const
Definition: ItemTemplate.h:687
bool HasAura(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, ObjectGuid itemCasterGUID=ObjectGuid::Empty, uint32 reqEffMask=0) const
Definition: Unit.cpp:4240
SpellInfo const *const m_spellInfo
Definition: Spell.h:547
Unit *const m_caster
Definition: Spell.h:647
Definition: SharedDefines.h:1895
Difficulty
Definition: DBCEnums.h:402
uint32 Id
Definition: SpellInfo.h:329
SpellCastResult CallScriptCheckCastHandlers()
Definition: Spell.cpp:7086
Definition: SpellAuraDefines.h:188
bool IsDisabledFor(DisableType type, uint32 entry, Unit const *unit, uint8 flags)
Definition: DisableMgr.cpp:277
Unit * GetUnitTarget() const
Definition: Spell.cpp:222
Definition: SharedDefines.h:1408
Definition: SharedDefines.h:1106
Definition: SharedDefines.h:1477
Definition: SharedDefines.h:430
uint32 GetUInt32Value(uint16 index) const
Definition: Object.cpp:300
bool HasUnitMovementFlag(uint32 f) const
Definition: Unit.h:2109
Guardian * GetGuardianPet() const
Definition: Unit.cpp:7596
Definition: SpellAuraDefines.h:66
bool CanFlyIn()
Return if we can use mount in battlefield.
Definition: Battlefield.h:335
Will ignore caster aura states including combat requirements and death state.
Definition: Unit.h:473
Definition: SharedDefines.h:1401
Definition: SharedDefines.h:1322
Definition: SharedDefines.h:1376
bool IsPassive() const
Definition: SpellInfo.cpp:1403
Definition: Map.h:222
Definition: PathGenerator.h:47
Player * GetOwner() const
Definition: Pet.cpp:1913
Definition: SharedDefines.h:1879
Definition: SharedDefines.h:1892
SpellCastResult CheckArenaAndRatedBattlegroundCastRules()
Definition: Spell.cpp:5779
SpellCastResult CheckItems()
Definition: Spell.cpp:5951
SpellCastResult CanOpenLock(uint32 effIndex, uint32 lockid, SkillType &skillid, int32 &reqSkillValue, int32 &skillValue)
Definition: Spell.cpp:6928
bool CanBeUsedInCombat() const
Definition: SpellInfo.cpp:1490
Definition: Unit.h:699
Map * GetMap() const
Definition: Object.h:543
Definition: SharedDefines.h:1351
Definition: SharedDefines.h:1294
Definition: SpellAuraDefines.h:335
DBCStorage< SummonPropertiesEntry > sSummonPropertiesStore(SummonPropertiesfmt)
SpellCustomErrors
Definition: SharedDefines.h:1541
uint32 SpellLevel
Definition: SpellInfo.h:375
Definition: SharedDefines.h:3883
#define M_PI
Definition: Common.h:163
Definition: SpellInfo.h:326
Definition: SharedDefines.h:1274
Definition: SharedDefines.h:1053
Definition: SharedDefines.h:1381
Definition: SharedDefines.h:1039
Definition: SharedDefines.h:28
Definition: SharedDefines.h:1072
Definition: SharedDefines.h:1383
SpellCastTargets m_targets
Definition: Spell.h:584
SpellCastResult CheckPower()
Definition: Spell.cpp:5913
Definition: SharedDefines.h:1084
Pet * ToPet()
Definition: Unit.h:2200
SpellCastResult CheckExplicitTarget(Unit const *caster, WorldObject const *target, Item const *itemTarget=NULL) const
Definition: SpellInfo.cpp:2026
Will ignore shapeshift checks.
Definition: Unit.h:472
bool HasAuraState(AuraStateType flag, SpellInfo const *spellProto=NULL, Unit const *Caster=NULL) const
Definition: Unit.cpp:7491
Definition: SharedDefines.h:1608
float GetMaxRange(bool positive=false, Unit *caster=NULL, Spell *spell=NULL) const
Definition: SpellInfo.cpp:2475
uint32 ApplyAuraName
Definition: SpellInfo.h:244
Item * GetItemTarget() const
Definition: Spell.h:203
AuraStateType
Definition: SharedDefines.h:1754
uint32 ExcludeCasterAuraSpell
Definition: SpellInfo.h:360
Definition: SharedDefines.h:1148
Definition: SharedDefines.h:1018
#define WORLD_TRIGGER
Definition: Unit.h:33
Definition: SharedDefines.h:1268
uint32 GetZoneId() const
Definition: Object.cpp:1525
SpellInfo const * m_triggeredByAuraSpell
Definition: Spell.h:826
int32 CalculateDamage(uint8 i, Unit const *target, float *var=nullptr) const
Definition: Spell.h:504
bool IsInCombat() const
Definition: Unit.h:1584
bool IsLocked() const
Definition: Item.h:306
Definition: SharedDefines.h:380
Loot loot
Definition: Creature.h:578
uint32 RequiresSpellFocus
Definition: SpellInfo.h:352
std::list< AuraEffect * > AuraEffectList
Definition: Unit.h:1322
Definition: SharedDefines.h:1391
bool IsAutoRepeat() const
Definition: Spell.h:591
Definition: DBCStructure.h:830
Definition: ObjectGuid.h:32
Definition: DisableMgr.h:47
SpellEffectInfo const * GetEffect(uint32 index) const
Definition: Spell.h:624
Definition: SharedDefines.h:1136
std::vector< uint8 > GetRawValue() const
Definition: ObjectGuid.cpp:127
Definition: SharedDefines.h:1038
arena_t NULL
Definition: jemalloc_internal.h:624
uint32 AuraInterruptFlags
Definition: SpellInfo.h:368
Definition: SpellAuraDefines.h:261
Definition: SharedDefines.h:1470
Definition: SharedDefines.h:1476
ObjectGuid GetCharmerGUID() const
Definition: Unit.h:1704
Definition: SharedDefines.h:362
WorldLocation const * GetDstPos() const
Definition: Spell.cpp:372
uint32 m_castItemEntry
Definition: Spell.h:550
Definition: UpdateFields.h:110
Will ignore Spell and Category cooldowns.
Definition: Unit.h:463
Definition: SharedDefines.h:1389
Definition: Object.h:423
Definition: Creature.h:467
bool HasAuraTypeWithAffectMask(AuraType auratype, SpellInfo const *affectedSpell) const
Definition: Unit.cpp:4270
Not triggered.
Definition: Unit.h:461
Definition: SharedDefines.h:1423
Definition: SpellAuraDefines.h:62
Definition: SharedDefines.h:370
Item * m_CastItem
Definition: Spell.h:548
Definition: SharedDefines.h:4387
Definition: SharedDefines.h:1350
ObjectGuid GetPetGUID() const
Definition: Unit.h:1708
SpellCastResult CheckRange(bool strict)
Definition: Spell.cpp:5853
Definition: SharedDefines.h:1374
Definition: SharedDefines.h:1046
uint32 EffectIndex
Definition: SpellInfo.h:242
#define sObjectMgr
Definition: ObjectMgr.h:1567
uint32 ErrorTextId
Definition: ConditionMgr.h:206
ShapeshiftForm GetShapeshiftForm() const
Definition: Unit.h:1932
Definition: SharedDefines.h:1413
Definition: SharedDefines.h:1379
Definition: SharedDefines.h:1343
Definition: DBCEnums.h:398
Player * ToPlayer()
Definition: Object.h:191
Definition: SharedDefines.h:1370
bool CalculatePath(float destX, float destY, float destZ, bool forceDest=false, bool straightLine=false)
Definition: PathGenerator.cpp:57
Definition: SharedDefines.h:1405
uint8 getLevel() const
Definition: Unit.h:1408
DBCStorage< AreaTableEntry > sAreaTableStore(AreaTablefmt)
SpellImplicitTargetInfo TargetA
Definition: SpellInfo.h:257
Definition: SharedDefines.h:611
int32 irand(int32 min, int32 max)
Definition: Random.cpp:39
Definition: DynamicObject.h:35
Definition: SharedDefines.h:475
Definition: SpellAuraDefines.h:357
Powers getPowerType() const
Definition: Unit.h:1444
TypeID GetTypeId() const
Definition: Object.h:113
TC_GAME_API Player * FindPlayer(ObjectGuid const &)
Definition: ObjectAccessor.cpp:209
Definition: SharedDefines.h:1334
CreatureTemplate const * GetCreatureTemplate() const
Definition: Creature.h:558
Definition: SharedDefines.h:1369
uint32 TriggerSpell
Definition: SpellInfo.h:263
WorldObject * GetObjectTarget() const
Definition: Spell.cpp:282
Definition: SharedDefines.h:1111
uint32 ErrorType
Definition: ConditionMgr.h:205
SpellCastResult CheckTarget(Unit const *caster, WorldObject const *target, bool implicit=true) const
Definition: SpellInfo.cpp:1875
T min(const T &x, const T &y)
Definition: g3dmath.h:305
Definition: SharedDefines.h:1388
SpellHistory * GetSpellHistory()
Definition: Unit.h:1926
bool IsPotion() const
Definition: Item.h:384
Powers
Definition: SharedDefines.h:246
Definition: SharedDefines.h:1066
AttackerSet const & getAttackers() const
Definition: Unit.h:1377
Definition: SharedDefines.h:1292
Definition: SharedDefines.h:1280
Definition: Unit.h:72
Unit * m_originalCaster
Definition: Spell.h:653
SpellCastResult CheckShapeshift(uint32 form) const
Definition: SpellInfo.cpp:1665
uint32 ExcludeCasterAuraState
Definition: SpellInfo.h:356
Definition: SharedDefines.h:371
uint32 SpellFamilyName
Definition: SpellInfo.h:396
bool HasDst() const
Definition: Spell.h:229
int32 RequiredAreasID
Definition: SpellInfo.h:400
PathGenerator m_preGeneratedPath
Definition: Spell.h:830
uint32 GetSpell() const
Definition: TradeData.h:49
bool isLineOfSightCalcEnabled() const
Definition: IVMapManager.h:86
Definition: SharedDefines.h:1163
Targets GetTarget() const
Definition: SpellInfo.cpp:121
Definition: TradeData.h:34
Definition: SharedDefines.h:1425
bool IsAlive() const
Definition: Unit.h:1692
bool HasAttribute(SpellAttr0 attribute) const
Definition: SpellInfo.h:462
float GetPositionY() const
Definition: Position.h:105
Definition: SharedDefines.h:1183
TradeSlots
Definition: TradeData.h:23
G3D::int16 z
Definition: Vector3int16.h:46
Definition: Item.h:259
Definition: Player.h:540
void GetPosition(float &x, float &y) const
Definition: Position.h:109
Definition: SharedDefines.h:1337
bool IsTriggered() const
Definition: Spell.h:595
#define sSpellMgr
Definition: SpellMgr.h:756
Definition: SpellInfo.h:238
float GetPositionZ() const
Definition: Position.h:106
int32_t int32
Definition: Define.h:146
uint8 ConditionTarget
Definition: ConditionMgr.h:209
AuraEffectList const & GetAuraEffectsByType(AuraType type) const
Definition: Unit.h:1832
uint32_t uint32
Definition: Define.h:150
Definition: SpellInfo.h:52
Definition: SharedDefines.h:1342
bool IsFriendlyTo(Unit const *unit) const
Definition: Unit.cpp:7170
Definition: Battlefield.h:196
Will ignore mounted/on vehicle restrictions.
Definition: Unit.h:474
GameObjectTemplate const * GetGOInfo() const
Definition: GameObject.h:894
G3D::int16 y
Definition: Vector2int16.h:38
Definition: ConditionMgr.h:181
DBCStorage< GlyphPropertiesEntry > sGlyphPropertiesStore(GlyphPropertiesfmt)
SpellInfo const * GetSpellInfo() const
Definition: Spell.h:614
uint32 GetCurrentFoodBenefitLevel(uint32 itemlevel) const
Definition: Pet.cpp:1061
void SetPathLengthLimit(float distance)
Definition: PathGenerator.h:64
Definition: SharedDefines.h:4386
Definition: GameObject.h:880
Definition: DisableMgr.h:29
bool IsDungeon() const
Definition: DBCStructure.h:857
Definition: SpellAuraDefines.h:322
#define sConditionMgr
Definition: ConditionMgr.h:307
SpellEffectInfoVector const & GetEffects() const
Definition: Spell.h:623
uint32 GetAreaId() const
Definition: Object.cpp:1530
Will not adjust facing to target (if any)
Definition: Unit.h:471
Definition: SharedDefines.h:379
Definition: SharedDefines.h:1346
bool IsRaid() const
Definition: DBCStructure.h:860
Definition: SpellAuraDefines.h:124
Definition: DBCStructure.h:509
Definition: SharedDefines.h:1043
Definition: PathGenerator.h:46
bool AllowMount
Definition: Map.h:226
bool IsReady(SpellInfo const *spellInfo, uint32 itemId=0, bool ignoreCategoryCooldown=false) const
Definition: SpellHistory.cpp:262
Definition: SpellAuraDefines.h:390
uint32 CasterAuraState
Definition: SpellInfo.h:354
bool IsTargetingArea() const
Definition: SpellInfo.cpp:419
#define sBattlefieldMgr
Definition: BattlefieldMgr.h:67
Definition: SharedDefines.h:1489
Definition: SharedDefines.h:1297
Definition: SharedDefines.h:3934
Definition: PathGenerator.h:49
Definition: SharedDefines.h:1162
ObjectGuid const & GetGUID() const
Definition: Object.h:105
DBCStorage< TalentEntry > sTalentStore(Talentfmt)
Definition: SpellAuraDefines.h:187
Definition: SpellAuraDefines.h:237
Definition: SharedDefines.h:1473
Definition: SharedDefines.h:1013
Definition: ObjectGuid.h:33
bool isLooted() const
Definition: LootMgr.h:375
bool HaveInDiet(ItemTemplate const *item) const
Definition: Pet.cpp:1043
Definition: SharedDefines.h:1347
Definition: SharedDefines.h:1172
uint32 GetTargetMask() const
Definition: Spell.h:179
Definition: UpdateFields.h:109
DBCStorage< MapEntry > sMapStore(Mapfmt)
bool IsCritter() const
Definition: Unit.h:1580
uint32 Category
Definition: DBCStructure.h:1245
static ObjectGuid const TradeItem
Definition: ObjectGuid.h:197
Creature * ToCreature()
Definition: Object.h:194
Definition: SharedDefines.h:1273
Definition: Unit.h:560
Definition: SpellInfo.h:60
Definition: SharedDefines.h:1393
Definition: Battleground.h:160
Definition: SharedDefines.h:4627
SpellCastResult CheckLocation(uint32 map_id, uint32 zone_id, uint32 area_id, Player const *player=NULL) const
Definition: SpellInfo.cpp:1724
Definition: SharedDefines.h:1293
int32_t int32
Definition: g3dmath.h:167
Disallows proc events from triggered spell (default)
Definition: Unit.h:476
Definition: SharedDefines.h:1419
ObjectGuid GetItemTargetGUID() const
Definition: Spell.h:202
uint32 CasterAuraSpell
Definition: SpellInfo.h:358
static IVMapManager * createOrGetVMapManager()
Definition: VMapFactory.cpp:28
Definition: SharedDefines.h:3938
Definition: SharedDefines.h:1349
Definition: Battleground.h:235
Definition: UpdateFields.h:191
SpellCastResult
Definition: SharedDefines.h:1265
SkillType
Definition: SharedDefines.h:3881
const FieldDescriptor value
Definition: descriptor.h:1522
Definition: SharedDefines.h:1191
bool IsOutdoors(float x, float y, float z) const
Definition: Map.cpp:2388
Definition: SharedDefines.h:1357
bool NeedsExplicitUnitTarget() const
Definition: SpellInfo.cpp:1358
Definition: ConditionMgr.h:144
uint32_t uint32
Definition: g3dmath.h:168
Definition: SpellAuraDefines.h:267
Definition: SharedDefines.h:1480
SpellCustomErrors m_customError
Definition: Spell.h:586
G3D::int16 x
Definition: Vector2int16.h:37
Definition: SharedDefines.h:1364
SpellCastResult CheckVehicle(Unit const *caster) const
Definition: SpellInfo.cpp:2061
Definition: SharedDefines.h:1333
void ReducePathLenghtByDist(float dist)
Definition: PathGenerator.cpp:905
bool IsIgnoringCooldowns() const
Definition: Spell.h:596
bool HasFlag(uint16 index, uint32 flag) const
Definition: Object.cpp:1239
Definition: SharedDefines.h:1094
Definition: SharedDefines.h:175
bool HasGlobalCooldown() const
Definition: Spell.cpp:7351
float GetPositionX() const
Definition: Position.h:104
Definition: SharedDefines.h:1354
Definition: SharedDefines.h:1067
uint32 Effect
Definition: SpellInfo.h:243
TriggerCastFlags _triggeredCastFlags
Definition: Spell.h:821
Definition: SharedDefines.h:1353
Definition: SharedDefines.h:1335
SpellCastResult CheckCasterAuras() const
Definition: Spell.cpp:5644
Spell ** m_selfContainer
Definition: Spell.h:634
Definition: Guild.h:320
Definition: DBCStructure.h:1255
Definition: SharedDefines.h:1306
PathType GetPathType() const
Definition: PathGenerator.h:73
SkillType GetRequiredLootSkill() const
Definition: Creature.h:150
Definition: Unit.h:1305
Definition: SharedDefines.h:1119
float GetObjectSize() const
Definition: Object.cpp:2656
Definition: Unit.h:728
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:2071
Definition: SharedDefines.h:1538
Definition: SharedDefines.h:1291
uint32 type
Definition: GameObject.h:37
Definition: SharedDefines.h:1279
Definition: SpellInfo.h:199
bool m_needComboPoints
Definition: Spell.h:685
Definition: SharedDefines.h:1328
Definition: SharedDefines.h:1282
bool IsEmpty() const
Definition: ObjectGuid.h:242
Definition: SharedDefines.h:1095
Definition: SharedDefines.h:373
Condition const * mLastFailedCondition
Definition: ConditionMgr.h:184
Definition: Pet.h:46
Definition: Unit.h:788
bool IsCooldownStartedOnEvent() const
Definition: SpellInfo.cpp:1470
Definition: SpellInfo.h:198
Definition: SharedDefines.h:248
GameObject * GetGOTarget() const
Definition: Spell.cpp:248
int32 MiscValueB
Definition: SpellInfo.h:254
Definition: SpellAuraDefines.h:138
uint32 SpellID
Definition: DBCStructure.h:1261
ItemTemplate const * GetTemplate() const
Definition: Item.cpp:547
Definition: DBCStructure.h:1242
Definition: SharedDefines.h:1430

+ Here is the caller graph for this function:

SpellCastResult Spell::CheckCasterAuras ( ) const
5645 {
5646  // spells totally immuned to caster auras (wsg flag drop, give marks etc)
5648  return SPELL_CAST_OK;
5649 
5650  uint8 school_immune = 0;
5651  uint32 mechanic_immune = 0;
5652  uint32 dispel_immune = 0;
5653 
5654  // Check if the spell grants school or mechanic immunity.
5655  // We use bitmasks so the loop is done only once and not on every aura check below.
5657  {
5658  for (SpellEffectInfo const* effect : GetEffects())
5659  {
5660  if (!effect)
5661  continue;
5662 
5663  if (effect->ApplyAuraName == SPELL_AURA_SCHOOL_IMMUNITY)
5664  school_immune |= uint32(effect->MiscValue);
5665  else if (effect->ApplyAuraName == SPELL_AURA_MECHANIC_IMMUNITY)
5666  mechanic_immune |= 1 << uint32(effect->MiscValue);
5667  else if (effect->ApplyAuraName == SPELL_AURA_DISPEL_IMMUNITY)
5668  dispel_immune |= SpellInfo::GetDispelMask(DispelType(effect->MiscValue));
5669  }
5670  // immune movement impairment and loss of control
5671  if (m_spellInfo->Id == 42292 || m_spellInfo->Id == 59752 || m_spellInfo->Id == 19574)
5673  }
5674 
5676 
5677  // Glyph of Pain Suppression
5678  // Allow Pain Suppression and Guardian Spirit to be cast while stunned
5679  // there is no other way to handle it
5680  if ((m_spellInfo->Id == 33206 || m_spellInfo->Id == 47788) && !m_caster->HasAura(63248))
5681  usableInStun = false;
5682 
5683  // Check whether the cast should be prevented by any state you might have.
5684  SpellCastResult prevented_reason = SPELL_CAST_OK;
5685  // Have to check if there is a stun aura. Otherwise will have problems with ghost aura apply while logging out
5686  uint32 unitflag = m_caster->GetUInt32Value(UNIT_FIELD_FLAGS); // Get unit state
5687  if (unitflag & UNIT_FLAG_STUNNED)
5688  {
5689  // spell is usable while stunned, check if caster has only mechanic stun auras, another stun types must prevent cast spell
5690  if (usableInStun)
5691  {
5692  bool foundNotStun = false;
5694  for (Unit::AuraEffectList::const_iterator i = stunAuras.begin(); i != stunAuras.end(); ++i)
5695  {
5696  if ((*i)->GetSpellInfo()->GetAllEffectsMechanicMask() && !((*i)->GetSpellInfo()->GetAllEffectsMechanicMask() & (1<<MECHANIC_STUN)))
5697  {
5698  foundNotStun = true;
5699  break;
5700  }
5701  }
5702  if (foundNotStun && m_spellInfo->Id != 22812)
5703  prevented_reason = SPELL_FAILED_STUNNED;
5704  }
5705  else
5706  prevented_reason = SPELL_FAILED_STUNNED;
5707  }
5709  prevented_reason = SPELL_FAILED_CONFUSED;
5711  prevented_reason = SPELL_FAILED_FLEEING;
5713  prevented_reason = SPELL_FAILED_SILENCED;
5715  prevented_reason = SPELL_FAILED_PACIFIED;
5716 
5717  // Attr must make flag drop spell totally immune from all effects
5718  if (prevented_reason != SPELL_CAST_OK)
5719  {
5720  if (school_immune || mechanic_immune || dispel_immune)
5721  {
5722  //Checking auras is needed now, because you are prevented by some state but the spell grants immunity.
5724  for (Unit::AuraApplicationMap::const_iterator itr = auras.begin(); itr != auras.end(); ++itr)
5725  {
5726  Aura const* aura = itr->second->GetBase();
5727  SpellInfo const* auraInfo = aura->GetSpellInfo();
5728  if (auraInfo->GetAllEffectsMechanicMask() & mechanic_immune)
5729  continue;
5730  if (auraInfo->GetSchoolMask() & school_immune && !auraInfo->HasAttribute(SPELL_ATTR1_UNAFFECTED_BY_SCHOOL_IMMUNE))
5731  continue;
5732  if (auraInfo->GetDispelMask() & dispel_immune)
5733  continue;
5734 
5735  //Make a second check for spell failed so the right SPELL_FAILED message is returned.
5736  //That is needed when your casting is prevented by multiple states and you are only immune to some of them.
5737  for (SpellEffectInfo const* effect : GetEffects())
5738  {
5739  if (!effect)
5740  continue;
5741 
5742  if (AuraEffect* part = aura->GetEffect(effect->EffectIndex))
5743  {
5744  switch (part->GetAuraType())
5745  {
5746  case SPELL_AURA_MOD_STUN:
5747  if (!usableInStun || !(auraInfo->GetAllEffectsMechanicMask() & (1<<MECHANIC_STUN)))
5748  return SPELL_FAILED_STUNNED;
5749  break;
5752  return SPELL_FAILED_CONFUSED;
5753  break;
5754  case SPELL_AURA_MOD_FEAR:
5756  return SPELL_FAILED_FLEEING;
5757  break;
5759  case SPELL_AURA_MOD_PACIFY:
5762  return SPELL_FAILED_PACIFIED;
5764  return SPELL_FAILED_SILENCED;
5765  break;
5766  default: break;
5767  }
5768  }
5769  }
5770  }
5771  }
5772  // You are prevented from casting and the spell cast does not grant immunity. Return a failed error.
5773  else
5774  return prevented_reason;
5775  }
5776  return SPELL_CAST_OK;
5777 }
Definition: SpellAuraEffects.h:30
SpellInfo const * GetSpellInfo() const
Definition: SpellAuras.h:130
bool HasAura(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, ObjectGuid itemCasterGUID=ObjectGuid::Empty, uint32 reqEffMask=0) const
Definition: Unit.cpp:4240
Definition: SharedDefines.h:1384
SpellInfo const *const m_spellInfo
Definition: Spell.h:547
Unit *const m_caster
Definition: Spell.h:647
uint32 Id
Definition: SpellInfo.h:329
uint32 GetUInt32Value(uint16 index) const
Definition: Object.cpp:300
Definition: SharedDefines.h:1802
Definition: SharedDefines.h:2058
Definition: SpellAuraDefines.h:72
Definition: Unit.h:686
Definition: SpellInfo.h:326
#define IMMUNE_TO_MOVEMENT_IMPAIRMENT_AND_LOSS_CONTROL_MASK
Definition: SharedDefines.h:1827
Definition: SharedDefines.h:554
std::list< AuraEffect * > AuraEffectList
Definition: Unit.h:1322
Definition: SpellAuraDefines.h:67
DispelType
Definition: SharedDefines.h:1836
Definition: Unit.h:696
Definition: SharedDefines.h:1305
Definition: SharedDefines.h:407
Definition: Unit.h:690
Definition: SpellAuraDefines.h:85
Definition: SharedDefines.h:1296
AuraEffect * GetEffect(uint32 index) const
Definition: SpellAuras.cpp:448
Definition: SharedDefines.h:539
AuraApplicationMap & GetAppliedAuras()
Definition: Unit.h:1789
bool HasAttribute(SpellAttr0 attribute) const
Definition: SpellInfo.h:462
Definition: SpellInfo.h:238
AuraEffectList const & GetAuraEffectsByType(AuraType type) const
Definition: Unit.h:1832
uint32_t uint32
Definition: Define.h:150
Definition: SpellAuraDefines.h:87
uint32 GetDispelMask() const
Definition: SpellInfo.cpp:2202
SpellEffectInfoVector const & GetEffects() const
Definition: Spell.h:623
Definition: SpellAuraDefines.h:137
uint32 PreventionType
Definition: SpellInfo.h:399
Definition: SharedDefines.h:1390
Definition: SharedDefines.h:574
Definition: UpdateFields.h:109
Definition: SpellAuraDefines.h:101
SpellSchoolMask GetSchoolMask() const
Definition: SpellInfo.cpp:2131
Definition: Unit.h:691
uint8_t uint8
Definition: Define.h:152
Definition: SharedDefines.h:553
SpellCastResult
Definition: SharedDefines.h:1265
uint32_t uint32
Definition: g3dmath.h:168
std::multimap< uint32, AuraApplication * > AuraApplicationMap
Definition: Unit.h:1315
uint32 GetAllEffectsMechanicMask() const
Definition: SpellInfo.cpp:2136
Definition: SpellAuras.h:116
Definition: SharedDefines.h:2059
Definition: SpellAuraDefines.h:65
Definition: SharedDefines.h:1394
Definition: SharedDefines.h:1538
Definition: SpellAuraDefines.h:99
Definition: SharedDefines.h:408
Definition: Unit.h:695
Definition: SpellAuraDefines.h:120

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Spell::CheckDst ( )
inline
Unit *const m_caster
Definition: Spell.h:647
SpellCastTargets m_targets
Definition: Spell.h:584
bool HasDst() const
Definition: Spell.h:229
void SetDst(float x, float y, float z, float orientation, uint32 mapId=MAPID_INVALID)
Definition: Spell.cpp:377

+ Here is the caller graph for this function:

bool Spell::CheckEffectTarget ( Unit const target,
SpellEffectInfo const effect,
Position const losPosition 
) const
Todo:
shit below shouldn't be here, but it's temporary
6579 {
6580  if (!effect->IsEffect())
6581  return false;
6582 
6583  switch (effect->ApplyAuraName)
6584  {
6586  case SPELL_AURA_MOD_CHARM:
6588  case SPELL_AURA_AOE_CHARM:
6589  if (target->GetTypeId() == TYPEID_UNIT && target->IsVehicle())
6590  return false;
6591  if (target->IsMounted())
6592  return false;
6593  if (!target->GetCharmerGUID().IsEmpty())
6594  return false;
6595  if (int32 value = CalculateDamage(effect->EffectIndex, target))
6596  if ((int32)target->getLevel() > value)
6597  return false;
6598  break;
6599  default:
6600  break;
6601  }
6602 
6603  // check for ignore LOS on the effect itself
6605  return true;
6606 
6607  // if spell is triggered, need to check for LOS disable on the aura triggering it and inherit that behaviour
6609  return true;
6610 
6612  //Check targets for LOS visibility (except spells without range limitations)
6613  switch (effect->Effect)
6614  {
6616  // player far away, maybe his corpse near?
6617  if (target != m_caster && !target->IsWithinLOSInMap(m_caster))
6618  {
6620  return false;
6621 
6623  if (!corpse)
6624  return false;
6625 
6626  if (target->GetGUID() != corpse->GetOwnerGUID())
6627  return false;
6628 
6629  if (!corpse->IsWithinLOSInMap(m_caster))
6630  return false;
6631  }
6632 
6633  // all ok by some way or another, skip normal check
6634  break;
6635  default: // normal case
6636  {
6637  if (losPosition)
6638  return target->IsWithinLOS(losPosition->GetPositionX(), losPosition->GetPositionY(), losPosition->GetPositionZ());
6639  else
6640  {
6641  // Get GO cast coordinates if original caster -> GO
6642  WorldObject* caster = NULL;
6645  if (!caster)
6646  caster = m_caster;
6647  if (target != m_caster && !target->IsWithinLOSInMap(caster))
6648  return false;
6649  }
6650  break;
6651  }
6652  }
6653 
6654  return true;
6655 }
SpellInfo const *const m_spellInfo
Definition: Spell.h:547
bool IsGameObject() const
Definition: ObjectGuid.h:252
Unit *const m_caster
Definition: Spell.h:647
uint32 Id
Definition: SpellInfo.h:329
Definition: Corpse.h:49
Definition: SpellAuraDefines.h:188
bool IsDisabledFor(DisableType type, uint32 entry, Unit const *unit, uint8 flags)
Definition: DisableMgr.cpp:277
Definition: SharedDefines.h:430
Definition: SpellAuraDefines.h:66
ObjectGuid GetOwnerGUID() const
Definition: Corpse.h:67
Map * GetMap() const
Definition: Object.h:543
ObjectGuid GetCorpseTargetGUID() const
Definition: Spell.cpp:266
bool IsWithinLOSInMap(WorldObject const *obj) const
Definition: Object.cpp:1584
SpellCastTargets m_targets
Definition: Spell.h:584
SpellInfo const * m_triggeredByAuraSpell
Definition: Spell.h:826
int32 CalculateDamage(uint8 i, Unit const *target, float *var=nullptr) const
Definition: Spell.h:504
Definition: ObjectGuid.h:32
Definition: DisableMgr.h:47
arena_t NULL
Definition: jemalloc_internal.h:624
bool IsWithinLOS(float x, float y, float z) const
Definition: Object.cpp:1668
Definition: Object.h:423
Definition: SpellAuraDefines.h:62
Definition: SharedDefines.h:1123
bool HasAttribute(SpellAttr0 attribute) const
Definition: SpellInfo.h:462
bool IsTriggered() const
Definition: Spell.h:595
int32_t int32
Definition: Define.h:146
TC_GAME_API Corpse * GetCorpse(WorldObject const &u, ObjectGuid const &guid)
Definition: ObjectAccessor.cpp:138
Definition: DisableMgr.h:29
ObjectGuid m_originalCasterGUID
Definition: Spell.h:651
Definition: SpellAuraDefines.h:237
const FieldDescriptor value
Definition: descriptor.h:1522
GameObject * GetGameObject(ObjectGuid const &guid)
Definition: Map.cpp:3545

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool Spell::CheckEffectTarget ( GameObject const target,
SpellEffectInfo const effect 
) const
6658 {
6659  if (!effect->IsEffect())
6660  return false;
6661 
6662  switch (effect->Effect)
6663  {
6667  if (target->GetGoType() != GAMEOBJECT_TYPE_DESTRUCTIBLE_BUILDING)
6668  return false;
6669  break;
6670  default:
6671  break;
6672  }
6673 
6674  return true;
6675 }
Definition: SharedDefines.h:1097
Definition: SharedDefines.h:1098
Definition: SharedDefines.h:1099
Definition: SharedDefines.h:2098

+ Here is the call graph for this function:

bool Spell::CheckEffectTarget ( Item const target,
SpellEffectInfo const effect 
) const
6678 {
6679  if (!effect->IsEffect())
6680  return false;
6681 
6682  return true;
6683 }

+ Here is the call graph for this function:

SpellCastResult Spell::CheckItems ( )
Todo:
Needs review
5952 {
5953  Player* player = m_caster->ToPlayer();
5954  if (!player)
5955  return SPELL_CAST_OK;
5956 
5957  if (!m_CastItem)
5958  {
5959  if (!m_castItemGUID.IsEmpty())
5961  }
5962  else
5963  {
5964  uint32 itemid = m_CastItem->GetEntry();
5965  if (!player->HasItemCount(itemid))
5967 
5968  ItemTemplate const* proto = m_CastItem->GetTemplate();
5969  if (!proto)
5971 
5972  for (uint8 i = 0; i < proto->Effects.size() && i < 5; ++i)
5973  if (proto->Effects[i]->Charges)
5974  if (m_CastItem->GetSpellCharges(i) == 0)
5976 
5977  // consumable cast item checks
5979  {
5980  // such items should only fail if there is no suitable effect at all - see Rejuvenation Potions for example
5981  SpellCastResult failReason = SPELL_CAST_OK;
5982  for (SpellEffectInfo const* effect : GetEffects())
5983  {
5984  // skip check, pet not required like checks, and for TARGET_UNIT_PET m_targets.GetUnitTarget() is not the real target but the caster
5985  if (!effect || effect->TargetA.GetTarget() == TARGET_UNIT_PET)
5986  continue;
5987 
5988  if (effect->Effect == SPELL_EFFECT_HEAL)
5989  {
5991  {
5993  continue;
5994  }
5995  else
5996  {
5997  failReason = SPELL_CAST_OK;
5998  break;
5999  }
6000  }
6001 
6002  // Mana Potion, Rage Potion, Thistle Tea(Rogue), ...
6003  if (effect->Effect == SPELL_EFFECT_ENERGIZE)
6004  {
6005  if (effect->MiscValue < 0 || effect->MiscValue >= int8(MAX_POWERS))
6006  {
6008  continue;
6009  }
6010 
6011  Powers power = Powers(effect->MiscValue);
6013  {
6015  continue;
6016  }
6017  else
6018  {
6019  failReason = SPELL_CAST_OK;
6020  break;
6021  }
6022  }
6023  }
6024  if (failReason != SPELL_CAST_OK)
6025  return failReason;
6026  }
6027  }
6028 
6029  // check target item
6031  {
6032  if (!m_targets.GetItemTarget())
6033  return SPELL_FAILED_ITEM_GONE;
6034 
6037  }
6038  // if not item target then required item must be equipped
6039  else
6040  {
6042  if (!player->HasItemFitToSpellRequirements(m_spellInfo))
6044  }
6045 
6046  // do not take reagents for these item casts
6048  {
6049  bool checkReagents = !(_triggeredCastFlags & TRIGGERED_IGNORE_POWER_AND_REAGENT_COST) && !player->CanNoReagentCast(m_spellInfo);
6050  // Not own traded item (in trader trade slot) requires reagents even if triggered spell
6051  if (!checkReagents)
6052  if (Item* targetItem = m_targets.GetItemTarget())
6053  if (targetItem->GetOwnerGUID() != m_caster->GetGUID())
6054  checkReagents = true;
6055 
6056  // check reagents (ignore triggered spells with reagents processed by original spell) and special reagent ignore case.
6057  if (checkReagents)
6058  {
6059  for (uint32 i = 0; i < MAX_SPELL_REAGENTS; i++)
6060  {
6061  if (m_spellInfo->Reagent[i] <= 0)
6062  continue;
6063 
6064  uint32 itemid = m_spellInfo->Reagent[i];
6065  uint32 itemcount = m_spellInfo->ReagentCount[i];
6066 
6067  // if CastItem is also spell reagent
6068  if (m_CastItem && m_CastItem->GetEntry() == itemid)
6069  {
6070  ItemTemplate const* proto = m_CastItem->GetTemplate();
6071  if (!proto)
6073  for (uint8 s = 0; s < proto->Effects.size() && s < 5; ++s)
6074  {
6075  // CastItem will be used up and does not count as reagent
6076  int32 charges = m_CastItem->GetSpellCharges(s);
6077  if (proto->Effects[s]->Charges < 0 && abs(charges) < 2)
6078  {
6079  ++itemcount;
6080  break;
6081  }
6082  }
6083  }
6084  if (!player->HasItemCount(itemid, itemcount))
6085  return SPELL_FAILED_REAGENTS;
6086  }
6087  }
6088 
6089  // check totem-item requirements (items presence in inventory)
6090  uint32 totems = 2;
6091  for (uint8 i = 0; i < 2; ++i)
6092  {
6093  if (m_spellInfo->Totem[i] != 0)
6094  {
6095  if (player->HasItemCount(m_spellInfo->Totem[i]))
6096  {
6097  totems -= 1;
6098  continue;
6099  }
6100  }
6101  else
6102  totems -= 1;
6103  }
6104 
6105  if (totems != 0)
6106  return SPELL_FAILED_TOTEMS;
6107 
6108  // Check items for TotemCategory (items presence in inventory)
6109  uint32 totemCategory = 2;
6110  for (uint8 i = 0; i < 2; ++i)
6111  {
6112  if (m_spellInfo->TotemCategory[i] != 0)
6113  {
6114  if (player->HasItemTotemCategory(m_spellInfo->TotemCategory[i]))
6115  {
6116  totemCategory -= 1;
6117  continue;
6118  }
6119  }
6120  else
6121  totemCategory -= 1;
6122  }
6123 
6124  if (totemCategory != 0)
6126  }
6127 
6128  // special checks for spell effects
6129  for (SpellEffectInfo const* effect : GetEffects())
6130  {
6131  if (!effect)
6132  continue;
6133 
6134  switch (effect->Effect)
6135  {
6138  {
6139  if (!IsTriggered() && effect->ItemType)
6140  {
6141  ItemPosCountVec dest;
6142  InventoryResult msg = player->CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, effect->ItemType, 1);
6143  if (msg != EQUIP_ERR_OK)
6144  {
6145  ItemTemplate const* pProto = sObjectMgr->GetItemTemplate(effect->ItemType);
6147  if (pProto && !(pProto->GetItemLimitCategory()))
6148  {
6149  player->SendEquipError(msg, NULL, NULL, effect->ItemType);
6150  return SPELL_FAILED_DONT_REPORT;
6151  }
6152  else
6153  {
6154  if (!(m_spellInfo->SpellFamilyName == SPELLFAMILY_MAGE && (m_spellInfo->SpellFamilyFlags[0] & 0x40000000)))
6156  else if (!(player->HasItemCount(effect->ItemType)))
6158  else if (SpellEffectInfo const* efi = GetEffect(EFFECT_1))
6159  player->CastSpell(m_caster, efi->CalcValue(), false); // move this to anywhere
6160  return SPELL_FAILED_DONT_REPORT;
6161  }
6162  }
6163  }
6164  break;
6165  }
6167  if (effect->ItemType && m_targets.GetItemTarget()
6168  && (m_targets.GetItemTarget()->IsVellum()))
6169  {
6170  // cannot enchant vellum for other player
6173  // do not allow to enchant vellum from scroll made by vellum-prevent exploit
6176  ItemPosCountVec dest;
6177  InventoryResult msg = player->CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, effect->ItemType, 1);
6178  if (msg != EQUIP_ERR_OK)
6179  {
6180  player->SendEquipError(msg, NULL, NULL, effect->ItemType);
6181  return SPELL_FAILED_DONT_REPORT;
6182  }
6183  }
6184  // no break
6186  {
6187  Item* targetItem = m_targets.GetItemTarget();
6188  if (!targetItem)
6190 
6191  if (targetItem->GetTemplate()->GetBaseItemLevel() < m_spellInfo->BaseLevel)
6192  return SPELL_FAILED_LOWLEVEL;
6193 
6194  bool isItemUsable = false;
6195  ItemTemplate const* proto = targetItem->GetTemplate();
6196  for (uint8 e = 0; e < proto->Effects.size(); ++e)
6197  {
6198  if (proto->Effects[e]->SpellID && (
6199  proto->Effects[e]->Trigger == ITEM_SPELLTRIGGER_ON_USE ||
6200  proto->Effects[e]->Trigger == ITEM_SPELLTRIGGER_ON_NO_DELAY_USE))
6201  {
6202  isItemUsable = true;
6203  break;
6204  }
6205  }
6206 
6207  SpellItemEnchantmentEntry const* enchantEntry = sSpellItemEnchantmentStore.LookupEntry(effect->MiscValue);
6208  // do not allow adding usable enchantments to items that have use effect already
6209  if (enchantEntry)
6210  {
6211  for (uint8 s = 0; s < MAX_ITEM_ENCHANTMENT_EFFECTS; ++s)
6212  {
6213  switch (enchantEntry->Effect[s])
6214  {
6216  if (isItemUsable)
6218  break;
6220  {
6221  uint32 numSockets = 0;
6222  for (uint32 socket = 0; socket < MAX_ITEM_PROTO_SOCKETS; ++socket)
6223  if (targetItem->GetSocketColor(socket))
6224  ++numSockets;
6225 
6226  if (numSockets == MAX_ITEM_PROTO_SOCKETS || targetItem->GetEnchantmentId(PRISMATIC_ENCHANTMENT_SLOT))
6227  return SPELL_FAILED_MAX_SOCKETS;
6228  break;
6229  }
6230  }
6231  }
6232  }
6233 
6234  // Not allow enchant in trade slot for some enchant type
6235  if (targetItem->GetOwner() != m_caster)
6236  {
6237  if (!enchantEntry)
6238  return SPELL_FAILED_ERROR;
6239  if (enchantEntry->Flags & ENCHANTMENT_CAN_SOULBOUND)
6241  }
6242  break;
6243  }
6245  {
6246  Item* item = m_targets.GetItemTarget();
6247  if (!item)
6249  // Not allow enchant in trade slot for some enchant type
6250  if (item->GetOwner() != m_caster)
6251  {
6252  uint32 enchant_id = effect->MiscValue;
6253  SpellItemEnchantmentEntry const* pEnchant = sSpellItemEnchantmentStore.LookupEntry(enchant_id);
6254  if (!pEnchant)
6255  return SPELL_FAILED_ERROR;
6256  if (pEnchant->Flags & ENCHANTMENT_CAN_SOULBOUND)
6258  }
6259  break;
6260  }
6262  // check item existence in effect code (not output errors at offhand hold item effect to main hand for example
6263  break;
6265  {
6266  if (!m_targets.GetItemTarget())
6268 
6269  // prevent disenchanting in trade slot
6272 
6273  ItemTemplate const* itemProto = m_targets.GetItemTarget()->GetTemplate();
6274  if (!itemProto)
6276 
6277  uint32 item_quality = itemProto->GetQuality();
6278  // 2.0.x addon: Check player enchanting level against the item disenchanting requirements
6279  uint32 item_disenchantskilllevel = itemProto->RequiredDisenchantSkill;
6280  if (item_disenchantskilllevel == uint32(-1))
6282  if (item_disenchantskilllevel > player->GetSkillValue(SKILL_ENCHANTING))
6284  if (item_quality > 4 || item_quality < 2)
6286  if (itemProto->GetClass() != ITEM_CLASS_WEAPON && itemProto->GetClass() != ITEM_CLASS_ARMOR)
6288  if (!itemProto->DisenchantID)
6290  break;
6291  }
6293  {
6294  if (!m_targets.GetItemTarget())
6296  //ensure item is a prospectable ore
6299  //prevent prospecting in trade slot
6302  //Check for enough skill in jewelcrafting
6303  uint32 item_prospectingskilllevel = m_targets.GetItemTarget()->GetTemplate()->GetRequiredSkillRank();
6304  if (item_prospectingskilllevel >player->GetSkillValue(SKILL_JEWELCRAFTING))
6306  //make sure the player has the required ores in inventory
6307  if (m_targets.GetItemTarget()->GetCount() < 5)
6309 
6312 
6313  break;
6314  }
6315  case SPELL_EFFECT_MILLING:
6316  {
6317  if (!m_targets.GetItemTarget())
6319  //ensure item is a millable herb
6322  //prevent milling in trade slot
6325  //Check for enough skill in inscription
6326  uint32 item_millingskilllevel = m_targets.GetItemTarget()->GetTemplate()->GetRequiredSkillRank();
6327  if (item_millingskilllevel > player->GetSkillValue(SKILL_INSCRIPTION))
6329  //make sure the player has the required herbs in inventory
6330  if (m_targets.GetItemTarget()->GetCount() < 5)
6332 
6335 
6336  break;
6337  }
6340  {
6341  if (m_attackType != RANGED_ATTACK)
6342  break;
6343 
6344  Item* pItem = player->GetWeaponForAttack(m_attackType);
6345  if (!pItem || pItem->IsBroken())
6347 
6348  switch (pItem->GetTemplate()->GetSubClass())
6349  {
6351  {
6352  uint32 ammo = pItem->GetEntry();
6353  if (!player->HasItemCount(ammo))
6354  return SPELL_FAILED_NO_AMMO;
6355  break;
6356  }
6361  break;
6362  default:
6363  break;
6364  }
6365  break;
6366  }
6368  {
6369  uint32 item_id = effect->ItemType;
6370  ItemTemplate const* pProto = sObjectMgr->GetItemTemplate(item_id);
6371 
6372  if (!pProto)
6374 
6375  if (Item* pitem = player->GetItemByEntry(item_id))
6376  {
6377  for (uint8 x = 0; x < pProto->Effects.size() && x < 5; ++x)
6378  if (pProto->Effects[x]->Charges != 0 && pitem->GetSpellCharges(x) == pProto->Effects[x]->Charges)
6380  }
6381  break;
6382  }
6383  default:
6384  break;
6385  }
6386  }
6387 
6388  // check weapon presence in slots for main/offhand weapons
6389  if (!(_triggeredCastFlags & TRIGGERED_IGNORE_EQUIPPED_ITEM_REQUIREMENT) && m_spellInfo->EquippedItemClass >=0)
6390  {
6391  // main hand weapon required
6393  {
6394  Item* item = m_caster->ToPlayer()->GetWeaponForAttack(BASE_ATTACK);
6395 
6396  // skip spell if no weapon in slot or broken
6397  if (!item || item->IsBroken())
6399 
6400  // skip spell if weapon not fit to triggered spell
6402  return (_triggeredCastFlags & TRIGGERED_DONT_REPORT_CAST_ERROR) ? SPELL_FAILED_DONT_REPORT : SPELL_FAILED_EQUIPPED_ITEM_CLASS;
6403  }
6404 
6405  // offhand hand weapon required
6407  {
6408  Item* item = m_caster->ToPlayer()->GetWeaponForAttack(OFF_ATTACK);
6409 
6410  // skip spell if no weapon in slot or broken
6411  if (!item || item->IsBroken())
6412  return (_triggeredCastFlags & TRIGGERED_DONT_REPORT_CAST_ERROR) ? SPELL_FAILED_DONT_REPORT : SPELL_FAILED_EQUIPPED_ITEM_CLASS;
6413 
6414  // skip spell if weapon not fit to triggered spell
6416  return (_triggeredCastFlags & TRIGGERED_DONT_REPORT_CAST_ERROR) ? SPELL_FAILED_DONT_REPORT : SPELL_FAILED_EQUIPPED_ITEM_CLASS;
6417  }
6418  }
6419 
6420  return SPELL_CAST_OK;
6421 }
uint32 GetBaseItemLevel() const
Definition: ItemTemplate.h:667
G3D::Matrix abs(const G3D::Matrix &M)
Definition: Matrix.h:632
bool IsVellum() const
Definition: Item.h:385
uint32 GetCount() const
Definition: Item.h:322
Definition: SharedDefines.h:1102
SpellInfo const *const m_spellInfo
Definition: Spell.h:547
Unit *const m_caster
Definition: Spell.h:647
uint32 ReagentCount[MAX_SPELL_REAGENTS]
Definition: SpellInfo.h:384
int32 EquippedItemClass
Definition: SpellInfo.h:385
Unit * GetUnitTarget() const
Definition: Spell.cpp:222
Definition: SharedDefines.h:1299
int32 GetSpellCharges(uint8 index=0) const
Definition: Item.h:364
Definition: SharedDefines.h:1417
int8_t int8
Definition: Define.h:148
Definition: DBCEnums.h:517
LootStore LootTemplates_Prospecting("prospecting_loot_template","item entry (ore)", true)
Definition: SharedDefines.h:29
Definition: SharedDefines.h:1166
Definition: SharedDefines.h:1879
Definition: SharedDefines.h:488
Definition: ItemTemplate.h:101
Definition: SharedDefines.h:1361
Definition: Unit.h:379
Definition: SharedDefines.h:1269
Definition: SharedDefines.h:1341
Definition: SharedDefines.h:1271
Definition: SharedDefines.h:1040
SpellCastTargets m_targets
Definition: Spell.h:584
Definition: SharedDefines.h:3973
Definition: Unit.h:619
uint32 Totem[2]
Definition: SpellInfo.h:382
#define MAX_ITEM_ENCHANTMENT_EFFECTS
Definition: DBCStructure.h:1212
Item * GetItemTarget() const
Definition: Spell.h:203
flag128 SpellFamilyFlags
Definition: SpellInfo.h:397
Definition: SharedDefines.h:1418
uint32 GetClass() const
Definition: ItemTemplate.h:653
SpellEffectInfo const * GetEffect(uint32 index) const
Definition: Spell.h:624
Definition: SharedDefines.h:1362
Definition: SharedDefines.h:1330
arena_t NULL
Definition: jemalloc_internal.h:624
Definition: SharedDefines.h:1109
Will ignore Spell and Category cooldowns.
Definition: Unit.h:463
uint32 GetRequiredSkillRank() const
Definition: ItemTemplate.h:670
Definition: SharedDefines.h:1286
Definition: SharedDefines.h:1298
Item * m_CastItem
Definition: Spell.h:548
Definition: DBCStructure.h:1214
int32 GetPower(Powers power) const
Definition: Unit.cpp:11589
#define sObjectMgr
Definition: ObjectMgr.h:1567
LootStore LootTemplates_Milling("milling_loot_template","item entry (herb)", true)
Definition: SharedDefines.h:1416
SocketColor GetSocketColor(uint32 index) const
Definition: Item.h:393
Player * ToPlayer()
Definition: Object.h:191
Definition: SharedDefines.h:1027
Definition: SharedDefines.h:1034
Definition: Item.h:208
Definition: SharedDefines.h:1386
uint32 GetItemLimitCategory() const
Definition: ItemTemplate.h:700
Definition: SharedDefines.h:1334
Definition: ItemTemplate.h:424
Definition: ItemTemplate.h:202
Definition: SharedDefines.h:4626
Definition: Item.h:48
Powers
Definition: SharedDefines.h:246
Definition: Unit.h:378
std::vector< ItemEffectEntry const * > Effects
Definition: ItemTemplate.h:707
Definition: Unit.h:618
Definition: SharedDefines.h:1356
uint32 SpellFamilyName
Definition: SpellInfo.h:396
ObjectGuid m_castItemGUID
Definition: Spell.h:549
Player * GetOwner() const
Definition: Item.cpp:552
bool IsFullHealth() const
Definition: Unit.h:1429
bool HasAttribute(SpellAttr0 attribute) const
Definition: SpellInfo.h:462
Definition: ItemTemplate.h:438
uint32 DisenchantID
Definition: ItemTemplate.h:711
Definition: ItemTemplate.h:425
Definition: Item.h:259
uint32 GetItemTargetEntry() const
Definition: Spell.h:204
bool IsTriggered() const
Definition: Spell.h:595
Definition: SpellInfo.h:238
int32_t int32
Definition: Define.h:146
uint32_t uint32
Definition: Define.h:150
Definition: SharedDefines.h:1068
DBCStorage< SpellItemEnchantmentEntry > sSpellItemEnchantmentStore(SpellItemEnchantmentfmt)
uint32 RequiredDisenchantSkill
Definition: ItemTemplate.h:712
SpellEffectInfoVector const & GetEffects() const
Definition: Spell.h:623
Definition: SharedDefines.h:1020
uint32 TotemCategory[2]
Definition: SpellInfo.h:388
WeaponAttackType m_attackType
Definition: Spell.h:657
bool HaveLootFor(uint32 loot_id) const
Definition: LootMgr.h:229
ObjectGuid GetOwnerGUID() const
Definition: Item.h:272
int32 Reagent[MAX_SPELL_REAGENTS]
Definition: SpellInfo.h:383
Definition: SharedDefines.h:1137
Definition: SharedDefines.h:1297
Definition: SharedDefines.h:1474
Definition: ItemTemplate.h:440
ObjectGuid const & GetGUID() const
Definition: Object.h:105
bool IsBroken() const
Definition: Item.h:310
Definition: ItemTemplate.h:441
Definition: ItemTemplate.h:369
Definition: ItemTemplate.h:647
Definition: SharedDefines.h:4004
Definition: SharedDefines.h:1491
#define MAX_ITEM_PROTO_SOCKETS
Definition: DB2Structure.h:789
uint32 GetSubClass() const
Definition: ItemTemplate.h:654
Definition: SharedDefines.h:4021
Definition: SharedDefines.h:1331
Definition: ItemTemplate.h:367
Definition: SharedDefines.h:1063
uint32 BaseLevel
Definition: SpellInfo.h:374
Definition: SharedDefines.h:1283
Disallows proc events from triggered spell (default)
Definition: Unit.h:476
ObjectGuid GetItemTargetGUID() const
Definition: Spell.h:202
uint8_t uint8
Definition: Define.h:152
Definition: SharedDefines.h:1064
uint32 GetFlags() const
Definition: ItemTemplate.h:656
Definition: SharedDefines.h:265
Definition: ItemTemplate.h:111
int32 GetMaxPower(Powers power) const
Definition: Unit.cpp:11598
SpellCastResult
Definition: SharedDefines.h:1265
Definition: SharedDefines.h:1076
uint32 GetEntry() const
Definition: Object.h:107
uint32_t uint32
Definition: g3dmath.h:168
Definition: SharedDefines.h:1329
#define MAX_SPELL_REAGENTS
Definition: DB2Structure.h:1285
Definition: ItemTemplate.h:201
G3D::int16 x
Definition: Vector2int16.h:37
Definition: Item.h:180
InventoryResult
Definition: Item.h:46
Definition: ItemTemplate.h:191
Definition: SharedDefines.h:1168
Definition: SharedDefines.h:1285
uint32 Flags
Definition: DBCStructure.h:1223
TriggerCastFlags _triggeredCastFlags
Definition: Spell.h:821
Definition: SharedDefines.h:1335
Definition: ItemTemplate.h:371
Definition: SharedDefines.h:1538
Definition: SharedDefines.h:1486
uint32 Effect[MAX_ITEM_ENCHANTMENT_EFFECTS]
Definition: DBCStructure.h:1218
bool IsEmpty() const
Definition: ObjectGuid.h:242
Will return SPELL_FAILED_DONT_REPORT in CheckCast functions.
Definition: Unit.h:477
Definition: Unit.h:617
Definition: SharedDefines.h:474
Definition: DBCEnums.h:516
ItemTemplate const * GetTemplate() const
Definition: Item.cpp:547
Definition: SharedDefines.h:1302
uint32 GetEnchantmentId(EnchantmentSlot slot) const
Definition: Item.h:351
uint32 GetQuality() const
Definition: ItemTemplate.h:655
bool IsFitToSpellRequirements(SpellInfo const *spellInfo) const
Definition: Item.cpp:869
Definition: SharedDefines.h:1167

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

SpellCastResult Spell::CheckPetCast ( Unit target)
5612 {
5613  if (m_caster->HasUnitState(UNIT_STATE_CASTING) && !(_triggeredCastFlags & TRIGGERED_IGNORE_CAST_IN_PROGRESS)) //prevent spellcast interruption by another spellcast
5615 
5616  // dead owner (pets still alive when owners ressed?)
5617  if (Unit* owner = m_caster->GetCharmerOrOwner())
5618  if (!owner->IsAlive())
5619  return SPELL_FAILED_CASTER_DEAD;
5620 
5621  if (!target && m_targets.GetUnitTarget())
5622  target = m_targets.GetUnitTarget();
5623 
5625  {
5626  if (!target)
5628  m_targets.SetUnitTarget(target);
5629  }
5630 
5631  // cooldown
5632  if (Creature* creatureCaster = m_caster->ToCreature())
5633  if (!creatureCaster->GetSpellHistory()->IsReady(m_spellInfo))
5634  return SPELL_FAILED_NOT_READY;
5635 
5636  // Check if spell is affected by GCD
5639  return SPELL_FAILED_NOT_READY;
5640 
5641  return CheckCast(true);
5642 }
SpellInfo const *const m_spellInfo
Definition: Spell.h:547
Unit *const m_caster
Definition: Spell.h:647
Unit * GetUnitTarget() const
Definition: Spell.cpp:222
Definition: Unit.h:565
SpellCastTargets m_targets
Definition: Spell.h:584
Definition: SharedDefines.h:1391
uint32 StartRecoveryCategory
Definition: SpellInfo.h:365
Definition: Creature.h:467
CharmInfo * GetCharmInfo()
Definition: Unit.h:1748
SpellHistory * GetSpellHistory()
Definition: Unit.h:1926
Unit * GetCharmerOrOwner() const
Definition: Unit.cpp:7627
void SetUnitTarget(Unit *target)
Definition: Spell.cpp:230
SpellCastResult CheckCast(bool strict)
Definition: Spell.cpp:4739
Creature * ToCreature()
Definition: Object.h:194
Definition: SharedDefines.h:1293
bool HasUnitState(const uint32 f) const
Definition: Unit.h:1395
bool HasGlobalCooldown(SpellInfo const *spellInfo) const
Definition: SpellHistory.cpp:821
Will ignore aura scaling.
Definition: Unit.h:466
bool NeedsExplicitUnitTarget() const
Definition: SpellInfo.cpp:1358
TriggerCastFlags _triggeredCastFlags
Definition: Spell.h:821
Definition: SharedDefines.h:1353
Definition: Unit.h:1305
Definition: SharedDefines.h:1279

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

SpellCastResult Spell::CheckPower ( )
5914 {
5915  // item cast not used power
5916  if (m_CastItem)
5917  return SPELL_CAST_OK;
5918 
5919  for (SpellInfo::CostData const& cost : m_powerCost)
5920  {
5921  // health as power used - need check health amount
5922  if (cost.Power == POWER_HEALTH)
5923  {
5924  if (int32(m_caster->GetHealth()) <= cost.Amount)
5926  continue;
5927  }
5928  // Check valid power type
5929  if (cost.Power >= MAX_POWERS)
5930  {
5931  TC_LOG_ERROR("spells", "Spell::CheckPower: Unknown power type '%d'", cost.Power);
5932  return SPELL_FAILED_UNKNOWN;
5933  }
5934 
5935  //check rune cost only if a spell has PowerType == POWER_RUNES
5936  if (cost.Power == POWER_RUNES)
5937  {
5939  if (failReason != SPELL_CAST_OK)
5940  return failReason;
5941  }
5942 
5943  // Check power amount
5944  if (int32(m_caster->GetPower(cost.Power)) < cost.Amount)
5945  return SPELL_FAILED_NO_POWER;
5946  }
5947 
5948  return SPELL_CAST_OK;
5949 }
SpellInfo const *const m_spellInfo
Definition: Spell.h:547
Unit *const m_caster
Definition: Spell.h:647
Item * m_CastItem
Definition: Spell.h:548
Definition: SpellInfo.h:553
int32 GetPower(Powers power) const
Definition: Unit.cpp:11589
Definition: SharedDefines.h:253
Definition: SharedDefines.h:1292
Definition: SharedDefines.h:1537
std::vector< SpellInfo::CostData > m_powerCost
Definition: Spell.h:659
Definition: SharedDefines.h:1371
int32_t int32
Definition: g3dmath.h:167
Definition: SharedDefines.h:265
SpellCastResult
Definition: SharedDefines.h:1265
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
uint32 GetHealth() const
Definition: Unit.h:1426
uint32 RuneCostID
Definition: SpellInfo.h:378
SpellCastResult CheckRuneCost(uint32 runeCostID)
Definition: Spell.cpp:4473
Definition: SharedDefines.h:1538
Definition: SharedDefines.h:267

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

SpellCastResult Spell::CheckRange ( bool  strict)
5854 {
5855  // Don't check for instant cast spells
5856  if (!strict && m_casttime == 0)
5857  return SPELL_CAST_OK;
5858 
5859  uint32 range_type = 0;
5860 
5861  if (m_spellInfo->RangeEntry)
5862  {
5863  // check needed by 68766 51693 - both spells are cast on enemies and have 0 max range
5864  // these are triggered by other spells - possibly we should omit range check in that case?
5865  if (m_spellInfo->RangeEntry->ID == 1)
5866  return SPELL_CAST_OK;
5867 
5868  range_type = m_spellInfo->RangeEntry->Flags;
5869  }
5870 
5871  Unit* target = m_targets.GetUnitTarget();
5872  float max_range = m_caster->GetSpellMaxRangeForTarget(target, m_spellInfo);
5873  float min_range = m_caster->GetSpellMinRangeForTarget(target, m_spellInfo);
5874 
5875  if (Player* modOwner = m_caster->GetSpellModOwner())
5876  modOwner->ApplySpellMod(m_spellInfo->Id, SPELLMOD_RANGE, max_range, this);
5877 
5878  if (target && target != m_caster)
5879  {
5880  if (range_type == SPELL_RANGE_MELEE)
5881  {
5882  // Because of lag, we can not check too strictly here.
5883  if (!m_caster->IsWithinMeleeRange(target, max_range))
5885  }
5886  else if (!m_caster->IsWithinCombatRange(target, max_range))
5888 
5889  if (range_type == SPELL_RANGE_RANGED)
5890  {
5891  if (m_caster->IsWithinMeleeRange(target))
5892  return !(_triggeredCastFlags & TRIGGERED_DONT_REPORT_CAST_ERROR) ? SPELL_FAILED_TOO_CLOSE : SPELL_FAILED_DONT_REPORT;
5893  }
5894  else if (min_range && m_caster->IsWithinCombatRange(target, min_range)) // skip this check if min_range = 0
5895  return !(_triggeredCastFlags & TRIGGERED_DONT_REPORT_CAST_ERROR) ? SPELL_FAILED_TOO_CLOSE : SPELL_FAILED_DONT_REPORT;
5896 
5897  if (m_caster->GetTypeId() == TYPEID_PLAYER &&
5898  (m_spellInfo->FacingCasterFlags & SPELL_FACING_FLAG_INFRONT) && !m_caster->HasInArc(static_cast<float>(M_PI), target))
5899  return !(_triggeredCastFlags & TRIGGERED_DONT_REPORT_CAST_ERROR) ? SPELL_FAILED_UNIT_NOT_INFRONT : SPELL_FAILED_DONT_REPORT;
5900  }
5901 
5902  if (m_targets.HasDst() && !m_targets.HasTraj())
5903  {
5904  if (!m_caster->IsWithinDist3d(m_targets.GetDstPos(), max_range))
5906  if (min_range && m_caster->IsWithinDist3d(m_targets.GetDstPos(), min_range))
5907  return SPELL_FAILED_TOO_CLOSE;
5908  }
5909 
5910  return SPELL_CAST_OK;
5911 }
bool IsWithinCombatRange(const Unit *obj, float dist2compare) const
Definition: Unit.cpp:492
Definition: SharedDefines.h:1421
float GetSpellMinRangeForTarget(Unit const *target, SpellInfo const *spellInfo) const
Definition: Unit.cpp:11239
uint32 Flags
Definition: DB2Structure.h:1280
SpellInfo const *const m_spellInfo
Definition: Spell.h:547
Unit *const m_caster
Definition: Spell.h:647
uint32 Id
Definition: SpellInfo.h:329
Unit * GetUnitTarget() const
Definition: Spell.cpp:222
Definition: SharedDefines.h:1415
Definition: Spell.h:114
int32 m_casttime
Definition: Spell.h:660
#define M_PI
Definition: Common.h:163
Definition: Unit.h:91
Definition: SharedDefines.h:1383
SpellCastTargets m_targets
Definition: Spell.h:584
WorldLocation const * GetDstPos() const
Definition: Spell.cpp:372
bool HasTraj() const
Definition: Spell.h:230
TypeID GetTypeId() const
Definition: Object.h:113
SpellRangeEntry const * RangeEntry
Definition: SpellInfo.h:379
bool HasDst() const
Definition: Spell.h:229
uint32_t uint32
Definition: Define.h:150
bool IsWithinMeleeRange(const Unit *obj, float dist=MELEE_RANGE) const
Definition: Unit.cpp:508
bool HasInArc(float arcangle, Position const *pos, float border=2.0f) const
Definition: Position.cpp:129
bool IsWithinDist3d(float x, float y, float z, float dist) const
Definition: Object.cpp:1638
uint32 ID
Definition: DB2Structure.h:1275
Definition: SharedDefines.h:1297
Definition: ObjectGuid.h:33
Definition: Unit.h:197
Player * GetSpellModOwner() const
Definition: Unit.cpp:12691
Disallows proc events from triggered spell (default)
Definition: Unit.h:476
uint32 FacingCasterFlags
Definition: SpellInfo.h:353
Definition: Spell.h:115
TriggerCastFlags _triggeredCastFlags
Definition: Spell.h:821
Definition: Unit.h:1305
float GetSpellMaxRangeForTarget(Unit const *target, SpellInfo const *spellInfo) const
Definition: Unit.cpp:11228
Definition: SharedDefines.h:1538

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

SpellCastResult Spell::CheckRuneCost ( uint32  runeCostID)
4474 {
4475  if (std::find_if(m_powerCost.begin(), m_powerCost.end(), [](SpellInfo::CostData const& cost) { return cost.Power == POWER_RUNES; }) == m_powerCost.end() || !runeCostID)
4476  return SPELL_CAST_OK;
4477 
4478  Player* player = m_caster->ToPlayer();
4479  if (!player)
4480  return SPELL_CAST_OK;
4481 
4482  if (player->getClass() != CLASS_DEATH_KNIGHT)
4483  return SPELL_CAST_OK;
4484 
4485  SpellRuneCostEntry const* src = sSpellRuneCostStore.LookupEntry(runeCostID);
4486  if (!src)
4487  return SPELL_CAST_OK;
4488 
4489  if (src->NoRuneCost())
4490  return SPELL_CAST_OK;
4491 
4492  int32 runeCost[NUM_RUNE_TYPES]; // blood, frost, unholy, death
4493 
4494  for (uint32 i = 0; i < NUM_RUNE_TYPES; ++i)
4495  {
4496  runeCost[i] = src->RuneCost[i];
4497  if (Player* modOwner = m_caster->GetSpellModOwner())
4498  modOwner->ApplySpellMod(m_spellInfo->Id, SPELLMOD_COST, runeCost[i], this);
4499  }
4500 
4501  runeCost[RUNE_DEATH] += MAX_RUNES;
4502 
4503  for (uint32 i = 0; i < MAX_RUNES; ++i)
4504  {
4505  RuneType rune = player->GetCurrentRune(i);
4506  if ((player->GetRuneCooldown(i) == 0) && (runeCost[rune] > 0))
4507  runeCost[rune]--;
4508  }
4509 
4510  for (uint32 i = 0; i < RUNE_DEATH; ++i)
4511  if (runeCost[i] > 0)
4512  runeCost[RUNE_DEATH] += runeCost[i];
4513 
4514  if (runeCost[RUNE_DEATH] > MAX_RUNES)
4515  return SPELL_FAILED_NO_POWER; // not sure if result code is correct
4516 
4517  return SPELL_CAST_OK;
4518 }
SpellInfo const *const m_spellInfo
Definition: Spell.h:547
Unit *const m_caster
Definition: Spell.h:647
uint32 Id
Definition: SpellInfo.h:329
Definition: SharedDefines.h:172
#define MAX_RUNES
Definition: Player.h:451
DB2Storage< SpellRuneCostEntry > sSpellRuneCostStore("SpellRuneCost.db2", SpellRuneCostFormat, HOTFIX_SEL_SPELL_RUNE_COST)
Definition: SpellInfo.h:553
Definition: SharedDefines.h:253
Player * ToPlayer()
Definition: Object.h:191
Definition: Player.h:464
Definition: Unit.h:100
int32_t int32
Definition: Define.h:146
uint32_t uint32
Definition: Define.h:150
uint32 RuneCost[4]
Definition: DB2Structure.h:1297
std::vector< SpellInfo::CostData > m_powerCost
Definition: Spell.h:659
bool NoRuneCost() const
Definition: DB2Structure.h:1300
Definition: SharedDefines.h:1371
Player * GetSpellModOwner() const
Definition: Unit.cpp:12691
Definition: Player.h:465
RuneType
Definition: Player.h:459
Definition: SharedDefines.h:1538
Definition: DB2Structure.h:1294

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool Spell::CheckScriptEffectImplicitTargets ( uint32  effIndex,
uint32  effIndexToCheck 
)
protected
7254 {
7255  // Skip if there are not any script
7256  if (m_loadedScripts.empty())
7257  return true;
7258 
7259  for (std::list<SpellScript*>::iterator itr = m_loadedScripts.begin(); itr != m_loadedScripts.end(); ++itr)
7260  {
7261  std::list<SpellScript::ObjectTargetSelectHandler>::iterator targetSelectHookEnd = (*itr)->OnObjectTargetSelect.end(), targetSelectHookItr = (*itr)->OnObjectTargetSelect.begin();
7262  for (; targetSelectHookItr != targetSelectHookEnd; ++targetSelectHookItr)
7263  if (((*targetSelectHookItr).IsEffectAffected(m_spellInfo, effIndex) && !(*targetSelectHookItr).IsEffectAffected(m_spellInfo, effIndexToCheck)) ||
7264  (!(*targetSelectHookItr).IsEffectAffected(m_spellInfo, effIndex) && (*targetSelectHookItr).IsEffectAffected(m_spellInfo, effIndexToCheck)))
7265  return false;
7266 
7267  std::list<SpellScript::ObjectAreaTargetSelectHandler>::iterator areaTargetSelectHookEnd = (*itr)->OnObjectAreaTargetSelect.end(), areaTargetSelectHookItr = (*itr)->OnObjectAreaTargetSelect.begin();
7268  for (; areaTargetSelectHookItr != areaTargetSelectHookEnd; ++areaTargetSelectHookItr)
7269  if (((*areaTargetSelectHookItr).IsEffectAffected(m_spellInfo, effIndex) && !(*areaTargetSelectHookItr).IsEffectAffected(m_spellInfo, effIndexToCheck)) ||
7270  (!(*areaTargetSelectHookItr).IsEffectAffected(m_spellInfo, effIndex) && (*areaTargetSelectHookItr).IsEffectAffected(m_spellInfo, effIndexToCheck)))
7271  return false;
7272  }
7273  return true;
7274 }
SpellInfo const *const m_spellInfo
Definition: Spell.h:547
std::list< SpellScript * > m_loadedScripts
Definition: Spell.h:794

+ Here is the caller graph for this function:

void Spell::CheckSrc ( )
inline
Unit *const m_caster
Definition: Spell.h:647
void SetSrc(float x, float y, float z)
Definition: Spell.cpp:338
SpellCastTargets m_targets
Definition: Spell.h:584
bool HasSrc() const
Definition: Spell.h:228
void Spell::CleanupExecuteLogList ( )
4239 {
4240  _durabilityDamageTargets->clear();
4241  _extraAttacksTargets->clear();
4242  _feedPetTargets->clear();
4243  _genericVictimTargets->clear();
4244  _powerDrainTargets->clear();
4245  _tradeSkillTargets->clear();
4246 }
std::vector< SpellLogEffectPowerDrainParams > _powerDrainTargets[MAX_SPELL_EFFECTS]
Definition: Spell.h:832
std::vector< SpellLogEffectTradeSkillItemParams > _tradeSkillTargets[MAX_SPELL_EFFECTS]
Definition: Spell.h:836
std::vector< SpellLogEffectDurabilityDamageParams > _durabilityDamageTargets[MAX_SPELL_EFFECTS]
Definition: Spell.h:834
std::vector< SpellLogEffectFeedPetParams > _feedPetTargets[MAX_SPELL_EFFECTS]
Definition: Spell.h:837
std::vector< SpellLogEffectGenericVictimParams > _genericVictimTargets[MAX_SPELL_EFFECTS]
Definition: Spell.h:835
std::vector< SpellLogEffectExtraAttacksParams > _extraAttacksTargets[MAX_SPELL_EFFECTS]
Definition: Spell.h:833

+ Here is the caller graph for this function:

void Spell::CleanupTargetList ( )
2035 {
2036  m_UniqueTargetInfo.clear();
2037  m_UniqueGOTargetInfo.clear();
2038  m_UniqueItemInfo.clear();
2039  m_delayMoment = 0;
2040 }
std::vector< TargetInfo > m_UniqueTargetInfo
Definition: Spell.h:739
std::vector< ItemTargetInfo > m_UniqueItemInfo
Definition: Spell.h:756
uint64 m_delayMoment
Definition: Spell.h:679
std::vector< GOTargetInfo > m_UniqueGOTargetInfo
Definition: Spell.h:749

+ Here is the caller graph for this function:

void Spell::Delayed ( )
6424 {
6425  if (!m_caster)// || m_caster->GetTypeId() != TYPEID_PLAYER)
6426  return;
6427 
6428  //if (m_spellState == SPELL_STATE_DELAYED)
6429  // return; // spell is active and can't be time-backed
6430 
6431  if (isDelayableNoMore()) // Spells may only be delayed twice
6432  return;
6433 
6434  // spells not loosing casting time (slam, dynamites, bombs..)
6435  //if (!(m_spellInfo->InterruptFlags & SPELL_INTERRUPT_FLAG_DAMAGE))
6436  // return;
6437 
6438  //check pushback reduce
6439  int32 delaytime = 500; // spellcasting delay is normally 500ms
6440  int32 delayReduce = 100; // must be initialized to 100 for percent modifiers
6441  m_caster->ToPlayer()->ApplySpellMod(m_spellInfo->Id, SPELLMOD_NOT_LOSE_CASTING_TIME, delayReduce, this);
6443  if (delayReduce >= 100)
6444  return;
6445 
6446  AddPct(delaytime, -delayReduce);
6447 
6448  if (m_timer + delaytime > m_casttime)
6449  {
6450  delaytime = m_casttime - m_timer;
6451  m_timer = m_casttime;
6452  }
6453  else
6454  m_timer += delaytime;
6455 
6456  TC_LOG_DEBUG("spells", "Spell %u partially interrupted for (%d) ms at damage", m_spellInfo->Id, delaytime);
6457 
6459  spellDelayed.Caster = m_caster->GetGUID();
6460  spellDelayed.ActualDelay = delaytime;
6461 
6462  m_caster->SendMessageToSet(spellDelayed.Write(), true);
6463 }
bool isDelayableNoMore()
Definition: Spell.h:668
SpellInfo const *const m_spellInfo
Definition: Spell.h:547
Unit *const m_caster
Definition: Spell.h:647
uint32 Id
Definition: SpellInfo.h:329
Definition: SpellAuraDefines.h:209
int32 m_casttime
Definition: Spell.h:660
int32 GetTotalAuraModifier(AuraType auratype) const
Definition: Unit.cpp:4396
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
int32 m_timer
Definition: Spell.h:819
Player * ToPlayer()
Definition: Object.h:191
int32_t int32
Definition: Define.h:146
int32 ActualDelay
Definition: SpellPackets.h:879
ObjectGuid const & GetGUID() const
Definition: Object.h:105
Definition: Unit.h:95
T AddPct(T &base, U pct)
Definition: Util.h:98
virtual void SendMessageToSet(WorldPacket const *data, bool self)
Definition: Object.cpp:2144
ObjectGuid Caster
Definition: SpellPackets.h:878
WorldPacket const * Write() override
Definition: SpellPackets.cpp:840
Definition: SpellPackets.h:871

+ Here is the call graph for this function:

void Spell::DelayedChannel ( )
6466 {
6468  return;
6469 
6470  if (isDelayableNoMore()) // Spells may only be delayed twice
6471  return;
6472 
6473  //check pushback reduce
6474  // should be affected by modifiers, not take the dbc duration.
6476 
6477  int32 delaytime = CalculatePct(duration, 25); // channeling delay is normally 25% of its time per hit
6478  int32 delayReduce = 100; // must be initialized to 100 for percent modifiers
6479  m_caster->ToPlayer()->ApplySpellMod(m_spellInfo->Id, SPELLMOD_NOT_LOSE_CASTING_TIME, delayReduce, this);
6481  if (delayReduce >= 100)
6482  return;
6483 
6484  AddPct(delaytime, -delayReduce);
6485 
6486  if (m_timer <= delaytime)
6487  {
6488  delaytime = m_timer;
6489  m_timer = 0;
6490  }
6491  else
6492  m_timer -= delaytime;
6493 
6494  TC_LOG_DEBUG("spells", "Spell %u partially interrupted for %i ms, new duration: %u ms", m_spellInfo->Id, delaytime, m_timer);
6495 
6496  for (std::vector<TargetInfo>::const_iterator ihit = m_UniqueTargetInfo.begin(); ihit != m_UniqueTargetInfo.end(); ++ihit)
6497  if ((*ihit).missCondition == SPELL_MISS_NONE)
6498  if (Unit* unit = (m_caster->GetGUID() == ihit->targetGUID) ? m_caster : ObjectAccessor::GetUnit(*m_caster, ihit->targetGUID))
6499  unit->DelayOwnedAuras(m_spellInfo->Id, m_originalCasterGUID, delaytime);
6500 
6501  // partially interrupt persistent area auras
6503  dynObj->Delay(delaytime);
6504 
6506 }
bool isDelayableNoMore()
Definition: Spell.h:668
SpellInfo const *const m_spellInfo
Definition: Spell.h:547
Unit *const m_caster
Definition: Spell.h:647
uint32 Id
Definition: SpellInfo.h:329
Definition: SpellAuraDefines.h:209
TC_GAME_API Unit * GetUnit(WorldObject const &, ObjectGuid const &guid)
Definition: ObjectAccessor.cpp:163
uint32 getState() const
Definition: Spell.h:509
int32 GetTotalAuraModifier(AuraType auratype) const
Definition: Unit.cpp:4396
DynamicObject * GetDynObject(uint32 spellId)
Definition: Unit.cpp:4702
Definition: SharedDefines.h:2021
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
int32 m_timer
Definition: Spell.h:819
Player * ToPlayer()
Definition: Object.h:191
int32 GetDuration() const
Definition: SpellInfo.cpp:2490
Definition: DynamicObject.h:35
TypeID GetTypeId() const
Definition: Object.h:113
std::vector< TargetInfo > m_UniqueTargetInfo
Definition: Spell.h:739
void SendChannelUpdate(uint32 time)
Definition: Spell.cpp:4266
int32_t int32
Definition: Define.h:146
Definition: Spell.h:278
T CalculatePct(T base, U pct)
Definition: Util.h:92
ObjectGuid m_originalCasterGUID
Definition: Spell.h:651
ObjectGuid const & GetGUID() const
Definition: Object.h:105
Definition: ObjectGuid.h:33
Definition: Unit.h:95
T AddPct(T &base, U pct)
Definition: Util.h:98
int32 m_channeledDuration
Definition: Spell.h:661
Definition: Unit.h:1305

+ Here is the call graph for this function:

void Spell::DoAllEffectOnLaunchTarget ( TargetInfo targetInfo,
float *  multiplier 
)
protected
6879 {
6880  Unit* unit = NULL;
6881  // In case spell hit target, do all effect on that target
6882  if (targetInfo.missCondition == SPELL_MISS_NONE)
6883  unit = m_caster->GetGUID() == targetInfo.targetGUID ? m_caster : ObjectAccessor::GetUnit(*m_caster, targetInfo.targetGUID);
6884  // In case spell reflect from target, do all effect on caster (if hit)
6885  else if (targetInfo.missCondition == SPELL_MISS_REFLECT && targetInfo.reflectResult == SPELL_MISS_NONE)
6886  unit = m_caster;
6887  if (!unit)
6888  return;
6889 
6890  for (SpellEffectInfo const* effect : GetEffects())
6891  {
6892  if (effect && (targetInfo.effectMask & (1<<effect->EffectIndex)))
6893  {
6894  m_damage = 0;
6895  m_healing = 0;
6896 
6897  HandleEffects(unit, NULL, NULL, effect->EffectIndex, SPELL_EFFECT_HANDLE_LAUNCH_TARGET);
6898 
6899  if (m_damage > 0)
6900  {
6901  if (effect->IsTargetingArea() || effect->IsAreaAuraEffect() || effect->IsEffect(SPELL_EFFECT_PERSISTENT_AREA_AURA))
6902  {
6904  if (m_caster->GetTypeId() != TYPEID_PLAYER)
6906 
6907  if (m_caster->GetTypeId() == TYPEID_PLAYER)
6908  {
6909  uint32 targetAmount = m_UniqueTargetInfo.size();
6910  if (targetAmount > 10)
6911  m_damage = m_damage * 10/targetAmount;
6912  }
6913  }
6914  }
6915 
6916  if (m_applyMultiplierMask & (1 << effect->EffectIndex))
6917  {
6918  m_damage = int32(m_damage * m_damageMultipliers[effect->EffectIndex]);
6919  m_damageMultipliers[effect->EffectIndex] *= multiplier[effect->EffectIndex];
6920  }
6921  targetInfo.damage += m_damage;
6922  }
6923  }
6924 
6925  targetInfo.crit = m_caster->IsSpellCrit(unit, m_spellInfo, m_spellSchoolMask, m_attackType);
6926 }
SpellInfo const *const m_spellInfo
Definition: Spell.h:547
Unit *const m_caster
Definition: Spell.h:647
TC_GAME_API Unit * GetUnit(WorldObject const &, ObjectGuid const &guid)
Definition: ObjectAccessor.cpp:163
void HandleEffects(Unit *pUnitTarget, Item *pItemTarget, GameObject *pGOTarget, uint32 i, SpellEffectHandleMode mode)
Definition: Spell.cpp:4711
uint32 SchoolMask
Definition: SpellInfo.h:401
bool IsSpellCrit(Unit *victim, SpellInfo const *spellProto, SpellSchoolMask schoolMask, WeaponAttackType attackType=BASE_ATTACK) const
Definition: Unit.cpp:8643
arena_t NULL
Definition: jemalloc_internal.h:624
Definition: SpellAuraDefines.h:370
Definition: SharedDefines.h:2021
Definition: SpellAuraDefines.h:289
TypeID GetTypeId() const
Definition: Object.h:113
std::vector< TargetInfo > m_UniqueTargetInfo
Definition: Spell.h:739
Definition: Spell.h:287
Definition: SpellInfo.h:238
uint32_t uint32
Definition: Define.h:150
int32 m_damage
Definition: Spell.h:709
SpellEffectInfoVector const & GetEffects() const
Definition: Spell.h:623
float GetTotalAuraMultiplierByMiscMask(AuraType auratype, uint32 misc_mask) const
Definition: Unit.cpp:4470
WeaponAttackType m_attackType
Definition: Spell.h:657
Definition: SharedDefines.h:2032
float m_damageMultipliers[3]
Definition: Spell.h:687
ObjectGuid const & GetGUID() const
Definition: Object.h:105
Definition: ObjectGuid.h:33
int32_t int32
Definition: g3dmath.h:167
uint8 m_applyMultiplierMask
Definition: Spell.h:686
SpellSchoolMask m_spellSchoolMask
Definition: Spell.h:656
Definition: SharedDefines.h:1037
Definition: Unit.h:1305
int32 m_healing
Definition: Spell.h:710

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Spell::DoAllEffectOnTarget ( TargetInfo target)
protected
Todo:
check how broad this rule should be
2246 {
2247  if (!target || target->processed)
2248  return;
2249 
2250  target->processed = true; // Target checked in apply effects procedure
2251 
2252  // Get mask of effects for target
2253  uint32 mask = target->effectMask;
2254 
2255  Unit* unit = m_caster->GetGUID() == target->targetGUID ? m_caster : ObjectAccessor::GetUnit(*m_caster, target->targetGUID);
2256  if (!unit && target->targetGUID.IsPlayer()) // only players may be targeted across maps
2257  {
2258  uint8 farMask = 0;
2259  // create far target mask
2260  for (SpellEffectInfo const* effect : GetEffects())
2261  if (effect && effect->IsFarUnitTargetEffect())
2262  if ((1 << effect->EffectIndex) & mask)
2263  farMask |= (1 << effect->EffectIndex);
2264 
2265  if (!farMask)
2266  return;
2267 
2268  // find unit in world
2269  unit = ObjectAccessor::FindPlayer(target->targetGUID);
2270  if (!unit)
2271  return;
2272 
2273  // do far effects on the unit
2274  // can't use default call because of threading, do stuff as fast as possible
2275  for (SpellEffectInfo const* effect : GetEffects())
2276  if (effect && (farMask & (1 << effect->EffectIndex)))
2277  HandleEffects(unit, NULL, NULL, effect->EffectIndex, SPELL_EFFECT_HANDLE_HIT_TARGET);
2278  return;
2279  }
2280 
2281  if (!unit)
2282  return;
2283 
2284  if (unit->IsAlive() != target->alive)
2285  return;
2286 
2287  if (getState() == SPELL_STATE_DELAYED && !m_spellInfo->IsPositive() && (getMSTime() - target->timeDelay) <= unit->m_lastSanctuaryTime)
2288  return; // No missinfo in that case
2289 
2290  // Get original caster (if exist) and calculate damage/healing from him data
2292 
2293  // Skip if m_originalCaster not avaiable
2294  if (!caster)
2295  return;
2296 
2297  SpellMissInfo missInfo = target->missCondition;
2298 
2299  // Need init unitTarget by default unit (can changed in code on reflect)
2300  // Or on missInfo != SPELL_MISS_NONE unitTarget undefined (but need in trigger subsystem)
2301  unitTarget = unit;
2302 
2303  // Reset damage/healing counter
2304  m_damage = target->damage;
2305  m_healing = -target->damage;
2306 
2307  // Fill base trigger info
2308  uint32 procAttacker = m_procAttacker;
2309  uint32 procVictim = m_procVictim;
2310  uint32 procEx = m_procEx;
2311 
2312  m_spellAura = NULL; // Set aura to null for every target-make sure that pointer is not used for unit without aura applied
2313 
2314  //Spells with this flag cannot trigger if effect is cast on self
2315  bool canEffectTrigger = !m_spellInfo->HasAttribute(SPELL_ATTR3_CANT_TRIGGER_PROC) && unitTarget->CanProc() && (CanExecuteTriggersOnHit(mask) || missInfo == SPELL_MISS_IMMUNE || missInfo == SPELL_MISS_IMMUNE2);
2316  Unit* spellHitTarget = NULL;
2317 
2318  if (missInfo == SPELL_MISS_NONE) // In case spell hit target, do all effect on that target
2319  spellHitTarget = unit;
2320  else if (missInfo == SPELL_MISS_REFLECT) // In case spell reflect from target, do all effect on caster (if hit)
2321  {
2322  if (target->reflectResult == SPELL_MISS_NONE) // If reflected spell hit caster -> do all effect on him
2323  {
2324  spellHitTarget = m_caster;
2325  if (m_caster->GetTypeId() == TYPEID_UNIT)
2326  m_caster->ToCreature()->LowerPlayerDamageReq(target->damage);
2327  }
2328  }
2329 
2330  if (spellHitTarget)
2331  {
2332  SpellMissInfo missInfo2 = DoSpellHitOnUnit(spellHitTarget, mask, target->scaleAura);
2333  if (missInfo2 != SPELL_MISS_NONE)
2334  {
2335  if (missInfo2 != SPELL_MISS_MISS)
2336  m_caster->SendSpellMiss(unit, m_spellInfo->Id, missInfo2);
2337  m_damage = 0;
2338  spellHitTarget = NULL;
2339  }
2340  }
2341 
2342  // Do not take combo points on dodge and miss
2343  if (missInfo != SPELL_MISS_NONE && m_needComboPoints &&
2344  m_targets.GetUnitTargetGUID() == target->targetGUID)
2345  {
2346  m_needComboPoints = false;
2347  // Restore spell mods for a miss/dodge/parry Cold Blood
2349  if (m_caster->GetTypeId() == TYPEID_PLAYER && (missInfo == SPELL_MISS_MISS ||
2350  missInfo == SPELL_MISS_DODGE || missInfo == SPELL_MISS_PARRY))
2351  m_caster->ToPlayer()->RestoreSpellMods(this, 14177);
2352  }
2353 
2354  // Trigger info was not filled in spell::preparedatafortriggersystem - we do it now
2355  if (canEffectTrigger && !procAttacker && !procVictim)
2356  {
2357  bool positive = true;
2358  if (m_damage > 0)
2359  positive = false;
2360  else if (!m_healing)
2361  positive = m_spellInfo->IsPositive();
2362 
2363  switch (m_spellInfo->DmgClass)
2364  {
2366  if (positive)
2367  {
2370  }
2371  else
2372  {
2375  }
2376  break;
2378  if (positive)
2379  {
2382  }
2383  else
2384  {
2387  }
2388  break;
2389  }
2390  }
2392 
2393  // All calculated do it!
2394  // Do healing and triggers
2395  if (m_healing > 0)
2396  {
2397  bool crit = target->crit;
2398  uint32 addhealth = m_healing;
2399  if (crit)
2400  {
2401  procEx |= PROC_EX_CRITICAL_HIT;
2402  addhealth = caster->SpellCriticalHealingBonus(m_spellInfo, addhealth, NULL);
2403  }
2404  else
2405  procEx |= PROC_EX_NORMAL_HIT;
2406 
2407  int32 gain = caster->HealBySpell(unitTarget, m_spellInfo, addhealth, crit);
2408  unitTarget->getHostileRefManager().threatAssist(caster, float(gain) * 0.5f, m_spellInfo);
2409  m_healing = gain;
2410 
2411  // Do triggers for unit (reflect triggers passed on hit phase for correct drop charge)
2412  if (canEffectTrigger && missInfo != SPELL_MISS_REFLECT)
2413  caster->ProcDamageAndSpell(unitTarget, procAttacker, procVictim, procEx, addhealth, m_attackType, m_spellInfo, m_triggeredByAuraSpell);
2414  }
2415  // Do damage and triggers
2416  else if (m_damage > 0)
2417  {
2418  // Fill base damage struct (unitTarget - is real spell target)
2420 
2421  // Add bonuses and fill damageInfo struct
2422  caster->CalculateSpellDamageTaken(&damageInfo, m_damage, m_spellInfo, m_attackType, target->crit);
2423  caster->DealDamageMods(damageInfo.target, damageInfo.damage, &damageInfo.absorb);
2424 
2425  procEx |= createProcExtendMask(&damageInfo, missInfo);
2426  procVictim |= PROC_FLAG_TAKEN_DAMAGE;
2427 
2428  // Do triggers for unit (reflect triggers passed on hit phase for correct drop charge)
2429  if (canEffectTrigger && missInfo != SPELL_MISS_REFLECT)
2430  {
2431  caster->ProcDamageAndSpell(unitTarget, procAttacker, procVictim, procEx, damageInfo.damage, m_attackType, m_spellInfo, m_triggeredByAuraSpell);
2434  caster->ToPlayer()->CastItemCombatSpell(unitTarget, m_attackType, procVictim, procEx);
2435  }
2436 
2437  m_damage = damageInfo.damage;
2438 
2439  caster->DealSpellDamage(&damageInfo, true);
2440 
2441  // Send log damage message to client
2442  caster->SendSpellNonMeleeDamageLog(&damageInfo);
2443  }
2444  // Passive spell hits/misses or active spells only misses (only triggers)
2445  else
2446  {
2447  // Fill base damage struct (unitTarget - is real spell target)
2449  procEx |= createProcExtendMask(&damageInfo, missInfo);
2450  // Do triggers for unit (reflect triggers passed on hit phase for correct drop charge)
2451  if (canEffectTrigger && missInfo != SPELL_MISS_REFLECT)
2452  caster->ProcDamageAndSpell(unit, procAttacker, procVictim, procEx, 0, m_attackType, m_spellInfo, m_triggeredByAuraSpell);
2453 
2454  // Failed Pickpocket, reveal rogue
2456  {
2460  }
2461  }
2462 
2464  {
2466 
2468  if (!unit->IsStandState())
2470  }
2471 
2472  if (spellHitTarget)
2473  {
2474  //AI functions
2475  if (spellHitTarget->GetTypeId() == TYPEID_UNIT)
2476  if (spellHitTarget->ToCreature()->IsAIEnabled)
2477  spellHitTarget->ToCreature()->AI()->SpellHit(m_caster, m_spellInfo);
2478 
2480  m_caster->ToCreature()->AI()->SpellHitTarget(spellHitTarget, m_spellInfo);
2481 
2482  // Needs to be called after dealing damage/healing to not remove breaking on damage auras
2483  DoTriggersOnSpellHit(spellHitTarget, mask);
2484 
2485  // if target is fallged for pvp also flag caster if a player
2486  if (unit->IsPvP() && m_caster->GetTypeId() == TYPEID_PLAYER)
2487  m_caster->ToPlayer()->UpdatePvP(true);
2488 
2490  }
2491 }
ObjectGuid GetUnitTargetGUID() const
Definition: Spell.cpp:214
Definition: SpellMgr.h:200
Definition: Unit.h:207
void DoTriggersOnSpellHit(Unit *unit, uint8 effMask)
Definition: Spell.cpp:2688
SpellInfo const *const m_spellInfo
Definition: Spell.h:547
Unit *const m_caster
Definition: Spell.h:647
uint32 Id
Definition: SpellInfo.h:329
Definition: Spell.h:281
Definition: SharedDefines.h:2028
void threatAssist(Unit *victim, float baseThreat, SpellInfo const *threatSpell=NULL)
Definition: HostileRefManager.cpp:35
Definition: SpellMgr.h:129
Definition: SharedDefines.h:2029
Definition: SharedDefines.h:481
int32 HealBySpell(Unit *victim, SpellInfo const *spellInfo, uint32 addHealth, bool critical=false)
Definition: Unit.cpp:8179
TC_GAME_API Unit * GetUnit(WorldObject const &, ObjectGuid const &guid)
Definition: ObjectAccessor.cpp:163
void CalculateSpellDamageTaken(SpellNonMeleeDamage *damageInfo, int32 damage, SpellInfo const *spellInfo, WeaponAttackType attackType=BASE_ATTACK, bool crit=false)
Definition: Unit.cpp:988
Definition: SharedDefines.h:2025
uint32 DmgClass
Definition: SpellInfo.h:398
virtual void SpellHitTarget(Unit *, SpellInfo const *)
Definition: CreatureAI.h:133
void HandleEffects(Unit *pUnitTarget, Item *pItemTarget, GameObject *pGOTarget, uint32 i, SpellEffectHandleMode mode)
Definition: Spell.cpp:4711
uint32 getState() const
Definition: Spell.h:509
bool CanProc() const
Definition: Unit.h:2141
SpellCastTargets m_targets
Definition: Spell.h:584
void CallScriptAfterHitHandlers()
Definition: Spell.cpp:7198
bool IsPvP() const
Definition: Unit.h:1481
SpellInfo const * m_triggeredByAuraSpell
Definition: Spell.h:826
void RemoveAurasWithInterruptFlags(uint32 flag, uint32 except=0)
Definition: Unit.cpp:3816
uint32 getMSTime()
Definition: Timer.h:24
uint32 SpellCriticalHealingBonus(SpellInfo const *spellProto, uint32 damage, Unit *victim)
Definition: Unit.cpp:8874
Definition: ObjectGuid.h:32
Definition: Unit.h:64
uint32 m_lastSanctuaryTime
Definition: Unit.h:1989
Definition: SharedDefines.h:2052
arena_t NULL
Definition: jemalloc_internal.h:624
Definition: SharedDefines.h:2021
void SendSpellMiss(Unit *target, uint32 spellID, SpellMissInfo missInfo)
Definition: Unit.cpp:4897
Definition: SharedDefines.h:376
bool IsAIEnabled
Definition: Unit.h:2161
Definition: SharedDefines.h:2024
Definition: SharedDefines.h:2049
Player * ToPlayer()
Definition: Object.h:191
uint32 m_procVictim
Definition: Spell.h:716
uint32 createProcExtendMask(SpellNonMeleeDamage *damageInfo, SpellMissInfo missCondition)
Definition: Unit.cpp:12194
Definition: SharedDefines.h:2027
Aura * m_spellAura
Definition: Spell.h:699
Definition: SharedDefines.h:2023
TypeID GetTypeId() const
Definition: Object.h:113
TC_GAME_API Player * FindPlayer(ObjectGuid const &)
Definition: ObjectAccessor.cpp:209
bool HasEffect(SpellEffectName effect) const
Definition: Spell.cpp:7410
Definition: Spell.h:289
Definition: SpellMgr.h:126
Definition: Unit.h:1042
Definition: SpellInfo.h:190
Unit * unitTarget
Definition: Spell.h:690
Unit * m_originalCaster
Definition: Spell.h:653
HostileRefManager & getHostileRefManager()
Definition: Unit.h:2001
bool IsPositive() const
Definition: SpellInfo.cpp:1495
Definition: SpellMgr.h:141
virtual void SpellHit(Unit *, SpellInfo const *)
Definition: CreatureAI.h:130
bool IsAlive() const
Definition: Unit.h:1692
bool HasAttribute(SpellAttr0 attribute) const
Definition: SpellInfo.h:462
SpellMissInfo DoSpellHitOnUnit(Unit *unit, uint32 effectMask, bool scaleAura)
Definition: Spell.cpp:2493
CreatureAI * AI() const
Definition: Creature.h:525
Definition: SpellInfo.h:238
Definition: SharedDefines.h:480
int32_t int32
Definition: Define.h:146
uint32_t uint32
Definition: Define.h:150
uint32 m_procAttacker
Definition: Spell.h:715
bool IsFriendlyTo(Unit const *unit) const
Definition: Unit.cpp:7170
SpellMissInfo
Definition: SharedDefines.h:2019
int32 m_damage
Definition: Spell.h:709
SpellEffectInfoVector const & GetEffects() const
Definition: Spell.h:623
void DealSpellDamage(SpellNonMeleeDamage const *damageInfo, bool durabilityLoss)
Definition: Unit.cpp:1094
WeaponAttackType m_attackType
Definition: Spell.h:657
Definition: SharedDefines.h:2051
Definition: SpellMgr.h:199
uint32 m_procEx
Definition: Spell.h:717
Definition: SharedDefines.h:2050
Definition: SharedDefines.h:2032
void DealDamageMods(Unit *victim, uint32 &damage, uint32 *absorb)
Definition: Unit.cpp:603
ObjectGuid const & GetGUID() const
Definition: Object.h:105
Definition: ObjectGuid.h:33
void SendSpellNonMeleeDamageLog(SpellNonMeleeDamage const *log)
Definition: Unit.cpp:4839
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
Definition: SpellInfo.h:193
Creature * ToCreature()
Definition: Object.h:194
void CombatStart(Unit *target, bool initialAggro=true)
Definition: Unit.cpp:9862
void CallScriptOnHitHandlers()
Definition: Spell.cpp:7185
Definition: SharedDefines.h:2022
void SetStandState(UnitStandStateType state, uint32 animKitID=0)
Definition: Unit.cpp:12772
uint8_t uint8
Definition: Define.h:152
SpellSchoolMask m_spellSchoolMask
Definition: Spell.h:656
bool CanExecuteTriggersOnHit(uint8 effMask, SpellInfo const *triggeredByAura=NULL) const
Definition: Spell.cpp:7276
Definition: Unit.h:1305
virtual void AttackStart(Unit *)
Definition: UnitAI.cpp:29
int32 m_healing
Definition: Spell.h:710
Definition: SharedDefines.h:1048
bool m_needComboPoints
Definition: Spell.h:685
bool IsStandState() const
Definition: Unit.cpp:12766
void LowerPlayerDamageReq(uint32 unDamage)
Definition: Creature.cpp:1239

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Spell::DoAllEffectOnTarget ( GOTargetInfo target)
protected
2761 {
2762  if (target->processed) // Check target
2763  return;
2764  target->processed = true; // Target checked in apply effects procedure
2765 
2766  uint32 effectMask = target->effectMask;
2767  if (!effectMask)
2768  return;
2769 
2770  GameObject* go = m_caster->GetMap()->GetGameObject(target->targetGUID);
2771  if (!go)
2772  return;
2773 
2776 
2777  for (SpellEffectInfo const* effect : GetEffects())
2778  if (effect && (effectMask & (1 << effect->EffectIndex)))
2779  HandleEffects(NULL, NULL, go, effect->EffectIndex, SPELL_EFFECT_HANDLE_HIT_TARGET);
2780 
2783 }
void PrepareScriptHitHandlers()
Definition: Spell.cpp:7105
Unit *const m_caster
Definition: Spell.h:647
Map * GetMap() const
Definition: Object.h:543
void CallScriptBeforeHitHandlers()
Definition: Spell.cpp:7172
void HandleEffects(Unit *pUnitTarget, Item *pItemTarget, GameObject *pGOTarget, uint32 i, SpellEffectHandleMode mode)
Definition: Spell.cpp:4711
void CallScriptAfterHitHandlers()
Definition: Spell.cpp:7198
arena_t NULL
Definition: jemalloc_internal.h:624
Definition: Spell.h:289
Definition: SpellInfo.h:238
uint32_t uint32
Definition: Define.h:150
Definition: GameObject.h:880
SpellEffectInfoVector const & GetEffects() const
Definition: Spell.h:623
void CallScriptOnHitHandlers()
Definition: Spell.cpp:7185
GameObject * GetGameObject(ObjectGuid const &guid)
Definition: Map.cpp:3545

+ Here is the call graph for this function:

void Spell::DoAllEffectOnTarget ( ItemTargetInfo target)
protected
2786 {
2787  uint32 effectMask = target->effectMask;
2788  if (!target->item || !effectMask)
2789  return;
2790 
2793 
2794  for (SpellEffectInfo const* effect : GetEffects())
2795  if (effect && (effectMask & (1 << effect->EffectIndex)))
2796  HandleEffects(NULL, target->item, NULL, effect->EffectIndex, SPELL_EFFECT_HANDLE_HIT_TARGET);
2797 
2799 
2801 }
void PrepareScriptHitHandlers()
Definition: Spell.cpp:7105
void CallScriptBeforeHitHandlers()
Definition: Spell.cpp:7172
void HandleEffects(Unit *pUnitTarget, Item *pItemTarget, GameObject *pGOTarget, uint32 i, SpellEffectHandleMode mode)
Definition: Spell.cpp:4711
void CallScriptAfterHitHandlers()
Definition: Spell.cpp:7198
arena_t NULL
Definition: jemalloc_internal.h:624
Definition: Spell.h:289
Definition: SpellInfo.h:238
uint32_t uint32
Definition: Define.h:150
SpellEffectInfoVector const & GetEffects() const
Definition: Spell.h:623
void CallScriptOnHitHandlers()
Definition: Spell.cpp:7185

+ Here is the call graph for this function:

void Spell::DoCreateItem ( uint32  i,
uint32  itemtype,
std::vector< int32 > const bonusListIDs = std::vector<int32>() 
)
1404 {
1406  return;
1407 
1408  Player* player = unitTarget->ToPlayer();
1409 
1410  uint32 newitemid = itemtype;
1411  ItemTemplate const* pProto = sObjectMgr->GetItemTemplate(newitemid);
1412  if (!pProto)
1413  {
1414  player->SendEquipError(EQUIP_ERR_ITEM_NOT_FOUND, NULL, NULL);
1415  return;
1416  }
1417 
1418  // bg reward have some special in code work
1419  uint32 bgType = 0;
1420  switch (m_spellInfo->Id)
1421  {
1422  case SPELL_AV_MARK_WINNER:
1423  case SPELL_AV_MARK_LOSER:
1424  bgType = BATTLEGROUND_AV;
1425  break;
1426  case SPELL_WS_MARK_WINNER:
1427  case SPELL_WS_MARK_LOSER:
1428  bgType = BATTLEGROUND_WS;
1429  break;
1430  case SPELL_AB_MARK_WINNER:
1431  case SPELL_AB_MARK_LOSER:
1432  bgType = BATTLEGROUND_AB;
1433  break;
1434  default:
1435  break;
1436  }
1437 
1438  uint32 num_to_add = damage;
1439 
1440  if (num_to_add < 1)
1441  num_to_add = 1;
1442  if (num_to_add > pProto->GetMaxStackSize())
1443  num_to_add = pProto->GetMaxStackSize();
1444 
1445  /* == gem perfection handling == */
1446 
1447  // the chance of getting a perfect result
1448  float perfectCreateChance = 0.0f;
1449  // the resulting perfect item if successful
1450  uint32 perfectItemType = itemtype;
1451  // get perfection capability and chance
1452  if (CanCreatePerfectItem(player, m_spellInfo->Id, perfectCreateChance, perfectItemType))
1453  if (roll_chance_f(perfectCreateChance)) // if the roll succeeds...
1454  newitemid = perfectItemType; // the perfect item replaces the regular one
1455 
1456  /* == gem perfection handling over == */
1457 
1458 
1459  /* == profession specialization handling == */
1460 
1461  // init items_count to 1, since 1 item will be created regardless of specialization
1462  int items_count=1;
1463  // the chance to create additional items
1464  float additionalCreateChance=0.0f;
1465  // the maximum number of created additional items
1466  uint8 additionalMaxNum=0;
1467  // get the chance and maximum number for creating extra items
1468  if (CanCreateExtraItems(player, m_spellInfo->Id, additionalCreateChance, additionalMaxNum))
1469  // roll with this chance till we roll not to create or we create the max num
1470  while (roll_chance_f(additionalCreateChance) && items_count <= additionalMaxNum)
1471  ++items_count;
1472 
1473  // really will be created more items
1474  num_to_add *= items_count;
1475 
1476  /* == profession specialization handling over == */
1477 
1478 
1479  // can the player store the new item?
1480  ItemPosCountVec dest;
1481  uint32 no_space = 0;
1482  InventoryResult msg = player->CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, newitemid, num_to_add, &no_space);
1483  if (msg != EQUIP_ERR_OK)
1484  {
1485  // convert to possible store amount
1486  if (msg == EQUIP_ERR_INV_FULL || msg == EQUIP_ERR_ITEM_MAX_COUNT)
1487  num_to_add -= no_space;
1488  else
1489  {
1490  // if not created by another reason from full inventory or unique items amount limitation
1491  player->SendEquipError(msg, NULL, NULL, newitemid);
1492  return;
1493  }
1494  }
1495 
1496  if (num_to_add)
1497  {
1498  // create the new item and store it
1499  Item* pItem = player->StoreNewItem(dest, newitemid, true, Item::GenerateItemRandomPropertyId(newitemid), GuidSet(), bonusListIDs);
1500 
1501  // was it successful? return error if not
1502  if (!pItem)
1503  {
1504  player->SendEquipError(EQUIP_ERR_ITEM_NOT_FOUND, NULL, NULL);
1505  return;
1506  }
1507 
1508  // set the "Crafted by ..." property of the item
1509  if (pItem->GetTemplate()->GetClass() != ITEM_CLASS_CONSUMABLE && pItem->GetTemplate()->GetClass() != ITEM_CLASS_QUEST && newitemid != 6265 && newitemid != 6948)
1510  pItem->SetGuidValue(ITEM_FIELD_CREATOR, player->GetGUID());
1511 
1512  // send info to the client
1513  player->SendNewItem(pItem, num_to_add, true, bgType == 0);
1514 
1515  if (pItem->GetQuality() > ITEM_QUALITY_EPIC || (pItem->GetQuality() == ITEM_QUALITY_EPIC && pItem->GetItemLevel(player) >= MinNewsItemLevel))
1516  if (Guild* guild = player->GetGuild())
1517  guild->AddGuildNews(GUILD_NEWS_ITEM_CRAFTED, player->GetGUID(), 0, pProto->GetId());
1518 
1519 
1520  // we succeeded in creating at least one item, so a levelup is possible
1521  if (bgType == 0)
1522  player->UpdateCraftSkill(m_spellInfo->Id);
1523  }
1524 
1525 /*
1526  // for battleground marks send by mail if not add all expected
1527  if (no_space > 0 && bgType)
1528  {
1529  if (Battleground* bg = sBattlegroundMgr->GetBattlegroundTemplate(BattlegroundTypeId(bgType)))
1530  bg->SendRewardMarkByMail(player, newitemid, no_space);
1531  }
1532 */
1533 }
Definition: Battleground.h:80
Definition: Battleground.h:82
SpellInfo const *const m_spellInfo
Definition: Spell.h:547
uint32 Id
Definition: SpellInfo.h:329
uint32 GetQuality() const
Definition: Item.h:388
Definition: Item.h:98
Definition: UpdateFields.h:44
Definition: SharedDefines.h:4563
bool CanCreatePerfectItem(Player *player, uint32 spellId, float &perfectCreateChance, uint32 &perfectItemType)
Definition: SkillExtraItems.cpp:202
Definition: Unit.h:379
Definition: SharedDefines.h:4562
uint32 GetClass() const
Definition: ItemTemplate.h:653
arena_t NULL
Definition: jemalloc_internal.h:624
void SetGuidValue(uint16 index, ObjectGuid const &value)
Definition: Object.cpp:1120
Definition: Battleground.h:78
#define sObjectMgr
Definition: ObjectMgr.h:1567
Player * ToPlayer()
Definition: Object.h:191
bool CanCreateExtraItems(Player *player, uint32 spellId, float &additionalChance, uint8 &additionalMax)
Definition: SkillExtraItems.cpp:226
TypeID GetTypeId() const
Definition: Object.h:113
Definition: Item.h:48
Definition: Item.h:71
Definition: Unit.h:378
Unit * unitTarget
Definition: Spell.h:690
bool roll_chance_f(float chance)
Definition: Random.h:47
int32 damage
Definition: Spell.h:694
static int32 GenerateItemRandomPropertyId(uint32 item_id)
Definition: Item.cpp:594
Definition: Item.h:259
uint32 GetItemLevel(Player const *owner) const
Definition: Item.cpp:1871
uint32_t uint32
Definition: Define.h:150
Definition: Battleground.h:81
Definition: Battleground.h:79
Definition: Item.h:65
uint32 GetMaxStackSize() const
Definition: ItemTemplate.h:745
Definition: Battleground.h:77
Definition: SharedDefines.h:4561
uint32 const MinNewsItemLevel
Definition: Guild.h:254
Definition: ObjectGuid.h:33
Definition: ItemTemplate.h:647
Definition: ItemTemplate.h:367
std::set< ObjectGuid > GuidSet
Definition: ObjectGuid.h:332
uint8_t uint8
Definition: Define.h:152
Definition: Guild.h:238
uint32 GetId() const
Definition: ItemTemplate.h:652
InventoryResult
Definition: Item.h:46
Definition: SharedDefines.h:324
Definition: Guild.h:320
Definition: ItemTemplate.h:379
ItemTemplate const * GetTemplate() const
Definition: Item.cpp:547

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

SpellMissInfo Spell::DoSpellHitOnUnit ( Unit unit,
uint32  effectMask,
bool  scaleAura 
)
protected
Todo:
This is a hack. But we do not know what types of stealth should be interrupted by CC
Todo:
this cause soul transfer bugged
2494 {
2495  if (!unit || !effectMask)
2496  return SPELL_MISS_EVADE;
2497 
2498  // For delayed spells immunity may be applied between missile launch and hit - check immunity for that case
2500  return SPELL_MISS_IMMUNE;
2501 
2502  // disable effects to which unit is immune
2503  SpellMissInfo returnVal = SPELL_MISS_IMMUNE;
2504  for (SpellEffectInfo const* effect : GetEffects())
2505  if (effect && (effectMask & (1 << effect->EffectIndex)))
2506  if (unit->IsImmunedToSpellEffect(m_spellInfo, effect->EffectIndex))
2507  effectMask &= ~(1 << effect->EffectIndex);
2508 
2509  if (!effectMask)
2510  return returnVal;
2511 
2514 
2515  if (Player* player = unit->ToPlayer())
2516  {
2517  player->StartTimedAchievement(ACHIEVEMENT_TIMED_TYPE_SPELL_TARGET, m_spellInfo->Id);
2518  player->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_BE_SPELL_TARGET, m_spellInfo->Id, 0, 0, m_caster);
2519  player->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_BE_SPELL_TARGET2, m_spellInfo->Id);
2520  }
2521 
2522  if (Player* player = m_caster->ToPlayer())
2523  {
2524  player->StartTimedAchievement(ACHIEVEMENT_TIMED_TYPE_SPELL_CASTER, m_spellInfo->Id);
2525  player->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_CAST_SPELL2, m_spellInfo->Id, 0, 0, unit);
2526  }
2527 
2528  if (m_caster != unit)
2529  {
2530  // Recheck UNIT_FLAG_NON_ATTACKABLE for delayed spells
2532  return SPELL_MISS_EVADE;
2533 
2535  {
2540  }
2541  else if (m_caster->IsFriendlyTo(unit))
2542  {
2543  // for delayed spells ignore negative spells (after duel end) for friendly targets
2545  // 63881 - Malady of the Mind jump spell (Yogg-Saron)
2546  if (m_spellInfo->Speed > 0.0f && unit->GetTypeId() == TYPEID_PLAYER && !m_spellInfo->IsPositive() && m_spellInfo->Id != 63881)
2547  return SPELL_MISS_EVADE;
2548 
2549  // assisting case, healing and resurrection
2551  {
2553  if (m_caster->GetTypeId() == TYPEID_PLAYER)
2554  m_caster->ToPlayer()->UpdatePvP(true);
2555  }
2557  {
2558  m_caster->SetInCombatState(unit->GetCombatTimer() > 0, unit);
2560  }
2561  }
2562  }
2563 
2564  uint8 aura_effmask = 0;
2565  for (SpellEffectInfo const* effect : GetEffects())
2566  if (effect && (effectMask & (1 << effect->EffectIndex) && effect->IsUnitOwnedAuraEffect()))
2567  aura_effmask |= 1 << effect->EffectIndex;
2568 
2569  // Get Data Needed for Diminishing Returns, some effects may have multiple auras, so this must be done on spell hit, not aura add
2571  if (m_diminishGroup && aura_effmask)
2572  {
2575  // Increase Diminishing on unit, current informations for actually casts will use values above
2576  if ((type == DRTYPE_PLAYER &&
2578  type == DRTYPE_ALL)
2580  }
2581 
2582  if (aura_effmask)
2583  {
2584  // Select rank for aura with level requirements only in specific cases
2585  // Unit has to be target only of aura effect, both caster and target have to be players, target has to be other than unit target
2586  SpellInfo const* aurSpellInfo = m_spellInfo;
2587  int32 basePoints[MAX_SPELL_EFFECTS];
2588  if (scaleAura)
2589  {
2590  aurSpellInfo = m_spellInfo->GetAuraRankForLevel(unitTarget->getLevel());
2591  ASSERT(aurSpellInfo);
2592  for (SpellEffectInfo const* effect : aurSpellInfo->GetEffectsForDifficulty(0))
2593  {
2594  basePoints[effect->EffectIndex] = effect->BasePoints;
2595  if (SpellEffectInfo const* myEffect = GetEffect(effect->EffectIndex))
2596  {
2597  if (myEffect->Effect != effect->Effect)
2598  {
2599  aurSpellInfo = m_spellInfo;
2600  break;
2601  }
2602  }
2603  }
2604  }
2605 
2606  if (m_originalCaster)
2607  {
2608  bool refresh = false;
2609  m_spellAura = Aura::TryRefreshStackOrCreate(aurSpellInfo, effectMask, unit,
2610  m_originalCaster, (aurSpellInfo == m_spellInfo) ? m_spellValue->EffectBasePoints : basePoints,
2612  if (m_spellAura)
2613  {
2614  // Set aura stack amount to desired value
2615  if (m_spellValue->AuraStackAmount > 1)
2616  {
2617  if (!refresh)
2619  else
2621  }
2622 
2623  // Now Reduce spell duration using data received at spell hit
2624  int32 duration = m_spellAura->GetMaxDuration();
2625  int32 limitduration = m_diminishGroup ? GetDiminishingReturnsLimitDuration(aurSpellInfo) : 0;
2626  float diminishMod = unit->ApplyDiminishingToDuration(m_diminishGroup, duration, m_originalCaster, m_diminishLevel, limitduration);
2627 
2628  // unit is immune to aura if it was diminished to 0 duration
2629  if (diminishMod == 0.0f)
2630  {
2631  m_spellAura->Remove();
2632  bool found = false;
2633  for (SpellEffectInfo const* effect : GetEffects())
2634  if (effect && (effectMask & (1 << effect->EffectIndex) && effect->Effect != SPELL_EFFECT_APPLY_AURA))
2635  found = true;
2636  if (!found)
2637  return SPELL_MISS_IMMUNE;
2638  }
2639  else
2640  {
2641  ((UnitAura*)m_spellAura)->SetDiminishGroup(m_diminishGroup);
2642 
2643  bool positive = m_spellAura->GetSpellInfo()->IsPositive();
2645  positive = aurApp->IsPositive();
2646 
2647  duration = m_originalCaster->ModSpellDuration(aurSpellInfo, unit, duration, positive, effectMask);
2648 
2649  if (duration > 0)
2650  {
2651  // Haste modifies duration of channeled spells
2652  if (m_spellInfo->IsChanneled())
2653  m_originalCaster->ModSpellDurationTime(aurSpellInfo, duration, this);
2655  {
2656  int32 origDuration = duration;
2657  duration = 0;
2658  for (SpellEffectInfo const* effect : GetEffects())
2659  if (effect)
2660  if (AuraEffect const* eff = m_spellAura->GetEffect(effect->EffectIndex))
2661  if (int32 period = eff->GetPeriod()) // period is hastened by UNIT_MOD_CAST_SPEED
2662  duration = std::max(std::max(origDuration / period, 1) * period, duration);
2663 
2664  // if there is no periodic effect
2665  if (!duration)
2666  duration = int32(origDuration * m_originalCaster->GetFloatValue(UNIT_MOD_CAST_SPEED));
2667  }
2668  }
2669 
2670  if (duration != m_spellAura->GetMaxDuration())
2671  {
2672  m_spellAura->SetMaxDuration(duration);
2673  m_spellAura->SetDuration(duration);
2674  }
2676  }
2677  }
2678  }
2679  }
2680 
2681  for (SpellEffectInfo const* effect : GetEffects())
2682  if (effect && (effectMask & (1 << effect->EffectIndex)))
2683  HandleEffects(unit, NULL, NULL, effect->EffectIndex, SPELL_EFFECT_HANDLE_HIT_TARGET);
2684 
2685  return SPELL_MISS_NONE;
2686 }
Definition: SharedDefines.h:549
Definition: SpellAuraEffects.h:30
SpellInfo const * GetSpellInfo() const
Definition: SpellAuras.h:130
Definition: SharedDefines.h:4364
Definition: Unit.h:564
void PrepareScriptHitHandlers()
Definition: Spell.cpp:7105
SpellInfo const *const m_spellInfo
Definition: Spell.h:547
Unit *const m_caster
Definition: Spell.h:647
uint32 Id
Definition: SpellInfo.h:329
Definition: SharedDefines.h:2028
void SetContestedPvP(Player *attackedPlayer=NULL)
Definition: Unit.cpp:13138
void threatAssist(Unit *victim, float baseThreat, SpellInfo const *threatSpell=NULL)
Definition: HostileRefManager.cpp:35
SpellInfo const * GetAuraRankForLevel(uint8 level) const
Definition: SpellInfo.cpp:2778
Definition: SharedDefines.h:481
static ObjectGuid const Empty
Definition: ObjectGuid.h:196
void SetStackAmount(uint8 num)
Definition: SpellAuras.cpp:930
bool IsChanneled() const
Definition: SpellInfo.cpp:1514
Definition: Unit.h:674
virtual bool IsImmunedToSpellEffect(SpellInfo const *spellInfo, uint32 index) const
Definition: Unit.cpp:9339
DiminishingLevels m_diminishLevel
Definition: Spell.h:702
int32 GetMaxDuration() const
Definition: SpellAuras.h:159
bool _IsValidAttackTarget(Unit const *target, SpellInfo const *bySpell, WorldObject const *obj=NULL) const
Definition: Unit.cpp:10008
void CallScriptBeforeHitHandlers()
Definition: Spell.cpp:7172
bool IsControlledByPlayer() const
Definition: Unit.h:1712
Definition: SpellInfo.h:326
void HandleEffects(Unit *pUnitTarget, Item *pItemTarget, GameObject *pGOTarget, uint32 i, SpellEffectHandleMode mode)
Definition: Spell.cpp:4711
void ModSpellDurationTime(SpellInfo const *spellProto, int32 &castTime, Spell *spell=NULL)
Definition: Unit.cpp:11067
virtual bool IsImmunedToSpell(SpellInfo const *spellInfo) const
Definition: Unit.cpp:9255
void SetMaxDuration(int32 duration)
Definition: SpellAuras.h:160
Definition: SpellAuraDefines.h:76
float ApplyDiminishingToDuration(DiminishingGroup group, int32 &duration, Unit *caster, DiminishingLevels Level, int32 limitduration)
Definition: Unit.cpp:11126
Definition: SpellAuras.h:50
bool IsInCombat() const
Definition: Unit.h:1584
void RemoveAurasWithInterruptFlags(uint32 flag, uint32 except=0)
Definition: Unit.cpp:3816
Definition: DBCEnums.h:185
DiminishingReturnsType GetDiminishingReturnsGroupType(DiminishingGroup group)
Definition: SpellMgr.cpp:404
Definition: ObjectGuid.h:32
Definition: UpdateFields.h:129
SpellEffectInfo const * GetEffect(uint32 index) const
Definition: Spell.h:624
arena_t NULL
Definition: jemalloc_internal.h:624
void SetInCombatState(bool PvP, Unit *enemy=NULL)
Definition: Unit.cpp:9895
Definition: SharedDefines.h:2021
Definition: Creature.h:56
Definition: SharedDefines.h:1016
uint32 flags_extra
Definition: Creature.h:142
virtual void Remove(AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)=0
Item * m_CastItem
Definition: Spell.h:548
SpellValue *const m_spellValue
Definition: Spell.h:649
int32 ModSpellDuration(SpellInfo const *spellProto, Unit const *target, int32 duration, bool positive, uint32 effectMask)
Definition: Unit.cpp:10956
Definition: SpellAuras.h:329
DiminishingLevels GetDiminishing(DiminishingGroup group)
Definition: Unit.cpp:11086
const AuraApplication * GetApplicationOfTarget(ObjectGuid guid) const
Definition: SpellAuras.h:233
T max(const T &x, const T &y)
Definition: g3dmath.h:320
Player * ToPlayer()
Definition: Object.h:191
bool ModStackAmount(int32 num, AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
Definition: SpellAuras.cpp:956
uint8 getLevel() const
Definition: Unit.h:1408
Definition: SharedDefines.h:2027
Definition: SharedDefines.h:4365
Definition: DBCEnums.h:186
Aura * m_spellAura
Definition: Spell.h:699
bool IsImmunedToDamage(SpellSchoolMask meleeSchoolMask) const
Definition: Unit.cpp:9214
DiminishingGroup GetDiminishingReturnsGroupForSpell(SpellInfo const *spellproto)
Definition: SpellMgr.cpp:55
TypeID GetTypeId() const
Definition: Object.h:113
CreatureTemplate const * GetCreatureTemplate() const
Definition: Creature.h:558
uint8 AuraStackAmount
Definition: Spell.h:271
Definition: Spell.h:289
Definition: SpellInfo.h:190
Unit * unitTarget
Definition: Spell.h:690
Unit * m_originalCaster
Definition: Spell.h:653
AuraEffect * GetEffect(uint32 index) const
Definition: SpellAuras.cpp:448
HostileRefManager & getHostileRefManager()
Definition: Unit.h:2001
bool IsPositive() const
Definition: SpellInfo.cpp:1495
bool HasAttribute(SpellAttr0 attribute) const
Definition: SpellInfo.h:462
float GetFloatValue(uint16 index) const
Definition: Object.cpp:312
Definition: SpellInfo.h:238
int32_t int32
Definition: Define.h:146
bool IsFriendlyTo(Unit const *unit) const
Definition: Unit.cpp:7170
SpellMissInfo
Definition: SharedDefines.h:2019
DiminishingReturnsType
Definition: SharedDefines.h:4361
ObjectGuid GetCharmerOrOwnerGUID() const
Definition: Unit.cpp:12677
SpellEffectInfoVector const & GetEffects() const
Definition: Spell.h:623
float Speed
Definition: SpellInfo.h:380
ObjectGuid const & GetGUID() const
Definition: Object.h:105
Definition: ObjectGuid.h:33
static Aura * TryRefreshStackOrCreate(SpellInfo const *spellproto, uint32 tryEffMask, WorldObject *owner, Unit *caster, int32 *baseAmount=NULL, Item *castItem=NULL, ObjectGuid casterGUID=ObjectGuid::Empty, bool *refresh=NULL, int32 castItemLevel=-1)
Definition: SpellAuras.cpp:282
Definition: UpdateFields.h:109
Creature * ToCreature()
Definition: Object.h:194
Definition: Unit.h:54
int32_t int32
Definition: g3dmath.h:167
SpellEffectInfoVector GetEffectsForDifficulty(uint32 difficulty) const
Definition: SpellInfo.cpp:3311
bool HasUnitState(const uint32 f) const
Definition: Unit.h:1395
uint8_t uint8
Definition: Define.h:152
int32 GetDiminishingReturnsLimitDuration(SpellInfo const *spellproto)
Definition: SpellMgr.cpp:432
#define ASSERT
Definition: Errors.h:55
void _RegisterForTargets()
Definition: SpellAuras.h:151
#define MAX_SPELL_EFFECTS
Definition: DBCStructure.h:1026
int32 EffectBasePoints[MAX_SPELL_EFFECTS]
Definition: Spell.h:268
void IncrDiminishing(DiminishingGroup group)
Definition: Unit.cpp:11112
void RemoveAurasByType(AuraType auraType, std::function< bool(AuraApplication const *)> const &check)
Definition: Unit.cpp:3567
Definition: DBCEnums.h:290
void SetDuration(int32 duration, bool withMods=false)
Definition: SpellAuras.cpp:806
DiminishingGroup m_diminishGroup
Definition: Spell.h:703
int32 m_castItemLevel
Definition: Spell.h:551
bool HasFlag(uint16 index, uint32 flag) const
Definition: Object.cpp:1239
uint32 GetCombatTimer() const
Definition: Unit.h:1590
Player * GetCharmerOrOwnerPlayerOrPlayerItself() const
Definition: Unit.cpp:7560

+ Here is the caller graph for this function:

void Spell::DoTriggersOnSpellHit ( Unit unit,
uint8  effMask 
)
protected
Todo:
move this code to scripts
Todo:
remove/cleanup this, as this table is not documented and people are doing stupid things with it
2689 {
2690  // Apply additional spell effects to target
2692  if (m_preCastSpell)
2693  {
2694  // Paladin immunity shields
2695  if (m_preCastSpell == 61988)
2696  {
2697  // Cast Forbearance
2698  m_caster->CastSpell(unit, 25771, true);
2699  // Cast Avenging Wrath Marker
2700  unit->CastSpell(unit, 61987, true);
2701  }
2702 
2703  // Avenging Wrath
2704  if (m_preCastSpell == 61987)
2705  // Cast the serverside immunity shield marker
2706  m_caster->CastSpell(unit, 61988, true);
2707 
2708  if (sSpellMgr->GetSpellInfo(m_preCastSpell))
2709  // Blizz seems to just apply aura without bothering to cast
2711  }
2712 
2713  // handle SPELL_AURA_ADD_TARGET_TRIGGER auras
2714  // this is executed after spell proc spells on target hit
2715  // spells are triggered for each hit spell target
2716  // info confirmed with retail sniffs of permafrost and shadow weaving
2717  if (!m_hitTriggerSpells.empty())
2718  {
2719  int _duration = 0;
2720  for (HitTriggerSpellList::const_iterator i = m_hitTriggerSpells.begin(); i != m_hitTriggerSpells.end(); ++i)
2721  {
2722  if (CanExecuteTriggersOnHit(effMask, i->triggeredByAura) && roll_chance_i(i->chance))
2723  {
2725  TC_LOG_DEBUG("spells", "Spell %d triggered spell %d by SPELL_AURA_ADD_TARGET_TRIGGER aura", m_spellInfo->Id, i->triggeredSpell->Id);
2726 
2727  // SPELL_AURA_ADD_TARGET_TRIGGER auras shouldn't trigger auras without duration
2728  // set duration of current aura to the triggered spell
2729  if (i->triggeredSpell->GetDuration() == -1)
2730  {
2731  if (Aura* triggeredAur = unit->GetAura(i->triggeredSpell->Id, m_caster->GetGUID()))
2732  {
2733  // get duration from aura-only once
2734  if (!_duration)
2735  {
2736  Aura* aur = unit->GetAura(m_spellInfo->Id, m_caster->GetGUID());
2737  _duration = aur ? aur->GetDuration() : -1;
2738  }
2739  triggeredAur->SetDuration(_duration);
2740  }
2741  }
2742  }
2743  }
2744  }
2745 
2746  // trigger linked auras remove/apply
2748  if (std::vector<int32> const* spellTriggered = sSpellMgr->GetSpellLinked(m_spellInfo->Id + SPELL_LINK_HIT))
2749  {
2750  for (std::vector<int32>::const_iterator i = spellTriggered->begin(); i != spellTriggered->end(); ++i)
2751  {
2752  if (*i < 0)
2753  unit->RemoveAurasDueToSpell(-(*i));
2754  else
2755  unit->CastSpell(unit, *i, true, nullptr, nullptr, m_caster->GetGUID());
2756  }
2757  }
2758 }
SpellInfo const *const m_spellInfo
Definition: Spell.h:547
Unit *const m_caster
Definition: Spell.h:647
uint32 Id
Definition: SpellInfo.h:329
Aura * GetAura(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, ObjectGuid itemCasterGUID=ObjectGuid::Empty, uint32 reqEffMask=0) const
Definition: Unit.cpp:4151
Aura * AddAura(uint32 spellId, Unit *target)
Definition: Unit.cpp:14463
Will ignore most target checks (mostly DBC target checks)
Definition: Unit.h:479
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
Definition: SpellMgr.h:100
HitTriggerSpellList m_hitTriggerSpells
Definition: Spell.h:807
TriggerCastFlags
Definition: Unit.h:458
#define sSpellMgr
Definition: SpellMgr.h:756
bool roll_chance_i(int chance)
Definition: Random.h:53
uint32 m_preCastSpell
Definition: Spell.h:583
int32 GetDuration() const
Definition: SpellAuras.h:163
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 equipped item requirements.
Definition: Unit.h:478
Definition: SpellAuras.h:116
bool CanExecuteTriggersOnHit(uint8 effMask, SpellInfo const *triggeredByAura=NULL) const
Definition: Spell.cpp:7276
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

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Spell::EffectActivateGarrisonBuilding ( SpellEffIndex  effIndex)
5907 {
5909  return;
5910 
5912  return;
5913 
5914  if (Garrison* garrison = unitTarget->ToPlayer()->GetGarrison())
5915  garrison->ActivateBuilding(GetEffect(effIndex)->MiscValue);
5916 }
Definition: Garrison.h:83
SpellEffectInfo const * GetEffect(uint32 index) const
Definition: Spell.h:624
Player * ToPlayer()
Definition: Object.h:191
TypeID GetTypeId() const
Definition: Object.h:113
Definition: Spell.h:289
Unit * unitTarget
Definition: Spell.h:690
Definition: ObjectGuid.h:33
SpellEffectHandleMode effectHandleMode
Definition: Spell.h:696

+ Here is the call graph for this function:

void Spell::EffectActivateObject ( SpellEffIndex  effIndex)
4014 {
4016  return;
4017 
4018  if (!gameObjTarget)
4019  return;
4020 
4021  ScriptInfo activateCommand;
4022  activateCommand.command = SCRIPT_COMMAND_ACTIVATE_OBJECT;
4023 
4024  // int32 unk = effectInfo->MiscValue; // This is set for EffectActivateObject spells; needs research
4025 
4026  gameObjTarget->GetMap()->ScriptCommandStart(activateCommand, 0, m_caster, gameObjTarget);
4027 }
GameObject * gameObjTarget
Definition: Spell.h:692
Unit *const m_caster
Definition: Spell.h:647
Map * GetMap() const
Definition: Object.h:543
ScriptCommands command
Definition: ObjectMgr.h:187
Definition: ObjectMgr.h:182
Definition: Spell.h:289
void ScriptCommandStart(ScriptInfo const &script, uint32 delay, Object *source, Object *target)
Definition: MapScripts.cpp:71
Definition: ObjectMgr.h:99
SpellEffectHandleMode effectHandleMode
Definition: Spell.h:696

+ Here is the call graph for this function:

void Spell::EffectActivateRune ( SpellEffIndex  effIndex)
5288 {
5290  return;
5291 
5292  if (m_caster->GetTypeId() != TYPEID_PLAYER)
5293  return;
5294 
5295  Player* player = m_caster->ToPlayer();
5296 
5297  if (player->getClass() != CLASS_DEATH_KNIGHT)
5298  return;
5299 
5300  // needed later
5301  m_runesState = m_caster->ToPlayer()->GetRunesState();
5302 
5303  uint32 count = damage;
5304  if (count == 0) count = 1;
5305  for (uint32 j = 0; j < MAX_RUNES && count > 0; ++j)
5306  {
5307  if (player->GetRuneCooldown(j) && player->GetCurrentRune(j) == RuneType(effectInfo->MiscValue))
5308  {
5309  if (m_spellInfo->Id == 45529)
5310  if (player->GetBaseRune(j) != RuneType(effectInfo->MiscValueB))
5311  continue;
5312  player->SetRuneCooldown(j, 0);
5313  --count;
5314  }
5315  }
5316 
5317  // Blood Tap
5318  if (m_spellInfo->Id == 45529 && count > 0)
5319  {
5320  for (uint32 l = 0; l + 1 < MAX_RUNES && count > 0; ++l)
5321  {
5322  // Check if both runes are on cd as that is the only time when this needs to come into effect
5323  if ((player->GetRuneCooldown(l) && player->GetCurrentRune(l) == RuneType(effectInfo->MiscValueB)) && (player->GetRuneCooldown(l + 1) && player->GetCurrentRune(l + 1) == RuneType(effectInfo->MiscValueB)))
5324  {
5325  // Should always update the rune with the lowest cd
5326  if (l + 1 < MAX_RUNES && player->GetRuneCooldown(l) >= player->GetRuneCooldown(l+1))
5327  l++;
5328  player->SetRuneCooldown(l, 0);
5329  --count;
5330  // is needed to push through to the client that the rune is active
5331  player->ResyncRunes(MAX_RUNES);
5332  }
5333  else
5334  break;
5335  }
5336  }
5337 
5338  // Empower rune weapon
5339  if (m_spellInfo->Id == 47568)
5340  {
5341  // Need to do this just once
5342  if (effIndex != 0)
5343  return;
5344 
5345  for (uint32 i = 0; i < MAX_RUNES; ++i)
5346  {
5347  if (player->GetRuneCooldown(i) && (player->GetCurrentRune(i) == RUNE_FROST || player->GetCurrentRune(i) == RUNE_DEATH))
5348  player->SetRuneCooldown(i, 0);
5349  }
5350  }
5351 }
int32 MiscValue
Definition: SpellInfo.h:253
SpellInfo const *const m_spellInfo
Definition: Spell.h:547
Unit *const m_caster
Definition: Spell.h:647
uint32 Id
Definition: SpellInfo.h:329
SpellEffectInfo const * effectInfo
Definition: Spell.h:697
Definition: SharedDefines.h:172
#define MAX_RUNES
Definition: Player.h:451
Player * ToPlayer()
Definition: Object.h:191
TypeID GetTypeId() const
Definition: Object.h:113
int32 damage
Definition: Spell.h:694
Definition: Player.h:464
uint32_t uint32
Definition: Define.h:150
Definition: ObjectGuid.h:33
uint8 m_runesState
Definition: Spell.h:665
Definition: Player.h:463
RuneType
Definition: Player.h:459
int32 MiscValueB
Definition: SpellInfo.h:254
SpellEffectHandleMode effectHandleMode
Definition: Spell.h:696
Definition: Spell.h:286

+ Here is the call graph for this function:

void Spell::EffectActivateSpec ( SpellEffIndex  effIndex)
5568 {
5570  return;
5571 
5573  return;
5574 
5575  unitTarget->ToPlayer()->ActivateTalentGroup(damage-1); // damage is 1 or 2, spec is 0 or 1
5576 }
Player * ToPlayer()
Definition: Object.h:191
TypeID GetTypeId() const
Definition: Object.h:113
Definition: Spell.h:289
Unit * unitTarget
Definition: Spell.h:690
int32 damage
Definition: Spell.h:694
Definition: ObjectGuid.h:33
SpellEffectHandleMode effectHandleMode
Definition: Spell.h:696

+ Here is the call graph for this function:

void Spell::EffectAddComboPoints ( SpellEffIndex  effIndex)
3834 {
3836  return;
3837 
3838  if (!unitTarget)
3839  return;
3840 
3841  if (!m_caster->m_movedPlayer)
3842  return;
3843 
3844  if (damage <= 0)
3845  return;
3846 
3847  m_caster->m_movedPlayer->AddComboPoints(damage, this);
3848 }
Unit *const m_caster
Definition: Spell.h:647
Definition: Spell.h:289
Unit * unitTarget
Definition: Spell.h:690
int32 damage
Definition: Spell.h:694
Player * m_movedPlayer
Definition: Unit.h:1753
SpellEffectHandleMode effectHandleMode
Definition: Spell.h:696
void Spell::EffectAddExtraAttacks ( SpellEffIndex  effIndex)
4316 {
4318  return;
4319 
4320  if (!unitTarget || !unitTarget->IsAlive())
4321  return;
4322 
4324  return;
4325 
4327 
4329 }
void ExecuteLogEffectExtraAttacks(uint8 effIndex, Unit *victim, uint32 numAttacks)
Definition: Spell.cpp:4160
Definition: Spell.h:289
Unit * unitTarget
Definition: Spell.h:690
int32 damage
Definition: Spell.h:694
bool IsAlive() const
Definition: Unit.h:1692
uint32 m_extraAttacks
Definition: Unit.h:1366
SpellEffectHandleMode effectHandleMode
Definition: Spell.h:696

+ Here is the call graph for this function:

void Spell::EffectAddFarsight ( SpellEffIndex  effIndex)
2436 {
2438  return;
2439 
2440  if (m_caster->GetTypeId() != TYPEID_PLAYER)
2441  return;
2442 
2443  float radius = effectInfo->CalcRadius();
2444  int32 duration = m_spellInfo->GetDuration();
2445  // Caster not in world, might be spell triggered from aura removal
2446  if (!m_caster->IsInWorld())
2447  return;
2448 
2449  DynamicObject* dynObj = new DynamicObject(true);
2451  {
2452  delete dynObj;
2453  return;
2454  }
2455 
2456  dynObj->SetDuration(duration);
2457  dynObj->SetCasterViewpoint();
2458 }
SpellInfo const *const m_spellInfo
Definition: Spell.h:547
Unit *const m_caster
Definition: Spell.h:647
SpellEffectInfo const * effectInfo
Definition: Spell.h:697
Map * GetMap() const
Definition: Object.h:543
bool CreateDynamicObject(ObjectGuid::LowType guidlow, Unit *caster, SpellInfo const *spell, Position const &pos, float radius, DynamicObjectType type)
Definition: DynamicObject.cpp:83
void SetDuration(int32 newDuration)
Definition: DynamicObject.cpp:179
WorldLocation * destTarget
Definition: Spell.h:693
void SetCasterViewpoint()
Definition: DynamicObject.cpp:207
int32 GetDuration() const
Definition: SpellInfo.cpp:2490
Definition: DynamicObject.h:35
TypeID GetTypeId() const
Definition: Object.h:113
float CalcRadius(Unit *caster=NULL, Spell *=NULL) const
Definition: SpellInfo.cpp:655
Definition: Spell.h:288
int32_t int32
Definition: Define.h:146
Definition: ObjectGuid.h:33
Definition: DynamicObject.h:32
ObjectGuid::LowType GenerateLowGuid()
Definition: Map.h:561
bool IsInWorld() const
Definition: Object.h:100
SpellEffectHandleMode effectHandleMode
Definition: Spell.h:696

+ Here is the call graph for this function:

void Spell::EffectAddGarrisonFollower ( SpellEffIndex  effIndex)
5875 {
5877  return;
5878 
5880  return;
5881 
5882  if (Garrison* garrison = unitTarget->ToPlayer()->GetGarrison())
5883  garrison->AddFollower(GetEffect(effIndex)->MiscValue);
5884 }
Definition: Garrison.h:83
SpellEffectInfo const * GetEffect(uint32 index) const
Definition: Spell.h:624
Player * ToPlayer()
Definition: Object.h:191
TypeID GetTypeId() const
Definition: Object.h:113
Definition: Spell.h:289
Unit * unitTarget
Definition: Spell.h:690
Definition: ObjectGuid.h:33
SpellEffectHandleMode effectHandleMode
Definition: Spell.h:696

+ Here is the call graph for this function:

void Spell::EffectApplyAreaAura ( SpellEffIndex  effIndex)
1102 {
1104  return;
1105 
1106  if (!m_spellAura || !unitTarget)
1107  return;
1110 }
Aura * m_spellAura
Definition: Spell.h:699
Definition: Spell.h:289
Unit * unitTarget
Definition: Spell.h:690
WorldObject * GetOwner() const
Definition: SpellAuras.h:137
void _ApplyEffectForTargets(uint8 effIndex)
Definition: SpellAuras.cpp:671
#define ASSERT
Definition: Errors.h:55
SpellEffectHandleMode effectHandleMode
Definition: Spell.h:696

+ Here is the call graph for this function:

void Spell::EffectApplyAura ( SpellEffIndex  effIndex)
1091 {
1093  return;
1094 
1095  if (!m_spellAura || !unitTarget)
1096  return;
1099 }
Aura * m_spellAura
Definition: Spell.h:699
Definition: Spell.h:289
Unit * unitTarget
Definition: Spell.h:690
WorldObject * GetOwner() const
Definition: SpellAuras.h:137
void _ApplyEffectForTargets(uint8 effIndex)
Definition: SpellAuras.cpp:671
#define ASSERT
Definition: Errors.h:55
SpellEffectHandleMode effectHandleMode
Definition: Spell.h:696

+ Here is the call graph for this function:

void Spell::EffectApplyGlyph ( SpellEffIndex  effIndex)
4030 {
4032  return;
4033 
4034  if (m_misc.GlyphSlot >= MAX_GLYPH_SLOT_INDEX)
4035  return;
4036 
4037  Player* player = m_caster->ToPlayer();
4038  if (!player)
4039  return;
4040 
4041  // glyph sockets level requirement
4042  uint8 minLevel = 0;
4043  switch (m_misc.GlyphSlot)
4044  {
4045  case 0:
4046  case 1:
4047  case 6: minLevel = 25; break;
4048  case 2:
4049  case 3:
4050  case 7: minLevel = 50; break;
4051  case 4:
4052  case 5:
4053  case 8: minLevel = 75; break;
4054  }
4055 
4056  if (minLevel && m_caster->getLevel() < minLevel)
4057  {
4059  return;
4060  }
4061 
4062  // apply new one
4063  if (uint32 newGlyph = effectInfo->MiscValue)
4064  {
4065  if (GlyphPropertiesEntry const* newGlyphProperties = sGlyphPropertiesStore.LookupEntry(newGlyph))
4066  {
4067  if (GlyphSlotEntry const* newGlyphSlot = sGlyphSlotStore.LookupEntry(player->GetGlyphSlot(m_misc.GlyphSlot)))
4068  {
4069  if (newGlyphProperties->Type != newGlyphSlot->Type)
4070  {
4072  return; // glyph slot mismatch
4073  }
4074  }
4075 
4076  // remove old glyph
4077  if (uint32 oldGlyph = player->GetGlyph(player->GetActiveTalentGroup(), m_misc.GlyphSlot))
4078  {
4079  if (GlyphPropertiesEntry const* oldGlyphProperties = sGlyphPropertiesStore.LookupEntry(oldGlyph))
4080  {
4081  player->RemoveAurasDueToSpell(oldGlyphProperties->SpellID);
4082  player->SetGlyph(m_misc.GlyphSlot, 0);
4083  }
4084  }
4085 
4086  player->CastSpell(m_caster, newGlyphProperties->SpellID, true);
4087  player->SetGlyph(m_misc.GlyphSlot, newGlyph);
4088  player->SendTalentsInfoData();
4089  }
4090  }
4091  else if (uint32 oldGlyph = player->GetGlyph(player->GetActiveTalentGroup(), m_misc.GlyphSlot)) // Removing the glyph, get the old one
4092  {
4093  if (GlyphPropertiesEntry const* oldGlyphProperties = sGlyphPropertiesStore.LookupEntry(oldGlyph))
4094  {
4095  player->RemoveAurasDueToSpell(oldGlyphProperties->SpellID);
4096  player->SetGlyph(m_misc.GlyphSlot, 0);
4097  player->SendTalentsInfoData();
4098  }
4099  }
4100 }
union Spell::@326 m_misc
int32 MiscValue
Definition: SpellInfo.h:253
Unit *const m_caster
Definition: Spell.h:647
SpellEffectInfo const * effectInfo
Definition: Spell.h:697
Definition: SharedDefines.h:1481
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
DB2Storage< GlyphSlotEntry > sGlyphSlotStore("GlyphSlot.db2", GlyphSlotFormat, HOTFIX_SEL_GLYPH_SLOT)
Player * ToPlayer()
Definition: Object.h:191
uint8 getLevel() const
Definition: Unit.h:1408
Definition: DB2Structure.h:572
#define MAX_GLYPH_SLOT_INDEX
Definition: SharedDefines.h:854
Definition: Spell.h:288
uint32_t uint32
Definition: Define.h:150
DBCStorage< GlyphPropertiesEntry > sGlyphPropertiesStore(GlyphPropertiesfmt)
Definition: SharedDefines.h:1479
Definition: DBCStructure.h:509
uint8_t uint8
Definition: Define.h:152
SpellEffectHandleMode effectHandleMode
Definition: Spell.h:696

+ Here is the call graph for this function:

void Spell::EffectBind ( SpellEffIndex  effIndex)
5715 {
5717  return;
5718 
5720  return;
5721 
5722  Player* player = unitTarget->ToPlayer();
5723 
5724  WorldLocation homeLoc;
5725  uint32 areaId = player->GetAreaId();
5726 
5727  if (effectInfo->MiscValue)
5728  areaId = effectInfo->MiscValue;
5729 
5730  if (m_targets.HasDst())
5731  homeLoc.WorldRelocate(*destTarget);
5732  else
5733  homeLoc = player->GetWorldLocation();
5734 
5735  player->SetHomebind(homeLoc, areaId);
5736  player->SendBindPointUpdate();
5737 
5738  TC_LOG_DEBUG("spells", "EffectBind: New homebind X: %f, Y: %f, Z: %f, MapId: %u, AreaId: %u",
5739  homeLoc.GetPositionX(), homeLoc.GetPositionY(), homeLoc.GetPositionZ(), homeLoc.GetMapId(), areaId);
5740 
5741  // zone update
5743  player->SendDirectMessage(packet.Write());
5744 }
int32 MiscValue
Definition: SpellInfo.h:253
Unit *const m_caster
Definition: Spell.h:647
Definition: Position.h:228
SpellEffectInfo const * effectInfo
Definition: Spell.h:697
SpellCastTargets m_targets
Definition: Spell.h:584
Definition: MiscPackets.h:47
WorldLocation * destTarget
Definition: Spell.h:693
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
Player * ToPlayer()
Definition: Object.h:191
TypeID GetTypeId() const
Definition: Object.h:113
WorldLocation GetWorldLocation() const
Definition: Position.h:249
Definition: Spell.h:289
Unit * unitTarget
Definition: Spell.h:690
bool HasDst() const
Definition: Spell.h:229
float GetPositionY() const
Definition: Position.h:105
float GetPositionZ() const
Definition: Position.h:106
uint32_t uint32
Definition: Define.h:150
uint32 GetMapId() const
Definition: Position.h:254
ObjectGuid const & GetGUID() const
Definition: Object.h:105
Definition: ObjectGuid.h:33
float GetPositionX() const
Definition: Position.h:104
void WorldRelocate(WorldLocation const &loc)
Definition: Position.h:237
SpellEffectHandleMode effectHandleMode
Definition: Spell.h:696

+ Here is the call graph for this function:

void Spell::EffectBlock ( SpellEffIndex  effIndex)
4341 {
4343  return;
4344 
4345  if (m_caster->GetTypeId() == TYPEID_PLAYER)
4346  m_caster->ToPlayer()->SetCanBlock(true);
4347 }
Unit *const m_caster
Definition: Spell.h:647
Player * ToPlayer()
Definition: Object.h:191
TypeID GetTypeId() const
Definition: Object.h:113
Definition: Spell.h:288
Definition: ObjectGuid.h:33
SpellEffectHandleMode effectHandleMode
Definition: Spell.h:696

+ Here is the call graph for this function:

void Spell::EffectCastButtons ( SpellEffIndex  effIndex)

Action button data is unverified when it's set so it can be "hacked" to contain invalid spells, so filter here.

5644 {
5646  return;
5647 
5648  if (m_caster->GetTypeId() != TYPEID_PLAYER)
5649  return;
5650 
5651  Player* p_caster = m_caster->ToPlayer();
5652  uint32 button_id = effectInfo->MiscValue + 132;
5653  uint32 n_buttons = effectInfo->MiscValueB;
5654 
5655  for (; n_buttons; --n_buttons, ++button_id)
5656  {
5657  ActionButton const* ab = p_caster->GetActionButton(button_id);
5658  if (!ab || ab->GetType() != ACTION_BUTTON_SPELL)
5659  continue;
5660 
5663  uint32 spell_id = ab->GetAction();
5664  if (!spell_id)
5665  continue;
5666 
5667  SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spell_id);
5668  if (!spellInfo)
5669  continue;
5670 
5671  if (!p_caster->HasSpell(spell_id) || p_caster->GetSpellHistory()->HasCooldown(spell_id))
5672  continue;
5673 
5675  continue;
5676 
5678  m_caster->CastSpell(m_caster, spell_id, triggerFlags);
5679  }
5680 }
int32 MiscValue
Definition: SpellInfo.h:253
Unit *const m_caster
Definition: Spell.h:647
SpellEffectInfo const * effectInfo
Definition: Spell.h:697
Definition: SharedDefines.h:685
Definition: SpellInfo.h:326
ActionButtonType GetType() const
Definition: Player.h:345
uint32 GetAction() const
Definition: Player.h:346
Definition: Player.h:312
Not triggered.
Definition: Unit.h:461
Will ignore combo point requirement.
Definition: Unit.h:468
Player * ToPlayer()
Definition: Object.h:191
TypeID GetTypeId() const
Definition: Object.h:113
Definition: Spell.h:288
Definition: Player.h:337
bool HasAttribute(SpellAttr0 attribute) const
Definition: SpellInfo.h:462
TriggerCastFlags
Definition: Unit.h:458
#define sSpellMgr
Definition: SpellMgr.h:756
uint32_t uint32
Definition: Define.h:150
Definition: ObjectGuid.h:33
Disallows proc events from triggered spell (default)
Definition: Unit.h:476
Will ignore aura scaling.
Definition: Unit.h:466
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
int32 MiscValueB
Definition: SpellInfo.h:254
SpellEffectHandleMode effectHandleMode
Definition: Spell.h:696

+ Here is the call graph for this function:

void Spell::EffectChangeRaidMarker ( SpellEffIndex  effIndex)
4674 {
4676  return;
4677 
4678  Player* player = m_caster->ToPlayer();
4679  if (!player || !m_targets.HasDst())
4680  return;
4681 
4682  Group* group = player->GetGroup();
4683  if (!group || (group->isRaidGroup() && !group->IsLeader(player->GetGUID()) && !group->IsAssistant(player->GetGUID())))
4684  return;
4685 
4686  float x, y, z;
4687  destTarget->GetPosition(x, y, z);
4688 
4689  group->AddRaidMarker(damage, player->GetMapId(), x, y, z);
4690 }
Unit *const m_caster
Definition: Spell.h:647
SpellCastTargets m_targets
Definition: Spell.h:584
bool isRaidGroup() const
Definition: Group.cpp:2509
WorldLocation * destTarget
Definition: Spell.h:693
void AddRaidMarker(uint8 markerId, uint32 mapId, float positionX, float positionY, float positionZ, ObjectGuid transportGuid=ObjectGuid::Empty)
Definition: Group.cpp:2457
Player * ToPlayer()
Definition: Object.h:191
Definition: Spell.h:288
int32 damage
Definition: Spell.h:694
bool HasDst() const
Definition: Spell.h:229
G3D::int16 z
Definition: Vector3int16.h:46
void GetPosition(float &x, float &y) const
Definition: Position.h:109
G3D::int16 y
Definition: Vector2int16.h:38
bool IsLeader(ObjectGuid guid) const
Definition: Group.cpp:2571
G3D::int16 x
Definition: Vector2int16.h:37
bool IsAssistant(ObjectGuid guid) const
Definition: Group.cpp:2584
Definition: Group.h:191
SpellEffectHandleMode effectHandleMode
Definition: Spell.h:696

+ Here is the call graph for this function:

void Spell::EffectCharge ( SpellEffIndex  effIndex)
4491 {
4492  if (!unitTarget)
4493  return;
4494 
4496  {
4497  float speed = G3D::fuzzyGt(m_spellInfo->Speed, 0.0f) ? m_spellInfo->Speed : SPEED_CHARGE;
4498  // Spell is not using explicit target - no generated path
4500  {
4501  //unitTarget->GetContactPoint(m_caster, pos.m_positionX, pos.m_positionY, pos.m_positionZ);
4504  }
4505  else
4507  }
4508 
4510  {
4511  // not all charge effects used in negative spells
4513  m_caster->Attack(unitTarget, true);
4514 
4515  if (effectInfo->TriggerSpell)
4517  }
4518 }
SpellInfo const *const m_spellInfo
Definition: Spell.h:547
Unit *const m_caster
Definition: Spell.h:647
bool Attack(Unit *victim, bool meleeAttack)
Definition: Unit.cpp:7222
SpellEffectInfo const * effectInfo
Definition: Spell.h:697
Position GetFirstCollisionPosition(float dist, float angle)
Definition: Object.cpp:2636
float m_positionY
Definition: Position.h:53
MotionMaster * GetMotionMaster()
Definition: Unit.h:2101
void MoveCharge(float x, float y, float z, float speed=SPEED_CHARGE, uint32 id=EVENT_CHARGE, bool generatePath=false)
Definition: MotionMaster.cpp:465
float m_positionX
Definition: Position.h:52
TypeID GetTypeId() const
Definition: Object.h:113
uint32 TriggerSpell
Definition: SpellInfo.h:263
Definition: Spell.h:289
Unit * unitTarget
Definition: Spell.h:690
Definition: PathGenerator.h:43
bool IsPositive() const
Definition: SpellInfo.cpp:1495
PathGenerator m_preGeneratedPath
Definition: Spell.h:830
Definition: Spell.h:287
float GetRelativeAngle(Position const *pos) const
Definition: Position.h:177
float m_positionZ
Definition: Position.h:54
float Speed
Definition: SpellInfo.h:380
ObjectGuid m_originalCasterGUID
Definition: Spell.h:651
Definition: ObjectGuid.h:33
#define SPEED_CHARGE
Definition: MotionMaster.h:80
Definition: Position.h:27
bool fuzzyGt(double a, double b)
Definition: g3dmath.h:865
PathType GetPathType() const
Definition: PathGenerator.h:73
float GetObjectSize() const
Definition: Object.cpp:2656
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
SpellEffectHandleMode effectHandleMode
Definition: Spell.h:696

+ Here is the call graph for this function:

void Spell::EffectChargeDest ( SpellEffIndex  effIndex)
4521 {
4523  return;
4524 
4525  if (m_targets.HasDst())
4526  {
4527  Position pos = destTarget->GetPosition();
4528  float angle = m_caster->GetRelativeAngle(pos.GetPositionX(), pos.GetPositionY());
4529  float dist = m_caster->GetDistance(pos);
4530  pos = m_caster->GetFirstCollisionPosition(dist, angle);
4531 
4533  }
4534 }
Unit *const m_caster
Definition: Spell.h:647
Position GetFirstCollisionPosition(float dist, float angle)
Definition: Object.cpp:2636
float m_positionY
Definition: Position.h:53
SpellCastTargets m_targets
Definition: Spell.h:584
MotionMaster * GetMotionMaster()
Definition: Unit.h:2101
void MoveCharge(float x, float y, float z, float speed=SPEED_CHARGE, uint32 id=EVENT_CHARGE, bool generatePath=false)
Definition: MotionMaster.cpp:465
float m_positionX
Definition: Position.h:52
WorldLocation * destTarget
Definition: Spell.h:693
float GetDistance(WorldObject const *obj) const
Definition: Object.cpp:1594
bool HasDst() const
Definition: Spell.h:229
float GetPositionY() const
Definition: Position.h:105
void GetPosition(float &x, float &y) const
Definition: Position.h:109
float GetRelativeAngle(Position const *pos) const
Definition: Position.h:177
float m_positionZ
Definition: Position.h:54
Definition: Position.h:27
float GetPositionX() const
Definition: Position.h:104
SpellEffectHandleMode effectHandleMode
Definition: Spell.h:696
Definition: Spell.h:286

+ Here is the call graph for this function:

void Spell::EffectCreateAreaTrigger ( SpellEffIndex  effIndex)
5801 {
5803  return;
5804 
5805  Position pos;
5806  if (!m_targets.HasDst())
5807  pos = GetCaster()->GetPosition();
5808  else
5809  pos = destTarget->GetPosition();
5810 
5811  // trigger entry/miscvalue relation is currently unknown, for now use MiscValue as trigger entry
5812  uint32 triggerEntry = effectInfo->MiscValue;
5813 
5814  AreaTrigger * areaTrigger = new AreaTrigger;
5815  if (!areaTrigger->CreateAreaTrigger(GetCaster()->GetMap()->GenerateLowGuid<HighGuid::AreaTrigger>(), triggerEntry, GetCaster(), GetSpellInfo(), pos))
5816  delete areaTrigger;
5817 }
int32 MiscValue
Definition: SpellInfo.h:253
SpellEffectInfo const * effectInfo
Definition: Spell.h:697
Unit * GetCaster() const
Definition: Spell.h:612
SpellCastTargets m_targets
Definition: Spell.h:584
WorldLocation * destTarget
Definition: Spell.h:693
Definition: Spell.h:288
bool HasDst() const
Definition: Spell.h:229
void GetPosition(float &x, float &y) const
Definition: Position.h:109
uint32_t uint32
Definition: Define.h:150
SpellInfo const * GetSpellInfo() const
Definition: Spell.h:614
bool CreateAreaTrigger(ObjectGuid::LowType guidlow, uint32 triggerEntry, Unit *caster, SpellInfo const *spell, Position const &pos)
Definition: AreaTrigger.cpp:59
Definition: Position.h:27
Definition: AreaTrigger.h:26
SpellEffectHandleMode effectHandleMode
Definition: Spell.h:696

+ Here is the call graph for this function:

void Spell::EffectCreateGarrison ( SpellEffIndex  effIndex)
5864 {
5866  return;
5867 
5869  return;
5870 
5871  unitTarget->ToPlayer()->CreateGarrison(GetEffect(effIndex)->MiscValue);
5872 }
SpellEffectInfo const * GetEffect(uint32 index) const
Definition: Spell.h:624
Player * ToPlayer()
Definition: Object.h:191
TypeID GetTypeId() const
Definition: Object.h:113
Definition: Spell.h:289
Unit * unitTarget
Definition: Spell.h:690
Definition: ObjectGuid.h:33
SpellEffectHandleMode effectHandleMode
Definition: Spell.h:696

+ Here is the call graph for this function:

void Spell::EffectCreateHeirloomItem ( SpellEffIndex  effIndex)
5887 {
5889  return;
5890 
5891  Player* player = m_caster->ToPlayer();
5892  if (!player)
5893  return;
5894 
5895  CollectionMgr* collectionMgr = player->GetSession()->GetCollectionMgr();
5896  if (!collectionMgr)
5897  return;
5898 
5899  std::vector<int32> bonusList;
5900  bonusList.push_back(collectionMgr->GetHeirloomBonus(m_misc.Raw.Data[0]));
5901 
5902  DoCreateItem(effIndex, m_misc.Raw.Data[0], bonusList);
5903  ExecuteLogEffectCreateItem(effIndex, m_misc.Raw.Data[0]);
5904 }
union Spell::@326 m_misc
Unit *const m_caster
Definition: Spell.h:647
Player * ToPlayer()
Definition: Object.h:191
void DoCreateItem(uint32 i, uint32 itemtype, std::vector< int32 > const &bonusListIDs=std::vector< int32 >())
Definition: SpellEffects.cpp:1403
Definition: Spell.h:289
void ExecuteLogEffectCreateItem(uint8 effIndex, uint32 entry)
Definition: Spell.cpp:4198
uint32 GetHeirloomBonus(uint32 itemId) const
Definition: CollectionMgr.cpp:124
Definition: CollectionMgr.h:48
SpellEffectHandleMode effectHandleMode
Definition: Spell.h:696

+ Here is the call graph for this function:

void Spell::EffectCreateItem ( SpellEffIndex  effIndex)
1536 {
1538  return;
1539 
1540  DoCreateItem(effIndex, effectInfo->ItemType);
1542 }
SpellEffectInfo const * effectInfo
Definition: Spell.h:697
void DoCreateItem(uint32 i, uint32 itemtype, std::vector< int32 > const &bonusListIDs=std::vector< int32 >())
Definition: SpellEffects.cpp:1403
Definition: Spell.h:289
void ExecuteLogEffectCreateItem(uint8 effIndex, uint32 entry)
Definition: Spell.cpp:4198
uint32 ItemType
Definition: SpellInfo.h:262
SpellEffectHandleMode effectHandleMode
Definition: Spell.h:696

+ Here is the call graph for this function:

void Spell::EffectCreateItem2 ( SpellEffIndex  effIndex)
Todo:
ExecuteLogEffectCreateItem(i, m_spellInfo->Effects[i].ItemType);
1545 {
1547  return;
1548 
1550  return;
1551 
1552  Player* player = unitTarget->ToPlayer();
1553 
1554  uint32 item_id = effectInfo->ItemType;
1555 
1556  if (item_id)
1557  DoCreateItem(effIndex, item_id);
1558 
1559  // special case: fake item replaced by generate using spell_loot_template
1560  if (m_spellInfo->IsLootCrafting())
1561  {
1562  if (item_id)
1563  {
1564  if (!player->HasItemCount(item_id))
1565  return;
1566 
1567  // remove reagent
1568  uint32 count = 1;
1569  player->DestroyItemCount(item_id, count, true);
1570 
1571  // create some random items
1572  player->AutoStoreLoot(m_spellInfo->Id, LootTemplates_Spell);
1573  }
1574  else
1575  player->AutoStoreLoot(m_spellInfo->Id, LootTemplates_Spell); // create some random items
1576  }
1578 }
bool IsLootCrafting() const
Definition: SpellInfo.cpp:1238
SpellInfo const *const m_spellInfo
Definition: Spell.h:547
uint32 Id
Definition: SpellInfo.h:329
SpellEffectInfo const * effectInfo
Definition: Spell.h:697
Player * ToPlayer()
Definition: Object.h:191
TypeID GetTypeId() const
Definition: Object.h:113
void DoCreateItem(uint32 i, uint32 itemtype, std::vector< int32 > const &bonusListIDs=std::vector< int32 >())
Definition: SpellEffects.cpp:1403
Definition: Spell.h:289
Unit * unitTarget
Definition: Spell.h:690
uint32_t uint32
Definition: Define.h:150
uint32 ItemType
Definition: SpellInfo.h:262
Definition: ObjectGuid.h:33
LootStore LootTemplates_Spell("spell_loot_template","spell id (random item creating)", false)
SpellEffectHandleMode effectHandleMode
Definition: Spell.h:696

+ Here is the call graph for this function:

void Spell::EffectCreateRandomItem ( SpellEffIndex  effIndex)
Todo:
ExecuteLogEffectCreateItem(i, m_spellInfo->Effects[i].ItemType);
1581 {
1583  return;
1584 
1586  return;
1587  Player* player = unitTarget->ToPlayer();
1588 
1589  // create some random items
1590  player->AutoStoreLoot(m_spellInfo->Id, LootTemplates_Spell);
1592 }
SpellInfo const *const m_spellInfo
Definition: Spell.h:547
uint32 Id
Definition: SpellInfo.h:329
Player * ToPlayer()
Definition: Object.h:191
TypeID GetTypeId() const
Definition: Object.h:113
Definition: Spell.h:289
Unit * unitTarget
Definition: Spell.h:690
Definition: ObjectGuid.h:33
LootStore LootTemplates_Spell("spell_loot_template","spell id (random item creating)", false)
SpellEffectHandleMode effectHandleMode
Definition: Spell.h:696

+ Here is the call graph for this function:

void Spell::EffectCreateTamedPet ( SpellEffIndex  effIndex)
5354 {
5356  return;
5357 
5359  return;
5360 
5361  uint32 creatureEntry = effectInfo->MiscValue;
5362  Pet* pet = unitTarget->CreateTamedPetFrom(creatureEntry, m_spellInfo->Id);
5363  if (!pet)
5364  return;
5365 
5366  // relocate
5367  float px, py, pz;
5369  pet->Relocate(px, py, pz, unitTarget->GetOrientation());
5370 
5371  // add to world
5372  pet->GetMap()->AddToMap(pet->ToCreature());
5373 
5374  // unitTarget has pet now
5375  unitTarget->SetMinion(pet, true);
5376 
5377  pet->InitTalentForLevel();
5378 
5380  {
5382  unitTarget->ToPlayer()->PetSpellInitialize();
5383  }
5384 }
int32 MiscValue
Definition: SpellInfo.h:253
SpellInfo const *const m_spellInfo
Definition: Spell.h:547
uint32 Id
Definition: SpellInfo.h:329
SpellEffectInfo const * effectInfo
Definition: Spell.h:697
Map * GetMap() const
Definition: Object.h:543
Pet * CreateTamedPetFrom(Creature *creatureTarget, uint32 spell_id=0)
Definition: Unit.cpp:13181
void SetMinion(Minion *minion, bool apply)
Definition: Unit.cpp:7640
ObjectGuid GetPetGUID() const
Definition: Unit.h:1708
Player * ToPlayer()
Definition: Object.h:191
Definition: PetDefines.h:35
TypeID GetTypeId() const
Definition: Object.h:113
void SavePetToDB(PetSaveMode mode)
Definition: Pet.cpp:372
float GetOrientation() const
Definition: Position.h:107
void Relocate(float x, float y)
Definition: Position.h:67
Definition: Spell.h:289
Unit * unitTarget
Definition: Spell.h:690
bool AddToMap(T *)
Definition: Map.cpp:566
uint32_t uint32
Definition: Define.h:150
void InitTalentForLevel()
Definition: Pet.cpp:1704
Definition: ObjectGuid.h:33
Creature * ToCreature()
Definition: Object.h:194
Definition: SharedDefines.h:169
uint8 getClass() const
Definition: Unit.h:1413
float GetFollowAngle() const override
Definition: TemporarySummon.h:73
#define PET_FOLLOW_DIST
Definition: PetDefines.h:77
float GetObjectSize() const
Definition: Object.cpp:2656
bool IsEmpty() const
Definition: ObjectGuid.h:242
Definition: Pet.h:46
void GetClosePoint(float &x, float &y, float &z, float size, float distance2d=0, float angle=0) const
Definition: Object.cpp:2623
SpellEffectHandleMode effectHandleMode
Definition: Spell.h:696

+ Here is the call graph for this function:

void Spell::EffectDamageFromMaxHealthPCT ( SpellEffIndex  effIndex)
5622 {
5624  return;
5625 
5626  if (!unitTarget)
5627  return;
5628 
5630 }
Definition: Spell.h:289
Unit * unitTarget
Definition: Spell.h:690
int32 damage
Definition: Spell.h:694
int32 m_damage
Definition: Spell.h:709
SpellEffectHandleMode effectHandleMode
Definition: Spell.h:696
uint32 CountPctFromMaxHealth(int32 pct) const
Definition: Unit.h:1435

+ Here is the call graph for this function:

void Spell::EffectDestroyAllTotems ( SpellEffIndex  effIndex)
4783 {
4785  return;
4786 
4787  int32 mana = 0;
4788  for (uint8 slot = SUMMON_SLOT_TOTEM; slot < MAX_TOTEM_SLOT; ++slot)
4789  {
4790  if (!m_caster->m_SummonSlot[slot])
4791  continue;
4792 
4794  if (totem && totem->IsTotem())
4795  {
4796  uint32 spell_id = totem->GetUInt32Value(UNIT_CREATED_BY_SPELL);
4797  SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spell_id);
4798  if (spellInfo)
4799  {
4800  std::vector<SpellInfo::CostData> costs = spellInfo->CalcPowerCost(m_caster, spellInfo->GetSchoolMask());
4801  auto m = std::find_if(costs.begin(), costs.end(), [](SpellInfo::CostData const& cost) { return cost.Power == POWER_MANA; });
4802  if (m != costs.end())
4803  mana += m->Amount;
4804  }
4805 
4806  totem->ToTotem()->UnSummon();
4807  }
4808  }
4809 
4810  ApplyPct(mana, damage);
4811 
4812  if (mana)
4813  m_caster->CastCustomSpell(m_caster, 39104, &mana, NULL, NULL, true);
4814 }
Unit *const m_caster
Definition: Spell.h:647
void UnSummon(uint32 msTime=0) override
Definition: Totem.cpp:98
uint32 GetUInt32Value(uint16 index) const
Definition: Object.cpp:300
Map * GetMap() const
Definition: Object.h:543
Definition: SpellInfo.h:326
Definition: UpdateFields.h:134
ObjectGuid m_SummonSlot[MAX_SUMMON_SLOT]
Definition: Unit.h:1929
T ApplyPct(T &base, U pct)
Definition: Util.h:104
arena_t NULL
Definition: jemalloc_internal.h:624
Definition: Creature.h:467
Definition: SpellInfo.h:553
std::vector< CostData > CalcPowerCost(Unit const *caster, SpellSchoolMask schoolMask) const
Definition: SpellInfo.cpp:2564
Totem * ToTotem()
Definition: Unit.h:2203
Definition: Spell.h:288
int32 damage
Definition: Spell.h:694
#define SUMMON_SLOT_TOTEM
Definition: Unit.h:1281
#define sSpellMgr
Definition: SpellMgr.h:756
int32_t int32
Definition: Define.h:146
uint32_t uint32
Definition: Define.h:150
Creature * GetCreature(ObjectGuid const &guid)
Definition: Map.cpp:3535
bool IsTotem() const
Definition: Unit.h:1405
SpellSchoolMask GetSchoolMask() const
Definition: SpellInfo.cpp:2131
uint8_t uint8
Definition: Define.h:152
void CastCustomSpell(Unit *victim, uint32 spellId, int32 const *bp0, int32 const *bp1, int32 const *bp2, bool triggered, Item *castItem=NULL, AuraEffect const *triggeredByAura=NULL, ObjectGuid originalCaster=ObjectGuid::Empty)
Definition: Unit.cpp:920
#define MAX_TOTEM_SLOT
Definition: Unit.h:1282
Definition: SharedDefines.h:248
SpellEffectHandleMode effectHandleMode
Definition: Spell.h:696

+ Here is the call graph for this function:

void Spell::EffectDestroyItem ( SpellEffIndex  effIndex)
5837 {
5839  return;
5840 
5842  return;
5843 
5844  Player* player = unitTarget->ToPlayer();
5845  SpellEffectInfo const* effect = GetEffect(effIndex);
5846  uint32 itemId = effect->ItemType;
5847  if (Item* item = player->GetItemByEntry(itemId))
5848  player->DestroyItem(item->GetBagSlot(), item->GetSlot(), true);
5849 }
SpellEffectInfo const * GetEffect(uint32 index) const
Definition: Spell.h:624
Player * ToPlayer()
Definition: Object.h:191
TypeID GetTypeId() const
Definition: Object.h:113
Definition: Spell.h:289
Unit * unitTarget
Definition: Spell.h:690
Definition: Item.h:259
Definition: SpellInfo.h:238
uint32_t uint32
Definition: Define.h:150
uint32 ItemType
Definition: SpellInfo.h:262
Definition: ObjectGuid.h:33
SpellEffectHandleMode effectHandleMode
Definition: Spell.h:696

+ Here is the call graph for this function:

void Spell::EffectDiscoverTaxi ( SpellEffIndex  effIndex)
5387 {
5389  return;
5390 
5392  return;
5393  uint32 nodeid = effectInfo->MiscValue;
5394  if (sTaxiNodesStore.LookupEntry(nodeid))
5395  unitTarget->ToPlayer()->GetSession()->SendDiscoverNewTaxiNode(nodeid);
5396 }
int32 MiscValue
Definition: SpellInfo.h:253
SpellEffectInfo const * effectInfo
Definition: Spell.h:697
Player * ToPlayer()
Definition: Object.h:191
TypeID GetTypeId() const
Definition: Object.h:113
Definition: Spell.h:289
Unit * unitTarget
Definition: Spell.h:690
uint32_t uint32
Definition: Define.h:150
Definition: ObjectGuid.h:33
DB2Storage< TaxiNodesEntry > sTaxiNodesStore("TaxiNodes.db2", TaxiNodesFormat, HOTFIX_SEL_TAXI_NODES)
SpellEffectHandleMode effectHandleMode
Definition: Spell.h:696

+ Here is the call graph for this function:

void Spell::EffectDisEnchant ( SpellEffIndex  effIndex)
4151 {
4153  return;
4154 
4156  return;
4157 
4158  if (Player* caster = m_caster->ToPlayer())
4159  {
4160  caster->UpdateCraftSkill(m_spellInfo->Id);
4161  caster->SendLoot(itemTarget->GetGUID(), LOOT_DISENCHANTING);
4162  }
4163 
4164  // item will be removed at disenchanting end
4165 }
SpellInfo const *const m_spellInfo
Definition: Spell.h:547
Unit *const m_caster
Definition: Spell.h:647
uint32 Id
Definition: SpellInfo.h:329
Player * ToPlayer()
Definition: Object.h:191
Definition: Spell.h:289
uint32 DisenchantID
Definition: ItemTemplate.h:711
Item * itemTarget
Definition: Spell.h:691
Definition: LootMgr.h:93
ObjectGuid const & GetGUID() const
Definition: Object.h:105
ItemTemplate const * GetTemplate() const
Definition: Item.cpp:547
SpellEffectHandleMode effectHandleMode
Definition: Spell.h:696

+ Here is the call graph for this function:

void Spell::EffectDismissPet ( SpellEffIndex  effIndex)
4224 {
4226  return;
4227 
4228  if (!unitTarget || !unitTarget->IsPet())
4229  return;
4230 
4231  Pet* pet = unitTarget->ToPet();
4232 
4233  ExecuteLogEffectUnsummonObject(effIndex, pet);
4234  pet->GetOwner()->RemovePet(pet, PET_SAVE_NOT_IN_SLOT);
4235 }
Player * GetOwner() const
Definition: Pet.cpp:1913
Pet * ToPet()
Definition: Unit.h:2200
void ExecuteLogEffectUnsummonObject(uint8 effIndex, WorldObject *obj)
Definition: Spell.cpp:4222
Definition: Spell.h:289
Unit * unitTarget
Definition: Spell.h:690
bool IsPet() const
Definition: Unit.h:1403
Definition: PetDefines.h:38
Definition: Pet.h:46
SpellEffectHandleMode effectHandleMode
Definition: Spell.h:696

+ Here is the call graph for this function:

void Spell::EffectDispel ( SpellEffIndex  effIndex)
2289 {
2291  return;
2292 
2293  if (!unitTarget)
2294  return;
2295 
2296  // Create dispel mask by dispel type
2297  uint32 dispel_type = effectInfo->MiscValue;
2298  uint32 dispelMask = SpellInfo::GetDispelMask(DispelType(dispel_type));
2299 
2300  DispelChargesList dispel_list;
2301  unitTarget->GetDispellableAuraList(m_caster, dispelMask, dispel_list);
2302  if (dispel_list.empty())
2303  return;
2304 
2305  // Ok if exist some buffs for dispel try dispel it
2306  DispelChargesList success_list;
2308  dispelFailed.CasterGUID = m_caster->GetGUID();
2309  dispelFailed.VictimGUID = unitTarget->GetGUID();
2310  dispelFailed.SpellID = m_spellInfo->Id;
2311 
2312  // dispel N = damage buffs (or while exist buffs for dispel)
2313  for (int32 count = 0; count < damage && !dispel_list.empty();)
2314  {
2315  // Random select buff for dispel
2316  DispelChargesList::iterator itr = dispel_list.begin();
2317  std::advance(itr, urand(0, dispel_list.size() - 1));
2318 
2319  int32 chance = itr->first->CalcDispelChance(unitTarget, !unitTarget->IsFriendlyTo(m_caster));
2320  // 2.4.3 Patch Notes: "Dispel effects will no longer attempt to remove effects that have 100% dispel resistance."
2321  if (!chance)
2322  {
2323  dispel_list.erase(itr);
2324  continue;
2325  }
2326  else
2327  {
2328  if (roll_chance_i(chance))
2329  {
2330  bool alreadyListed = false;
2331  for (DispelChargesList::iterator successItr = success_list.begin(); successItr != success_list.end(); ++successItr)
2332  {
2333  if (successItr->first->GetId() == itr->first->GetId())
2334  {
2335  ++successItr->second;
2336  alreadyListed = true;
2337  }
2338  }
2339  if (!alreadyListed)
2340  success_list.push_back(std::make_pair(itr->first, 1));
2341  --itr->second;
2342  if (itr->second <= 0)
2343  dispel_list.erase(itr);
2344  }
2345  else
2346  dispelFailed.FailedSpells.push_back(int32(itr->first->GetId()));
2347 
2348  ++count;
2349  }
2350  }
2351 
2352  if (!dispelFailed.FailedSpells.empty())
2353  m_caster->SendMessageToSet(dispelFailed.Write(), true);
2354 
2355  if (success_list.empty())
2356  return;
2357 
2359  spellDispellLog.IsBreak = false; // TODO: use me
2360  spellDispellLog.IsSteal = false;
2361 
2362  spellDispellLog.TargetGUID = unitTarget->GetGUID();
2363  spellDispellLog.CasterGUID = m_caster->GetGUID();
2364  spellDispellLog.DispelledBySpellID = m_spellInfo->Id;
2365 
2366  for (std::pair<Aura*, uint8> const& dispellCharge : success_list)
2367  {
2369  dispellData.SpellID = dispellCharge.first->GetId();
2370  dispellData.Harmful = false; // TODO: use me
2371  dispellData.Rolled = boost::none; // TODO: use me
2372  dispellData.Needed = boost::none; // TODO: use me
2373 
2374  unitTarget->RemoveAurasDueToSpellByDispel(dispellCharge.first->GetId(), m_spellInfo->Id, dispellCharge.first->GetCasterGUID(), m_caster, dispellCharge.second);
2375 
2376  spellDispellLog.DispellData.emplace_back(dispellData);
2377  }
2378 
2379  m_caster->SendMessageToSet(spellDispellLog.Write(), true);
2380 
2381  CallScriptSuccessfulDispel(effIndex);
2382 }
int32 MiscValue
Definition: SpellInfo.h:253
ObjectGuid CasterGUID
Definition: SpellPackets.h:889
SpellInfo const *const m_spellInfo
Definition: Spell.h:547
Unit *const m_caster
Definition: Spell.h:647
uint32 Id
Definition: SpellInfo.h:329
std::vector< int32 > FailedSpells
Definition: SpellPackets.h:892
SpellEffectInfo const * effectInfo
Definition: Spell.h:697
ObjectGuid VictimGUID
Definition: SpellPackets.h:890
Definition: CombatLogPackets.h:209
int32 DispelledBySpellID
Definition: CombatLogPackets.h:219
WorldPacket const * Write() override
Definition: SpellPackets.cpp:848
std::vector< SpellDispellData > DispellData
Definition: CombatLogPackets.h:216
DispelType
Definition: SharedDefines.h:1836
WorldPacket const * Write() override
Definition: CombatLogPackets.cpp:354
std::list< std::pair< Aura *, uint8 > > DispelChargesList
Definition: Unit.h:422
void advance(octet_iterator &it, distance_type n, octet_iterator end)
Definition: checked.h:190
bool IsSteal
Definition: CombatLogPackets.h:221
Definition: CombatLogPackets.h:201
void CallScriptSuccessfulDispel(SpellEffIndex effIndex)
Definition: Spell.cpp:7159
Definition: Spell.h:289
Unit * unitTarget
Definition: Spell.h:690
void GetDispellableAuraList(Unit *caster, uint32 dispelMask, DispelChargesList &dispelList)
Definition: Unit.cpp:4175
int32 damage
Definition: Spell.h:694
Optional< int32 > Rolled
Definition: CombatLogPackets.h:205
bool IsBreak
Definition: CombatLogPackets.h:220
void RemoveAurasDueToSpellByDispel(uint32 spellId, uint32 dispellerSpellId, ObjectGuid casterGUID, Unit *dispeller, uint8 chargesRemoved=1)
Definition: Unit.cpp:3619
uint32 urand(uint32 min, uint32 max)
Definition: Random.cpp:45
int32_t int32
Definition: Define.h:146
uint32_t uint32
Definition: Define.h:150
bool roll_chance_i(int chance)
Definition: Random.h:53
bool IsFriendlyTo(Unit const *unit) const
Definition: Unit.cpp:7170
uint32 GetDispelMask() const
Definition: SpellInfo.cpp:2202
bool Harmful
Definition: CombatLogPackets.h:204
uint32 SpellID
Definition: SpellPackets.h:891
ObjectGuid const & GetGUID() const
Definition: Object.h:105
ObjectGuid TargetGUID
Definition: CombatLogPackets.h:218
int32_t int32
Definition: g3dmath.h:167
virtual void SendMessageToSet(WorldPacket const *data, bool self)
Definition: Object.cpp:2144
Definition: SpellPackets.h:882
int32 SpellID
Definition: CombatLogPackets.h:203
ObjectGuid CasterGUID
Definition: CombatLogPackets.h:217
Optional< int32 > Needed
Definition: CombatLogPackets.h:206
SpellEffectHandleMode effectHandleMode
Definition: Spell.h:696

+ Here is the call graph for this function:

void Spell::EffectDispelMechanic ( SpellEffIndex  effIndex)
4693 {
4695  return;
4696 
4697  if (!unitTarget)
4698  return;
4699 
4700  uint32 mechanic = effectInfo->MiscValue;
4701  DispelList dispel_list;
4702  Unit::AuraMap const& auras = unitTarget->GetOwnedAuras();
4703  for (Unit::AuraMap::const_iterator itr = auras.begin(); itr != auras.end(); ++itr)
4704  {
4705  Aura* aura = itr->second;
4706  if (!aura->GetApplicationOfTarget(unitTarget->GetGUID()))
4707  continue;
4709  if ((aura->GetSpellInfo()->GetAllEffectsMechanicMask() & (1 << mechanic)))
4710  dispel_list.push_back(std::make_pair(aura->GetId(), aura->GetCasterGUID()));
4711  }
4712 
4713  while (!dispel_list.empty())
4714  {
4715  unitTarget->RemoveAura(dispel_list.front().first, dispel_list.front().second, 0, AURA_REMOVE_BY_ENEMY_SPELL);
4716  dispel_list.pop_front();
4717  }
4718 }
SpellInfo const * GetSpellInfo() const
Definition: SpellAuras.h:130
int32 MiscValue
Definition: SpellInfo.h:253
Unit *const m_caster
Definition: Spell.h:647
SpellEffectInfo const * effectInfo
Definition: Spell.h:697
AuraMap & GetOwnedAuras()
Definition: Unit.h:1779
void RemoveAura(AuraApplicationMap::iterator &i, AuraRemoveMode mode=AURA_REMOVE_BY_DEFAULT)
Definition: Unit.cpp:3442
const AuraApplication * GetApplicationOfTarget(ObjectGuid guid) const
Definition: SpellAuras.h:233
Definition: Spell.h:289
Unit * unitTarget
Definition: Spell.h:690
std::multimap< uint32, Aura * > AuraMap
Definition: Unit.h:1311
uint32_t uint32
Definition: Define.h:150
bool roll_chance_i(int chance)
Definition: Random.h:53
bool IsFriendlyTo(Unit const *unit) const
Definition: Unit.cpp:7170
int32 CalcDispelChance(Unit *auraTarget, bool offensive) const
Definition: SpellAuras.cpp:1124
ObjectGuid const & GetGUID() const
Definition: Object.h:105
Definition: Unit.h:453
std::list< std::pair< uint32, ObjectGuid > > DispelList
Definition: Spell.h:292
uint32 GetAllEffectsMechanicMask() const
Definition: SpellInfo.cpp:2136
Definition: SpellAuras.h:116
ObjectGuid GetCasterGUID() const
Definition: SpellAuras.h:135
uint32 GetId() const
Definition: SpellAuras.h:131
SpellEffectHandleMode effectHandleMode
Definition: Spell.h:696

+ Here is the call graph for this function:

void Spell::EffectDistract ( SpellEffIndex  effIndex)
2399 {
2401  return;
2402 
2403  // Check for possible target
2404  if (!unitTarget || unitTarget->IsInCombat())
2405  return;
2406 
2407  // target must be OK to do this
2409  return;
2410 
2413 
2414  if (unitTarget->GetTypeId() == TYPEID_UNIT)
2416 }
Definition: Unit.h:586
MotionMaster * GetMotionMaster()
Definition: Unit.h:2101
bool IsInCombat() const
Definition: Unit.h:1584
Definition: ObjectGuid.h:32
Definition: Unit.h:561
WorldLocation * destTarget
Definition: Spell.h:693
Definition: Unit.h:557
void ClearUnitState(uint32 f)
Definition: Unit.h:1396
TypeID GetTypeId() const
Definition: Object.h:113
Definition: Spell.h:289
Definition: Unit.h:553
Unit * unitTarget
Definition: Spell.h:690
int32 damage
Definition: Spell.h:694
float GetAngle(Position const *pos) const
Definition: Position.cpp:63
void SetFacingTo(float ori)
Definition: Unit.cpp:15777
Definition: Common.h:103
bool HasUnitState(const uint32 f) const
Definition: Unit.h:1395
void MoveDistract(uint32 time)
Definition: MotionMaster.cpp:574
SpellEffectHandleMode effectHandleMode
Definition: Spell.h:696

+ Here is the call graph for this function:

void Spell::EffectDualWield ( SpellEffIndex  effIndex)
2385 {
2387  return;
2388 
2389  unitTarget->SetCanDualWield(true);
2390 }
Definition: Spell.h:289
Unit * unitTarget
Definition: Spell.h:690
virtual void SetCanDualWield(bool value)
Definition: Unit.h:1360
SpellEffectHandleMode effectHandleMode
Definition: Spell.h:696

+ Here is the call graph for this function:

void Spell::EffectDuel ( SpellEffIndex  effIndex)
3851 {
3853  return;
3854 
3856  return;
3857 
3858  Player* caster = m_caster->ToPlayer();
3859  Player* target = unitTarget->ToPlayer();
3860 
3861  // caster or target already have requested duel
3862  if (caster->duel || target->duel || !target->GetSocial() || target->GetSocial()->HasIgnore(caster->GetGUID()))
3863  return;
3864 
3865  // Players can only fight a duel in zones with this flag
3866  AreaTableEntry const* casterAreaEntry = sAreaTableStore.LookupEntry(caster->GetAreaId());
3867  if (casterAreaEntry && !(casterAreaEntry->Flags[0] & AREA_FLAG_ALLOW_DUELS))
3868  {
3869  SendCastResult(SPELL_FAILED_NO_DUELING); // Dueling isn't allowed here
3870  return;
3871  }
3872 
3873  AreaTableEntry const* targetAreaEntry = sAreaTableStore.LookupEntry(target->GetAreaId());
3874  if (targetAreaEntry && !(targetAreaEntry->Flags[0] & AREA_FLAG_ALLOW_DUELS))
3875  {
3876  SendCastResult(SPELL_FAILED_NO_DUELING); // Dueling isn't allowed here
3877  return;
3878  }
3879 
3880  //CREATE DUEL FLAG OBJECT
3881  GameObject* pGameObj = new GameObject;
3882 
3883  uint32 gameobject_id = effectInfo->MiscValue;
3884 
3885  Map* map = m_caster->GetMap();
3886  if (!pGameObj->Create(map->GenerateLowGuid<HighGuid::GameObject>(), gameobject_id,
3887  map, 0,
3891  m_caster->GetOrientation(), 0.0f, 0.0f, 0.0f, 0.0f, 0, GO_STATE_READY))
3892  {
3893  delete pGameObj;
3894  return;
3895  }
3896 
3897  pGameObj->CopyPhaseFrom(m_caster);
3898 
3901  int32 duration = m_spellInfo->GetDuration();
3902  pGameObj->SetRespawnTime(duration > 0 ? duration/IN_MILLISECONDS : 0);
3903  pGameObj->SetSpellId(m_spellInfo->Id);
3904 
3905  ExecuteLogEffectSummonObject(effIndex, pGameObj);
3906 
3907  m_caster->AddGameObject(pGameObj);
3908  map->AddToMap(pGameObj);
3909  //END
3910 
3911  // Send request
3913  packet.ArbiterGUID = pGameObj->GetGUID();
3914  packet.RequestedByGUID = caster->GetGUID();
3915  packet.RequestedByWowAccount = caster->GetSession()->GetAccountGUID();
3916 
3917  WorldPacket const* worldPacket = packet.Write();
3918  caster->GetSession()->SendPacket(worldPacket);
3919  target->GetSession()->SendPacket(worldPacket);
3920 
3921  // create duel-info
3922  DuelInfo* duel = new DuelInfo;
3923  duel->initiator = caster;
3924  duel->opponent = target;
3925  duel->startTime = 0;
3926  duel->startTimer = 0;
3927  duel->isMounted = (GetSpellInfo()->Id == 62875); // Mounted Duel
3928  caster->duel = duel;
3929 
3930  DuelInfo* duel2 = new DuelInfo;
3931  duel2->initiator = caster;
3932  duel2->opponent = caster;
3933  duel2->startTime = 0;
3934  duel2->startTimer = 0;
3935  duel2->isMounted = (GetSpellInfo()->Id == 62875); // Mounted Duel
3936  target->duel = duel2;
3937 
3938  caster->SetGuidValue(PLAYER_DUEL_ARBITER, pGameObj->GetGUID());
3939  target->SetGuidValue(PLAYER_DUEL_ARBITER, pGameObj->GetGUID());
3940 
3941  sScriptMgr->OnPlayerDuelRequest(target, caster);
3942 }
int32 MiscValue
Definition: SpellInfo.h:253
Definition: DBCStructure.h:37
Definition: UpdateFields.h:188
SpellInfo const *const m_spellInfo
Definition: Spell.h:547
Unit *const m_caster
Definition: Spell.h:647
uint32 Id
Definition: SpellInfo.h:329
time_t startTime
Definition: Player.h:436
SpellEffectInfo const * effectInfo
Definition: Spell.h:697
Map * GetMap() const
Definition: Object.h:543
ObjectGuid RequestedByWowAccount
Definition: DuelPackets.h:94
uint32 getFaction() const
Definition: Unit.h:1466
bool isMounted
Definition: Player.h:438
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
uint32 Flags[2]
Definition: DBCStructure.h:43
void SetUInt32Value(uint16 index, uint32 value)
Definition: Object.cpp:996
void ExecuteLogEffectSummonObject(uint8 effIndex, WorldObject *obj)
Definition: Spell.cpp:4214
void CopyPhaseFrom(WorldObject *obj, bool update=false)
Definition: Object.cpp:2915
void SetRespawnTime(int32 respawn)
Definition: GameObject.h:945
time_t startTimer
Definition: Player.h:435
Definition: DuelPackets.h:85
Definition: SharedDefines.h:1365
Player * ToPlayer()
Definition: Object.h:191
uint8 getLevel() const
Definition: Unit.h:1408
DBCStorage< AreaTableEntry > sAreaTableStore(AreaTablefmt)
WorldPacket const * Write() override
Definition: DuelPackets.cpp:49
Player * initiator
Definition: Player.h:433
int32 GetDuration() const
Definition: SpellInfo.cpp:2490
TypeID GetTypeId() const
Definition: Object.h:113
float GetOrientation() const
Definition: Position.h:107
Definition: Spell.h:289
Unit * unitTarget
Definition: Spell.h:690
ObjectGuid RequestedByGUID
Definition: DuelPackets.h:93
float GetPositionY() const
Definition: Position.h:105
bool AddToMap(T *)
Definition: Map.cpp:566
Definition: UpdateFields.h:322
float GetPositionZ() const
Definition: Position.h:106
int32_t int32
Definition: Define.h:146
uint32_t uint32
Definition: Define.h:150
SpellInfo const * GetSpellInfo() const
Definition: Spell.h:614
Definition: GameObject.h:880
void AddGameObject(GameObject *gameObj)
Definition: Unit.cpp:4747
Definition: Map.h:259
Definition: UpdateFields.h:321
Definition: GameObject.h:823
ObjectGuid const & GetGUID() const
Definition: Object.h:105
Definition: ObjectGuid.h:33
Player * opponent
Definition: Player.h:434
Definition: Common.h:103
bool Create(ObjectGuid::LowType guidlow, uint32 name_id, Map *map, uint32 phaseMask, float x, float y, float z, float ang, float rotation0, float rotation1, float rotation2, float rotation3, uint32 animprogress, GOState go_state, uint32 artKit=0)
Definition: GameObject.cpp:173
void SetSpellId(uint32 id)
Definition: GameObject.h:928
Definition: DBCEnums.h:376
ObjectGuid ArbiterGUID
Definition: DuelPackets.h:92
#define sScriptMgr
Definition: ScriptMgr.h:837
Definition: Player.h:429
ObjectGuid::LowType GenerateLowGuid()
Definition: Map.h:561
float GetPositionX() const
Definition: Position.h:104
Definition: WorldPacket.h:26
SpellEffectHandleMode effectHandleMode
Definition: Spell.h:696

+ Here is the call graph for this function:

void Spell::EffectDummy ( SpellEffIndex  effIndex)
584 {
586  return;
587 
588  if (!unitTarget && !gameObjTarget && !itemTarget)
589  return;
590 
591  // selection by spell family
592  switch (m_spellInfo->SpellFamilyName)
593  {
594  case SPELLFAMILY_PALADIN:
595  switch (m_spellInfo->Id)
596  {
597  case 31789: // Righteous Defense (step 1)
598  {
599  // Clear targets for eff 1
600  for (std::vector<TargetInfo>::iterator ihit = m_UniqueTargetInfo.begin(); ihit != m_UniqueTargetInfo.end(); ++ihit)
601  ihit->effectMask &= ~(1<<1);
602 
603  // not empty (checked), copy
605 
606  // remove invalid attackers
607  for (Unit::AttackerSet::iterator aItr = attackers.begin(); aItr != attackers.end();)
608  if (!(*aItr)->IsValidAttackTarget(m_caster))
609  attackers.erase(aItr++);
610  else
611  ++aItr;
612 
613  // selected from list 3
614  uint32 maxTargets = std::min<uint32>(3, attackers.size());
615  for (uint32 i = 0; i < maxTargets; ++i)
616  {
618  AddUnitTarget(attacker, 1 << 1);
619  attackers.erase(attacker);
620  }
621 
622  // now let next effect cast spell at each target.
623  return;
624  }
625  }
626  break;
627  default:
628  break;
629  }
630 
631  // pet auras
632  if (PetAura const* petSpell = sSpellMgr->GetPetAura(m_spellInfo->Id, effIndex))
633  {
634  m_caster->AddPetAura(petSpell);
635  return;
636  }
637 
638  // normal DB scripted effect
639  TC_LOG_DEBUG("spells", "Spell ScriptStart spellid %u in EffectDummy(%u)", m_spellInfo->Id, effIndex);
641 
642  // Script based implementation. Must be used only for not good for implementation in core spell effects
643  // So called only for not proccessed cases
644  if (gameObjTarget)
645  sScriptMgr->OnDummyEffect(m_caster, m_spellInfo->Id, effIndex, gameObjTarget);
646  else if (unitTarget && unitTarget->GetTypeId() == TYPEID_UNIT)
647  sScriptMgr->OnDummyEffect(m_caster, m_spellInfo->Id, effIndex, unitTarget->ToCreature());
648  else if (itemTarget)
649  sScriptMgr->OnDummyEffect(m_caster, m_spellInfo->Id, effIndex, itemTarget);
650 }
Definition: SharedDefines.h:4633
GameObject * gameObjTarget
Definition: Spell.h:692
SpellInfo const *const m_spellInfo
Definition: Spell.h:547
Unit *const m_caster
Definition: Spell.h:647
ScriptMapMap sSpellScripts
Definition: ObjectMgr.cpp:51
uint32 Id
Definition: SpellInfo.h:329
void ScriptsStart(std::map< uint32, std::multimap< uint32, ScriptInfo > > const &scripts, uint32 id, Object *source, Object *target)
Put scripts in the execution queue.
Definition: MapScripts.cpp:33
Map * GetMap() const
Definition: Object.h:543
C::value_type const & SelectRandomContainerElement(C const &container)
Definition: Containers.h:68
Definition: ObjectGuid.h:32
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
void AddUnitTarget(Unit *target, uint32 effectMask, bool checkIfValid=true, bool implicit=true, Position const *losPosition=nullptr)
Definition: Spell.cpp:2042
TypeID GetTypeId() const
Definition: Object.h:113
std::vector< TargetInfo > m_UniqueTargetInfo
Definition: Spell.h:739
Definition: Spell.h:289
AttackerSet const & getAttackers() const
Definition: Unit.h:1377
Definition: SpellMgr.h:433
Unit * unitTarget
Definition: Spell.h:690
uint32 SpellFamilyName
Definition: SpellInfo.h:396
std::set< Unit * > AttackerSet
Definition: Unit.h:1308
void AddPetAura(PetAura const *petSpell)
Definition: Unit.cpp:13161
#define sSpellMgr
Definition: SpellMgr.h:756
uint32_t uint32
Definition: Define.h:150
Item * itemTarget
Definition: Spell.h:691
Creature * ToCreature()
Definition: Object.h:194
#define sScriptMgr
Definition: ScriptMgr.h:837
uint32_t uint32
Definition: g3dmath.h:168
Definition: Unit.h:1305
SpellEffectHandleMode effectHandleMode
Definition: Spell.h:696

+ Here is the call graph for this function:

void Spell::EffectDurabilityDamage ( SpellEffIndex  effIndex)
4817 {
4819  return;
4820 
4822  return;
4823 
4824  int32 slot = effectInfo->MiscValue;
4825 
4826  // -1 means all player equipped items and -2 all items
4827  if (slot < 0)
4828  {
4829  unitTarget->ToPlayer()->DurabilityPointsLossAll(damage, (slot < -1));
4830  ExecuteLogEffectDurabilityDamage(effIndex, unitTarget, -1, -1);
4831  return;
4832  }
4833 
4834  // invalid slot value
4835  if (slot >= INVENTORY_SLOT_BAG_END)
4836  return;
4837 
4838  if (Item* item = unitTarget->ToPlayer()->GetItemByPos(INVENTORY_SLOT_BAG_0, slot))
4839  {
4840  unitTarget->ToPlayer()->DurabilityPointsLoss(item, damage);
4841  ExecuteLogEffectDurabilityDamage(effIndex, unitTarget, item->GetEntry(), slot);
4842  }
4843 }
int32 MiscValue
Definition: SpellInfo.h:253
#define INVENTORY_SLOT_BAG_0
SpellEffectInfo const * effectInfo
Definition: Spell.h:697
Player * ToPlayer()
Definition: Object.h:191
TypeID GetTypeId() const
Definition: Object.h:113
Definition: Spell.h:289
Unit * unitTarget
Definition: Spell.h:690
int32 damage
Definition: Spell.h:694
Definition: Item.h:259
void ExecuteLogEffectDurabilityDamage(uint8 effIndex, Unit *victim, int32 itemId, int32 amount)
Definition: Spell.cpp:4180
int32_t int32
Definition: Define.h:146
Definition: ObjectGuid.h:33
uint32 GetEntry() const
Definition: Object.h:107
SpellEffectHandleMode effectHandleMode
Definition: Spell.h:696

+ Here is the call graph for this function:

void Spell::EffectDurabilityDamagePCT ( SpellEffIndex  effIndex)
4846 {
4848  return;
4849 
4851  return;
4852 
4853  int32 slot = effectInfo->MiscValue;
4854 
4855  // FIXME: some spells effects have value -1/-2
4856  // Possibly its mean -1 all player equipped items and -2 all items
4857  if (slot < 0)
4858  {
4859  unitTarget->ToPlayer()->DurabilityLossAll(float(damage) / 100.0f, (slot < -1));
4860  return;
4861  }
4862 
4863  // invalid slot value
4864  if (slot >= INVENTORY_SLOT_BAG_END)
4865  return;
4866 
4867  if (damage <= 0)
4868  return;
4869 
4870  if (Item* item = unitTarget->ToPlayer()->GetItemByPos(INVENTORY_SLOT_BAG_0, slot))
4871  unitTarget->ToPlayer()->DurabilityLoss(item, float(damage) / 100.0f);
4872 }
int32 MiscValue
Definition: SpellInfo.h:253
#define INVENTORY_SLOT_BAG_0
SpellEffectInfo const * effectInfo
Definition: Spell.h:697
Player * ToPlayer()
Definition: Object.h:191
TypeID GetTypeId() const
Definition: Object.h:113
Definition: Spell.h:289
Unit * unitTarget
Definition: Spell.h:690
int32 damage
Definition: Spell.h:694
Definition: Item.h:259
int32_t int32
Definition: Define.h:146
Definition: ObjectGuid.h:33
SpellEffectHandleMode effectHandleMode
Definition: Spell.h:696

+ Here is the call graph for this function:

void Spell::EffectEnableBattlePets ( SpellEffIndex  effIndex)
5931 {
5933  return;
5934 
5936  return;
5937 
5938  Player* plr = unitTarget->ToPlayer();
5940  plr->GetSession()->GetBattlePetMgr()->UnlockSlot(0);
5941 }
Player * ToPlayer()
Definition: Object.h:191
TypeID GetTypeId() const
Definition: Object.h:113
Definition: Spell.h:289
Unit * unitTarget
Definition: Spell.h:690
Definition: Player.h:541
Definition: ObjectGuid.h:33
Definition: UpdateFields.h:191
SpellEffectHandleMode effectHandleMode
Definition: Spell.h:696

+ Here is the call graph for this function:

void Spell::EffectEnchantHeldItem ( SpellEffIndex  effIndex)
4103 {
4105  return;
4106 
4107  // this is only item spell effect applied to main-hand weapon of target player (players in area)
4109  return;
4110 
4111  Player* item_owner = unitTarget->ToPlayer();
4112  Item* item = item_owner->GetItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_MAINHAND);
4113 
4114  if (!item)
4115  return;
4116 
4117  // must be equipped
4118  if (!item->IsEquipped())
4119  return;
4120 
4121  if (effectInfo->MiscValue)
4122  {
4123  uint32 enchant_id = effectInfo->MiscValue;
4124  int32 duration = m_spellInfo->GetDuration(); //Try duration index first ..
4125  if (!duration)
4126  duration = damage;//+1; //Base points after ..
4127  if (!duration)
4128  duration = 10 * IN_MILLISECONDS; //10 seconds for enchants which don't have listed duration
4129 
4130  if (m_spellInfo->Id == 14792) // Venomhide Poison
4131  duration = 5 * MINUTE * IN_MILLISECONDS;
4132 
4133  SpellItemEnchantmentEntry const* pEnchant = sSpellItemEnchantmentStore.LookupEntry(enchant_id);
4134  if (!pEnchant)
4135  return;
4136 
4137  // Always go to temp enchantment slot
4139 
4140  // Enchantment will not be applied if a different one already exists
4141  if (item->GetEnchantmentId(slot) && item->GetEnchantmentId(slot) != enchant_id)
4142  return;
4143 
4144  // Apply the temporary enchantment
4145  item->SetEnchantment(slot, enchant_id, duration, 0, m_caster->GetGUID());
4146  item_owner->ApplyEnchantment(item, slot, true);
4147  }
4148 }
int32 MiscValue
Definition: SpellInfo.h:253
SpellInfo const *const m_spellInfo
Definition: Spell.h:547
Unit *const m_caster
Definition: Spell.h:647
uint32 Id
Definition: SpellInfo.h:329
#define INVENTORY_SLOT_BAG_0
SpellEffectInfo const * effectInfo
Definition: Spell.h:697
EnchantmentSlot
Definition: Item.h:172
bool IsEquipped() const
Definition: Item.cpp:764
Definition: DBCStructure.h:1214
Definition: Common.h:97
Player * ToPlayer()
Definition: Object.h:191
int32 GetDuration() const
Definition: SpellInfo.cpp:2490
TypeID GetTypeId() const
Definition: Object.h:113
Definition: Item.h:175
Definition: Spell.h:289
Unit * unitTarget
Definition: Spell.h:690
int32 damage
Definition: Spell.h:694
Definition: Item.h:259
int32_t int32
Definition: Define.h:146
uint32_t uint32
Definition: Define.h:150
DBCStorage< SpellItemEnchantmentEntry > sSpellItemEnchantmentStore(SpellItemEnchantmentfmt)
void SetEnchantment(EnchantmentSlot slot, uint32 id, uint32 duration, uint32 charges, ObjectGuid caster=ObjectGuid::Empty)
Definition: Item.cpp:905
ObjectGuid const & GetGUID() const
Definition: Object.h:105
Definition: ObjectGuid.h:33
Definition: Common.h:103
SpellEffectHandleMode effectHandleMode
Definition: Spell.h:696
uint32 GetEnchantmentId(EnchantmentSlot slot) const
Definition: Item.h:351

+ Here is the call graph for this function:

void Spell::EffectEnchantItemPerm ( SpellEffIndex  effIndex)
2542 {
2544  return;
2545 
2546  if (!itemTarget)
2547  return;
2548 
2549  Player* player = m_caster->ToPlayer();
2550  if (!player)
2551  return;
2552 
2553  // Handle vellums
2554  if (itemTarget->IsVellum())
2555  {
2556  // destroy one vellum from stack
2557  uint32 count = 1;
2558  player->DestroyItemCount(itemTarget, count, true);
2559  unitTarget = player;
2560  // and add a scroll
2561  DoCreateItem(effIndex, effectInfo->ItemType);
2562  itemTarget = NULL;
2564  }
2565  else
2566  {
2567  // do not increase skill if vellum used
2569  player->UpdateCraftSkill(m_spellInfo->Id);
2570 
2571  uint32 enchant_id = effectInfo->MiscValue;
2572  if (!enchant_id)
2573  return;
2574 
2575  SpellItemEnchantmentEntry const* pEnchant = sSpellItemEnchantmentStore.LookupEntry(enchant_id);
2576  if (!pEnchant)
2577  return;
2578 
2579  // item can be in trade slot and have owner diff. from caster
2580  Player* item_owner = itemTarget->GetOwner();
2581  if (!item_owner)
2582  return;
2583 
2584  if (item_owner != player && player->GetSession()->HasPermission(rbac::RBAC_PERM_LOG_GM_TRADE))
2585  {
2586  sLog->outCommand(player->GetSession()->GetAccountId(), "GM %s (Account: %u) enchanting(perm): %s (Entry: %d) for player: %s (Account: %u)",
2587  player->GetName().c_str(), player->GetSession()->GetAccountId(),
2589  item_owner->GetName().c_str(), item_owner->GetSession()->GetAccountId());
2590  }
2591 
2592  // remove old enchanting before applying new if equipped
2593  item_owner->ApplyEnchantment(itemTarget, PERM_ENCHANTMENT_SLOT, false);
2594 
2596 
2597  // add new enchanting if equipped
2598  item_owner->ApplyEnchantment(itemTarget, PERM_ENCHANTMENT_SLOT, true);
2599 
2600  item_owner->RemoveTradeableItem(itemTarget);
2601  itemTarget->ClearSoulboundTradeable(item_owner);
2602  }
2603 }
int32 MiscValue
Definition: SpellInfo.h:253
bool IsVellum() const
Definition: Item.h:385
SpellInfo const *const m_spellInfo
Definition: Spell.h:547
Unit *const m_caster
Definition: Spell.h:647
uint32 Id
Definition: SpellInfo.h:329
SpellEffectInfo const * effectInfo
Definition: Spell.h:697
Definition: Item.h:174
SpellCastTargets m_targets
Definition: Spell.h:584
arena_t NULL
Definition: jemalloc_internal.h:624
#define sLog
Definition: Log.h:154
Item * m_CastItem
Definition: Spell.h:548
Definition: DBCStructure.h:1214
Player * ToPlayer()
Definition: Object.h:191
void SetItemTarget(Item *item)
Definition: Spell.cpp:299
void ClearSoulboundTradeable(Player *currentOwner)
Definition: Item.cpp:1309
void DoCreateItem(uint32 i, uint32 itemtype, std::vector< int32 > const &bonusListIDs=std::vector< int32 >())
Definition: SpellEffects.cpp:1403
Definition: Spell.h:289
Unit * unitTarget
Definition: Spell.h:690
Player * GetOwner() const
Definition: Item.cpp:552
uint32_t uint32
Definition: Define.h:150
DBCStorage< SpellItemEnchantmentEntry > sSpellItemEnchantmentStore(SpellItemEnchantmentfmt)
Item * itemTarget
Definition: Spell.h:691
uint32 ItemType
Definition: SpellInfo.h:262
void SetEnchantment(EnchantmentSlot slot, uint32 id, uint32 duration, uint32 charges, ObjectGuid caster=ObjectGuid::Empty)
Definition: Item.cpp:905
ObjectGuid const & GetGUID() const
Definition: Object.h:105
Definition: RBAC.h:63
uint32 GetFlags() const
Definition: ItemTemplate.h:656
uint32 GetEntry() const
Definition: Object.h:107
Definition: ItemTemplate.h:201
ItemTemplate const * GetTemplate() const
Definition: Item.cpp:547
SpellEffectHandleMode effectHandleMode
Definition: Spell.h:696
char const * GetDefaultLocaleName() const
Definition: ItemTemplate.cpp:33

+ Here is the call graph for this function:

void Spell::EffectEnchantItemPrismatic ( SpellEffIndex  effIndex)
2606 {
2608  return;
2609 
2610  if (!itemTarget)
2611  return;
2612 
2613  Player* player = m_caster->ToPlayer();
2614  if (!player)
2615  return;
2616 
2617  uint32 enchantId = effectInfo->MiscValue;
2618  if (!enchantId)
2619  return;
2620 
2621  SpellItemEnchantmentEntry const* enchant = sSpellItemEnchantmentStore.LookupEntry(enchantId);
2622  if (!enchant)
2623  return;
2624 
2625  // support only enchantings with add socket in this slot
2626  {
2627  bool add_socket = false;
2628  for (uint8 i = 0; i < MAX_ITEM_ENCHANTMENT_EFFECTS; ++i)
2629  {
2631  {
2632  add_socket = true;
2633  break;
2634  }
2635  }
2636  if (!add_socket)
2637  {
2638  TC_LOG_ERROR("spells", "Spell::EffectEnchantItemPrismatic: attempt apply enchant spell %u with SPELL_EFFECT_ENCHANT_ITEM_PRISMATIC (%u) but without ITEM_ENCHANTMENT_TYPE_PRISMATIC_SOCKET (%u), not suppoted yet.",
2640  return;
2641  }
2642  }
2643 
2644  // item can be in trade slot and have owner diff. from caster
2645  Player* item_owner = itemTarget->GetOwner();
2646  if (!item_owner)
2647  return;
2648 
2649  if (item_owner != player && player->GetSession()->HasPermission(rbac::RBAC_PERM_LOG_GM_TRADE))
2650  {
2651  sLog->outCommand(player->GetSession()->GetAccountId(), "GM %s (Account: %u) enchanting(perm): %s (Entry: %d) for player: %s (Account: %u)",
2652  player->GetName().c_str(), player->GetSession()->GetAccountId(),
2654  item_owner->GetName().c_str(), item_owner->GetSession()->GetAccountId());
2655  }
2656 
2657  // remove old enchanting before applying new if equipped
2658  item_owner->ApplyEnchantment(itemTarget, PRISMATIC_ENCHANTMENT_SLOT, false);
2659 
2661 
2662  // add new enchanting if equipped
2663  item_owner->ApplyEnchantment(itemTarget, PRISMATIC_ENCHANTMENT_SLOT, true);
2664 
2665  item_owner->RemoveTradeableItem(itemTarget);
2666  itemTarget->ClearSoulboundTradeable(item_owner);
2667 }
int32 MiscValue
Definition: SpellInfo.h:253
SpellInfo const *const m_spellInfo
Definition: Spell.h:547
Unit *const m_caster
Definition: Spell.h:647
uint32 Id
Definition: SpellInfo.h:329
SpellEffectInfo const * effectInfo
Definition: Spell.h:697
Definition: DBCEnums.h:517
Definition: SharedDefines.h:1166
#define MAX_ITEM_ENCHANTMENT_EFFECTS
Definition: DBCStructure.h:1212
#define sLog
Definition: Log.h:154
Definition: DBCStructure.h:1214
Player * ToPlayer()
Definition: Object.h:191
void ClearSoulboundTradeable(Player *currentOwner)
Definition: Item.cpp:1309
Definition: Spell.h:289
Player * GetOwner() const
Definition: Item.cpp:552
uint32_t uint32
Definition: Define.h:150
DBCStorage< SpellItemEnchantmentEntry > sSpellItemEnchantmentStore(SpellItemEnchantmentfmt)
Item * itemTarget
Definition: Spell.h:691
void SetEnchantment(EnchantmentSlot slot, uint32 id, uint32 duration, uint32 charges, ObjectGuid caster=ObjectGuid::Empty)
Definition: Item.cpp:905
ObjectGuid const & GetGUID() const
Definition: Object.h:105
Definition: RBAC.h:63
uint8_t uint8
Definition: Define.h:152
uint32 GetEntry() const
Definition: Object.h:107
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
Definition: Item.h:180
uint32 Effect[MAX_ITEM_ENCHANTMENT_EFFECTS]
Definition: DBCStructure.h:1218
ItemTemplate const * GetTemplate() const
Definition: Item.cpp:547
SpellEffectHandleMode effectHandleMode
Definition: Spell.h:696
char const * GetDefaultLocaleName() const
Definition: ItemTemplate.cpp:33

+ Here is the call graph for this function:

void Spell::EffectEnchantItemTmp ( SpellEffIndex  effIndex)
2670 {
2672  return;
2673 
2674  Player* player = m_caster->ToPlayer();
2675  if (!player)
2676  return;
2677 
2678  if (!itemTarget)
2679  return;
2680 
2681  uint32 enchant_id = effectInfo->MiscValue;
2682 
2683  if (!enchant_id)
2684  {
2685  TC_LOG_ERROR("spells", "Spell %u Effect %u (SPELL_EFFECT_ENCHANT_ITEM_TEMPORARY) have 0 as enchanting id", m_spellInfo->Id, effIndex);
2686  return;
2687  }
2688 
2689  SpellItemEnchantmentEntry const* pEnchant = sSpellItemEnchantmentStore.LookupEntry(enchant_id);
2690  if (!pEnchant)
2691  {
2692  TC_LOG_ERROR("spells", "Spell %u Effect %u (SPELL_EFFECT_ENCHANT_ITEM_TEMPORARY) have not existed enchanting id %u ", m_spellInfo->Id, effIndex, enchant_id);
2693  return;
2694  }
2695 
2696  // select enchantment duration
2697  uint32 duration;
2698 
2699  // rogue family enchantments exception by duration
2700  if (m_spellInfo->Id == 38615)
2701  duration = 1800; // 30 mins
2702  // other rogue family enchantments always 1 hour (some have spell damage=0, but some have wrong data in EffBasePoints)
2704  duration = 3600; // 1 hour
2705  // shaman family enchantments
2707  duration = 3600; // 30 mins
2708  // other cases with this SpellVisual already selected
2709  else if (m_spellInfo->GetSpellVisual(DIFFICULTY_NONE) == 215)
2710  duration = 1800; // 30 mins
2711  // some fishing pole bonuses except Glow Worm which lasts full hour
2712  else if (m_spellInfo->GetSpellVisual(DIFFICULTY_NONE) == 563 && m_spellInfo->Id != 64401)
2713  duration = 600; // 10 mins
2714  else if (m_spellInfo->Id == 29702)
2715  duration = 300; // 5 mins
2716  else if (m_spellInfo->Id == 37360)
2717  duration = 300; // 5 mins
2718  // default case
2719  else
2720  duration = 3600; // 1 hour
2721 
2722  // item can be in trade slot and have owner diff. from caster
2723  Player* item_owner = itemTarget->GetOwner();
2724  if (!item_owner)
2725  return;
2726 
2727  if (item_owner != player && player->GetSession()->HasPermission(rbac::RBAC_PERM_LOG_GM_TRADE))
2728  {
2729  sLog->outCommand(player->GetSession()->GetAccountId(), "GM %s (Account: %u) enchanting(temp): %s (Entry: %d) for player: %s (Account: %u)",
2730  player->GetName().c_str(), player->GetSession()->GetAccountId(),
2732  item_owner->GetName().c_str(), item_owner->GetSession()->GetAccountId());
2733  }
2734 
2735  // remove old enchanting before applying new if equipped
2736  item_owner->ApplyEnchantment(itemTarget, TEMP_ENCHANTMENT_SLOT, false);
2737 
2738  itemTarget->SetEnchantment(TEMP_ENCHANTMENT_SLOT, enchant_id, duration * 1000, 0, m_caster->GetGUID());
2739 
2740  // add new enchanting if equipped
2741  item_owner->ApplyEnchantment(itemTarget, TEMP_ENCHANTMENT_SLOT, true);
2742 }
int32 MiscValue
Definition: SpellInfo.h:253
Definition: DBCEnums.h:404
SpellInfo const *const m_spellInfo
Definition: Spell.h:547
Unit *const m_caster
Definition: Spell.h:647
uint32 Id
Definition: SpellInfo.h:329
SpellEffectInfo const * effectInfo
Definition: Spell.h:697
#define sLog
Definition: Log.h:154
Definition: DBCStructure.h:1214
Player * ToPlayer()
Definition: Object.h:191
uint32 GetSpellVisual(Difficulty difficulty, Player *forPlayer=nullptr) const
Definition: SpellInfo.cpp:2860
Definition: Item.h:175
Definition: Spell.h:289
uint32 SpellFamilyName
Definition: SpellInfo.h:396
Player * GetOwner() const
Definition: Item.cpp:552
Definition: SharedDefines.h:4634
Definition: SharedDefines.h:4631
uint32_t uint32
Definition: Define.h:150
DBCStorage< SpellItemEnchantmentEntry > sSpellItemEnchantmentStore(SpellItemEnchantmentfmt)
Item * itemTarget
Definition: Spell.h:691
void SetEnchantment(EnchantmentSlot slot, uint32 id, uint32 duration, uint32 charges, ObjectGuid caster=ObjectGuid::Empty)
Definition: Item.cpp:905
ObjectGuid const & GetGUID() const
Definition: Object.h:105
Definition: RBAC.h:63
uint32 GetEntry() const
Definition: Object.h:107
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
ItemTemplate const * GetTemplate() const
Definition: Item.cpp:547
SpellEffectHandleMode effectHandleMode
Definition: Spell.h:696
char const * GetDefaultLocaleName() const
Definition: ItemTemplate.cpp:33

+ Here is the call graph for this function:

void Spell::EffectEnergize ( SpellEffIndex  effIndex)
1628 {
1630  return;
1631 
1632  if (!unitTarget)
1633  return;
1634  if (!unitTarget->IsAlive())
1635  return;
1636 
1638  return;
1639 
1640  Powers power = Powers(effectInfo->MiscValue);
1641 
1643  return;
1644 
1645  if (unitTarget->GetMaxPower(power) == 0)
1646  return;
1647 
1648  // Some level depends spells
1649  int level_multiplier = 0;
1650  int level_diff = 0;
1651  switch (m_spellInfo->Id)
1652  {
1653  case 9512: // Restore Energy
1654  level_diff = m_caster->getLevel() - 40;
1655  level_multiplier = 2;
1656  break;
1657  case 24571: // Blood Fury
1658  level_diff = m_caster->getLevel() - 60;
1659  level_multiplier = 10;
1660  break;
1661  case 24532: // Burst of Energy
1662  level_diff = m_caster->getLevel() - 60;
1663  level_multiplier = 4;
1664  break;
1665  case 31930: // Judgements of the Wise
1666  case 63375: // Primal Wisdom
1667  case 68082: // Glyph of Seal of Command
1669  break;
1670  case 67490: // Runic Mana Injector (mana gain increased by 25% for engineers - 3.2.0 patch change)
1671  {
1672  if (Player* player = m_caster->ToPlayer())
1673  if (player->HasSkill(SKILL_ENGINEERING))
1674  AddPct(damage, 25);
1675  break;
1676  }
1677  default:
1678  break;
1679  }
1680 
1681  if (level_diff > 0)
1682  damage -= level_multiplier * level_diff;
1683 
1684  if (damage < 0 && power != POWER_ECLIPSE)
1685  return;
1686 
1688 
1689  // Mad Alchemist's Potion
1690  if (m_spellInfo->Id == 45051)
1691  {
1692  // find elixirs on target
1693  bool guardianFound = false;
1694  bool battleFound = false;
1696  for (Unit::AuraApplicationMap::iterator itr = Auras.begin(); itr != Auras.end(); ++itr)
1697  {
1698  uint32 spell_id = itr->second->GetBase()->GetId();
1699  if (!guardianFound)
1700  if (sSpellMgr->IsSpellMemberOfSpellGroup(spell_id, SPELL_GROUP_ELIXIR_GUARDIAN))
1701  guardianFound = true;
1702  if (!battleFound)
1703  if (sSpellMgr->IsSpellMemberOfSpellGroup(spell_id, SPELL_GROUP_ELIXIR_BATTLE))
1704  battleFound = true;
1705  if (battleFound && guardianFound)
1706  break;
1707  }
1708 
1709  // get all available elixirs by mask and spell level
1710  std::set<uint32> avalibleElixirs;
1711  if (!guardianFound)
1712  sSpellMgr->GetSetOfSpellsInSpellGroup(SPELL_GROUP_ELIXIR_GUARDIAN, avalibleElixirs);
1713  if (!battleFound)
1714  sSpellMgr->GetSetOfSpellsInSpellGroup(SPELL_GROUP_ELIXIR_BATTLE, avalibleElixirs);
1715  for (std::set<uint32>::iterator itr = avalibleElixirs.begin(); itr != avalibleElixirs.end();)
1716  {
1717  SpellInfo const* spellInfo = sSpellMgr->AssertSpellInfo(*itr);
1718  if (spellInfo->SpellLevel < m_spellInfo->SpellLevel || spellInfo->SpellLevel > unitTarget->getLevel())
1719  avalibleElixirs.erase(itr++);
1720  else if (sSpellMgr->IsSpellMemberOfSpellGroup(*itr, SPELL_GROUP_ELIXIR_SHATTRATH))
1721  avalibleElixirs.erase(itr++);
1722  else if (sSpellMgr->IsSpellMemberOfSpellGroup(*itr, SPELL_GROUP_ELIXIR_UNSTABLE))
1723  avalibleElixirs.erase(itr++);
1724  else
1725  ++itr;
1726  }
1727 
1728  if (!avalibleElixirs.empty())
1729  {
1730  // cast random elixir on target
1732  }
1733  }
1734 }
uint32 GetCreateMana() const
Definition: Unit.h:1897
int32 MiscValue
Definition: SpellInfo.h:253
SpellInfo const *const m_spellInfo
Definition: Spell.h:547
Unit *const m_caster
Definition: Spell.h:647
uint32 Id
Definition: SpellInfo.h:329
SpellEffectInfo const * effectInfo
Definition: Spell.h:697
int8_t int8
Definition: Define.h:148
C::value_type const & SelectRandomContainerElement(C const &container)
Definition: Containers.h:68
uint32 SpellLevel
Definition: SpellInfo.h:375
Definition: SpellInfo.h:326
Definition: SharedDefines.h:3942
Definition: SpellMgr.h:323
Item * m_CastItem
Definition: Spell.h:548
void EnergizeBySpell(Unit *victim, uint32 SpellID, int32 Damage, Powers powertype)
Definition: Unit.cpp:8202
Player * ToPlayer()
Definition: Object.h:191
uint8 getLevel() const
Definition: Unit.h:1408
Powers getPowerType() const
Definition: Unit.h:1444
TypeID GetTypeId() const
Definition: Object.h:113
Powers
Definition: SharedDefines.h:246
Definition: Spell.h:289
Unit * unitTarget
Definition: Spell.h:690
int32 damage
Definition: Spell.h:694
AuraApplicationMap & GetAppliedAuras()
Definition: Unit.h:1789
bool IsAlive() const
Definition: Unit.h:1692
bool HasAttribute(SpellAttr0 attribute) const
Definition: SpellInfo.h:462
#define sSpellMgr
Definition: SpellMgr.h:756
Definition: SpellMgr.h:320
uint32_t uint32
Definition: Define.h:150
T CalculatePct(T base, U pct)
Definition: Util.h:92
Definition: SharedDefines.h:624
Definition: ObjectGuid.h:33
T AddPct(T &base, U pct)
Definition: Util.h:98
int32_t int32
Definition: g3dmath.h:167
Definition: SpellMgr.h:321
Definition: SharedDefines.h:265
int32 GetMaxPower(Powers power) const
Definition: Unit.cpp:11598
std::multimap< uint32, AuraApplication * > AuraApplicationMap
Definition: Unit.h:1315
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: SpellMgr.h:322
Definition: SharedDefines.h:256
SpellEffectHandleMode effectHandleMode
Definition: Spell.h:696

+ Here is the call graph for this function:

void Spell::EffectEnergizePct ( SpellEffIndex  effIndex)
1737 {
1739  return;
1740 
1741  if (!unitTarget)
1742  return;
1743  if (!unitTarget->IsAlive())
1744  return;
1745 
1747  return;
1748 
1749  Powers power = Powers(effectInfo->MiscValue);
1750 
1752  return;
1753 
1754  uint32 maxPower = unitTarget->GetMaxPower(power);
1755  if (maxPower == 0)
1756  return;
1757 
1758  uint32 gain = CalculatePct(maxPower, damage);
1760 }
int32 MiscValue
Definition: SpellInfo.h:253
SpellInfo const *const m_spellInfo
Definition: Spell.h:547
Unit *const m_caster
Definition: Spell.h:647
uint32 Id
Definition: SpellInfo.h:329
SpellEffectInfo const * effectInfo
Definition: Spell.h:697
int8_t int8
Definition: Define.h:148
void EnergizeBySpell(Unit *victim, uint32 SpellID, int32 Damage, Powers powertype)
Definition: Unit.cpp:8202
Powers getPowerType() const
Definition: Unit.h:1444
TypeID GetTypeId() const
Definition: Object.h:113
Powers
Definition: SharedDefines.h:246
Definition: Spell.h:289
Unit * unitTarget
Definition: Spell.h:690
int32 damage
Definition: Spell.h:694
bool IsAlive() const
Definition: Unit.h:1692
bool HasAttribute(SpellAttr0 attribute) const
Definition: SpellInfo.h:462
uint32_t uint32
Definition: Define.h:150
T CalculatePct(T base, U pct)
Definition: Util.h:92
Definition: SharedDefines.h:624
Definition: ObjectGuid.h:33
Definition: SharedDefines.h:265
int32 GetMaxPower(Powers power) const
Definition: Unit.cpp:11598
SpellEffectHandleMode effectHandleMode
Definition: Spell.h:696

+ Here is the call graph for this function:

void Spell::EffectEnvironmentalDMG ( SpellEffIndex  effIndex)
384 {
386  return;
387 
388  if (!unitTarget || !unitTarget->IsAlive())
389  return;
390 
391  uint32 absorb = 0;
392  uint32 resist = 0;
393 
396  log.damage = damage - absorb - resist;
397  log.absorb = absorb;
398  log.resist = resist;
400  unitTarget->ToPlayer()->EnvironmentalDamage(DAMAGE_FIRE, damage);
401 
403 }
SpellInfo const *const m_spellInfo
Definition: Spell.h:547
Unit *const m_caster
Definition: Spell.h:647
uint32 Id
Definition: SpellInfo.h:329
TC_SHARED_API::google::protobuf::internal::ExtensionIdentifier< ::google::protobuf::FieldOptions,::google::protobuf::internal::EnumTypeTraits< ::bgs::protocol::LogOption,::bgs::protocol::LogOption_IsValid >, 14, false > log
Player * ToPlayer()
Definition: Object.h:191
TypeID GetTypeId() const
Definition: Object.h:113
Definition: Spell.h:289
Definition: Unit.h:1042
Unit * unitTarget
Definition: Spell.h:690
int32 damage
Definition: Spell.h:694
bool IsAlive() const
Definition: Unit.h:1692
uint32_t uint32
Definition: Define.h:150
void CalcAbsorbResist(Unit *victim, SpellSchoolMask schoolMask, DamageEffectType damagetype, uint32 const damage, uint32 *absorb, uint32 *resist, SpellInfo const *spellInfo=NULL)
Definition: Unit.cpp:1608
Definition: ObjectGuid.h:33
void SendSpellNonMeleeDamageLog(SpellNonMeleeDamage const *log)
Definition: Unit.cpp:4839
SpellSchoolMask GetSchoolMask() const
Definition: SpellInfo.cpp:2131
Definition: Unit.h:663
SpellEffectHandleMode effectHandleMode
Definition: Spell.h:696

+ Here is the call graph for this function:

void Spell::EffectFeedPet ( SpellEffIndex  effIndex)
Todo:
fix crash when a spell has two effects, both pointed at the same item target
4191 {
4193  return;
4194 
4195  Player* player = m_caster->ToPlayer();
4196  if (!player)
4197  return;
4198 
4199  Item* foodItem = itemTarget;
4200  if (!foodItem)
4201  return;
4202 
4203  Pet* pet = player->GetPet();
4204  if (!pet)
4205  return;
4206 
4207  if (!pet->IsAlive())
4208  return;
4209 
4210  int32 benefit = pet->GetCurrentFoodBenefitLevel(foodItem->GetTemplate()->GetBaseItemLevel());
4211  if (benefit <= 0)
4212  return;
4213 
4214  ExecuteLogEffectDestroyItem(effIndex, foodItem->GetEntry());
4215 
4216  uint32 count = 1;
4217  player->DestroyItemCount(foodItem, count, true);
4219 
4220  m_caster->CastCustomSpell(pet, effectInfo->TriggerSpell, &benefit, NULL, NULL, true);
4221 }
uint32 GetBaseItemLevel() const
Definition: ItemTemplate.h:667
Unit *const m_caster
Definition: Spell.h:647
SpellEffectInfo const * effectInfo
Definition: Spell.h:697
void ExecuteLogEffectDestroyItem(uint8 effIndex, uint32 entry)
Definition: Spell.cpp:4206
arena_t NULL
Definition: jemalloc_internal.h:624
Player * ToPlayer()
Definition: Object.h:191
uint32 TriggerSpell
Definition: SpellInfo.h:263
Definition: Spell.h:289
bool IsAlive() const
Definition: Unit.h:1692
Definition: Item.h:259
int32_t int32
Definition: Define.h:146
uint32_t uint32
Definition: Define.h:150
uint32 GetCurrentFoodBenefitLevel(uint32 itemlevel) const
Definition: Pet.cpp:1061
Item * itemTarget
Definition: Spell.h:691
uint32 GetEntry() const
Definition: Object.h:107
void CastCustomSpell(Unit *victim, uint32 spellId, int32 const *bp0, int32 const *bp1, int32 const *bp2, bool triggered, Item *castItem=NULL, AuraEffect const *triggeredByAura=NULL, ObjectGuid originalCaster=ObjectGuid::Empty)
Definition: Unit.cpp:920
Definition: Pet.h:46
ItemTemplate const * GetTemplate() const
Definition: Item.cpp:547
SpellEffectHandleMode effectHandleMode
Definition: Spell.h:696

+ Here is the call graph for this function:

void Spell::EffectForceCast ( SpellEffIndex  effIndex)
836 {
838  return;
839 
840  if (!unitTarget)
841  return;
842 
843  uint32 triggered_spell_id = effectInfo->TriggerSpell;
844 
845  // normal case
846  SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(triggered_spell_id);
847 
848  if (!spellInfo)
849  {
850  TC_LOG_ERROR("spells", "Spell::EffectForceCast of spell %u: triggering unknown spell id %i", m_spellInfo->Id, triggered_spell_id);
851  return;
852  }
853 
855  {
856  switch (m_spellInfo->Id)
857  {
858  case 52588: // Skeletal Gryphon Escape
859  case 48598: // Ride Flamebringer Cue
861  break;
862  case 52463: // Hide In Mine Car
863  case 52349: // Overtake
865  return;
866  }
867  }
868 
869  switch (spellInfo->Id)
870  {
871  case 72298: // Malleable Goo Summon
873  return;
874  }
875 
876  CustomSpellValues values;
877  // set basepoints for trigger with value effect
879  {
880  // maybe need to set value only when basepoints == 0?
884  }
885 
886  SpellCastTargets targets;
887  targets.SetUnitTarget(m_caster);
888 
889  unitTarget->CastSpell(targets, spellInfo, &values, TRIGGERED_FULL_MASK);
890 }
Definition: Unit.h:131
SpellInfo const *const m_spellInfo
Definition: Spell.h:547
Unit *const m_caster
Definition: Spell.h:647
uint32 Id
Definition: SpellInfo.h:329
Definition: Unit.h:167
SpellEffectInfo const * effectInfo
Definition: Spell.h:697
Definition: SpellInfo.h:326
arena_t NULL
Definition: jemalloc_internal.h:624
Will ignore most target checks (mostly DBC target checks)
Definition: Unit.h:479
void RemoveAura(AuraApplicationMap::iterator &i, AuraRemoveMode mode=AURA_REMOVE_BY_DEFAULT)
Definition: Unit.cpp:3442
uint32 TriggerSpell
Definition: SpellInfo.h:263
Definition: Spell.h:289
Unit * unitTarget
Definition: Spell.h:690
int32 damage
Definition: Spell.h:694
void SetUnitTarget(Unit *target)
Definition: Spell.cpp:230
#define sSpellMgr
Definition: SpellMgr.h:756
uint32_t uint32
Definition: Define.h:150
Definition: Spell.h:170
Definition: Unit.h:130
ObjectGuid m_originalCasterGUID
Definition: Spell.h:651
Definition: SharedDefines.h:1151
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
void AddSpellMod(SpellValueMod mod, int32 value)
Definition: Unit.h:176
uint32 Effect
Definition: SpellInfo.h:243
Definition: SharedDefines.h:1150
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
void CastCustomSpell(Unit *victim, uint32 spellId, int32 const *bp0, int32 const *bp1, int32 const *bp2, bool triggered, Item *castItem=NULL, AuraEffect const *triggeredByAura=NULL, ObjectGuid originalCaster=ObjectGuid::Empty)
Definition: Unit.cpp:920
Definition: Unit.h:129
SpellEffectHandleMode effectHandleMode
Definition: Spell.h:696

+ Here is the call graph for this function:

void Spell::EffectForceDeselect ( SpellEffIndex  effIndex)
4413 {
4415  return;
4416 
4418  clearTarget.Guid = m_caster->GetGUID();
4419  m_caster->SendMessageToSet(clearTarget.Write(), true);
4420 }
Unit *const m_caster
Definition: Spell.h:647
WorldPacket const * Write() override
Definition: SpellPackets.cpp:634
Definition: Spell.h:288
ObjectGuid const & GetGUID() const
Definition: Object.h:105
Definition: SpellPackets.h:610
virtual void SendMessageToSet(WorldPacket const *data, bool self)
Definition: Object.cpp:2144
ObjectGuid Guid
Definition: SpellPackets.h:617
SpellEffectHandleMode effectHandleMode
Definition: Spell.h:696

+ Here is the call graph for this function:

void Spell::EffectGameObjectDamage ( SpellEffIndex  effIndex)
5417 {
5419  return;
5420 
5421  if (!gameObjTarget)
5422  return;
5423 
5424  Unit* caster = m_originalCaster;
5425  if (!caster)
5426  return;
5427 
5428  FactionTemplateEntry const* casterFaction = caster->GetFactionTemplateEntry();
5430  // Do not allow to damage GO's of friendly factions (ie: Wintergrasp Walls/Ulduar Storm Beacons)
5431  if (!targetFaction || (casterFaction && targetFaction && !casterFaction->IsFriendlyTo(*targetFaction)))
5433 }
GameObject * gameObjTarget
Definition: Spell.h:692
uint32 GetUInt32Value(uint16 index) const
Definition: Object.cpp:300
Definition: Spell.h:289
Unit * m_originalCaster
Definition: Spell.h:653
int32 damage
Definition: Spell.h:694
bool IsFriendlyTo(FactionTemplateEntry const &entry) const
Definition: DBCStructure.h:446
SpellInfo const * GetSpellInfo() const
Definition: Spell.h:614
Definition: UpdateFields.h:321
Definition: DBCStructure.h:433
void ModifyHealth(int32 change, Unit *attackerOrHealer=NULL, uint32 spellId=0)
Definition: GameObject.cpp:1973
FactionTemplateEntry const * GetFactionTemplateEntry() const
Definition: Unit.cpp:7019
Definition: Unit.h:1305
DBCStorage< FactionTemplateEntry > sFactionTemplateStore(FactionTemplatefmt)
uint32 Id
Definition: Spell.h:567
SpellEffectHandleMode effectHandleMode
Definition: Spell.h:696

+ Here is the call graph for this function:

void Spell::EffectGameObjectRepair ( SpellEffIndex  effIndex)
5436 {
5438  return;
5439 
5440  if (!gameObjTarget)
5441  return;
5442 
5444 }
GameObject * gameObjTarget
Definition: Spell.h:692
Unit *const m_caster
Definition: Spell.h:647
Definition: Spell.h:289
int32 damage
Definition: Spell.h:694
void ModifyHealth(int32 change, Unit *attackerOrHealer=NULL, uint32 spellId=0)
Definition: GameObject.cpp:1973
SpellEffectHandleMode effectHandleMode
Definition: Spell.h:696

+ Here is the call graph for this function:

void Spell::EffectGameObjectSetDestructionState ( SpellEffIndex  effIndex)
5447 {
5449  return;
5450 
5452  return;
5453 
5456 }
int32 MiscValue
Definition: SpellInfo.h:253
GameObject * gameObjTarget
Definition: Spell.h:692
SpellEffectInfo const * effectInfo
Definition: Spell.h:697
Definition: Spell.h:289
Unit * m_originalCaster
Definition: Spell.h:653
GameObjectDestructibleState
Definition: SharedDefines.h:2142
void SetDestructibleState(GameObjectDestructibleState state, Player *eventInvoker=NULL, bool setHealth=false)
Definition: GameObject.cpp:2022
Player * GetCharmerOrOwnerPlayerOrPlayerItself() const
Definition: Unit.cpp:7560
SpellEffectHandleMode effectHandleMode
Definition: Spell.h:696

+ Here is the call graph for this function:

void Spell::EffectGiveCurrency ( SpellEffIndex  effIndex)
5633 {
5635  return;
5636 
5638  return;
5639 
5640  unitTarget->ToPlayer()->ModifyCurrency(effectInfo->MiscValue, damage);
5641 }
int32 MiscValue
Definition: SpellInfo.h:253
SpellEffectInfo const * effectInfo
Definition: Spell.h:697
Player * ToPlayer()
Definition: Object.h:191
TypeID GetTypeId() const
Definition: Object.h:113
Definition: Spell.h:289
Unit * unitTarget
Definition: Spell.h:690
int32 damage
Definition: Spell.h:694
Definition: ObjectGuid.h:33
SpellEffectHandleMode effectHandleMode
Definition: Spell.h:696

+ Here is the call graph for this function:

void Spell::EffectHeal ( SpellEffIndex  effIndex)
1238 {
1240  return;
1241 
1242  if (unitTarget && unitTarget->IsAlive() && damage >= 0)
1243  {
1244  // Try to get original caster
1246 
1247  // Skip if m_originalCaster not available
1248  if (!caster)
1249  return;
1250 
1251  int32 addhealth = damage;
1252 
1253  // Vessel of the Naaru (Vial of the Sunwell trinket)
1254  if (m_spellInfo->Id == 45064)
1255  {
1256  // Amount of heal - depends from stacked Holy Energy
1257  int damageAmount = 0;
1258  if (AuraEffect const* aurEff = m_caster->GetAuraEffect(45062, 0))
1259  {
1260  damageAmount+= aurEff->GetAmount();
1262  }
1263 
1264  addhealth += damageAmount;
1265  }
1266  // Runic Healing Injector (heal increased by 25% for engineers - 3.2.0 patch change)
1267  else if (m_spellInfo->Id == 67489)
1268  {
1269  if (Player* player = m_caster->ToPlayer())
1270  if (player->HasSkill(SKILL_ENGINEERING))
1271  AddPct(addhealth, 25);
1272  }
1273  // Swiftmend - consumes Regrowth or Rejuvenation
1275  {
1277  // find most short by duration
1278  AuraEffect* targetAura = NULL;
1279  for (Unit::AuraEffectList::const_iterator i = RejorRegr.begin(); i != RejorRegr.end(); ++i)
1280  {
1281  if ((*i)->GetSpellInfo()->SpellFamilyName == SPELLFAMILY_DRUID
1282  && (*i)->GetSpellInfo()->SpellFamilyFlags[0] & 0x50)
1283  {
1284  if (!targetAura || (*i)->GetBase()->GetDuration() < targetAura->GetBase()->GetDuration())
1285  targetAura = *i;
1286  }
1287  }
1288 
1289  if (!targetAura)
1290  {
1291  TC_LOG_ERROR("spells", "Target (%s) has aurastate AURA_STATE_SWIFTMEND but no matching aura.", unitTarget->GetGUID().ToString().c_str());
1292  return;
1293  }
1294 
1295  int32 tickheal = targetAura->GetAmount();
1296  if (Unit* auraCaster = targetAura->GetCaster())
1297  tickheal = auraCaster->SpellHealingBonusDone(unitTarget, targetAura->GetSpellInfo(), tickheal, DOT, effectInfo);
1298  //int32 tickheal = targetAura->GetSpellInfo()->EffectBasePoints[idx] + 1;
1299  //It is said that talent bonus should not be included
1300 
1301  int32 tickcount = 0;
1302  // Rejuvenation
1303  if (targetAura->GetSpellInfo()->SpellFamilyFlags[0] & 0x10)
1304  tickcount = 4;
1305  // Regrowth
1306  else // if (targetAura->GetSpellInfo()->SpellFamilyFlags[0] & 0x40)
1307  tickcount = 6;
1308 
1309  addhealth += tickheal * tickcount;
1310 
1311  // Glyph of Swiftmend
1312  if (!caster->HasAura(54824))
1313  unitTarget->RemoveAura(targetAura->GetId(), targetAura->GetCasterGUID());
1314 
1315  //addhealth += tickheal * tickcount;
1316  //addhealth = caster->SpellHealingBonus(m_spellInfo, addhealth, HEAL, unitTarget);
1317  }
1318  // Death Pact - return pct of max health to caster
1321  else
1322  {
1323  addhealth = caster->SpellHealingBonusDone(unitTarget, m_spellInfo, addhealth, HEAL, effectInfo);
1324  uint32 bonus = caster->SpellHealingBonusDone(unitTarget, m_spellInfo, addhealth, HEAL, effectInfo);
1325  damage = bonus + uint32(bonus * variance);
1326  }
1327 
1328  addhealth = unitTarget->SpellHealingBonusTaken(caster, m_spellInfo, addhealth, HEAL, effectInfo);
1329 
1330  // Remove Grievious bite if fully healed
1331  if (unitTarget->HasAura(48920) && (unitTarget->GetHealth() + addhealth >= unitTarget->GetMaxHealth()))
1332  unitTarget->RemoveAura(48920);
1333 
1334  m_damage -= addhealth;
1335  }
1336 }
Definition: SpellAuraDefines.h:68
Definition: SpellAuraEffects.h:30
bool HasAura(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, ObjectGuid itemCasterGUID=ObjectGuid::Empty, uint32 reqEffMask=0) const
Definition: Unit.cpp:4240
SpellInfo const *const m_spellInfo
Definition: Spell.h:547
Unit *const m_caster
Definition: Spell.h:647
uint32 Id
Definition: SpellInfo.h:329
SpellInfo const * GetSpellInfo() const
Definition: SpellAuraEffects.h:46
ObjectGuid GetCasterGUID() const
Definition: SpellAuraEffects.h:40
SpellEffectInfo const * effectInfo
Definition: Spell.h:697
uint32 GetMaxHealth() const
Definition: Unit.h:1427
uint32 TargetAuraState
Definition: SpellInfo.h:355
uint32 GetId() const
Definition: SpellAuraEffects.h:47
Definition: SharedDefines.h:3942
bool HasAuraState(AuraStateType flag, SpellInfo const *spellProto=NULL, Unit const *Caster=NULL) const
Definition: Unit.cpp:7491
flag128 SpellFamilyFlags
Definition: SpellInfo.h:397
std::list< AuraEffect * > AuraEffectList
Definition: Unit.h:1322
Definition: SharedDefines.h:4638
arena_t NULL
Definition: jemalloc_internal.h:624
Definition: Unit.h:664
Aura * GetBase() const
Definition: SpellAuraEffects.h:41
void RemoveAura(AuraApplicationMap::iterator &i, AuraRemoveMode mode=AURA_REMOVE_BY_DEFAULT)
Definition: Unit.cpp:3442
Unit * GetCaster() const
Definition: SpellAuraEffects.h:39
Definition: SharedDefines.h:1773
Player * ToPlayer()
Definition: Object.h:191
Unit * unitTarget
Definition: Spell.h:690
Unit * m_originalCaster
Definition: Spell.h:653
int32 damage
Definition: Spell.h:694
uint32 SpellFamilyName
Definition: SpellInfo.h:396
bool IsAlive() const
Definition: Unit.h:1692
uint32 SpellHealingBonusTaken(Unit *caster, SpellInfo const *spellProto, uint32 healamount, DamageEffectType damagetype, SpellEffectInfo const *effect, uint32 stack=1) const
Definition: Unit.cpp:9073
Definition: Spell.h:287
int32 GetAmount() const
Definition: SpellAuraEffects.h:55
int32_t int32
Definition: Define.h:146
AuraEffectList const & GetAuraEffectsByType(AuraType type) const
Definition: Unit.h:1832
uint32_t uint32
Definition: Define.h:150
int32 m_damage
Definition: Spell.h:709
Definition: SharedDefines.h:4630
float variance
Definition: Spell.h:695
int32 GetDuration() const
Definition: SpellAuras.h:163
ObjectGuid m_originalCasterGUID
Definition: Spell.h:651
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
T AddPct(T &base, U pct)
Definition: Util.h:98
int32_t int32
Definition: g3dmath.h:167
AuraEffect * GetAuraEffect(uint32 spellId, uint8 effIndex, ObjectGuid casterGUID=ObjectGuid::Empty) const
Definition: Unit.cpp:4071
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
uint32_t uint32
Definition: g3dmath.h:168
uint32 SpellHealingBonusDone(Unit *victim, SpellInfo const *spellProto, uint32 healamount, DamageEffectType damagetype, SpellEffectInfo const *effect, uint32 stack=1) const
Definition: Unit.cpp:8886
uint32 GetHealth() const
Definition: Unit.h:1426
Definition: Unit.h:1305
Definition: Unit.h:665
std::string ToString() const
Definition: ObjectGuid.cpp:99
bool IsEmpty() const
Definition: ObjectGuid.h:242
SpellEffectHandleMode effectHandleMode
Definition: Spell.h:696
uint32 CountPctFromMaxHealth(int32 pct) const
Definition: Unit.h:1435

+ Here is the call graph for this function:

void Spell::EffectHealBattlePetPct ( SpellEffIndex  effIndex)
5919 {
5921  return;
5922 
5924  return;
5925 
5926  if (BattlePetMgr* battlePetMgr = unitTarget->ToPlayer()->GetSession()->GetBattlePetMgr())
5927  battlePetMgr->HealBattlePetsPct(GetEffect(effIndex)->BasePoints);
5928 }
SpellEffectInfo const * GetEffect(uint32 index) const
Definition: Spell.h:624
Player * ToPlayer()
Definition: Object.h:191
TypeID GetTypeId() const
Definition: Object.h:113
Definition: Spell.h:289
Unit * unitTarget
Definition: Spell.h:690
Definition: BattlePetMgr.h:83
Definition: ObjectGuid.h:33
SpellEffectHandleMode effectHandleMode
Definition: Spell.h:696

+ Here is the call graph for this function:

void Spell::EffectHealMaxHealth ( SpellEffIndex  effIndex)
3159 {
3161  return;
3162 
3163  if (!unitTarget || !unitTarget->IsAlive())
3164  return;
3165 
3166  int32 addhealth = 0;
3167 
3168  // damage == 0 - heal for caster max health
3169  if (damage == 0)
3170  addhealth = m_caster->GetMaxHealth();
3171  else
3172  addhealth = unitTarget->GetMaxHealth() - unitTarget->GetHealth();
3173 
3174  m_healing += addhealth;
3175 }
Unit *const m_caster
Definition: Spell.h:647
uint32 GetMaxHealth() const
Definition: Unit.h:1427
Definition: Spell.h:289
Unit * unitTarget
Definition: Spell.h:690
int32 damage
Definition: Spell.h:694
bool IsAlive() const
Definition: Unit.h:1692
int32_t int32
Definition: Define.h:146
uint32 GetHealth() const
Definition: Unit.h:1426
int32 m_healing
Definition: Spell.h:710
SpellEffectHandleMode effectHandleMode
Definition: Spell.h:696

+ Here is the call graph for this function:

void Spell::EffectHealMechanical ( SpellEffIndex  effIndex)
1357 {
1359  return;
1360 
1361  if (!unitTarget || !unitTarget->IsAlive() || damage < 0)
1362  return;
1363 
1364  // Skip if m_originalCaster not available
1365  if (!m_originalCaster)
1366  return;
1367 
1369  heal += uint32(heal * variance);
1370 
1372 }
SpellInfo const *const m_spellInfo
Definition: Spell.h:547
SpellEffectInfo const * effectInfo
Definition: Spell.h:697
Definition: Spell.h:289
Unit * unitTarget
Definition: Spell.h:690
Unit * m_originalCaster
Definition: Spell.h:653
int32 damage
Definition: Spell.h:694
bool IsAlive() const
Definition: Unit.h:1692
uint32 SpellHealingBonusTaken(Unit *caster, SpellInfo const *spellProto, uint32 healamount, DamageEffectType damagetype, SpellEffectInfo const *effect, uint32 stack=1) const
Definition: Unit.cpp:9073
uint32_t uint32
Definition: Define.h:150
float variance
Definition: Spell.h:695
uint32_t uint32
Definition: g3dmath.h:168
uint32 SpellHealingBonusDone(Unit *victim, SpellInfo const *spellProto, uint32 healamount, DamageEffectType damagetype, SpellEffectInfo const *effect, uint32 stack=1) const
Definition: Unit.cpp:8886
int32 m_healing
Definition: Spell.h:710
Definition: Unit.h:665
SpellEffectHandleMode effectHandleMode
Definition: Spell.h:696

+ Here is the call graph for this function:

void Spell::EffectHealPct ( SpellEffIndex  effIndex)
1339 {
1341  return;
1342 
1343  if (!unitTarget || !unitTarget->IsAlive() || damage < 0)
1344  return;
1345 
1346  // Skip if m_originalCaster not available
1347  if (!m_originalCaster)
1348  return;
1349 
1352 
1353  m_healing += heal;
1354 }
SpellInfo const *const m_spellInfo
Definition: Spell.h:547
SpellEffectInfo const * effectInfo
Definition: Spell.h:697
Definition: Spell.h:289
Unit * unitTarget
Definition: Spell.h:690
Unit * m_originalCaster
Definition: Spell.h:653
int32 damage
Definition: Spell.h:694
bool IsAlive() const
Definition: Unit.h:1692
uint32 SpellHealingBonusTaken(Unit *caster, SpellInfo const *spellProto, uint32 healamount, DamageEffectType damagetype, SpellEffectInfo const *effect, uint32 stack=1) const
Definition: Unit.cpp:9073
uint32_t uint32
Definition: Define.h:150
uint32 SpellHealingBonusDone(Unit *victim, SpellInfo const *spellProto, uint32 healamount, DamageEffectType damagetype, SpellEffectInfo const *effect, uint32 stack=1) const
Definition: Unit.cpp:8886
int32 m_healing
Definition: Spell.h:710
Definition: Unit.h:665
SpellEffectHandleMode effectHandleMode
Definition: Spell.h:696
uint32 CountPctFromMaxHealth(int32 pct) const
Definition: Unit.h:1435

+ Here is the call graph for this function:

void Spell::EffectHealthLeech ( SpellEffIndex  effIndex)
1375 {
1377  return;
1378 
1379  if (!unitTarget || !unitTarget->IsAlive() || damage < 0)
1380  return;
1381 
1383  damage = bonus + uint32(bonus * variance);
1385 
1386  TC_LOG_DEBUG("spells", "HealthLeech :%i", damage);
1387 
1388  float healMultiplier = effectInfo->CalcValueMultiplier(m_originalCaster, this);
1389 
1390  m_damage += damage;
1391  // get max possible damage, don't count overkill for heal
1392  uint32 healthGain = uint32(-unitTarget->GetHealthGain(-damage) * healMultiplier);
1393 
1394  if (m_caster->IsAlive())
1395  {
1396  healthGain = m_caster->SpellHealingBonusDone(m_caster, m_spellInfo, healthGain, HEAL, effectInfo);
1397  healthGain = m_caster->SpellHealingBonusTaken(m_caster, m_spellInfo, healthGain, HEAL, effectInfo);
1398 
1400  }
1401 }
SpellInfo const *const m_spellInfo
Definition: Spell.h:547
Unit *const m_caster
Definition: Spell.h:647
SpellEffectInfo const * effectInfo
Definition: Spell.h:697
int32 HealBySpell(Unit *victim, SpellInfo const *spellInfo, uint32 addHealth, bool critical=false)
Definition: Unit.cpp:8179
float CalcValueMultiplier(Unit *caster, Spell *spell=NULL) const
Definition: SpellInfo.cpp:629
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
uint32 SpellDamageBonusDone(Unit *victim, SpellInfo const *spellProto, uint32 pdamage, DamageEffectType damagetype, SpellEffectInfo const *effect, uint32 stack=1) const
Definition: Unit.cpp:8212
Definition: Spell.h:289
Unit * unitTarget
Definition: Spell.h:690
Unit * m_originalCaster
Definition: Spell.h:653
int32 damage
Definition: Spell.h:694
bool IsAlive() const
Definition: Unit.h:1692
uint32 SpellHealingBonusTaken(Unit *caster, SpellInfo const *spellProto, uint32 healamount, DamageEffectType damagetype, SpellEffectInfo const *effect, uint32 stack=1) const
Definition: Unit.cpp:9073
int32 GetHealthGain(int32 dVal)
Definition: Unit.cpp:10259
uint32 SpellDamageBonusTaken(Unit *caster, SpellInfo const *spellProto, uint32 pdamage, DamageEffectType damagetype, SpellEffectInfo const *effect, uint32 stack=1) const
Definition: Unit.cpp:8493
uint32_t uint32
Definition: Define.h:150
int32 m_damage
Definition: Spell.h:709
float variance
Definition: Spell.h:695
uint32_t uint32
Definition: g3dmath.h:168
Definition: Unit.h:663
uint32 SpellHealingBonusDone(Unit *victim, SpellInfo const *spellProto, uint32 healamount, DamageEffectType damagetype, SpellEffectInfo const *effect, uint32 stack=1) const
Definition: Unit.cpp:8886
Definition: Unit.h:665
SpellEffectHandleMode effectHandleMode
Definition: Spell.h:696

+ Here is the call graph for this function:

void Spell::EffectInebriate ( SpellEffIndex  effIndex)
4168 {
4170  return;
4171 
4173  return;
4174 
4175  Player* player = unitTarget->ToPlayer();
4176  uint8 currentDrunk = player->GetDrunkValue();
4177  uint8 drunkMod = damage;
4178  if (currentDrunk + drunkMod > 100)
4179  {
4180  currentDrunk = 100;
4181  if (rand_chance() < 25.0f)
4182  player->CastSpell(player, 67468, false); // Drunken Vomit
4183  }
4184  else
4185  currentDrunk += drunkMod;
4186 
4187  player->SetDrunkValue(currentDrunk, m_CastItem ? m_CastItem->GetEntry() : 0);
4188 }
Item * m_CastItem
Definition: Spell.h:548
double rand_chance()
Definition: Random.cpp:74
Player * ToPlayer()
Definition: Object.h:191
TypeID GetTypeId() const
Definition: Object.h:113
Definition: Spell.h:289
Unit * unitTarget
Definition: Spell.h:690
int32 damage
Definition: Spell.h:694
Definition: ObjectGuid.h:33
uint8_t uint8
Definition: Define.h:152
uint32 GetEntry() const
Definition: Object.h:107
SpellEffectHandleMode effectHandleMode
Definition: Spell.h:696

+ Here is the call graph for this function:

void Spell::EffectInstaKill ( SpellEffIndex  effIndex)
359 {
361  return;
362 
363  if (!unitTarget || !unitTarget->IsAlive())
364  return;
365 
367  if (unitTarget->ToPlayer()->GetCommandStatus(CHEAT_GOD))
368  return;
369 
370  if (m_caster == unitTarget) // prevent interrupt message
371  finish();
372 
374  data.Target = unitTarget->GetGUID();
375  data.Caster = m_caster->GetGUID();
376  data.SpellID = m_spellInfo->Id;
377 
378  m_caster->SendMessageToSet(data.Write(), true);
379 
381 }
SpellInfo const *const m_spellInfo
Definition: Spell.h:547
Unit *const m_caster
Definition: Spell.h:647
uint32 Id
Definition: SpellInfo.h:329
ObjectGuid Target
Definition: CombatLogPackets.h:245
arena_t NULL
Definition: jemalloc_internal.h:624
Player * ToPlayer()
Definition: Object.h:191
TypeID GetTypeId() const
Definition: Object.h:113
Definition: Spell.h:289
Definition: Unit.h:666
Unit * unitTarget
Definition: Spell.h:690
void finish(bool ok=true)
Definition: Spell.cpp:3620
Definition: CombatLogPackets.h:238
Definition: SharedDefines.h:288
bool IsAlive() const
Definition: Unit.h:1692
ObjectGuid const & GetGUID() const
Definition: Object.h:105
Definition: ObjectGuid.h:33
int32 SpellID
Definition: CombatLogPackets.h:247
ObjectGuid Caster
Definition: CombatLogPackets.h:246
virtual void SendMessageToSet(WorldPacket const *data, bool self)
Definition: Object.cpp:2144
WorldPacket const * Write() override
Definition: CombatLogPackets.cpp:197
uint32 GetHealth() const
Definition: Unit.h:1426
uint32 DealDamage(Unit *victim, uint32 damage, CleanDamage const *cleanDamage=NULL, DamageEffectType damagetype=DIRECT_DAMAGE, SpellSchoolMask damageSchoolMask=SPELL_SCHOOL_MASK_NORMAL, SpellInfo const *spellProto=NULL, bool durabilityLoss=true)
Definition: Unit.cpp:613
SpellEffectHandleMode effectHandleMode
Definition: Spell.h:696

+ Here is the call graph for this function:

void Spell::EffectInterruptCast ( SpellEffIndex  effIndex)
Todo:
not all spells that used this effect apply cooldown at school spells
3178 {
3180  return;
3181 
3182  if (!unitTarget || !unitTarget->IsAlive())
3183  return;
3184 
3186  // also exist case: apply cooldown to interrupted cast only and to all spells
3187  // there is no CURRENT_AUTOREPEAT_SPELL spells that can be interrupted
3189  {
3191  {
3192  SpellInfo const* curSpellInfo = spell->m_spellInfo;
3193  // check if we can interrupt spell
3194  if ((spell->getState() == SPELL_STATE_CASTING
3195  || (spell->getState() == SPELL_STATE_PREPARING && spell->GetCastTime() > 0.0f))
3199  {
3200  if (m_originalCaster)
3201  {
3202  int32 duration = m_spellInfo->GetDuration();
3203  unitTarget->GetSpellHistory()->LockSpellSchool(curSpellInfo->GetSchoolMask(), unitTarget->ModSpellDuration(m_spellInfo, unitTarget, duration, false, 1 << effIndex));
3204  }
3205  ExecuteLogEffectInterruptCast(effIndex, unitTarget, curSpellInfo->Id);
3207  }
3208  }
3209  }
3210 }
SpellInfo const *const m_spellInfo
Definition: Spell.h:547
Definition: Unit.h:1109
uint32 Id
Definition: SpellInfo.h:329
void ExecuteLogEffectInterruptCast(uint8 effIndex, Unit *victim, uint32 spellId)
Definition: Spell.cpp:4169
Definition: SharedDefines.h:2058
CurrentSpellTypes
Definition: Unit.h:1106
Definition: SpellInfo.h:326
Definition: Unit.h:1110
int32 ModSpellDuration(SpellInfo const *spellProto, Unit const *target, int32 duration, bool positive, uint32 effectMask)
Definition: Unit.cpp:10956
Definition: Unit.h:1111
int32 GetDuration() const
Definition: SpellInfo.cpp:2490
void InterruptSpell(CurrentSpellTypes spellType, bool withDelayed=true, bool withInstant=true)
Definition: Unit.cpp:2849
SpellHistory * GetSpellHistory()
Definition: Unit.h:1926
Definition: Spell.h:289
Unit * unitTarget
Definition: Spell.h:690
Unit * m_originalCaster
Definition: Spell.h:653
bool IsAlive() const
Definition: Unit.h:1692
Spell * GetCurrentSpell(CurrentSpellTypes spellType) const
Definition: Unit.h:1920
int32_t int32
Definition: Define.h:146
uint32_t uint32
Definition: Define.h:150
Definition: Spell.h:278
uint32 PreventionType
Definition: SpellInfo.h:399
void LockSpellSchool(SpellSchoolMask schoolMask, uint32 lockoutTime)
Definition: SpellHistory.cpp:635
Definition: Spell.h:277
Definition: SharedDefines.h:2060
uint32 ChannelInterruptFlags
Definition: SpellInfo.h:369
SpellSchoolMask GetSchoolMask() const
Definition: SpellInfo.cpp:2131
Definition: Unit.h:40
uint32 InterruptFlags
Definition: SpellInfo.h:367
#define CURRENT_FIRST_NON_MELEE_SPELL
Definition: Unit.h:1114
SpellEffectHandleMode effectHandleMode
Definition: Spell.h:696
Definition: Spell.h:294

+ Here is the call graph for this function:

void Spell::EffectJump ( SpellEffIndex  effIndex)
912 {
914  return;
915 
916  if (m_caster->IsInFlight())
917  return;
918 
919  if (!unitTarget)
920  return;
921 
922  float x, y, z;
924 
925  float speedXY, speedZ;
926  CalculateJumpSpeeds(effectInfo, m_caster->GetExactDist2d(x, y), speedXY, speedZ);
927  m_caster->GetMotionMaster()->MoveJump(x, y, z, 0.0f, speedXY, speedZ, EVENT_JUMP, false, effectInfo->TriggerSpell, unitTarget->GetGUID());
928 }
Unit *const m_caster
Definition: Spell.h:647
SpellEffectInfo const * effectInfo
Definition: Spell.h:697
MotionMaster * GetMotionMaster()
Definition: Unit.h:2101
bool IsInFlight() const
Definition: Unit.h:1582
void CalculateJumpSpeeds(SpellEffectInfo const *effInfo, float dist, float &speedxy, float &speedz)
Definition: SpellEffects.cpp:946
uint32 TriggerSpell
Definition: SpellInfo.h:263
float GetExactDist2d(const float x, const float y) const
Definition: Position.h:137
Unit * unitTarget
Definition: Spell.h:690
void MoveJump(Position const &pos, float speedXY, float speedZ, uint32 id=EVENT_JUMP, bool hasOrientation=false, uint32 arrivalSpellId=0, ObjectGuid const &arrivalSpellTargetGuid=ObjectGuid::Empty)
Definition: MotionMaster.h:184
Definition: Spell.h:287
G3D::int16 z
Definition: Vector3int16.h:46
G3D::int16 y
Definition: Vector2int16.h:38
ObjectGuid const & GetGUID() const
Definition: Object.h:105
Definition: SharedDefines.h:4414
#define CONTACT_DISTANCE
Definition: Object.h:33
G3D::int16 x
Definition: Vector2int16.h:37
void GetContactPoint(WorldObject const *obj, float &x, float &y, float &z, float distance2d=CONTACT_DISTANCE) const
Definition: Object.cpp:2650
SpellEffectHandleMode effectHandleMode
Definition: Spell.h:696

+ Here is the call graph for this function:

void Spell::EffectJumpDest ( SpellEffIndex  effIndex)
931 {
933  return;
934 
935  if (m_caster->IsInFlight())
936  return;
937 
938  if (!m_targets.HasDst())
939  return;
940 
941  float speedXY, speedZ;
944 }
Unit *const m_caster
Definition: Spell.h:647
SpellEffectInfo const * effectInfo
Definition: Spell.h:697
SpellCastTargets m_targets
Definition: Spell.h:584
MotionMaster * GetMotionMaster()
Definition: Unit.h:2101
bool IsInFlight() const
Definition: Unit.h:1582
WorldLocation * destTarget
Definition: Spell.h:693
void CalculateJumpSpeeds(SpellEffectInfo const *effInfo, float dist, float &speedxy, float &speedz)
Definition: SpellEffects.cpp:946
uint32 TriggerSpell
Definition: SpellInfo.h:263
float GetExactDist2d(const float x, const float y) const
Definition: Position.h:137
void MoveJump(Position const &pos, float speedXY, float speedZ, uint32 id=EVENT_JUMP, bool hasOrientation=false, uint32 arrivalSpellId=0, ObjectGuid const &arrivalSpellTargetGuid=ObjectGuid::Empty)
Definition: MotionMaster.h:184
bool HasDst() const
Definition: Spell.h:229
Definition: SharedDefines.h:4414
SpellEffectHandleMode effectHandleMode
Definition: Spell.h:696
Definition: Spell.h:286

+ Here is the call graph for this function:

void Spell::EffectKillCredit ( SpellEffIndex  effIndex)
5234 {
5236  return;
5237 
5239  return;
5240 
5241  int32 creatureEntry = effectInfo->MiscValue;
5242  if (!creatureEntry)
5243  {
5244  if (m_spellInfo->Id == 42793) // Burn Body
5245  creatureEntry = 24008; // Fallen Combatant
5246  }
5247 
5248  if (creatureEntry)
5249  unitTarget->ToPlayer()->RewardPlayerAndGroupAtEvent(creatureEntry, unitTarget);
5250 }
int32 MiscValue
Definition: SpellInfo.h:253
SpellInfo const *const m_spellInfo
Definition: Spell.h:547
uint32 Id
Definition: SpellInfo.h:329
SpellEffectInfo const * effectInfo
Definition: Spell.h:697
Player * ToPlayer()
Definition: Object.h:191
TypeID GetTypeId() const
Definition: Object.h:113
Definition: Spell.h:289
Unit * unitTarget
Definition: Spell.h:690
int32_t int32
Definition: Define.h:146
Definition: ObjectGuid.h:33
SpellEffectHandleMode effectHandleMode
Definition: Spell.h:696

+ Here is the call graph for this function:

void Spell::EffectKillCreditPersonal ( SpellEffIndex  effIndex)
5223 {
5225  return;
5226 
5228  return;
5229 
5230  unitTarget->ToPlayer()->KilledMonsterCredit(effectInfo->MiscValue);
5231 }
int32 MiscValue
Definition: SpellInfo.h:253
SpellEffectInfo const * effectInfo
Definition: Spell.h:697
Player * ToPlayer()
Definition: Object.h:191
TypeID GetTypeId() const
Definition: Object.h:113
Definition: Spell.h:289
Unit * unitTarget
Definition: Spell.h:690
Definition: ObjectGuid.h:33
SpellEffectHandleMode effectHandleMode
Definition: Spell.h:696

+ Here is the call graph for this function:

void Spell::EffectKnockBack ( SpellEffIndex  effIndex)
4537 {
4539  return;
4540 
4541  if (!unitTarget)
4542  return;
4543 
4544  if (Creature* creatureTarget = unitTarget->ToCreature())
4545  if (creatureTarget->isWorldBoss() || creatureTarget->IsDungeonBoss())
4546  return;
4547 
4548  // Spells with SPELL_EFFECT_KNOCK_BACK (like Thunderstorm) can't knockback target if target has ROOT/STUN
4550  return;
4551 
4552  // Instantly interrupt non melee spells being cast
4553  if (unitTarget->IsNonMeleeSpellCast(true))
4555 
4556  float ratio = 0.1f;
4557  float speedxy = float(effectInfo->MiscValue) * ratio;
4558  float speedz = float(damage) * ratio;
4559  if (speedxy < 0.1f && speedz < 0.1f)
4560  return;
4561 
4562  float x, y;
4564  {
4565  if (m_targets.HasDst())
4566  destTarget->GetPosition(x, y);
4567  else
4568  return;
4569  }
4570  else //if (m_spellInfo->Effects[i].Effect == SPELL_EFFECT_KNOCK_BACK)
4571  {
4572  m_caster->GetPosition(x, y);
4573  }
4574 
4575  unitTarget->KnockbackFrom(x, y, speedxy, speedz);
4576 }
int32 MiscValue
Definition: SpellInfo.h:253
Unit *const m_caster
Definition: Spell.h:647
SpellEffectInfo const * effectInfo
Definition: Spell.h:697
SpellCastTargets m_targets
Definition: Spell.h:584
WorldLocation * destTarget
Definition: Spell.h:693
Definition: Creature.h:467
bool IsNonMeleeSpellCast(bool withDelayed, bool skipChanneled=false, bool skipAutorepeat=false, bool isAutoshoot=false, bool skipInstant=true) const
Definition: Unit.cpp:2886
Definition: Spell.h:289
Definition: Unit.h:553
Unit * unitTarget
Definition: Spell.h:690
int32 damage
Definition: Spell.h:694
bool HasDst() const
Definition: Spell.h:229
void KnockbackFrom(float x, float y, float speedXY, float speedZ)
Definition: Unit.cpp:14655
void GetPosition(float &x, float &y) const
Definition: Position.h:109
G3D::int16 y
Definition: Vector2int16.h:38
Creature * ToCreature()
Definition: Object.h:194
Definition: Unit.h:560
void InterruptNonMeleeSpells(bool withDelayed, uint32 spellid=0, bool withInstant=true)
Definition: Unit.cpp:2916
bool HasUnitState(const uint32 f) const
Definition: Unit.h:1395
G3D::int16 x
Definition: Vector2int16.h:37
uint32 Effect
Definition: SpellInfo.h:243
Definition: SharedDefines.h:1154
SpellEffectHandleMode effectHandleMode
Definition: Spell.h:696

+ Here is the call graph for this function:

void Spell::EffectLeap ( SpellEffIndex  effIndex)
4350 {
4352  return;
4353 
4354  if (!unitTarget || unitTarget->IsInFlight())
4355  return;
4356 
4357  if (!m_targets.HasDst())
4358  return;
4359 
4360  Position pos = destTarget->GetPosition();
4363 }
Unit *const m_caster
Definition: Spell.h:647
Position GetFirstCollisionPosition(float dist, float angle)
Definition: Object.cpp:2636
SpellCastTargets m_targets
Definition: Spell.h:584
bool IsInFlight() const
Definition: Unit.h:1582
WorldLocation * destTarget
Definition: Spell.h:693
float GetOrientation() const
Definition: Position.h:107
Definition: Spell.h:289
Unit * unitTarget
Definition: Spell.h:690
float GetDistance(WorldObject const *obj) const
Definition: Object.cpp:1594
bool HasDst() const
Definition: Spell.h:229
void NearTeleportTo(float x, float y, float z, float orientation, bool casting=false)
Definition: Unit.cpp:15407
float GetPositionY() const
Definition: Position.h:105
void GetPosition(float &x, float &y) const
Definition: Position.h:109
float GetPositionZ() const
Definition: Position.h:106
Definition: Position.h:27
float GetPositionX() const
Definition: Position.h:104
SpellEffectHandleMode effectHandleMode
Definition: Spell.h:696

+ Here is the call graph for this function:

void Spell::EffectLeapBack ( SpellEffIndex  effIndex)
4579 {
4581  return;
4582 
4583  if (!unitTarget)
4584  return;
4585 
4586  float speedxy = effectInfo->MiscValue / 10.f;
4587  float speedz = damage / 10.f;
4588  //1891: Disengage
4589  m_caster->JumpTo(speedxy, speedz, m_spellInfo->SpellIconID != 1891);
4590 }
int32 MiscValue
Definition: SpellInfo.h:253
SpellInfo const *const m_spellInfo
Definition: Spell.h:547
Unit *const m_caster
Definition: Spell.h:647
void JumpTo(float speedXY, float speedZ, bool forward=true)
Definition: Unit.cpp:15152
SpellEffectInfo const * effectInfo
Definition: Spell.h:697
Unit * unitTarget
Definition: Spell.h:690
int32 damage
Definition: Spell.h:694
Definition: Spell.h:287
uint32 SpellIconID
Definition: SpellInfo.h:390
SpellEffectHandleMode effectHandleMode
Definition: Spell.h:696

+ Here is the call graph for this function:

void Spell::EffectLearnGarrisonBuilding ( SpellEffIndex  effIndex)
5852 {
5854  return;
5855 
5857  return;
5858 
5859  if (Garrison* garrison = unitTarget->ToPlayer()->GetGarrison())
5860  garrison->LearnBlueprint(GetEffect(effIndex)->MiscValue);
5861 }
Definition: Garrison.h:83
SpellEffectInfo const * GetEffect(uint32 index) const
Definition: Spell.h:624
Player * ToPlayer()
Definition: Object.h:191
TypeID GetTypeId() const
Definition: Object.h:113
Definition: Spell.h:289
Unit * unitTarget
Definition: Spell.h:690
Definition: ObjectGuid.h:33
SpellEffectHandleMode effectHandleMode
Definition: Spell.h:696

+ Here is the call graph for this function:

void Spell::EffectLearnPetSpell ( SpellEffIndex  effIndex)
2883 {
2885  return;
2886 
2887  if (!unitTarget)
2888  return;
2889 
2890  if (unitTarget->ToPlayer())
2891  {
2892  EffectLearnSpell(effIndex);
2893  return;
2894  }
2895  Pet* pet = unitTarget->ToPet();
2896  if (!pet)
2897  return;
2898 
2899  SpellInfo const* learn_spellproto = sSpellMgr->GetSpellInfo(effectInfo->TriggerSpell);
2900  if (!learn_spellproto)
2901  return;
2902 
2903  pet->learnSpell(learn_spellproto->Id);
2905  pet->GetOwner()->PetSpellInitialize();
2906 }
uint32 Id
Definition: SpellInfo.h:329
SpellEffectInfo const * effectInfo
Definition: Spell.h:697
Player * GetOwner() const
Definition: Pet.cpp:1913
Definition: SpellInfo.h:326
Pet * ToPet()
Definition: Unit.h:2200
Player * ToPlayer()
Definition: Object.h:191
Definition: PetDefines.h:35
void SavePetToDB(PetSaveMode mode)
Definition: Pet.cpp:372
uint32 TriggerSpell
Definition: SpellInfo.h:263
Definition: Spell.h:289
Unit * unitTarget
Definition: Spell.h:690
#define sSpellMgr
Definition: SpellMgr.h:756
bool learnSpell(uint32 spell_id)
Definition: Pet.cpp:1423
Definition: Pet.h:46
SpellEffectHandleMode effectHandleMode
Definition: Spell.h:696
void EffectLearnSpell(SpellEffIndex effIndex)
Definition: SpellEffects.cpp:2249

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Spell::EffectLearnSkill ( SpellEffIndex  effIndex)
2491 {
2493  return;
2494 
2496  return;
2497 
2498  if (damage < 0)
2499  return;
2500 
2501  uint32 skillid = effectInfo->MiscValue;
2503  if (!rcEntry)
2504  return;
2505 
2506  SkillTiersEntry const* tier = sObjectMgr->GetSkillTier(rcEntry->SkillTierID);
2507  if (!tier)
2508  return;
2509 
2510  uint16 skillval = unitTarget->ToPlayer()->GetPureSkillValue(skillid);
2511  unitTarget->ToPlayer()->SetSkill(skillid, effectInfo->CalcValue(), std::max<uint16>(skillval, 1), tier->Value[damage - 1]);
2512 }
int32 MiscValue
Definition: SpellInfo.h:253
SpellEffectInfo const * effectInfo
Definition: Spell.h:697
#define sObjectMgr
Definition: ObjectMgr.h:1567
Player * ToPlayer()
Definition: Object.h:191
TypeID GetTypeId() const
Definition: Object.h:113
uint32 Value[MAX_SKILL_STEP]
Definition: ObjectMgr.h:639
Definition: ObjectMgr.h:636
Definition: Spell.h:289
Unit * unitTarget
Definition: Spell.h:690
int32 damage
Definition: Spell.h:694
uint32_t uint32
Definition: Define.h:150
uint16_t uint16
Definition: Define.h:151
Definition: DBCStructure.h:982
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
uint8 getRace() const
Definition: Unit.h:1411
Definition: ObjectGuid.h:33
SkillRaceClassInfoEntry const * GetSkillRaceClassInfo(uint32 skill, uint8 race, uint8 class_)
Definition: DBCStores.cpp:845
uint32 SkillTierID
Definition: DBCStructure.h:991
uint8 getClass() const
Definition: Unit.h:1413
SpellEffectHandleMode effectHandleMode
Definition: Spell.h:696

+ Here is the call graph for this function:

void Spell::EffectLearnSpell ( SpellEffIndex  effIndex)
2250 {
2252  return;
2253 
2254  if (!unitTarget)
2255  return;
2256 
2258  {
2259  if (unitTarget->ToPet())
2260  EffectLearnPetSpell(effIndex);
2261  return;
2262  }
2263 
2264  Player* player = unitTarget->ToPlayer();
2265 
2266  uint32 spellToLearn = (m_spellInfo->Id == 483 || m_spellInfo->Id == 55884) ? damage : effectInfo->TriggerSpell;
2267  player->LearnSpell(spellToLearn, false);
2268 
2269  if (m_spellInfo->Id == 55884)
2270  {
2271  if (BattlePetMgr* battlePetMgr = player->GetSession()->GetBattlePetMgr())
2272  {
2273  for (auto entry : sBattlePetSpeciesStore)
2274  {
2275  if (entry->SummonSpellID == spellToLearn)
2276  {
2277  battlePetMgr->AddPet(entry->ID, entry->CreatureID, BattlePetMgr::RollPetBreed(entry->ID), BattlePetMgr::GetDefaultPetQuality(entry->ID));
2278  player->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_OWN_BATTLE_PET_COUNT);
2279  break;
2280  }
2281  }
2282  }
2283  }
2284 
2285  TC_LOG_DEBUG("spells", "Spell: %s has learned spell %u from %s", player->GetGUID().ToString().c_str(), spellToLearn, m_caster->GetGUID().ToString().c_str());
2286 }
SpellInfo const *const m_spellInfo
Definition: Spell.h:547
Unit *const m_caster
Definition: Spell.h:647
uint32 Id
Definition: SpellInfo.h:329
SpellEffectInfo const * effectInfo
Definition: Spell.h:697
Pet * ToPet()
Definition: Unit.h:2200
DB2Storage< BattlePetSpeciesEntry > sBattlePetSpeciesStore("BattlePetSpecies.db2", BattlePetSpeciesFormat, HOTFIX_SEL_BATTLE_PET_SPECIES)
static uint16 RollPetBreed(uint32 species)
Definition: BattlePetMgr.cpp:154
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
Player * ToPlayer()
Definition: Object.h:191
TypeID GetTypeId() const
Definition: Object.h:113
uint32 TriggerSpell
Definition: SpellInfo.h:263
Definition: Spell.h:289
Unit * unitTarget
Definition: Spell.h:690
int32 damage
Definition: Spell.h:694
uint32_t uint32
Definition: Define.h:150
Definition: BattlePetMgr.h:83
ObjectGuid const & GetGUID() const
Definition: Object.h:105
void EffectLearnPetSpell(SpellEffIndex effIndex)
Definition: SpellEffects.cpp:2882
Definition: ObjectGuid.h:33
static uint8 GetDefaultPetQuality(uint32 species)
Definition: BattlePetMgr.cpp:163
std::string ToString() const
Definition: ObjectGuid.cpp:99
SpellEffectHandleMode effectHandleMode
Definition: Spell.h:696

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Spell::EffectMilling ( SpellEffIndex  effIndex)
5044 {
5046  return;
5047 
5048  Player* player = m_caster->ToPlayer();
5049  if (!player)
5050  return;
5051 
5053  return;
5054 
5055  if (itemTarget->GetCount() < 5)
5056  return;
5057 
5058  if (sWorld->getBoolConfig(CONFIG_SKILL_MILLING))
5059  {
5060  uint32 SkillValue = player->GetPureSkillValue(SKILL_INSCRIPTION);
5061  uint32 reqSkillValue = itemTarget->GetTemplate()->GetRequiredSkillRank();
5062  player->UpdateGatherSkill(SKILL_INSCRIPTION, SkillValue, reqSkillValue);
5063  }
5064 
5065  player->SendLoot(itemTarget->GetGUID(), LOOT_MILLING);
5066 }
uint32 GetCount() const
Definition: Item.h:322
Unit *const m_caster
Definition: Spell.h:647
uint32 GetRequiredSkillRank() const
Definition: ItemTemplate.h:670
#define sWorld
Definition: World.h:887
Player * ToPlayer()
Definition: Object.h:191
Definition: ItemTemplate.h:202
Definition: Spell.h:289
uint32_t uint32
Definition: Define.h:150
Item * itemTarget
Definition: Spell.h:691
Definition: World.h:120
ObjectGuid const & GetGUID() const
Definition: Object.h:105
Definition: LootMgr.h:97
Definition: SharedDefines.h:4021
uint32 GetFlags() const
Definition: ItemTemplate.h:656
ItemTemplate const * GetTemplate() const
Definition: Item.cpp:547
SpellEffectHandleMode effectHandleMode
Definition: Spell.h:696

+ Here is the call graph for this function:

void Spell::EffectModifyThreatPercent ( SpellEffIndex  effIndex)
4875 {
4877  return;
4878 
4879  if (!unitTarget)
4880  return;
4881 
4883 }
Unit *const m_caster
Definition: Spell.h:647
void modifyThreatPercent(Unit *victim, int32 percent)
Definition: ThreatManager.cpp:452
Definition: Spell.h:289
Unit * unitTarget
Definition: Spell.h:690
int32 damage
Definition: Spell.h:694
ThreatManager & getThreatManager()
Definition: Unit.h:1998
SpellEffectHandleMode effectHandleMode
Definition: Spell.h:696

+ Here is the call graph for this function:

void Spell::EffectNULL ( SpellEffIndex  effIndex)
323 {
324  TC_LOG_DEBUG("spells", "WORLD: Spell Effect DUMMY");
325 }
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198

+ Here is the caller graph for this function:

void Spell::EffectOpenLock ( SpellEffIndex  effIndex)
Todo:
Add script for spell 41920 - Filling, becouse server it freze when use this spell
1831 {
1833  return;
1834 
1835  if (m_caster->GetTypeId() != TYPEID_PLAYER)
1836  {
1837  TC_LOG_DEBUG("spells", "WORLD: Open Lock - No Player Caster!");
1838  return;
1839  }
1840 
1841  Player* player = m_caster->ToPlayer();
1842 
1843  uint32 lockId = 0;
1844  ObjectGuid guid;
1845 
1846  // Get lockId
1847  if (gameObjTarget)
1848  {
1849  GameObjectTemplate const* goInfo = gameObjTarget->GetGOInfo();
1850  // Arathi Basin banner opening. /// @todo Verify correctness of this check
1851  if ((goInfo->type == GAMEOBJECT_TYPE_BUTTON && goInfo->button.noDamageImmune) ||
1852  (goInfo->type == GAMEOBJECT_TYPE_GOOBER && goInfo->goober.requireLOS))
1853  {
1854  //CanUseBattlegroundObject() already called in CheckCast()
1855  // in battleground check
1856  if (Battleground* bg = player->GetBattleground())
1857  {
1858  bg->EventPlayerClickedOnFlag(player, gameObjTarget);
1859  return;
1860  }
1861  }
1862  else if (goInfo->type == GAMEOBJECT_TYPE_FLAGSTAND)
1863  {
1864  //CanUseBattlegroundObject() already called in CheckCast()
1865  // in battleground check
1866  if (Battleground* bg = player->GetBattleground())
1867  {
1868  if (bg->GetTypeID(true) == BATTLEGROUND_EY)
1869  bg->EventPlayerClickedOnFlag(player, gameObjTarget);
1870  return;
1871  }
1872  }
1874  {
1876  return;
1877  }
1879  // handle outdoor pvp object opening, return true if go was registered for handling
1880  // these objects must have been spawned by outdoorpvp!
1881  else if (gameObjTarget->GetGOInfo()->type == GAMEOBJECT_TYPE_GOOBER && sOutdoorPvPMgr->HandleOpenGo(player, gameObjTarget))
1882  return;
1883  lockId = goInfo->GetLockId();
1884  guid = gameObjTarget->GetGUID();
1885  }
1886  else if (itemTarget)
1887  {
1888  lockId = itemTarget->GetTemplate()->GetLockID();
1889  guid = itemTarget->GetGUID();
1890  }
1891  else
1892  {
1893  TC_LOG_DEBUG("spells", "WORLD: Open Lock - No GameObject/Item Target!");
1894  return;
1895  }
1896 
1897  SkillType skillId = SKILL_NONE;
1898  int32 reqSkillValue = 0;
1899  int32 skillValue;
1900 
1901  SpellCastResult res = CanOpenLock(effIndex, lockId, skillId, reqSkillValue, skillValue);
1902  if (res != SPELL_CAST_OK)
1903  {
1904  SendCastResult(res);
1905  return;
1906  }
1907 
1908  if (gameObjTarget)
1909  SendLoot(guid, LOOT_SKINNING);
1910  else if (itemTarget)
1912 
1913  // not allow use skill grow at item base open
1914  if (!m_CastItem && skillId != SKILL_NONE)
1915  {
1916  // update skill if really known
1917  if (uint32 pureSkillValue = player->GetPureSkillValue(skillId))
1918  {
1919  if (gameObjTarget)
1920  {
1921  // Allow one skill-up until respawned
1922  if (!gameObjTarget->IsInSkillupList(player->GetGUID()) &&
1923  player->UpdateGatherSkill(skillId, pureSkillValue, reqSkillValue))
1924  gameObjTarget->AddToSkillupList(player->GetGUID());
1925  }
1926  else if (itemTarget)
1927  {
1928  // Do one skill-up
1929  player->UpdateGatherSkill(skillId, pureSkillValue, reqSkillValue);
1930  }
1931  }
1932  }
1934 }
Definition: Object.h:95
Definition: LootMgr.h:95
uint32 GetLockID() const
Definition: ItemTemplate.h:687
GameObject * gameObjTarget
Definition: Spell.h:692
SpellInfo const *const m_spellInfo
Definition: Spell.h:547
Unit *const m_caster
Definition: Spell.h:647
uint32 Id
Definition: SpellInfo.h:329
Unit * GetOwner() const
Definition: GameObject.cpp:1009
Definition: GameObject.h:871
#define sOutdoorPvPMgr
Definition: OutdoorPvPMgr.h:105
SpellCastResult CanOpenLock(uint32 effIndex, uint32 lockid, SkillType &skillid, int32 &reqSkillValue, int32 &skillValue)
Definition: Spell.cpp:6928
Definition: SharedDefines.h:3883
struct GameObjectTemplate::@221::@224 button
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
Definition: UpdateFields.h:49
Definition: GameObject.h:34
Definition: SharedDefines.h:4567
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
void ExecuteLogEffectOpenLock(uint8 effIndex, Object *obj)
Definition: Spell.cpp:4190
Item * m_CastItem
Definition: Spell.h:548
void SetFlag(uint16 index, uint32 newFlag)
Definition: Object.cpp:1199
Player * ToPlayer()
Definition: Object.h:191
uint32 GetLockId() const
Definition: GameObject.h:650
TypeID GetTypeId() const
Definition: Object.h:113
void SetLootState(LootState s, Unit *unit=NULL)
Definition: GameObject.cpp:2112
void SendLoot(ObjectGuid guid, LootType loottype)
Definition: SpellEffects.cpp:1762
Definition: Spell.h:289
Definition: SharedDefines.h:2066
void AddToSkillupList(ObjectGuid const &PlayerGuidLow)
Definition: GameObject.h:992
int32_t int32
Definition: Define.h:146
Definition: SharedDefines.h:2089
uint32_t uint32
Definition: Define.h:150
GameObjectTemplate const * GetGOInfo() const
Definition: GameObject.h:894
Item * itemTarget
Definition: Spell.h:691
struct GameObjectTemplate::@221::@233 goober
ObjectGuid const & GetGUID() const
Definition: Object.h:105
Definition: ObjectGuid.h:33
Definition: SharedDefines.h:2075
Definition: Battleground.h:235
SpellCastResult
Definition: SharedDefines.h:1265
SkillType
Definition: SharedDefines.h:3881
Definition: ObjectGuid.h:189
Definition: SharedDefines.h:2071
Definition: SharedDefines.h:1538
uint32 type
Definition: GameObject.h:37
Definition: ItemTemplate.h:137
bool IsInSkillupList(ObjectGuid const &playerGuid) const
Definition: GameObject.h:993
ItemTemplate const * GetTemplate() const
Definition: Item.cpp:547
SpellEffectHandleMode effectHandleMode
Definition: Spell.h:696

+ Here is the call graph for this function:

void Spell::EffectParry ( SpellEffIndex  effIndex)
4332 {
4334  return;
4335 
4336  if (m_caster->GetTypeId() == TYPEID_PLAYER)
4337  m_caster->ToPlayer()->SetCanParry(true);
4338 }
Unit *const m_caster
Definition: Spell.h:647
Player * ToPlayer()
Definition: Object.h:191
TypeID GetTypeId() const
Definition: Object.h:113
Definition: Spell.h:288
Definition: ObjectGuid.h:33
SpellEffectHandleMode effectHandleMode
Definition: Spell.h:696

+ Here is the call graph for this function:

void Spell::EffectPersistentAA ( SpellEffIndex  effIndex)
1595 {
1597  return;
1598 
1599  if (!m_spellAura)
1600  {
1602  float radius = effectInfo->CalcRadius(caster);
1603 
1604  // Caster not in world, might be spell triggered from aura removal
1605  if (!caster->IsInWorld())
1606  return;
1607  DynamicObject* dynObj = new DynamicObject(false);
1609  {
1610  delete dynObj;
1611  return;
1612  }
1613 
1615  {
1616  m_spellAura = aura;
1618  }
1619  else
1620  return;
1621  }
1622 
1625 }
SpellInfo const *const m_spellInfo
Definition: Spell.h:547
Unit *const m_caster
Definition: Spell.h:647
SpellEffectInfo const * effectInfo
Definition: Spell.h:697
static ObjectGuid const Empty
Definition: ObjectGuid.h:196
Map * GetMap() const
Definition: Object.h:543
#define WORLD_TRIGGER
Definition: Unit.h:33
bool CreateDynamicObject(ObjectGuid::LowType guidlow, Unit *caster, SpellInfo const *spell, Position const &pos, float radius, DynamicObjectType type)
Definition: DynamicObject.cpp:83
WorldLocation * destTarget
Definition: Spell.h:693
SpellValue *const m_spellValue
Definition: Spell.h:649
Aura * m_spellAura
Definition: Spell.h:699
Definition: DynamicObject.h:31
Definition: DynamicObject.h:35
float CalcRadius(Unit *caster=NULL, Spell *=NULL) const
Definition: SpellInfo.cpp:655
Unit * m_originalCaster
Definition: Spell.h:653
Definition: Spell.h:288
void _ApplyEffectForTargets(uint8 effIndex)
Definition: SpellAuras.cpp:671
DynamicObject * GetDynobjOwner() const
Definition: SpellAuras.h:139
#define ASSERT
Definition: Errors.h:55
void _RegisterForTargets()
Definition: SpellAuras.h:151
int32 EffectBasePoints[MAX_SPELL_EFFECTS]
Definition: Spell.h:268
uint32 GetEntry() const
Definition: Object.h:107
int32 m_castItemLevel
Definition: Spell.h:551
ObjectGuid::LowType GenerateLowGuid()
Definition: Map.h:561
bool IsInWorld() const
Definition: Object.h:100
Definition: SpellAuras.h:116
Definition: Unit.h:1305
static Aura * TryCreate(SpellInfo const *spellproto, uint32 tryEffMask, WorldObject *owner, Unit *caster, int32 *baseAmount, Item *castItem=NULL, ObjectGuid casterGUID=ObjectGuid::Empty, int32 castItemLevel=-1)
Definition: SpellAuras.cpp:309
#define MAX_EFFECT_MASK
Definition: DBCStructure.h:1027
SpellEffectHandleMode effectHandleMode
Definition: Spell.h:696

+ Here is the call graph for this function:

void Spell::EffectPickPocket ( SpellEffIndex  effIndex)
2419 {
2421  return;
2422 
2423  if (m_caster->GetTypeId() != TYPEID_PLAYER)
2424  return;
2425 
2426  // victim must be creature and attackable
2428  return;
2429 
2430  // victim have to be alive and humanoid or undead
2433 }
uint32 GetCreatureTypeMask() const
Definition: Unit.cpp:11263
uint32 const CREATURE_TYPEMASK_HUMANOID_OR_UNDEAD
Definition: SharedDefines.h:3572
Unit *const m_caster
Definition: Spell.h:647
Definition: ObjectGuid.h:32
Player * ToPlayer()
Definition: Object.h:191
TypeID GetTypeId() const
Definition: Object.h:113
Definition: Spell.h:289
Unit * unitTarget
Definition: Spell.h:690
bool IsAlive() const
Definition: Unit.h:1692
bool IsFriendlyTo(Unit const *unit) const
Definition: Unit.cpp:7170
ObjectGuid const & GetGUID() const
Definition: Object.h:105
Definition: ObjectGuid.h:33
Definition: LootMgr.h:91
SpellEffectHandleMode effectHandleMode
Definition: Spell.h:696

+ Here is the call graph for this function:

void Spell::EffectPlayMovie ( SpellEffIndex  effIndex)
2515 {
2517  return;
2518 
2520  return;
2521 
2522  uint32 movieId = effectInfo->MiscValue;
2523  if (!sMovieStore.LookupEntry(movieId))
2524  return;
2525 
2526  unitTarget->ToPlayer()->SendMovieStart(movieId);
2527 }
int32 MiscValue
Definition: SpellInfo.h:253
SpellEffectInfo const * effectInfo
Definition: Spell.h:697
Player * ToPlayer()
Definition: Object.h:191
DBCStorage< MovieEntry > sMovieStore(Moviefmt)
TypeID GetTypeId() const
Definition: Object.h:113
Definition: Spell.h:289
Unit * unitTarget
Definition: Spell.h:690
uint32_t uint32
Definition: Define.h:150
Definition: ObjectGuid.h:33
SpellEffectHandleMode effectHandleMode
Definition: Spell.h:696

+ Here is the call graph for this function:

void Spell::EffectPlayMusic ( SpellEffIndex  effIndex)
5538 {
5540  return;
5541 
5543  return;
5544 
5545  uint32 soundid = effectInfo->MiscValue;
5546 
5547  if (!sSoundEntriesStore.LookupEntry(soundid))
5548  {
5549  TC_LOG_ERROR("spells", "EffectPlayMusic: Sound (Id: %u) not exist in spell %u.", soundid, m_spellInfo->Id);
5550  return;
5551  }
5552 
5553  unitTarget->ToPlayer()->GetSession()->SendPacket(WorldPackets::Misc::PlayMusic(soundid).Write());
5554 }
int32 MiscValue
Definition: SpellInfo.h:253
SpellInfo const *const m_spellInfo
Definition: Spell.h:547
uint32 Id
Definition: SpellInfo.h:329
SpellEffectInfo const * effectInfo
Definition: Spell.h:697
Definition: MiscPackets.h:501
Player * ToPlayer()
Definition: Object.h:191
TypeID GetTypeId() const
Definition: Object.h:113
Definition: Spell.h:289
Unit * unitTarget
Definition: Spell.h:690
uint32_t uint32
Definition: Define.h:150
Definition: ObjectGuid.h:33
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
DB2Storage< SoundEntriesEntry > sSoundEntriesStore("SoundEntries.db2", SoundEntriesFormat, HOTFIX_SEL_SOUND_ENTRIES)
SpellEffectHandleMode effectHandleMode
Definition: Spell.h:696

+ Here is the call graph for this function:

void Spell::EffectPlaySound ( SpellEffIndex  effIndex)
5579 {
5581  return;
5582 
5583  if (!unitTarget)
5584  return;
5585 
5586  Player* player = unitTarget->ToPlayer();
5587  if (!player)
5588  return;
5589 
5590  switch (m_spellInfo->Id)
5591  {
5592  case 91604: // Restricted Flight Area
5593  player->GetSession()->SendNotification(LANG_ZONE_NOFLYZONE);
5594  break;
5595  default:
5596  break;
5597  }
5598 
5599  uint32 soundId = effectInfo->MiscValue;
5600 
5601  if (!sSoundEntriesStore.LookupEntry(soundId))
5602  {
5603  TC_LOG_ERROR("spells", "EffectPlaySound: Sound (Id: %u) not exist in spell %u.", soundId, m_spellInfo->Id);
5604  return;
5605  }
5606 
5607  player->PlayDirectSound(soundId, player);
5608 }
int32 MiscValue
Definition: SpellInfo.h:253
SpellInfo const *const m_spellInfo
Definition: Spell.h:547
uint32 Id
Definition: SpellInfo.h:329
SpellEffectInfo const * effectInfo
Definition: Spell.h:697
Definition: Language.h:783
Player * ToPlayer()
Definition: Object.h:191
Definition: Spell.h:289
Unit * unitTarget
Definition: Spell.h:690
uint32_t uint32
Definition: Define.h:150
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
DB2Storage< SoundEntriesEntry > sSoundEntriesStore("SoundEntries.db2", SoundEntriesFormat, HOTFIX_SEL_SOUND_ENTRIES)
SpellEffectHandleMode effectHandleMode
Definition: Spell.h:696

+ Here is the call graph for this function:

void Spell::EffectPowerBurn ( SpellEffIndex  effIndex)
1204 {
1206  return;
1207 
1209  return;
1210 
1211  Powers powerType = Powers(effectInfo->MiscValue);
1212 
1213  if (!unitTarget || !unitTarget->IsAlive() || unitTarget->getPowerType() != powerType || damage < 0)
1214  return;
1215 
1216  // burn x% of target's mana, up to maximum of 2x% of caster's mana (Mana Burn)
1217  if (m_spellInfo->Id == 8129)
1218  {
1219  int32 maxDamage = int32(CalculatePct(m_caster->GetMaxPower(powerType), damage * 2));
1221  damage = std::min(damage, maxDamage);
1222  }
1223 
1224  int32 newDamage = -(unitTarget->ModifyPower(powerType, -damage));
1225 
1226  // NO - Not a typo - EffectPowerBurn uses effect value multiplier - not effect damage multiplier
1227  float dmgMultiplier = effectInfo->CalcValueMultiplier(m_originalCaster, this);
1228 
1229  // add log data before multiplication (need power amount, not damage)
1230  ExecuteLogEffectTakeTargetPower(effIndex, unitTarget, powerType, newDamage, 0.0f);
1231 
1232  newDamage = int32(newDamage* dmgMultiplier);
1233 
1234  m_damage += newDamage;
1235 }
int32 MiscValue
Definition: SpellInfo.h:253
int32 ModifyPower(Powers power, int32 val)
Definition: Unit.cpp:10285
SpellInfo const *const m_spellInfo
Definition: Spell.h:547
Unit *const m_caster
Definition: Spell.h:647
uint32 Id
Definition: SpellInfo.h:329
SpellEffectInfo const * effectInfo
Definition: Spell.h:697
int8_t int8
Definition: Define.h:148
float CalcValueMultiplier(Unit *caster, Spell *spell=NULL) const
Definition: SpellInfo.cpp:629
Powers getPowerType() const
Definition: Unit.h:1444
T min(const T &x, const T &y)
Definition: g3dmath.h:305
Powers
Definition: SharedDefines.h:246
Definition: Spell.h:289
Unit * unitTarget
Definition: Spell.h:690
Unit * m_originalCaster
Definition: Spell.h:653
int32 damage
Definition: Spell.h:694
bool IsAlive() const
Definition: Unit.h:1692
void ExecuteLogEffectTakeTargetPower(uint8 effIndex, Unit *target, uint32 powerType, uint32 points, float amplitude)
Definition: Spell.cpp:4148
int32_t int32
Definition: Define.h:146
int32 m_damage
Definition: Spell.h:709
T CalculatePct(T base, U pct)
Definition: Util.h:92
int32_t int32
Definition: g3dmath.h:167
Definition: SharedDefines.h:265
int32 GetMaxPower(Powers power) const
Definition: Unit.cpp:11598
SpellEffectHandleMode effectHandleMode
Definition: Spell.h:696

+ Here is the call graph for this function:

void Spell::EffectPowerDrain ( SpellEffIndex  effIndex)
1129 {
1131  return;
1132 
1134  return;
1135 
1136  Powers powerType = Powers(effectInfo->MiscValue);
1137 
1138  if (!unitTarget || !unitTarget->IsAlive() || unitTarget->getPowerType() != powerType || damage < 0)
1139  return;
1140 
1141  // add spell damage bonus
1143  damage = bonus + uint32(bonus * variance);
1145 
1146  int32 newDamage = -(unitTarget->ModifyPower(powerType, -damage));
1147 
1148  float gainMultiplier = 0.0f;
1149 
1150  // Don't restore from self drain
1151  if (m_caster != unitTarget)
1152  {
1153  gainMultiplier = effectInfo->CalcValueMultiplier(m_originalCaster, this);
1154 
1155  int32 gain = int32(newDamage* gainMultiplier);
1156 
1157  m_caster->EnergizeBySpell(m_caster, m_spellInfo->Id, gain, powerType);
1158  }
1159  ExecuteLogEffectTakeTargetPower(effIndex, unitTarget, powerType, newDamage, gainMultiplier);
1160 }
int32 MiscValue
Definition: SpellInfo.h:253
int32 ModifyPower(Powers power, int32 val)
Definition: Unit.cpp:10285
SpellInfo const *const m_spellInfo
Definition: Spell.h:547
Unit *const m_caster
Definition: Spell.h:647
uint32 Id
Definition: SpellInfo.h:329
SpellEffectInfo const * effectInfo
Definition: Spell.h:697
int8_t int8
Definition: Define.h:148
float CalcValueMultiplier(Unit *caster, Spell *spell=NULL) const
Definition: SpellInfo.cpp:629
void EnergizeBySpell(Unit *victim, uint32 SpellID, int32 Damage, Powers powertype)
Definition: Unit.cpp:8202
uint32 SpellDamageBonusDone(Unit *victim, SpellInfo const *spellProto, uint32 pdamage, DamageEffectType damagetype, SpellEffectInfo const *effect, uint32 stack=1) const
Definition: Unit.cpp:8212
Powers getPowerType() const
Definition: Unit.h:1444
Powers
Definition: SharedDefines.h:246
Definition: Spell.h:289
Unit * unitTarget
Definition: Spell.h:690
Unit * m_originalCaster
Definition: Spell.h:653
int32 damage
Definition: Spell.h:694
bool IsAlive() const
Definition: Unit.h:1692
void ExecuteLogEffectTakeTargetPower(uint8 effIndex, Unit *target, uint32 powerType, uint32 points, float amplitude)
Definition: Spell.cpp:4148
uint32 SpellDamageBonusTaken(Unit *caster, SpellInfo const *spellProto, uint32 pdamage, DamageEffectType damagetype, SpellEffectInfo const *effect, uint32 stack=1) const
Definition: Unit.cpp:8493
int32_t int32
Definition: Define.h:146
uint32_t uint32
Definition: Define.h:150
float variance
Definition: Spell.h:695
int32_t int32
Definition: g3dmath.h:167
Definition: SharedDefines.h:265
uint32_t uint32
Definition: g3dmath.h:168
Definition: Unit.h:663
SpellEffectHandleMode effectHandleMode
Definition: Spell.h:696

+ Here is the call graph for this function:

void Spell::EffectProficiency ( SpellEffIndex  effIndex)
2048 {
2050  return;
2051 
2052  if (m_caster->GetTypeId() != TYPEID_PLAYER)
2053  return;
2054  Player* p_target = m_caster->ToPlayer();
2055 
2057  if (m_spellInfo->EquippedItemClass == ITEM_CLASS_WEAPON && !(p_target->GetWeaponProficiency() & subClassMask))
2058  {
2059  p_target->AddWeaponProficiency(subClassMask);
2060  p_target->SendProficiency(ITEM_CLASS_WEAPON, p_target->GetWeaponProficiency());
2061  }
2062  if (m_spellInfo->EquippedItemClass == ITEM_CLASS_ARMOR && !(p_target->GetArmorProficiency() & subClassMask))
2063  {
2064  p_target->AddArmorProficiency(subClassMask);
2065  p_target->SendProficiency(ITEM_CLASS_ARMOR, p_target->GetArmorProficiency());
2066  }
2067 }
SpellInfo const *const m_spellInfo
Definition: Spell.h:547
Unit *const m_caster
Definition: Spell.h:647
int32 EquippedItemClass
Definition: SpellInfo.h:385
int32 EquippedItemSubClassMask
Definition: SpellInfo.h:386
Player * ToPlayer()
Definition: Object.h:191
TypeID GetTypeId() const
Definition: Object.h:113
Definition: Spell.h:288
uint32_t uint32
Definition: Define.h:150
Definition: ItemTemplate.h:369
Definition: ObjectGuid.h:33
Definition: ItemTemplate.h:371
SpellEffectHandleMode effectHandleMode
Definition: Spell.h:696

+ Here is the call graph for this function:

void Spell::EffectProspecting ( SpellEffIndex  effIndex)
5019 {
5021  return;
5022 
5023  Player* player = m_caster->ToPlayer();
5024  if (!player)
5025  return;
5026 
5028  return;
5029 
5030  if (itemTarget->GetCount() < 5)
5031  return;
5032 
5033  if (sWorld->getBoolConfig(CONFIG_SKILL_PROSPECTING))
5034  {
5035  uint32 SkillValue = player->GetPureSkillValue(SKILL_JEWELCRAFTING);
5036  uint32 reqSkillValue = itemTarget->GetTemplate()->GetRequiredSkillRank();
5037  player->UpdateGatherSkill(SKILL_JEWELCRAFTING, SkillValue, reqSkillValue);
5038  }
5039 
5040  player->SendLoot(itemTarget->GetGUID(), LOOT_PROSPECTING);
5041 }
uint32 GetCount() const
Definition: Item.h:322
Unit *const m_caster
Definition: Spell.h:647
Definition: LootMgr.h:96
uint32 GetRequiredSkillRank() const
Definition: ItemTemplate.h:670
#define sWorld
Definition: World.h:887
Player * ToPlayer()
Definition: Object.h:191
Definition: World.h:119
Definition: Spell.h:289
uint32_t uint32
Definition: Define.h:150
Item * itemTarget
Definition: Spell.h:691
ObjectGuid const & GetGUID() const
Definition: Object.h:105
Definition: SharedDefines.h:4004
uint32 GetFlags() const
Definition: ItemTemplate.h:656
Definition: ItemTemplate.h:191
ItemTemplate const * GetTemplate() const
Definition: Item.cpp:547
SpellEffectHandleMode effectHandleMode
Definition: Spell.h:696

+ Here is the call graph for this function:

void Spell::EffectPull ( SpellEffIndex  effIndex)
Todo:
create a proper pull towards distract spell center for distract
2393 {
2395  EffectNULL(effIndex);
2396 }
void EffectNULL(SpellEffIndex effIndex)
Definition: SpellEffects.cpp:322

+ Here is the call graph for this function:

void Spell::EffectPullTowards ( SpellEffIndex  effIndex)
4647 {
4649  return;
4650 
4651  if (!unitTarget)
4652  return;
4653 
4654  Position pos;
4656  {
4657  if (m_targets.HasDst())
4658  pos.Relocate(*destTarget);
4659  else
4660  return;
4661  }
4662  else //if (m_spellInfo->Effects[i].Effect == SPELL_EFFECT_PULL_TOWARDS)
4663  {
4664  pos.Relocate(m_caster);
4665  }
4666 
4667  float speedXY = float(effectInfo->MiscValue) * 0.1f;
4668  float speedZ = unitTarget->GetDistance(pos) / speedXY * 0.5f * Movement::gravity;
4669 
4670  unitTarget->GetMotionMaster()->MoveJump(pos, speedXY, speedZ);
4671 }
int32 MiscValue
Definition: SpellInfo.h:253
Unit *const m_caster
Definition: Spell.h:647
TC_GAME_API float gravity
Definition: MovementUtil.cpp:23
SpellEffectInfo const * effectInfo
Definition: Spell.h:697
Definition: SharedDefines.h:1155
SpellCastTargets m_targets
Definition: Spell.h:584
MotionMaster * GetMotionMaster()
Definition: Unit.h:2101
WorldLocation * destTarget
Definition: Spell.h:693
void Relocate(float x, float y)
Definition: Position.h:67
Definition: Spell.h:289
Unit * unitTarget
Definition: Spell.h:690
float GetDistance(WorldObject const *obj) const
Definition: Object.cpp:1594
void MoveJump(Position const &pos, float speedXY, float speedZ, uint32 id=EVENT_JUMP, bool hasOrientation=false, uint32 arrivalSpellId=0, ObjectGuid const &arrivalSpellTargetGuid=ObjectGuid::Empty)
Definition: MotionMaster.h:184
bool HasDst() const
Definition: Spell.h:229
Definition: Position.h:27
uint32 Effect
Definition: SpellInfo.h:243
SpellEffectHandleMode effectHandleMode
Definition: Spell.h:696

+ Here is the call graph for this function:

void Spell::EffectQuestClear ( SpellEffIndex  effIndex)
4593 {
4595  return;
4596 
4598  return;
4599  Player* player = unitTarget->ToPlayer();
4600 
4601  uint32 quest_id = effectInfo->MiscValue;
4602 
4603  Quest const* quest = sObjectMgr->GetQuestTemplate(quest_id);
4604 
4605  if (!quest)
4606  return;
4607 
4608  // Player has never done this quest
4609  if (player->GetQuestStatus(quest_id) == QUEST_STATUS_NONE)
4610  return;
4611 
4612  // remove all quest entries for 'entry' from quest log
4613  for (uint8 slot = 0; slot < MAX_QUEST_LOG_SIZE; ++slot)
4614  {
4615  uint32 logQuest = player->GetQuestSlotQuestId(slot);
4616  if (logQuest == quest_id)
4617  {
4618  player->SetQuestSlot(slot, 0);
4619 
4620  // we ignore unequippable quest items in this case, it's still be equipped
4621  player->TakeQuestSourceItem(logQuest, false);
4622 
4623  if (quest->HasFlag(QUEST_FLAGS_FLAGS_PVP))
4624  {
4625  player->pvpInfo.IsHostile = player->pvpInfo.IsInHostileArea || player->HasPvPForcingQuest();
4626  player->UpdatePvPState();
4627  }
4628  }
4629  }
4630 
4631  player->RemoveActiveQuest(quest_id, false);
4632  player->RemoveRewardedQuest(quest_id);
4633 }
int32 MiscValue
Definition: SpellInfo.h:253
SpellEffectInfo const * effectInfo
Definition: Spell.h:697
Definition: QuestDef.h:279
#define MAX_QUEST_LOG_SIZE
Definition: QuestDef.h:43
#define sObjectMgr
Definition: ObjectMgr.h:1567
Definition: QuestDef.h:155
Definition: QuestDef.h:110
Player * ToPlayer()
Definition: Object.h:191
TypeID GetTypeId() const
Definition: Object.h:113
Definition: Spell.h:289
Unit * unitTarget
Definition: Spell.h:690
uint32_t uint32
Definition: Define.h:150
Definition: ObjectGuid.h:33
bool HasFlag(uint32 flag) const
Definition: QuestDef.h:297
uint8_t uint8
Definition: Define.h:152
SpellEffectHandleMode effectHandleMode
Definition: Spell.h:696

+ Here is the call graph for this function:

void Spell::EffectQuestComplete ( SpellEffIndex  effIndex)
4389 {
4391  return;
4392 
4394  return;
4395  Player* player = unitTarget->ToPlayer();
4396 
4397  uint32 questId = effectInfo->MiscValue;
4398  if (questId)
4399  {
4400  Quest const* quest = sObjectMgr->GetQuestTemplate(questId);
4401  if (!quest)
4402  return;
4403 
4404  uint16 logSlot = player->FindQuestSlot(questId);
4405  if (logSlot < MAX_QUEST_LOG_SIZE)
4406  player->AreaExploredOrEventHappens(questId);
4407  else if (player->CanTakeQuest(quest, false)) // never rewarded before
4408  player->CompleteQuest(questId); // quest not in log - for internal use
4409  }
4410 }
int32 MiscValue
Definition: SpellInfo.h:253
SpellEffectInfo const * effectInfo
Definition: Spell.h:697
Definition: QuestDef.h:279
#define MAX_QUEST_LOG_SIZE
Definition: QuestDef.h:43
#define sObjectMgr
Definition: ObjectMgr.h:1567
Player * ToPlayer()
Definition: Object.h:191
TypeID GetTypeId() const
Definition: Object.h:113
Definition: Spell.h:289
Unit * unitTarget
Definition: Spell.h:690
uint32_t uint32
Definition: Define.h:150
uint16_t uint16
Definition: Define.h:151
Definition: ObjectGuid.h:33
SpellEffectHandleMode effectHandleMode
Definition: Spell.h:696

+ Here is the call graph for this function:

void Spell::EffectQuestFail ( SpellEffIndex  effIndex)
5253 {
5255  return;
5256 
5258  return;
5259 
5260  unitTarget->ToPlayer()->FailQuest(effectInfo->MiscValue);
5261 }
int32 MiscValue
Definition: SpellInfo.h:253
SpellEffectInfo const * effectInfo
Definition: Spell.h:697
Player * ToPlayer()
Definition: Object.h:191
TypeID GetTypeId() const
Definition: Object.h:113
Definition: Spell.h:289
Unit * unitTarget
Definition: Spell.h:690
Definition: ObjectGuid.h:33
SpellEffectHandleMode effectHandleMode
Definition: Spell.h:696

+ Here is the call graph for this function:

void Spell::EffectQuestStart ( SpellEffIndex  effIndex)
5264 {
5266  return;
5267 
5268  if (!unitTarget)
5269  return;
5270 
5271  Player* player = unitTarget->ToPlayer();
5272  if (!player)
5273  return;
5274 
5275  if (Quest const* quest = sObjectMgr->GetQuestTemplate(effectInfo->MiscValue))
5276  {
5277  if (!player->CanTakeQuest(quest, false))
5278  return;
5279 
5280  if (quest->IsAutoAccept() && player->CanAddQuest(quest, false))
5281  player->AddQuestAndCheckCompletion(quest, player);
5282 
5283  player->PlayerTalkClass->SendQuestGiverQuestDetails(quest, player->GetGUID(), true);
5284  }
5285 }
int32 MiscValue
Definition: SpellInfo.h:253
SpellEffectInfo const * effectInfo
Definition: Spell.h:697
Definition: QuestDef.h:279
#define sObjectMgr
Definition: ObjectMgr.h:1567
Player * ToPlayer()
Definition: Object.h:191
Definition: Spell.h:289
Unit * unitTarget
Definition: Spell.h:690
SpellEffectHandleMode effectHandleMode
Definition: Spell.h:696

+ Here is the call graph for this function:

void Spell::EffectRechargeManaGem ( SpellEffIndex  effIndex)
5683 {
5685  return;
5686 
5688  return;
5689 
5690  Player* player = m_caster->ToPlayer();
5691 
5692  if (!player)
5693  return;
5694  if (SpellEffectInfo const* effect = GetEffect(EFFECT_0))
5695  {
5696  uint32 item_id = effect->ItemType;
5697 
5698  ItemTemplate const* pProto = sObjectMgr->GetItemTemplate(item_id);
5699  if (!pProto)
5700  {
5701  player->SendEquipError(EQUIP_ERR_ITEM_NOT_FOUND, NULL, NULL);
5702  return;
5703  }
5704 
5705  if (Item* pItem = player->GetItemByEntry(item_id))
5706  {
5707  for (size_t x = 0; x < pProto->Effects.size() && x < 5; ++x)
5708  pItem->SetSpellCharges(x, pProto->Effects[x]->Charges);
5709  pItem->SetState(ITEM_CHANGED, player);
5710  }
5711  }
5712 }
Unit *const m_caster
Definition: Spell.h:647
Definition: SharedDefines.h:28
SpellEffectInfo const * GetEffect(uint32 index) const
Definition: Spell.h:624
arena_t NULL
Definition: jemalloc_internal.h:624
#define sObjectMgr
Definition: ObjectMgr.h:1567
Player * ToPlayer()
Definition: Object.h:191
TypeID GetTypeId() const
Definition: Object.h:113
Definition: Item.h:71
Definition: Spell.h:289
std::vector< ItemEffectEntry const * > Effects
Definition: ItemTemplate.h:707
Unit * unitTarget
Definition: Spell.h:690
Definition: Item.h:259
Definition: SpellInfo.h:238
uint32_t uint32
Definition: Define.h:150
Definition: Item.h:217
Definition: ObjectGuid.h:33
Definition: ItemTemplate.h:647
G3D::int16 x
Definition: Vector2int16.h:37
SpellEffectHandleMode effectHandleMode
Definition: Spell.h:696

+ Here is the call graph for this function:

void Spell::EffectRedirectThreat ( SpellEffIndex  effIndex)
5408 {
5410  return;
5411 
5412  if (unitTarget)
5414 }
Unit *const m_caster
Definition: Spell.h:647
void SetRedirectThreat(ObjectGuid guid, uint32 pct)
Definition: Unit.h:2154
Definition: Spell.h:289
Unit * unitTarget
Definition: Spell.h:690
int32 damage
Definition: Spell.h:694
ObjectGuid const & GetGUID() const
Definition: Object.h:105
uint32_t uint32
Definition: g3dmath.h:168
SpellEffectHandleMode effectHandleMode
Definition: Spell.h:696

+ Here is the call graph for this function:

void Spell::EffectRemoveAura ( SpellEffIndex  effIndex)
5611 {
5613  return;
5614 
5615  if (!unitTarget)
5616  return;
5617  // there may be need of specifying casterguid of removed auras
5619 }
SpellEffectInfo const * effectInfo
Definition: Spell.h:697
uint32 TriggerSpell
Definition: SpellInfo.h:263
Definition: Spell.h:289
Unit * unitTarget
Definition: Spell.h:690
void RemoveAurasDueToSpell(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, uint32 reqEffMask=0, AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
Definition: Unit.cpp:3586
SpellEffectHandleMode effectHandleMode
Definition: Spell.h:696

+ Here is the call graph for this function:

void Spell::EffectRemoveTalent ( SpellEffIndex  effIndex)
5820 {
5822  return;
5823 
5824  TalentEntry const* talent = sTalentStore.LookupEntry(m_misc.TalentId);
5825  if (!talent)
5826  return;
5827 
5828  Player* player = unitTarget ? unitTarget->ToPlayer() : nullptr;
5829  if (!player)
5830  return;
5831 
5832  player->RemoveTalent(talent);
5833  player->SendTalentsInfoData();
5834 }
union Spell::@326 m_misc
Player * ToPlayer()
Definition: Object.h:191
Definition: Spell.h:289
Unit * unitTarget
Definition: Spell.h:690
DBCStorage< TalentEntry > sTalentStore(Talentfmt)
Definition: DBCStructure.h:1255
SpellEffectHandleMode effectHandleMode
Definition: Spell.h:696

+ Here is the call graph for this function:

void Spell::EffectRenamePet ( SpellEffIndex  effIndex)
5526 {
5528  return;
5529 
5530  if (!unitTarget || unitTarget->GetTypeId() != TYPEID_UNIT ||
5531  !unitTarget->IsPet() || ((Pet*)unitTarget)->getPetType() != HUNTER_PET)
5532  return;
5533 
5535 }
Definition: UpdateFields.h:146
Definition: ObjectGuid.h:32
Definition: PetDefines.h:25
void SetByteFlag(uint16 index, uint8 offset, uint8 newFlag)
Definition: Object.cpp:1252
TypeID GetTypeId() const
Definition: Object.h:113
Definition: Spell.h:289
Unit * unitTarget
Definition: Spell.h:690
bool IsPet() const
Definition: Unit.h:1403
Definition: Unit.h:321
Definition: Pet.h:46
SpellEffectHandleMode effectHandleMode
Definition: Spell.h:696

+ Here is the call graph for this function:

void Spell::EffectReputation ( SpellEffIndex  effIndex)
4366 {
4368  return;
4369 
4371  return;
4372 
4373  Player* player = unitTarget->ToPlayer();
4374 
4375  int32 repChange = damage;
4376 
4377  uint32 factionId = effectInfo->MiscValue;
4378 
4379  FactionEntry const* factionEntry = sFactionStore.LookupEntry(factionId);
4380  if (!factionEntry)
4381  return;
4382 
4383  repChange = player->CalculateReputationGain(REPUTATION_SOURCE_SPELL, 0, repChange, factionId);
4384 
4385  player->GetReputationMgr().ModifyReputation(factionEntry, repChange);
4386 }
int32 MiscValue
Definition: SpellInfo.h:253
SpellEffectInfo const * effectInfo
Definition: Spell.h:697
Player * ToPlayer()
Definition: Object.h:191
TypeID GetTypeId() const
Definition: Object.h:113
Definition: Spell.h:289
Unit * unitTarget
Definition: Spell.h:690
int32 damage
Definition: Spell.h:694
Definition: Player.h:330
int32_t int32
Definition: Define.h:146
uint32_t uint32
Definition: Define.h:150
Definition: DBCStructure.h:405
Definition: ObjectGuid.h:33
DBCStorage< FactionEntry > sFactionStore(Factionfmt)
SpellEffectHandleMode effectHandleMode
Definition: Spell.h:696

+ Here is the call graph for this function:

void Spell::EffectResurrect ( SpellEffIndex  effIndex)
4291 {
4293  return;
4294 
4296  return;
4297 
4298  if (unitTarget->IsAlive() || !unitTarget->IsInWorld())
4299  return;
4300 
4301  Player* target = unitTarget->ToPlayer();
4302 
4303  if (target->IsResurrectRequested()) // already have one active request
4304  return;
4305 
4306  uint32 health = target->CountPctFromMaxHealth(damage);
4307  uint32 mana = CalculatePct(target->GetMaxPower(POWER_MANA), damage);
4308 
4309  ExecuteLogEffectResurrect(effIndex, target);
4310 
4311  target->SetResurrectRequestData(m_caster, health, mana, 0);
4312  SendResurrectRequest(target);
4313 }
Unit *const m_caster
Definition: Spell.h:647
void SendResurrectRequest(Player *target)
Definition: Spell.cpp:4311
Player * ToPlayer()
Definition: Object.h:191
TypeID GetTypeId() const
Definition: Object.h:113
Definition: Spell.h:289
Unit * unitTarget
Definition: Spell.h:690
int32 damage
Definition: Spell.h:694
bool IsAlive() const
Definition: Unit.h:1692
uint32_t uint32
Definition: Define.h:150
T CalculatePct(T base, U pct)
Definition: Util.h:92
Definition: ObjectGuid.h:33
void ExecuteLogEffectResurrect(uint8 effIndex, Unit *target)
Definition: Spell.cpp:4230
bool IsInWorld() const
Definition: Object.h:100
Definition: SharedDefines.h:248
SpellEffectHandleMode effectHandleMode
Definition: Spell.h:696

+ Here is the call graph for this function:

void Spell::EffectResurrectNew ( SpellEffIndex  effIndex)
333 {
335  return;
336 
337  if (!unitTarget || unitTarget->IsAlive())
338  return;
339 
341  return;
342 
343  if (!unitTarget->IsInWorld())
344  return;
345 
346  Player* target = unitTarget->ToPlayer();
347 
348  if (target->IsResurrectRequested()) // already have one active request
349  return;
350 
351  uint32 health = damage;
352  uint32 mana = effectInfo->MiscValue;
353  ExecuteLogEffectResurrect(effIndex, target);
354  target->SetResurrectRequestData(m_caster, health, mana, 0);
355  SendResurrectRequest(target);
356 }
int32 MiscValue
Definition: SpellInfo.h:253
Unit *const m_caster
Definition: Spell.h:647
SpellEffectInfo const * effectInfo
Definition: Spell.h:697
void SendResurrectRequest(Player *target)
Definition: Spell.cpp:4311
Player * ToPlayer()
Definition: Object.h:191
TypeID GetTypeId() const
Definition: Object.h:113
Definition: Spell.h:289
Unit * unitTarget
Definition: Spell.h:690
int32 damage
Definition: Spell.h:694
bool IsAlive() const
Definition: Unit.h:1692
uint32_t uint32
Definition: Define.h:150
Definition: ObjectGuid.h:33
void ExecuteLogEffectResurrect(uint8 effIndex, Unit *target)
Definition: Spell.cpp:4230
bool IsInWorld() const
Definition: Object.h:100
SpellEffectHandleMode effectHandleMode
Definition: Spell.h:696

+ Here is the call graph for this function:

void Spell::EffectResurrectPet ( SpellEffIndex  effIndex)
4721 {
4723  return;
4724 
4725  if (damage < 0)
4726  return;
4727 
4728  Player* player = m_caster->ToPlayer();
4729  if (!player)
4730  return;
4731 
4732  // Maybe player dismissed dead pet or pet despawned?
4733  bool hadPet = true;
4734 
4735  if (!player->GetPet())
4736  {
4737  // Position passed to SummonPet is irrelevant with current implementation,
4738  // pet will be relocated without using these coords in Pet::LoadPetFromDB
4739  player->SummonPet(0, 0.0f, 0.0f, 0.0f, 0.0f, SUMMON_PET, 0);
4740  hadPet = false;
4741  }
4742 
4743  // TODO: Better to fail Hunter's "Revive Pet" at cast instead of here when casting ends
4744  Pet* pet = player->GetPet(); // Attempt to get current pet
4745  if (!pet || pet->IsAlive())
4746  return;
4747 
4748  // If player did have a pet before reviving, teleport it
4749  if (hadPet)
4750  {
4751  // Reposition the pet's corpse before reviving so as not to grab aggro
4752  // We can use a different, more accurate version of GetClosePoint() since we have a pet
4753  float x, y, z; // Will be used later to reposition the pet if we have one
4754  player->GetClosePoint(x, y, z, pet->GetObjectSize(), PET_FOLLOW_DIST, pet->GetFollowAngle());
4755  pet->NearTeleportTo(x, y, z, player->GetOrientation());
4756  pet->Relocate(x, y, z, player->GetOrientation()); // This is needed so SaveStayPosition() will get the proper coords.
4757  }
4758 
4761  pet->setDeathState(ALIVE);
4764 
4765  // Reset things for when the AI to takes over
4766  CharmInfo *ci = pet->GetCharmInfo();
4767  if (ci)
4768  {
4769  // In case the pet was at stay, we don't want it running back
4770  ci->SaveStayPosition();
4772 
4773  ci->SetIsFollowing(false);
4774  ci->SetIsCommandAttack(false);
4775  ci->SetIsCommandFollow(false);
4776  ci->SetIsReturning(false);
4777  }
4778 
4780 }
Unit *const m_caster
Definition: Spell.h:647
Definition: PetDefines.h:24
Definition: Unit.h:699
void SetIsFollowing(bool val)
Definition: Unit.cpp:15751
void SaveStayPosition()
Definition: Unit.cpp:15720
Definition: Unit.h:594
Definition: Unit.h:541
void SetUInt32Value(uint16 index, uint32 value)
Definition: Object.cpp:996
CharmInfo * GetCharmInfo()
Definition: Unit.h:1748
void setDeathState(DeathState s) override
Definition: Pet.cpp:521
Player * ToPlayer()
Definition: Object.h:191
Definition: PetDefines.h:35
void ClearUnitState(uint32 f)
Definition: Unit.h:1396
void SavePetToDB(PetSaveMode mode)
Definition: Pet.cpp:372
void Relocate(float x, float y)
Definition: Position.h:67
Definition: Spell.h:288
int32 damage
Definition: Spell.h:694
void SetIsReturning(bool val)
Definition: Unit.cpp:15761
void NearTeleportTo(float x, float y, float z, float orientation, bool casting=false)
Definition: Unit.cpp:15407
bool IsAlive() const
Definition: Unit.h:1692
G3D::int16 z
Definition: Vector3int16.h:46
G3D::int16 y
Definition: Vector2int16.h:38
void SetIsAtStay(bool val)
Definition: Unit.cpp:15741
void SetIsCommandAttack(bool val)
Definition: Unit.cpp:15700
Definition: Unit.h:1201
void RemoveFlag(uint16 index, uint32 oldFlag)
Definition: Object.cpp:1214
Definition: UpdateFields.h:109
bool HasCommandState(CommandStates state) const
Definition: Unit.h:1212
float GetFollowAngle() const override
Definition: TemporarySummon.h:73
Definition: UpdateFields.h:30
#define PET_FOLLOW_DIST
Definition: PetDefines.h:77
uint32_t uint32
Definition: g3dmath.h:168
void SetHealth(uint32 val)
Definition: Unit.cpp:11537
G3D::int16 x
Definition: Vector2int16.h:37
Definition: Unit.h:1137
void SetIsCommandFollow(bool val)
Definition: Unit.cpp:15710
float GetObjectSize() const
Definition: Object.cpp:2656
Definition: Pet.h:46
Definition: SharedDefines.h:4199
SpellEffectHandleMode effectHandleMode
Definition: Spell.h:696
uint32 CountPctFromMaxHealth(int32 pct) const
Definition: Unit.h:1435

+ Here is the call graph for this function:

void Spell::EffectResurrectWithAura ( SpellEffIndex  effIndex)
5769 {
5771  return;
5772 
5773  if (!unitTarget || !unitTarget->IsInWorld())
5774  return;
5775 
5776  Player* target = unitTarget->ToPlayer();
5777  if (!target)
5778  return;
5779 
5780  if (unitTarget->IsAlive())
5781  return;
5782 
5783  if (target->IsResurrectRequested()) // already have one active request
5784  return;
5785 
5786  uint32 health = target->CountPctFromMaxHealth(damage);
5787  uint32 mana = CalculatePct(target->GetMaxPower(POWER_MANA), damage);
5788  uint32 resurrectAura = 0;
5789  if (sSpellMgr->GetSpellInfo(effectInfo->TriggerSpell))
5790  resurrectAura = effectInfo->TriggerSpell;
5791 
5792  if (resurrectAura && target->HasAura(resurrectAura))
5793  return;
5794 
5795  ExecuteLogEffectResurrect(effIndex, target);
5796  target->SetResurrectRequestData(m_caster, health, mana, resurrectAura);
5797  SendResurrectRequest(target);
5798 }
Unit *const m_caster
Definition: Spell.h:647
SpellEffectInfo const * effectInfo
Definition: Spell.h:697
void SendResurrectRequest(Player *target)
Definition: Spell.cpp:4311
Player * ToPlayer()
Definition: Object.h:191
uint32 TriggerSpell
Definition: SpellInfo.h:263
Definition: Spell.h:289
Unit * unitTarget
Definition: Spell.h:690
int32 damage
Definition: Spell.h:694
bool IsAlive() const
Definition: Unit.h:1692
#define sSpellMgr
Definition: SpellMgr.h:756
uint32_t uint32
Definition: Define.h:150
T CalculatePct(T base, U pct)
Definition: Util.h:92
void ExecuteLogEffectResurrect(uint8 effIndex, Unit *target)
Definition: Spell.cpp:4230
bool IsInWorld() const
Definition: Object.h:100
Definition: SharedDefines.h:248
SpellEffectHandleMode effectHandleMode
Definition: Spell.h:696

+ Here is the call graph for this function:

void Spell::EffectSanctuary ( SpellEffIndex  effIndex)
3801 {
3803  return;
3804 
3805  if (!unitTarget)
3806  return;
3807 
3809 
3810  Unit::AttackerSet const& attackers = unitTarget->getAttackers();
3811  for (Unit::AttackerSet::const_iterator itr = attackers.begin(); itr != attackers.end();)
3812  {
3813  if (!(*itr)->CanSeeOrDetect(unitTarget))
3814  (*(itr++))->AttackStop();
3815  else
3816  ++itr;
3817  }
3818 
3820 
3821  // Vanish allows to remove all threat and cast regular stealth so other spells can be used
3822  if (m_caster->GetTypeId() == TYPEID_PLAYER
3825  {
3826  m_caster->ToPlayer()->RemoveAurasByType(SPELL_AURA_MOD_ROOT);
3827  // Overkill
3828  if (m_caster->ToPlayer()->HasSpell(58426))
3829  m_caster->CastSpell(m_caster, 58427, true);
3830  }
3831 }
SpellInfo const *const m_spellInfo
Definition: Spell.h:547
Unit *const m_caster
Definition: Spell.h:647
void UpdateVisibility()
Definition: HostileRefManager.cpp:183
flag128 SpellFamilyFlags
Definition: SpellInfo.h:397
uint32 getMSTime()
Definition: Timer.h:24
Definition: SpellMgr.h:58
uint32 m_lastSanctuaryTime
Definition: Unit.h:1989
Definition: SpellAuraDefines.h:86
Player * ToPlayer()
Definition: Object.h:191
TypeID GetTypeId() const
Definition: Object.h:113
Definition: Spell.h:289
AttackerSet const & getAttackers() const
Definition: Unit.h:1377
Unit * unitTarget
Definition: Spell.h:690
HostileRefManager & getHostileRefManager()
Definition: Unit.h:2001
uint32 SpellFamilyName
Definition: SpellInfo.h:396
std::set< Unit * > AttackerSet
Definition: Unit.h:1308
Definition: SharedDefines.h:4631
Definition: ObjectGuid.h:33
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
SpellEffectHandleMode effectHandleMode
Definition: Spell.h:696

+ Here is the call graph for this function:

void Spell::EffectSchoolDMG ( SpellEffIndex  effIndex)
406 {
408  return;
409 
410  if (unitTarget && unitTarget->IsAlive())
411  {
412  bool apply_direct_bonus = true;
413  switch (m_spellInfo->SpellFamilyName)
414  {
415  case SPELLFAMILY_GENERIC:
416  {
417  // Meteor like spells (divided damage to targets)
419  {
420  uint32 count = 0;
421  for (std::vector<TargetInfo>::iterator ihit = m_UniqueTargetInfo.begin(); ihit != m_UniqueTargetInfo.end(); ++ihit)
422  if (ihit->effectMask & (1<<effIndex))
423  ++count;
424 
425  damage /= count; // divide to all targets
426  }
427 
428  switch (m_spellInfo->Id) // better way to check unknown
429  {
430  // Consumption
431  case 28865:
432  damage = (m_caster->GetMap()->GetDifficultyID() == DIFFICULTY_NONE ? 2750 : 4250);
433  break;
434  // percent from health with min
435  case 25599: // Thundercrash
436  {
437  damage = unitTarget->GetHealth() / 2;
438  if (damage < 200)
439  damage = 200;
440  break;
441  }
442  // arcane charge. must only affect demons (also undead?)
443  case 45072:
444  {
447  return;
448  break;
449  }
450  // Gargoyle Strike
451  case 51963:
452  {
453  // about +4 base spell dmg per level
454  damage = (m_caster->getLevel() - 60) * 4 + 60;
455  break;
456  }
457  }
458  break;
459  }
460  case SPELLFAMILY_WARRIOR:
461  {
462  // Victory Rush
463  if (m_spellInfo->Id == 34428)
465  // Shockwave
466  else if (m_spellInfo->Id == 46968)
467  {
469  if (pct > 0)
471  break;
472  }
473  break;
474  }
475  case SPELLFAMILY_WARLOCK:
476  {
477  // Incinerate Rank 1 & 2
478  if ((m_spellInfo->SpellFamilyFlags[1] & 0x000040) && m_spellInfo->SpellIconID == 2128)
479  {
480  // Incinerate does more dmg (dmg/6) if the target have Immolate debuff.
481  // Check aura state for speed but aura state set not only for Immolate spell
483  {
485  damage += damage / 6;
486  }
487  }
488  break;
489  }
490  case SPELLFAMILY_PRIEST:
491  {
492  break;
493  }
494  case SPELLFAMILY_DRUID:
495  {
496  // Ferocious Bite
497  if (m_caster->GetTypeId() == TYPEID_PLAYER && m_spellInfo->SpellFamilyFlags[3] & 0x1000)
498  {
499  // converts each extra point of energy ( up to 25 energy ) into additional damage
500  int32 energy = -(m_caster->ModifyPower(POWER_ENERGY, -25));
501  // 25 energy = 100% more damage
502  AddPct(damage, energy * 4);
503  }
504  break;
505  }
506  case SPELLFAMILY_ROGUE:
507  {
508  // Envenom
509  if (m_spellInfo->SpellFamilyFlags[1] & 0x00000008)
510  {
511  if (Player* player = m_caster->ToPlayer())
512  {
513  // consume from stack dozes not more that have combo-points
514  if (uint32 combo = player->GetComboPoints())
515  {
516  // Lookup for Deadly poison (only attacker applied)
518  {
519  // count consumed deadly poison doses at target
520  uint32 spellId = aurEff->GetId();
521 
522  uint32 doses = aurEff->GetBase()->GetStackAmount();
523  if (doses > combo)
524  doses = combo;
525 
526  for (uint32 i = 0; i < doses; ++i)
528 
529  damage *= doses;
530  damage += int32(player->GetTotalAttackPowerValue(BASE_ATTACK) * 0.09f * combo);
531  }
532 
533  // Eviscerate and Envenom Bonus Damage (item set effect)
534  if (m_caster->HasAura(37169))
535  damage += combo * 40;
536  }
537  }
538  }
539  // Eviscerate
540  else if (m_spellInfo->SpellFamilyFlags[0] & 0x00020000)
541  {
542  if (Player* player = m_caster->ToPlayer())
543  {
544  if (uint32 combo = player->GetComboPoints())
545  {
547  damage += irand(int32(ap * combo * 0.03f), int32(ap * combo * 0.07f));
548 
549  // Eviscerate and Envenom Bonus Damage (item set effect)
550  if (m_caster->HasAura(37169))
551  damage += combo*40;
552  }
553  }
554  }
555  break;
556  }
558  {
559  // Blood Boil - bonus for diseased targets
560  if (m_spellInfo->SpellFamilyFlags[0] & 0x00040000)
561  {
563  {
564  damage += m_damage / 2;
566  }
567  }
568  break;
569  }
570  }
571 
572  if (m_originalCaster && apply_direct_bonus)
573  {
575  damage = bonus + uint32(bonus * variance);
577  }
578 
579  m_damage += damage;
580  }
581 }
Definition: SpellAuraEffects.h:30
Definition: SpellAuraDefines.h:63
int32 ModifyPower(Powers power, int32 val)
Definition: Unit.cpp:10285
Definition: DBCEnums.h:404
bool HasAura(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, ObjectGuid itemCasterGUID=ObjectGuid::Empty, uint32 reqEffMask=0) const
Definition: Unit.cpp:4240
SpellInfo const *const m_spellInfo
Definition: Spell.h:547
Unit *const m_caster
Definition: Spell.h:647
uint32 Id
Definition: SpellInfo.h:329
Definition: SharedDefines.h:1772
SpellEffectInfo const * effectInfo
Definition: Spell.h:697
Map * GetMap() const
Definition: Object.h:543
Definition: SharedDefines.h:3556
Difficulty GetDifficultyID() const
Definition: Map.h:390
bool HasAuraState(AuraStateType flag, SpellInfo const *spellProto=NULL, Unit const *Caster=NULL) const
Definition: Unit.cpp:7491
flag128 SpellFamilyFlags
Definition: SpellInfo.h:397
Definition: SharedDefines.h:3559
void RemoveAuraFromStack(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
Definition: Unit.cpp:3602
T ApplyPct(T &base, U pct)
Definition: Util.h:104
Definition: SharedDefines.h:4638
Definition: SharedDefines.h:4628
uint32 GetCreatureType() const
Definition: Unit.cpp:11248
Player * ToPlayer()
Definition: Object.h:191
uint8 getLevel() const
Definition: Unit.h:1408
uint32 SpellDamageBonusDone(Unit *victim, SpellInfo const *spellProto, uint32 pdamage, DamageEffectType damagetype, SpellEffectInfo const *effect, uint32 stack=1) const
Definition: Unit.cpp:8212
int32 irand(int32 min, int32 max)
Definition: Random.cpp:39
Definition: SpellInfo.h:187
TypeID GetTypeId() const
Definition: Object.h:113
std::vector< TargetInfo > m_UniqueTargetInfo
Definition: Spell.h:739
Unit * unitTarget
Definition: Spell.h:690
Unit * m_originalCaster
Definition: Spell.h:653
int32 damage
Definition: Spell.h:694
uint32 SpellFamilyName
Definition: SpellInfo.h:396
Definition: SharedDefines.h:4629
bool IsAlive() const
Definition: Unit.h:1692
bool HasAttribute(SpellAttr0 attribute) const
Definition: SpellInfo.h:462
Definition: Spell.h:287
Definition: Util.h:362
Definition: SharedDefines.h:4631
uint32 SpellDamageBonusTaken(Unit *caster, SpellInfo const *spellProto, uint32 pdamage, DamageEffectType damagetype, SpellEffectInfo const *effect, uint32 stack=1) const
Definition: Unit.cpp:8493
int32_t int32
Definition: Define.h:146
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
uint32_t uint32
Definition: Define.h:150
int32 m_damage
Definition: Spell.h:709
Definition: SharedDefines.h:4630
float variance
Definition: Spell.h:695
T CalculatePct(T base, U pct)
Definition: Util.h:92
ObjectGuid const & GetGUID() const
Definition: Object.h:105
Definition: ObjectGuid.h:33
Definition: SharedDefines.h:4623
Definition: SharedDefines.h:251
Definition: SharedDefines.h:4627
T AddPct(T &base, U pct)
Definition: Util.h:98
int32_t int32
Definition: g3dmath.h:167
uint32 SpellIconID
Definition: SpellInfo.h:390
AuraEffect * GetAuraEffect(uint32 spellId, uint8 effIndex, ObjectGuid casterGUID=ObjectGuid::Empty) const
Definition: Unit.cpp:4071
uint32_t uint32
Definition: g3dmath.h:168
Definition: Unit.h:663
float GetTotalAttackPowerValue(WeaponAttackType attType) const
Definition: Unit.cpp:11491
uint32 GetHealth() const
Definition: Unit.h:1426
Definition: Unit.h:617
SpellEffectHandleMode effectHandleMode
Definition: Spell.h:696

+ Here is the call graph for this function:

void Spell::EffectScriptEffect ( SpellEffIndex  effIndex)
Todo:
we must implement hunter pet summon at login there (spell 6962)
Todo:
a hack, range = 11, should after some time cast, otherwise too far
3283 {
3285  return;
3286 
3288 
3289  switch (m_spellInfo->SpellFamilyName)
3290  {
3291  case SPELLFAMILY_GENERIC:
3292  {
3293  switch (m_spellInfo->Id)
3294  {
3295  // Glyph of Backstab
3296  case 63975:
3297  {
3298  // search our Rupture aura on target
3300  {
3301  uint32 countMin = aurEff->GetBase()->GetMaxDuration();
3302  uint32 countMax = 12000; // this can be wrong, duration should be based on combo-points
3303  countMax += m_caster->HasAura(56801) ? 4000 : 0;
3304 
3305  if (countMin < countMax)
3306  {
3307  aurEff->GetBase()->SetDuration(uint32(aurEff->GetBase()->GetDuration() + 3000));
3308  aurEff->GetBase()->SetMaxDuration(countMin + 2000);
3309  }
3310 
3311  }
3312  return;
3313  }
3314  // Glyph of Scourge Strike
3315  case 69961:
3316  {
3318  for (Unit::AuraEffectList::const_iterator i = mPeriodic.begin(); i != mPeriodic.end(); ++i)
3319  {
3320  AuraEffect const* aurEff = *i;
3321  SpellInfo const* spellInfo = aurEff->GetSpellInfo();
3322  // search our Blood Plague and Frost Fever on target
3323  if (spellInfo->SpellFamilyName == SPELLFAMILY_DEATHKNIGHT && spellInfo->SpellFamilyFlags[2] & 0x2 &&
3324  aurEff->GetCasterGUID() == m_caster->GetGUID())
3325  {
3326  uint32 countMin = aurEff->GetBase()->GetMaxDuration();
3327  uint32 countMax = spellInfo->GetMaxDuration();
3328 
3329  // this Glyph
3330  countMax += 9000;
3331  // talent Epidemic
3333  countMax += epidemic->GetAmount();
3334 
3335  if (countMin < countMax)
3336  {
3337  aurEff->GetBase()->SetDuration(aurEff->GetBase()->GetDuration() + 3000);
3338  aurEff->GetBase()->SetMaxDuration(countMin + 3000);
3339  }
3340  }
3341  }
3342  return;
3343  }
3344  case 55693: // Remove Collapsing Cave Aura
3345  if (!unitTarget)
3346  return;
3348  break;
3349  // Bending Shinbone
3350  case 8856:
3351  {
3353  return;
3354 
3355  uint32 spell_id = roll_chance_i(20) ? 8854 : 8855;
3356 
3357  m_caster->CastSpell(m_caster, spell_id, true, NULL);
3358  return;
3359  }
3360  // Brittle Armor - need remove one 24575 Brittle Armor aura
3361  case 24590:
3363  return;
3364  // Mercurial Shield - need remove one 26464 Mercurial Shield aura
3365  case 26465:
3367  return;
3368  // Shadow Flame (All script effects, not just end ones to prevent player from dodging the last triggered spell)
3369  case 22539:
3370  case 22972:
3371  case 22975:
3372  case 22976:
3373  case 22977:
3374  case 22978:
3375  case 22979:
3376  case 22980:
3377  case 22981:
3378  case 22982:
3379  case 22983:
3380  case 22984:
3381  case 22985:
3382  {
3383  if (!unitTarget || !unitTarget->IsAlive())
3384  return;
3385 
3386  // Onyxia Scale Cloak
3387  if (unitTarget->HasAura(22683))
3388  return;
3389 
3390  // Shadow Flame
3391  m_caster->CastSpell(unitTarget, 22682, true);
3392  return;
3393  }
3394  // Decimate
3395  case 28374:
3396  case 54426:
3397  if (unitTarget)
3398  {
3400  if (decimateDamage > 0)
3401  m_caster->CastCustomSpell(28375, SPELLVALUE_BASE_POINT0, decimateDamage, unitTarget);
3402  }
3403  return;
3404  // Mirren's Drinking Hat
3405  case 29830:
3406  {
3407  uint32 item = 0;
3408  switch (urand(1, 6))
3409  {
3410  case 1:
3411  case 2:
3412  case 3:
3413  item = 23584; break; // Loch Modan Lager
3414  case 4:
3415  case 5:
3416  item = 23585; break; // Stouthammer Lite
3417  case 6:
3418  item = 23586; break; // Aerie Peak Pale Ale
3419  }
3420  if (item)
3421  DoCreateItem(effIndex, item);
3422  break;
3423  }
3424  case 20589: // Escape artist
3425  case 30918: // Improved Sprint
3426  {
3427  // Removes snares and roots.
3429  break;
3430  }
3431  // Plant Warmaul Ogre Banner
3432  case 32307:
3433  if (Player* caster = m_caster->ToPlayer())
3434  {
3435  caster->RewardPlayerAndGroupAtEvent(18388, unitTarget);
3436  if (Creature* target = unitTarget->ToCreature())
3437  {
3438  target->setDeathState(CORPSE);
3439  target->RemoveCorpse();
3440  }
3441  }
3442  break;
3443  // Mug Transformation
3444  case 41931:
3445  {
3446  if (m_caster->GetTypeId() != TYPEID_PLAYER)
3447  return;
3448 
3449  uint8 bag = 19;
3450  uint8 slot = 0;
3451  Item* item = NULL;
3452 
3453  while (bag) // 256 = 0 due to var type
3454  {
3455  item = m_caster->ToPlayer()->GetItemByPos(bag, slot);
3456  if (item && item->GetEntry() == 38587)
3457  break;
3458 
3459  ++slot;
3460  if (slot == 39)
3461  {
3462  slot = 0;
3463  ++bag;
3464  }
3465  }
3466  if (bag)
3467  {
3468  if (m_caster->ToPlayer()->GetItemByPos(bag, slot)->GetCount() == 1) m_caster->ToPlayer()->RemoveItem(bag, slot, true);
3469  else m_caster->ToPlayer()->GetItemByPos(bag, slot)->SetCount(m_caster->ToPlayer()->GetItemByPos(bag, slot)->GetCount()-1);
3470  // Spell 42518 (Braufest - Gratisprobe des Braufest herstellen)
3471  m_caster->CastSpell(m_caster, 42518, true);
3472  return;
3473  }
3474  break;
3475  }
3476  // Brutallus - Burn
3477  case 45141:
3478  case 45151:
3479  {
3480  //Workaround for Range ... should be global for every ScriptEffect
3481  float radius = effectInfo->CalcRadius();
3483  unitTarget->CastSpell(unitTarget, 46394, true);
3484 
3485  break;
3486  }
3487  // Goblin Weather Machine
3488  case 46203:
3489  {
3490  if (!unitTarget)
3491  return;
3492 
3493  uint32 spellId = 0;
3494  switch (rand32() % 4)
3495  {
3496  case 0: spellId = 46740; break;
3497  case 1: spellId = 46739; break;
3498  case 2: spellId = 46738; break;
3499  case 3: spellId = 46736; break;
3500  }
3501  unitTarget->CastSpell(unitTarget, spellId, true);
3502  break;
3503  }
3504  // 5, 000 Gold
3505  case 46642:
3506  {
3508  return;
3509 
3510  unitTarget->ToPlayer()->ModifyMoney(5000 * GOLD);
3511 
3512  break;
3513  }
3514  // Roll Dice - Decahedral Dwarven Dice
3515  case 47770:
3516  {
3517  char buf[128];
3518  const char *gender = "his";
3519  if (m_caster->getGender() > 0)
3520  gender = "her";
3521  sprintf(buf, "%s rubs %s [Decahedral Dwarven Dice] between %s hands and rolls. One %u and one %u.", m_caster->GetName().c_str(), gender, gender, urand(1, 10), urand(1, 10));
3522  m_caster->TextEmote(buf);
3523  break;
3524  }
3525  // Roll 'dem Bones - Worn Troll Dice
3526  case 47776:
3527  {
3528  char buf[128];
3529  const char *gender = "his";
3530  if (m_caster->getGender() > 0)
3531  gender = "her";
3532  sprintf(buf, "%s causually tosses %s [Worn Troll Dice]. One %u and one %u.", m_caster->GetName().c_str(), gender, urand(1, 6), urand(1, 6));
3533  m_caster->TextEmote(buf);
3534  break;
3535  }
3536  // Death Knight Initiate Visual
3537  case 51519:
3538  {
3540  return;
3541 
3542  uint32 iTmpSpellId = 0;
3543  switch (unitTarget->GetDisplayId())
3544  {
3545  case 25369: iTmpSpellId = 51552; break; // bloodelf female
3546  case 25373: iTmpSpellId = 51551; break; // bloodelf male
3547  case 25363: iTmpSpellId = 51542; break; // draenei female
3548  case 25357: iTmpSpellId = 51541; break; // draenei male
3549  case 25361: iTmpSpellId = 51537; break; // dwarf female
3550  case 25356: iTmpSpellId = 51538; break; // dwarf male
3551  case 25372: iTmpSpellId = 51550; break; // forsaken female
3552  case 25367: iTmpSpellId = 51549; break; // forsaken male
3553  case 25362: iTmpSpellId = 51540; break; // gnome female
3554  case 25359: iTmpSpellId = 51539; break; // gnome male
3555  case 25355: iTmpSpellId = 51534; break; // human female
3556  case 25354: iTmpSpellId = 51520; break; // human male
3557  case 25360: iTmpSpellId = 51536; break; // nightelf female
3558  case 25358: iTmpSpellId = 51535; break; // nightelf male
3559  case 25368: iTmpSpellId = 51544; break; // orc female
3560  case 25364: iTmpSpellId = 51543; break; // orc male
3561  case 25371: iTmpSpellId = 51548; break; // tauren female
3562  case 25366: iTmpSpellId = 51547; break; // tauren male
3563  case 25370: iTmpSpellId = 51545; break; // troll female
3564  case 25365: iTmpSpellId = 51546; break; // troll male
3565  default: return;
3566  }
3567 
3568  unitTarget->CastSpell(unitTarget, iTmpSpellId, true);
3569  Creature* npc = unitTarget->ToCreature();
3570  npc->LoadEquipment();
3571  return;
3572  }
3573  // Deathbolt from Thalgran Blightbringer
3574  // reflected by Freya's Ward
3575  // Retribution by Sevenfold Retribution
3576  case 51854:
3577  {
3578  if (!unitTarget)
3579  return;
3580  if (unitTarget->HasAura(51845))
3581  unitTarget->CastSpell(m_caster, 51856, true);
3582  else
3583  m_caster->CastSpell(unitTarget, 51855, true);
3584  break;
3585  }
3586  // Summon Ghouls On Scarlet Crusade
3587  case 51904:
3588  {
3589  if (!m_targets.HasDst())
3590  return;
3591 
3592  float x, y, z;
3593  float radius = effectInfo->CalcRadius();
3594  for (uint8 i = 0; i < 15; ++i)
3595  {
3596  m_caster->GetRandomPoint(*destTarget, radius, x, y, z);
3597  m_caster->CastSpell(x, y, z, 54522, true);
3598  }
3599  break;
3600  }
3601  case 52173: // Coyote Spirit Despawn
3602  case 60243: // Blood Parrot Despawn
3605  return;
3606  case 52479: // Gift of the Harvester
3608  m_originalCaster->CastSpell(unitTarget, urand(0, 1) ? damage : 52505, true);
3609  return;
3610  case 53110: // Devour Humanoid
3611  if (unitTarget)
3613  return;
3614  case 57347: // Retrieving (Wintergrasp RP-GG pickup spell)
3615  {
3617  return;
3618 
3620 
3621  return;
3622  }
3623  case 57349: // Drop RP-GG (Wintergrasp RP-GG at death drop spell)
3624  {
3625  if (m_caster->GetTypeId() != TYPEID_PLAYER)
3626  return;
3627 
3628  // Delete item from inventory at death
3629  m_caster->ToPlayer()->DestroyItemCount(damage, 5, true);
3630 
3631  return;
3632  }
3633  case 58418: // Portal to Orgrimmar
3634  case 58420: // Portal to Stormwind
3635  {
3636  if (!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER || effIndex != 0)
3637  return;
3638 
3639  // Effects for 58418 and 58420 are all DIFFICULTY_NONE so always valid
3640  uint32 spellID = GetEffect(EFFECT_0)->CalcValue();
3641  uint32 questID = GetEffect(EFFECT_1)->CalcValue();
3642 
3643  if (unitTarget->ToPlayer()->GetQuestStatus(questID) == QUEST_STATUS_COMPLETE)
3644  unitTarget->CastSpell(unitTarget, spellID, true);
3645 
3646  return;
3647  }
3648  case 58983: // Big Blizzard Bear
3649  {
3651  return;
3652 
3653  // Prevent stacking of mounts and client crashes upon dismounting
3655 
3656  // Triggered spell id dependent on riding skill
3657  if (uint16 skillval = unitTarget->ToPlayer()->GetSkillValue(SKILL_RIDING))
3658  {
3659  if (skillval >= 150)
3660  unitTarget->CastSpell(unitTarget, 58999, true);
3661  else
3662  unitTarget->CastSpell(unitTarget, 58997, true);
3663  }
3664  return;
3665  }
3666  case 59317: // Teleporting
3667  {
3668 
3670  return;
3671 
3672  // return from top
3673  if (unitTarget->ToPlayer()->GetAreaId() == 4637)
3674  unitTarget->CastSpell(unitTarget, 59316, true);
3675  // teleport atop
3676  else
3677  unitTarget->CastSpell(unitTarget, 59314, true);
3678 
3679  return;
3680  }
3681  case 62482: // Grab Crate
3682  {
3683  if (unitTarget)
3684  {
3685  if (Unit* seat = m_caster->GetVehicleBase())
3686  {
3687  if (Unit* parent = seat->GetVehicleBase())
3688  {
3690  m_caster->CastSpell(parent, 62496, true);
3691  unitTarget->CastSpell(parent, GetEffect(EFFECT_0)->CalcValue()); // DIFFICULTY_NONE, so effect always valid
3692  }
3693  }
3694  }
3695  return;
3696  }
3697  case 60123: // Lightwell
3698  {
3699  if (m_caster->GetTypeId() != TYPEID_UNIT || !m_caster->IsSummon())
3700  return;
3701 
3702  uint32 spell_heal;
3703 
3704  switch (m_caster->GetEntry())
3705  {
3706  case 31897: spell_heal = 7001; break;
3707  case 31896: spell_heal = 27873; break;
3708  case 31895: spell_heal = 27874; break;
3709  case 31894: spell_heal = 28276; break;
3710  case 31893: spell_heal = 48084; break;
3711  case 31883: spell_heal = 48085; break;
3712  default:
3713  TC_LOG_ERROR("spells", "Unknown Lightwell spell caster %u", m_caster->GetEntry());
3714  return;
3715  }
3716 
3717  // proc a spellcast
3718  if (Aura* chargesAura = m_caster->GetAura(59907))
3719  {
3721  if (chargesAura->ModCharges(-1))
3723  }
3724 
3725  return;
3726  }
3727  // Stoneclaw Totem
3728  case 55328: // Rank 1
3729  case 55329: // Rank 2
3730  case 55330: // Rank 3
3731  case 55332: // Rank 4
3732  case 55333: // Rank 5
3733  case 55335: // Rank 6
3734  case 55278: // Rank 7
3735  case 58589: // Rank 8
3736  case 58590: // Rank 9
3737  case 58591: // Rank 10
3738  {
3739  int32 basepoints0 = damage;
3740  // Cast Absorb on totems
3741  for (uint8 slot = SUMMON_SLOT_TOTEM; slot < MAX_TOTEM_SLOT; ++slot)
3742  {
3743  if (!unitTarget->m_SummonSlot[slot])
3744  continue;
3745 
3747  if (totem && totem->IsTotem())
3748  {
3749  m_caster->CastCustomSpell(totem, 55277, &basepoints0, NULL, NULL, true);
3750  }
3751  }
3752  // Glyph of Stoneclaw Totem
3753  if (AuraEffect* aur=unitTarget->GetAuraEffect(63298, 0))
3754  {
3755  basepoints0 *= aur->GetAmount();
3756  m_caster->CastCustomSpell(unitTarget, 55277, &basepoints0, NULL, NULL, true);
3757  }
3758  break;
3759  }
3760  case 45668: // Ultra-Advanced Proto-Typical Shortening Blaster
3761  {
3763  return;
3764 
3765  if (roll_chance_i(50)) // chance unknown, using 50
3766  return;
3767 
3768  static uint32 const spellPlayer[5] =
3769  {
3770  45674, // Bigger!
3771  45675, // Shrunk
3772  45678, // Yellow
3773  45682, // Ghost
3774  45684 // Polymorph
3775  };
3776 
3777  static uint32 const spellTarget[5] =
3778  {
3779  45673, // Bigger!
3780  45672, // Shrunk
3781  45677, // Yellow
3782  45681, // Ghost
3783  45683 // Polymorph
3784  };
3785 
3786  m_caster->CastSpell(m_caster, spellPlayer[urand(0, 4)], true);
3787  unitTarget->CastSpell(unitTarget, spellTarget[urand(0, 4)], true);
3788  break;
3789  }
3790  }
3791  break;
3792  }
3793  }
3794 
3795  // normal DB scripted effect
3796  TC_LOG_DEBUG("spells", "Spell ScriptStart spellid %u in EffectScriptEffect(%u)", m_spellInfo->Id, effIndex);
3798 }
Definition: SpellAuraEffects.h:30
Definition: SpellAuraDefines.h:63
Unit * GetVehicleBase() const
Definition: Unit.cpp:14341
void DespawnOrUnsummon(uint32 msTimeToDespawn=0)
Definition: Creature.cpp:1774
bool HasAura(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, ObjectGuid itemCasterGUID=ObjectGuid::Empty, uint32 reqEffMask=0) const
Definition: Unit.cpp:4240
SpellInfo const *const m_spellInfo
Definition: Spell.h:547
Definition: QuestDef.h:111
Unit *const m_caster
Definition: Spell.h:647
ScriptMapMap sSpellScripts
Definition: ObjectMgr.cpp:51
uint32 Id
Definition: SpellInfo.h:329
SpellInfo const * GetSpellInfo() const
Definition: SpellAuraEffects.h:46
ObjectGuid GetCasterGUID() const
Definition: SpellAuraEffects.h:40
SpellEffectInfo const * effectInfo
Definition: Spell.h:697
Definition: SharedDefines.h:29
void ScriptsStart(std::map< uint32, std::multimap< uint32, ScriptInfo > > const &scripts, uint32 id, Object *source, Object *target)
Put scripts in the execution queue.
Definition: MapScripts.cpp:33
Map * GetMap() const
Definition: Object.h:543
uint32 GetDisplayId() const
Definition: Unit.h:2012
virtual void TextEmote(std::string const &text, WorldObject const *target=nullptr, bool isBossEmote=false)
Definition: Unit.cpp:16403
int32 GetMaxDuration() const
Definition: SpellAuras.h:159
Definition: SpellInfo.h:326
Definition: SharedDefines.h:28
Aura * GetAura(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, ObjectGuid itemCasterGUID=ObjectGuid::Empty, uint32 reqEffMask=0) const
Definition: Unit.cpp:4151
SpellCastTargets m_targets
Definition: Spell.h:584
void SetMaxDuration(int32 duration)
Definition: SpellAuras.h:160
std::string const & GetName() const
Definition: Object.h:479
flag128 SpellFamilyFlags
Definition: SpellInfo.h:397
ObjectGuid m_SummonSlot[MAX_SUMMON_SLOT]
Definition: Unit.h:1929
void RemoveMovementImpairingAuras()
Definition: Unit.cpp:3865
void RemoveAuraFromStack(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
Definition: Unit.cpp:3602
std::list< AuraEffect * > AuraEffectList
Definition: Unit.h:1322
Definition: ObjectGuid.h:32
SpellEffectInfo const * GetEffect(uint32 index) const
Definition: Spell.h:624
Definition: SharedDefines.h:4638
arena_t NULL
Definition: jemalloc_internal.h:624
WorldLocation * destTarget
Definition: Spell.h:693
Aura * GetBase() const
Definition: SpellAuraEffects.h:41
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
Definition: Creature.h:467
Definition: Unit.h:543
Player * ToPlayer()
Definition: Object.h:191
TempSummon * ToTempSummon()
Definition: Unit.h:2206
virtual void UnSummon(uint32 msTime=0)
Definition: TemporarySummon.cpp:237
TypeID GetTypeId() const
Definition: Object.h:113
void DoCreateItem(uint32 i, uint32 itemtype, std::vector< int32 > const &bonusListIDs=std::vector< int32 >())
Definition: SpellEffects.cpp:1403
float CalcRadius(Unit *caster=NULL, Spell *=NULL) const
Definition: SpellInfo.cpp:655
Definition: Spell.h:289
Unit * unitTarget
Definition: Spell.h:690
void LoadEquipment(int8 id=1, bool force=false)
Definition: Creature.cpp:1429
Unit * m_originalCaster
Definition: Spell.h:653
void GetRandomPoint(Position const &srcPos, float distance, float &rand_x, float &rand_y, float &rand_z) const
Definition: Object.cpp:1799
float GetDistance(WorldObject const *obj) const
Definition: Object.cpp:1594
int32 damage
Definition: Spell.h:694
uint32 SpellFamilyName
Definition: SpellInfo.h:396
bool HasDst() const
Definition: Spell.h:229
std::string sprintf(CStringRef format, ArgList args)
Definition: format.h:3096
bool IsAlive() const
Definition: Unit.h:1692
G3D::int16 z
Definition: Vector3int16.h:46
Definition: SharedDefines.h:4010
uint32 urand(uint32 min, uint32 max)
Definition: Random.cpp:45
#define SUMMON_SLOT_TOTEM
Definition: Unit.h:1281
Definition: Item.h:259
Definition: Util.h:362
Definition: SharedDefines.h:4631
int32_t int32
Definition: Define.h:146
AuraEffectList const & GetAuraEffectsByType(AuraType type) const
Definition: Unit.h:1832
uint32_t uint32
Definition: Define.h:150
bool roll_chance_i(int chance)
Definition: Random.h:53
G3D::int16 y
Definition: Vector2int16.h:38
uint16_t uint16
Definition: Define.h:151
Item * itemTarget
Definition: Spell.h:691
ObjectGuid GetSummonerGUID() const
Definition: TemporarySummon.h:54
Definition: SharedDefines.h:232
int32 GetDuration() const
Definition: SpellAuras.h:163
int32 GetMaxDuration() const
Definition: SpellInfo.cpp:2497
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
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
Definition: ObjectGuid.h:33
Definition: SharedDefines.h:4623
Creature * GetCreature(ObjectGuid const &guid)
Definition: Map.cpp:3535
bool IsTotem() const
Definition: Unit.h:1405
Definition: SpellAuraDefines.h:167
Creature * ToCreature()
Definition: Object.h:194
uint8 getGender() const
Definition: Unit.h:1415
int32_t int32
Definition: g3dmath.h:167
uint32 rand32()
Definition: Random.cpp:64
AuraEffect * GetAuraEffect(uint32 spellId, uint8 effIndex, ObjectGuid casterGUID=ObjectGuid::Empty) const
Definition: Unit.cpp:4071
uint8_t uint8
Definition: Define.h:152
void RemoveAurasByType(AuraType auraType, std::function< bool(AuraApplication const *)> const &check)
Definition: Unit.cpp:3567
void SetDuration(int32 duration, bool withMods=false)
Definition: SpellAuras.cpp:806
uint32 GetEntry() const
Definition: Object.h:107
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
uint32_t uint32
Definition: g3dmath.h:168
G3D::int16 x
Definition: Vector2int16.h:37
Definition: SpellAuras.h:116
bool IsSummon() const
Definition: Unit.h:1401
uint32 GetHealth() const
Definition: Unit.h:1426
Definition: Unit.h:1305
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
void CastCustomSpell(Unit *victim, uint32 spellId, int32 const *bp0, int32 const *bp1, int32 const *bp2, bool triggered, Item *castItem=NULL, AuraEffect const *triggeredByAura=NULL, ObjectGuid originalCaster=ObjectGuid::Empty)
Definition: Unit.cpp:920
Definition: Unit.h:129
#define MAX_TOTEM_SLOT
Definition: Unit.h:1282
Definition: SpellAuraDefines.h:138
SpellEffectHandleMode effectHandleMode
Definition: Spell.h:696
uint32 CountPctFromMaxHealth(int32 pct) const
Definition: Unit.h:1435
void Spell::EffectSelfResurrect ( SpellEffIndex  effIndex)
4423 {
4425  return;
4426 
4427  if (!m_caster || m_caster->IsAlive())
4428  return;
4429  if (m_caster->GetTypeId() != TYPEID_PLAYER)
4430  return;
4431  if (!m_caster->IsInWorld())
4432  return;
4433 
4434  uint32 health = 0;
4435  uint32 mana = 0;
4436 
4437  // flat case
4438  if (damage < 0)
4439  {
4440  health = uint32(-damage);
4441  mana = effectInfo->MiscValue;
4442  }
4443  // percent case
4444  else
4445  {
4447  if (m_caster->GetMaxPower(POWER_MANA) > 0)
4449  }
4450 
4451  Player* player = m_caster->ToPlayer();
4452  player->ResurrectPlayer(0.0f);
4453 
4454  player->SetHealth(health);
4455  player->SetPower(POWER_MANA, mana);
4456  player->SetPower(POWER_RAGE, 0);
4457  player->SetPower(POWER_ENERGY, player->GetMaxPower(POWER_ENERGY));
4458  player->SetPower(POWER_FOCUS, 0);
4459 
4460  player->SpawnCorpseBones();
4461 }
int32 MiscValue
Definition: SpellInfo.h:253
Unit *const m_caster
Definition: Spell.h:647
SpellEffectInfo const * effectInfo
Definition: Spell.h:697
Definition: SharedDefines.h:249
Definition: SharedDefines.h:250
Player * ToPlayer()
Definition: Object.h:191
TypeID GetTypeId() const
Definition: Object.h:113
Definition: Spell.h:288
int32 damage
Definition: Spell.h:694
bool IsAlive() const
Definition: Unit.h:1692
uint32_t uint32
Definition: Define.h:150
T CalculatePct(T base, U pct)
Definition: Util.h:92
Definition: ObjectGuid.h:33
Definition: SharedDefines.h:251
int32 GetMaxPower(Powers power) const
Definition: Unit.cpp:11598
uint32_t uint32
Definition: g3dmath.h:168
bool IsInWorld() const
Definition: Object.h:100
Definition: SharedDefines.h:248
SpellEffectHandleMode effectHandleMode
Definition: Spell.h:696
uint32 CountPctFromMaxHealth(int32 pct) const
Definition: Unit.h:1435

+ Here is the call graph for this function:

void Spell::EffectSendEvent ( SpellEffIndex  effIndex)
Todo:
there should be a possibility to pass dest target to event script
1163 {
1164  // we do not handle a flag dropping or clicking on flag in battleground by sendevent system
1167  return;
1168 
1169  WorldObject* target = NULL;
1170 
1171  // call events for object target if present
1173  {
1174  if (unitTarget)
1175  target = unitTarget;
1176  else if (gameObjTarget)
1177  target = gameObjTarget;
1178  }
1179  else // if (effectHandleMode == SPELL_EFFECT_HANDLE_HIT)
1180  {
1181  // let's prevent executing effect handler twice in case when spell effect is capable of targeting an object
1182  // this check was requested by scripters, but it has some downsides:
1183  // now it's impossible to script (using sEventScripts) a cast which misses all targets
1184  // or to have an ability to script the moment spell hits dest (in a case when there are object targets present)
1186  return;
1187  // some spells have no target entries in dbc and they use focus target
1188  if (focusObject)
1189  target = focusObject;
1191  }
1192 
1193  TC_LOG_DEBUG("spells", "Spell ScriptStart %u for spellid %u in EffectSendEvent ", effectInfo->MiscValue, m_spellInfo->Id);
1194 
1195  if (ZoneScript* zoneScript = m_caster->GetZoneScript())
1196  zoneScript->ProcessEvent(target, effectInfo->MiscValue);
1197  else if (InstanceScript* instanceScript = m_caster->GetInstanceScript()) // needed in case Player is the caster
1198  instanceScript->ProcessEvent(target, effectInfo->MiscValue);
1199 
1201 }
GameObject * focusObject
Definition: Spell.h:706
int32 MiscValue
Definition: SpellInfo.h:253
GameObject * gameObjTarget
Definition: Spell.h:692
SpellInfo const *const m_spellInfo
Definition: Spell.h:547
Unit *const m_caster
Definition: Spell.h:647
uint32 Id
Definition: SpellInfo.h:329
Definition: SpellInfo.h:77
SpellEffectInfo const * effectInfo
Definition: Spell.h:697
void ScriptsStart(std::map< uint32, std::multimap< uint32, ScriptInfo > > const &scripts, uint32 id, Object *source, Object *target)
Put scripts in the execution queue.
Definition: MapScripts.cpp:33
Map * GetMap() const
Definition: Object.h:543
InstanceScript * GetInstanceScript()
Definition: Object.cpp:1540
arena_t NULL
Definition: jemalloc_internal.h:624
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
Definition: Object.h:423
Definition: Spell.h:289
Definition: ZoneScript.h:26
Unit * unitTarget
Definition: Spell.h:690
Definition: Spell.h:288
ScriptMapMap sEventScripts
Definition: ObjectMgr.cpp:52
ZoneScript * GetZoneScript() const
Definition: Object.h:551
Definition: InstanceScript.h:141
uint32 GetProvidedTargetMask() const
Definition: SpellInfo.cpp:681
Definition: SpellInfo.h:75
SpellEffectHandleMode effectHandleMode
Definition: Spell.h:696

+ Here is the call graph for this function:

void Spell::EffectSendTaxi ( SpellEffIndex  effIndex)
4636 {
4638  return;
4639 
4641  return;
4642 
4643  unitTarget->ToPlayer()->ActivateTaxiPathTo(effectInfo->MiscValue, m_spellInfo->Id);
4644 }
int32 MiscValue
Definition: SpellInfo.h:253
SpellInfo const *const m_spellInfo
Definition: Spell.h:547
uint32 Id
Definition: SpellInfo.h:329
SpellEffectInfo const * effectInfo
Definition: Spell.h:697
Player * ToPlayer()
Definition: Object.h:191
TypeID GetTypeId() const
Definition: Object.h:113
Definition: Spell.h:289
Unit * unitTarget
Definition: Spell.h:690
Definition: ObjectGuid.h:33
SpellEffectHandleMode effectHandleMode
Definition: Spell.h:696

+ Here is the call graph for this function:

void Spell::EffectSkill ( SpellEffIndex  effIndex)
5069 {
5071  return;
5072 
5073  TC_LOG_DEBUG("spells", "WORLD: SkillEFFECT");
5074 }
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
Definition: Spell.h:288
SpellEffectHandleMode effectHandleMode
Definition: Spell.h:696
void Spell::EffectSkinning ( SpellEffIndex  effIndex)
4464 {
4466  return;
4467 
4468  if (unitTarget->GetTypeId() != TYPEID_UNIT)
4469  return;
4470  if (m_caster->GetTypeId() != TYPEID_PLAYER)
4471  return;
4472 
4473  Creature* creature = unitTarget->ToCreature();
4474  int32 targetLevel = creature->getLevel();
4475 
4476  uint32 skill = creature->GetCreatureTemplate()->GetRequiredLootSkill();
4477 
4478  m_caster->ToPlayer()->SendLoot(creature->GetGUID(), LOOT_SKINNING);
4481 
4482  int32 reqValue = targetLevel < 10 ? 0 : targetLevel < 20 ? (targetLevel-10)*10 : targetLevel*5;
4483 
4484  int32 skillValue = m_caster->ToPlayer()->GetPureSkillValue(skill);
4485 
4486  // Double chances for elites
4487  m_caster->ToPlayer()->UpdateGatherSkill(skill, skillValue, reqValue, creature->isElite() ? 2 : 1);
4488 }
Definition: LootMgr.h:95
Unit *const m_caster
Definition: Spell.h:647
Definition: Unit.h:699
Definition: ObjectGuid.h:32
Definition: Creature.h:467
void SetFlag(uint16 index, uint32 newFlag)
Definition: Object.cpp:1199
Player * ToPlayer()
Definition: Object.h:191
uint8 getLevel() const
Definition: Unit.h:1408
TypeID GetTypeId() const
Definition: Object.h:113
CreatureTemplate const * GetCreatureTemplate() const
Definition: Creature.h:558
Definition: Spell.h:289
Unit * unitTarget
Definition: Spell.h:690
int32_t int32
Definition: Define.h:146
uint32_t uint32
Definition: Define.h:150
Definition: SharedDefines.h:4201
void RemoveFlag(uint16 index, uint32 oldFlag)
Definition: Object.cpp:1214
ObjectGuid const & GetGUID() const
Definition: Object.h:105
Definition: ObjectGuid.h:33
Definition: UpdateFields.h:109
Creature * ToCreature()
Definition: Object.h:194
bool isElite() const
Definition: Creature.cpp:1824
Definition: UpdateFields.h:30
SkillType GetRequiredLootSkill() const
Definition: Creature.h:150
SpellEffectHandleMode effectHandleMode
Definition: Spell.h:696

+ Here is the call graph for this function:

void Spell::EffectSkinPlayerCorpse ( SpellEffIndex  effIndex)
5100 {
5102  return;
5103 
5104  TC_LOG_DEBUG("spells", "Effect: SkinPlayerCorpse");
5105 
5106  Player* player = m_caster->ToPlayer();
5107  Player* target = unitTarget->ToPlayer();
5108  if (!player || !target || target->IsAlive())
5109  return;
5110 
5111  target->RemovedInsignia(player);
5112 }
Unit *const m_caster
Definition: Spell.h:647
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
Player * ToPlayer()
Definition: Object.h:191
Definition: Spell.h:289
Unit * unitTarget
Definition: Spell.h:690
SpellEffectHandleMode effectHandleMode
Definition: Spell.h:696

+ Here is the call graph for this function:

void Spell::EffectSpecCount ( SpellEffIndex  effIndex)
5557 {
5559  return;
5560 
5562  return;
5563 
5564  unitTarget->ToPlayer()->UpdateTalentGroupCount(damage);
5565 }
Player * ToPlayer()
Definition: Object.h:191
TypeID GetTypeId() const
Definition: Object.h:113
Definition: Spell.h:289
Unit * unitTarget
Definition: Spell.h:690
int32 damage
Definition: Spell.h:694
Definition: ObjectGuid.h:33
SpellEffectHandleMode effectHandleMode
Definition: Spell.h:696

+ Here is the call graph for this function:

void Spell::EffectSpiritHeal ( SpellEffIndex  effIndex)
5081 {
5083  return;
5084 
5085  /*
5086  if (unitTarget->GetTypeId() != TYPEID_PLAYER)
5087  return;
5088  if (!unitTarget->IsInWorld())
5089  return;
5090 
5091  //m_spellInfo->Effects[i].BasePoints; == 99 (percent?)
5092  //unitTarget->ToPlayer()->setResurrect(m_caster->GetGUID(), unitTarget->GetPositionX(), unitTarget->GetPositionY(), unitTarget->GetPositionZ(), unitTarget->GetMaxHealth(), unitTarget->GetMaxPower(POWER_MANA));
5093  unitTarget->ToPlayer()->ResurrectPlayer(1.0f);
5094  unitTarget->ToPlayer()->SpawnCorpseBones();
5095  */
5096 }
Definition: Spell.h:289
SpellEffectHandleMode effectHandleMode
Definition: Spell.h:696
void Spell::EffectStealBeneficialBuff ( SpellEffIndex  effIndex)
5115 {
5117  return;
5118 
5119  TC_LOG_DEBUG("spells", "Effect: StealBeneficialBuff");
5120 
5121  if (!unitTarget || unitTarget == m_caster) // can't steal from self
5122  return;
5123 
5124  DispelChargesList steal_list;
5125 
5126  // Create dispel mask by dispel type
5128  Unit::AuraMap const& auras = unitTarget->GetOwnedAuras();
5129  for (Unit::AuraMap::const_iterator itr = auras.begin(); itr != auras.end(); ++itr)
5130  {
5131  Aura* aura = itr->second;
5133  if (!aurApp)
5134  continue;
5135 
5136  if ((aura->GetSpellInfo()->GetDispelMask()) & dispelMask)
5137  {
5138  // Need check for passive? this
5139  if (!aurApp->IsPositive() || aura->IsPassive() || aura->GetSpellInfo()->AttributesEx4 & SPELL_ATTR4_NOT_STEALABLE)
5140  continue;
5141 
5142  // The charges / stack amounts don't count towards the total number of auras that can be dispelled.
5143  // Ie: A dispel on a target with 5 stacks of Winters Chill and a Polymorph has 1 / (1 + 1) -> 50% chance to dispell
5144  // Polymorph instead of 1 / (5 + 1) -> 16%.
5145  bool dispel_charges = (aura->GetSpellInfo()->AttributesEx7 & SPELL_ATTR7_DISPEL_CHARGES) != 0;
5146  uint8 charges = dispel_charges ? aura->GetCharges() : aura->GetStackAmount();
5147  if (charges > 0)
5148  steal_list.push_back(std::make_pair(aura, charges));
5149  }
5150  }
5151 
5152  if (steal_list.empty())
5153  return;
5154 
5155  // Ok if exist some buffs for dispel try dispel it
5156  DispelList success_list;
5158  dispelFailed.CasterGUID = m_caster->GetGUID();
5159  dispelFailed.VictimGUID = unitTarget->GetGUID();
5160  dispelFailed.SpellID = m_spellInfo->Id;
5161 
5162  // dispel N = damage buffs (or while exist buffs for dispel)
5163  for (int32 count = 0; count < damage && !steal_list.empty();)
5164  {
5165  // Random select buff for dispel
5166  DispelChargesList::iterator itr = steal_list.begin();
5167  std::advance(itr, urand(0, steal_list.size() - 1));
5168 
5169  int32 chance = itr->first->CalcDispelChance(unitTarget, !unitTarget->IsFriendlyTo(m_caster));
5170  // 2.4.3 Patch Notes: "Dispel effects will no longer attempt to remove effects that have 100% dispel resistance."
5171  if (!chance)
5172  {
5173  steal_list.erase(itr);
5174  continue;
5175  }
5176  else
5177  {
5178  if (roll_chance_i(chance))
5179  {
5180  success_list.push_back(std::make_pair(itr->first->GetId(), itr->first->GetCasterGUID()));
5181  --itr->second;
5182  if (itr->second <= 0)
5183  steal_list.erase(itr);
5184  }
5185  else
5186  dispelFailed.FailedSpells.push_back(int32(itr->first->GetId()));
5187 
5188  ++count;
5189  }
5190  }
5191 
5192  if (!dispelFailed.FailedSpells.empty())
5193  m_caster->SendMessageToSet(dispelFailed.Write(), true);
5194 
5195  if (success_list.empty())
5196  return;
5197 
5199  spellDispellLog.IsBreak = false; // TODO: use me
5200  spellDispellLog.IsSteal = true;
5201 
5202  spellDispellLog.TargetGUID = unitTarget->GetGUID();
5203  spellDispellLog.CasterGUID = m_caster->GetGUID();
5204  spellDispellLog.DispelledBySpellID = m_spellInfo->Id;
5205 
5206  for (std::pair<uint32, ObjectGuid> const& dispell : success_list)
5207  {
5209  dispellData.SpellID = dispell.first;
5210  dispellData.Harmful = false; // TODO: use me
5211  dispellData.Rolled = boost::none; // TODO: use me
5212  dispellData.Needed = boost::none; // TODO: use me
5213 
5214  unitTarget->RemoveAurasDueToSpellBySteal(dispell.first, dispell.second, m_caster);
5215 
5216  spellDispellLog.DispellData.emplace_back(dispellData);
5217  }
5218 
5219  m_caster->SendMessageToSet(spellDispellLog.Write(), true);
5220 }
SpellInfo const * GetSpellInfo() const
Definition: SpellAuras.h:130
bool IsPassive() const
Definition: SpellAuras.cpp:1026
int32 MiscValue
Definition: SpellInfo.h:253
ObjectGuid CasterGUID
Definition: SpellPackets.h:889
SpellInfo const *const m_spellInfo
Definition: Spell.h:547
Unit *const m_caster
Definition: Spell.h:647
uint32 Id
Definition: SpellInfo.h:329
std::vector< int32 > FailedSpells
Definition: SpellPackets.h:892
SpellEffectInfo const * effectInfo
Definition: Spell.h:697
ObjectGuid VictimGUID
Definition: SpellPackets.h:890
Definition: CombatLogPackets.h:209
int32 DispelledBySpellID
Definition: CombatLogPackets.h:219
AuraMap & GetOwnedAuras()
Definition: Unit.h:1779
Definition: SpellAuras.h:50
WorldPacket const * Write() override
Definition: SpellPackets.cpp:848
std::vector< SpellDispellData > DispellData
Definition: CombatLogPackets.h:216
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
DispelType
Definition: SharedDefines.h:1836
WorldPacket const * Write() override
Definition: CombatLogPackets.cpp:354
std::list< std::pair< Aura *, uint8 > > DispelChargesList
Definition: Unit.h:422
const AuraApplication * GetApplicationOfTarget(ObjectGuid guid) const
Definition: SpellAuras.h:233
Definition: SharedDefines.h:506
void advance(octet_iterator &it, distance_type n, octet_iterator end)
Definition: checked.h:190
bool IsSteal
Definition: CombatLogPackets.h:221
Definition: CombatLogPackets.h:201
uint32 AttributesEx7
Definition: SpellInfo.h:340
bool IsPositive() const
Definition: SpellAuras.h:81
Definition: Spell.h:289
Unit * unitTarget
Definition: Spell.h:690
int32 damage
Definition: Spell.h:694
Optional< int32 > Rolled
Definition: CombatLogPackets.h:205
bool IsBreak
Definition: CombatLogPackets.h:220
uint32 urand(uint32 min, uint32 max)
Definition: Random.cpp:45
std::multimap< uint32, Aura * > AuraMap
Definition: Unit.h:1311
int32_t int32
Definition: Define.h:146
uint32_t uint32
Definition: Define.h:150
bool roll_chance_i(int chance)
Definition: Random.h:53
bool IsFriendlyTo(Unit const *unit) const
Definition: Unit.cpp:7170
uint32 GetDispelMask() const
Definition: SpellInfo.cpp:2202
bool Harmful
Definition: CombatLogPackets.h:204
uint32 SpellID
Definition: SpellPackets.h:891
ObjectGuid const & GetGUID() const
Definition: Object.h:105
ObjectGuid TargetGUID
Definition: CombatLogPackets.h:218
std::list< std::pair< uint32, ObjectGuid > > DispelList
Definition: Spell.h:292
uint8 GetStackAmount() const
Definition: SpellAuras.h:179
int32_t int32
Definition: g3dmath.h:167
uint8 GetCharges() const
Definition: SpellAuras.h:170
void RemoveAurasDueToSpellBySteal(uint32 spellId, ObjectGuid casterGUID, Unit *stealer)
Definition: Unit.cpp:3647
uint8_t uint8
Definition: Define.h:152
virtual void SendMessageToSet(WorldPacket const *data, bool self)
Definition: Object.cpp:2144
Definition: SpellPackets.h:882
Definition: SpellAuras.h:116
int32 SpellID
Definition: CombatLogPackets.h:203
ObjectGuid CasterGUID
Definition: CombatLogPackets.h:217
Optional< int32 > Needed
Definition: CombatLogPackets.h:206
uint32 AttributesEx4
Definition: SpellInfo.h:337
SpellEffectHandleMode effectHandleMode
Definition: Spell.h:696
Definition: SharedDefines.h:618

+ Here is the call graph for this function:

void Spell::EffectStuck ( SpellEffIndex  effIndex)
3945 {
3947  return;
3948 
3949  if (!sWorld->getBoolConfig(CONFIG_CAST_UNSTUCK))
3950  return;
3951 
3952  Player* player = m_caster->ToPlayer();
3953  if (!player)
3954  return;
3955 
3956  TC_LOG_DEBUG("spells", "Spell Effect: Stuck");
3957  TC_LOG_DEBUG("spells", "Player %s (%s) used auto-unstuck future at map %u (%f, %f, %f)", player->GetName().c_str(), player->GetGUID().ToString().c_str(), player->GetMapId(), player->GetPositionX(), player->GetPositionY(), player->GetPositionZ());
3958 
3959  if (player->IsInFlight())
3960  return;
3961 
3962  // if player is dead without death timer is teleported to graveyard, otherwise not apply the effect
3963  if (player->isDead())
3964  {
3965  if (!player->GetDeathTimer())
3966  player->RepopAtGraveyard();
3967 
3968  return;
3969  }
3970 
3971  // the player dies if hearthstone is in cooldown, else the player is teleported to home
3972  if (player->GetSpellHistory()->HasCooldown(8690))
3973  {
3974  player->Kill(player);
3975  return;
3976  }
3977 
3978  player->TeleportTo(player->m_homebindMapId, player->m_homebindX, player->m_homebindY, player->m_homebindZ, player->GetOrientation(), TELE_TO_SPELL);
3979 
3980  // Stuck spell trigger Hearthstone cooldown
3981  SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(8690);
3982  if (!spellInfo)
3983  return;
3984  Spell spell(player, spellInfo, TRIGGERED_FULL_MASK);
3985  spell.SendSpellCooldown();
3986 }
Unit *const m_caster
Definition: Spell.h:647
Definition: SpellInfo.h:326
Will ignore most target checks (mostly DBC target checks)
Definition: Unit.h:479
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
#define sWorld
Definition: World.h:887
Player * ToPlayer()
Definition: Object.h:191
Definition: Spell.h:288
#define sSpellMgr
Definition: SpellMgr.h:756
Definition: World.h:116
SpellEffectHandleMode effectHandleMode
Definition: Spell.h:696
Definition: Spell.h:294

+ Here is the call graph for this function:

void Spell::EffectSummonChangeItem ( SpellEffIndex  effIndex)
1937 {
1939  return;
1940 
1941  if (m_caster->GetTypeId() != TYPEID_PLAYER)
1942  return;
1943 
1944  Player* player = m_caster->ToPlayer();
1945 
1946  // applied only to using item
1947  if (!m_CastItem)
1948  return;
1949 
1950  // ... only to item in own inventory/bank/equip_slot
1951  if (m_CastItem->GetOwnerGUID() != player->GetGUID())
1952  return;
1953 
1954  uint32 newitemid = effectInfo->ItemType;
1955  if (!newitemid)
1956  return;
1957 
1958  uint16 pos = m_CastItem->GetPos();
1959 
1960  Item* pNewItem = Item::CreateItem(newitemid, 1, player);
1961  if (!pNewItem)
1962  return;
1963 
1967 
1969  {
1971  player->DurabilityLoss(pNewItem, lossPercent);
1972  }
1973 
1974  if (player->IsInventoryPos(pos))
1975  {
1976  ItemPosCountVec dest;
1977  InventoryResult msg = player->CanStoreItem(m_CastItem->GetBagSlot(), m_CastItem->GetSlot(), dest, pNewItem, true);
1978  if (msg == EQUIP_ERR_OK)
1979  {
1980  player->DestroyItem(m_CastItem->GetBagSlot(), m_CastItem->GetSlot(), true);
1981 
1982  // prevent crash at access and unexpected charges counting with item update queue corrupt
1985 
1986  m_CastItem = NULL;
1988  m_castItemEntry = 0;
1989  m_castItemLevel = -1;
1990 
1991  player->StoreItem(dest, pNewItem, true);
1992  return;
1993  }
1994  }
1995  else if (player->IsBankPos(pos))
1996  {
1997  ItemPosCountVec dest;
1998  uint8 msg = player->CanBankItem(m_CastItem->GetBagSlot(), m_CastItem->GetSlot(), dest, pNewItem, true);
1999  if (msg == EQUIP_ERR_OK)
2000  {
2001  player->DestroyItem(m_CastItem->GetBagSlot(), m_CastItem->GetSlot(), true);
2002 
2003  // prevent crash at access and unexpected charges counting with item update queue corrupt
2006 
2007  m_CastItem = NULL;
2009  m_castItemEntry = 0;
2010  m_castItemLevel = -1;
2011 
2012  player->BankItem(dest, pNewItem, true);
2013  return;
2014  }
2015  }
2016  else if (player->IsEquipmentPos(pos))
2017  {
2018  uint16 dest;
2019 
2020  player->DestroyItem(m_CastItem->GetBagSlot(), m_CastItem->GetSlot(), true);
2021 
2022  uint8 msg = player->CanEquipItem(m_CastItem->GetSlot(), dest, pNewItem, true);
2023 
2024  if (msg == EQUIP_ERR_OK || msg == EQUIP_ERR_CLIENT_LOCKED_OUT)
2025  {
2026  if (msg == EQUIP_ERR_CLIENT_LOCKED_OUT) dest = EQUIPMENT_SLOT_MAINHAND;
2027 
2028  // prevent crash at access and unexpected charges counting with item update queue corrupt
2031 
2032  m_CastItem = NULL;
2034  m_castItemEntry = 0;
2035  m_castItemLevel = -1;
2036 
2037  player->EquipItem(dest, pNewItem, true);
2038  player->AutoUnequipOffhandIfNeed();
2039  return;
2040  }
2041  }
2042 
2043  // fail
2044  delete pNewItem;
2045 }
Unit *const m_caster
Definition: Spell.h:647
uint32 GetUInt32Value(uint16 index) const
Definition: Object.cpp:300
SpellEffectInfo const * effectInfo
Definition: Spell.h:697
Definition: Item.h:174
SpellCastTargets m_targets
Definition: Spell.h:584
EnchantmentSlot
Definition: Item.h:172
Item * GetItemTarget() const
Definition: Spell.h:203
Definition: UpdateFields.h:53
uint16 GetPos() const
Definition: Item.h:333
arena_t NULL
Definition: jemalloc_internal.h:624
uint32 m_castItemEntry
Definition: Spell.h:550
Item * m_CastItem
Definition: Spell.h:548
uint32 GetEnchantmentDuration(EnchantmentSlot slot) const
Definition: Item.h:352
Player * ToPlayer()
Definition: Object.h:191
void SetItemTarget(Item *item)
Definition: Spell.cpp:299
TypeID GetTypeId() const
Definition: Object.h:113
Definition: Item.h:48
Definition: Item.h:175
Definition: Spell.h:288
ObjectGuid m_castItemGUID
Definition: Spell.h:549
Definition: Item.h:259
uint32_t uint32
Definition: Define.h:150
uint16_t uint16
Definition: Define.h:151
static Item * CreateItem(uint32 itemEntry, uint32 count, Player const *player=NULL)
Definition: Item.cpp:1068
uint32 ItemType
Definition: SpellInfo.h:262
ObjectGuid GetOwnerGUID() const
Definition: Item.h:272
uint8 GetSlot() const
Definition: Item.h:329
void SetEnchantment(EnchantmentSlot slot, uint32 id, uint32 duration, uint32 charges, ObjectGuid caster=ObjectGuid::Empty)
Definition: Item.cpp:905
void Clear()
Definition: ObjectGuid.h:215
Definition: ObjectGuid.h:33
uint32 GetEnchantmentCharges(EnchantmentSlot slot) const
Definition: Item.h:353
Definition: Item.h:87
uint8_t uint8
Definition: Define.h:152
int32 m_castItemLevel
Definition: Spell.h:551
InventoryResult
Definition: Item.h:46
Definition: UpdateFields.h:54
uint8 GetBagSlot() const
Definition: Item.cpp:759
SpellEffectHandleMode effectHandleMode
Definition: Spell.h:696
uint32 GetEnchantmentId(EnchantmentSlot slot) const
Definition: Item.h:351

+ Here is the call graph for this function:

void Spell::EffectSummonCritter ( SpellEffIndex  effIndex)
void Spell::EffectSummonObject ( SpellEffIndex  effIndex)
4238 {
4240  return;
4241 
4242  uint32 go_id = effectInfo->MiscValue;
4244  ObjectGuid guid = m_caster->m_ObjectSlot[slot];
4245  if (!guid.IsEmpty())
4246  {
4247  if (GameObject* obj = m_caster->GetMap()->GetGameObject(guid))
4248  {
4249  // Recast case - null spell id to make auras not be removed on object remove from world
4250  if (m_spellInfo->Id == obj->GetSpellId())
4251  obj->SetSpellId(0);
4252  m_caster->RemoveGameObject(obj, true);
4253  }
4254  m_caster->m_ObjectSlot[slot].Clear();
4255  }
4256 
4257  GameObject* go = new GameObject();
4258 
4259  float x, y, z;
4260  // If dest location if present
4261  if (m_targets.HasDst())
4262  destTarget->GetPosition(x, y, z);
4263  // Summon in random point all other units if location present
4264  else
4266 
4267  Map* map = m_caster->GetMap();
4268  if (!go->Create(map->GenerateLowGuid<HighGuid::GameObject>(), go_id, map,
4269  0, x, y, z, m_caster->GetOrientation(), 0.0f, 0.0f, 0.0f, 0.0f, 0, GO_STATE_READY))
4270  {
4271  delete go;
4272  return;
4273  }
4274 
4275  go->CopyPhaseFrom(m_caster);
4276 
4277  //pGameObj->SetUInt32Value(GAMEOBJECT_LEVEL, m_caster->getLevel());
4278  int32 duration = m_spellInfo->GetDuration();
4279  go->SetRespawnTime(duration > 0 ? duration/IN_MILLISECONDS : 0);
4280  go->SetSpellId(m_spellInfo->Id);
4281  m_caster->AddGameObject(go);
4282 
4283  ExecuteLogEffectSummonObject(effIndex, go);
4284 
4285  map->AddToMap(go);
4286 
4287  m_caster->m_ObjectSlot[slot] = go->GetGUID();
4288 }
int32 MiscValue
Definition: SpellInfo.h:253
SpellInfo const *const m_spellInfo
Definition: Spell.h:547
Unit *const m_caster
Definition: Spell.h:647
uint32 Id
Definition: SpellInfo.h:329
SpellEffectInfo const * effectInfo
Definition: Spell.h:697
Map * GetMap() const
Definition: Object.h:543
SpellCastTargets m_targets
Definition: Spell.h:584
void ExecuteLogEffectSummonObject(uint8 effIndex, WorldObject *obj)
Definition: Spell.cpp:4214
void CopyPhaseFrom(WorldObject *obj, bool update=false)
Definition: Object.cpp:2915
WorldLocation * destTarget
Definition: Spell.h:693
void SetRespawnTime(int32 respawn)
Definition: GameObject.h:945
int32 GetDuration() const
Definition: SpellInfo.cpp:2490
float GetOrientation() const
Definition: Position.h:107
Definition: Spell.h:288
bool HasDst() const
Definition: Spell.h:229
G3D::int16 z
Definition: Vector3int16.h:46
void GetPosition(float &x, float &y) const
Definition: Position.h:109
bool AddToMap(T *)
Definition: Map.cpp:566
int32_t int32
Definition: Define.h:146
uint32_t uint32
Definition: Define.h:150
G3D::int16 y
Definition: Vector2int16.h:38
#define DEFAULT_WORLD_OBJECT_SIZE
Definition: Object.h:44
Definition: GameObject.h:880
void AddGameObject(GameObject *gameObj)
Definition: Unit.cpp:4747
Definition: Map.h:259
Definition: GameObject.h:823
void Clear()
Definition: ObjectGuid.h:215
ObjectGuid const & GetGUID() const
Definition: Object.h:105
void RemoveGameObject(GameObject *gameObj, bool del)
Definition: Unit.cpp:4765
ObjectGuid m_ObjectSlot[MAX_GAMEOBJECT_SLOT]
Definition: Unit.h:1930
Definition: Common.h:103
bool Create(ObjectGuid::LowType guidlow, uint32 name_id, Map *map, uint32 phaseMask, float x, float y, float z, float ang, float rotation0, float rotation1, float rotation2, float rotation3, uint32 animprogress, GOState go_state, uint32 artKit=0)
Definition: GameObject.cpp:173
void SetSpellId(uint32 id)
Definition: GameObject.h:928
uint8_t uint8
Definition: Define.h:152
Definition: ObjectGuid.h:189
G3D::int16 x
Definition: Vector2int16.h:37
ObjectGuid::LowType GenerateLowGuid()
Definition: Map.h:561
GameObject * GetGameObject(ObjectGuid const &guid)
Definition: Map.cpp:3545
uint32 Effect
Definition: SpellInfo.h:243
Definition: SharedDefines.h:1114
bool IsEmpty() const
Definition: ObjectGuid.h:242
void GetClosePoint(float &x, float &y, float &z, float size, float distance2d=0, float angle=0) const
Definition: Object.cpp:2623
SpellEffectHandleMode effectHandleMode
Definition: Spell.h:696

+ Here is the call graph for this function:

void Spell::EffectSummonObjectWild ( SpellEffIndex  effIndex)
3213 {
3215  return;
3216 
3217  uint32 gameobject_id = effectInfo->MiscValue;
3218 
3219  GameObject* pGameObj = new GameObject;
3220 
3221  WorldObject* target = focusObject;
3222  if (!target)
3223  target = m_caster;
3224 
3225  float x, y, z;
3226  if (m_targets.HasDst())
3227  destTarget->GetPosition(x, y, z);
3228  else
3230 
3231  Map* map = target->GetMap();
3232 
3233  if (!pGameObj->Create(map->GenerateLowGuid<HighGuid::GameObject>(), gameobject_id, map,
3234  m_caster->GetPhaseMask(), x, y, z, target->GetOrientation(), 0.0f, 0.0f, 0.0f, 0.0f, 100, GO_STATE_READY))
3235  {
3236  delete pGameObj;
3237  return;
3238  }
3239 
3240  pGameObj->CopyPhaseFrom(m_caster);
3241 
3242  int32 duration = m_spellInfo->GetDuration();
3243 
3244  pGameObj->SetRespawnTime(duration > 0 ? duration/IN_MILLISECONDS : 0);
3245  pGameObj->SetSpellId(m_spellInfo->Id);
3246 
3247  ExecuteLogEffectSummonObject(effIndex, pGameObj);
3248 
3249  // Wild object not have owner and check clickable by players
3250  map->AddToMap(pGameObj);
3251 
3252  if (pGameObj->GetGoType() == GAMEOBJECT_TYPE_FLAGDROP)
3253  if (Player* player = m_caster->ToPlayer())
3254  if (Battleground* bg = player->GetBattleground())
3255  bg->SetDroppedFlagGUID(pGameObj->GetGUID(), player->GetTeam() == ALLIANCE ? TEAM_HORDE: TEAM_ALLIANCE);
3256 
3257  if (uint32 linkedEntry = pGameObj->GetGOInfo()->GetLinkedGameObjectEntry())
3258  {
3259  GameObject* linkedGO = new GameObject;
3260  if (linkedGO->Create(map->GenerateLowGuid<HighGuid::GameObject>(), linkedEntry, map,
3261  m_caster->GetPhaseMask(), x, y, z, target->GetOrientation(), 0.0f, 0.0f, 0.0f, 0.0f, 100, GO_STATE_READY))
3262  {
3263  linkedGO->CopyPhaseFrom(m_caster);
3264 
3265  linkedGO->SetRespawnTime(duration > 0 ? duration/IN_MILLISECONDS : 0);
3266  linkedGO->SetSpellId(m_spellInfo->Id);
3267 
3268  ExecuteLogEffectSummonObject(effIndex, linkedGO);
3269 
3270  // Wild object not have owner and check clickable by players
3271  map->AddToMap(linkedGO);
3272  }
3273  else
3274  {
3275  delete linkedGO;
3276  linkedGO = NULL;
3277  return;
3278  }
3279  }
3280 }
GameObject * focusObject
Definition: Spell.h:706
int32 MiscValue
Definition: SpellInfo.h:253
SpellInfo const *const m_spellInfo
Definition: Spell.h:547
Unit *const m_caster
Definition: Spell.h:647
uint32 Id
Definition: SpellInfo.h:329
uint32 GetLinkedGameObjectEntry() const
Definition: GameObject.h:697
SpellEffectInfo const * effectInfo
Definition: Spell.h:697
Map * GetMap() const
Definition: Object.h:543
SpellCastTargets m_targets
Definition: Spell.h:584
arena_t NULL
Definition: jemalloc_internal.h:624
Definition: SharedDefines.h:2091
void ExecuteLogEffectSummonObject(uint8 effIndex, WorldObject *obj)
Definition: Spell.cpp:4214
void CopyPhaseFrom(WorldObject *obj, bool update=false)
Definition: Object.cpp:2915
WorldLocation * destTarget
Definition: Spell.h:693
Definition: Object.h:423
void SetRespawnTime(int32 respawn)
Definition: GameObject.h:945
Player * ToPlayer()
Definition: Object.h:191
Definition: SharedDefines.h:1000
int32 GetDuration() const
Definition: SpellInfo.cpp:2490
float GetOrientation() const
Definition: Position.h:107
Definition: Spell.h:288
uint32 GetPhaseMask() const
Definition: Object.h:461
bool HasDst() const
Definition: Spell.h:229
G3D::int16 z
Definition: Vector3int16.h:46
void GetPosition(float &x, float &y) const
Definition: Position.h:109
bool AddToMap(T *)
Definition: Map.cpp:566
int32_t int32
Definition: Define.h:146
uint32_t uint32
Definition: Define.h:150
GameObjectTemplate const * GetGOInfo() const
Definition: GameObject.h:894
G3D::int16 y
Definition: Vector2int16.h:38
Definition: SharedDefines.h:992
#define DEFAULT_WORLD_OBJECT_SIZE
Definition: Object.h:44
Definition: GameObject.h:880
Definition: Map.h:259
Definition: GameObject.h:823
ObjectGuid const & GetGUID() const
Definition: Object.h:105
GameobjectTypes GetGoType() const
Definition: GameObject.h:964
Definition: Common.h:103
bool Create(ObjectGuid::LowType guidlow, uint32 name_id, Map *map, uint32 phaseMask, float x, float y, float z, float ang, float rotation0, float rotation1, float rotation2, float rotation3, uint32 animprogress, GOState go_state, uint32 artKit=0)
Definition: GameObject.cpp:173
void SetSpellId(uint32 id)
Definition: GameObject.h:928
Definition: Battleground.h:235
G3D::int16 x
Definition: Vector2int16.h:37
ObjectGuid::LowType GenerateLowGuid()
Definition: Map.h:561
Definition: SharedDefines.h:993
void GetClosePoint(float &x, float &y, float &z, float size, float distance2d=0, float angle=0) const
Definition: Object.cpp:2623
SpellEffectHandleMode effectHandleMode
Definition: Spell.h:696

+ Here is the call graph for this function:

void Spell::EffectSummonPet ( SpellEffIndex  effIndex)
2801 {
2803  return;
2804 
2805  Player* owner = NULL;
2806  if (m_originalCaster)
2807  {
2808  owner = m_originalCaster->ToPlayer();
2809  if (!owner && m_originalCaster->IsTotem())
2811  }
2812 
2813  uint32 petentry = effectInfo->MiscValue;
2814 
2815  if (!owner)
2816  {
2817  SummonPropertiesEntry const* properties = sSummonPropertiesStore.LookupEntry(67);
2818  if (properties)
2819  SummonGuardian(effIndex, petentry, properties, 1);
2820  return;
2821  }
2822 
2823  Pet* OldSummon = owner->GetPet();
2824 
2825  // if pet requested type already exist
2826  if (OldSummon)
2827  {
2828  if (petentry == 0 || OldSummon->GetEntry() == petentry)
2829  {
2830  // pet in corpse state can't be summoned
2831  if (OldSummon->isDead())
2832  return;
2833 
2834  ASSERT(OldSummon->GetMap() == owner->GetMap());
2835 
2836  //OldSummon->GetMap()->Remove(OldSummon->ToCreature(), false);
2837 
2838  float px, py, pz;
2839  owner->GetClosePoint(px, py, pz, OldSummon->GetObjectSize());
2840 
2841  OldSummon->NearTeleportTo(px, py, pz, OldSummon->GetOrientation());
2842  //OldSummon->Relocate(px, py, pz, OldSummon->GetOrientation());
2843  //OldSummon->SetMap(owner->GetMap());
2844  //owner->GetMap()->Add(OldSummon->ToCreature());
2845 
2846  if (owner->GetTypeId() == TYPEID_PLAYER && OldSummon->isControlled())
2847  owner->ToPlayer()->PetSpellInitialize();
2848 
2849  return;
2850  }
2851 
2852  if (owner->GetTypeId() == TYPEID_PLAYER)
2853  owner->ToPlayer()->RemovePet(OldSummon, (OldSummon->getPetType() == HUNTER_PET ? PET_SAVE_AS_DELETED : PET_SAVE_NOT_IN_SLOT), false);
2854  else
2855  return;
2856  }
2857 
2858  float x, y, z;
2859  owner->GetClosePoint(x, y, z, owner->GetObjectSize());
2860  Pet* pet = owner->SummonPet(petentry, x, y, z, owner->GetOrientation(), SUMMON_PET, 0);
2861  if (!pet)
2862  return;
2863 
2864  if (m_caster->GetTypeId() == TYPEID_UNIT)
2865  {
2866  if (m_caster->IsTotem())
2868  else
2870  }
2871 
2873 
2874  // generate new name for summon pet
2875  std::string new_name=sObjectMgr->GeneratePetName(petentry);
2876  if (!new_name.empty())
2877  pet->SetName(new_name);
2878 
2879  ExecuteLogEffectSummonObject(effIndex, pet);
2880 }
int32 MiscValue
Definition: SpellInfo.h:253
SpellInfo const *const m_spellInfo
Definition: Spell.h:547
Unit *const m_caster
Definition: Spell.h:647
uint32 Id
Definition: SpellInfo.h:329
Definition: PetDefines.h:24
SpellEffectInfo const * effectInfo
Definition: Spell.h:697
Definition: Unit.h:1131
Map * GetMap() const
Definition: Object.h:543
DBCStorage< SummonPropertiesEntry > sSummonPropertiesStore(SummonPropertiesfmt)
Definition: UpdateFields.h:134
Definition: Unit.h:1130
Definition: ObjectGuid.h:32
arena_t NULL
Definition: jemalloc_internal.h:624
void SetUInt32Value(uint16 index, uint32 value)
Definition: Object.cpp:996
void ExecuteLogEffectSummonObject(uint8 effIndex, WorldObject *obj)
Definition: Spell.cpp:4214
void SetName(std::string const &newname)
Definition: Object.h:480
#define sObjectMgr
Definition: ObjectMgr.h:1567
Definition: PetDefines.h:25
Player * ToPlayer()
Definition: Object.h:191
TypeID GetTypeId() const
Definition: Object.h:113
float GetOrientation() const
Definition: Position.h:107
Unit * m_originalCaster
Definition: Spell.h:653
Definition: Spell.h:288
void NearTeleportTo(float x, float y, float z, float orientation, bool casting=false)
Definition: Unit.cpp:15407
G3D::int16 z
Definition: Vector3int16.h:46
bool isControlled() const
Definition: Pet.h:59
uint32_t uint32
Definition: Define.h:150
G3D::int16 y
Definition: Vector2int16.h:38
bool isDead() const
Definition: Unit.h:1694
Definition: ObjectGuid.h:33
bool IsTotem() const
Definition: Unit.h:1405
Definition: PetDefines.h:38
#define ASSERT
Definition: Errors.h:55
uint32 GetEntry() const
Definition: Object.h:107
Definition: PetDefines.h:34
G3D::int16 x
Definition: Vector2int16.h:37
float GetObjectSize() const
Definition: Object.cpp:2656
void SetReactState(ReactStates st)
Definition: Creature.h:502
void SummonGuardian(uint32 i, uint32 entry, SummonPropertiesEntry const *properties, uint32 numSummons)
Definition: SpellEffects.cpp:5458
Definition: Pet.h:46
PetType getPetType() const
Definition: Pet.h:57
Player * GetCharmerOrOwnerPlayerOrPlayerItself() const
Definition: Unit.cpp:7560
Definition: DBCStructure.h:1242
SpellEffectHandleMode effectHandleMode
Definition: Spell.h:696

+ Here is the call graph for this function:

void Spell::EffectSummonPlayer ( SpellEffIndex  effIndex)
3989 {
3990  // workaround - this effect should not use target map
3992  return;
3993 
3995  return;
3996 
3997  // Evil Twin (ignore player summon, but hide this for summoner)
3998  if (unitTarget->HasAura(23445))
3999  return;
4000 
4001  float x, y, z;
4002  m_caster->GetPosition(x, y, z);
4003 
4004  unitTarget->ToPlayer()->SetSummonPoint(m_caster->GetMapId(), x, y, z);
4005 
4006  WorldPacket data(SMSG_SUMMON_REQUEST, 8+4+4);
4007  data << m_caster->GetGUID(); // summoner guid
4008  data << uint32(m_caster->GetZoneId()); // summoner zone
4009  data << uint32(MAX_PLAYER_SUMMON_DELAY*IN_MILLISECONDS); // auto decline after msecs
4010  unitTarget->ToPlayer()->GetSession()->SendPacket(&data);
4011 }
bool HasAura(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, ObjectGuid itemCasterGUID=ObjectGuid::Empty, uint32 reqEffMask=0) const
Definition: Unit.cpp:4240
Unit *const m_caster
Definition: Spell.h:647
uint32 GetZoneId() const
Definition: Object.cpp:1525
Player * ToPlayer()
Definition: Object.h:191
TypeID GetTypeId() const
Definition: Object.h:113
Definition: Opcodes.h:1562
Definition: Spell.h:289
Unit * unitTarget
Definition: Spell.h:690
G3D::int16 z
Definition: Vector3int16.h:46
void GetPosition(float &x, float &y) const
Definition: Position.h:109
G3D::int16 y
Definition: Vector2int16.h:38
#define MAX_PLAYER_SUMMON_DELAY
uint32 GetMapId() const
Definition: Position.h:254
ObjectGuid const & GetGUID() const
Definition: Object.h:105
Definition: ObjectGuid.h:33
Definition: Common.h:103
uint32_t uint32
Definition: g3dmath.h:168
G3D::int16 x
Definition: Vector2int16.h:37
Definition: WorldPacket.h:26
SpellEffectHandleMode effectHandleMode
Definition: Spell.h:696

+ Here is the call graph for this function:

void Spell::EffectSummonRaFFriend ( SpellEffIndex  effIndex)
5747 {
5749  return;
5750 
5752  return;
5753 
5755 }
Unit *const m_caster
Definition: Spell.h:647
SpellEffectInfo const * effectInfo
Definition: Spell.h:697
TypeID GetTypeId() const
Definition: Object.h:113
uint32 TriggerSpell
Definition: SpellInfo.h:263
Definition: Spell.h:289
Unit * unitTarget
Definition: Spell.h:690
Definition: ObjectGuid.h:33
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
SpellEffectHandleMode effectHandleMode
Definition: Spell.h:696

+ Here is the call graph for this function:

void Spell::EffectSummonType ( SpellEffIndex  effIndex)
2070 {
2072  return;
2073 
2074  uint32 entry = effectInfo->MiscValue;
2075  if (!entry)
2076  return;
2077 
2078  SummonPropertiesEntry const* properties = sSummonPropertiesStore.LookupEntry(effectInfo->MiscValueB);
2079  if (!properties)
2080  {
2081  TC_LOG_ERROR("spells", "EffectSummonType: Unhandled summon type %u", effectInfo->MiscValueB);
2082  return;
2083  }
2084 
2085  if (!m_originalCaster)
2086  return;
2087 
2088  int32 duration = m_spellInfo->GetDuration();
2089  if (Player* modOwner = m_originalCaster->GetSpellModOwner())
2090  modOwner->ApplySpellMod(m_spellInfo->Id, SPELLMOD_DURATION, duration);
2091 
2092  TempSummon* summon = NULL;
2093 
2094  // determine how many units should be summoned
2095  uint32 numSummons;
2096 
2097  // some spells need to summon many units, for those spells number of summons is stored in effect value
2098  // however so far noone found a generic check to find all of those (there's no related data in summonproperties.dbc
2099  // and in spell attributes, possibly we need to add a table for those)
2100  // so here's a list of MiscValueB values, which is currently most generic check
2101  switch (properties->ID)
2102  {
2103  case 64:
2104  case 61:
2105  case 1101:
2106  case 66:
2107  case 648:
2108  case 2301:
2109  case 1061:
2110  case 1261:
2111  case 629:
2112  case 181:
2113  case 715:
2114  case 1562:
2115  case 833:
2116  case 1161:
2117  case 713:
2118  numSummons = (damage > 0) ? damage : 1;
2119  break;
2120  default:
2121  numSummons = 1;
2122  break;
2123  }
2124 
2125  switch (properties->Category)
2126  {
2127  case SUMMON_CATEGORY_WILD:
2128  case SUMMON_CATEGORY_ALLY:
2129  case SUMMON_CATEGORY_UNK:
2130  if (properties->Flags & 512)
2131  {
2132  SummonGuardian(effIndex, entry, properties, numSummons);
2133  break;
2134  }
2135  switch (properties->Type)
2136  {
2137  case SUMMON_TYPE_PET:
2138  case SUMMON_TYPE_GUARDIAN:
2139  case SUMMON_TYPE_GUARDIAN2:
2140  case SUMMON_TYPE_MINION:
2141  SummonGuardian(effIndex, entry, properties, numSummons);
2142  break;
2143  // Summons a vehicle, but doesn't force anyone to enter it (see SUMMON_CATEGORY_VEHICLE)
2144  case SUMMON_TYPE_VEHICLE:
2145  case SUMMON_TYPE_VEHICLE2:
2146  summon = m_caster->GetMap()->SummonCreature(entry, *destTarget, properties, duration, m_originalCaster, m_spellInfo->Id);
2147  break;
2148  case SUMMON_TYPE_LIGHTWELL:
2149  case SUMMON_TYPE_TOTEM:
2150  {
2151  summon = m_caster->GetMap()->SummonCreature(entry, *destTarget, properties, duration, m_originalCaster, m_spellInfo->Id);
2152  if (!summon || !summon->IsTotem())
2153  return;
2154 
2155  // Mana Tide Totem
2156  if (m_spellInfo->Id == 16190)
2158 
2159  if (damage) // if not spell info, DB values used
2160  {
2161  summon->SetMaxHealth(damage);
2162  summon->SetHealth(damage);
2163  }
2164  break;
2165  }
2166  case SUMMON_TYPE_MINIPET:
2167  {
2168  summon = m_caster->GetMap()->SummonCreature(entry, *destTarget, properties, duration, m_originalCaster, m_spellInfo->Id);
2169  if (!summon || !summon->HasUnitTypeMask(UNIT_MASK_MINION))
2170  return;
2171 
2172  summon->SelectLevel(); // some summoned creaters have different from 1 DB data for level/hp
2174 
2176 
2177  summon->AI()->EnterEvadeMode();
2178  break;
2179  }
2180  default:
2181  {
2182  float radius = effectInfo->CalcRadius();
2183 
2184  TempSummonType summonType = (duration == 0) ? TEMPSUMMON_DEAD_DESPAWN : TEMPSUMMON_TIMED_DESPAWN;
2185 
2186  for (uint32 count = 0; count < numSummons; ++count)
2187  {
2188  Position pos;
2189  if (count == 0)
2190  pos = *destTarget;
2191  else
2192  // randomize position for multiple summons
2193  pos = m_caster->GetRandomPoint(*destTarget, radius);
2194 
2195  summon = m_originalCaster->SummonCreature(entry, pos, summonType, duration);
2196  if (!summon)
2197  continue;
2198 
2199  if (properties->Category == SUMMON_CATEGORY_ALLY)
2200  {
2204  }
2205 
2206  ExecuteLogEffectSummonObject(effIndex, summon);
2207  }
2208  return;
2209  }
2210  }//switch
2211  break;
2212  case SUMMON_CATEGORY_PET:
2213  SummonGuardian(effIndex, entry, properties, numSummons);
2214  break;
2216  summon = m_caster->GetMap()->SummonCreature(entry, *destTarget, properties, duration, m_originalCaster, m_spellInfo->Id);
2217  break;
2219  // Summoning spells (usually triggered by npc_spellclick) that spawn a vehicle and that cause the clicker
2220  // to cast a ride vehicle spell on the summoned unit.
2221  summon = m_originalCaster->GetMap()->SummonCreature(entry, *destTarget, properties, duration, m_caster, m_spellInfo->Id);
2222  if (!summon || !summon->IsVehicle())
2223  return;
2224 
2225  // The spell that this effect will trigger. It has SPELL_AURA_CONTROL_VEHICLE
2227  SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(effectInfo->CalcValue());
2228  if (spellInfo && spellInfo->HasAura(m_originalCaster->GetMap()->GetDifficultyID(), SPELL_AURA_CONTROL_VEHICLE))
2229  spellId = spellInfo->Id;
2230 
2231  // Hard coded enter vehicle spell
2232  m_originalCaster->CastSpell(summon, spellId, true);
2233 
2234  uint32 faction = properties->Faction;
2235  if (!faction)
2236  faction = m_originalCaster->getFaction();
2237 
2238  summon->setFaction(faction);
2239  break;
2240  }
2241 
2242  if (summon)
2243  {
2245  ExecuteLogEffectSummonObject(effIndex, summon);
2246  }
2247 }
int32 MiscValue
Definition: SpellInfo.h:253
SpellInfo const *const m_spellInfo
Definition: Spell.h:547
Unit *const m_caster
Definition: Spell.h:647
uint32 Id
Definition: SpellInfo.h:329
Definition: SharedDefines.h:4396
SpellEffectInfo const * effectInfo
Definition: Spell.h:697
Definition: TemporarySummon.h:40
TempSummon * SummonCreature(uint32 entry, Position const &pos, SummonPropertiesEntry const *properties=NULL, uint32 duration=0, Unit *summoner=NULL, uint32 spellId=0, uint32 vehId=0)
Definition: Object.cpp:2219
Map * GetMap() const
Definition: Object.h:543
Definition: SharedDefines.h:4404
bool IsVehicle() const
Definition: Unit.h:1406
Definition: SharedDefines.h:4400
DBCStorage< SummonPropertiesEntry > sSummonPropertiesStore(SummonPropertiesfmt)
Definition: SpellInfo.h:326
Definition: Unit.h:87
uint32 getFaction() const
Definition: Unit.h:1466
uint64 npcflag
Definition: Creature.h:98
Definition: SharedDefines.h:4406
Definition: SharedDefines.h:4385
Difficulty GetDifficultyID() const
Definition: Map.h:390
virtual void EnterEvadeMode(EvadeReason why=EVADE_REASON_OTHER)
Definition: CreatureAI.cpp:168
Definition: UpdateFields.h:134
uint32 Faction
Definition: DBCStructure.h:1246
arena_t NULL
Definition: jemalloc_internal.h:624
void SetUInt32Value(uint16 index, uint32 value)
Definition: Object.cpp:996
Definition: VehicleDefines.h:74
void ExecuteLogEffectSummonObject(uint8 effIndex, WorldObject *obj)
Definition: Spell.cpp:4214
WorldLocation * destTarget
Definition: Spell.h:693
Definition: SharedDefines.h:4387
Definition: Object.h:60
void SetFlag(uint16 index, uint32 newFlag)
Definition: Object.cpp:1199
TempSummonType
Definition: Object.h:52
uint32 Flags
Definition: DBCStructure.h:1249
Definition: Unit.h:859
Definition: Unit.h:681
bool HasAura(uint32 difficulty, AuraType aura) const
Definition: SpellInfo.cpp:1193
int32 GetDuration() const
Definition: SpellInfo.cpp:2490
void setFaction(uint32 faction)
Definition: Unit.h:1467
CreatureTemplate const * GetCreatureTemplate() const
Definition: Creature.h:558
float CalcRadius(Unit *caster=NULL, Spell *=NULL) const
Definition: SpellInfo.cpp:655
Unit * m_originalCaster
Definition: Spell.h:653
void GetRandomPoint(Position const &srcPos, float distance, float &rand_x, float &rand_y, float &rand_z) const
Definition: Object.cpp:1799
Definition: Spell.h:288
int32 damage
Definition: Spell.h:694
Definition: SpellAuraDefines.h:296
uint32 ID
Definition: DBCStructure.h:1244
Definition: Object.h:56
Definition: SharedDefines.h:4398
CreatureAI * AI() const
Definition: Creature.h:525
#define sSpellMgr
Definition: SpellMgr.h:756
Definition: SharedDefines.h:4401
int32_t int32
Definition: Define.h:146
uint32_t uint32
Definition: Define.h:150
Definition: SharedDefines.h:4386
void SetMaxHealth(uint32 val)
Definition: Unit.cpp:11565
Definition: SharedDefines.h:4384
void SetOwnerGUID(ObjectGuid owner)
Definition: Unit.cpp:7517
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
uint32 Type
Definition: DBCStructure.h:1247
Definition: Unit.h:682
ObjectGuid const & GetGUID() const
Definition: Object.h:105
Definition: SharedDefines.h:4389
void SelectLevel()
Definition: Creature.cpp:1154
Player * GetSpellModOwner() const
Definition: Unit.cpp:12691
Definition: UpdateFields.h:109
bool IsTotem() const
Definition: Unit.h:1405
uint32 Category
Definition: DBCStructure.h:1245
Definition: SharedDefines.h:4405
uint32 HasUnitTypeMask(uint32 mask) const
Definition: Unit.h:1399
Definition: SharedDefines.h:4397
Definition: Position.h:27
void SetCreatorGUID(ObjectGuid creator)
Definition: Unit.h:1701
Definition: UpdateFields.h:135
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
void SetUInt64Value(uint16 index, uint64 value)
Definition: Object.cpp:1017
void SetHealth(uint32 val)
Definition: Unit.cpp:11537
Definition: SharedDefines.h:4388
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
void SummonGuardian(uint32 i, uint32 entry, SummonPropertiesEntry const *properties, uint32 numSummons)
Definition: SpellEffects.cpp:5458
TempSummon * SummonCreature(uint32 id, Position const &pos, TempSummonType spwtype=TEMPSUMMON_MANUAL_DESPAWN, uint32 despwtime=0, uint32 vehId=0) const
Definition: Object.cpp:2346
Definition: SharedDefines.h:4399
int32 MiscValueB
Definition: SpellInfo.h:254
Definition: DBCStructure.h:1242
SpellEffectHandleMode effectHandleMode
Definition: Spell.h:696
uint32 CountPctFromMaxHealth(int32 pct) const
Definition: Unit.h:1435

+ Here is the call graph for this function:

void Spell::EffectTameCreature ( SpellEffIndex  effIndex)
2745 {
2747  return;
2748 
2749  if (!m_caster->GetPetGUID().IsEmpty())
2750  return;
2751 
2752  if (!unitTarget)
2753  return;
2754 
2755  if (unitTarget->GetTypeId() != TYPEID_UNIT)
2756  return;
2757 
2758  Creature* creatureTarget = unitTarget->ToCreature();
2759 
2760  if (creatureTarget->IsPet())
2761  return;
2762 
2763  if (m_caster->getClass() != CLASS_HUNTER)
2764  return;
2765 
2766  // cast finish successfully
2767  //SendChannelUpdate(0);
2768  finish();
2769 
2770  Pet* pet = m_caster->CreateTamedPetFrom(creatureTarget, m_spellInfo->Id);
2771  if (!pet) // in very specific state like near world end/etc.
2772  return;
2773 
2774  // "kill" original creature
2775  creatureTarget->DespawnOrUnsummon();
2776 
2777  uint8 level = (creatureTarget->getLevel() < (m_caster->getLevel() - 5)) ? (m_caster->getLevel() - 5) : creatureTarget->getLevel();
2778 
2779  // prepare visual effect for levelup
2780  pet->SetUInt32Value(UNIT_FIELD_LEVEL, level - 1);
2781 
2782  // add to world
2783  pet->GetMap()->AddToMap(pet->ToCreature());
2784 
2785  // visual effect for levelup
2786  pet->SetUInt32Value(UNIT_FIELD_LEVEL, level);
2787 
2788  // caster have pet now
2789  m_caster->SetMinion(pet, true);
2790 
2791  pet->InitTalentForLevel();
2792 
2793  if (m_caster->GetTypeId() == TYPEID_PLAYER)
2794  {
2796  m_caster->ToPlayer()->PetSpellInitialize();
2797  }
2798 }
void DespawnOrUnsummon(uint32 msTimeToDespawn=0)
Definition: Creature.cpp:1774
SpellInfo const *const m_spellInfo
Definition: Spell.h:547
Unit *const m_caster
Definition: Spell.h:647
uint32 Id
Definition: SpellInfo.h:329
Map * GetMap() const
Definition: Object.h:543
Pet * CreateTamedPetFrom(Creature *creatureTarget, uint32 spell_id=0)
Definition: Unit.cpp:13181
Definition: ObjectGuid.h:32
void SetUInt32Value(uint16 index, uint32 value)
Definition: Object.cpp:996
Definition: Creature.h:467
void SetMinion(Minion *minion, bool apply)
Definition: Unit.cpp:7640
ObjectGuid GetPetGUID() const
Definition: Unit.h:1708
Definition: UpdateFields.h:105
Player * ToPlayer()
Definition: Object.h:191
uint8 getLevel() const
Definition: Unit.h:1408
Definition: PetDefines.h:35
TypeID GetTypeId() const
Definition: Object.h:113
void SavePetToDB(PetSaveMode mode)
Definition: Pet.cpp:372
Definition: Spell.h:289
Unit * unitTarget
Definition: Spell.h:690
void finish(bool ok=true)
Definition: Spell.cpp:3620
bool AddToMap(T *)
Definition: Map.cpp:566
void InitTalentForLevel()
Definition: Pet.cpp:1704
bool IsPet() const
Definition: Unit.h:1403
Definition: ObjectGuid.h:33
Creature * ToCreature()
Definition: Object.h:194
Definition: SharedDefines.h:169
uint8 getClass() const
Definition: Unit.h:1413
uint8_t uint8
Definition: Define.h:152
bool IsEmpty() const
Definition: ObjectGuid.h:242
Definition: Pet.h:46
SpellEffectHandleMode effectHandleMode
Definition: Spell.h:696

+ Here is the call graph for this function:

void Spell::EffectTaunt ( SpellEffIndex  effIndex)
2909 {
2911  return;
2912 
2913  if (!unitTarget)
2914  return;
2915 
2916  // this effect use before aura Taunt apply for prevent taunt already attacking target
2917  // for spell as marked "non effective at already attacking target"
2919  || unitTarget->GetVictim() == m_caster)
2920  {
2922  return;
2923  }
2924 
2926  {
2927  // Also use this effect to set the taunter's threat to the taunted creature's highest value
2928  float myThreat = unitTarget->getThreatManager().getThreat(m_caster);
2930  if (topThreat > myThreat)
2931  unitTarget->getThreatManager().doAddThreat(m_caster, topThreat - myThreat);
2932 
2933  //Set aggro victim to caster
2935  unitTarget->getThreatManager().setCurrentVictim(forcedVictim);
2936  }
2937 
2940 }
Unit *const m_caster
Definition: Spell.h:647
ThreatContainer & getOnlineContainer()
Definition: ThreatManager.h:265
HostileReference * getReferenceByTarget(Unit *victim) const
Definition: ThreatManager.cpp:266
Definition: Unit.h:1129
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
float getThreat() const
Definition: ThreatManager.h:61
bool empty() const
Definition: ThreatManager.h:165
void setCurrentVictim(HostileReference *hostileRef)
Definition: ThreatManager.cpp:503
bool HasReactState(ReactStates state) const
Definition: Creature.h:504
void doAddThreat(Unit *victim, float threat)
Definition: ThreatManager.cpp:414
bool IsAIEnabled
Definition: Unit.h:2161
bool CanHaveThreatList(bool skipAliveCheck=false) const
Definition: Unit.cpp:10652
Definition: Spell.h:289
Unit * unitTarget
Definition: Spell.h:690
Unit * GetVictim() const
Definition: Unit.h:1379
CreatureAI * AI() const
Definition: Creature.h:525
Definition: ThreatManager.h:49
float getThreat(Unit *victim, bool alsoSearchOfflineList=false)
Definition: ThreatManager.cpp:469
Definition: SharedDefines.h:1297
Creature * ToCreature()
Definition: Object.h:194
ThreatManager & getThreatManager()
Definition: Unit.h:1998
HostileReference * getMostHated() const
Definition: ThreatManager.h:170
virtual void AttackStart(Unit *)
Definition: UnitAI.cpp:29
SpellEffectHandleMode effectHandleMode
Definition: Spell.h:696

+ Here is the call graph for this function:

void Spell::EffectTeleportUnits ( SpellEffIndex  effIndex)
959 {
961  return;
962 
963  if (!unitTarget || unitTarget->IsInFlight())
964  return;
965 
966  // If not exist data for dest location - return
967  if (!m_targets.HasDst())
968  {
969  TC_LOG_ERROR("spells", "Spell::EffectTeleportUnits - does not have destination for spellId %u.", m_spellInfo->Id);
970  return;
971  }
972 
973  // Init dest coordinates
974  uint32 mapid = destTarget->GetMapId();
975  if (mapid == MAPID_INVALID)
976  mapid = unitTarget->GetMapId();
977  float x, y, z, orientation;
978  destTarget->GetPosition(x, y, z, orientation);
979  if (!orientation && m_targets.GetUnitTarget())
980  orientation = m_targets.GetUnitTarget()->GetOrientation();
981  TC_LOG_DEBUG("spells", "Spell::EffectTeleportUnits - teleport unit to %u %f %f %f %f\n", mapid, x, y, z, orientation);
982 
984  unitTarget->ToPlayer()->TeleportTo(mapid, x, y, z, orientation, unitTarget == m_caster ? TELE_TO_SPELL | TELE_TO_NOT_LEAVE_COMBAT : 0);
985  else if (mapid == unitTarget->GetMapId())
986  unitTarget->NearTeleportTo(x, y, z, orientation, unitTarget == m_caster);
987  else
988  {
989  TC_LOG_ERROR("spells", "Spell::EffectTeleportUnits - spellId %u attempted to teleport creature to a different map.", m_spellInfo->Id);
990  return;
991  }
992 
993  // post effects for TARGET_DEST_DB
994  switch (m_spellInfo->Id)
995  {
996  // Dimensional Ripper - Everlook
997  case 23442:
998  {
999  int32 r = irand(0, 119);
1000  if (r >= 70) // 7/12 success
1001  {
1002  if (r < 100) // 4/12 evil twin
1003  m_caster->CastSpell(m_caster, 23445, true);
1004  else // 1/12 fire
1005  m_caster->CastSpell(m_caster, 23449, true);
1006  }
1007  return;
1008  }
1009  // Ultrasafe Transporter: Toshley's Station
1010  case 36941:
1011  {
1012  if (roll_chance_i(50)) // 50% success
1013  {
1014  int32 rand_eff = urand(1, 7);
1015  switch (rand_eff)
1016  {
1017  case 1:
1018  // soul split - evil
1019  m_caster->CastSpell(m_caster, 36900, true);
1020  break;
1021  case 2:
1022  // soul split - good
1023  m_caster->CastSpell(m_caster, 36901, true);
1024  break;
1025  case 3:
1026  // Increase the size
1027  m_caster->CastSpell(m_caster, 36895, true);
1028  break;
1029  case 4:
1030  // Decrease the size
1031  m_caster->CastSpell(m_caster, 36893, true);
1032  break;
1033  case 5:
1034  // Transform
1035  {
1036  if (m_caster->ToPlayer()->GetTeam() == ALLIANCE)
1037  m_caster->CastSpell(m_caster, 36897, true);
1038  else
1039  m_caster->CastSpell(m_caster, 36899, true);
1040  break;
1041  }
1042  case 6:
1043  // chicken
1044  m_caster->CastSpell(m_caster, 36940, true);
1045  break;
1046  case 7:
1047  // evil twin
1048  m_caster->CastSpell(m_caster, 23445, true);
1049  break;
1050  }
1051  }
1052  return;
1053  }
1054  // Dimensional Ripper - Area 52
1055  case 36890:
1056  {
1057  if (roll_chance_i(50)) // 50% success
1058  {
1059  int32 rand_eff = urand(1, 4);
1060  switch (rand_eff)
1061  {
1062  case 1:
1063  // soul split - evil
1064  m_caster->CastSpell(m_caster, 36900, true);
1065  break;
1066  case 2:
1067  // soul split - good
1068  m_caster->CastSpell(m_caster, 36901, true);
1069  break;
1070  case 3:
1071  // Increase the size
1072  m_caster->CastSpell(m_caster, 36895, true);
1073  break;
1074  case 4:
1075  // Transform
1076  {
1077  if (m_caster->ToPlayer()->GetTeam() == ALLIANCE)
1078  m_caster->CastSpell(m_caster, 36897, true);
1079  else
1080  m_caster->CastSpell(m_caster, 36899, true);
1081  break;
1082  }
1083  }
1084  }
1085  return;
1086  }
1087  }
1088 }
SpellInfo const *const m_spellInfo
Definition: Spell.h:547
Unit *const m_caster
Definition: Spell.h:647
uint32 Id
Definition: SpellInfo.h:329
Unit * GetUnitTarget() const
Definition: Spell.cpp:222
SpellCastTargets m_targets
Definition: Spell.h:584
bool IsInFlight() const
Definition: Unit.h:1582
WorldLocation * destTarget
Definition: Spell.h:693
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
Player * ToPlayer()
Definition: Object.h:191
Definition: SharedDefines.h:1000
int32 irand(int32 min, int32 max)
Definition: Random.cpp:39
TypeID GetTypeId() const
Definition: Object.h:113
float GetOrientation() const
Definition: Position.h:107
Definition: Spell.h:289
Unit * unitTarget
Definition: Spell.h:690
bool HasDst() const
Definition: Spell.h:229
void NearTeleportTo(float x, float y, float z, float orientation, bool casting=false)
Definition: Unit.cpp:15407
G3D::int16 z
Definition: Vector3int16.h:46
uint32 urand(uint32 min, uint32 max)
Definition: Random.cpp:45
void GetPosition(float &x, float &y) const
Definition: Position.h:109
int32_t int32
Definition: Define.h:146
uint32_t uint32
Definition: Define.h:150
bool roll_chance_i(int chance)
Definition: Random.h:53
G3D::int16 y
Definition: Vector2int16.h:38
uint32 GetMapId() const
Definition: Position.h:254
Definition: ObjectGuid.h:33
#define MAPID_INVALID
Definition: Position.h:226
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
G3D::int16 x
Definition: Vector2int16.h:37
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
SpellEffectHandleMode effectHandleMode
Definition: Spell.h:696

+ Here is the call graph for this function:

void Spell::EffectTeleUnitsFaceCaster ( SpellEffIndex  effIndex)
2472 {
2474  return;
2475 
2476  if (!unitTarget)
2477  return;
2478 
2479  if (unitTarget->IsInFlight())
2480  return;
2481 
2482  float dis = effectInfo->CalcRadius(m_caster);
2483 
2484  float fx, fy, fz;
2485  m_caster->GetClosePoint(fx, fy, fz, unitTarget->GetObjectSize(), dis);
2486 
2488 }
Unit *const m_caster
Definition: Spell.h:647
SpellEffectInfo const * effectInfo
Definition: Spell.h:697
bool IsInFlight() const
Definition: Unit.h:1582
float GetOrientation() const
Definition: Position.h:107
float CalcRadius(Unit *caster=NULL, Spell *=NULL) const
Definition: SpellInfo.cpp:655
Definition: Spell.h:289
Unit * unitTarget
Definition: Spell.h:690
void NearTeleportTo(float x, float y, float z, float orientation, bool casting=false)
Definition: Unit.cpp:15407
float GetObjectSize() const
Definition: Object.cpp:2656
void GetClosePoint(float &x, float &y, float &z, float size, float distance2d=0, float angle=0) const
Definition: Object.cpp:2623
SpellEffectHandleMode effectHandleMode
Definition: Spell.h:696

+ Here is the call graph for this function:

void Spell::EffectThreat ( SpellEffIndex  effIndex)
3145 {
3147  return;
3148 
3149  if (!unitTarget || !unitTarget->IsAlive() || !m_caster->IsAlive())
3150  return;
3151 
3152  if (!unitTarget->CanHaveThreatList())
3153  return;
3154 
3155  unitTarget->AddThreat(m_caster, float(damage));
3156 }
Unit *const m_caster
Definition: Spell.h:647
void AddThreat(Unit *victim, float fThreat, SpellSchoolMask schoolMask=SPELL_SCHOOL_MASK_NORMAL, SpellInfo const *threatSpell=NULL)
Definition: Unit.cpp:10691
bool CanHaveThreatList(bool skipAliveCheck=false) const
Definition: Unit.cpp:10652
Definition: Spell.h:289
Unit * unitTarget
Definition: Spell.h:690
int32 damage
Definition: Spell.h:694
bool IsAlive() const
Definition: Unit.h:1692
SpellEffectHandleMode effectHandleMode
Definition: Spell.h:696

+ Here is the call graph for this function:

void Spell::EffectTitanGrip ( SpellEffIndex  effIndex)
5399 {
5401  return;
5402 
5403  if (m_caster->GetTypeId() == TYPEID_PLAYER)
5404  m_caster->ToPlayer()->SetCanTitanGrip(true);
5405 }
Unit *const m_caster
Definition: Spell.h:647
Player * ToPlayer()
Definition: Object.h:191
TypeID GetTypeId() const
Definition: Object.h:113
Definition: Spell.h:288
Definition: ObjectGuid.h:33
SpellEffectHandleMode effectHandleMode
Definition: Spell.h:696

+ Here is the call graph for this function:

void Spell::EffectTradeSkill ( SpellEffIndex  effIndex)
2530 {
2532  return;
2533 
2534  if (m_caster->GetTypeId() != TYPEID_PLAYER)
2535  return;
2536  // uint32 skillid = m_spellInfo->Effects[i].MiscValue;
2537  // uint16 skillmax = unitTarget->ToPlayer()->(skillid);
2538  // m_caster->ToPlayer()->SetSkill(skillid, skillval?skillval:1, skillmax+75);
2539 }
Unit *const m_caster
Definition: Spell.h:647
TypeID GetTypeId() const
Definition: Object.h:113
Definition: Spell.h:288
Definition: ObjectGuid.h:33
SpellEffectHandleMode effectHandleMode
Definition: Spell.h:696

+ Here is the call graph for this function:

void Spell::EffectTransmitted ( SpellEffIndex  effIndex)
4886 {
4888  return;
4889 
4890  uint32 name_id = effectInfo->MiscValue;
4891 
4892  GameObjectTemplate const* goinfo = sObjectMgr->GetGameObjectTemplate(name_id);
4893 
4894  if (!goinfo)
4895  {
4896  TC_LOG_ERROR("sql.sql", "Gameobject (Entry: %u) not exist and not created at spell (ID: %u) cast", name_id, m_spellInfo->Id);
4897  return;
4898  }
4899 
4900  float fx, fy, fz;
4901 
4902  if (m_targets.HasDst())
4903  destTarget->GetPosition(fx, fy, fz);
4904  //FIXME: this can be better check for most objects but still hack
4905  else if (effectInfo->HasRadius() && m_spellInfo->Speed == 0)
4906  {
4907  float dis = effectInfo->CalcRadius(m_originalCaster);
4909  }
4910  else
4911  {
4912  //GO is always friendly to it's creator, get range for friends
4913  float min_dis = m_spellInfo->GetMinRange(true);
4914  float max_dis = m_spellInfo->GetMaxRange(true);
4915  float dis = (float)rand_norm() * (max_dis - min_dis) + min_dis;
4916 
4918  }
4919 
4920  Map* cMap = m_caster->GetMap();
4921  // if gameobject is summoning object, it should be spawned right on caster's position
4922  if (goinfo->type == GAMEOBJECT_TYPE_RITUAL)
4923  m_caster->GetPosition(fx, fy, fz);
4924 
4925  GameObject* pGameObj = new GameObject;
4926 
4927  if (!pGameObj->Create(cMap->GenerateLowGuid<HighGuid::GameObject>(), name_id, cMap,
4928  0, fx, fy, fz, m_caster->GetOrientation(), 0.0f, 0.0f, 0.0f, 0.0f, 100, GO_STATE_READY))
4929  {
4930  delete pGameObj;
4931  return;
4932  }
4933 
4934  pGameObj->CopyPhaseFrom(m_caster);
4935 
4936  int32 duration = m_spellInfo->GetDuration();
4937 
4938  switch (goinfo->type)
4939  {
4941  {
4942  m_caster->SetChannelObjectGuid(pGameObj->GetGUID());
4943  m_caster->AddGameObject(pGameObj); // will removed at spell cancel
4944 
4945  // end time of range when possible catch fish (FISHING_BOBBER_READY_TIME..GetDuration(m_spellInfo))
4946  // start time == fish-FISHING_BOBBER_READY_TIME (0..GetDuration(m_spellInfo)-FISHING_BOBBER_READY_TIME)
4947  int32 lastSec = 0;
4948  switch (urand(0, 3))
4949  {
4950  case 0: lastSec = 3; break;
4951  case 1: lastSec = 7; break;
4952  case 2: lastSec = 13; break;
4953  case 3: lastSec = 17; break;
4954  }
4955 
4956  duration = duration - lastSec*IN_MILLISECONDS + FISHING_BOBBER_READY_TIME*IN_MILLISECONDS;
4957  break;
4958  }
4960  {
4961  if (m_caster->GetTypeId() == TYPEID_PLAYER)
4962  {
4963  pGameObj->AddUniqueUse(m_caster->ToPlayer());
4964  m_caster->AddGameObject(pGameObj); // will be removed at spell cancel
4965  }
4966  break;
4967  }
4968  case GAMEOBJECT_TYPE_DUEL_ARBITER: // 52991
4969  m_caster->AddGameObject(pGameObj);
4970  break;
4972  case GAMEOBJECT_TYPE_CHEST:
4973  default:
4974  break;
4975  }
4976 
4977  pGameObj->SetRespawnTime(duration > 0 ? duration/IN_MILLISECONDS : 0);
4978 
4979  pGameObj->SetOwnerGUID(m_caster->GetGUID());
4980 
4981  //pGameObj->SetUInt32Value(GAMEOBJECT_LEVEL, m_caster->getLevel());
4982  pGameObj->SetSpellId(m_spellInfo->Id);
4983 
4984  ExecuteLogEffectSummonObject(effIndex, pGameObj);
4985 
4986  TC_LOG_DEBUG("spells", "AddObject at SpellEfects.cpp EffectTransmitted");
4987  //m_caster->AddGameObject(pGameObj);
4988  //m_ObjToDel.push_back(pGameObj);
4989 
4990  cMap->AddToMap(pGameObj);
4991 
4992  if (uint32 linkedEntry = pGameObj->GetGOInfo()->GetLinkedGameObjectEntry())
4993  {
4994  GameObject* linkedGO = new GameObject;
4995  if (linkedGO->Create(cMap->GenerateLowGuid<HighGuid::GameObject>(), linkedEntry, cMap,
4996  0, fx, fy, fz, m_caster->GetOrientation(), 0.0f, 0.0f, 0.0f, 0.0f, 100, GO_STATE_READY))
4997  {
4998  linkedGO->CopyPhaseFrom(m_caster);
4999 
5000  linkedGO->SetRespawnTime(duration > 0 ? duration/IN_MILLISECONDS : 0);
5001  //linkedGO->SetUInt32Value(GAMEOBJECT_LEVEL, m_caster->getLevel());
5002  linkedGO->SetSpellId(m_spellInfo->Id);
5003  linkedGO->SetOwnerGUID(m_caster->GetGUID());
5004 
5005  ExecuteLogEffectSummonObject(effIndex, linkedGO);
5006 
5007  linkedGO->GetMap()->AddToMap(linkedGO);
5008  }
5009  else
5010  {
5011  delete linkedGO;
5012  linkedGO = NULL;
5013  return;
5014  }
5015  }
5016 }
int32 MiscValue
Definition: SpellInfo.h:253
SpellInfo const *const m_spellInfo
Definition: Spell.h:547
Unit *const m_caster
Definition: Spell.h:647
uint32 Id
Definition: SpellInfo.h:329
uint32 GetLinkedGameObjectEntry() const
Definition: GameObject.h:697
SpellEffectInfo const * effectInfo
Definition: Spell.h:697
Map * GetMap() const
Definition: Object.h:543
SpellCastTargets m_targets
Definition: Spell.h:584
float GetMaxRange(bool positive=false, Unit *caster=NULL, Spell *spell=NULL) const
Definition: SpellInfo.cpp:2475
Definition: GameObject.h:34
arena_t NULL
Definition: jemalloc_internal.h:624
void ExecuteLogEffectSummonObject(uint8 effIndex, WorldObject *obj)
Definition: Spell.cpp:4214
void CopyPhaseFrom(WorldObject *obj, bool update=false)
Definition: Object.cpp:2915
WorldLocation * destTarget
Definition: Spell.h:693
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
void SetRespawnTime(int32 respawn)
Definition: GameObject.h:945
float GetMinRange(bool positive=false) const
Definition: SpellInfo.cpp:2466
Definition: SharedDefines.h:2082
#define sObjectMgr
Definition: ObjectMgr.h:1567
Player * ToPlayer()
Definition: Object.h:191
Definition: SharedDefines.h:2081
int32 GetDuration() const
Definition: SpellInfo.cpp:2490
bool HasRadius() const
Definition: SpellInfo.cpp:645
TypeID GetTypeId() const
Definition: Object.h:113
float GetOrientation() const
Definition: Position.h:107
float CalcRadius(Unit *caster=NULL, Spell *=NULL) const
Definition: SpellInfo.cpp:655
Unit * m_originalCaster
Definition: Spell.h:653
Definition: Spell.h:288
#define FISHING_BOBBER_READY_TIME
Definition: GameObject.h:878
bool HasDst() const
Definition: Spell.h:229
uint32 urand(uint32 min, uint32 max)
Definition: Random.cpp:45
void GetPosition(float &x, float &y) const
Definition: Position.h:109
bool AddToMap(T *)
Definition: Map.cpp:566
int32_t int32
Definition: Define.h:146
uint32_t uint32
Definition: Define.h:150
GameObjectTemplate const * GetGOInfo() const
Definition: GameObject.h:894
#define DEFAULT_WORLD_OBJECT_SIZE
Definition: Object.h:44
Definition: GameObject.h:880
void AddGameObject(GameObject *gameObj)
Definition: Unit.cpp:4747
Definition: Map.h:259
float Speed
Definition: SpellInfo.h:380
Definition: SharedDefines.h:2090
Definition: GameObject.h:823
ObjectGuid const & GetGUID() const
Definition: Object.h:105
Definition: ObjectGuid.h:33
void AddUniqueUse(Player *player)
Definition: GameObject.cpp:720
double rand_norm()
Definition: Random.cpp:69
Definition: Common.h:103
bool Create(ObjectGuid::LowType guidlow, uint32 name_id, Map *map, uint32 phaseMask, float x, float y, float z, float ang, float rotation0, float rotation1, float rotation2, float rotation3, uint32 animprogress, GOState go_state, uint32 artKit=0)
Definition: GameObject.cpp:173
void SetChannelObjectGuid(ObjectGuid guid)
Definition: Unit.h:1905
void SetSpellId(uint32 id)
Definition: GameObject.h:928
Definition: SharedDefines.h:2083
Definition: SharedDefines.h:2068
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
ObjectGuid::LowType GenerateLowGuid()
Definition: Map.h:561
uint32 type
Definition: GameObject.h:37
void SetOwnerGUID(ObjectGuid owner)
Definition: GameObject.h:915
void GetClosePoint(float &x, float &y, float &z, float size, float distance2d=0, float angle=0) const
Definition: Object.cpp:2623
SpellEffectHandleMode effectHandleMode
Definition: Spell.h:696

+ Here is the call graph for this function:

void Spell::EffectTriggerMissileSpell ( SpellEffIndex  effIndex)
788 {
791  return;
792 
793  uint32 triggered_spell_id = effectInfo->TriggerSpell;
794 
795  // normal case
796  SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(triggered_spell_id);
797  if (!spellInfo)
798  {
799  TC_LOG_ERROR("spells", "Spell::EffectTriggerMissileSpell spell %u tried to trigger unknown spell %u", m_spellInfo->Id, triggered_spell_id);
800  return;
801  }
802 
803  SpellCastTargets targets;
805  {
807  return;
808  targets.SetUnitTarget(unitTarget);
809  }
810  else //if (effectHandleMode == SPELL_EFFECT_HANDLE_HIT)
811  {
813  return;
814 
816  targets.SetDst(m_targets);
817 
818  targets.SetUnitTarget(m_caster);
819  }
820 
821  CustomSpellValues values;
822  // set basepoints for trigger with value effect
824  {
825  // maybe need to set value only when basepoints == 0?
829  }
830 
831  // original caster guid only for GO cast
832  m_caster->CastSpell(targets, spellInfo, &values, TRIGGERED_FULL_MASK, NULL, NULL, m_originalCasterGUID);
833 }
Definition: Unit.h:131
SpellInfo const *const m_spellInfo
Definition: Spell.h:547
Unit *const m_caster
Definition: Spell.h:647
uint32 Id
Definition: SpellInfo.h:329
Definition: Unit.h:167
uint32 GetExplicitTargetMask() const
Definition: SpellInfo.cpp:2216
SpellEffectInfo const * effectInfo
Definition: Spell.h:697
Map * GetMap() const
Definition: Object.h:543
Definition: SpellInfo.h:326
SpellCastTargets m_targets
Definition: Spell.h:584
Difficulty GetDifficultyID() const
Definition: Map.h:390
arena_t NULL
Definition: jemalloc_internal.h:624
Will ignore most target checks (mostly DBC target checks)
Definition: Unit.h:479
Definition: SharedDefines.h:1158
uint32 TriggerSpell
Definition: SpellInfo.h:263
Definition: Spell.h:289
Unit * unitTarget
Definition: Spell.h:690
Definition: Spell.h:288
int32 damage
Definition: Spell.h:694
void SetUnitTarget(Unit *target)
Definition: Spell.cpp:230
#define sSpellMgr
Definition: SpellMgr.h:756
uint32_t uint32
Definition: Define.h:150
Definition: SpellInfo.h:54
Definition: Spell.h:170
Definition: Unit.h:130
ObjectGuid m_originalCasterGUID
Definition: Spell.h:651
uint32 GetProvidedTargetMask() const
Definition: SpellInfo.cpp:681
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
Definition: SpellInfo.h:75
void SetDst(float x, float y, float z, float orientation, uint32 mapId=MAPID_INVALID)
Definition: Spell.cpp:377
void AddSpellMod(SpellValueMod mod, int32 value)
Definition: Unit.h:176
uint32 Effect
Definition: SpellInfo.h:243
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
bool NeedsToBeTriggeredByCaster(SpellInfo const *triggeringSpell, uint32 difficulty) const
Definition: SpellInfo.cpp:1363
Definition: Unit.h:129
SpellEffectHandleMode effectHandleMode
Definition: Spell.h:696

+ Here is the call graph for this function:

void Spell::EffectTriggerRitualOfSummoning ( SpellEffIndex  effIndex)
893 {
895  return;
896 
897  uint32 triggered_spell_id = effectInfo->TriggerSpell;
898  SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(triggered_spell_id);
899 
900  if (!spellInfo)
901  {
902  TC_LOG_ERROR("spells", "EffectTriggerRitualOfSummoning of spell %u: triggering unknown spell id %i", m_spellInfo->Id, triggered_spell_id);
903  return;
904  }
905 
906  finish();
907 
908  m_caster->CastSpell((Unit*)NULL, spellInfo, false);
909 }
SpellInfo const *const m_spellInfo
Definition: Spell.h:547
Unit *const m_caster
Definition: Spell.h:647
uint32 Id
Definition: SpellInfo.h:329
SpellEffectInfo const * effectInfo
Definition: Spell.h:697
Definition: SpellInfo.h:326
arena_t NULL
Definition: jemalloc_internal.h:624
uint32 TriggerSpell
Definition: SpellInfo.h:263
void finish(bool ok=true)
Definition: Spell.cpp:3620
Definition: Spell.h:288
#define sSpellMgr
Definition: SpellMgr.h:756
uint32_t uint32
Definition: Define.h:150
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
Definition: Unit.h:1305
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
SpellEffectHandleMode effectHandleMode
Definition: Spell.h:696

+ Here is the call graph for this function:

void Spell::EffectTriggerSpell ( SpellEffIndex  effIndex)
Todo:
move those to spell scripts
653 {
656  return;
657 
658  uint32 triggered_spell_id = effectInfo->TriggerSpell;
659 
663  {
664  // special cases
665  switch (triggered_spell_id)
666  {
667  // Vanish (not exist)
668  case 18461:
669  {
672 
673  // If this spell is given to an NPC, it must handle the rest using its own AI
675  return;
676 
677  // See if we already are stealthed. If so, we're done.
678  if (unitTarget->HasAura(1784))
679  return;
680 
681  // Reset cooldown on stealth if needed
683  unitTarget->CastSpell(unitTarget, 1784, true);
684  return;
685  }
686  // Demonic Empowerment -- succubus
687  case 54437:
688  {
692 
693  // Cast Lesser Invisibility
694  unitTarget->CastSpell(unitTarget, 7870, true);
695  return;
696  }
697  // Brittle Armor - (need add max stack of 24575 Brittle Armor)
698  case 29284:
699  {
700  // Brittle Armor
701  SpellInfo const* spell = sSpellMgr->GetSpellInfo(24575);
702  if (!spell)
703  return;
704 
705  for (uint32 j = 0; j < spell->StackAmount; ++j)
706  m_caster->CastSpell(unitTarget, spell->Id, true);
707  return;
708  }
709  // Mercurial Shield - (need add max stack of 26464 Mercurial Shield)
710  case 29286:
711  {
712  // Mercurial Shield
713  SpellInfo const* spell = sSpellMgr->GetSpellInfo(26464);
714  if (!spell)
715  return;
716 
717  for (uint32 j = 0; j < spell->StackAmount; ++j)
718  m_caster->CastSpell(unitTarget, spell->Id, true);
719  return;
720  }
721  // Cloak of Shadows
722  case 35729:
723  {
726  for (Unit::AuraApplicationMap::iterator iter = Auras.begin(); iter != Auras.end();)
727  {
728  // remove all harmful spells on you...
729  SpellInfo const* spell = iter->second->GetBase()->GetSpellInfo();
730  if (((spell->DmgClass == SPELL_DAMAGE_CLASS_MAGIC && spell->GetSchoolMask() != SPELL_SCHOOL_MASK_NORMAL) // only affect magic spells
731  || (spell->GetDispelMask() & dispelMask)) &&
732  // ignore positive and passive auras
733  !iter->second->IsPositive() && !iter->second->GetBase()->IsPassive())
734  {
735  m_caster->RemoveAura(iter);
736  }
737  else
738  ++iter;
739  }
740  return;
741  }
742  }
743  }
744 
745  // normal case
746  SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(triggered_spell_id);
747  if (!spellInfo)
748  {
749  TC_LOG_ERROR("spells", "Spell::EffectTriggerSpell spell %u tried to trigger unknown spell %u", m_spellInfo->Id, triggered_spell_id);
750  return;
751  }
752 
753  SpellCastTargets targets;
755  {
757  return;
758  targets.SetUnitTarget(unitTarget);
759  }
760  else //if (effectHandleMode == SPELL_EFFECT_HANDLE_LAUNCH)
761  {
763  return;
764 
766  targets.SetDst(m_targets);
767 
768  if (Unit* target = m_targets.GetUnitTarget())
769  targets.SetUnitTarget(target);
770  else
771  targets.SetUnitTarget(m_caster);
772  }
773 
774  CustomSpellValues values;
775  // set basepoints for trigger with value effect
777  {
781  }
782 
783  // original caster guid only for GO cast
784  m_caster->CastSpell(targets, spellInfo, &values, TRIGGERED_FULL_MASK, NULL, NULL, m_originalCasterGUID);
785 }
Definition: Unit.h:131
bool HasAura(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, ObjectGuid itemCasterGUID=ObjectGuid::Empty, uint32 reqEffMask=0) const
Definition: Unit.cpp:4240
SpellInfo const *const m_spellInfo
Definition: Spell.h:547
Unit *const m_caster
Definition: Spell.h:647
uint32 Id
Definition: SpellInfo.h:329
Unit * GetUnitTarget() const
Definition: Spell.cpp:222
Definition: Unit.h:167
uint32 GetExplicitTargetMask() const
Definition: SpellInfo.cpp:2216
SpellEffectInfo const * effectInfo
Definition: Spell.h:697
Definition: SpellAuraDefines.h:72
Map * GetMap() const
Definition: Object.h:543
uint32 DmgClass
Definition: SpellInfo.h:398
Definition: SpellInfo.h:326
Definition: SharedDefines.h:1152
Definition: SpellAuraDefines.h:128
SpellCastTargets m_targets
Definition: Spell.h:584
Difficulty GetDifficultyID() const
Definition: Map.h:390
void RemoveMovementImpairingAuras()
Definition: Unit.cpp:3865
arena_t NULL
Definition: jemalloc_internal.h:624
Will ignore most target checks (mostly DBC target checks)
Definition: Unit.h:479
void RemoveAura(AuraApplicationMap::iterator &i, AuraRemoveMode mode=AURA_REMOVE_BY_DEFAULT)
Definition: Unit.cpp:3442
TypeID GetTypeId() const
Definition: Object.h:113
uint32 TriggerSpell
Definition: SpellInfo.h:263
SpellHistory * GetSpellHistory()
Definition: Unit.h:1926
Unit * unitTarget
Definition: Spell.h:690
int32 damage
Definition: Spell.h:694
AuraApplicationMap & GetAppliedAuras()
Definition: Unit.h:1789
Definition: SharedDefines.h:288
Definition: Spell.h:287
void SetUnitTarget(Unit *target)
Definition: Spell.cpp:230
#define sSpellMgr
Definition: SpellMgr.h:756
uint32_t uint32
Definition: Define.h:150
uint32 GetDispelMask() const
Definition: SpellInfo.cpp:2202
Definition: SpellInfo.h:54
Definition: Spell.h:170
Definition: SharedDefines.h:2050
Definition: SharedDefines.h:1074
Definition: Unit.h:130
ObjectGuid m_originalCasterGUID
Definition: Spell.h:651
void ResetCooldown(uint32 spellId, bool update=false)
Definition: SpellHistory.cpp:549
Definition: ObjectGuid.h:33
SpellSchoolMask GetSchoolMask() const
Definition: SpellInfo.cpp:2131
uint32 GetProvidedTargetMask() const
Definition: SpellInfo.cpp:681
void RemoveAurasByType(AuraType auraType, std::function< bool(AuraApplication const *)> const &check)
Definition: Unit.cpp:3567
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
Definition: SpellInfo.h:75
std::multimap< uint32, AuraApplication * > AuraApplicationMap
Definition: Unit.h:1315
void SetDst(float x, float y, float z, float orientation, uint32 mapId=MAPID_INVALID)
Definition: Spell.cpp:377
uint32 StackAmount
Definition: SpellInfo.h:381
Definition: SharedDefines.h:1845
void AddSpellMod(SpellValueMod mod, int32 value)
Definition: Unit.h:176
uint32 Effect
Definition: SpellInfo.h:243
Definition: Unit.h:1305
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
bool NeedsToBeTriggeredByCaster(SpellInfo const *triggeringSpell, uint32 difficulty) const
Definition: SpellInfo.cpp:1363
Definition: Unit.h:129
SpellEffectHandleMode effectHandleMode
Definition: Spell.h:696
Definition: Spell.h:286

+ Here is the call graph for this function:

void Spell::EffectUncageBattlePet ( SpellEffIndex  effIndex)
5944 {
5946  return;
5947 
5949  return;
5950 
5951  Player* plr = m_caster->ToPlayer();
5952 
5953  // are we allowed to learn battle pets without it?
5954  /*if (plr->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_PET_BATTLES_UNLOCKED))
5955  return; // send some error*/
5956 
5962 
5963  BattlePetSpeciesEntry const* speciesEntry = sBattlePetSpeciesStore.LookupEntry(speciesId);
5964  if (!speciesEntry)
5965  return;
5966 
5967  BattlePetMgr* battlePetMgr = plr->GetSession()->GetBattlePetMgr();
5968  if (!battlePetMgr)
5969  return;
5970 
5971  uint16 maxLearnedLevel = 0;
5972 
5973  for (auto pet : battlePetMgr->GetLearnedPets())
5974  maxLearnedLevel = std::max(pet.PacketInfo.Level, maxLearnedLevel);
5975 
5976  // TODO: This means if you put your highest lvl pet into cage, you won't be able to uncage it again which is probably wrong.
5977  // We will need to store maxLearnedLevel somewhere to avoid this behaviour.
5978  if (maxLearnedLevel < level)
5979  {
5980  battlePetMgr->SendError(BATTLEPETRESULT_TOO_HIGH_LEVEL_TO_UNCAGE, creatureId); // or speciesEntry.CreatureID
5982  return;
5983  }
5984 
5985  if (battlePetMgr->GetPetCount(speciesId) >= MAX_BATTLE_PETS_PER_SPECIES)
5986  {
5987  battlePetMgr->SendError(BATTLEPETRESULT_CANT_HAVE_MORE_PETS_OF_THAT_TYPE, creatureId); // or speciesEntry.CreatureID
5989  return;
5990  }
5991 
5992  if (!plr->HasSpell(speciesEntry->SummonSpellID))
5993  plr->LearnSpell(speciesEntry->SummonSpellID, false);
5994 
5995  battlePetMgr->AddPet(speciesId, creatureId, breed, quality, level);
5996  plr->DestroyItem(m_CastItem->GetBagSlot(), m_CastItem->GetSlot(), true);
5997  m_CastItem = nullptr;
5998 }
Definition: DB2Structure.h:89
void AddPet(uint32 species, uint32 creatureId, uint16 breed, uint8 quality, uint16 level=1)
Definition: BattlePetMgr.cpp:310
Definition: BattlePetMgr.h:27
Unit *const m_caster
Definition: Spell.h:647
std::vector< BattlePet > GetLearnedPets() const
Definition: BattlePetMgr.cpp:377
Definition: BattlePetMgr.h:36
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
uint32 SummonSpellID
Definition: DB2Structure.h:94
DB2Storage< BattlePetSpeciesEntry > sBattlePetSpeciesStore("BattlePetSpecies.db2", BattlePetSpeciesFormat, HOTFIX_SEL_BATTLE_PET_SPECIES)
Item * m_CastItem
Definition: Spell.h:548
T max(const T &x, const T &y)
Definition: g3dmath.h:320
Player * ToPlayer()
Definition: Object.h:191
TypeID GetTypeId() const
Definition: Object.h:113
void SendError(BattlePetError error, uint32 creatureId)
Definition: BattlePetMgr.cpp:463
Definition: Spell.h:288
uint32 GetModifier(ItemModifier modifier) const
Definition: Item.h:440
uint32_t uint32
Definition: Define.h:150
Definition: SharedDefines.h:1511
uint16_t uint16
Definition: Define.h:151
uint8 GetPetCount(uint32 species) const
Definition: BattlePetMgr.cpp:353
uint8 GetSlot() const
Definition: Item.h:329
Definition: BattlePetMgr.h:83
Definition: ObjectGuid.h:33
uint8_t uint8
Definition: Define.h:152
Definition: Item.h:229
uint8 GetBagSlot() const
Definition: Item.cpp:759
SpellEffectHandleMode effectHandleMode
Definition: Spell.h:696

+ Here is the call graph for this function:

void Spell::EffectUnlearnSpecialization ( SpellEffIndex  effIndex)
1113 {
1115  return;
1116 
1118  return;
1119 
1120  Player* player = unitTarget->ToPlayer();
1121  uint32 spellToUnlearn = effectInfo->TriggerSpell;
1122 
1123  player->RemoveSpell(spellToUnlearn);
1124 
1125  TC_LOG_DEBUG("spells", "Spell: %s has unlearned spell %u from %s", player->GetGUID().ToString().c_str(), spellToUnlearn, m_caster->GetGUID().ToString().c_str());
1126 }
Unit *const m_caster
Definition: Spell.h:647
SpellEffectInfo const * effectInfo
Definition: Spell.h:697
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
Player * ToPlayer()
Definition: Object.h:191
TypeID GetTypeId() const
Definition: Object.h:113
uint32 TriggerSpell
Definition: SpellInfo.h:263
Definition: Spell.h:289
Unit * unitTarget
Definition: Spell.h:690
uint32_t uint32
Definition: Define.h:150
ObjectGuid const & GetGUID() const
Definition: Object.h:105
Definition: ObjectGuid.h:33
std::string ToString() const
Definition: ObjectGuid.cpp:99
SpellEffectHandleMode effectHandleMode
Definition: Spell.h:696

+ Here is the call graph for this function:

void Spell::EffectUnlockGuildVaultTab ( SpellEffIndex  effIndex)
5758 {
5760  return;
5761 
5762  // Safety checks done in Spell::CheckCast
5763  Player* caster = m_caster->ToPlayer();
5764  if (Guild* guild = caster->GetGuild())
5765  guild->HandleBuyBankTab(caster->GetSession(), effectInfo->BasePoints - 1); // Bank tabs start at zero internally
5766 }
Unit *const m_caster
Definition: Spell.h:647
SpellEffectInfo const * effectInfo
Definition: Spell.h:697
Player * ToPlayer()
Definition: Object.h:191
Definition: Spell.h:288
int32 BasePoints
Definition: SpellInfo.h:248
Definition: Guild.h:320
SpellEffectHandleMode effectHandleMode
Definition: Spell.h:696

+ Here is the call graph for this function:

void Spell::EffectUntrainTalents ( SpellEffIndex  effIndex)
2461 {
2463  return;
2464 
2466  return;
2467 
2468  unitTarget->ToPlayer()->SendRespecWipeConfirm(m_caster->GetGUID(), sWorld->getBoolConfig(CONFIG_NO_RESET_TALENT_COST) ? 0 : unitTarget->ToPlayer()->GetNextResetTalentsCost());
2469 }
Unit *const m_caster
Definition: Spell.h:647
Definition: World.h:149
#define sWorld
Definition: World.h:887
Player * ToPlayer()
Definition: Object.h:191
TypeID GetTypeId() const
Definition: Object.h:113
Definition: Spell.h:289
Unit * unitTarget
Definition: Spell.h:690
ObjectGuid const & GetGUID() const
Definition: Object.h:105
Definition: ObjectGuid.h:33
SpellEffectHandleMode effectHandleMode
Definition: Spell.h:696

+ Here is the call graph for this function:

void Spell::EffectUnused ( SpellEffIndex  effIndex)
328 {
329  // NOT USED BY ANY SPELL OR USELESS OR IMPLEMENTED IN DIFFERENT WAY IN TRINITY
330 }
void Spell::EffectUpgradeHeirloom ( SpellEffIndex  effIndex)
6001 {
6003  return;
6004 
6005  if (Player* player = m_caster->ToPlayer())
6006  if (CollectionMgr* collectionMgr = player->GetSession()->GetCollectionMgr())
6007  collectionMgr->UpgradeHeirloom(m_misc.Raw.Data[0], m_castItemEntry);
6008 }
union Spell::@326 m_misc
Unit *const m_caster
Definition: Spell.h:647
uint32 m_castItemEntry
Definition: Spell.h:550
Player * ToPlayer()
Definition: Object.h:191
Definition: Spell.h:288
Definition: CollectionMgr.h:48
SpellEffectHandleMode effectHandleMode
Definition: Spell.h:696

+ Here is the call graph for this function:

void Spell::EffectWeaponDmg ( SpellEffIndex  effIndex)
2943 {
2945  return;
2946 
2947  if (!unitTarget || !unitTarget->IsAlive())
2948  return;
2949 
2950  // multiple weapon dmg effect workaround
2951  // execute only the last weapon damage
2952  // and handle all effects at once
2953  for (uint8 index = effIndex + 1; index < MAX_SPELL_EFFECTS; ++index)
2954  {
2955  SpellEffectInfo const* effect = GetEffect(index);
2956  if (!effect)
2957  continue;
2958  switch (effect->Effect)
2959  {
2964  return; // we must calculate only at last weapon effect
2965  break;
2966  }
2967  }
2968 
2969  // some spell specific modifiers
2970  float totalDamagePercentMod = 1.0f; // applied to final bonus+weapon damage
2971  int32 fixed_bonus = 0;
2972  int32 spell_bonus = 0; // bonus specific for spell
2973 
2974  switch (m_spellInfo->SpellFamilyName)
2975  {
2976  case SPELLFAMILY_WARRIOR:
2977  {
2978  // Devastate (player ones)
2979  if (m_spellInfo->SpellFamilyFlags[1] & 0x40)
2980  {
2981  // Player can apply only 58567 Sunder Armor effect.
2982  bool needCast = !unitTarget->HasAura(58567, m_caster->GetGUID());
2983  if (needCast)
2984  m_caster->CastSpell(unitTarget, 58567, true);
2985 
2986  if (Aura* aur = unitTarget->GetAura(58567, m_caster->GetGUID()))
2987  {
2988  if (int32 num = (needCast ? 0 : 1))
2989  aur->ModStackAmount(num);
2990  fixed_bonus += (aur->GetStackAmount() - 1) * CalculateDamage(2, unitTarget);
2991  }
2992  }
2993  break;
2994  }
2995  case SPELLFAMILY_ROGUE:
2996  {
2997  // Hemorrhage
2998  if (m_spellInfo->SpellFamilyFlags[0] & 0x2000000)
2999  {
3000  if (m_caster->GetTypeId() == TYPEID_PLAYER)
3001  m_caster->ToPlayer()->AddComboPoints(1, this);
3002  // 50% more damage with daggers
3003  if (m_caster->GetTypeId() == TYPEID_PLAYER)
3004  if (Item* item = m_caster->ToPlayer()->GetWeaponForAttack(m_attackType, true))
3005  if (item->GetTemplate()->GetSubClass() == ITEM_SUBCLASS_WEAPON_DAGGER)
3006  totalDamagePercentMod *= 1.5f;
3007  }
3008  break;
3009  }
3010  case SPELLFAMILY_SHAMAN:
3011  {
3012  // Skyshatter Harness item set bonus
3013  // Stormstrike
3014  if (AuraEffect* aurEff = m_caster->IsScriptOverriden(m_spellInfo, 5634))
3015  m_caster->CastSpell(m_caster, 38430, true, NULL, aurEff);
3016  break;
3017  }
3018  case SPELLFAMILY_DRUID:
3019  {
3020  // Mangle (Cat): CP
3021  if (m_spellInfo->SpellFamilyFlags[1] & 0x400)
3022  {
3023  if (m_caster->GetTypeId() == TYPEID_PLAYER)
3024  m_caster->ToPlayer()->AddComboPoints(1, this);
3025  }
3026  // Shred, Maul - Rend and Tear
3028  {
3029  if (AuraEffect const* rendAndTear = m_caster->GetDummyAuraEffect(SPELLFAMILY_DRUID, 2859, 0))
3030  AddPct(totalDamagePercentMod, rendAndTear->GetAmount());
3031  }
3032  break;
3033  }
3034  case SPELLFAMILY_HUNTER:
3035  {
3036  // Kill Shot - bonus damage from Ranged Attack Power
3037  if (m_spellInfo->SpellFamilyFlags[1] & 0x800000)
3038  spell_bonus += int32(0.45f * m_caster->GetTotalAttackPowerValue(RANGED_ATTACK));
3039  break;
3040  }
3042  {
3043  // Blood Strike
3044  if (m_spellInfo->SpellFamilyFlags[0] & 0x400000)
3045  {
3046  if (SpellEffectInfo const* effect = GetEffect(EFFECT_2))
3047  {
3048  float bonusPct = effect->CalcValue(m_caster) * unitTarget->GetDiseasesByCaster(m_caster->GetGUID()) / 2.0f;
3049  // Death Knight T8 Melee 4P Bonus
3050  if (AuraEffect const* aurEff = m_caster->GetAuraEffect(64736, EFFECT_0))
3051  AddPct(bonusPct, aurEff->GetAmount());
3052  AddPct(totalDamagePercentMod, bonusPct);
3053  }
3054  break;
3055  }
3056  break;
3057  }
3058  }
3059 
3060  bool normalized = false;
3061  float weaponDamagePercentMod = 1.0f;
3062  for (SpellEffectInfo const* effect : GetEffects())
3063  {
3064  if (!effect)
3065  continue;
3066  switch (effect->Effect)
3067  {
3070  fixed_bonus += CalculateDamage(effect->EffectIndex, unitTarget);
3071  break;
3073  fixed_bonus += CalculateDamage(effect->EffectIndex, unitTarget);
3074  normalized = true;
3075  break;
3077  ApplyPct(weaponDamagePercentMod, CalculateDamage(effect->EffectIndex, unitTarget));
3078  break;
3079  default:
3080  break; // not weapon damage effect, just skip
3081  }
3082  }
3083 
3084  // apply to non-weapon bonus weapon total pct effect, weapon total flat effect included in weapon damage
3085  if (fixed_bonus || spell_bonus)
3086  {
3087  UnitMods unitMod;
3088  switch (m_attackType)
3089  {
3090  default:
3091  case BASE_ATTACK: unitMod = UNIT_MOD_DAMAGE_MAINHAND; break;
3092  case OFF_ATTACK: unitMod = UNIT_MOD_DAMAGE_OFFHAND; break;
3093  case RANGED_ATTACK: unitMod = UNIT_MOD_DAMAGE_RANGED; break;
3094  }
3095 
3096  float weapon_total_pct = 1.0f;
3098  weapon_total_pct = m_caster->GetModifierValue(unitMod, TOTAL_PCT);
3099 
3100  if (fixed_bonus)
3101  fixed_bonus = int32(fixed_bonus * weapon_total_pct);
3102  if (spell_bonus)
3103  spell_bonus = int32(spell_bonus * weapon_total_pct);
3104  }
3105 
3106  int32 weaponDamage = m_caster->CalculateDamage(m_attackType, normalized, true);
3107 
3108  // Sequence is important
3109  for (SpellEffectInfo const* effect : GetEffects())
3110  {
3111  if (!effect)
3112  continue;
3113  // We assume that a spell have at most one fixed_bonus
3114  // and at most one weaponDamagePercentMod
3115  switch (effect->Effect)
3116  {
3120  weaponDamage += fixed_bonus;
3121  break;
3123  weaponDamage = int32(weaponDamage* weaponDamagePercentMod);
3124  default:
3125  break; // not weapon damage effect, just skip
3126  }
3127  }
3128 
3129  if (spell_bonus)
3130  weaponDamage += spell_bonus;
3131 
3132  if (totalDamagePercentMod != 1.0f)
3133  weaponDamage = int32(weaponDamage* totalDamagePercentMod);
3134 
3135  // prevent negative damage
3136  uint32 eff_damage(std::max(weaponDamage, 0));
3137 
3138  // Add melee damage bonuses (also check for negative)
3139  uint32 damageBonusDone = m_caster->MeleeDamageBonusDone(unitTarget, eff_damage, m_attackType, m_spellInfo);
3140 
3142 }
Definition: SpellAuraEffects.h:30
bool HasAura(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, ObjectGuid itemCasterGUID=ObjectGuid::Empty, uint32 reqEffMask=0) const
Definition: Unit.cpp:4240
SpellInfo const *const m_spellInfo
Definition: Spell.h:547
Unit *const m_caster
Definition: Spell.h:647
Definition: ItemTemplate.h:437
UnitMods
Definition: Unit.h:482
Definition: Unit.h:510
Definition: SharedDefines.h:28
Aura * GetAura(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, ObjectGuid itemCasterGUID=ObjectGuid::Empty, uint32 reqEffMask=0) const
Definition: Unit.cpp:4151
uint32 GetDiseasesByCaster(ObjectGuid casterGUID, bool remove=false)
Definition: Unit.cpp:4340
uint32 MeleeDamageBonusTaken(Unit *attacker, uint32 pdamage, WeaponAttackType attType, SpellInfo const *spellProto=NULL)
Definition: Unit.cpp:9493
Definition: Unit.h:619
bool HasAuraState(AuraStateType flag, SpellInfo const *spellProto=NULL, Unit const *Caster=NULL) const
Definition: Unit.cpp:7491
AuraEffect * IsScriptOverriden(SpellInfo const *spell, int32 script) const
Definition: Unit.cpp:4328
flag128 SpellFamilyFlags
Definition: SpellInfo.h:397
uint32 SchoolMask
Definition: SpellInfo.h:401
int32 CalculateDamage(uint8 i, Unit const *target, float *var=nullptr) const
Definition: Spell.h:504
T ApplyPct(T &base, U pct)
Definition: Util.h:104
Definition: SharedDefines.h:4638
SpellEffectInfo const * GetEffect(uint32 index) const
Definition: Spell.h:624
arena_t NULL
Definition: jemalloc_internal.h:624
Definition: Unit.h:512
Definition: Unit.h:511
uint32 EffectIndex
Definition: SpellInfo.h:242
Definition: SharedDefines.h:4632
T max(const T &x, const T &y)
Definition: g3dmath.h:320
Player * ToPlayer()
Definition: Object.h:191
Definition: SharedDefines.h:1027
TypeID GetTypeId() const
Definition: Object.h:113
uint32 CalculateDamage(WeaponAttackType attType, bool normalized, bool addTotalPct)
Definition: Unit.cpp:2078
AuraEffect * GetDummyAuraEffect(SpellFamilyNames name, uint32 iconId, uint8 effIndex) const
Definition: Unit.cpp:4127
Unit * unitTarget
Definition: Spell.h:690
Definition: Unit.h:618
Definition: SharedDefines.h:288
uint32 SpellFamilyName
Definition: SpellInfo.h:396
Definition: SharedDefines.h:4634
bool IsAlive() const
Definition: Unit.h:1692
Definition: Spell.h:287
Definition: SharedDefines.h:1776
Definition: Item.h:259
Definition: SharedDefines.h:4631
Definition: SpellInfo.h:238
int32_t int32
Definition: Define.h:146
uint32_t uint32
Definition: Define.h:150
Definition: SharedDefines.h:1068
float GetModifierValue(UnitMods unitMod, UnitModifierType modifierType) const
Definition: Unit.cpp:11388
int32 m_damage
Definition: Spell.h:709
SpellEffectInfoVector const & GetEffects() const
Definition: Spell.h:623
Definition: SharedDefines.h:4630
WeaponAttackType m_attackType
Definition: Spell.h:657
Definition: Unit.h:438
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
ObjectGuid const & GetGUID() const
Definition: Object.h:105
uint32 MeleeDamageBonusDone(Unit *pVictim, uint32 damage, WeaponAttackType attType, SpellInfo const *spellProto=NULL)
Definition: Unit.cpp:9385
Definition: ObjectGuid.h:33
Definition: SharedDefines.h:4627
T AddPct(T &base, U pct)
Definition: Util.h:98
int32_t int32
Definition: g3dmath.h:167
Definition: SharedDefines.h:1041
AuraEffect * GetAuraEffect(uint32 spellId, uint8 effIndex, ObjectGuid casterGUID=ObjectGuid::Empty) const
Definition: Unit.cpp:4071
uint8_t uint8
Definition: Define.h:152
#define MAX_SPELL_EFFECTS
Definition: DBCStructure.h:1026
Definition: SharedDefines.h:30
float GetTotalAttackPowerValue(WeaponAttackType attType) const
Definition: Unit.cpp:11491
Definition: SpellAuras.h:116
uint32 Effect
Definition: SpellInfo.h:243
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:1131
Definition: Unit.h:617
SpellEffectHandleMode effectHandleMode
Definition: Spell.h:696

+ Here is the call graph for this function:

void Spell::ExecuteLogEffectCreateItem ( uint8  effIndex,
uint32  entry 
)
4199 {
4200  SpellLogEffectTradeSkillItemParams spellLogEffectTradeSkillItemParams;
4201  spellLogEffectTradeSkillItemParams.ItemID = entry;
4202 
4203  _tradeSkillTargets[effIndex].push_back(spellLogEffectTradeSkillItemParams);
4204 }
Definition: Spell.h:160
std::vector< SpellLogEffectTradeSkillItemParams > _tradeSkillTargets[MAX_SPELL_EFFECTS]
Definition: Spell.h:836
int32 ItemID
Definition: Spell.h:162

+ Here is the caller graph for this function:

void Spell::ExecuteLogEffectDestroyItem ( uint8  effIndex,
uint32  entry 
)
4207 {
4208  SpellLogEffectFeedPetParams spellLogEffectFeedPetParams;
4209  spellLogEffectFeedPetParams.ItemID = entry;
4210 
4211  _feedPetTargets[effIndex].push_back(spellLogEffectFeedPetParams);
4212 }
int32 ItemID
Definition: Spell.h:167
std::vector< SpellLogEffectFeedPetParams > _feedPetTargets[MAX_SPELL_EFFECTS]
Definition: Spell.h:837
Definition: Spell.h:165

+ Here is the caller graph for this function:

void Spell::ExecuteLogEffectDurabilityDamage ( uint8  effIndex,
Unit victim,
int32  itemId,
int32  amount 
)
4181 {
4182  SpellLogEffectDurabilityDamageParams spellLogEffectDurabilityDamageParams;
4183  spellLogEffectDurabilityDamageParams.Victim = victim->GetGUID();
4184  spellLogEffectDurabilityDamageParams.ItemID = itemId;
4185  spellLogEffectDurabilityDamageParams.Amount = amount;
4186 
4187  _durabilityDamageTargets[effIndex].push_back(spellLogEffectDurabilityDamageParams);
4188 }
ObjectGuid Victim
Definition: Spell.h:150
std::vector< SpellLogEffectDurabilityDamageParams > _durabilityDamageTargets[MAX_SPELL_EFFECTS]
Definition: Spell.h:834
int32 Amount
Definition: Spell.h:152
int32 ItemID
Definition: Spell.h:151
ObjectGuid const & GetGUID() const
Definition: Object.h:105

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Spell::ExecuteLogEffectExtraAttacks ( uint8  effIndex,
Unit victim,
uint32  numAttacks 
)
4161 {
4162  SpellLogEffectExtraAttacksParams spellLogEffectExtraAttacksParams;
4163  spellLogEffectExtraAttacksParams.Victim = victim->GetGUID();
4164  spellLogEffectExtraAttacksParams.NumAttacks = numAttacks;
4165 
4166  _extraAttacksTargets[effIndex].push_back(spellLogEffectExtraAttacksParams);
4167 }
uint32 NumAttacks
Definition: Spell.h:145
ObjectGuid Victim
Definition: Spell.h:144
std::vector< SpellLogEffectExtraAttacksParams > _extraAttacksTargets[MAX_SPELL_EFFECTS]
Definition: Spell.h:833
Definition: Spell.h:142
ObjectGuid const & GetGUID() const
Definition: Object.h:105

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Spell::ExecuteLogEffectInterruptCast ( uint8  effIndex,
Unit victim,
uint32  spellId 
)
4170 {
4172  data.Caster = m_caster->GetGUID();
4173  data.Victim = victim->GetGUID();
4175  data.SpellID = spellId;
4176 
4177  m_caster->SendMessageToSet(data.Write(), true);
4178 }
SpellInfo const *const m_spellInfo
Definition: Spell.h:547
Unit *const m_caster
Definition: Spell.h:647
uint32 Id
Definition: SpellInfo.h:329
int32 InterruptedSpellID
Definition: CombatLogPackets.h:197
int32 SpellID
Definition: CombatLogPackets.h:198
ObjectGuid Victim
Definition: CombatLogPackets.h:196
ObjectGuid const & GetGUID() const
Definition: Object.h:105
Definition: CombatLogPackets.h:188
WorldPacket const * Write() override
Definition: CombatLogPackets.cpp:171
ObjectGuid Caster
Definition: CombatLogPackets.h:195
virtual void SendMessageToSet(WorldPacket const *data, bool self)
Definition: Object.cpp:2144

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Spell::ExecuteLogEffectOpenLock ( uint8  effIndex,
Object obj 
)
4191 {
4192  SpellLogEffectGenericVictimParams spellLogEffectGenericVictimParams;
4193  spellLogEffectGenericVictimParams.Victim = obj->GetGUID();
4194 
4195  _genericVictimTargets[effIndex].push_back(spellLogEffectGenericVictimParams);
4196 }
Definition: Spell.h:155
std::vector< SpellLogEffectGenericVictimParams > _genericVictimTargets[MAX_SPELL_EFFECTS]
Definition: Spell.h:835
ObjectGuid const & GetGUID() const
Definition: Object.h:105
ObjectGuid Victim
Definition: Spell.h:157

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Spell::ExecuteLogEffectResurrect ( uint8  effIndex,
Unit target 
)
4231 {
4232  SpellLogEffectGenericVictimParams spellLogEffectGenericVictimParams;
4233  spellLogEffectGenericVictimParams.Victim = target->GetGUID();
4234 
4235  _genericVictimTargets[effect].push_back(spellLogEffectGenericVictimParams);
4236 }
Definition: Spell.h:155
std::vector< SpellLogEffectGenericVictimParams > _genericVictimTargets[MAX_SPELL_EFFECTS]
Definition: Spell.h:835
ObjectGuid const & GetGUID() const
Definition: Object.h:105
ObjectGuid Victim
Definition: Spell.h:157

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Spell::ExecuteLogEffectSummonObject ( uint8  effIndex,
WorldObject obj 
)
4215 {
4216  SpellLogEffectGenericVictimParams spellLogEffectGenericVictimParams;
4217  spellLogEffectGenericVictimParams.Victim = obj->GetGUID();
4218 
4219  _genericVictimTargets[effIndex].push_back(spellLogEffectGenericVictimParams);
4220 }
Definition: Spell.h:155
std::vector< SpellLogEffectGenericVictimParams > _genericVictimTargets[MAX_SPELL_EFFECTS]
Definition: Spell.h:835
ObjectGuid const & GetGUID() const
Definition: Object.h:105
ObjectGuid Victim
Definition: Spell.h:157

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Spell::ExecuteLogEffectTakeTargetPower ( uint8  effIndex,
Unit target,
uint32  powerType,
uint32  points,
float  amplitude 
)
4149 {
4150  SpellLogEffectPowerDrainParams spellLogEffectPowerDrainParams;
4151 
4152  spellLogEffectPowerDrainParams.Victim = target->GetGUID();
4153  spellLogEffectPowerDrainParams.Points = points;
4154  spellLogEffectPowerDrainParams.PowerType = powerType;
4155  spellLogEffectPowerDrainParams.Amplitude = amplitude;
4156 
4157  _powerDrainTargets[effIndex].push_back(spellLogEffectPowerDrainParams);
4158 }
std::vector< SpellLogEffectPowerDrainParams > _powerDrainTargets[MAX_SPELL_EFFECTS]
Definition: Spell.h:832
float Amplitude
Definition: Spell.h:139
ObjectGuid Victim
Definition: Spell.h:136
uint32 PowerType
Definition: Spell.h:138
Definition: Spell.h:134
ObjectGuid const & GetGUID() const
Definition: Object.h:105
uint32 Points
Definition: Spell.h:137

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Spell::ExecuteLogEffectUnsummonObject ( uint8  effIndex,
WorldObject obj 
)
4223 {
4224  SpellLogEffectGenericVictimParams spellLogEffectGenericVictimParams;
4225  spellLogEffectGenericVictimParams.Victim = obj->GetGUID();
4226 
4227  _genericVictimTargets[effIndex].push_back(spellLogEffectGenericVictimParams);
4228 }
Definition: Spell.h:155
std::vector< SpellLogEffectGenericVictimParams > _genericVictimTargets[MAX_SPELL_EFFECTS]
Definition: Spell.h:835
ObjectGuid const & GetGUID() const
Definition: Object.h:105
ObjectGuid Victim
Definition: Spell.h:157

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Spell::finish ( bool  ok = true)
3621 {
3622  if (!m_caster)
3623  return;
3624 
3626  return;
3628 
3629  if (m_spellInfo->IsChanneled())
3631 
3632  if (m_caster->HasUnitState(UNIT_STATE_CASTING) && !m_caster->IsNonMeleeSpellCast(false, false, true))
3634 
3635  // Unsummon summon as possessed creatures on spell cancel
3637  {
3638  if (Unit* charm = m_caster->GetCharm())
3639  if (charm->GetTypeId() == TYPEID_UNIT
3640  && charm->ToCreature()->HasUnitTypeMask(UNIT_MASK_PUPPET)
3641  && charm->GetUInt32Value(UNIT_CREATED_BY_SPELL) == m_spellInfo->Id)
3642  ((Puppet*)charm)->UnSummon();
3643  }
3644 
3645  if (Creature* creatureCaster = m_caster->ToCreature())
3646  creatureCaster->ReleaseFocus(this);
3647 
3648  if (!ok)
3649  return;
3650 
3652  {
3653  // Unsummon statue
3655  SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spell);
3656  if (spellInfo && spellInfo->SpellIconID == 2056)
3657  {
3658  TC_LOG_DEBUG("spells", "Statue %s is unsummoned in spell %d finish", m_caster->GetGUID().ToString().c_str(), m_spellInfo->Id);
3660  return;
3661  }
3662  }
3663 
3664  if (IsAutoActionResetSpell())
3665  {
3666  bool found = false;
3668  for (Unit::AuraEffectList::const_iterator i = vIgnoreReset.begin(); i != vIgnoreReset.end(); ++i)
3669  {
3670  if ((*i)->IsAffectingSpell(m_spellInfo))
3671  {
3672  found = true;
3673  break;
3674  }
3675  }
3677  {
3679  if (m_caster->haveOffhandWeapon())
3682  }
3683  }
3684 
3685  // potions disabled by client, send event "not in combat" if need
3686  if (m_caster->GetTypeId() == TYPEID_PLAYER)
3687  {
3689  m_caster->ToPlayer()->UpdatePotionCooldown(this);
3690 
3691  // triggered spell pointer can be not set in some cases
3692  // this is needed for proper apply of triggered spell mods
3693  m_caster->ToPlayer()->SetSpellModTakingSpell(this, true);
3694 
3695  // Take mods after trigger spell (needed for 14177 to affect 48664)
3696  // mods are taken only on succesfull cast and independantly from targets of the spell
3697  m_caster->ToPlayer()->RemoveSpellMods(this);
3698  m_caster->ToPlayer()->SetSpellModTakingSpell(this, false);
3699  }
3700 
3701  // Stop Attack for some spells
3703  m_caster->AttackStop();
3704 }
bool AttackStop()
Definition: Unit.cpp:7337
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
uint32 GetUInt32Value(uint16 index) const
Definition: Object.cpp:300
bool IsChanneled() const
Definition: SpellInfo.cpp:1514
void UpdateInterruptMask()
Definition: Unit.cpp:557
Definition: Unit.h:565
Definition: SpellInfo.h:326
Definition: TemporarySummon.h:107
Definition: Unit.h:542
Definition: Unit.h:619
Definition: UpdateFields.h:134
SpellInfo const * m_triggeredByAuraSpell
Definition: Spell.h:826
std::list< AuraEffect * > AuraEffectList
Definition: Unit.h:1322
Definition: ObjectGuid.h:32
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
Definition: Creature.h:467
Definition: SharedDefines.h:376
bool IsNonMeleeSpellCast(bool withDelayed, bool skipChanneled=false, bool skipAutorepeat=false, bool isAutoshoot=false, bool skipInstant=true) const
Definition: Unit.cpp:2886
Definition: SpellAuraDefines.h:332
Player * ToPlayer()
Definition: Object.h:191
void ClearUnitState(uint32 f)
Definition: Unit.h:1396
TypeID GetTypeId() const
Definition: Object.h:113
Definition: Unit.h:618
Unit * GetCharm() const
Definition: Unit.cpp:7612
bool HasAttribute(SpellAttr0 attribute) const
Definition: SpellInfo.h:462
#define sSpellMgr
Definition: SpellMgr.h:756
AuraEffectList const & GetAuraEffectsByType(AuraType type) const
Definition: Unit.h:1832
uint32_t uint32
Definition: Define.h:150
bool haveOffhandWeapon() const
Definition: Unit.cpp:418
bool IsAutoActionResetSpell() const
Definition: Spell.cpp:6690
void resetAttackTimer(WeaponAttackType type=BASE_ATTACK)
Definition: Unit.cpp:481
ObjectGuid const & GetGUID() const
Definition: Object.h:105
Definition: ObjectGuid.h:33
virtual void setDeathState(DeathState s)
Definition: Unit.cpp:10593
Creature * ToCreature()
Definition: Object.h:194
uint32 SpellIconID
Definition: SpellInfo.h:390
bool HasUnitState(const uint32 f) const
Definition: Unit.h:1395
Definition: SharedDefines.h:445
bool IsSummon() const
Definition: Unit.h:1401
Definition: Unit.h:1305
Definition: Spell.h:279
Definition: Unit.h:864
std::string ToString() const
Definition: ObjectGuid.cpp:99
Definition: Unit.h:617

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Spell::FinishTargetProcessing ( )
protected
7024 {
7026 }
void SendSpellExecuteLog()
Definition: Spell.cpp:4104

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Unit* Spell::GetCaster ( ) const
inline
612 { return m_caster; }
Unit *const m_caster
Definition: Spell.h:647

+ Here is the caller graph for this function:

int32 Spell::GetCastTime ( ) const
inline
590 { return m_casttime; }
int32 m_casttime
Definition: Spell.h:660

+ Here is the caller graph for this function:

CurrentSpellTypes Spell::GetCurrentContainer ( ) const
6567 {
6568  if (IsNextMeleeSwingSpell())
6569  return(CURRENT_MELEE_SPELL);
6570  else if (IsAutoRepeat())
6571  return(CURRENT_AUTOREPEAT_SPELL);
6572  else if (m_spellInfo->IsChanneled())
6573  return(CURRENT_CHANNELED_SPELL);
6574  else
6575  return(CURRENT_GENERIC_SPELL);
6576 }
SpellInfo const *const m_spellInfo
Definition: Spell.h:547
Definition: Unit.h:1109
bool IsChanneled() const
Definition: SpellInfo.cpp:1514
Definition: Unit.h:1110
bool IsAutoRepeat() const
Definition: Spell.h:591
bool IsNextMeleeSwingSpell() const
Definition: Spell.cpp:6685
Definition: Unit.h:1111
Definition: Unit.h:1108

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

uint64 Spell::GetDelayMoment ( ) const
inline
606 { return m_delayMoment; }
uint64 m_delayMoment
Definition: Spell.h:679

+ Here is the caller graph for this function:

uint64 Spell::GetDelayStart ( ) const
inline
604 { return m_delayStart; }
uint64 m_delayStart
Definition: Spell.h:678

+ Here is the caller graph for this function:

SpellEffectInfo const* Spell::GetEffect ( uint32  index) const
inline
625  {
626  if (index >= _effects.size())
627  return nullptr;
628 
629  return _effects[index];
630  }
SpellEffectInfoVector _effects
Definition: Spell.h:850

+ Here is the caller graph for this function:

SpellEffectInfoVector const& Spell::GetEffects ( ) const
inline
623 { return _effects; }
SpellEffectInfoVector _effects
Definition: Spell.h:850

+ Here is the caller graph for this function:

Unit* Spell::GetOriginalCaster ( ) const
inline
613 { return m_originalCaster; }
Unit * m_originalCaster
Definition: Spell.h:653

+ Here is the caller graph for this function:

std::vector<SpellInfo::CostData> Spell::GetPowerCost ( ) const
inline
615 { return m_powerCost; }
std::vector< SpellInfo::CostData > m_powerCost
Definition: Spell.h:659
uint32 Spell::GetSearcherTypeMask ( SpellTargetObjectTypes  objType,
ConditionContainer condList 
)
1757 {
1758  // this function selects which containers need to be searched for spell target
1759  uint32 retMask = GRID_MAP_TYPE_MASK_ALL;
1760 
1761  // filter searchers based on searched object type
1762  switch (objType)
1763  {
1770  break;
1773  retMask &= GRID_MAP_TYPE_MASK_GAMEOBJECT;
1774  break;
1775  default:
1776  break;
1777  }
1779  retMask &= ~GRID_MAP_TYPE_MASK_CORPSE;
1783  retMask &= GRID_MAP_TYPE_MASK_PLAYER;
1784 
1785  if (condList)
1786  retMask &= sConditionMgr->GetSearcherTypeMaskForConditionList(*condList);
1787  return retMask;
1788 }
Definition: SharedDefines.h:472
SpellInfo const *const m_spellInfo
Definition: Spell.h:547
Definition: GridDefines.h:79
Definition: SpellInfo.h:110
Definition: SpellInfo.h:114
Definition: SpellInfo.h:115
Definition: SpellInfo.h:112
Definition: SpellInfo.h:109
Definition: SpellInfo.h:107
Definition: GridDefines.h:77
Definition: SpellInfo.h:108
Definition: GridDefines.h:76
bool HasAttribute(SpellAttr0 attribute) const
Definition: SpellInfo.h:462
Definition: SharedDefines.h:428
uint32_t uint32
Definition: Define.h:150
#define sConditionMgr
Definition: ConditionMgr.h:307
Definition: SharedDefines.h:476
Definition: GridDefines.h:74
Definition: GridDefines.h:73

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

SpellInfo const* Spell::GetSpellInfo ( ) const
inline
614 { return m_spellInfo; }
SpellInfo const *const m_spellInfo
Definition: Spell.h:547

+ Here is the caller graph for this function:

uint32 Spell::getState ( ) const
inline
509 { return m_spellState; }
uint32 m_spellState
Definition: Spell.h:818

+ Here is the caller graph for this function:

int32 Spell::GetTimer ( ) const
inline
638 { return m_timer; }
int32 m_timer
Definition: Spell.h:819
SpellInfo const* Spell::GetTriggeredByAuraSpell ( ) const
inline
636 { return m_triggeredByAuraSpell; }
SpellInfo const * m_triggeredByAuraSpell
Definition: Spell.h:826
uint64 Spell::handle_delayed ( uint64  t_offset)
3393 {
3394  if (!UpdatePointers())
3395  {
3396  // finish the spell if UpdatePointers() returned false, something wrong happened there
3397  finish(false);
3398  return 0;
3399  }
3400 
3401  if (m_caster->GetTypeId() == TYPEID_PLAYER)
3402  m_caster->ToPlayer()->SetSpellModTakingSpell(this, true);
3403 
3404  uint64 next_time = 0;
3405 
3407 
3408  if (!m_immediateHandled)
3409  {
3411  m_immediateHandled = true;
3412  }
3413 
3414  bool single_missile = (m_targets.HasDst());
3415 
3416  // now recheck units targeting correctness (need before any effects apply to prevent adding immunity at first effect not allow apply second spell effect and similar cases)
3417  for (std::vector<TargetInfo>::iterator ihit = m_UniqueTargetInfo.begin(); ihit != m_UniqueTargetInfo.end(); ++ihit)
3418  {
3419  if (ihit->processed == false)
3420  {
3421  if (single_missile || ihit->timeDelay <= t_offset)
3422  {
3423  ihit->timeDelay = t_offset;
3424  DoAllEffectOnTarget(&(*ihit));
3425  }
3426  else if (next_time == 0 || ihit->timeDelay < next_time)
3427  next_time = ihit->timeDelay;
3428  }
3429  }
3430 
3431  // now recheck gameobject targeting correctness
3432  for (std::vector<GOTargetInfo>::iterator ighit = m_UniqueGOTargetInfo.begin(); ighit != m_UniqueGOTargetInfo.end(); ++ighit)
3433  {
3434  if (ighit->processed == false)
3435  {
3436  if (single_missile || ighit->timeDelay <= t_offset)
3437  DoAllEffectOnTarget(&(*ighit));
3438  else if (next_time == 0 || ighit->timeDelay < next_time)
3439  next_time = ighit->timeDelay;
3440  }
3441  }
3442 
3444 
3445  if (m_caster->GetTypeId() == TYPEID_PLAYER)
3446  m_caster->ToPlayer()->SetSpellModTakingSpell(this, false);
3447 
3448  // All targets passed - need finish phase
3449  if (next_time == 0)
3450  {
3451  // spell is finished, perform some last features of the spell here
3453 
3454  finish(true); // successfully finish spell cast
3455 
3456  // return zero, spell is finished now
3457  return 0;
3458  }
3459  else
3460  {
3461  // spell is unfinished, return next execution time
3462  return next_time;
3463  }
3464 }
Unit *const m_caster
Definition: Spell.h:647
void _handle_finish_phase()
Definition: Spell.cpp:3508
SpellCastTargets m_targets
Definition: Spell.h:584
void _handle_immediate_phase()
Definition: Spell.cpp:3466
void PrepareTargetProcessing()
Definition: Spell.cpp:7019
bool m_immediateHandled
Definition: Spell.h:680
Player * ToPlayer()
Definition: Object.h:191
void DoAllEffectOnTarget(TargetInfo *target)
Definition: Spell.cpp:2245
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
bool HasDst() const
Definition: Spell.h:229
uint64_t uint64
Definition: Define.h:149
std::vector< GOTargetInfo > m_UniqueGOTargetInfo
Definition: Spell.h:749
Definition: ObjectGuid.h:33
void FinishTargetProcessing()
Definition: Spell.cpp:7023
bool UpdatePointers()
Definition: Spell.cpp:6508

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Spell::handle_immediate ( )
3341 {
3342  // start channeling if applicable
3343  if (m_spellInfo->IsChanneled())
3344  {
3345  int32 duration = m_spellInfo->GetDuration();
3346  if (duration > 0)
3347  {
3348  // First mod_duration then haste - see Missile Barrage
3349  // Apply duration mod
3350  if (Player* modOwner = m_caster->GetSpellModOwner())
3351  modOwner->ApplySpellMod(m_spellInfo->Id, SPELLMOD_DURATION, duration);
3352 
3353  // Apply haste mods
3354  m_caster->ModSpellDurationTime(m_spellInfo, duration, this);
3355 
3358  m_channeledDuration = duration;
3359  SendChannelStart(duration);
3360  }
3361  else if (duration == -1)
3362  {
3365  SendChannelStart(duration);
3366  }
3367  }
3368 
3370 
3371  // process immediate effects (items, ground, etc.) also initialize some variables
3373 
3374  for (std::vector<TargetInfo>::iterator ihit = m_UniqueTargetInfo.begin(); ihit != m_UniqueTargetInfo.end(); ++ihit)
3375  DoAllEffectOnTarget(&(*ihit));
3376 
3377  for (std::vector<GOTargetInfo>::iterator ihit = m_UniqueGOTargetInfo.begin(); ihit != m_UniqueGOTargetInfo.end(); ++ihit)
3378  DoAllEffectOnTarget(&(*ihit));
3379 
3381 
3382  // spell is finished, perform some last features of the spell here
3384 
3385  // Remove used for cast item if need (it can be already NULL after TakeReagents call
3386  TakeCastItem();
3387 
3389  finish(true); // successfully finish spell cast (not last in case autorepeat or channel spell)
3390 }
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
bool IsChanneled() const
Definition: SpellInfo.cpp:1514
void ModSpellDurationTime(SpellInfo const *spellProto, int32 &castTime, Spell *spell=NULL)
Definition: Unit.cpp:11067
Definition: Unit.h:87
void _handle_finish_phase()
Definition: Spell.cpp:3508
void TakeCastItem()
Definition: Spell.cpp:4338
void _handle_immediate_phase()
Definition: Spell.cpp:3466
void PrepareTargetProcessing()
Definition: Spell.cpp:7019
int32 GetDuration() const
Definition: SpellInfo.cpp:2490
void DoAllEffectOnTarget(TargetInfo *target)
Definition: Spell.cpp:2245
std::vector< TargetInfo > m_UniqueTargetInfo
Definition: Spell.h:739
void finish(bool ok=true)
Definition: Spell.cpp:3620
int32_t int32
Definition: Define.h:146
Definition: Spell.h:278
void SendChannelStart(uint32 duration)
Definition: Spell.cpp:4280
std::vector< GOTargetInfo > m_UniqueGOTargetInfo
Definition: Spell.h:749
Player * GetSpellModOwner() const
Definition: Unit.cpp:12691
uint32 ChannelInterruptFlags
Definition: SpellInfo.h:369
int32 m_channeledDuration
Definition: Spell.h:661
void FinishTargetProcessing()
Definition: Spell.cpp:7023
void AddInterruptMask(uint32 mask)
Definition: Unit.h:2009

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Spell::HandleEffects ( Unit pUnitTarget,
Item pItemTarget,
GameObject pGOTarget,
uint32  i,
SpellEffectHandleMode  mode 
)
4712 {
4713  effectHandleMode = mode;
4714  unitTarget = pUnitTarget;
4715  itemTarget = pItemTarget;
4716  gameObjTarget = pGOTarget;
4718 
4719  effectInfo = GetEffect(i);
4720  if (!effectInfo)
4721  {
4722  TC_LOG_ERROR("spells", "Spell: %u HandleEffects at EffectIndex: %u missing effect", m_spellInfo->Id, i);
4723  return;
4724  }
4725  uint32 eff = effectInfo->Effect;
4726 
4727  TC_LOG_DEBUG("spells", "Spell: %u Effect: %u", m_spellInfo->Id, eff);
4728 
4730 
4731  bool preventDefault = CallScriptEffectHandlers((SpellEffIndex)i, mode);
4732 
4733  if (!preventDefault && eff < TOTAL_SPELL_EFFECTS)
4734  {
4735  (this->*SpellEffects[eff])((SpellEffIndex)i);
4736  }
4737 }
GameObject * gameObjTarget
Definition: Spell.h:692
SpellInfo const *const m_spellInfo
Definition: Spell.h:547
uint32 Id
Definition: SpellInfo.h:329
SpellEffectInfo const * effectInfo
Definition: Spell.h:697
Definition: SharedDefines.h:1262
WorldLocation _position
Definition: Spell.h:128
int32 CalculateDamage(uint8 i, Unit const *target, float *var=nullptr) const
Definition: Spell.h:504
SpellEffectInfo const * GetEffect(uint32 index) const
Definition: Spell.h:624
pEffect SpellEffects[TOTAL_SPELL_EFFECTS]
Definition: SpellEffects.cpp:66
WorldLocation * destTarget
Definition: Spell.h:693
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
Unit * unitTarget
Definition: Spell.h:690
int32 damage
Definition: Spell.h:694
SpellEffIndex
Definition: SharedDefines.h:26
uint32_t uint32
Definition: Define.h:150
Item * itemTarget
Definition: Spell.h:691
float variance
Definition: Spell.h:695
bool CallScriptEffectHandlers(SpellEffIndex effIndex, SpellEffectHandleMode mode)
Definition: Spell.cpp:7111
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
uint32 Effect
Definition: SpellInfo.h:243
SpellDestination m_destTargets[MAX_SPELL_EFFECTS]
Definition: Spell.h:758
SpellEffectHandleMode effectHandleMode
Definition: Spell.h:696

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Spell::HandleLaunchPhase ( )
protected
6850 {
6851  // handle effects with SPELL_EFFECT_HANDLE_LAUNCH mode
6852  for (SpellEffectInfo const* effect : GetEffects())
6853  {
6854  // don't do anything for empty effect
6855  if (!effect || !effect->IsEffect())
6856  continue;
6857 
6858  HandleEffects(NULL, NULL, NULL, effect->EffectIndex, SPELL_EFFECT_HANDLE_LAUNCH);
6859  }
6860 
6861  float multiplier[MAX_SPELL_EFFECTS];
6862  for (SpellEffectInfo const* effect : GetEffects())
6863  if (effect && (m_applyMultiplierMask & (1 << effect->EffectIndex)))
6864  multiplier[effect->EffectIndex] = effect->CalcDamageMultiplier(m_originalCaster, this);
6865 
6866  for (std::vector<TargetInfo>::iterator ihit = m_UniqueTargetInfo.begin(); ihit != m_UniqueTargetInfo.end(); ++ihit)
6867  {
6868  TargetInfo& target = *ihit;
6869 
6870  uint32 mask = target.effectMask;
6871  if (!mask)
6872  continue;
6873 
6874  DoAllEffectOnLaunchTarget(target, multiplier);
6875  }
6876 }
void HandleEffects(Unit *pUnitTarget, Item *pItemTarget, GameObject *pGOTarget, uint32 i, SpellEffectHandleMode mode)
Definition: Spell.cpp:4711
arena_t NULL
Definition: jemalloc_internal.h:624
void DoAllEffectOnLaunchTarget(TargetInfo &targetInfo, float *multiplier)
Definition: Spell.cpp:6878
std::vector< TargetInfo > m_UniqueTargetInfo
Definition: Spell.h:739
Unit * m_originalCaster
Definition: Spell.h:653
Definition: SpellInfo.h:238
uint32_t uint32
Definition: Define.h:150
SpellEffectInfoVector const & GetEffects() const
Definition: Spell.h:623
uint8 m_applyMultiplierMask
Definition: Spell.h:686
#define MAX_SPELL_EFFECTS
Definition: DBCStructure.h:1026
Definition: Spell.h:286

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Spell::HandleThreatSpells ( )
4660 {
4661  if (m_UniqueTargetInfo.empty())
4662  return;
4663 
4666  return;
4667 
4668  float threat = 0.0f;
4669  if (SpellThreatEntry const* threatEntry = sSpellMgr->GetSpellThreatEntry(m_spellInfo->Id))
4670  {
4671  if (threatEntry->apPctMod != 0.0f)
4672  threat += threatEntry->apPctMod * m_caster->GetTotalAttackPowerValue(BASE_ATTACK);
4673 
4674  threat += threatEntry->flatMod;
4675  }
4677  threat += m_spellInfo->SpellLevel;
4678 
4679  // past this point only multiplicative effects occur
4680  if (threat == 0.0f)
4681  return;
4682 
4683  // since 2.0.1 threat from positive effects also is distributed among all targets, so the overall caused threat is at most the defined bonus
4684  threat /= m_UniqueTargetInfo.size();
4685 
4686  for (std::vector<TargetInfo>::iterator ihit = m_UniqueTargetInfo.begin(); ihit != m_UniqueTargetInfo.end(); ++ihit)
4687  {
4688  float threatToAdd = threat;
4689  if (ihit->missCondition != SPELL_MISS_NONE)
4690  threatToAdd = 0.0f;
4691 
4692  Unit* target = ObjectAccessor::GetUnit(*m_caster, ihit->targetGUID);
4693  if (!target)
4694  continue;
4695 
4696  // positive spells distribute threat among all units that are in combat with target, like healing
4698  target->getHostileRefManager().threatAssist(m_caster, threatToAdd, m_spellInfo);
4699  // for negative spells threat gets distributed among affected targets
4700  else
4701  {
4702  if (!target->CanHaveThreatList())
4703  continue;
4704 
4705  target->AddThreat(m_caster, threatToAdd, m_spellInfo->GetSchoolMask(), m_spellInfo);
4706  }
4707  }
4708  TC_LOG_DEBUG("spells", "Spell %u, added an additional %f threat for %s %u target(s)", m_spellInfo->Id, threat, m_spellInfo->_IsPositiveSpell() ? "assisting" : "harming", uint32(m_UniqueTargetInfo.size()));
4709 }
SpellInfo const *const m_spellInfo
Definition: Spell.h:547
Unit *const m_caster
Definition: Spell.h:647
uint32 Id
Definition: SpellInfo.h:329
void AddThreat(Unit *victim, float fThreat, SpellSchoolMask schoolMask=SPELL_SCHOOL_MASK_NORMAL, SpellInfo const *threatSpell=NULL)
Definition: Unit.cpp:10691
void threatAssist(Unit *victim, float baseThreat, SpellInfo const *threatSpell=NULL)
Definition: HostileRefManager.cpp:35
Definition: SharedDefines.h:481
TC_GAME_API Unit * GetUnit(WorldObject const &, ObjectGuid const &guid)
Definition: ObjectAccessor.cpp:163
uint32 SpellLevel
Definition: SpellInfo.h:375
uint32 AttributesEx
Definition: SpellInfo.h:334
bool _IsPositiveSpell() const
Definition: SpellInfo.cpp:3178
Definition: SpellInfo.h:188
Definition: SharedDefines.h:2021
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
bool CanHaveThreatList(bool skipAliveCheck=false) const
Definition: Unit.cpp:10652
std::vector< TargetInfo > m_UniqueTargetInfo
Definition: Spell.h:739
Definition: SpellMgr.h:349
HostileRefManager & getHostileRefManager()
Definition: Unit.h:2001
Definition: SharedDefines.h:402
bool HasAttribute(SpellAttr0 attribute) const
Definition: SpellInfo.h:462
#define sSpellMgr
Definition: SpellMgr.h:756
SpellSchoolMask GetSchoolMask() const
Definition: SpellInfo.cpp:2131
uint32_t uint32
Definition: g3dmath.h:168
float GetTotalAttackPowerValue(WeaponAttackType attType) const
Definition: Unit.cpp:11491
Definition: Unit.h:1305
Definition: Unit.h:617

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool Spell::HasEffect ( SpellEffectName  effect) const
7411 {
7412  for (SpellEffectInfo const* eff : GetEffects())
7413  {
7414  if (eff && eff->IsEffect(effect))
7415  return true;
7416  }
7417  return false;
7418 }
Definition: SpellInfo.h:238
SpellEffectInfoVector const & GetEffects() const
Definition: Spell.h:623

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool Spell::HasGlobalCooldown ( ) const
protected
7352 {
7353  // Only players or controlled units have global cooldown
7355  return false;
7356 
7358 }
SpellInfo const *const m_spellInfo
Definition: Spell.h:547
Unit *const m_caster
Definition: Spell.h:647
CharmInfo * GetCharmInfo()
Definition: Unit.h:1748
TypeID GetTypeId() const
Definition: Object.h:113
SpellHistory * GetSpellHistory()
Definition: Unit.h:1926
Definition: ObjectGuid.h:33
bool HasGlobalCooldown(SpellInfo const *spellInfo) const
Definition: SpellHistory.cpp:821

+ Here is the caller graph for this function:

bool Spell::HaveTargetsForEffect ( uint8  effect) const
6703 {
6704  for (std::vector<TargetInfo>::const_iterator itr = m_UniqueTargetInfo.begin(); itr != m_UniqueTargetInfo.end(); ++itr)
6705  if (itr->effectMask & (1 << effect))
6706  return true;
6707 
6708  for (std::vector<GOTargetInfo>::const_iterator itr = m_UniqueGOTargetInfo.begin(); itr != m_UniqueGOTargetInfo.end(); ++itr)
6709  if (itr->effectMask & (1 << effect))
6710  return true;
6711 
6712  for (std::vector<ItemTargetInfo>::const_iterator itr = m_UniqueItemInfo.begin(); itr != m_UniqueItemInfo.end(); ++itr)
6713  if (itr->effectMask & (1 << effect))
6714  return true;
6715 
6716  return false;
6717 }
std::vector< TargetInfo > m_UniqueTargetInfo
Definition: Spell.h:739
std::vector< ItemTargetInfo > m_UniqueItemInfo
Definition: Spell.h:756
std::vector< GOTargetInfo > m_UniqueGOTargetInfo
Definition: Spell.h:749
void Spell::InitExplicitTargets ( SpellCastTargets const targets)
652 {
653  m_targets = targets;
655  // this function tries to correct spell explicit targets for spell
656  // client doesn't send explicit targets correctly sometimes - we need to fix such spells serverside
657  // this also makes sure that we correctly send explicit targets to client (removes redundant data)
658  uint32 neededTargets = m_spellInfo->GetExplicitTargetMask();
659 
660  if (WorldObject* target = m_targets.GetObjectTarget())
661  {
662  // check if object target is valid with needed target flags
663  // for unit case allow corpse target mask because player with not released corpse is a unit target
664  if ((target->ToUnit() && !(neededTargets & (TARGET_FLAG_UNIT_MASK | TARGET_FLAG_CORPSE_MASK)))
665  || (target->ToGameObject() && !(neededTargets & TARGET_FLAG_GAMEOBJECT_MASK))
666  || (target->ToCorpse() && !(neededTargets & TARGET_FLAG_CORPSE_MASK)))
668  }
669  else
670  {
671  // try to select correct unit target if not provided by client or by serverside cast
672  if (neededTargets & (TARGET_FLAG_UNIT_MASK))
673  {
674  Unit* unit = NULL;
675  // try to use player selection as a target
676  if (Player* playerCaster = m_caster->ToPlayer())
677  {
678  // selection has to be found and to be valid target for the spell
679  if (Unit* selectedUnit = ObjectAccessor::GetUnit(*m_caster, playerCaster->GetTarget()))
680  if (m_spellInfo->CheckExplicitTarget(m_caster, selectedUnit) == SPELL_CAST_OK)
681  unit = selectedUnit;
682  }
683  // try to use attacked unit as a target
684  else if ((m_caster->GetTypeId() == TYPEID_UNIT) && neededTargets & (TARGET_FLAG_UNIT_ENEMY | TARGET_FLAG_UNIT))
685  unit = m_caster->GetVictim();
686 
687  // didn't find anything - let's use self as target
688  if (!unit && neededTargets & (TARGET_FLAG_UNIT_RAID | TARGET_FLAG_UNIT_PARTY | TARGET_FLAG_UNIT_ALLY))
689  unit = m_caster;
690 
691  m_targets.SetUnitTarget(unit);
692  }
693  }
694 
695  // check if spell needs dst target
696  if (neededTargets & TARGET_FLAG_DEST_LOCATION)
697  {
698  // and target isn't set
699  if (!m_targets.HasDst())
700  {
701  // try to use unit target if provided
702  if (WorldObject* target = targets.GetObjectTarget())
703  m_targets.SetDst(*target);
704  // or use self if not available
705  else
707  }
708  }
709  else
711 
712  if (neededTargets & TARGET_FLAG_SOURCE_LOCATION)
713  {
714  if (!targets.HasSrc())
716  }
717  else
719 }
SpellInfo const *const m_spellInfo
Definition: Spell.h:547
Unit *const m_caster
Definition: Spell.h:647
Unit * GetUnitTarget() const
Definition: Spell.cpp:222
Definition: SpellInfo.h:49
Definition: SpellInfo.h:77
uint32 GetExplicitTargetMask() const
Definition: SpellInfo.cpp:2216
void SetSrc(float x, float y, float z)
Definition: Spell.cpp:338
TC_GAME_API Unit * GetUnit(WorldObject const &, ObjectGuid const &guid)
Definition: ObjectAccessor.cpp:163
SpellCastTargets m_targets
Definition: Spell.h:584
Definition: SpellInfo.h:56
SpellCastResult CheckExplicitTarget(Unit const *caster, WorldObject const *target, Item const *itemTarget=NULL) const
Definition: SpellInfo.cpp:2026
void RemoveDst()
Definition: Spell.cpp:419
Definition: SpellInfo.h:53
Definition: ObjectGuid.h:32
arena_t NULL
Definition: jemalloc_internal.h:624
void RemoveObjectTarget()
Definition: Spell.cpp:292
Definition: Object.h:423
Player * ToPlayer()
Definition: Object.h:191
TypeID GetTypeId() const
Definition: Object.h:113
WorldObject * GetObjectTarget() const
Definition: Spell.cpp:282
bool HasDst() const
Definition: Spell.h:229
Definition: SpellInfo.h:50
void SetOrigUnitTarget(Unit *target)
Definition: Spell.cpp:206
Unit * GetVictim() const
Definition: Unit.h:1379
Definition: SpellInfo.h:51
Definition: SpellInfo.h:55
void SetUnitTarget(Unit *target)
Definition: Spell.cpp:230
Definition: SpellInfo.h:78
uint32_t uint32
Definition: Define.h:150
Definition: SpellInfo.h:54
ObjectGuid GetTarget() const
Definition: Unit.h:2209
Definition: SpellInfo.h:75
void SetDst(float x, float y, float z, float orientation, uint32 mapId=MAPID_INVALID)
Definition: Spell.cpp:377
Definition: Unit.h:1305
Definition: SharedDefines.h:1538
void RemoveSrc()
Definition: Spell.cpp:362

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool Spell::IsAutoActionResetSpell ( ) const
Todo:
changed SPELL_INTERRUPT_FLAG_AUTOATTACK -> SPELL_INTERRUPT_FLAG_INTERRUPT to fix compile - is this check correct at all?
6691 {
6694 }
SpellInfo const *const m_spellInfo
Definition: Spell.h:547
bool IsTriggered() const
Definition: Spell.h:595
Definition: Unit.h:40
uint32 InterruptFlags
Definition: SpellInfo.h:367

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool Spell::IsAutoRepeat ( ) const
inline
591 { return m_autoRepeat; }
bool m_autoRepeat
Definition: Spell.h:663

+ Here is the caller graph for this function:

bool Spell::IsChannelActive ( ) const
inline
597 { return m_caster->GetUInt32Value(UNIT_CHANNEL_SPELL) != 0; }
Unit *const m_caster
Definition: Spell.h:647
uint32 GetUInt32Value(uint16 index) const
Definition: Object.cpp:300
Definition: UpdateFields.h:93
bool Spell::isDelayableNoMore ( )
inlineprotected
669  {
670  if (m_delayAtDamageCount >= 2)
671  return true;
672 
674  return false;
675  }
uint8 m_delayAtDamageCount
Definition: Spell.h:667

+ Here is the caller graph for this function:

bool Spell::IsDeletable ( ) const
inline
bool m_executedCurrently
Definition: Spell.h:684
bool m_referencedFromCurrentSpell
Definition: Spell.h:683

+ Here is the caller graph for this function:

bool Spell::IsIgnoringCooldowns ( ) const
inline
Will ignore GCD.
Definition: Unit.h:462
TriggerCastFlags _triggeredCastFlags
Definition: Spell.h:821

+ Here is the caller graph for this function:

bool Spell::IsInterruptable ( ) const
inline
602 { return !m_executedCurrently; }
bool m_executedCurrently
Definition: Spell.h:684

+ Here is the caller graph for this function:

bool Spell::IsNeedSendToClient ( ) const
6697 {
6700 }
SpellInfo const *const m_spellInfo
Definition: Spell.h:547
Unit *const m_caster
Definition: Spell.h:647
bool IsChanneled() const
Definition: SpellInfo.cpp:1514
Map * GetMap() const
Definition: Object.h:543
Difficulty GetDifficultyID() const
Definition: Map.h:390
SpellInfo const * m_triggeredByAuraSpell
Definition: Spell.h:826
uint32 GetSpellXSpellVisualId(Difficulty difficulty) const
Definition: SpellInfo.cpp:2837
bool HasAttribute(SpellAttr0 attribute) const
Definition: SpellInfo.h:462
bool IsTriggered() const
Definition: Spell.h:595
float Speed
Definition: SpellInfo.h:380
Definition: SharedDefines.h:656

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool Spell::IsNextMeleeSwingSpell ( ) const
6686 {
6688 }
SpellInfo const *const m_spellInfo
Definition: Spell.h:547
bool HasAttribute(SpellAttr0 attribute) const
Definition: SpellInfo.h:462
Definition: SharedDefines.h:358

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool Spell::IsTriggered ( ) const
inline
595 { return (_triggeredCastFlags & TRIGGERED_FULL_MASK) != 0; }
Will ignore most target checks (mostly DBC target checks)
Definition: Unit.h:479
TriggerCastFlags _triggeredCastFlags
Definition: Spell.h:821

+ Here is the caller graph for this function:

bool Spell::IsValidDeadOrAliveTarget ( Unit const target) const
protected
6841 {
6842  if (target->IsAlive())
6845  return true;
6846  return false;
6847 }
SpellInfo const *const m_spellInfo
Definition: Spell.h:547
bool IsRequiringDeadTarget() const
Definition: SpellInfo.cpp:1480
bool IsAllowingDeadTarget() const
Definition: SpellInfo.cpp:1485

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Spell::LoadScripts ( )
protected
7029 {
7030  sScriptMgr->CreateSpellScripts(m_spellInfo->Id, m_loadedScripts);
7031  for (std::list<SpellScript*>::iterator itr = m_loadedScripts.begin(); itr != m_loadedScripts.end();)
7032  {
7033  if (!(*itr)->_Load(this))
7034  {
7035  std::list<SpellScript*>::iterator bitr = itr;
7036  ++itr;
7037  delete (*bitr);
7038  m_loadedScripts.erase(bitr);
7039  continue;
7040  }
7041  TC_LOG_DEBUG("spells", "Spell::LoadScripts: Script `%s` for spell `%u` is loaded now", (*itr)->_GetScriptName()->c_str(), m_spellInfo->Id);
7042  (*itr)->Register();
7043  ++itr;
7044  }
7045 }
SpellInfo const *const m_spellInfo
Definition: Spell.h:547
uint32 Id
Definition: SpellInfo.h:329
std::list< SpellScript * > m_loadedScripts
Definition: Spell.h:794
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
#define sScriptMgr
Definition: ScriptMgr.h:837

+ Here is the caller graph for this function:

Spell& Spell::operator= ( Spell const right)
protecteddelete
void Spell::prepare ( SpellCastTargets const targets,
AuraEffect const triggeredByAura = NULL 
)

this to all cast spells if needed

2861 {
2862  if (m_CastItem)
2863  {
2866 
2867  if (Player* owner = m_CastItem->GetOwner())
2869  else if (m_CastItem->GetOwnerGUID() == m_caster->GetGUID())
2871  else
2872  {
2874  finish(false);
2875  return;
2876  }
2877  }
2878 
2879  InitExplicitTargets(*targets);
2880 
2881  // Fill aura scaling information
2883  {
2884  for (SpellEffectInfo const* effect : GetEffects())
2885  {
2886  if (effect && effect->Effect == SPELL_EFFECT_APPLY_AURA)
2887  {
2888  // Change aura with ranks only if basepoints are taken from spellInfo and aura is positive
2889  if (m_spellInfo->IsPositiveEffect(effect->EffectIndex))
2890  {
2891  m_auraScaleMask |= (1 << effect->EffectIndex);
2892  if (m_spellValue->EffectBasePoints[effect->EffectIndex] != effect->BasePoints)
2893  {
2894  m_auraScaleMask = 0;
2895  break;
2896  }
2897  }
2898  }
2899  }
2900  }
2901 
2903 
2904  if (triggeredByAura)
2905  {
2906  m_triggeredByAuraSpell = triggeredByAura->GetSpellInfo();
2907  m_castItemLevel = triggeredByAura->GetBase()->GetCastItemLevel();
2908  }
2909 
2910  // create and add update event for this spell
2911  SpellEvent* Event = new SpellEvent(this);
2913 
2914  //Prevent casting at cast another spell (ServerSide check)
2916  {
2918  finish(false);
2919  return;
2920  }
2921 
2923  {
2925  finish(false);
2926  return;
2927  }
2928  LoadScripts();
2929 
2930  if (m_caster->GetTypeId() == TYPEID_PLAYER)
2931  m_caster->ToPlayer()->SetSpellModTakingSpell(this, true);
2932  // Fill cost data (not use power for item casts
2933  if (!m_CastItem)
2935  if (m_caster->GetTypeId() == TYPEID_PLAYER)
2936  m_caster->ToPlayer()->SetSpellModTakingSpell(this, false);
2937 
2938  // Set combo point requirement
2940  m_needComboPoints = false;
2941 
2942  SpellCastResult result = CheckCast(true);
2943  // target is checked in too many locations and with different results to handle each of them
2944  // handle just the general SPELL_FAILED_BAD_TARGETS result which is the default result for most DBC target checks
2946  result = SPELL_CAST_OK;
2947  if (result != SPELL_CAST_OK && !IsAutoRepeat()) //always cast autorepeat dummy for triggering
2948  {
2949  // Periodic auras should be interrupted when aura triggers a spell which can't be cast
2950  // for example bladestorm aura should be removed on disarm as of patch 3.3.5
2951  // channeled periodic spells should be affected by this (arcane missiles, penance, etc)
2952  // a possible alternative sollution for those would be validating aura target on unit state change
2953  if (triggeredByAura && triggeredByAura->IsPeriodic() && !triggeredByAura->GetBase()->IsPassive())
2954  {
2955  SendChannelUpdate(0);
2956  triggeredByAura->GetBase()->SetDuration(0);
2957  }
2958 
2959  if (m_caster->GetTypeId() == TYPEID_PLAYER)
2960  {
2961  m_caster->ToPlayer()->RestoreSpellMods(this);
2962  // cleanup after mod system
2963  // triggered spell pointer can be not removed in some cases
2964  m_caster->ToPlayer()->SetSpellModTakingSpell(this, false);
2965  }
2966 
2967  SendCastResult(result);
2968 
2969  finish(false);
2970  return;
2971  }
2972 
2973  // Prepare data for triggers
2974  prepareDataForTriggerSystem(triggeredByAura);
2975 
2976  if (Player* player = m_caster->ToPlayer())
2977  {
2978  if (!player->GetCommandStatus(CHEAT_CASTTIME))
2979  {
2980  player->SetSpellModTakingSpell(this, true);
2981  // calculate cast time (calculated after first CheckCast check to prevent charge counting for first CheckCast fail)
2982  m_casttime = m_spellInfo->CalcCastTime(player->getLevel(), this);
2983  player->SetSpellModTakingSpell(this, false);
2984  }
2985  else
2986  m_casttime = 0; // Set cast time to 0 if .cheat casttime is enabled.
2987  }
2988  else
2990 
2991  if (m_caster->GetTypeId() == TYPEID_UNIT && !m_caster->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED)) // _UNIT actually means creature. for some reason.
2993  {
2995  {
2997  {
2998  m_isDelayedInstantCast = true;
2999  m_timer = 100; // 100ms delay ensures client has updated creature orientation when cast goes off
3000  }
3001  }
3003  {
3004  if (m_caster->ToCreature()->FocusTarget(this, nullptr))
3005  {
3006  m_isDelayedInstantCast = true;
3007  m_timer = 100;
3008  }
3009  }
3010  }
3011 
3012  // don't allow channeled spells / spells with cast time to be cast while moving
3013  // (even if they are interrupted on moving, spells with almost immediate effect get to have their effect processed before movement interrupter kicks in)
3014  // don't cancel spells which are affected by a SPELL_AURA_CAST_WHILE_WALKING effect
3017  {
3019  finish(false);
3020  return;
3021  }
3022 
3023  // set timer base at cast time
3024  ReSetTimer();
3025 
3026  TC_LOG_DEBUG("spells", "Spell::prepare: spell id %u source %u caster %d customCastFlags %u mask %u", m_spellInfo->Id, m_caster->GetEntry(), m_originalCaster ? m_originalCaster->GetEntry() : -1, _triggeredCastFlags, m_targets.GetTargetMask());
3027 
3028  //Containers for channeled spells have to be set
3030  // Why check duration? 29350: channelled triggers channelled
3032  cast(true);
3033  else
3034  {
3035  // stealth must be removed at cast starting (at show channel bar)
3036  // skip triggered spell (item equip spell casting and other not explicit character casts/item uses)
3038  {
3040  for (SpellEffectInfo const* effect : GetEffects())
3041  if (effect && effect->GetUsedTargetObjectType() == TARGET_OBJECT_TYPE_UNIT)
3042  {
3044  break;
3045  }
3046  }
3047 
3050  SendSpellStart();
3051 
3054 
3055  //item: first cast may destroy item and second cast causes crash
3057  cast(true);
3058  }
3059 }
Definition: Unit.h:56
SpellInfo const *const m_spellInfo
Definition: Spell.h:547
Unit *const m_caster
Definition: Spell.h:647
uint32 m_spellState
Definition: Spell.h:818
Definition: Unit.h:1109
EventProcessor m_Events
Definition: Unit.h:1948
uint32 Id
Definition: SpellInfo.h:329
bool IsDisabledFor(DisableType type, uint32 entry, Unit const *unit, uint8 flags)
Definition: DisableMgr.cpp:277
bool IsPassive() const
Definition: SpellInfo.cpp:1403
bool IsChanneled() const
Definition: SpellInfo.cpp:1514
int32 m_casttime
Definition: Spell.h:660
void SetCurrentCastSpell(Spell *pSpell)
Definition: Unit.cpp:2773
uint32 SpellLevel
Definition: SpellInfo.h:375
bool IsControlledByPlayer() const
Definition: Unit.h:1712
SpellCastTargets m_targets
Definition: Spell.h:584
bool IsPositiveEffect(uint8 effIndex) const
Definition: SpellInfo.cpp:1500
uint32 CalcCastTime(uint8 level=0, Spell *spell=NULL) const
Definition: SpellInfo.cpp:2504
void AddEvent(BasicEvent *Event, uint64 e_time, bool set_addtime=true)
Definition: EventProcessor.cpp:88
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
SpellInfo const * m_triggeredByAuraSpell
Definition: Spell.h:826
void SendSpellStart()
Definition: Spell.cpp:3858
void RemoveAurasWithInterruptFlags(uint32 flag, uint32 except=0)
Definition: Unit.cpp:3816
Definition: SharedDefines.h:1391
bool IsAutoRepeat() const
Definition: Spell.h:591
Definition: ObjectGuid.h:32
uint32 m_castItemEntry
Definition: Spell.h:550
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
Definition: SharedDefines.h:1016
bool HasAuraTypeWithAffectMask(AuraType auratype, SpellInfo const *affectedSpell) const
Definition: Unit.cpp:4270
Not triggered.
Definition: Unit.h:461
Definition: SpellInfo.h:107
Definition: SharedDefines.h:1298
int32 m_timer
Definition: Spell.h:819
Item * m_CastItem
Definition: Spell.h:548
SpellValue *const m_spellValue
Definition: Spell.h:649
bool IsNonMeleeSpellCast(bool withDelayed, bool skipChanneled=false, bool skipAutorepeat=false, bool isAutoshoot=false, bool skipInstant=true) const
Definition: Unit.cpp:2886
bool IsNextMeleeSwingSpell() const
Definition: Spell.cpp:6685
Will ignore combo point requirement.
Definition: Unit.h:468
uint32 m_auraScaleMask
Definition: Spell.h:829
bool IsBreakingStealth() const
Definition: SpellInfo.cpp:1524
Player * ToPlayer()
Definition: Object.h:191
uint8 getLevel() const
Definition: Unit.h:1408
bool isMoving() const
Definition: Unit.h:2186
std::vector< CostData > CalcPowerCost(Unit const *caster, SpellSchoolMask schoolMask) const
Definition: SpellInfo.cpp:2564
Definition: Unit.h:37
TypeID GetTypeId() const
Definition: Object.h:113
WorldObject * GetObjectTarget() const
Definition: Spell.cpp:282
Will ignore interruptible aura's at cast.
Definition: Unit.h:470
Definition: SharedDefines.h:1280
Unit * m_originalCaster
Definition: Spell.h:653
void finish(bool ok=true)
Definition: Spell.cpp:3620
ObjectGuid m_castItemGUID
Definition: Spell.h:549
Player * GetOwner() const
Definition: Item.cpp:552
bool HasAttribute(SpellAttr0 attribute) const
Definition: SpellInfo.h:462
Definition: SharedDefines.h:1337
CurrentSpellTypes GetCurrentContainer() const
Definition: Spell.cpp:6566
Definition: SpellInfo.h:238
void SendChannelUpdate(uint32 time)
Definition: Spell.cpp:4266
uint32 GetItemLevel(Player const *owner) const
Definition: Item.cpp:1871
uint64 CalculateTime(uint64 t_offset) const
Definition: EventProcessor.cpp:95
Definition: DisableMgr.h:29
Definition: Spell.h:905
SpellEffectInfoVector const & GetEffects() const
Definition: Spell.h:623
bool m_isDelayedInstantCast
Definition: Spell.h:664
bool FocusTarget(Spell const *focusSpell, WorldObject const *target)
Definition: Creature.cpp:2681
std::vector< SpellInfo::CostData > m_powerCost
Definition: Spell.h:659
ObjectGuid GetOwnerGUID() const
Definition: Item.h:272
int32 GetMaxDuration() const
Definition: SpellInfo.cpp:2497
Definition: Spell.h:277
Definition: SpellAuraDefines.h:390
void ReSetTimer()
Definition: Spell.h:593
void InitExplicitTargets(SpellCastTargets const &targets)
Definition: Spell.cpp:651
ObjectGuid const & GetGUID() const
Definition: Object.h:105
SpellCastResult CheckCast(bool strict)
Definition: Spell.cpp:4739
Definition: ObjectGuid.h:33
uint32 GetTargetMask() const
Definition: Spell.h:179
Definition: UpdateFields.h:109
Creature * ToCreature()
Definition: Object.h:194
Definition: SharedDefines.h:1393
int32_t int32
Definition: g3dmath.h:167
Will ignore equipped item requirements.
Definition: Unit.h:478
int32 EffectBasePoints[MAX_SPELL_EFFECTS]
Definition: Spell.h:268
SpellSchoolMask m_spellSchoolMask
Definition: Spell.h:656
Will ignore aura scaling.
Definition: Unit.h:466
SpellCastResult
Definition: SharedDefines.h:1265
uint32 GetEntry() const
Definition: Object.h:107
int32 m_castItemLevel
Definition: Spell.h:551
Will not take away cast item or update related achievement criteria.
Definition: Unit.h:465
void LoadScripts()
Definition: Spell.cpp:7028
bool HasFlag(uint16 index, uint32 flag) const
Definition: Object.cpp:1239
uint8 m_cast_count
Definition: Spell.h:552
TriggerCastFlags _triggeredCastFlags
Definition: Spell.h:821
Definition: SharedDefines.h:555
uint32 StartRecoveryTime
Definition: SpellInfo.h:366
Definition: Unit.h:697
void prepareDataForTriggerSystem(AuraEffect const *triggeredByAura)
Definition: Spell.cpp:1954
Player * m_movedPlayer
Definition: Unit.h:1753
Definition: SharedDefines.h:1538
uint32 InterruptFlags
Definition: SpellInfo.h:367
bool m_needComboPoints
Definition: Spell.h:685
void cast(bool skipCheck=false)
Definition: Spell.cpp:3120
In Spell::prepare, will be cast directly without setting containers for executed spell.
Definition: Unit.h:469
void TriggerGlobalCooldown()
Definition: Spell.cpp:7360
Will not check if a current cast is in progress.
Definition: Unit.h:467

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Spell::prepareDataForTriggerSystem ( AuraEffect const triggeredByAura)
protected
1955 {
1956  //==========================================================================================
1957  // Now fill data for trigger system, need know:
1958  // can spell trigger another or not (m_canTrigger)
1959  // Create base triggers flags for Attacker and Victim (m_procAttacker, m_procVictim and m_procEx)
1960  //==========================================================================================
1961 
1963  // Get data for type of attack and fill base info for trigger
1964  switch (m_spellInfo->DmgClass)
1965  {
1968  if (m_attackType == OFF_ATTACK)
1970  else
1973  break;
1975  // Auto attack
1977  {
1980  }
1981  else // Ranged spell attack
1982  {
1985  }
1986  break;
1987  default:
1990  && m_spellInfo->HasAttribute(SPELL_ATTR2_AUTOREPEAT_FLAG)) // Wands auto attack
1991  {
1994  }
1995  // For other spells trigger procflags are set in Spell::DoAllEffectOnTarget
1996  // Because spell positivity is dependant on target
1997  }
1999 
2000  // Hunter trap spells - activation proc for Lock and Load, Entrapment and Misdirection
2002  (m_spellInfo->SpellFamilyFlags[0] & 0x18 || // Freezing and Frost Trap, Freezing Arrow
2003  m_spellInfo->Id == 57879 || // Snake Trap - done this way to avoid double proc
2004  m_spellInfo->SpellFamilyFlags[2] & 0x00024000)) // Explosive and Immolation Trap
2005  {
2007  }
2008 
2009  /* Effects which are result of aura proc from triggered spell cannot proc
2010  to prevent chain proc of these spells */
2011 
2012  // Hellfire Effect - trigger as DOT
2014  {
2017  }
2018 
2019  // Ranged autorepeat attack is set as triggered spell - ignore it
2021  {
2028  }
2029  // Totem casts require spellfamilymask defined in spell_proc_event to proc
2032 }
Definition: SpellMgr.h:124
SpellInfo const *const m_spellInfo
Definition: Spell.h:547
Unit *const m_caster
Definition: Spell.h:647
uint32 Id
Definition: SpellInfo.h:329
int32 EquippedItemClass
Definition: SpellInfo.h:385
Definition: SpellMgr.h:198
Definition: SharedDefines.h:473
uint32 DmgClass
Definition: SpellInfo.h:398
bool IsControlledByPlayer() const
Definition: Unit.h:1712
int32 EquippedItemSubClassMask
Definition: SpellInfo.h:386
Will ignore caster aura restrictions or requirements.
Definition: Unit.h:475
flag128 SpellFamilyFlags
Definition: SpellInfo.h:397
Definition: ObjectGuid.h:32
Definition: SharedDefines.h:2052
Definition: SpellMgr.h:117
Definition: SpellMgr.h:121
Definition: SharedDefines.h:4628
Definition: SharedDefines.h:4632
uint32 m_procVictim
Definition: Spell.h:716
Definition: SpellMgr.h:138
Definition: SpellMgr.h:139
Definition: SpellMgr.h:120
TypeID GetTypeId() const
Definition: Object.h:113
Definition: SharedDefines.h:433
Definition: Unit.h:618
Unit * m_originalCaster
Definition: Spell.h:653
uint32 SpellFamilyName
Definition: SpellInfo.h:396
bool HasAttribute(SpellAttr0 attribute) const
Definition: SpellInfo.h:462
Definition: SpellMgr.h:220
Definition: SpellMgr.h:142
Definition: SpellMgr.h:144
uint32 m_procAttacker
Definition: Spell.h:715
Definition: SpellMgr.h:223
WeaponAttackType m_attackType
Definition: Spell.h:657
Definition: SharedDefines.h:2051
Definition: SharedDefines.h:458
uint32 m_procEx
Definition: Spell.h:717
Definition: ItemTemplate.h:441
Definition: ItemTemplate.h:369
bool IsTotem() const
Definition: Unit.h:1405
Definition: SpellMgr.h:123
Definition: SpellMgr.h:224
Definition: SpellMgr.h:118
TriggerCastFlags _triggeredCastFlags
Definition: Spell.h:821
Definition: SpellMgr.h:145

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Spell::PrepareScriptHitHandlers ( )
protected
7106 {
7107  for (std::list<SpellScript*>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
7108  (*scritr)->_InitHit();
7109 }
std::list< SpellScript * > m_loadedScripts
Definition: Spell.h:794

+ Here is the caller graph for this function:

void Spell::PrepareTargetProcessing ( )
protected
7020 {
7021 }

+ Here is the caller graph for this function:

void Spell::PrepareTriggersExecutedOnHit ( )
protected
Todo:
move this to scripts
Todo:
move this to scripts
7289 {
7292  {
7293  SpellInfo const* excludeCasterSpellInfo = sSpellMgr->GetSpellInfo(m_spellInfo->ExcludeCasterAuraSpell);
7294  if (excludeCasterSpellInfo && !excludeCasterSpellInfo->IsPositive())
7296  SpellInfo const* excludeTargetSpellInfo = sSpellMgr->GetSpellInfo(m_spellInfo->ExcludeTargetAuraSpell);
7297  if (excludeTargetSpellInfo && !excludeTargetSpellInfo->IsPositive())
7299  }
7300 
7302  switch (m_spellInfo->SpellFamilyName)
7303  {
7304  case SPELLFAMILY_MAGE:
7305  {
7306  // Permafrost
7307  if (m_spellInfo->SpellFamilyFlags[1] & 0x00001000 || m_spellInfo->SpellFamilyFlags[0] & 0x00100220)
7308  m_preCastSpell = 68391;
7309  break;
7310  }
7311  }
7312 
7313  // handle SPELL_AURA_ADD_TARGET_TRIGGER auras:
7314  // save auras which were present on spell caster on cast, to prevent triggered auras from affecting caster
7315  // and to correctly calculate proc chance when combopoints are present
7317  for (Unit::AuraEffectList::const_iterator i = targetTriggers.begin(); i != targetTriggers.end(); ++i)
7318  {
7319  if (!(*i)->IsAffectingSpell(m_spellInfo))
7320  continue;
7321  SpellInfo const* auraSpellInfo = (*i)->GetSpellInfo();
7322  uint32 auraSpellIdx = (*i)->GetEffIndex();
7323  // todo 6.x
7324  if (SpellEffectInfo const* auraEffect = auraSpellInfo->GetEffect(m_caster->GetMap()->GetDifficultyID(), auraSpellIdx))
7325  {
7326  if (SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(auraEffect->TriggerSpell))
7327  {
7328  // calculate the chance using spell base amount, because aura amount is not updated on combo-points change
7329  // this possibly needs fixing
7330  int32 auraBaseAmount = (*i)->GetBaseAmount();
7331  // proc chance is stored in effect amount
7332  int32 chance = m_caster->CalculateSpellDamage(NULL, auraSpellInfo, auraSpellIdx, &auraBaseAmount);
7333  // build trigger and add to the list
7334  HitTriggerSpell spellTriggerInfo;
7335  spellTriggerInfo.triggeredSpell = spellInfo;
7336  spellTriggerInfo.triggeredByAura = auraSpellInfo;
7337  spellTriggerInfo.chance = chance * (*i)->GetBase()->GetStackAmount();
7338  m_hitTriggerSpells.push_back(spellTriggerInfo);
7339  }
7340  }
7341  }
7342 }
SpellInfo const *const m_spellInfo
Definition: Spell.h:547
Unit *const m_caster
Definition: Spell.h:647
Map * GetMap() const
Definition: Object.h:543
Definition: SpellInfo.h:326
Difficulty GetDifficultyID() const
Definition: Map.h:390
flag128 SpellFamilyFlags
Definition: SpellInfo.h:397
uint32 ExcludeCasterAuraSpell
Definition: SpellInfo.h:360
uint32 ExcludeTargetAuraSpell
Definition: SpellInfo.h:361
std::list< AuraEffect * > AuraEffectList
Definition: Unit.h:1322
arena_t NULL
Definition: jemalloc_internal.h:624
Definition: SpellAuraDefines.h:169
Definition: SharedDefines.h:4626
bool IsPositive() const
Definition: SpellInfo.cpp:1495
uint32 SpellFamilyName
Definition: SpellInfo.h:396
HitTriggerSpellList m_hitTriggerSpells
Definition: Spell.h:807
#define sSpellMgr
Definition: SpellMgr.h:756
Definition: SpellInfo.h:238
int32_t int32
Definition: Define.h:146
AuraEffectList const & GetAuraEffectsByType(AuraType type) const
Definition: Unit.h:1832
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
uint32_t uint32
Definition: Define.h:150
uint32 m_preCastSpell
Definition: Spell.h:583
SpellEffectInfo const * GetEffect(uint32 difficulty, uint32 index) const
Definition: SpellInfo.cpp:3348

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Spell::ReSetTimer ( )
inline
593 { m_timer = m_casttime > 0 ? m_casttime : 0; }
int32 m_casttime
Definition: Spell.h:660
int32 m_timer
Definition: Spell.h:819

+ Here is the caller graph for this function:

void Spell::SearchAreaTargets ( std::list< WorldObject * > &  targets,
float  range,
Position const position,
Unit referer,
SpellTargetObjectTypes  objectType,
SpellTargetCheckTypes  selectionType,
ConditionContainer condList 
)
1837 {
1838  uint32 containerTypeMask = GetSearcherTypeMask(objectType, condList);
1839  if (!containerTypeMask)
1840  return;
1841  Trinity::WorldObjectSpellAreaTargetCheck check(range, position, m_caster, referer, m_spellInfo, selectionType, condList);
1843  SearchTargets<Trinity::WorldObjectListSearcher<Trinity::WorldObjectSpellAreaTargetCheck> > (searcher, containerTypeMask, m_caster, position, range);
1844 }
SpellInfo const *const m_spellInfo
Definition: Spell.h:547
Unit *const m_caster
Definition: Spell.h:647
uint32_t uint32
Definition: Define.h:150
uint32 GetSearcherTypeMask(SpellTargetObjectTypes objType, ConditionContainer *condList)
Definition: Spell.cpp:1756
T check(T value)
Definition: format.h:305
Definition: GridNotifiers.h:218

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Spell::SearchChainTargets ( std::list< WorldObject * > &  targets,
uint32  chainTargets,
WorldObject target,
SpellTargetObjectTypes  objectType,
SpellTargetCheckTypes  selectType,
ConditionContainer condList,
bool  isChainHeal 
)
1847 {
1848  // max dist for jump target selection
1849  float jumpRadius = 0.0f;
1850  switch (m_spellInfo->DmgClass)
1851  {
1853  // 7.5y for multi shot
1854  jumpRadius = 7.5f;
1855  break;
1857  // 5y for swipe, cleave and similar
1858  jumpRadius = 5.0f;
1859  break;
1862  // 12.5y for chain heal spell since 3.2 patch
1863  if (isChainHeal)
1864  jumpRadius = 12.5f;
1865  // 10y as default for magic chain spells
1866  else
1867  jumpRadius = 10.0f;
1868  break;
1869  }
1870 
1871  if (Player* modOwner = m_caster->GetSpellModOwner())
1872  modOwner->ApplySpellMod(m_spellInfo->Id, SPELLMOD_JUMP_DISTANCE, jumpRadius, this);
1873 
1874  // chain lightning/heal spells and similar - allow to jump at larger distance and go out of los
1878 
1879  // max dist which spell can reach
1880  float searchRadius = jumpRadius;
1881  if (isBouncingFar)
1882  searchRadius *= chainTargets;
1883 
1884  std::list<WorldObject*> tempTargets;
1885  SearchAreaTargets(tempTargets, searchRadius, target, m_caster, objectType, selectType, condList);
1886  tempTargets.remove(target);
1887 
1888  // remove targets which are always invalid for chain spells
1889  // for some spells allow only chain targets in front of caster (swipe for example)
1890  if (!isBouncingFar)
1891  {
1892  for (std::list<WorldObject*>::iterator itr = tempTargets.begin(); itr != tempTargets.end();)
1893  {
1894  std::list<WorldObject*>::iterator checkItr = itr++;
1895  if (!m_caster->HasInArc(static_cast<float>(M_PI), *checkItr))
1896  tempTargets.erase(checkItr);
1897  }
1898  }
1899 
1900  while (chainTargets)
1901  {
1902  // try to get unit for next chain jump
1903  std::list<WorldObject*>::iterator foundItr = tempTargets.end();
1904  // get unit with highest hp deficit in dist
1905  if (isChainHeal)
1906  {
1907  uint32 maxHPDeficit = 0;
1908  for (std::list<WorldObject*>::iterator itr = tempTargets.begin(); itr != tempTargets.end(); ++itr)
1909  {
1910  if (Unit* unit = (*itr)->ToUnit())
1911  {
1912  uint32 deficit = unit->GetMaxHealth() - unit->GetHealth();
1913  if ((deficit > maxHPDeficit || foundItr == tempTargets.end()) && target->IsWithinDist(unit, jumpRadius) && target->IsWithinLOSInMap(unit))
1914  {
1915  foundItr = itr;
1916  maxHPDeficit = deficit;
1917  }
1918  }
1919  }
1920  }
1921  // get closest object
1922  else
1923  {
1924  for (std::list<WorldObject*>::iterator itr = tempTargets.begin(); itr != tempTargets.end(); ++itr)
1925  {
1926  if (foundItr == tempTargets.end())
1927  {
1928  if ((!isBouncingFar || target->IsWithinDist(*itr, jumpRadius)) && target->IsWithinLOSInMap(*itr))
1929  foundItr = itr;
1930  }
1931  else if (target->GetDistanceOrder(*itr, *foundItr) && target->IsWithinLOSInMap(*itr))
1932  foundItr = itr;
1933  }
1934  }
1935  // not found any valid target - chain ends
1936  if (foundItr == tempTargets.end())
1937  break;
1938  target = *foundItr;
1939  tempTargets.erase(foundItr);
1940  targets.push_back(target);
1941  --chainTargets;
1942  }
1943 }
SpellInfo const *const m_spellInfo
Definition: Spell.h:547
Unit *const m_caster
Definition: Spell.h:647
uint32 Id
Definition: SpellInfo.h:329
bool GetDistanceOrder(WorldObject const *obj1, WorldObject const *obj2, bool is3D=true) const
Definition: Object.cpp:1680
uint32 DmgClass
Definition: SpellInfo.h:398
#define M_PI
Definition: Common.h:163
bool IsWithinLOSInMap(WorldObject const *obj) const
Definition: Object.cpp:1584
Definition: SharedDefines.h:2052
Definition: SharedDefines.h:2049
bool IsWithinDist(WorldObject const *obj, float dist2compare, bool is3D=true) const
Definition: Object.cpp:1658
Definition: SharedDefines.h:518
bool HasAttribute(SpellAttr0 attribute) const
Definition: SpellInfo.h:462
uint32_t uint32
Definition: Define.h:150
bool HasInArc(float arcangle, Position const *pos, float border=2.0f) const
Definition: Position.cpp:129
Definition: SharedDefines.h:2051
Definition: Unit.h:121
Definition: SharedDefines.h:2050
Player * GetSpellModOwner() const
Definition: Unit.cpp:12691
Definition: Unit.h:1305
Unit * ToUnit()
Definition: Object.h:197
void SearchAreaTargets(std::list< WorldObject * > &targets, float range, Position const *position, Unit *referer, SpellTargetObjectTypes objectType, SpellTargetCheckTypes selectionType, ConditionContainer *condList)
Definition: Spell.cpp:1836

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

WorldObject * Spell::SearchNearbyTarget ( float  range,
SpellTargetObjectTypes  objectType,
SpellTargetCheckTypes  selectionType,
ConditionContainer condList = NULL 
)
1825 {
1826  WorldObject* target = NULL;
1827  uint32 containerTypeMask = GetSearcherTypeMask(objectType, condList);
1828  if (!containerTypeMask)
1829  return NULL;
1830  Trinity::WorldObjectSpellNearbyTargetCheck check(range, m_caster, m_spellInfo, selectionType, condList);
1832  SearchTargets<Trinity::WorldObjectLastSearcher<Trinity::WorldObjectSpellNearbyTargetCheck> > (searcher, containerTypeMask, m_caster, m_caster, range);
1833  return target;
1834 }
SpellInfo const *const m_spellInfo
Definition: Spell.h:547
Unit *const m_caster
Definition: Spell.h:647
arena_t NULL
Definition: jemalloc_internal.h:624
Definition: Object.h:423
uint32_t uint32
Definition: Define.h:150
uint32 GetSearcherTypeMask(SpellTargetObjectTypes objType, ConditionContainer *condList)
Definition: Spell.cpp:1756
T check(T value)
Definition: format.h:305
Definition: GridNotifiers.h:197

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

GameObject * Spell::SearchSpellFocus ( )
1946 {
1947  GameObject* focus = NULL;
1950  SearchTargets<Trinity::GameObjectSearcher<Trinity::GameObjectFocusCheck> > (searcher, GRID_MAP_TYPE_MASK_GAMEOBJECT, m_caster, m_caster, m_caster->GetVisibilityRange());
1951  return focus;
1952 }
SpellInfo const *const m_spellInfo
Definition: Spell.h:547
Unit *const m_caster
Definition: Spell.h:647
Definition: GridNotifiers.h:625
uint32 RequiresSpellFocus
Definition: SpellInfo.h:352
float GetVisibilityRange() const
Definition: Object.cpp:1912
arena_t NULL
Definition: jemalloc_internal.h:624
Definition: GridNotifiers.h:307
Definition: GridDefines.h:76
Definition: GameObject.h:880
T check(T value)
Definition: format.h:305

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

template<class SEARCHER >
void Spell::SearchTargets ( SEARCHER &  searcher,
uint32  containerMask,
Unit referer,
Position const pos,
float  radius 
)
1792 {
1793  if (!containerMask)
1794  return;
1795 
1796  // search world and grid for possible targets
1797  bool searchInGrid = (containerMask & (GRID_MAP_TYPE_MASK_CREATURE | GRID_MAP_TYPE_MASK_GAMEOBJECT)) != 0;
1798  bool searchInWorld = (containerMask & (GRID_MAP_TYPE_MASK_CREATURE | GRID_MAP_TYPE_MASK_PLAYER | GRID_MAP_TYPE_MASK_CORPSE)) != 0;
1799  if (searchInGrid || searchInWorld)
1800  {
1801  float x, y;
1802  x = pos->GetPositionX();
1803  y = pos->GetPositionY();
1804 
1806  Cell cell(p);
1807  cell.SetNoCreate();
1808 
1809  Map& map = *(referer->GetMap());
1810 
1811  if (searchInWorld)
1812  {
1813  TypeContainerVisitor<SEARCHER, WorldTypeMapContainer> world_object_notifier(searcher);
1814  cell.Visit(p, world_object_notifier, map, radius, x, y);
1815  }
1816  if (searchInGrid)
1817  {
1818  TypeContainerVisitor<SEARCHER, GridTypeMapContainer > grid_object_notifier(searcher);
1819  cell.Visit(p, grid_object_notifier, map, radius, x, y);
1820  }
1821  }
1822 }
Definition: TypeContainerVisitor.h:32
Map * GetMap() const
Definition: Object.h:543
CellCoord ComputeCellCoord(float x, float y)
Definition: GridDefines.h:193
Definition: GridDefines.h:77
Definition: GridDefines.h:76
G3D::int16 y
Definition: Vector2int16.h:38
Definition: Map.h:259
Definition: Cell.h:49
Definition: GridDefines.h:74
G3D::int16 x
Definition: Vector2int16.h:37
Definition: GridDefines.h:73

+ Here is the call graph for this function:

void Spell::SelectEffectImplicitTargets ( SpellEffIndex  effIndex,
SpellImplicitTargetInfo const targetType,
uint32 processedEffectMask 
)
846 {
847  if (!targetType.GetTarget())
848  return;
849 
850  uint32 effectMask = 1 << effIndex;
851  // set the same target list for all effects
852  // some spells appear to need this, however this requires more research
853  switch (targetType.GetSelectionCategory())
854  {
858  // targets for effect already selected
859  if (effectMask & processedEffectMask)
860  return;
861  if (SpellEffectInfo const* _effect = GetEffect(effIndex))
862  {
863  // choose which targets we can select at once
864  for (SpellEffectInfo const* effect : GetEffects())
865  {
866  //for (uint32 j = effIndex + 1; j < MAX_SPELL_EFFECTS; ++j)
867  if (!effect || effect->EffectIndex <= uint32(effIndex))
868  continue;
869  if (effect->IsEffect() &&
870  _effect->TargetA.GetTarget() == effect->TargetA.GetTarget() &&
871  _effect->TargetB.GetTarget() == effect->TargetB.GetTarget() &&
872  _effect->ImplicitTargetConditions == effect->ImplicitTargetConditions &&
873  _effect->CalcRadius(m_caster) == effect->CalcRadius(m_caster) &&
874  CheckScriptEffectImplicitTargets(effIndex, effect->EffectIndex))
875  {
876  effectMask |= 1 << effect->EffectIndex;
877  }
878  }
879  }
880  processedEffectMask |= effectMask;
881  break;
882  default:
883  break;
884  }
885 
886  switch (targetType.GetSelectionCategory())
887  {
889  SelectImplicitChannelTargets(effIndex, targetType);
890  break;
892  SelectImplicitNearbyTargets(effIndex, targetType, effectMask);
893  break;
895  SelectImplicitConeTargets(effIndex, targetType, effectMask);
896  break;
898  SelectImplicitAreaTargets(effIndex, targetType, effectMask);
899  break;
901  switch (targetType.GetObjectType())
902  {
904  switch (targetType.GetReferenceType())
905  {
908  break;
909  default:
910  ASSERT(false && "Spell::SelectEffectImplicitTargets: received not implemented select target reference type for TARGET_TYPE_OBJECT_SRC");
911  break;
912  }
913  break;
915  switch (targetType.GetReferenceType())
916  {
918  SelectImplicitCasterDestTargets(effIndex, targetType);
919  break;
921  SelectImplicitTargetDestTargets(effIndex, targetType);
922  break;
924  SelectImplicitDestDestTargets(effIndex, targetType);
925  break;
926  default:
927  ASSERT(false && "Spell::SelectEffectImplicitTargets: received not implemented select target reference type for TARGET_TYPE_OBJECT_DEST");
928  break;
929  }
930  break;
931  default:
932  switch (targetType.GetReferenceType())
933  {
935  SelectImplicitCasterObjectTargets(effIndex, targetType);
936  break;
938  SelectImplicitTargetObjectTargets(effIndex, targetType);
939  break;
940  default:
941  ASSERT(false && "Spell::SelectEffectImplicitTargets: received not implemented select target reference type for TARGET_TYPE_OBJECT");
942  break;
943  }
944  break;
945  }
946  break;
948  TC_LOG_DEBUG("spells", "SPELL: target type %u, found in spellID %u, effect %u is not implemented yet!", m_spellInfo->Id, effIndex, targetType.GetTarget());
949  break;
950  default:
951  ASSERT(false && "Spell::SelectEffectImplicitTargets: received not implemented select target category");
952  break;
953  }
954 }
SpellInfo const *const m_spellInfo
Definition: Spell.h:547
Unit *const m_caster
Definition: Spell.h:647
uint32 Id
Definition: SpellInfo.h:329
Definition: SpellInfo.h:99
void SetSrc(float x, float y, float z)
Definition: Spell.cpp:338
SpellCastTargets m_targets
Definition: Spell.h:584
Definition: SpellInfo.h:96
bool CheckScriptEffectImplicitTargets(uint32 effIndex, uint32 effIndexToCheck)
Definition: Spell.cpp:7253
SpellEffectInfo const * GetEffect(uint32 index) const
Definition: Spell.h:624
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
void SelectImplicitNearbyTargets(SpellEffIndex effIndex, SpellImplicitTargetInfo const &targetType, uint32 effMask)
Definition: Spell.cpp:1004
Definition: SpellInfo.h:95
Definition: SpellInfo.h:238
uint32_t uint32
Definition: Define.h:150
Definition: SpellInfo.h:88
SpellEffectInfoVector const & GetEffects() const
Definition: Spell.h:623
void SelectImplicitCasterDestTargets(SpellEffIndex effIndex, SpellImplicitTargetInfo const &targetType)
Definition: Spell.cpp:1233
Definition: SpellInfo.h:87
Definition: SpellInfo.h:85
void SelectImplicitConeTargets(SpellEffIndex effIndex, SpellImplicitTargetInfo const &targetType, uint32 effMask)
Definition: Spell.cpp:1113
Definition: SpellInfo.h:89
Definition: SpellInfo.h:86
void SelectImplicitChannelTargets(SpellEffIndex effIndex, SpellImplicitTargetInfo const &targetType)
Definition: Spell.cpp:956
Definition: SpellInfo.h:106
#define ASSERT
Definition: Errors.h:55
Definition: SpellInfo.h:84
void SelectImplicitAreaTargets(SpellEffIndex effIndex, SpellImplicitTargetInfo const &targetType, uint32 effMask)
Definition: Spell.cpp:1155
void SelectImplicitTargetObjectTargets(SpellEffIndex effIndex, SpellImplicitTargetInfo const &targetType)
Definition: Spell.cpp:1449
void SelectImplicitTargetDestTargets(SpellEffIndex effIndex, SpellImplicitTargetInfo const &targetType)
Definition: Spell.cpp:1325
void SelectImplicitCasterObjectTargets(SpellEffIndex effIndex, SpellImplicitTargetInfo const &targetType)
Definition: Spell.cpp:1404
void SelectImplicitDestDestTargets(SpellEffIndex effIndex, SpellImplicitTargetInfo const &targetType)
Definition: Spell.cpp:1362
Definition: SpellInfo.h:105

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Spell::SelectEffectTypeImplicitTargets ( uint32  effIndex)
Todo:
this is a workaround - target shouldn't be stored in target map for those spells
Todo:
this is a workaround - corpses should be added to spell target map too, but we can't do that so we add owner instead
1671 {
1672  // special case for SPELL_EFFECT_SUMMON_RAF_FRIEND and SPELL_EFFECT_SUMMON_PLAYER
1674  SpellEffectInfo const* effect = GetEffect(effIndex);
1675  if (!effect)
1676  return;
1677  switch (effect->Effect)
1678  {
1682  {
1684 
1686 
1687  if (target && target->ToPlayer())
1688  AddUnitTarget(target->ToUnit(), 1 << effIndex, false);
1689  }
1690  return;
1691  default:
1692  break;
1693  }
1694 
1695  // select spell implicit targets based on effect type
1696  if (!effect->GetImplicitTargetType())
1697  return;
1698 
1699  uint32 targetMask = effect->GetMissingTargetMask();
1700 
1701  if (!targetMask)
1702  return;
1703 
1704  WorldObject* target = NULL;
1705 
1706  switch (effect->GetImplicitTargetType())
1707  {
1708  // add explicit object target or self to the target map
1710  // player which not released his spirit is Unit, but target flag for it is TARGET_FLAG_CORPSE_MASK
1711  if (targetMask & (TARGET_FLAG_UNIT_MASK | TARGET_FLAG_CORPSE_MASK))
1712  {
1713  if (Unit* unit = m_targets.GetUnitTarget())
1714  target = unit;
1715  else if (targetMask & TARGET_FLAG_CORPSE_MASK)
1716  {
1717  if (Corpse* corpseTarget = m_targets.GetCorpseTarget())
1718  {
1720  if (Player* owner = ObjectAccessor::FindPlayer(corpseTarget->GetOwnerGUID()))
1721  target = owner;
1722  }
1723  }
1724  else //if (targetMask & TARGET_FLAG_UNIT_MASK)
1725  target = m_caster;
1726  }
1727  if (targetMask & TARGET_FLAG_ITEM_MASK)
1728  {
1729  if (Item* item = m_targets.GetItemTarget())
1730  AddItemTarget(item, 1 << effIndex);
1731  return;
1732  }
1733  if (targetMask & TARGET_FLAG_GAMEOBJECT_MASK)
1734  target = m_targets.GetGOTarget();
1735  break;
1736  // add self to the target map
1738  if (targetMask & TARGET_FLAG_UNIT_MASK)
1739  target = m_caster;
1740  break;
1741  default:
1742  break;
1743  }
1744 
1746 
1747  if (target)
1748  {
1749  if (target->ToUnit())
1750  AddUnitTarget(target->ToUnit(), 1 << effIndex, false);
1751  else if (target->ToGameObject())
1752  AddGOTarget(target->ToGameObject(), 1 << effIndex);
1753  }
1754 }
Unit *const m_caster
Definition: Spell.h:647
Definition: Corpse.h:49
Unit * GetUnitTarget() const
Definition: Spell.cpp:222
Definition: SpellInfo.h:77
SpellCastTargets m_targets
Definition: Spell.h:584
Item * GetItemTarget() const
Definition: Spell.h:203
uint32 GetMissingTargetMask(bool srcSet=false, bool destSet=false, uint32 mask=0) const
Definition: SpellInfo.cpp:686
SpellEffectInfo const * GetEffect(uint32 index) const
Definition: Spell.h:624
void AddItemTarget(Item *item, uint32 effectMask)
Definition: Spell.cpp:2208
arena_t NULL
Definition: jemalloc_internal.h:624
Definition: Object.h:423
Definition: SpellInfo.h:79
GameObject * ToGameObject()
Definition: Object.h:200
void AddUnitTarget(Unit *target, uint32 effectMask, bool checkIfValid=true, bool implicit=true, Position const *losPosition=nullptr)
Definition: Spell.cpp:2042
Player * ToPlayer()
Definition: Object.h:191
Definition: SpellInfo.h:148
TypeID GetTypeId() const
Definition: Object.h:113
TC_GAME_API Player * FindPlayer(ObjectGuid const &)
Definition: ObjectAccessor.cpp:209
SpellEffectImplicitTargetTypes GetImplicitTargetType() const
Definition: SpellInfo.cpp:710
void CallScriptObjectTargetSelectHandlers(WorldObject *&target, SpellEffIndex effIndex, SpellImplicitTargetInfo const &targetType)
Definition: Spell.cpp:7225
Definition: Item.h:259
Definition: SpellInfo.h:78
SpellEffIndex
Definition: SharedDefines.h:26
Definition: SpellInfo.h:238
uint32_t uint32
Definition: Define.h:150
Corpse * GetCorpseTarget() const
Definition: Spell.cpp:274
Definition: SpellInfo.h:207
ObjectGuid GetTarget() const
Definition: Unit.h:2209
Definition: SharedDefines.h:1162
Definition: ObjectGuid.h:33
Definition: SpellInfo.h:149
Definition: SpellInfo.h:75
void AddGOTarget(GameObject *target, uint32 effectMask)
Definition: Spell.cpp:2153
uint32 Effect
Definition: SpellInfo.h:243
Definition: Unit.h:1305
Unit * ToUnit()
Definition: Object.h:197
bool IsEmpty() const
Definition: ObjectGuid.h:242
Definition: SharedDefines.h:1095
GameObject * GetGOTarget() const
Definition: Spell.cpp:248

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Spell::SelectExplicitTargets ( )
722 {
723  // here go all explicit target changes made to explicit targets after spell prepare phase is finished
724  if (Unit* target = m_targets.GetUnitTarget())
725  {
726  // check for explicit target redirection, for Grounding Totem for example
729  {
730  Unit* redirect;
731  switch (m_spellInfo->DmgClass)
732  {
734  redirect = m_caster->GetMagicHitRedirectTarget(target, m_spellInfo);
735  break;
738  redirect = m_caster->GetMeleeHitRedirectTarget(target, m_spellInfo);
739  break;
740  default:
741  redirect = NULL;
742  break;
743  }
744  if (redirect && (redirect != target))
745  m_targets.SetUnitTarget(redirect);
746  }
747  }
748 }
SpellInfo const *const m_spellInfo
Definition: Spell.h:547
Unit *const m_caster
Definition: Spell.h:647
Unit * GetUnitTarget() const
Definition: Spell.cpp:222
Definition: SpellInfo.h:49
uint32 GetExplicitTargetMask() const
Definition: SpellInfo.cpp:2216
uint32 DmgClass
Definition: SpellInfo.h:398
Unit * GetMeleeHitRedirectTarget(Unit *victim, SpellInfo const *spellInfo=NULL)
Definition: Unit.cpp:7966
SpellCastTargets m_targets
Definition: Spell.h:584
Definition: SharedDefines.h:2052
arena_t NULL
Definition: jemalloc_internal.h:624
Definition: SpellInfo.h:55
void SetUnitTarget(Unit *target)
Definition: Spell.cpp:230
bool IsFriendlyTo(Unit const *unit) const
Definition: Unit.cpp:7170
Definition: SharedDefines.h:2051
Definition: SharedDefines.h:2050
Definition: Unit.h:1305
Unit * GetMagicHitRedirectTarget(Unit *victim, SpellInfo const *spellInfo)
Definition: Unit.cpp:7936

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Spell::SelectImplicitAreaTargets ( SpellEffIndex  effIndex,
SpellImplicitTargetInfo const targetType,
uint32  effMask 
)
1156 {
1157  Unit* referer = NULL;
1158  switch (targetType.GetReferenceType())
1159  {
1163  referer = m_caster;
1164  break;
1166  referer = m_targets.GetUnitTarget();
1167  break;
1169  {
1170  // find last added target for this effect
1171  for (std::vector<TargetInfo>::reverse_iterator ihit = m_UniqueTargetInfo.rbegin(); ihit != m_UniqueTargetInfo.rend(); ++ihit)
1172  {
1173  if (ihit->effectMask & (1<<effIndex))
1174  {
1175  referer = ObjectAccessor::GetUnit(*m_caster, ihit->targetGUID);
1176  break;
1177  }
1178  }
1179  break;
1180  }
1181  default:
1182  ASSERT(false && "Spell::SelectImplicitAreaTargets: received not implemented target reference type");
1183  return;
1184  }
1185 
1186  if (!referer)
1187  return;
1188 
1189  Position const* center = NULL;
1190  switch (targetType.GetReferenceType())
1191  {
1193  center = m_targets.GetSrcPos();
1194  break;
1196  center = m_targets.GetDstPos();
1197  break;
1201  center = referer;
1202  break;
1203  default:
1204  ASSERT(false && "Spell::SelectImplicitAreaTargets: received not implemented target reference type");
1205  return;
1206  }
1207 
1208  std::list<WorldObject*> targets;
1209  SpellEffectInfo const* effect = GetEffect(effIndex);
1210  if (!effect)
1211  return;
1212  float radius = effect->CalcRadius(m_caster) * m_spellValue->RadiusMod;
1213  SearchAreaTargets(targets, radius, center, referer, targetType.GetObjectType(), targetType.GetCheckType(), effect->ImplicitTargetConditions);
1214 
1215  CallScriptObjectAreaTargetSelectHandlers(targets, effIndex, targetType);
1216 
1217  if (!targets.empty())
1218  {
1219  // Other special target selection goes here
1220  if (uint32 maxTargets = m_spellValue->MaxAffectedTargets)
1221  Trinity::Containers::RandomResizeList(targets, maxTargets);
1222 
1223  for (std::list<WorldObject*>::iterator itr = targets.begin(); itr != targets.end(); ++itr)
1224  {
1225  if (Unit* unit = (*itr)->ToUnit())
1226  AddUnitTarget(unit, effMask, false, true, center);
1227  else if (GameObject* gObjTarget = (*itr)->ToGameObject())
1228  AddGOTarget(gObjTarget, effMask);
1229  }
1230  }
1231 }
Unit *const m_caster
Definition: Spell.h:647
Unit * GetUnitTarget() const
Definition: Spell.cpp:222
Definition: SpellInfo.h:99
TC_GAME_API Unit * GetUnit(WorldObject const &, ObjectGuid const &guid)
Definition: ObjectAccessor.cpp:163
SpellCastTargets m_targets
Definition: Spell.h:584
Definition: SpellInfo.h:96
uint32 MaxAffectedTargets
Definition: Spell.h:269
void RandomResizeList(std::list< T > &list, uint32 size)
Definition: Containers.h:34
SpellEffectInfo const * GetEffect(uint32 index) const
Definition: Spell.h:624
arena_t NULL
Definition: jemalloc_internal.h:624
WorldLocation const * GetDstPos() const
Definition: Spell.cpp:372
SpellValue *const m_spellValue
Definition: Spell.h:649
GameObject * ToGameObject()
Definition: Object.h:200
void AddUnitTarget(Unit *target, uint32 effectMask, bool checkIfValid=true, bool implicit=true, Position const *losPosition=nullptr)
Definition: Spell.cpp:2042
std::vector< TargetInfo > m_UniqueTargetInfo
Definition: Spell.h:739
float CalcRadius(Unit *caster=NULL, Spell *=NULL) const
Definition: SpellInfo.cpp:655
std::vector< Condition * > * ImplicitTargetConditions
Definition: SpellInfo.h:266
Definition: SpellInfo.h:95
Definition: SpellInfo.h:238
uint32_t uint32
Definition: Define.h:150
Definition: SpellInfo.h:97
Definition: GameObject.h:880
Position const * GetSrcPos() const
Definition: Spell.cpp:333
float RadiusMod
Definition: Spell.h:270
Definition: Position.h:27
Definition: SpellInfo.h:98
#define ASSERT
Definition: Errors.h:55
void CallScriptObjectAreaTargetSelectHandlers(std::list< WorldObject * > &targets, SpellEffIndex effIndex, SpellImplicitTargetInfo const &targetType)
Definition: Spell.cpp:7211
void AddGOTarget(GameObject *target, uint32 effectMask)
Definition: Spell.cpp:2153
Definition: Unit.h:1305
Unit * ToUnit()
Definition: Object.h:197
void SearchAreaTargets(std::list< WorldObject * > &targets, float range, Position const *position, Unit *referer, SpellTargetObjectTypes objectType, SpellTargetCheckTypes selectionType, ConditionContainer *condList)
Definition: Spell.cpp:1836

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Spell::SelectImplicitCasterDestTargets ( SpellEffIndex  effIndex,
SpellImplicitTargetInfo const targetType 
)
Todo:
fix this check
1234 {
1235  SpellDestination dest(*m_caster);
1236 
1237  switch (targetType.GetTarget())
1238  {
1239  case TARGET_DEST_CASTER:
1240  break;
1241  case TARGET_DEST_HOME:
1242  if (Player* playerCaster = m_caster->ToPlayer())
1243  dest = SpellDestination(playerCaster->m_homebindX, playerCaster->m_homebindY, playerCaster->m_homebindZ, playerCaster->GetOrientation(), playerCaster->m_homebindMapId);
1244  break;
1245  case TARGET_DEST_DB:
1246  if (SpellTargetPosition const* st = sSpellMgr->GetSpellTargetPosition(m_spellInfo->Id, effIndex))
1247  {
1250  dest = SpellDestination(st->target_X, st->target_Y, st->target_Z, st->target_Orientation, (int32)st->target_mapId);
1251  else if (st->target_mapId == m_caster->GetMapId())
1252  dest = SpellDestination(st->target_X, st->target_Y, st->target_Z, st->target_Orientation);
1253  }
1254  else
1255  {
1256  TC_LOG_DEBUG("spells", "SPELL: unknown target coordinates for spell ID %u", m_spellInfo->Id);
1257  if (WorldObject* target = m_targets.GetObjectTarget())
1258  dest = SpellDestination(*target);
1259  }
1260  break;
1262  {
1263  float minDist = m_spellInfo->GetMinRange(true);
1264  float maxDist = m_spellInfo->GetMaxRange(true);
1265  float dist = frand(minDist, maxDist);
1266  float x, y, z;
1267  float angle = float(rand_norm()) * static_cast<float>(M_PI * 35.0f / 180.0f) - static_cast<float>(M_PI * 17.5f / 180.0f);
1268  m_caster->GetClosePoint(x, y, z, DEFAULT_WORLD_OBJECT_SIZE, dist, angle);
1269 
1270  float ground = m_caster->GetMap()->GetHeight(m_caster->GetPhaseMask(), x, y, z, true, 50.0f);
1271  float liquidLevel = VMAP_INVALID_HEIGHT_VALUE;
1272  LiquidData liquidData;
1273  if (m_caster->GetMap()->getLiquidStatus(x, y, z, MAP_ALL_LIQUIDS, &liquidData))
1274  liquidLevel = liquidData.level;
1275 
1276  if (liquidLevel <= ground) // When there is no liquid Map::GetWaterOrGroundLevel returns ground level
1277  {
1279  SendChannelUpdate(0);
1280  finish(false);
1281  return;
1282  }
1283 
1284  if (ground + 0.75 > liquidLevel)
1285  {
1287  SendChannelUpdate(0);
1288  finish(false);
1289  return;
1290  }
1291 
1292  dest = SpellDestination(x, y, liquidLevel, m_caster->GetOrientation());
1293  break;
1294  }
1295  default:
1296  {
1297  if (SpellEffectInfo const* effect = GetEffect(effIndex))
1298  {
1299  float dist;
1300  float angle = targetType.CalcDirectionAngle();
1301  float objSize = m_caster->GetObjectSize();
1302  if (targetType.GetTarget() == TARGET_DEST_CASTER_SUMMON)
1303  dist = PET_FOLLOW_DIST;
1304  else
1305  dist = effect->CalcRadius(m_caster);
1306 
1307  if (dist < objSize)
1308  dist = objSize;
1309  else if (targetType.GetTarget() == TARGET_DEST_CASTER_RANDOM)
1310  dist = objSize + (dist - objSize) * float(rand_norm());
1311 
1312  Position pos = dest._position;
1313  m_caster->MovePositionToFirstCollision(pos, dist, angle);
1314 
1315  dest.Relocate(pos);
1316  }
1317  break;
1318  }
1319  }
1320 
1321  CallScriptDestinationTargetSelectHandlers(dest, effIndex, targetType);
1322  m_targets.SetDst(dest);
1323 }
SpellInfo const *const m_spellInfo
Definition: Spell.h:547
Unit *const m_caster
Definition: Spell.h:647
uint32 Id
Definition: SpellInfo.h:329
Map * GetMap() const
Definition: Object.h:543
#define M_PI
Definition: Common.h:163
SpellCastTargets m_targets
Definition: Spell.h:584
double frand()
Definition: Vector3.cpp:170
Definition: Map.h:151
float GetMaxRange(bool positive=false, Unit *caster=NULL, Spell *spell=NULL) const
Definition: SpellInfo.cpp:2475
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
float GetHeight(float x, float y, float z, bool checkVMap=true, float maxSearchDist=DEFAULT_HEIGHT_SEARCH) const
Definition: Map.cpp:2314
SpellEffectInfo const * GetEffect(uint32 index) const
Definition: Spell.h:624
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
Definition: Object.h:423
float GetMinRange(bool positive=false) const
Definition: SpellInfo.cpp:2466
Definition: SharedDefines.h:1941
Player * ToPlayer()
Definition: Object.h:191
Definition: SharedDefines.h:1021
Definition: SharedDefines.h:1883
WorldObject * GetObjectTarget() const
Definition: Spell.cpp:282
Definition: Spell.h:118
float GetOrientation() const
Definition: Position.h:107
bool HasEffect(SpellEffectName effect) const
Definition: Spell.cpp:7410
void finish(bool ok=true)
Definition: Spell.cpp:3620
uint32 GetPhaseMask() const
Definition: Object.h:461
G3D::int16 z
Definition: Vector3int16.h:46
#define MAP_ALL_LIQUIDS
Definition: Map.h:146
float level
Definition: Map.h:155
#define sSpellMgr
Definition: SpellMgr.h:756
#define VMAP_INVALID_HEIGHT_VALUE
Definition: IVMapManager.h:42
Definition: SpellInfo.h:238
void SendChannelUpdate(uint32 time)
Definition: Spell.cpp:4266
int32_t int32
Definition: Define.h:146
Definition: SharedDefines.h:1444
G3D::int16 y
Definition: Vector2int16.h:38
#define DEFAULT_WORLD_OBJECT_SIZE
Definition: Object.h:44
uint32 GetMapId() const
Definition: Position.h:254
Definition: SharedDefines.h:1908
Definition: SharedDefines.h:1346
void MovePositionToFirstCollision(Position &pos, float dist, float angle)
Definition: Object.cpp:2733
Definition: SharedDefines.h:1901
double rand_norm()
Definition: Random.cpp:69
Definition: SharedDefines.h:1887
void CallScriptDestinationTargetSelectHandlers(SpellDestination &target, SpellEffIndex effIndex, SpellImplicitTargetInfo const &targetType)
Definition: Spell.cpp:7239
Definition: Position.h:27
Definition: SpellMgr.h:359
#define PET_FOLLOW_DIST
Definition: PetDefines.h:77
void SetDst(float x, float y, float z, float orientation, uint32 mapId=MAPID_INVALID)
Definition: Spell.cpp:377
Definition: SharedDefines.h:1015
G3D::int16 x
Definition: Vector2int16.h:37
float GetObjectSize() const
Definition: Object.cpp:2656
ZLiquidStatus getLiquidStatus(float x, float y, float z, uint8 ReqLiquidType, LiquidData *data=nullptr) const
Definition: Map.cpp:2497
Definition: SharedDefines.h:1888
void GetClosePoint(float &x, float &y, float &z, float size, float distance2d=0, float angle=0) const
Definition: Object.cpp:2623

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Spell::SelectImplicitCasterObjectTargets ( SpellEffIndex  effIndex,
SpellImplicitTargetInfo const targetType 
)
1405 {
1406  WorldObject* target = NULL;
1407  bool checkIfValid = true;
1408 
1409  switch (targetType.GetTarget())
1410  {
1411  case TARGET_UNIT_CASTER:
1412  target = m_caster;
1413  checkIfValid = false;
1414  break;
1415  case TARGET_UNIT_MASTER:
1416  target = m_caster->GetCharmerOrOwner();
1417  break;
1418  case TARGET_UNIT_PET:
1419  target = m_caster->GetGuardianPet();
1420  break;
1421  case TARGET_UNIT_SUMMONER:
1422  if (m_caster->IsSummon())
1423  target = m_caster->ToTempSummon()->GetSummoner();
1424  break;
1425  case TARGET_UNIT_VEHICLE:
1426  target = m_caster->GetVehicleBase();
1427  break;
1437  target = m_caster->GetVehicleKit()->GetPassenger(targetType.GetTarget() - TARGET_UNIT_PASSENGER_0);
1438  break;
1439  default:
1440  break;
1441  }
1442 
1443  CallScriptObjectTargetSelectHandlers(target, effIndex, targetType);
1444 
1445  if (target && target->ToUnit())
1446  AddUnitTarget(target->ToUnit(), 1 << effIndex, checkIfValid);
1447 }
Unit * GetVehicleBase() const
Definition: Unit.cpp:14341
Unit *const m_caster
Definition: Spell.h:647
Guardian * GetGuardianPet() const
Definition: Unit.cpp:7596
Definition: SharedDefines.h:1967
Definition: SharedDefines.h:1879
bool IsVehicle() const
Definition: Unit.h:1406
Definition: SharedDefines.h:1969
Definition: ObjectGuid.h:32
arena_t NULL
Definition: jemalloc_internal.h:624
Definition: Object.h:423
void AddUnitTarget(Unit *target, uint32 effectMask, bool checkIfValid=true, bool implicit=true, Position const *losPosition=nullptr)
Definition: Spell.cpp:2042
Unit * GetSummoner() const
Definition: TemporarySummon.cpp:37
Definition: SharedDefines.h:1896
TempSummon * ToTempSummon()
Definition: Unit.h:2206
TypeID GetTypeId() const
Definition: Object.h:113
Unit * GetCharmerOrOwner() const
Definition: Unit.cpp:7627
Unit * GetPassenger(int8 seatId) const
Gets a passenger on specified seat.
Definition: Vehicle.cpp:287
Definition: SharedDefines.h:1970
Definition: SharedDefines.h:1971
void CallScriptObjectTargetSelectHandlers(WorldObject *&target, SpellEffIndex effIndex, SpellImplicitTargetInfo const &targetType)
Definition: Spell.cpp:7225
Definition: SharedDefines.h:1963
Definition: SharedDefines.h:1961
Definition: SharedDefines.h:1966
Definition: SharedDefines.h:1972
Definition: SharedDefines.h:1875
bool IsSummon() const
Definition: Unit.h:1401
Unit * ToUnit()
Definition: Object.h:197
Definition: SharedDefines.h:1968
Definition: SharedDefines.h:1965
Vehicle * GetVehicleKit() const
Definition: Unit.h:2165

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Spell::SelectImplicitChainTargets ( SpellEffIndex  effIndex,
SpellImplicitTargetInfo const targetType,
WorldObject target,
uint32  effMask 
)
1472 {
1473  SpellEffectInfo const* effect = GetEffect(effIndex);
1474  if (!effect)
1475  return;
1476 
1477  uint32 maxTargets = effect->ChainTargets;
1478  if (Player* modOwner = m_caster->GetSpellModOwner())
1479  modOwner->ApplySpellMod(m_spellInfo->Id, SPELLMOD_JUMP_TARGETS, maxTargets, this);
1480 
1481  if (maxTargets > 1)
1482  {
1483  // mark damage multipliers as used
1484  for (SpellEffectInfo const* eff : GetEffects())
1485  if (eff && (effMask & (1 << eff->EffectIndex)))
1486  m_damageMultipliers[eff->EffectIndex] = 1.0f;
1487  m_applyMultiplierMask |= effMask;
1488 
1489  std::list<WorldObject*> targets;
1490  SearchChainTargets(targets, maxTargets - 1, target, targetType.GetObjectType(), targetType.GetCheckType()
1491  , effect->ImplicitTargetConditions, targetType.GetTarget() == TARGET_UNIT_TARGET_CHAINHEAL_ALLY);
1492 
1493  // Chain primary target is added earlier
1494  CallScriptObjectAreaTargetSelectHandlers(targets, effIndex, targetType);
1495 
1496  for (std::list<WorldObject*>::iterator itr = targets.begin(); itr != targets.end(); ++itr)
1497  if (Unit* unit = (*itr)->ToUnit())
1498  AddUnitTarget(unit, effMask, false);
1499  }
1500 }
SpellInfo const *const m_spellInfo
Definition: Spell.h:547
Unit *const m_caster
Definition: Spell.h:647
uint32 Id
Definition: SpellInfo.h:329
SpellEffectInfo const * GetEffect(uint32 index) const
Definition: Spell.h:624
void AddUnitTarget(Unit *target, uint32 effectMask, bool checkIfValid=true, bool implicit=true, Position const *losPosition=nullptr)
Definition: Spell.cpp:2042
Definition: Unit.h:103
uint32 ChainTargets
Definition: SpellInfo.h:261
std::vector< Condition * > * ImplicitTargetConditions
Definition: SpellInfo.h:266
Definition: SpellInfo.h:238
uint32_t uint32
Definition: Define.h:150
SpellEffectInfoVector const & GetEffects() const
Definition: Spell.h:623
void SearchChainTargets(std::list< WorldObject * > &targets, uint32 chainTargets, WorldObject *target, SpellTargetObjectTypes objectType, SpellTargetCheckTypes selectType, ConditionContainer *condList, bool isChainHeal)
Definition: Spell.cpp:1846
float m_damageMultipliers[3]
Definition: Spell.h:687
Definition: SharedDefines.h:1914
Player * GetSpellModOwner() const
Definition: Unit.cpp:12691
uint8 m_applyMultiplierMask
Definition: Spell.h:686
void CallScriptObjectAreaTargetSelectHandlers(std::list< WorldObject * > &targets, SpellEffIndex effIndex, SpellImplicitTargetInfo const &targetType)
Definition: Spell.cpp:7211
Definition: Unit.h:1305
Unit * ToUnit()
Definition: Object.h:197

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Spell::SelectImplicitChannelTargets ( SpellEffIndex  effIndex,
SpellImplicitTargetInfo const targetType 
)
957 {
958  if (targetType.GetReferenceType() != TARGET_REFERENCE_TYPE_CASTER)
959  {
960  ASSERT(false && "Spell::SelectImplicitChannelTargets: received not implemented target reference type");
961  return;
962  }
963 
965  if (!channeledSpell)
966  {
967  TC_LOG_DEBUG("spells", "Spell::SelectImplicitChannelTargets: cannot find channel spell for spell ID %u, effect %u", m_spellInfo->Id, effIndex);
968  return;
969  }
970  switch (targetType.GetTarget())
971  {
973  {
975  CallScriptObjectTargetSelectHandlers(target, effIndex, targetType);
976  // unit target may be no longer avalible - teleported out of map for example
977  if (target && target->ToUnit())
978  AddUnitTarget(target->ToUnit(), 1 << effIndex);
979  else
980  TC_LOG_DEBUG("spells", "SPELL: cannot find channel spell target for spell ID %u, effect %u", m_spellInfo->Id, effIndex);
981  break;
982  }
984  if (channeledSpell->m_targets.HasDst())
985  m_targets.SetDst(channeledSpell->m_targets);
987  {
988  CallScriptObjectTargetSelectHandlers(target, effIndex, targetType);
989  if (target)
990  m_targets.SetDst(*target);
991  }
992  else
993  TC_LOG_DEBUG("spells", "SPELL: cannot find channel spell destination for spell ID %u, effect %u", m_spellInfo->Id, effIndex);
994  break;
996  m_targets.SetDst(*channeledSpell->GetCaster());
997  break;
998  default:
999  ASSERT(false && "Spell::SelectImplicitChannelTargets: received not implemented target type");
1000  break;
1001  }
1002 }
SpellInfo const *const m_spellInfo
Definition: Spell.h:547
Unit *const m_caster
Definition: Spell.h:647
uint32 Id
Definition: SpellInfo.h:329
TC_GAME_API Unit * GetUnit(WorldObject const &, ObjectGuid const &guid)
Definition: ObjectAccessor.cpp:163
Unit * GetCaster() const
Definition: Spell.h:612
SpellCastTargets m_targets
Definition: Spell.h:584
Definition: Unit.h:1110
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
Definition: Object.h:423
void AddUnitTarget(Unit *target, uint32 effectMask, bool checkIfValid=true, bool implicit=true, Position const *losPosition=nullptr)
Definition: Spell.cpp:2042
TC_GAME_API WorldObject * GetWorldObject(WorldObject const &, ObjectGuid const &)
Definition: ObjectAccessor.cpp:79
ObjectGuid GetChannelObjectGuid() const
Definition: Unit.h:1904
Unit * m_originalCaster
Definition: Spell.h:653
bool HasDst() const
Definition: Spell.h:229
Definition: SpellInfo.h:95
void CallScriptObjectTargetSelectHandlers(WorldObject *&target, SpellEffIndex effIndex, SpellImplicitTargetInfo const &targetType)
Definition: Spell.cpp:7225
Spell * GetCurrentSpell(CurrentSpellTypes spellType) const
Definition: Unit.h:1920
Definition: SharedDefines.h:1946
Definition: SharedDefines.h:1945
Definition: SharedDefines.h:1975
#define ASSERT
Definition: Errors.h:55
void SetDst(float x, float y, float z, float orientation, uint32 mapId=MAPID_INVALID)
Definition: Spell.cpp:377
Unit * ToUnit()
Definition: Object.h:197
Definition: Spell.h:294

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Spell::SelectImplicitConeTargets ( SpellEffIndex  effIndex,
SpellImplicitTargetInfo const targetType,
uint32  effMask 
)
1114 {
1115  if (targetType.GetReferenceType() != TARGET_REFERENCE_TYPE_CASTER)
1116  {
1117  ASSERT(false && "Spell::SelectImplicitConeTargets: received not implemented target reference type");
1118  return;
1119  }
1120  std::list<WorldObject*> targets;
1121  SpellTargetObjectTypes objectType = targetType.GetObjectType();
1122  SpellTargetCheckTypes selectionType = targetType.GetCheckType();
1123  SpellEffectInfo const* effect = GetEffect(effIndex);
1124  if (!effect)
1125  return;
1126  ConditionContainer* condList = effect->ImplicitTargetConditions;
1127  float coneAngle = float(M_PI) / 2;
1128  float radius = effect->CalcRadius(m_caster) * m_spellValue->RadiusMod;
1129 
1130  if (uint32 containerTypeMask = GetSearcherTypeMask(objectType, condList))
1131  {
1132  Trinity::WorldObjectSpellConeTargetCheck check(coneAngle, radius, m_caster, m_spellInfo, selectionType, condList);
1134  SearchTargets<Trinity::WorldObjectListSearcher<Trinity::WorldObjectSpellConeTargetCheck> >(searcher, containerTypeMask, m_caster, m_caster, radius);
1135 
1136  CallScriptObjectAreaTargetSelectHandlers(targets, effIndex, targetType);
1137 
1138  if (!targets.empty())
1139  {
1140  // Other special target selection goes here
1141  if (uint32 maxTargets = m_spellValue->MaxAffectedTargets)
1142  Trinity::Containers::RandomResizeList(targets, maxTargets);
1143 
1144  for (std::list<WorldObject*>::iterator itr = targets.begin(); itr != targets.end(); ++itr)
1145  {
1146  if (Unit* unit = (*itr)->ToUnit())
1147  AddUnitTarget(unit, effMask, false);
1148  else if (GameObject* gObjTarget = (*itr)->ToGameObject())
1149  AddGOTarget(gObjTarget, effMask);
1150  }
1151  }
1152  }
1153 }
SpellInfo const *const m_spellInfo
Definition: Spell.h:547
Unit *const m_caster
Definition: Spell.h:647
#define M_PI
Definition: Common.h:163
uint32 MaxAffectedTargets
Definition: Spell.h:269
void RandomResizeList(std::list< T > &list, uint32 size)
Definition: Containers.h:34
SpellTargetObjectTypes
Definition: SpellInfo.h:102
SpellEffectInfo const * GetEffect(uint32 index) const
Definition: Spell.h:624
SpellValue *const m_spellValue
Definition: Spell.h:649
GameObject * ToGameObject()
Definition: Object.h:200
void AddUnitTarget(Unit *target, uint32 effectMask, bool checkIfValid=true, bool implicit=true, Position const *losPosition=nullptr)
Definition: Spell.cpp:2042
float CalcRadius(Unit *caster=NULL, Spell *=NULL) const
Definition: SpellInfo.cpp:655
std::vector< Condition * > * ImplicitTargetConditions
Definition: SpellInfo.h:266
Definition: SpellInfo.h:95
Definition: SpellInfo.h:238
uint32_t uint32
Definition: Define.h:150
Definition: GameObject.h:880
uint32 GetSearcherTypeMask(SpellTargetObjectTypes objType, ConditionContainer *condList)
Definition: Spell.cpp:1756
float RadiusMod
Definition: Spell.h:270
#define ASSERT
Definition: Errors.h:55
void CallScriptObjectAreaTargetSelectHandlers(std::list< WorldObject * > &targets, SpellEffIndex effIndex, SpellImplicitTargetInfo const &targetType)
Definition: Spell.cpp:7211
SpellTargetCheckTypes
Definition: SpellInfo.h:118
T check(T value)
Definition: format.h:305
void AddGOTarget(GameObject *target, uint32 effectMask)
Definition: Spell.cpp:2153
std::vector< Condition * > ConditionContainer
Definition: ConditionMgr.h:239
Definition: Unit.h:1305
Definition: GridNotifiers.h:218
Unit * ToUnit()
Definition: Object.h:197

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Spell::SelectImplicitDestDestTargets ( SpellEffIndex  effIndex,
SpellImplicitTargetInfo const targetType 
)
1363 {
1364  // set destination to caster if no dest provided
1365  // can only happen if previous destination target could not be set for some reason
1366  // (not found nearby target, or channel target for example
1367  // maybe we should abort the spell in such case?
1368  CheckDst();
1369 
1371 
1372  switch (targetType.GetTarget())
1373  {
1377  case TARGET_DEST_DEST:
1378  return;
1379  case TARGET_DEST_TRAJ:
1380  SelectImplicitTrajTargets(effIndex);
1381  return;
1382  default:
1383  {
1384  if (SpellEffectInfo const* effect = GetEffect(effIndex))
1385  {
1386  float angle = targetType.CalcDirectionAngle();
1387  float dist = effect->CalcRadius(m_caster);
1388  if (targetType.GetTarget() == TARGET_DEST_DEST_RANDOM)
1389  dist *= float(rand_norm());
1390 
1391  Position pos = dest._position;
1392  m_caster->MovePositionToFirstCollision(pos, dist, angle);
1393 
1394  dest.Relocate(pos);
1395  }
1396  break;
1397  }
1398  }
1399 
1400  CallScriptDestinationTargetSelectHandlers(dest, effIndex, targetType);
1401  m_targets.ModDst(dest);
1402 }
Unit *const m_caster
Definition: Spell.h:647
SpellCastTargets m_targets
Definition: Spell.h:584
SpellEffectInfo const * GetEffect(uint32 index) const
Definition: Spell.h:624
Definition: SharedDefines.h:1897
Definition: SharedDefines.h:1958
SpellDestination const * GetDst() const
Definition: Spell.cpp:367
Definition: Spell.h:118
void ModDst(Position const &pos)
Definition: Spell.cpp:407
Definition: SpellInfo.h:238
Definition: SharedDefines.h:1955
Definition: SharedDefines.h:1956
Definition: SharedDefines.h:1957
void MovePositionToFirstCollision(Position &pos, float dist, float angle)
Definition: Object.cpp:2733
double rand_norm()
Definition: Random.cpp:69
void CheckDst()
Definition: Spell.h:519
void CallScriptDestinationTargetSelectHandlers(SpellDestination &target, SpellEffIndex effIndex, SpellImplicitTargetInfo const &targetType)
Definition: Spell.cpp:7239
Definition: Position.h:27
Definition: SharedDefines.h:1898
void SelectImplicitTrajTargets(SpellEffIndex effIndex)
Definition: Spell.cpp:1516

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Spell::SelectImplicitNearbyTargets ( SpellEffIndex  effIndex,
SpellImplicitTargetInfo const targetType,
uint32  effMask 
)
1005 {
1006  if (targetType.GetReferenceType() != TARGET_REFERENCE_TYPE_CASTER)
1007  {
1008  ASSERT(false && "Spell::SelectImplicitNearbyTargets: received not implemented target reference type");
1009  return;
1010  }
1011 
1012  SpellEffectInfo const* effect = GetEffect(effIndex);
1013  if (!effect)
1014  return;
1015 
1016  float range = 0.0f;
1017  switch (targetType.GetCheckType())
1018  {
1019  case TARGET_CHECK_ENEMY:
1020  range = m_spellInfo->GetMaxRange(false, m_caster, this);
1021  break;
1022  case TARGET_CHECK_ALLY:
1023  case TARGET_CHECK_PARTY:
1024  case TARGET_CHECK_RAID:
1026  range = m_spellInfo->GetMaxRange(true, m_caster, this);
1027  break;
1028  case TARGET_CHECK_ENTRY:
1029  case TARGET_CHECK_DEFAULT:
1031  break;
1032  default:
1033  ASSERT(false && "Spell::SelectImplicitNearbyTargets: received not implemented selection check type");
1034  break;
1035  }
1036 
1037  ConditionContainer* condList = effect->ImplicitTargetConditions;
1038 
1039  // handle emergency case - try to use other provided targets if no conditions provided
1040  if (targetType.GetCheckType() == TARGET_CHECK_ENTRY && (!condList || condList->empty()))
1041  {
1042  TC_LOG_DEBUG("spells", "Spell::SelectImplicitNearbyTargets: no conditions entry for target with TARGET_CHECK_ENTRY of spell ID %u, effect %u - selecting default targets", m_spellInfo->Id, effIndex);
1043  switch (targetType.GetObjectType())
1044  {
1047  {
1048  if (focusObject)
1049  AddGOTarget(focusObject, effMask);
1050  return;
1051  }
1052  break;
1055  {
1056  if (focusObject)
1058  return;
1059  }
1060  break;
1061  default:
1062  break;
1063  }
1064  }
1065 
1066  WorldObject* target = SearchNearbyTarget(range, targetType.GetObjectType(), targetType.GetCheckType(), condList);
1067  if (!target)
1068  {
1069  TC_LOG_DEBUG("spells", "Spell::SelectImplicitNearbyTargets: cannot find nearby target for spell ID %u, effect %u", m_spellInfo->Id, effIndex);
1070  return;
1071  }
1072 
1073  CallScriptObjectTargetSelectHandlers(target, effIndex, targetType);
1074  if (!target)
1075  {
1076  TC_LOG_DEBUG("spells", "Spell::SelectImplicitNearbyTargets: OnObjectTargetSelect script hook for spell Id %u set NULL target, effect %u", m_spellInfo->Id, effIndex);
1077  return;
1078  }
1079 
1080  switch (targetType.GetObjectType())
1081  {
1083  {
1084  if (Unit* unit = target->ToUnit())
1085  AddUnitTarget(unit, effMask, true, false);
1086  else
1087  {
1088  TC_LOG_DEBUG("spells", "Spell::SelectImplicitNearbyTargets: OnObjectTargetSelect script hook for spell Id %u set object of wrong type, expected unit, got %s, effect %u", m_spellInfo->Id, target->GetGUID().GetTypeName(), effMask);
1089  return;
1090  }
1091  break;
1092  }
1094  if (GameObject* gobjTarget = target->ToGameObject())
1095  AddGOTarget(gobjTarget, effMask);
1096  else
1097  {
1098  TC_LOG_DEBUG("spells", "Spell::SelectImplicitNearbyTargets: OnObjectTargetSelect script hook for spell Id %u set object of wrong type, expected gameobject, got %s, effect %u", m_spellInfo->Id, target->GetGUID().GetTypeName(), effMask);
1099  return;
1100  }
1101  break;
1103  m_targets.SetDst(*target);
1104  break;
1105  default:
1106  ASSERT(false && "Spell::SelectImplicitNearbyTargets: received not implemented target object type");
1107  break;
1108  }
1109 
1110  SelectImplicitChainTargets(effIndex, targetType, target, effMask);
1111 }
GameObject * focusObject
Definition: Spell.h:706
SpellInfo const *const m_spellInfo
Definition: Spell.h:547
Unit *const m_caster
Definition: Spell.h:647
WorldObject * SearchNearbyTarget(float range, SpellTargetObjectTypes objectType, SpellTargetCheckTypes selectionType, ConditionContainer *condList=NULL)
Definition: Spell.cpp:1824
uint32 Id
Definition: SpellInfo.h:329
Definition: SpellInfo.h:126
SpellCastTargets m_targets
Definition: Spell.h:584
Definition: SpellInfo.h:122
float GetMaxRange(bool positive=false, Unit *caster=NULL, Spell *spell=NULL) const
Definition: SpellInfo.cpp:2475
uint32 RequiresSpellFocus
Definition: SpellInfo.h:352
SpellEffectInfo const * GetEffect(uint32 index) const
Definition: Spell.h:624
Definition: SpellInfo.h:109
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
Definition: Object.h:423
Definition: SpellInfo.h:107
Definition: SpellInfo.h:123
GameObject * ToGameObject()
Definition: Object.h:200
void AddUnitTarget(Unit *target, uint32 effectMask, bool checkIfValid=true, bool implicit=true, Position const *losPosition=nullptr)
Definition: Spell.cpp:2042
Definition: SpellInfo.h:120
Definition: SpellInfo.h:121
Definition: SpellInfo.h:124
bool IsPositive() const
Definition: SpellInfo.cpp:1495
std::vector< Condition * > * ImplicitTargetConditions
Definition: SpellInfo.h:266
Definition: SpellInfo.h:95
void CallScriptObjectTargetSelectHandlers(WorldObject *&target, SpellEffIndex effIndex, SpellImplicitTargetInfo const &targetType)
Definition: Spell.cpp:7225
Definition: SpellInfo.h:238
Definition: SpellInfo.h:125
Definition: GameObject.h:880
static char const * GetTypeName(HighGuid high)
Definition: ObjectGuid.cpp:91
ObjectGuid const & GetGUID() const
Definition: Object.h:105
Definition: SpellInfo.h:106
#define ASSERT
Definition: Errors.h:55
void SelectImplicitChainTargets(SpellEffIndex effIndex, SpellImplicitTargetInfo const &targetType, WorldObject *target, uint32 effMask)
Definition: Spell.cpp:1471
void SetDst(float x, float y, float z, float orientation, uint32 mapId=MAPID_INVALID)
Definition: Spell.cpp:377
void AddGOTarget(GameObject *target, uint32 effectMask)
Definition: Spell.cpp:2153
std::vector< Condition * > ConditionContainer
Definition: ConditionMgr.h:239
Definition: Unit.h:1305
Unit * ToUnit()
Definition: Object.h:197

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Spell::SelectImplicitTargetDestTargets ( SpellEffIndex  effIndex,
SpellImplicitTargetInfo const targetType 
)
1326 {
1327  ASSERT(m_targets.GetObjectTarget() && "Spell::SelectImplicitTargetDestTargets - no explicit object target available!");
1329 
1330  SpellDestination dest(*target);
1331 
1332  switch (targetType.GetTarget())
1333  {
1336  break;
1337  default:
1338  {
1339  if (SpellEffectInfo const* effect = GetEffect(effIndex))
1340  {
1341  float angle = targetType.CalcDirectionAngle();
1342  float objSize = target->GetObjectSize();
1343  float dist = effect->CalcRadius(m_caster);
1344  if (dist < objSize)
1345  dist = objSize;
1346  else if (targetType.GetTarget() == TARGET_DEST_TARGET_RANDOM)
1347  dist = objSize + (dist - objSize) * float(rand_norm());
1348 
1349  Position pos = dest._position;
1350  target->MovePositionToFirstCollision(pos, dist, angle);
1351 
1352  dest.Relocate(pos);
1353  }
1354  break;
1355  }
1356  }
1357 
1358  CallScriptDestinationTargetSelectHandlers(dest, effIndex, targetType);
1359  m_targets.SetDst(dest);
1360 }
Unit *const m_caster
Definition: Spell.h:647
Definition: SharedDefines.h:1932
SpellCastTargets m_targets
Definition: Spell.h:584
SpellEffectInfo const * GetEffect(uint32 index) const
Definition: Spell.h:624
Definition: Object.h:423
Definition: SharedDefines.h:1943
WorldObject * GetObjectTarget() const
Definition: Spell.cpp:282
Definition: Spell.h:118
void Relocate(float x, float y)
Definition: Position.h:67
Definition: SpellInfo.h:238
Definition: SharedDefines.h:1922
double rand_norm()
Definition: Random.cpp:69
void CallScriptDestinationTargetSelectHandlers(SpellDestination &target, SpellEffIndex effIndex, SpellImplicitTargetInfo const &targetType)
Definition: Spell.cpp:7239
Definition: Position.h:27
#define ASSERT
Definition: Errors.h:55
void SetDst(float x, float y, float z, float orientation, uint32 mapId=MAPID_INVALID)
Definition: Spell.cpp:377

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Spell::SelectImplicitTargetObjectTargets ( SpellEffIndex  effIndex,
SpellImplicitTargetInfo const targetType 
)
1450 {
1451  ASSERT((m_targets.GetObjectTarget() || m_targets.GetItemTarget()) && "Spell::SelectImplicitTargetObjectTargets - no explicit object or item target available!");
1452 
1454 
1455  CallScriptObjectTargetSelectHandlers(target, effIndex, targetType);
1456 
1457  if (target)
1458  {
1459  if (Unit* unit = target->ToUnit())
1460  AddUnitTarget(unit, 1 << effIndex, true, false);
1461  else if (GameObject* gobj = target->ToGameObject())
1462  AddGOTarget(gobj, 1 << effIndex);
1463 
1464  SelectImplicitChainTargets(effIndex, targetType, target, 1 << effIndex);
1465  }
1466  // Script hook can remove object target and we would wrongly land here
1467  else if (Item* item = m_targets.GetItemTarget())
1468  AddItemTarget(item, 1 << effIndex);
1469 }
SpellCastTargets m_targets
Definition: Spell.h:584
Item * GetItemTarget() const
Definition: Spell.h:203
void AddItemTarget(Item *item, uint32 effectMask)
Definition: Spell.cpp:2208
Definition: Object.h:423
GameObject * ToGameObject()
Definition: Object.h:200
void AddUnitTarget(Unit *target, uint32 effectMask, bool checkIfValid=true, bool implicit=true, Position const *losPosition=nullptr)
Definition: Spell.cpp:2042
WorldObject * GetObjectTarget() const
Definition: Spell.cpp:282
void CallScriptObjectTargetSelectHandlers(WorldObject *&target, SpellEffIndex effIndex, SpellImplicitTargetInfo const &targetType)
Definition: Spell.cpp:7225
Definition: Item.h:259
Definition: GameObject.h:880
#define ASSERT
Definition: Errors.h:55
void SelectImplicitChainTargets(SpellEffIndex effIndex, SpellImplicitTargetInfo const &targetType, WorldObject *target, uint32 effMask)
Definition: Spell.cpp:1471
void AddGOTarget(GameObject *target, uint32 effectMask)
Definition: Spell.cpp:2153
Definition: Unit.h:1305
Unit * ToUnit()
Definition: Object.h:197

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Spell::SelectImplicitTrajTargets ( SpellEffIndex  effIndex)
Todo:
all calculation should be based on src instead of m_caster
1517 {
1518  if (!m_targets.HasTraj())
1519  return;
1520 
1521  float dist2d = m_targets.GetDist2d();
1522  if (!dist2d)
1523  return;
1524 
1525  float srcToDestDelta = m_targets.GetDstPos()->m_positionZ - m_targets.GetSrcPos()->m_positionZ;
1526 
1527  std::list<WorldObject*> targets;
1530  SearchTargets<Trinity::WorldObjectListSearcher<Trinity::WorldObjectSpellTrajTargetCheck> > (searcher, GRID_MAP_TYPE_MASK_ALL, m_caster, m_targets.GetSrcPos(), dist2d);
1531  if (targets.empty())
1532  return;
1533 
1534  targets.sort(Trinity::ObjectDistanceOrderPred(m_caster));
1535 
1536  float b = tangent(m_targets.GetPitch());
1537  float a = (srcToDestDelta - dist2d * b) / (dist2d * dist2d);
1538  if (a > -0.0001f)
1539  a = 0;
1540  DEBUG_TRAJ(TC_LOG_ERROR("spells", "Spell::SelectTrajTargets: a %f b %f", a, b);)
1541 
1542  float bestDist = m_spellInfo->GetMaxRange(false);
1543 
1544  std::list<WorldObject*>::const_iterator itr = targets.begin();
1545  for (; itr != targets.end(); ++itr)
1546  {
1547  if (!m_caster->HasInLine(*itr, 5.0f))
1548  continue;
1549 
1550  if (m_spellInfo->CheckTarget(m_caster, *itr, true) != SPELL_CAST_OK)
1551  continue;
1552 
1553  if (Unit* unit = (*itr)->ToUnit())
1554  {
1555  if (m_caster == *itr || m_caster->IsOnVehicle(unit) || unit->GetVehicle())
1556  continue;
1557 
1558  if (Creature* creatureTarget = unit->ToCreature())
1559  {
1560  if (!(creatureTarget->GetCreatureTemplate()->type_flags & CREATURE_TYPEFLAGS_PROJECTILE_COLLISION))
1561  continue;
1562  }
1563  }
1564 
1565  const float size = std::max((*itr)->GetObjectSize() * 0.7f, 1.0f); // 1/sqrt(3)
1567  const float objDist2d = m_targets.GetSrcPos()->GetExactDist2d(*itr) * std::cos(m_targets.GetSrcPos()->GetRelativeAngle(*itr));
1568  const float dz = (*itr)->GetPositionZ() - m_targets.GetSrcPos()->m_positionZ;
1569 
1570  DEBUG_TRAJ(TC_LOG_ERROR("spells", "Spell::SelectTrajTargets: check %u, dist between %f %f, height between %f %f.", (*itr)->GetEntry(), objDist2d - size, objDist2d + size, dz - size, dz + size);)
1571 
1572  float dist = objDist2d - size;
1573  float height = dist * (a * dist + b);
1574  DEBUG_TRAJ(TC_LOG_ERROR("spells", "Spell::SelectTrajTargets: dist %f, height %f.", dist, height);)
1575  if (dist < bestDist && height < dz + size && height > dz - size)
1576  {
1577  bestDist = dist > 0 ? dist : 0;
1578  break;
1579  }
1580 
1581 #define CHECK_DIST {\
1582  DEBUG_TRAJ(TC_LOG_ERROR("spells", "Spell::SelectTrajTargets: dist %f, height %f.", dist, height);)\
1583  if (dist > bestDist)\
1584  continue;\
1585  if (dist < objDist2d + size && dist > objDist2d - size)\
1586  {\
1587  bestDist = dist;\
1588  break;\
1589  }\
1590  }
1591 
1592  if (!a)
1593  {
1594  height = dz - size;
1595  dist = height / b;
1596  CHECK_DIST;
1597 
1598  height = dz + size;
1599  dist = height / b;
1600  CHECK_DIST;
1601 
1602  continue;
1603  }
1604 
1605  height = dz - size;
1606  float sqrt1 = b * b + 4 * a * height;
1607  if (sqrt1 > 0)
1608  {
1609  sqrt1 = std::sqrt(sqrt1);
1610  dist = (sqrt1 - b) / (2 * a);
1611  CHECK_DIST;
1612  }
1613 
1614  height = dz + size;
1615  float sqrt2 = b * b + 4 * a * height;
1616  if (sqrt2 > 0)
1617  {
1618  sqrt2 = std::sqrt(sqrt2);
1619  dist = (sqrt2 - b) / (2 * a);
1620  CHECK_DIST;
1621 
1622  dist = (-sqrt2 - b) / (2 * a);
1623  CHECK_DIST;
1624  }
1625 
1626  if (sqrt1 > 0)
1627  {
1628  dist = (-sqrt1 - b) / (2 * a);
1629  CHECK_DIST;
1630  }
1631  }
1632 
1633  if (m_targets.GetSrcPos()->GetExactDist2d(m_targets.GetDstPos()) > bestDist)
1634  {
1635  float x = m_targets.GetSrcPos()->m_positionX + std::cos(m_caster->GetOrientation()) * bestDist;
1636  float y = m_targets.GetSrcPos()->m_positionY + std::sin(m_caster->GetOrientation()) * bestDist;
1637  float z = m_targets.GetSrcPos()->m_positionZ + bestDist * (a * bestDist + b);
1638 
1639  if (itr != targets.end())
1640  {
1641  float distSq = (*itr)->GetExactDistSq(x, y, z);
1642  float sizeSq = (*itr)->GetObjectSize();
1643  sizeSq *= sizeSq;
1644  DEBUG_TRAJ(TC_LOG_ERROR("spells", "Initial %f %f %f %f %f", x, y, z, distSq, sizeSq);)
1645  if (distSq > sizeSq)
1646  {
1647  float factor = 1 - std::sqrt(sizeSq / distSq);
1648  x += factor * ((*itr)->GetPositionX() - x);
1649  y += factor * ((*itr)->GetPositionY() - y);
1650  z += factor * ((*itr)->GetPositionZ() - z);
1651 
1652  distSq = (*itr)->GetExactDistSq(x, y, z);
1653  DEBUG_TRAJ(TC_LOG_ERROR("spells", "Initial %f %f %f %f %f", x, y, z, distSq, sizeSq);)
1654  }
1655  }
1656 
1657  Position trajDst;
1658  trajDst.Relocate(x, y, z, m_caster->GetOrientation());
1660  dest.Relocate(trajDst);
1661 
1663  m_targets.ModDst(dest);
1664  }
1665 
1666  if (Vehicle* veh = m_caster->GetVehicleKit())
1667  veh->SetLastShootPos(*m_targets.GetDstPos());
1668 }
SpellInfo const *const m_spellInfo
Definition: Spell.h:547
Unit *const m_caster
Definition: Spell.h:647
Definition: GridDefines.h:79
Definition: Vehicle.h:32
float m_positionY
Definition: Position.h:53
SpellCastTargets m_targets
Definition: Spell.h:584
float GetMaxRange(bool positive=false, Unit *caster=NULL, Spell *spell=NULL) const
Definition: SpellInfo.cpp:2475
float GetDist2d() const
Definition: Spell.h:237
Definition: Object.h:668
WorldLocation const * GetDstPos() const
Definition: Spell.cpp:372
float m_positionX
Definition: Position.h:52
Definition: Creature.h:467
T max(const T &x, const T &y)
Definition: g3dmath.h:320
bool HasTraj() const
Definition: Spell.h:230
Definition: SharedDefines.h:1958
SpellDestination const * GetDst() const
Definition: Spell.cpp:367
float GetExactDist2d(const float x, const float y) const
Definition: Position.h:137
Definition: Spell.h:118
SpellCastResult CheckTarget(Unit const *caster, WorldObject const *target, bool implicit=true) const
Definition: SpellInfo.cpp:1875
void ModDst(Position const &pos)
Definition: Spell.cpp:407
void Relocate(float x, float y)
Definition: Position.h:67
G3D::int16 z
Definition: Vector3int16.h:46
#define DEBUG_TRAJ(a)
Definition: Spell.cpp:1514
G3D::int16 y
Definition: Vector2int16.h:38
float GetRelativeAngle(Position const *pos) const
Definition: Position.h:177
float m_positionZ
Definition: Position.h:54
#define CHECK_DIST
Definition: SpellInfo.h:207
Definition: SharedDefines.h:3675
void Relocate(Position const &pos)
Definition: Spell.cpp:93
Creature * ToCreature()
Definition: Object.h:194
Position const * GetSrcPos() const
Definition: Spell.cpp:333
void CallScriptDestinationTargetSelectHandlers(SpellDestination &target, SpellEffIndex effIndex, SpellImplicitTargetInfo const &targetType)
Definition: Spell.cpp:7239
Definition: Position.h:27
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
G3D::int16 x
Definition: Vector2int16.h:37
T check(T value)
Definition: format.h:305
float tangent(float x)
Definition: Spell.cpp:1502
Definition: Unit.h:1305
Definition: SharedDefines.h:1538
Definition: GridNotifiers.h:218
Unit * ToUnit()
Definition: Object.h:197
float GetPitch() const
Definition: Spell.h:232

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Spell::SelectSpellTargets ( )
751 {
752  // select targets for cast phase
754 
755  uint32 processedAreaEffectsMask = 0;
756 
757  for (SpellEffectInfo const* effect : GetEffects())
758  {
759  if (!effect)
760  continue;
761 
762  // not call for empty effect.
763  // Also some spells use not used effect targets for store targets for dummy effect in triggered spells
764  if (!effect->IsEffect())
765  continue;
766 
767  // set expected type of implicit targets to be sent to client
768  uint32 implicitTargetMask = GetTargetFlagMask(effect->TargetA.GetObjectType()) | GetTargetFlagMask(effect->TargetB.GetObjectType());
769  if (implicitTargetMask & TARGET_FLAG_UNIT)
770  m_targets.SetTargetFlag(TARGET_FLAG_UNIT);
771  if (implicitTargetMask & (TARGET_FLAG_GAMEOBJECT | TARGET_FLAG_GAMEOBJECT_ITEM))
773 
774  SelectEffectImplicitTargets(SpellEffIndex(effect->EffectIndex), effect->TargetA, processedAreaEffectsMask);
775  SelectEffectImplicitTargets(SpellEffIndex(effect->EffectIndex), effect->TargetB, processedAreaEffectsMask);
776 
777  // Select targets of effect based on effect type
778  // those are used when no valid target could be added for spell effect based on spell target type
779  // some spell effects use explicit target as a default target added to target map (like SPELL_EFFECT_LEARN_SPELL)
780  // some spell effects add target to target map only when target type specified (like SPELL_EFFECT_WEAPON)
781  // some spell effects don't add anything to target map (confirmed with sniffs) (like SPELL_EFFECT_DESTROY_ALL_TOTEMS)
782  SelectEffectTypeImplicitTargets(effect->EffectIndex);
783 
784  if (m_targets.HasDst())
785  AddDestTarget(*m_targets.GetDst(), effect->EffectIndex);
786 
787  if (m_spellInfo->IsChanneled())
788  {
789  uint32 mask = (1 << effect->EffectIndex);
790  for (std::vector<TargetInfo>::iterator ihit = m_UniqueTargetInfo.begin(); ihit != m_UniqueTargetInfo.end(); ++ihit)
791  {
792  if (ihit->effectMask & mask)
793  {
795  break;
796  }
797  }
798  }
799  else if (m_auraScaleMask)
800  {
801  bool checkLvl = !m_UniqueTargetInfo.empty();
802  for (std::vector<TargetInfo>::iterator ihit = m_UniqueTargetInfo.begin(); ihit != m_UniqueTargetInfo.end();)
803  {
804  // remove targets which did not pass min level check
805  if (m_auraScaleMask && ihit->effectMask == m_auraScaleMask)
806  {
807  // Do not check for selfcast
808  if (!ihit->scaleAura && ihit->targetGUID != m_caster->GetGUID())
809  {
810  ihit = m_UniqueTargetInfo.erase(ihit);
811  continue;
812  }
813  }
814 
815  ++ihit;
816  }
817 
818  if (checkLvl && m_UniqueTargetInfo.empty())
819  {
821  finish(false);
822  }
823  }
824  }
825 
826  if (m_targets.HasDst())
827  {
828  if (m_targets.HasTraj())
829  {
830  float speed = m_targets.GetSpeedXY();
831  if (speed > 0.0f)
832  m_delayMoment = uint64(std::floor(m_targets.GetDist2d() / speed * 1000.0f));
833  }
834  else if (m_spellInfo->Speed > 0.0f)
835  {
836  float dist = m_caster->GetDistance(*m_targets.GetDstPos());
838  m_delayMoment = uint64(std::floor(dist / m_spellInfo->Speed * 1000.0f));
839  else
840  m_delayMoment = uint64(m_spellInfo->Speed * 1000.0f);
841  }
842  }
843 }
Definition: SharedDefines.h:684
SpellInfo const *const m_spellInfo
Definition: Spell.h:547
Unit *const m_caster
Definition: Spell.h:647
Definition: SpellInfo.h:49
bool IsChanneled() const
Definition: SpellInfo.cpp:1514
uint32 m_channelTargetEffectMask
Definition: Spell.h:740
void SelectEffectTypeImplicitTargets(uint32 effIndex)
Definition: Spell.cpp:1670
void SelectEffectImplicitTargets(SpellEffIndex effIndex, SpellImplicitTargetInfo const &targetType, uint32 &processedEffectMask)
Definition: Spell.cpp:845
SpellCastTargets m_targets
Definition: Spell.h:584
static Vector3int16 floor(const Vector3 &v)
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 AddDestTarget(SpellDestination const &dest, uint32 effIndex)
Definition: Spell.cpp:2240
float GetDist2d() const
Definition: Spell.h:237
WorldLocation const * GetDstPos() const
Definition: Spell.cpp:372
uint64_t uint64
Definition: g3dmath.h:170
uint32 m_auraScaleMask
Definition: Spell.h:829
bool HasTraj() const
Definition: Spell.h:230
void SelectExplicitTargets()
Definition: Spell.cpp:721
SpellDestination const * GetDst() const
Definition: Spell.cpp:367
Definition: SharedDefines.h:1334
std::vector< TargetInfo > m_UniqueTargetInfo
Definition: Spell.h:739
void finish(bool ok=true)
Definition: Spell.cpp:3620
float GetDistance(WorldObject const *obj) const
Definition: Object.cpp:1594
bool HasDst() const
Definition: Spell.h:229
bool HasAttribute(SpellAttr0 attribute) const
Definition: SpellInfo.h:462
uint64 m_delayMoment
Definition: Spell.h:679
SpellEffIndex
Definition: SharedDefines.h:26
Definition: SpellInfo.h:238
uint32_t uint32
Definition: Define.h:150
SpellEffectInfoVector const & GetEffects() const
Definition: Spell.h:623
Definition: SpellInfo.h:62
float Speed
Definition: SpellInfo.h:380
ObjectGuid const & GetGUID() const
Definition: Object.h:105
void SetTargetFlag(SpellCastTargetFlags flag)
Definition: Spell.h:182
Definition: SpellInfo.h:59
float GetSpeedXY() const
Definition: Spell.h:238
uint32 GetTargetFlagMask(SpellTargetObjectTypes objType)
Definition: SpellInfo.cpp:30

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Spell::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 
)
static
3733 {
3734  if (result == SPELL_CAST_OK)
3735  return;
3736 
3737  WorldPackets::Spells::CastFailed packet(opcode);
3738  packet.CastID = cast_count;
3739  packet.SpellID = spellInfo->Id;
3740  packet.Reason = result;
3741 
3742  switch (result)
3743  {
3745  packet.FailedArg1 = 0; // unknown (value 1 update cooldowns on client flag)
3746  break;
3748  packet.FailedArg1 = spellInfo->RequiresSpellFocus; // SpellFocusObject.dbc id
3749  break;
3750  case SPELL_FAILED_REQUIRES_AREA: // AreaTable.dbc id
3751  // hardcode areas limitation case
3752  switch (spellInfo->Id)
3753  {
3754  case 41617: // Cenarion Mana Salve
3755  case 41619: // Cenarion Healing Salve
3756  packet.FailedArg1 = 3905;
3757  break;
3758  case 41618: // Bottled Nethergon Energy
3759  case 41620: // Bottled Nethergon Vapor
3760  packet.FailedArg1 = 3842;
3761  break;
3762  case 45373: // Bloodberry Elixir
3763  packet.FailedArg1 = 4075;
3764  break;
3765  default: // default case (don't must be)
3766  packet.FailedArg1 = 0;
3767  break;
3768  }
3769  break;
3770  case SPELL_FAILED_TOTEMS:
3771  if (spellInfo->Totem[0])
3772  packet.FailedArg1 = spellInfo->Totem[0];
3773  if (spellInfo->Totem[1])
3774  packet.FailedArg2 = spellInfo->Totem[1];
3775  break;
3777  if (spellInfo->TotemCategory[0])
3778  packet.FailedArg1 = spellInfo->TotemCategory[0];
3779  if (spellInfo->TotemCategory[1])
3780  packet.FailedArg2 = spellInfo->TotemCategory[1];
3781  break;
3785  packet.FailedArg1 = spellInfo->EquippedItemClass;
3786  packet.FailedArg2 = spellInfo->EquippedItemSubClassMask;
3787  break;
3789  {
3790  uint32 item = 0;
3791  for (SpellEffectInfo const* effect : spellInfo->GetEffectsForDifficulty(caster->GetMap()->GetDifficultyID()))
3792  if (effect->ItemType)
3793  item = effect->ItemType;
3794  ItemTemplate const* proto = sObjectMgr->GetItemTemplate(item);
3795  if (proto && proto->GetItemLimitCategory())
3796  packet.FailedArg1 = proto->GetItemLimitCategory();
3797  break;
3798  }
3800  packet.FailedArg1 = spellInfo->GetAllEffectsMechanicMask(); // SpellMechanic.dbc id
3801  break;
3803  packet.FailedArg1 = spellInfo->EquippedItemSubClassMask; // seems correct...
3804  break;
3806  packet.FailedArg1 = 0; // Item id
3807  packet.FailedArg2 = 0; // Item count?
3808  break;
3810  packet.FailedArg1 = 0; // SkillLine.dbc id
3811  packet.FailedArg2 = 0; // required skill value
3812  break;
3814  packet.FailedArg1 = 0; // required fishing skill
3815  break;
3817  packet.FailedArg1 = customError;
3818  break;
3819  case SPELL_FAILED_SILENCED:
3820  packet.FailedArg1 = 0; // Unknown
3821  break;
3822  case SPELL_FAILED_REAGENTS:
3823  {
3824  uint32 missingItem = 0;
3825  for (uint32 i = 0; i < MAX_SPELL_REAGENTS; i++)
3826  {
3827  if (spellInfo->Reagent[i] <= 0)
3828  continue;
3829 
3830  uint32 itemid = spellInfo->Reagent[i];
3831  uint32 itemcount = spellInfo->ReagentCount[i];
3832 
3833  if (!caster->HasItemCount(itemid, itemcount))
3834  {
3835  missingItem = itemid;
3836  break;
3837  }
3838  }
3839 
3840  packet.FailedArg1 = missingItem; // first missing item
3841  break;
3842  }
3844  {
3845  if (misc)
3846  if (TalentEntry const* talent = sTalentStore.LookupEntry(misc[0]))
3847  packet.FailedArg1 = talent->SpellID;
3848  break;
3849  }
3850  // TODO: SPELL_FAILED_NOT_STANDING
3851  default:
3852  break;
3853  }
3854 
3855  caster->GetSession()->SendPacket(packet.Write());
3856 }
Definition: SharedDefines.h:1299
Definition: SharedDefines.h:1417
Definition: SharedDefines.h:1438
Definition: SharedDefines.h:1341
Definition: SharedDefines.h:1418
Definition: SharedDefines.h:1476
Definition: SharedDefines.h:1488
#define sObjectMgr
Definition: ObjectMgr.h:1567
Definition: SharedDefines.h:1416
Definition: SharedDefines.h:1386
uint32 GetItemLimitCategory() const
Definition: ItemTemplate.h:700
Definition: SharedDefines.h:1388
Definition: SharedDefines.h:1340
Definition: SpellInfo.h:238
uint32_t uint32
Definition: Define.h:150
Definition: SpellPackets.h:422
Definition: SharedDefines.h:1435
Definition: SharedDefines.h:1390
DBCStorage< TalentEntry > sTalentStore(Talentfmt)
Definition: ItemTemplate.h:647
#define MAX_SPELL_REAGENTS
Definition: DB2Structure.h:1285
Definition: SharedDefines.h:1387
Definition: SharedDefines.h:1353
Definition: SharedDefines.h:1301
Definition: DBCStructure.h:1255
Definition: SharedDefines.h:1538
Definition: SharedDefines.h:1291
Definition: SharedDefines.h:1300

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Spell::SendCastResult ( SpellCastResult  result)
3707 {
3708  if (result == SPELL_CAST_OK)
3709  return;
3710 
3711  if (m_caster->GetTypeId() != TYPEID_PLAYER)
3712  return;
3713 
3714  if (m_caster->ToPlayer()->GetSession()->PlayerLoading()) // don't send cast results at loading time
3715  return;
3716 
3718 }
union Spell::@326 m_misc
SpellInfo const *const m_spellInfo
Definition: Spell.h:547
Unit *const m_caster
Definition: Spell.h:647
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
Definition: Opcodes.h:872
Player * ToPlayer()
Definition: Object.h:191
TypeID GetTypeId() const
Definition: Object.h:113
Definition: ObjectGuid.h:33
SpellCustomErrors m_customError
Definition: Spell.h:586
uint8 m_cast_count
Definition: Spell.h:552
Definition: SharedDefines.h:1538

+ Here is the call graph for this function:

void Spell::SendChannelStart ( uint32  duration)
4281 {
4282  ObjectGuid channelTarget = m_targets.GetObjectTargetGUID();
4283  if (!channelTarget && !m_spellInfo->NeedsExplicitUnitTarget())
4284  if (m_UniqueTargetInfo.size() + m_UniqueGOTargetInfo.size() == 1) // this is for TARGET_SELECT_CATEGORY_NEARBY
4285  channelTarget = !m_UniqueTargetInfo.empty() ? m_UniqueTargetInfo.front().targetGUID : m_UniqueGOTargetInfo.front().targetGUID;
4286 
4287  WorldPackets::Spells::SpellChannelStart spellChannelStart;
4288  spellChannelStart.CasterGUID = m_caster->GetGUID();
4289  spellChannelStart.SpellID = m_spellInfo->Id;
4290  spellChannelStart.ChannelDuration = duration;
4291  m_caster->SendMessageToSet(spellChannelStart.Write(), true);
4292 
4293  uint32 schoolImmunityMask = m_caster->GetSchoolImmunityMask();
4294  uint32 mechanicImmunityMask = m_caster->GetMechanicImmunityMask();
4295 
4296  if (schoolImmunityMask || mechanicImmunityMask)
4297  {
4298  spellChannelStart.InterruptImmunities = boost::in_place();
4299  spellChannelStart.InterruptImmunities->SchoolImmunities = schoolImmunityMask;
4300  spellChannelStart.InterruptImmunities->Immunities = mechanicImmunityMask;
4301  }
4302 
4303  m_timer = duration;
4304  if (!channelTarget.IsEmpty())
4305  m_caster->SetChannelObjectGuid(channelTarget);
4306 
4309 }
SpellInfo const *const m_spellInfo
Definition: Spell.h:547
Unit *const m_caster
Definition: Spell.h:647
uint32 Id
Definition: SpellInfo.h:329
Map * GetMap() const
Definition: Object.h:543
SpellCastTargets m_targets
Definition: Spell.h:584
Difficulty GetDifficultyID() const
Definition: Map.h:390
uint32 GetSpellXSpellVisualId(Difficulty difficulty) const
Definition: SpellInfo.cpp:2837
Definition: SpellPackets.h:688
WorldPacket const * Write() override
Definition: SpellPackets.cpp:692
uint32 ChannelDuration
Definition: SpellPackets.h:699
void SetUInt32Value(uint16 index, uint32 value)
Definition: Object.cpp:996
int32 m_timer
Definition: Spell.h:819
ObjectGuid GetObjectTargetGUID() const
Definition: Spell.cpp:287
Definition: UpdateFields.h:94
std::vector< TargetInfo > m_UniqueTargetInfo
Definition: Spell.h:739
uint32 GetSchoolImmunityMask() const
Definition: Unit.cpp:9319
uint32_t uint32
Definition: Define.h:150
uint32 GetMechanicImmunityMask() const
Definition: Unit.cpp:9329
ObjectGuid CasterGUID
Definition: SpellPackets.h:697
std::vector< GOTargetInfo > m_UniqueGOTargetInfo
Definition: Spell.h:749
ObjectGuid const & GetGUID() const
Definition: Object.h:105
void SetChannelObjectGuid(ObjectGuid guid)
Definition: Unit.h:1905
Definition: UpdateFields.h:93
int32 SpellID
Definition: SpellPackets.h:695
bool NeedsExplicitUnitTarget() const
Definition: SpellInfo.cpp:1358
Definition: ObjectGuid.h:189
virtual void SendMessageToSet(WorldPacket const *data, bool self)
Definition: Object.cpp:2144
Optional< SpellChannelStartInterruptImmunities > InterruptImmunities
Definition: SpellPackets.h:696
bool IsEmpty() const
Definition: ObjectGuid.h:242

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Spell::SendChannelUpdate ( uint32  time)
4267 {
4268  if (time == 0)
4269  {
4272  }
4273 
4274  WorldPackets::Spells::SpellChannelUpdate spellChannelUpdate;
4275  spellChannelUpdate.CasterGUID = m_caster->GetGUID();
4276  spellChannelUpdate.TimeRemaining = time;
4277  m_caster->SendMessageToSet(spellChannelUpdate.Write(), true);
4278 }
Unit *const m_caster
Definition: Spell.h:647
static ObjectGuid const Empty
Definition: ObjectGuid.h:196
void SetUInt32Value(uint16 index, uint32 value)
Definition: Object.cpp:996
ObjectGuid const & GetGUID() const
Definition: Object.h:105
void SetChannelObjectGuid(ObjectGuid guid)
Definition: Unit.h:1905
WorldPacket const * Write() override
Definition: SpellPackets.cpp:710
Definition: UpdateFields.h:93
virtual void SendMessageToSet(WorldPacket const *data, bool self)
Definition: Object.cpp:2144
Definition: SpellPackets.h:702
ObjectGuid CasterGUID
Definition: SpellPackets.h:709
int32 TimeRemaining
Definition: SpellPackets.h:710

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Spell::SendInterrupted ( uint8  result)
4249 {
4250  WorldPackets::Spells::SpellFailure failurePacket;
4251  failurePacket.CasterUnit = m_caster->GetGUID();
4252  failurePacket.CastID = m_cast_count;
4253  failurePacket.SpellID = m_spellInfo->Id;
4254  failurePacket.SpelXSpellVisualID = m_SpellVisual;
4255  failurePacket.Reason = result;
4256  m_caster->SendMessageToSet(failurePacket.Write(), true);
4257 
4259  failedPacket.CasterUnit = m_caster->GetGUID();
4260  failedPacket.CastID = m_cast_count;
4261  failedPacket.SpellID = m_spellInfo->Id;
4262  failedPacket.Reason = result;
4263  m_caster->SendMessageToSet(failedPacket.Write(), true);
4264 }
SpellInfo const *const m_spellInfo
Definition: Spell.h:547
Unit *const m_caster
Definition: Spell.h:647
uint32 Id
Definition: SpellInfo.h:329
ObjectGuid CasterUnit
Definition: SpellPackets.h:416
uint32 m_SpellVisual
Definition: Spell.h:582
uint32 SpellID
Definition: SpellPackets.h:417
uint16 Reason
Definition: SpellPackets.h:405
uint8 Reason
Definition: SpellPackets.h:418
ObjectGuid CasterUnit
Definition: SpellPackets.h:402
Definition: SpellPackets.h:395
uint32 SpelXSpellVisualID
Definition: SpellPackets.h:404
uint8 CastID
Definition: SpellPackets.h:419
uint8 CastID
Definition: SpellPackets.h:406
Definition: SpellPackets.h:409
ObjectGuid const & GetGUID() const
Definition: Object.h:105
WorldPacket const * Write() override
Definition: SpellPackets.cpp:442
WorldPacket const * Write() override
Definition: SpellPackets.cpp:431
uint32 SpellID
Definition: SpellPackets.h:403
virtual void SendMessageToSet(WorldPacket const *data, bool self)
Definition: Object.cpp:2144
uint8 m_cast_count
Definition: Spell.h:552

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Spell::SendLoot ( ObjectGuid  guid,
LootType  loottype 
)
protected
Todo:
possible must be moved to loot release (in different from linked triggering)
1763 {
1764  Player* player = m_caster->ToPlayer();
1765  if (!player)
1766  return;
1767 
1768  if (gameObjTarget)
1769  {
1770  // Players shouldn't be able to loot gameobjects that are currently despawned
1771  if (!gameObjTarget->isSpawned() && !player->IsGameMaster())
1772  {
1773  TC_LOG_ERROR("spells", "Possible hacking attempt: Player %s [%s] tried to loot a gameobject [%s] which is on respawn time without being in GM mode!",
1774  player->GetName().c_str(), player->GetGUID().ToString().c_str(), gameObjTarget->GetGUID().ToString().c_str());
1775  return;
1776  }
1777  // special case, already has GossipHello inside so return and avoid calling twice
1779  {
1781  return;
1782  }
1783 
1784  if (sScriptMgr->OnGossipHello(player, gameObjTarget))
1785  return;
1786 
1787  if (gameObjTarget->AI()->GossipHello(player))
1788  return;
1789 
1790  switch (gameObjTarget->GetGoType())
1791  {
1792  case GAMEOBJECT_TYPE_DOOR:
1794  gameObjTarget->UseDoorOrButton(0, false, player);
1795  return;
1796 
1798  player->PrepareGossipMenu(gameObjTarget, gameObjTarget->GetGOInfo()->questgiver.gossipID, true);
1799  player->SendPreparedGossip(gameObjTarget);
1800  return;
1801 
1803  // triggering linked GO
1804  if (uint32 trapEntry = gameObjTarget->GetGOInfo()->spellFocus.linkedTrap)
1806  return;
1807 
1808  case GAMEOBJECT_TYPE_CHEST:
1810  if (gameObjTarget->GetGOInfo()->chest.triggeredEvent)
1811  {
1812  TC_LOG_DEBUG("spells", "Chest ScriptStart id %u for GO " UI64FMTD, gameObjTarget->GetGOInfo()->chest.triggeredEvent, gameObjTarget->GetSpawnId());
1813  player->GetMap()->ScriptsStart(sEventScripts, gameObjTarget->GetGOInfo()->chest.triggeredEvent, player, gameObjTarget);
1814  }
1815 
1816  // triggering linked GO
1817  if (uint32 trapEntry = gameObjTarget->GetGOInfo()->chest.linkedTrap)
1819 
1820  // Don't return, let loots been taken
1821  default:
1822  break;
1823  }
1824  }
1825 
1826  // Send loot
1827  player->SendLoot(guid, loottype);
1828 }
GameObject * gameObjTarget
Definition: Spell.h:692
Unit *const m_caster
Definition: Spell.h:647
GameObjectAI * AI() const
Definition: GameObject.h:1061
void TriggeringLinkedGameObject(uint32 trapEntry, Unit *target)
Definition: GameObject.cpp:1126
Definition: SharedDefines.h:2073
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
ObjectGuid::LowType GetSpawnId() const
Definition: GameObject.h:902
Player * ToPlayer()
Definition: Object.h:191
struct GameObjectTemplate::@221::@225 questgiver
virtual bool GossipHello(Player *)
Definition: GameObjectAI.h:50
Definition: SharedDefines.h:2066
struct GameObjectTemplate::@221::@226 chest
#define UI64FMTD
Definition: Define.h:137
uint32_t uint32
Definition: Define.h:150
GameObjectTemplate const * GetGOInfo() const
Definition: GameObject.h:894
void UseDoorOrButton(uint32 time_to_restore=0, bool alternative=false, Unit *user=NULL)
Definition: GameObject.cpp:1182
void Use(Unit *user)
Definition: GameObject.cpp:1232
ObjectGuid const & GetGUID() const
Definition: Object.h:105
bool isSpawned() const
Definition: GameObject.h:951
Definition: SharedDefines.h:2067
GameobjectTypes GetGoType() const
Definition: GameObject.h:964
ScriptMapMap sEventScripts
Definition: ObjectMgr.cpp:52
Definition: SharedDefines.h:2075
Definition: SharedDefines.h:2068
#define sScriptMgr
Definition: ScriptMgr.h:837
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
struct GameObjectTemplate::@221::@231 spellFocus
std::string ToString() const
Definition: ObjectGuid.cpp:99
Definition: SharedDefines.h:2065

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Spell::SendPetCastResult ( SpellCastResult  result)
3721 {
3722  if (result == SPELL_CAST_OK)
3723  return;
3724 
3725  Unit* owner = m_caster->GetCharmerOrOwner();
3726  if (!owner || owner->GetTypeId() != TYPEID_PLAYER)
3727  return;
3728 
3730 }
union Spell::@326 m_misc
SpellInfo const *const m_spellInfo
Definition: Spell.h:547
Unit *const m_caster
Definition: Spell.h:647
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
Definition: Opcodes.h:1351
Player * ToPlayer()
Definition: Object.h:191
Definition: SharedDefines.h:1543
TypeID GetTypeId() const
Definition: Object.h:113
Unit * GetCharmerOrOwner() const
Definition: Unit.cpp:7627
Definition: ObjectGuid.h:33
uint8 m_cast_count
Definition: Spell.h:552
Definition: Unit.h:1305
Definition: SharedDefines.h:1538

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Spell::SendResurrectRequest ( Player target)
4312 {
4313  // get resurrector name for creature resurrections, otherwise packet will be not accepted
4314  // for player resurrections the name is looked up by guid
4315  std::string const sentName(m_caster->GetTypeId() == TYPEID_PLAYER
4316  ? "" : m_caster->GetNameForLocaleIdx(target->GetSession()->GetSessionDbLocaleIndex()));
4317 
4318  WorldPackets::Spells::ResurrectRequest resurrectRequest;
4319  resurrectRequest.ResurrectOffererGUID = m_caster->GetGUID();
4321 
4322  if (Pet* pet = target->GetPet())
4323  {
4324  if (CharmInfo* charmInfo = pet->GetCharmInfo())
4325  resurrectRequest.PetNumber = charmInfo->GetPetNumber();
4326  }
4327 
4328  resurrectRequest.SpellID = m_spellInfo->Id;
4329 
4330  //packet.ReadBit("UseTimer"); /// @todo: 6.x Has to be implemented
4331  resurrectRequest.Sickness = m_caster->GetTypeId() != TYPEID_PLAYER; // "you'll be afflicted with resurrection sickness"
4332 
4333  resurrectRequest.Name = sentName;
4334 
4335  target->GetSession()->SendPacket(resurrectRequest.Write());
4336 }
SpellInfo const *const m_spellInfo
Definition: Spell.h:547
Unit *const m_caster
Definition: Spell.h:647
uint32 Id
Definition: SpellInfo.h:329
WorldPacket const * Write() override
Definition: SpellPackets.cpp:717
uint32 ResurrectOffererVirtualRealmAddress
Definition: SpellPackets.h:721
ObjectGuid ResurrectOffererGUID
Definition: SpellPackets.h:720
int32 SpellID
Definition: SpellPackets.h:723
TypeID GetTypeId() const
Definition: Object.h:113
bool Sickness
Definition: SpellPackets.h:725
uint32 PetNumber
Definition: SpellPackets.h:722
Definition: Unit.h:1201
ObjectGuid const & GetGUID() const
Definition: Object.h:105
Definition: ObjectGuid.h:33
std::string Name
Definition: SpellPackets.h:726
Definition: SpellPackets.h:713
virtual std::string const & GetNameForLocaleIdx(LocaleConstant) const
Definition: Object.h:482
uint32 GetVirtualRealmAddress()
Definition: World.cpp:3487
Definition: Pet.h:46

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Spell::SendSpellCooldown ( )
3533 {
3534  if (m_CastItem)
3536  else
3538 }
SpellInfo const *const m_spellInfo
Definition: Spell.h:547
Unit *const m_caster
Definition: Spell.h:647
void HandleCooldowns(SpellInfo const *spellInfo, Item const *item, Spell *spell=nullptr)
Definition: SpellHistory.cpp:233
uint32 m_castItemEntry
Definition: Spell.h:550
Item * m_CastItem
Definition: Spell.h:548
SpellHistory * GetSpellHistory()
Definition: Unit.h:1926

+ Here is the caller graph for this function:

void Spell::SendSpellExecuteLog ( )
4105 {
4107 
4108  spellExecuteLog.Caster = m_caster->GetGUID();
4109  spellExecuteLog.SpellID = m_spellInfo->Id;
4110 
4111  if (_powerDrainTargets->empty() && _extraAttacksTargets->empty() &&
4112  _durabilityDamageTargets->empty() && _genericVictimTargets->empty() &&
4113  _tradeSkillTargets->empty() && _feedPetTargets->empty())
4114  return;
4115 
4116  for (SpellEffectInfo const* effect : GetEffects())
4117  {
4119  if (!effect)
4120  continue;
4121 
4122  spellLogEffect.Effect = effect->Effect;
4123 
4124  for (SpellLogEffectPowerDrainParams const& powerDrainParam : _powerDrainTargets[effect->EffectIndex])
4125  spellLogEffect.PowerDrainTargets.push_back(powerDrainParam);
4126 
4127  for (SpellLogEffectExtraAttacksParams const& extraAttacksTarget : _extraAttacksTargets[effect->EffectIndex])
4128  spellLogEffect.ExtraAttacksTargets.push_back(extraAttacksTarget);
4129 
4130  for (SpellLogEffectDurabilityDamageParams const& durabilityDamageTarget : _durabilityDamageTargets[effect->EffectIndex])
4131  spellLogEffect.DurabilityDamageTargets.push_back(durabilityDamageTarget);
4132 
4133  for (SpellLogEffectGenericVictimParams const& genericVictimTarget : _genericVictimTargets[effect->EffectIndex])
4134  spellLogEffect.GenericVictimTargets.push_back(genericVictimTarget);
4135 
4136  for (SpellLogEffectTradeSkillItemParams const& tradeSkillTarget : _tradeSkillTargets[effect->EffectIndex])
4137  spellLogEffect.TradeSkillTargets.push_back(tradeSkillTarget);
4138 
4139  for (SpellLogEffectFeedPetParams const& feedPetTarget : _feedPetTargets[effect->EffectIndex])
4140  spellLogEffect.FeedPetTargets.push_back(feedPetTarget);
4141 
4142  spellExecuteLog.Effects.push_back(spellLogEffect);
4143  }
4144 
4145  m_caster->SendCombatLogMessage(&spellExecuteLog);
4146 }
SpellInfo const *const m_spellInfo
Definition: Spell.h:547
Unit *const m_caster
Definition: Spell.h:647
uint32 Id
Definition: SpellInfo.h:329
Definition: Spell.h:160
std::vector< SpellLogEffectPowerDrainParams > _powerDrainTargets[MAX_SPELL_EFFECTS]
Definition: Spell.h:832
std::vector< SpellLogEffectExtraAttacksParams > ExtraAttacksTargets
Definition: CombatLogPackets.h:121
std::vector< SpellLogEffectDurabilityDamageParams > DurabilityDamageTargets
Definition: CombatLogPackets.h:122
std::vector< SpellLogEffectTradeSkillItemParams > _tradeSkillTargets[MAX_SPELL_EFFECTS]
Definition: Spell.h:836
int32 Effect
Definition: CombatLogPackets.h:118
int32 SpellID
Definition: CombatLogPackets.h:133
Definition: Spell.h:155
Definition: CombatLogPackets.h:113
std::vector< SpellLogEffectDurabilityDamageParams > _durabilityDamageTargets[MAX_SPELL_EFFECTS]
Definition: Spell.h:834
Definition: Spell.h:134
std::vector< SpellLogEffectFeedPetParams > _feedPetTargets[MAX_SPELL_EFFECTS]
Definition: Spell.h:837
std::vector< SpellLogEffectFeedPetParams > FeedPetTargets
Definition: CombatLogPackets.h:125
Definition: Spell.h:165
Definition: SpellInfo.h:238
std::vector< SpellLogEffectPowerDrainParams > PowerDrainTargets
Definition: CombatLogPackets.h:120
std::vector< SpellLogEffectGenericVictimParams > _genericVictimTargets[MAX_SPELL_EFFECTS]
Definition: Spell.h:835
SpellEffectInfoVector const & GetEffects() const
Definition: Spell.h:623
std::vector< SpellLogEffectExtraAttacksParams > _extraAttacksTargets[MAX_SPELL_EFFECTS]
Definition: Spell.h:833
Definition: Spell.h:142
ObjectGuid const & GetGUID() const
Definition: Object.h:105
std::vector< SpellLogEffectTradeSkillItemParams > TradeSkillTargets
Definition: CombatLogPackets.h:124
void SendCombatLogMessage(WorldPackets::CombatLog::CombatLogServerPacket *combatLog) const
Definition: Unit.cpp:16597
ObjectGuid Caster
Definition: CombatLogPackets.h:132
std::vector< SpellLogEffect > Effects
Definition: CombatLogPackets.h:134
std::vector< SpellLogEffectGenericVictimParams > GenericVictimTargets
Definition: CombatLogPackets.h:123

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Spell::SendSpellGo ( )
3963 {
3964  // not send invisible spell casting
3965  if (!IsNeedSendToClient())
3966  return;
3967 
3968  TC_LOG_DEBUG("spells", "Sending SMSG_SPELL_GO id=%u", m_spellInfo->Id);
3969 
3970  uint32 castFlags = CAST_FLAG_UNKNOWN_9;
3971 
3972  // triggered spells with spell visual != 0
3974  castFlags |= CAST_FLAG_PENDING;
3975 
3976  if ((m_caster->GetTypeId() == TYPEID_PLAYER ||
3978  && std::find_if(m_powerCost.begin(), m_powerCost.end(), [](SpellInfo::CostData const& cost) { return cost.Power != POWER_HEALTH; }) != m_powerCost.end())
3979  castFlags |= CAST_FLAG_POWER_LEFT_SELF; // should only be sent to self, but the current messaging doesn't make that possible
3980 
3981  if ((m_caster->GetTypeId() == TYPEID_PLAYER)
3984  && std::find_if(m_powerCost.begin(), m_powerCost.end(), [](SpellInfo::CostData const& cost) { return cost.Power == POWER_RUNES; }) != m_powerCost.end()
3986  {
3987  castFlags |= CAST_FLAG_NO_GCD; // not needed, but Blizzard sends it
3988  castFlags |= CAST_FLAG_RUNE_LIST; // rune cooldowns list
3989  }
3990 
3992  castFlags |= CAST_FLAG_RUNE_LIST; // rune cooldowns list
3993 
3994  if (m_targets.HasTraj())
3995  castFlags |= CAST_FLAG_ADJUST_MISSILE;
3996 
3998  castFlags |= CAST_FLAG_NO_GCD;
3999 
4001  WorldPackets::Spells::SpellCastData& castData = packet.Cast;
4002 
4003  if (m_CastItem)
4004  castData.CasterGUID = m_CastItem->GetGUID();
4005  else
4006  castData.CasterGUID = m_caster->GetGUID();
4007 
4008  castData.CasterUnit = m_caster->GetGUID();
4009  castData.CastID = m_cast_count; // pending spell cast?
4010  castData.SpellID = m_spellInfo->Id;
4012  castData.CastFlags = castFlags;
4013  castData.CastFlagsEx = m_castFlagsEx;
4014  castData.CastTime = getMSTime();
4015 
4016  UpdateSpellCastDataTargets(castData);
4017 
4018  m_targets.Write(castData.Target);
4019 
4020  if (castFlags & CAST_FLAG_POWER_LEFT_SELF)
4021  {
4022  for (SpellInfo::CostData const& cost : m_powerCost)
4023  {
4025  powerData.Type = cost.Power;
4026  powerData.Cost = m_caster->GetPower(cost.Power);
4027  castData.RemainingPower.push_back(powerData);
4028  }
4029  }
4030 
4031  if (castFlags & CAST_FLAG_RUNE_LIST) // rune cooldowns list
4032  {
4033  castData.RemainingRunes = boost::in_place();
4034 
4035  //TODO: There is a crash caused by a spell with CAST_FLAG_RUNE_LIST casted by a creature
4036  //The creature is the mover of a player, so HandleCastSpellOpcode uses it as the caster
4037  if (Player* player = m_caster->ToPlayer())
4038  {
4039  castData.RemainingRunes->Start = m_runesState; // runes state before
4040  castData.RemainingRunes->Count = player->GetRunesState(); // runes state after
4041  for (uint8 i = 0; i < MAX_RUNES; ++i)
4042  {
4043  // float casts ensure the division is performed on floats as we need float result
4044  float baseCd = float(player->GetRuneBaseCooldown(i));
4045  castData.RemainingRunes->Cooldowns.push_back((baseCd - float(player->GetRuneCooldown(i))) / baseCd * 255); // rune cooldown passed
4046  }
4047  }
4048  else
4049  {
4050  castData.RemainingRunes->Start = 0;
4051  castData.RemainingRunes->Count = 0;
4052  for (uint8 i = 0; i < MAX_RUNES; ++i)
4053  castData.RemainingRunes->Cooldowns.push_back(0);
4054  }
4055  }
4056 
4057  if (castFlags & CAST_FLAG_ADJUST_MISSILE)
4058  {
4061  }
4062 
4063  m_caster->SendMessageToSet(packet.Write(), true);
4064 }
int32 Cost
Definition: SpellPackets.h:303
Definition: Spell.h:60
SpellInfo const *const m_spellInfo
Definition: Spell.h:547
Unit *const m_caster
Definition: Spell.h:647
uint32 Id
Definition: SpellInfo.h:329
uint32 CastTime
Definition: SpellPackets.h:348
Definition: SharedDefines.h:172
bool IsNeedSendToClient() const
Definition: Spell.cpp:6696
uint32 SpellXSpellVisualID
Definition: SpellPackets.h:345
Definition: Spell.h:70
void Write(WorldPackets::Spells::SpellTargetData &data)
Definition: Spell.cpp:158
SpellCastTargets m_targets
Definition: Spell.h:584
uint32 CastFlags
Definition: SpellPackets.h:346
WorldPacket const * Write() override
Definition: SpellPackets.cpp:406
std::vector< SpellPowerData > RemainingPower
Definition: SpellPackets.h:353
Definition: Spell.h:63
uint32 m_SpellVisual
Definition: Spell.h:582
SpellInfo const * m_triggeredByAuraSpell
Definition: Spell.h:826
#define MAX_RUNES
Definition: Player.h:451
uint32 getMSTime()
Definition: Timer.h:24
Definition: ObjectGuid.h:32
int32 SpellID
Definition: SpellPackets.h:344
Definition: Spell.h:69
bool IsAutoRepeatRangedSpell() const
Definition: SpellInfo.cpp:1535
Will ignore Spell and Category cooldowns.
Definition: Unit.h:463
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
Item * m_CastItem
Definition: Spell.h:548
Definition: SpellInfo.h:553
int32 GetPower(Powers power) const
Definition: Unit.cpp:11589
MissileTrajectoryResult MissileTrajectory
Definition: SpellPackets.h:355
Definition: SharedDefines.h:253
Player * ToPlayer()
Definition: Object.h:191
bool HasTraj() const
Definition: Spell.h:230
SpellTargetData Target
Definition: SpellPackets.h:352
TypeID GetTypeId() const
Definition: Object.h:113
Definition: SharedDefines.h:1156
uint8 CastID
Definition: SpellPackets.h:343
bool HasEffect(SpellEffectName effect) const
Definition: Spell.cpp:7410
Definition: SpellPackets.h:363
uint32 CastFlagsEx
Definition: SpellPackets.h:347
uint64 m_delayMoment
Definition: Spell.h:679
bool IsTriggered() const
Definition: Spell.h:595
uint32_t uint32
Definition: Define.h:150
SpellCastData Cast
Definition: SpellPackets.h:371
void UpdateSpellCastDataTargets(WorldPackets::Spells::SpellCastData &data)
Writes miss and hit targets for a SMSG_SPELL_GO packet.
Definition: Spell.cpp:4067
Definition: Spell.h:52
std::vector< SpellInfo::CostData > m_powerCost
Definition: Spell.h:659
bool IsPet() const
Definition: Unit.h:1403
ObjectGuid const & GetGUID() const
Definition: Object.h:105
Definition: ObjectGuid.h:33
int8 Type
Definition: SpellPackets.h:304
ObjectGuid CasterUnit
Definition: SpellPackets.h:342
uint8 m_runesState
Definition: Spell.h:665
Optional< RuneData > RemainingRunes
Definition: SpellPackets.h:354
uint8 getClass() const
Definition: Unit.h:1413
uint32 m_castFlagsEx
Definition: Spell.h:553
uint8_t uint8
Definition: Define.h:152
virtual void SendMessageToSet(WorldPacket const *data, bool self)
Definition: Object.cpp:2144
uint8 m_cast_count
Definition: Spell.h:552
TriggerCastFlags _triggeredCastFlags
Definition: Spell.h:821
uint32 RuneCostID
Definition: SpellInfo.h:378
uint32 StartRecoveryTime
Definition: SpellInfo.h:366
Definition: SpellPackets.h:339
Definition: SpellPackets.h:301
float Pitch
Definition: SpellPackets.h:317
ObjectGuid CasterGUID
Definition: SpellPackets.h:341
Definition: Spell.h:73
float GetPitch() const
Definition: Spell.h:232
uint32 TravelTime
Definition: SpellPackets.h:316
Definition: SharedDefines.h:267

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Spell::SendSpellStart ( )
Todo:
implement spell ammo packet data if (castFlags & CAST_FLAG_PROJECTILE) { castData.Ammo.DisplayID = 0; castData.Ammo.InventoryType = 0; }
Todo:
implement heal prediction packet data if (castFlags & CAST_FLAG_HEAL_PREDICTION) { castData.Predict.BeconGUID = ?? castData.Predict.Points = 0; castData.Predict.Type = 0; }
3859 {
3860  if (!IsNeedSendToClient())
3861  return;
3862 
3863  TC_LOG_DEBUG("spells", "Sending SMSG_SPELL_START id=%u", m_spellInfo->Id);
3864 
3865  uint32 castFlags = CAST_FLAG_HAS_TRAJECTORY;
3866  uint32 schoolImmunityMask = m_caster->GetSchoolImmunityMask();
3867  uint32 mechanicImmunityMask = m_caster->GetMechanicImmunityMask();
3868  if (schoolImmunityMask || mechanicImmunityMask)
3869  castFlags |= CAST_FLAG_IMMUNITY;
3870 
3872  castFlags |= CAST_FLAG_PENDING;
3873 
3874  if ((m_caster->GetTypeId() == TYPEID_PLAYER ||
3876  && std::find_if(m_powerCost.begin(), m_powerCost.end(), [](SpellInfo::CostData const& cost) { return cost.Power != POWER_HEALTH; }) != m_powerCost.end())
3877  castFlags |= CAST_FLAG_POWER_LEFT_SELF;
3878 
3879  if (m_spellInfo->RuneCostID &&
3880  std::find_if(m_powerCost.begin(), m_powerCost.end(), [](SpellInfo::CostData const& cost) { return cost.Power == POWER_RUNES; }) != m_powerCost.end())
3881  castFlags |= CAST_FLAG_NO_GCD; // not needed, but Blizzard sends it
3882 
3884  WorldPackets::Spells::SpellCastData& castData = packet.Cast;
3885 
3886  if (m_CastItem)
3887  castData.CasterGUID = m_CastItem->GetGUID();
3888  else
3889  castData.CasterGUID = m_caster->GetGUID();
3890 
3891  castData.CasterUnit = m_caster->GetGUID();
3892  castData.CastID = m_cast_count; // pending spell cast?
3893  castData.SpellID = m_spellInfo->Id;
3895  castData.CastFlags = castFlags;
3896  castData.CastFlagsEx = m_castFlagsEx;
3897  castData.CastTime = m_casttime;
3898 
3899  m_targets.Write(castData.Target);
3900 
3901  if (castFlags & CAST_FLAG_POWER_LEFT_SELF)
3902  {
3903  for (SpellInfo::CostData const& cost : m_powerCost)
3904  {
3906  powerData.Type = cost.Power;
3907  powerData.Cost = m_caster->GetPower(cost.Power);
3908  castData.RemainingPower.push_back(powerData);
3909  }
3910  }
3911 
3912  if (castFlags & CAST_FLAG_RUNE_LIST) // rune cooldowns list
3913  {
3914  castData.RemainingRunes = boost::in_place();
3915 
3916  //TODO: There is a crash caused by a spell with CAST_FLAG_RUNE_LIST casted by a creature
3917  //The creature is the mover of a player, so HandleCastSpellOpcode uses it as the caster
3918  if (Player* player = m_caster->ToPlayer())
3919  {
3920  castData.RemainingRunes->Start = m_runesState; // runes state before
3921  castData.RemainingRunes->Count = player->GetRunesState(); // runes state after
3922  for (uint8 i = 0; i < MAX_RUNES; ++i)
3923  {
3924  // float casts ensure the division is performed on floats as we need float result
3925  float baseCd = float(player->GetRuneBaseCooldown(i));
3926  castData.RemainingRunes->Cooldowns.push_back((baseCd - float(player->GetRuneCooldown(i))) / baseCd * 255); // rune cooldown passed
3927  }
3928  }
3929  else
3930  {
3931  castData.RemainingRunes->Start = 0;
3932  castData.RemainingRunes->Count = 0;
3933  for (uint8 i = 0; i < MAX_RUNES; ++i)
3934  castData.RemainingRunes->Cooldowns.push_back(0);
3935  }
3936  }
3937 
3945  if (castFlags & CAST_FLAG_IMMUNITY)
3946  {
3947  castData.Immunities.School = schoolImmunityMask;
3948  castData.Immunities.Value = mechanicImmunityMask;
3949  }
3950 
3959  m_caster->SendMessageToSet(packet.Write(), true);
3960 }
int32 Cost
Definition: SpellPackets.h:303
SpellInfo const *const m_spellInfo
Definition: Spell.h:547
Unit *const m_caster
Definition: Spell.h:647
uint32 Id
Definition: SpellInfo.h:329
uint32 CastTime
Definition: SpellPackets.h:348
int32 m_casttime
Definition: Spell.h:660
bool IsNeedSendToClient() const
Definition: Spell.cpp:6696
uint32 SpellXSpellVisualID
Definition: SpellPackets.h:345
Definition: Spell.h:70
void Write(WorldPackets::Spells::SpellTargetData &data)
Definition: Spell.cpp:158
SpellCastTargets m_targets
Definition: Spell.h:584
uint32 CastFlags
Definition: SpellPackets.h:346
std::vector< SpellPowerData > RemainingPower
Definition: SpellPackets.h:353
Definition: Spell.h:63
uint32 m_SpellVisual
Definition: Spell.h:582
SpellInfo const * m_triggeredByAuraSpell
Definition: Spell.h:826
#define MAX_RUNES
Definition: Player.h:451
SpellCastData Cast
Definition: SpellPackets.h:381
Definition: ObjectGuid.h:32
int32 SpellID
Definition: SpellPackets.h:344
bool IsAutoRepeatRangedSpell() const
Definition: SpellInfo.cpp:1535
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
Definition: Spell.h:53
Item * m_CastItem
Definition: Spell.h:548
Definition: SpellInfo.h:553
int32 GetPower(Powers power) const
Definition: Unit.cpp:11589
Definition: SharedDefines.h:253
Player * ToPlayer()
Definition: Object.h:191
CreatureImmunities Immunities
Definition: SpellPackets.h:359
SpellTargetData Target
Definition: SpellPackets.h:352
TypeID GetTypeId() const
Definition: Object.h:113
uint8 CastID
Definition: SpellPackets.h:343
uint32 Value
Definition: SpellPackets.h:329
Definition: Spell.h:78
uint32 CastFlagsEx
Definition: SpellPackets.h:347
uint32 GetSchoolImmunityMask() const
Definition: Unit.cpp:9319
bool IsTriggered() const
Definition: Spell.h:595
uint32_t uint32
Definition: Define.h:150
Definition: Spell.h:52
uint32 GetMechanicImmunityMask() const
Definition: Unit.cpp:9329
std::vector< SpellInfo::CostData > m_powerCost
Definition: Spell.h:659
WorldPacket const * Write() override
Definition: SpellPackets.cpp:399
bool IsPet() const
Definition: Unit.h:1403
ObjectGuid const & GetGUID() const
Definition: Object.h:105
Definition: ObjectGuid.h:33
int8 Type
Definition: SpellPackets.h:304
Definition: SpellPackets.h:374
ObjectGuid CasterUnit
Definition: SpellPackets.h:342
uint8 m_runesState
Definition: Spell.h:665
Optional< RuneData > RemainingRunes
Definition: SpellPackets.h:354
uint32 m_castFlagsEx
Definition: Spell.h:553
uint8_t uint8
Definition: Define.h:152
virtual void SendMessageToSet(WorldPacket const *data, bool self)
Definition: Object.cpp:2144
uint8 m_cast_count
Definition: Spell.h:552
uint32 RuneCostID
Definition: SpellInfo.h:378
Definition: SpellPackets.h:339
Definition: SpellPackets.h:301
ObjectGuid CasterGUID
Definition: SpellPackets.h:341
Definition: Spell.h:73
uint32 School
Definition: SpellPackets.h:328
Definition: SharedDefines.h:267

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Spell::SetAutoRepeat ( bool  rep)
inline
592 { m_autoRepeat = rep; }
bool m_autoRepeat
Definition: Spell.h:663
void Spell::SetDelayStart ( uint64  m_time)
inline
605 { m_delayStart = m_time; }
uint64 m_delayStart
Definition: Spell.h:678

+ Here is the caller graph for this function:

void Spell::SetExecutedCurrently ( bool  yes)
inline
603 {m_executedCurrently = yes;}
bool m_executedCurrently
Definition: Spell.h:684

+ Here is the caller graph for this function:

void Spell::SetReferencedFromCurrent ( bool  yes)
inline
bool m_referencedFromCurrentSpell
Definition: Spell.h:683

+ Here is the caller graph for this function:

void Spell::SetSpellValue ( SpellValueMod  mod,
int32  value 
)
6995 {
6996  if (mod < SPELLVALUE_BASE_POINT_END)
6997  {
6998  if (SpellEffectInfo const* effect = GetEffect(mod))
6999  m_spellValue->EffectBasePoints[mod] = effect->CalcBaseValue(value);
7000  return;
7001  }
7002 
7003  switch (mod)
7004  {
7005  case SPELLVALUE_RADIUS_MOD:
7006  m_spellValue->RadiusMod = (float)value / 10000;
7007  break;
7010  break;
7011  case SPELLVALUE_AURA_STACK:
7013  break;
7014  default:
7015  break;
7016  }
7017 }
Definition: Unit.h:161
Definition: Unit.h:163
uint32 MaxAffectedTargets
Definition: Spell.h:269
SpellEffectInfo const * GetEffect(uint32 index) const
Definition: Spell.h:624
SpellValue *const m_spellValue
Definition: Spell.h:649
Definition: Unit.h:162
uint8 AuraStackAmount
Definition: Spell.h:271
Definition: SpellInfo.h:238
uint8_t uint8
Definition: g3dmath.h:164
float RadiusMod
Definition: Spell.h:270
int32 EffectBasePoints[MAX_SPELL_EFFECTS]
Definition: Spell.h:268
Definition: Unit.h:164
const FieldDescriptor value
Definition: descriptor.h:1522
uint32_t uint32
Definition: g3dmath.h:168

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Spell::setState ( uint32  state)
inline
510 { m_spellState = state; }
uint32 m_spellState
Definition: Spell.h:818
void Spell::SummonGuardian ( uint32  i,
uint32  entry,
SummonPropertiesEntry const properties,
uint32  numSummons 
)
protected
5459 {
5460  Unit* caster = m_originalCaster;
5461  if (!caster)
5462  return;
5463 
5464  if (caster->IsTotem())
5465  caster = caster->ToTotem()->GetOwner();
5466 
5467  // in another case summon new
5468  uint8 level = caster->getLevel();
5469 
5470  // level of pet summoned using engineering item based at engineering skill level
5471  if (m_CastItem && caster->GetTypeId() == TYPEID_PLAYER)
5472  if (ItemTemplate const* proto = m_CastItem->GetTemplate())
5473  if (proto->GetRequiredSkill() == SKILL_ENGINEERING)
5474  if (uint16 skill202 = caster->ToPlayer()->GetSkillValue(SKILL_ENGINEERING))
5475  level = skill202 / 5;
5476 
5477  float radius = 5.0f;
5478  int32 duration = m_spellInfo->GetDuration();
5479 
5480  if (Player* modOwner = m_originalCaster->GetSpellModOwner())
5481  modOwner->ApplySpellMod(m_spellInfo->Id, SPELLMOD_DURATION, duration);
5482 
5483  //TempSummonType summonType = (duration == 0) ? TEMPSUMMON_DEAD_DESPAWN : TEMPSUMMON_TIMED_DESPAWN;
5484  Map* map = caster->GetMap();
5485 
5486  for (uint32 count = 0; count < numGuardians; ++count)
5487  {
5488  Position pos;
5489  if (count == 0)
5490  pos = *destTarget;
5491  else
5492  // randomize position for multiple summons
5493  pos = m_caster->GetRandomPoint(*destTarget, radius);
5494 
5495  TempSummon* summon = map->SummonCreature(entry, pos, properties, duration, caster, m_spellInfo->Id);
5496  if (!summon)
5497  return;
5498 
5499  if (summon->HasUnitTypeMask(UNIT_MASK_GUARDIAN))
5500  ((Guardian*)summon)->InitStatsForLevel(level);
5501 
5502  if (properties && properties->Category == SUMMON_CATEGORY_ALLY)
5503  summon->setFaction(caster->getFaction());
5504 
5506  ((Minion*)summon)->SetFollowAngle(m_caster->GetAngle(summon));
5507 
5508  if (summon->GetEntry() == 27893)
5509  {
5510  if (uint32 weapon = m_caster->GetUInt32Value(PLAYER_VISIBLE_ITEM + VISIBLE_ITEM_ENTRY_OFFSET + (EQUIPMENT_SLOT_MAINHAND * 2)))
5511  {
5512  summon->SetDisplayId(11686); // modelid2
5513  summon->SetVirtualItem(0, weapon);
5514  }
5515  else
5516  summon->SetDisplayId(1126); // modelid1
5517  }
5518 
5519  summon->AI()->EnterEvadeMode();
5520 
5521  ExecuteLogEffectSummonObject(i, summon);
5522  }
5523 }
Definition: TemporarySummon.h:83
SpellInfo const *const m_spellInfo
Definition: Spell.h:547
Unit *const m_caster
Definition: Spell.h:647
uint32 Id
Definition: SpellInfo.h:329
void SetVirtualItem(uint32 slot, uint32 itemId, uint16 appearanceModId=0)
Definition: Unit.cpp:16427
uint32 GetUInt32Value(uint16 index) const
Definition: Object.cpp:300
Definition: TemporarySummon.h:40
TempSummon * SummonCreature(uint32 entry, Position const &pos, SummonPropertiesEntry const *properties=NULL, uint32 duration=0, Unit *summoner=NULL, uint32 spellId=0, uint32 vehId=0)
Definition: Object.cpp:2219
Map * GetMap() const
Definition: Object.h:543
Definition: Unit.h:87
uint32 getFaction() const
Definition: Unit.h:1466
Definition: SharedDefines.h:3942
Definition: Unit.h:860
SpellCastTargets m_targets
Definition: Spell.h:584
Definition: SharedDefines.h:4385
virtual void EnterEvadeMode(EvadeReason why=EVADE_REASON_OTHER)
Definition: CreatureAI.cpp:168
Definition: UpdateFields.h:202
void ExecuteLogEffectSummonObject(uint8 effIndex, WorldObject *obj)
Definition: Spell.cpp:4214
WorldLocation * destTarget
Definition: Spell.h:693
Item * m_CastItem
Definition: Spell.h:548
Definition: Unit.h:859
Player * ToPlayer()
Definition: Object.h:191
uint8 getLevel() const
Definition: Unit.h:1408
int32 GetDuration() const
Definition: SpellInfo.cpp:2490
void setFaction(uint32 faction)
Definition: Unit.h:1467
TypeID GetTypeId() const
Definition: Object.h:113
Totem * ToTotem()
Definition: Unit.h:2203
Unit * GetOwner() const
Definition: TemporarySummon.h:72
Definition: TemporarySummon.h:66
Unit * m_originalCaster
Definition: Spell.h:653
void GetRandomPoint(Position const &srcPos, float distance, float &rand_x, float &rand_y, float &rand_z) const
Definition: Object.cpp:1799
bool HasDst() const
Definition: Spell.h:229
CreatureAI * AI() const
Definition: Creature.h:525
int32_t int32
Definition: Define.h:146
float GetAngle(Position const *pos) const
Definition: Position.cpp:63
uint32_t uint32
Definition: Define.h:150
uint16_t uint16
Definition: Define.h:151
Definition: Map.h:259
void SetDisplayId(uint32 modelId) override
Definition: Creature.cpp:2664
Definition: ObjectGuid.h:33
Definition: ItemTemplate.h:647
#define VISIBLE_ITEM_ENTRY_OFFSET
Player * GetSpellModOwner() const
Definition: Unit.cpp:12691
bool IsTotem() const
Definition: Unit.h:1405
uint32 HasUnitTypeMask(uint32 mask) const
Definition: Unit.h:1399
uint8_t uint8
Definition: Define.h:152
Definition: Position.h:27
uint32 GetEntry() const
Definition: Object.h:107
Definition: Unit.h:1305
ItemTemplate const * GetTemplate() const
Definition: Item.cpp:547

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Spell::TakeCastItem ( )
4339 {
4340  if (!m_CastItem)
4341  return;
4342 
4343  Player* player = m_caster->ToPlayer();
4344  if (!player)
4345  return;
4346 
4347  // not remove cast item at triggered spell (equipping, weapon damage, etc)
4349  return;
4350 
4351  ItemTemplate const* proto = m_CastItem->GetTemplate();
4352 
4353  if (!proto)
4354  {
4355  // This code is to avoid a crash
4356  // I'm not sure, if this is really an error, but I guess every item needs a prototype
4357  TC_LOG_ERROR("spells", "Cast item has no item prototype %s", m_CastItem->GetGUID().ToString().c_str());
4358  return;
4359  }
4360 
4361  bool expendable = false;
4362  bool withoutCharges = false;
4363 
4364  for (uint8 i = 0; i < proto->Effects.size() && i < 5; ++i)
4365  {
4366  // item has limited charges
4367  if (proto->Effects[i]->Charges)
4368  {
4369  if (proto->Effects[i]->Charges < 0)
4370  expendable = true;
4371 
4372  int32 charges = m_CastItem->GetSpellCharges(i);
4373 
4374  // item has charges left
4375  if (charges)
4376  {
4377  (charges > 0) ? --charges : ++charges; // abs(charges) less at 1 after use
4378  if (proto->GetMaxStackSize() == 1)
4379  m_CastItem->SetSpellCharges(i, charges);
4380  m_CastItem->SetState(ITEM_CHANGED, player);
4381  }
4382 
4383  // all charges used
4384  withoutCharges = (charges == 0);
4385  }
4386  }
4387 
4388  if (expendable && withoutCharges)
4389  {
4390  uint32 count = 1;
4391  m_caster->ToPlayer()->DestroyItemCount(m_CastItem, count, true);
4392 
4393  // prevent crash at access to deleted m_targets.GetItemTarget
4396 
4397  m_CastItem = NULL;
4399  m_castItemEntry = 0;
4400  }
4401 }
Unit *const m_caster
Definition: Spell.h:647
void SetState(ItemUpdateState state, Player *forplayer=NULL)
Definition: Item.cpp:686
int32 GetSpellCharges(uint8 index=0) const
Definition: Item.h:364
SpellCastTargets m_targets
Definition: Spell.h:584
Item * GetItemTarget() const
Definition: Spell.h:203
arena_t NULL
Definition: jemalloc_internal.h:624
uint32 m_castItemEntry
Definition: Spell.h:550
Item * m_CastItem
Definition: Spell.h:548
Player * ToPlayer()
Definition: Object.h:191
void SetItemTarget(Item *item)
Definition: Spell.cpp:299
std::vector< ItemEffectEntry const * > Effects
Definition: ItemTemplate.h:707
ObjectGuid m_castItemGUID
Definition: Spell.h:549
int32_t int32
Definition: Define.h:146
uint32_t uint32
Definition: Define.h:150
uint32 GetMaxStackSize() const
Definition: ItemTemplate.h:745
void SetSpellCharges(uint8 index, int32 value)
Definition: Item.h:365
void Clear()
Definition: ObjectGuid.h:215
ObjectGuid const & GetGUID() const
Definition: Object.h:105
Definition: Item.h:217
Will ignore power and reagent cost.
Definition: Unit.h:464
Definition: ItemTemplate.h:647
uint8_t uint8
Definition: Define.h:152
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
TriggerCastFlags _triggeredCastFlags
Definition: Spell.h:821
std::string ToString() const
Definition: ObjectGuid.cpp:99
ItemTemplate const * GetTemplate() const
Definition: Item.cpp:547

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Spell::TakePower ( )
4404 {
4406  return;
4407 
4408  //Don't take power if the spell is cast while .cheat power is enabled.
4409  if (m_caster->GetTypeId() == TYPEID_PLAYER)
4410  {
4411  if (m_caster->ToPlayer()->GetCommandStatus(CHEAT_POWER))
4412  return;
4413  }
4414 
4415  for (SpellInfo::CostData& cost : m_powerCost)
4416  {
4417  Powers powerType = Powers(cost.Power);
4418  bool hit = true;
4419  if (m_caster->GetTypeId() == TYPEID_PLAYER)
4420  {
4421  if (powerType == POWER_RAGE || powerType == POWER_ENERGY || powerType == POWER_RUNES)
4422  {
4423  ObjectGuid targetGUID = m_targets.GetUnitTargetGUID();
4424  if (!targetGUID.IsEmpty())
4425  {
4426  for (std::vector<TargetInfo>::iterator ihit = m_UniqueTargetInfo.begin(); ihit != m_UniqueTargetInfo.end(); ++ihit)
4427  {
4428  if (ihit->targetGUID == targetGUID)
4429  {
4430  if (ihit->missCondition != SPELL_MISS_NONE)
4431  {
4432  hit = false;
4433  //lower spell cost on fail (by talent aura)
4434  if (Player* modOwner = m_caster->ToPlayer()->GetSpellModOwner())
4435  modOwner->ApplySpellMod(m_spellInfo->Id, SPELLMOD_SPELL_COST_REFUND_ON_FAIL, cost.Amount);
4436  }
4437  break;
4438  }
4439  }
4440  }
4441  }
4442  }
4443 
4444  if (powerType == POWER_RUNES)
4445  {
4446  TakeRunePower(hit);
4447  continue;
4448  }
4449 
4450  if (!cost.Amount)
4451  continue;
4452 
4453  // health as power used
4454  if (powerType == POWER_HEALTH)
4455  {
4456  m_caster->ModifyHealth(-cost.Amount);
4457  continue;
4458  }
4459 
4460  if (powerType >= MAX_POWERS)
4461  {
4462  TC_LOG_ERROR("spells", "Spell::TakePower: Unknown power type '%d'", powerType);
4463  continue;
4464  }
4465 
4466  if (hit)
4467  m_caster->ModifyPower(powerType, -cost.Amount);
4468  else
4469  m_caster->ModifyPower(powerType, -irand(0, cost.Amount / 4));
4470  }
4471 }
ObjectGuid GetUnitTargetGUID() const
Definition: Spell.cpp:214
int32 ModifyPower(Powers power, int32 val)
Definition: Unit.cpp:10285
SpellInfo const *const m_spellInfo
Definition: Spell.h:547
Unit *const m_caster
Definition: Spell.h:647
uint32 Id
Definition: SpellInfo.h:329
SpellCastTargets m_targets
Definition: Spell.h:584
SpellInfo const * m_triggeredByAuraSpell
Definition: Spell.h:826
Definition: SharedDefines.h:249
int32 ModifyHealth(int32 val)
Definition: Unit.cpp:10216
Definition: SharedDefines.h:2021
Item * m_CastItem
Definition: Spell.h:548
Definition: SpellInfo.h:553
Definition: SharedDefines.h:253
Player * ToPlayer()
Definition: Object.h:191
int32 irand(int32 min, int32 max)
Definition: Random.cpp:39
TypeID GetTypeId() const
Definition: Object.h:113
std::vector< TargetInfo > m_UniqueTargetInfo
Definition: Spell.h:739
Powers
Definition: SharedDefines.h:246
std::vector< SpellInfo::CostData > m_powerCost
Definition: Spell.h:659
Definition: ObjectGuid.h:33
Definition: SharedDefines.h:251
void TakeRunePower(bool didHit)
Definition: Spell.cpp:4520
Definition: SharedDefines.h:265
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
Definition: ObjectGuid.h:189
bool IsEmpty() const
Definition: ObjectGuid.h:242
Definition: SharedDefines.h:267

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Spell::TakeReagents ( )
4610 {
4611  if (m_caster->GetTypeId() != TYPEID_PLAYER)
4612  return;
4613 
4614  ItemTemplate const* castItemTemplate = m_CastItem ? m_CastItem->GetTemplate() : NULL;
4615 
4616  // do not take reagents for these item casts
4617  if (castItemTemplate && castItemTemplate->GetFlags() & ITEM_FLAG_TRIGGERED_CAST)
4618  return;
4619 
4620  Player* p_caster = m_caster->ToPlayer();
4621  if (p_caster->CanNoReagentCast(m_spellInfo))
4622  return;
4623 
4624  for (uint32 x = 0; x < MAX_SPELL_REAGENTS; ++x)
4625  {
4626  if (m_spellInfo->Reagent[x] <= 0)
4627  continue;
4628 
4629  uint32 itemid = m_spellInfo->Reagent[x];
4630  uint32 itemcount = m_spellInfo->ReagentCount[x];
4631 
4632  // if CastItem is also spell reagent
4633  if (castItemTemplate && castItemTemplate->GetId() == itemid)
4634  {
4635  for (uint8 s = 0; s < castItemTemplate->Effects.size() && s < 5; ++s)
4636  {
4637  // CastItem will be used up and does not count as reagent
4638  int32 charges = m_CastItem->GetSpellCharges(s);
4639  if (castItemTemplate->Effects[s]->Charges < 0 && abs(charges) < 2)
4640  {
4641  ++itemcount;
4642  break;
4643  }
4644  }
4645 
4646  m_CastItem = NULL;
4648  m_castItemEntry = 0;
4649  }
4650 
4651  // if GetItemTarget is also spell reagent
4652  if (m_targets.GetItemTargetEntry() == itemid)
4654 
4655  p_caster->DestroyItemCount(itemid, itemcount, true);
4656  }
4657 }
G3D::Matrix abs(const G3D::Matrix &M)
Definition: Matrix.h:632
SpellInfo const *const m_spellInfo
Definition: Spell.h:547
Unit *const m_caster
Definition: Spell.h:647
uint32 ReagentCount[MAX_SPELL_REAGENTS]
Definition: SpellInfo.h:384
int32 GetSpellCharges(uint8 index=0) const
Definition: Item.h:364
SpellCastTargets m_targets
Definition: Spell.h:584
arena_t NULL
Definition: jemalloc_internal.h:624
uint32 m_castItemEntry
Definition: Spell.h:550
Item * m_CastItem
Definition: Spell.h:548
Player * ToPlayer()
Definition: Object.h:191
void SetItemTarget(Item *item)
Definition: Spell.cpp:299
TypeID GetTypeId() const
Definition: Object.h:113
std::vector< ItemEffectEntry const * > Effects
Definition: ItemTemplate.h:707
ObjectGuid m_castItemGUID
Definition: Spell.h:549
uint32 GetItemTargetEntry() const
Definition: Spell.h:204
int32_t int32
Definition: Define.h:146
uint32_t uint32
Definition: Define.h:150
int32 Reagent[MAX_SPELL_REAGENTS]
Definition: SpellInfo.h:383
void Clear()
Definition: ObjectGuid.h:215
Definition: ObjectGuid.h:33
Definition: ItemTemplate.h:647
uint8_t uint8
Definition: Define.h:152
uint32 GetFlags() const
Definition: ItemTemplate.h:656
uint32 GetId() const
Definition: ItemTemplate.h:652
#define MAX_SPELL_REAGENTS
Definition: DB2Structure.h:1285
Definition: ItemTemplate.h:201
G3D::int16 x
Definition: Vector2int16.h:37
ItemTemplate const * GetTemplate() const
Definition: Item.cpp:547

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Spell::TakeRunePower ( bool  didHit)
4521 {
4523  return;
4524 
4525  SpellRuneCostEntry const* runeCostData = sSpellRuneCostStore.LookupEntry(m_spellInfo->RuneCostID);
4526  if (!runeCostData || (runeCostData->NoRuneCost() && runeCostData->NoRunicPowerGain()))
4527  return;
4528 
4529  Player* player = m_caster->ToPlayer();
4530  m_runesState = player->GetRunesState(); // store previous state
4531 
4532  int32 runeCost[NUM_RUNE_TYPES]; // blood, frost, unholy, death
4533 
4534  for (uint32 i = 0; i < NUM_RUNE_TYPES; ++i)
4535  {
4536  runeCost[i] = runeCostData->RuneCost[i];
4537  if (Player* modOwner = m_caster->GetSpellModOwner())
4538  modOwner->ApplySpellMod(m_spellInfo->Id, SPELLMOD_COST, runeCost[i], this);
4539  }
4540 
4541  // Let's say we use a skill that requires a Frost rune. This is the order:
4542  // - Frost rune
4543  // - Death rune, originally a Frost rune
4544  // - Death rune, any kind
4545  for (uint32 i = 0; i < MAX_RUNES; ++i)
4546  {
4547  RuneType rune = player->GetCurrentRune(i);
4548  if (!player->GetRuneCooldown(i) && runeCost[rune] > 0)
4549  {
4550  player->SetRuneCooldown(i, didHit ? player->GetRuneBaseCooldown(i) : uint32(RUNE_MISS_COOLDOWN), true);
4551  player->SetLastUsedRune(rune);
4552  runeCost[rune]--;
4553  }
4554  }
4555 
4556  // Find a Death rune where the base rune matches the one we need
4557  runeCost[RUNE_DEATH] += runeCost[RUNE_BLOOD] + runeCost[RUNE_UNHOLY] + runeCost[RUNE_FROST];
4558  if (runeCost[RUNE_DEATH] > 0)
4559  {
4560  for (uint32 i = 0; i < MAX_RUNES; ++i)
4561  {
4562  RuneType rune = player->GetCurrentRune(i);
4563  RuneType baseRune = player->GetBaseRune(i);
4564  if (!player->GetRuneCooldown(i) && rune == RUNE_DEATH && runeCost[baseRune] > 0)
4565  {
4566  player->SetRuneCooldown(i, didHit ? player->GetRuneBaseCooldown(i) : uint32(RUNE_MISS_COOLDOWN), true);
4567  player->SetLastUsedRune(rune);
4568  runeCost[baseRune]--;
4569  runeCost[rune]--;
4570 
4571  // keep Death Rune type if missed
4572  if (didHit)
4573  player->RestoreBaseRune(i);
4574 
4575  if (runeCost[RUNE_DEATH] == 0)
4576  break;
4577  }
4578  }
4579  }
4580 
4581  // Grab any Death rune
4582  if (runeCost[RUNE_DEATH] > 0)
4583  {
4584  for (uint32 i = 0; i < MAX_RUNES; ++i)
4585  {
4586  RuneType rune = player->GetCurrentRune(i);
4587  if (!player->GetRuneCooldown(i) && rune == RUNE_DEATH)
4588  {
4589  player->SetRuneCooldown(i, didHit ? player->GetRuneBaseCooldown(i) : uint32(RUNE_MISS_COOLDOWN), true);
4590  player->SetLastUsedRune(rune);
4591  runeCost[rune]--;
4592 
4593  // keep Death Rune type if missed
4594  if (didHit)
4595  player->RestoreBaseRune(i);
4596 
4597  if (runeCost[RUNE_DEATH] == 0)
4598  break;
4599  }
4600  }
4601  }
4602 
4603  // you can gain some runic power when use runes
4604  if (didHit)
4605  if (int32 rp = int32(runeCostData->RunicPower * sWorld->getRate(RATE_POWER_RUNICPOWER_INCOME)))
4606  player->ModifyPower(POWER_RUNIC_POWER, int32(rp));
4607 }
SpellInfo const *const m_spellInfo
Definition: Spell.h:547
Unit *const m_caster
Definition: Spell.h:647
uint32 Id
Definition: SpellInfo.h:329
Definition: SharedDefines.h:172
uint32 RunicPower
Definition: DB2Structure.h:1298
#define MAX_RUNES
Definition: Player.h:451
Definition: SharedDefines.h:254
#define sWorld
Definition: World.h:887
DB2Storage< SpellRuneCostEntry > sSpellRuneCostStore("SpellRuneCost.db2", SpellRuneCostFormat, HOTFIX_SEL_SPELL_RUNE_COST)
Player * ToPlayer()
Definition: Object.h:191
TypeID GetTypeId() const
Definition: Object.h:113
Definition: Player.h:462
Definition: Player.h:464
Definition: Unit.h:100
int32_t int32
Definition: Define.h:146
uint32_t uint32
Definition: Define.h:150
Definition: Player.h:456
uint32 RuneCost[4]
Definition: DB2Structure.h:1297
bool NoRuneCost() const
Definition: DB2Structure.h:1300
Definition: World.h:387
Definition: ObjectGuid.h:33
Player * GetSpellModOwner() const
Definition: Unit.cpp:12691
Definition: Player.h:465
uint8 m_runesState
Definition: Spell.h:665
int32_t int32
Definition: g3dmath.h:167
uint8 getClass() const
Definition: Unit.h:1413
Definition: Player.h:463
uint32_t uint32
Definition: g3dmath.h:168
Definition: Player.h:461
RuneType
Definition: Player.h:459
uint32 RuneCostID
Definition: SpellInfo.h:378
bool NoRunicPowerGain() const
Definition: DB2Structure.h:1301
Definition: DB2Structure.h:1294

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Spell::TriggerGlobalCooldown ( )
protected
7361 {
7363  if (!gcd)
7364  return;
7365 
7366  // Only players or controlled units have global cooldown
7368  return;
7369 
7370  if (m_caster->GetTypeId() == TYPEID_PLAYER)
7371  if (m_caster->ToPlayer()->GetCommandStatus(CHEAT_COOLDOWN))
7372  return;
7373 
7374  // Global cooldown can't leave range 1..1.5 secs
7375  // There are some spells (mostly not cast directly by player) that have < 1 sec and > 1.5 sec global cooldowns
7376  // but as tests show are not affected by any spell mods.
7378  {
7379  // gcd modifier auras are applied only to own spells and only players have such mods
7380  if (m_caster->GetTypeId() == TYPEID_PLAYER)
7381  m_caster->ToPlayer()->ApplySpellMod(m_spellInfo->Id, SPELLMOD_GLOBAL_COOLDOWN, gcd, this);
7382 
7383  // Apply haste rating
7384  gcd = int32(float(gcd) * m_caster->GetFloatValue(UNIT_MOD_CAST_SPEED));
7385  if (gcd < MIN_GCD)
7386  gcd = MIN_GCD;
7387  else if (gcd > MAX_GCD)
7388  gcd = MAX_GCD;
7389  }
7390 
7392 }
SpellInfo const *const m_spellInfo
Definition: Spell.h:547
Unit *const m_caster
Definition: Spell.h:647
uint32 Id
Definition: SpellInfo.h:329
Definition: UpdateFields.h:129
CharmInfo * GetCharmInfo()
Definition: Unit.h:1748
Player * ToPlayer()
Definition: Object.h:191
Definition: Unit.h:107
Definition: Spell.cpp:7348
TypeID GetTypeId() const
Definition: Object.h:113
SpellHistory * GetSpellHistory()
Definition: Unit.h:1926
float GetFloatValue(uint16 index) const
Definition: Object.cpp:312
int32_t int32
Definition: Define.h:146
Definition: Spell.cpp:7347
void AddGlobalCooldown(SpellInfo const *spellInfo, uint32 duration)
Definition: SpellHistory.cpp:827
Definition: ObjectGuid.h:33
int32_t int32
Definition: g3dmath.h:167
uint32 StartRecoveryTime
Definition: SpellInfo.h:366

+ Here is the caller graph for this function:

void Spell::update ( uint32  difftime)
3541 {
3542  // update pointers based at it's GUIDs
3543  if (!UpdatePointers())
3544  {
3545  // cancel the spell if UpdatePointers() returned false, something wrong happened there
3546  cancel();
3547  return;
3548  }
3549 
3551  {
3552  TC_LOG_DEBUG("spells", "Spell %u is cancelled due to removal of target.", m_spellInfo->Id);
3553  cancel();
3554  return;
3555  }
3556 
3557  // check if the player caster has moved before the spell finished
3558  // with the exception of spells affected with SPELL_AURA_CAST_WHILE_WALKING effect
3559  SpellEffectInfo const* effect = GetEffect(EFFECT_0);
3560  if ((m_caster->GetTypeId() == TYPEID_PLAYER && m_timer != 0) &&
3564  {
3565  // don't cancel for melee, autorepeat, triggered and instant spells
3566  if (!IsNextMeleeSwingSpell() && !IsAutoRepeat() && !IsTriggered())
3567  cancel();
3568  }
3569 
3570  switch (m_spellState)
3571  {
3572  case SPELL_STATE_PREPARING:
3573  {
3574  if (m_timer > 0)
3575  {
3576  if (difftime >= (uint32)m_timer)
3577  m_timer = 0;
3578  else
3579  m_timer -= difftime;
3580  }
3581 
3582  if (m_timer == 0 && !IsNextMeleeSwingSpell() && !IsAutoRepeat())
3583  // don't CheckCast for instant spells - done in spell::prepare, skip duplicate checks, needed for range checks for example
3584  cast(!m_casttime);
3585  break;
3586  }
3587  case SPELL_STATE_CASTING:
3588  {
3589  if (m_timer)
3590  {
3591  // check if there are alive targets left
3593  {
3594  TC_LOG_DEBUG("spells", "Channeled spell %d is removed due to lack of targets", m_spellInfo->Id);
3595  SendChannelUpdate(0);
3596  finish();
3597  }
3598 
3599  if (m_timer > 0)
3600  {
3601  if (difftime >= (uint32)m_timer)
3602  m_timer = 0;
3603  else
3604  m_timer -= difftime;
3605  }
3606  }
3607 
3608  if (m_timer == 0)
3609  {
3610  SendChannelUpdate(0);
3611  finish();
3612  }
3613  break;
3614  }
3615  default:
3616  break;
3617  }
3618 }
ObjectGuid GetUnitTargetGUID() const
Definition: Spell.cpp:214
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
Unit * GetUnitTarget() const
Definition: Spell.cpp:222
bool HasUnitMovementFlag(uint32 f) const
Definition: Unit.h:2109
int32 m_casttime
Definition: Spell.h:660
Definition: SharedDefines.h:28
SpellCastTargets m_targets
Definition: Spell.h:584
bool IsAutoRepeat() const
Definition: Spell.h:591
SpellEffectInfo const * GetEffect(uint32 index) const
Definition: Spell.h:624
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
bool HasAuraTypeWithAffectMask(AuraType auratype, SpellInfo const *affectedSpell) const
Definition: Unit.cpp:4270
int32 m_timer
Definition: Spell.h:819
bool IsNextMeleeSwingSpell() const
Definition: Spell.cpp:6685
bool isMoving() const
Definition: Unit.h:2186
Definition: Unit.h:37
TypeID GetTypeId() const
Definition: Object.h:113
void finish(bool ok=true)
Definition: Spell.cpp:3620
bool IsTriggered() const
Definition: Spell.h:595
Definition: SpellInfo.h:238
void SendChannelUpdate(uint32 time)
Definition: Spell.cpp:4266
bool UpdateChanneledTargetList()
Definition: Spell.cpp:2803
uint32_t uint32
Definition: Define.h:150
Definition: Spell.h:278
Definition: Spell.h:277
Definition: SpellAuraDefines.h:390
Definition: ObjectGuid.h:33
void cancel()
Definition: Spell.cpp:3061
Definition: SharedDefines.h:1094
uint32 Effect
Definition: SpellInfo.h:243
uint32 InterruptFlags
Definition: SpellInfo.h:367
void cast(bool skipCheck=false)
Definition: Spell.cpp:3120
bool IsEmpty() const
Definition: ObjectGuid.h:242
Definition: Unit.h:788
bool UpdatePointers()
Definition: Spell.cpp:6508

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool Spell::UpdateChanneledTargetList ( )
protected
2804 {
2805  // Not need check return true
2806  if (m_channelTargetEffectMask == 0)
2807  return true;
2808 
2809  uint32 channelTargetEffectMask = m_channelTargetEffectMask;
2810  uint32 channelAuraMask = 0;
2811  for (SpellEffectInfo const* effect : GetEffects())
2812  if (effect && effect->Effect == SPELL_EFFECT_APPLY_AURA)
2813  channelAuraMask |= 1 << effect->EffectIndex;
2814 
2815  channelAuraMask &= channelTargetEffectMask;
2816 
2817  float range = 0;
2818  if (channelAuraMask)
2819  {
2821  if (Player* modOwner = m_caster->GetSpellModOwner())
2822  modOwner->ApplySpellMod(m_spellInfo->Id, SPELLMOD_RANGE, range, this);
2823  }
2824 
2825  for (std::vector<TargetInfo>::iterator ihit = m_UniqueTargetInfo.begin(); ihit != m_UniqueTargetInfo.end(); ++ihit)
2826  {
2827  if (ihit->missCondition == SPELL_MISS_NONE && (channelTargetEffectMask & ihit->effectMask))
2828  {
2829  Unit* unit = m_caster->GetGUID() == ihit->targetGUID ? m_caster : ObjectAccessor::GetUnit(*m_caster, ihit->targetGUID);
2830 
2831  if (!unit)
2832  continue;
2833 
2834  if (IsValidDeadOrAliveTarget(unit))
2835  {
2836  if (channelAuraMask & ihit->effectMask)
2837  {
2839  {
2840  if (m_caster != unit && !m_caster->IsWithinDistInMap(unit, range))
2841  {
2842  ihit->effectMask &= ~aurApp->GetEffectMask();
2843  unit->RemoveAura(aurApp);
2844  continue;
2845  }
2846  }
2847  else // aura is dispelled
2848  continue;
2849  }
2850 
2851  channelTargetEffectMask &= ~ihit->effectMask; // remove from need alive mask effect that have alive target
2852  }
2853  }
2854  }
2855 
2856  // is all effects from m_needAliveTargetMask have alive targets
2857  return channelTargetEffectMask == 0;
2858 }
SpellInfo const *const m_spellInfo
Definition: Spell.h:547
Unit *const m_caster
Definition: Spell.h:647
uint32 Id
Definition: SpellInfo.h:329
uint32 m_channelTargetEffectMask
Definition: Spell.h:740
TC_GAME_API Unit * GetUnit(WorldObject const &, ObjectGuid const &guid)
Definition: ObjectAccessor.cpp:163
Definition: Unit.h:91
float GetMaxRange(bool positive=false, Unit *caster=NULL, Spell *spell=NULL) const
Definition: SpellInfo.cpp:2475
Definition: SpellAuras.h:50
Definition: SharedDefines.h:2021
Definition: SharedDefines.h:1016
void RemoveAura(AuraApplicationMap::iterator &i, AuraRemoveMode mode=AURA_REMOVE_BY_DEFAULT)
Definition: Unit.cpp:3442
bool IsWithinDistInMap(WorldObject const *obj, float dist2compare, bool is3D=true) const
Definition: Object.cpp:1663
std::vector< TargetInfo > m_UniqueTargetInfo
Definition: Spell.h:739
bool IsPositive() const
Definition: SpellInfo.cpp:1495
AuraApplication * GetAuraApplication(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, ObjectGuid itemCasterGUID=ObjectGuid::Empty, uint32 reqEffMask=0, AuraApplication *except=NULL) const
Definition: Unit.cpp:4132
Definition: SpellInfo.h:238
uint32_t uint32
Definition: Define.h:150
SpellEffectInfoVector const & GetEffects() const
Definition: Spell.h:623
ObjectGuid m_originalCasterGUID
Definition: Spell.h:651
ObjectGuid const & GetGUID() const
Definition: Object.h:105
Player * GetSpellModOwner() const
Definition: Unit.cpp:12691
bool IsValidDeadOrAliveTarget(Unit const *target) const
Definition: Spell.cpp:6840
Definition: Unit.h:1305

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool Spell::UpdatePointers ( )
6509 {
6512  else
6513  {
6517  }
6518 
6520  {
6521  m_CastItem = m_caster->ToPlayer()->GetItemByGuid(m_castItemGUID);
6522  m_castItemLevel = -1;
6523  // cast item not found, somehow the item is no longer where we expected
6524  if (!m_CastItem)
6525  return false;
6526 
6527  // check if the item is really the same, in case it has been wrapped for example
6529  return false;
6530 
6532  }
6533 
6535 
6536  // further actions done only for dest targets
6537  if (!m_targets.HasDst())
6538  return true;
6539 
6540  // cache last transport
6541  WorldObject* transport = NULL;
6542 
6543  // update effect destinations (in case of moved transport dest target)
6544  for (SpellEffectInfo const* effect : GetEffects())
6545  {
6546  if (!effect)
6547  continue;
6548 
6549  SpellDestination& dest = m_destTargets[effect->EffectIndex];
6550  if (!dest._transportGUID)
6551  continue;
6552 
6553  if (!transport || transport->GetGUID() != dest._transportGUID)
6555 
6556  if (transport)
6557  {
6558  dest._position.Relocate(transport);
6560  }
6561  }
6562 
6563  return true;
6564 }
Unit *const m_caster
Definition: Spell.h:647
Position _transportOffset
Definition: Spell.h:130
TC_GAME_API Unit * GetUnit(WorldObject const &, ObjectGuid const &guid)
Definition: ObjectAccessor.cpp:163
void RelocateOffset(Position const &offset)
Definition: Position.cpp:32
SpellCastTargets m_targets
Definition: Spell.h:584
WorldLocation _position
Definition: Spell.h:128
arena_t NULL
Definition: jemalloc_internal.h:624
uint32 m_castItemEntry
Definition: Spell.h:550
Definition: Object.h:423
Item * m_CastItem
Definition: Spell.h:548
TC_GAME_API WorldObject * GetWorldObject(WorldObject const &, ObjectGuid const &)
Definition: ObjectAccessor.cpp:79
Player * ToPlayer()
Definition: Object.h:191
TypeID GetTypeId() const
Definition: Object.h:113
Definition: Spell.h:118
void Relocate(float x, float y)
Definition: Position.h:67
ObjectGuid _transportGUID
Definition: Spell.h:129
Unit * m_originalCaster
Definition: Spell.h:653
ObjectGuid m_castItemGUID
Definition: Spell.h:549
bool HasDst() const
Definition: Spell.h:229
Definition: SpellInfo.h:238
uint32 GetItemLevel(Player const *owner) const
Definition: Item.cpp:1871
SpellEffectInfoVector const & GetEffects() const
Definition: Spell.h:623
void Update(Unit *caster)
Definition: Spell.cpp:424
ObjectGuid m_originalCasterGUID
Definition: Spell.h:651
ObjectGuid const & GetGUID() const
Definition: Object.h:105
Definition: ObjectGuid.h:33
int32_t int32
Definition: g3dmath.h:167
uint32 GetEntry() const
Definition: Object.h:107
int32 m_castItemLevel
Definition: Spell.h:551
bool IsInWorld() const
Definition: Object.h:100
bool IsEmpty() const
Definition: ObjectGuid.h:242
SpellDestination m_destTargets[MAX_SPELL_EFFECTS]
Definition: Spell.h:758

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Spell::UpdateSpellCastDataTargets ( WorldPackets::Spells::SpellCastData data)
protected

Writes miss and hit targets for a SMSG_SPELL_GO packet.

4068 {
4069  // This function also fill data for channeled spells:
4070  // m_needAliveTargetMask req for stop channeling if one target die
4071  for (TargetInfo& targetInfo : m_UniqueTargetInfo)
4072  {
4073  if (targetInfo.effectMask == 0) // No effect apply - all immune add state
4074  // possibly SPELL_MISS_IMMUNE2 for this??
4075  targetInfo.missCondition = SPELL_MISS_IMMUNE2;
4076 
4077  if (targetInfo.missCondition == SPELL_MISS_NONE) // hits
4078  {
4079  data.HitTargets.push_back(targetInfo.targetGUID);
4080 
4081  m_channelTargetEffectMask |= targetInfo.effectMask;
4082  }
4083  else // misses
4084  {
4085  data.MissTargets.push_back(targetInfo.targetGUID);
4086 
4088  missStatus.Reason = targetInfo.missCondition;
4089  if (targetInfo.missCondition == SPELL_MISS_REFLECT)
4090  missStatus.ReflectStatus = targetInfo.reflectResult;
4091 
4092  data.MissStatus.push_back(missStatus);
4093  }
4094  }
4095 
4096  for (GOTargetInfo const& targetInfo : m_UniqueGOTargetInfo)
4097  data.HitTargets.push_back(targetInfo.targetGUID); // Always hits
4098 
4099  // Reset m_needAliveTargetMask for non channeled spell
4100  if (!m_spellInfo->IsChanneled())
4102 }
SpellInfo const *const m_spellInfo
Definition: Spell.h:547
Definition: SharedDefines.h:2029
bool IsChanneled() const
Definition: SpellInfo.cpp:1514
uint32 m_channelTargetEffectMask
Definition: Spell.h:740
std::vector< SpellMissStatus > MissStatus
Definition: SpellPackets.h:351
std::vector< ObjectGuid > HitTargets
Definition: SpellPackets.h:349
uint8 ReflectStatus
Definition: SpellPackets.h:298
uint8 Reason
Definition: SpellPackets.h:297
Definition: SharedDefines.h:2021
std::vector< TargetInfo > m_UniqueTargetInfo
Definition: Spell.h:739
Definition: SharedDefines.h:2032
std::vector< GOTargetInfo > m_UniqueGOTargetInfo
Definition: Spell.h:749
Definition: SpellPackets.h:295
std::vector< ObjectGuid > MissTargets
Definition: SpellPackets.h:350

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Friends And Related Function Documentation

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

Member Data Documentation

std::vector<SpellLogEffectDurabilityDamageParams> Spell::_durabilityDamageTargets[MAX_SPELL_EFFECTS]
protected
SpellEffectInfoVector Spell::_effects
protected
std::vector<SpellLogEffectExtraAttacksParams> Spell::_extraAttacksTargets[MAX_SPELL_EFFECTS]
protected
std::vector<SpellLogEffectFeedPetParams> Spell::_feedPetTargets[MAX_SPELL_EFFECTS]
protected
std::vector<SpellLogEffectGenericVictimParams> Spell::_genericVictimTargets[MAX_SPELL_EFFECTS]
protected
std::vector<SpellLogEffectPowerDrainParams> Spell::_powerDrainTargets[MAX_SPELL_EFFECTS]
protected
std::vector<SpellLogEffectTradeSkillItemParams> Spell::_tradeSkillTargets[MAX_SPELL_EFFECTS]
protected
TriggerCastFlags Spell::_triggeredCastFlags
protected
uint32 Spell::AbilityId
int32 Spell::damage
protected
uint32 Spell::Data[2]
WorldLocation* Spell::destTarget
protected
SpellEffectHandleMode Spell::effectHandleMode
protected
SpellEffectInfo const* Spell::effectInfo
protected
GameObject* Spell::focusObject
protected
GameObject* Spell::gameObjTarget
protected
struct { ... } Spell::GarrFollower
uint32 Spell::GarrMissionId
uint32 Spell::GlyphSlot
uint32 Spell::Id
uint32 Spell::ItemId
Item* Spell::itemTarget
protected
UsedSpellMods Spell::m_appliedMods
uint8 Spell::m_applyMultiplierMask
protected
WeaponAttackType Spell::m_attackType
protected
uint32 Spell::m_auraScaleMask
protected
bool Spell::m_autoRepeat
protected
bool Spell::m_canReflect
protected
uint8 Spell::m_cast_count
Unit* const Spell::m_caster
protected
uint32 Spell::m_castFlagsEx
Item* Spell::m_CastItem
uint32 Spell::m_castItemEntry
ObjectGuid Spell::m_castItemGUID
int32 Spell::m_castItemLevel
int32 Spell::m_casttime
protected
int32 Spell::m_channeledDuration
protected
uint32 Spell::m_channelTargetEffectMask
protected
int8 Spell::m_comboPointGain
SpellCustomErrors Spell::m_customError
int32 Spell::m_damage
protected
float Spell::m_damageMultipliers[3]
protected
uint8 Spell::m_delayAtDamageCount
protected
uint64 Spell::m_delayMoment
protected
uint64 Spell::m_delayStart
protected
SpellDestination Spell::m_destTargets[MAX_SPELL_EFFECTS]
protected
DiminishingGroup Spell::m_diminishGroup
protected
DiminishingLevels Spell::m_diminishLevel
protected
bool Spell::m_executedCurrently
protected
int32 Spell::m_healing
protected
HitTriggerSpellList Spell::m_hitTriggerSpells
protected
bool Spell::m_immediateHandled
protected
bool Spell::m_isDelayedInstantCast
protected
std::list<SpellScript*> Spell::m_loadedScripts
protected
union { ... } Spell::m_misc
bool Spell::m_needComboPoints
protected
Unit* Spell::m_originalCaster
protected
ObjectGuid Spell::m_originalCasterGUID
protected
std::vector<SpellInfo::CostData> Spell::m_powerCost
protected
uint32 Spell::m_preCastSpell
PathGenerator Spell::m_preGeneratedPath
protected
uint32 Spell::m_procAttacker
protected
uint32 Spell::m_procEx
protected
uint32 Spell::m_procVictim
protected
bool Spell::m_referencedFromCurrentSpell
protected
uint8 Spell::m_runesState
protected
Spell** Spell::m_selfContainer
bool Spell::m_skipCheck
protected
Aura* Spell::m_spellAura
protected
SpellInfo const* const Spell::m_spellInfo
SpellSchoolMask Spell::m_spellSchoolMask
protected
uint32 Spell::m_spellState
protected
SpellValue* const Spell::m_spellValue
protected
uint32 Spell::m_SpellVisual
SpellCastTargets Spell::m_targets
int32 Spell::m_timer
protected
SpellInfo const* Spell::m_triggeredByAuraSpell
protected
std::vector<GOTargetInfo> Spell::m_UniqueGOTargetInfo
protected
std::vector<ItemTargetInfo> Spell::m_UniqueItemInfo
protected
std::vector<TargetInfo> Spell::m_UniqueTargetInfo
protected
struct { ... } Spell::Raw
uint32 Spell::TalentId
Unit* Spell::unitTarget
protected
float Spell::variance
protected

The documentation for this class was generated from the following files: