TrinityCore
Aura Class Referenceabstract

#include <SpellAuras.h>

Public Types

typedef std::unordered_map< ObjectGuid, AuraApplication * > ApplicationMap
 

Public Member Functions

 Aura (AuraCreateInfo const &createInfo)
 
void _InitEffects (uint32 effMask, Unit *caster, int32 const *baseAmount)
 
void SaveCasterInfo (Unit *caster)
 
virtual ~Aura ()
 
SpellInfo const * GetSpellInfo () const
 
uint32 GetId () const
 
Difficulty GetCastDifficulty () const
 
ObjectGuid GetCastId () const
 
ObjectGuid GetCasterGUID () const
 
ObjectGuid GetCastItemGUID () const
 
uint32 GetCastItemId () const
 
int32 GetCastItemLevel () const
 
SpellCastVisual GetSpellVisual () const
 
UnitGetCaster () const
 
WorldObjectGetWorldObjectCaster () const
 
WorldObjectGetOwner () const
 
UnitGetUnitOwner () const
 
DynamicObjectGetDynobjOwner () const
 
AuraObjectType GetType () const
 
virtual void _ApplyForTarget (Unit *target, Unit *caster, AuraApplication *auraApp)
 
virtual void _UnapplyForTarget (Unit *target, Unit *caster, AuraApplication *auraApp)
 
void _Remove (AuraRemoveMode removeMode)
 
virtual void Remove (AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)=0
 
virtual void FillTargetMap (std::unordered_map< Unit *, uint32 > &targets, Unit *caster)=0
 
void UpdateTargetMap (Unit *caster, bool apply=true)
 
void _RegisterForTargets ()
 
void ApplyForTargets ()
 
void _ApplyEffectForTargets (uint8 effIndex)
 
void UpdateOwner (uint32 diff, WorldObject *owner)
 
void Update (uint32 diff, Unit *caster)
 
time_t GetApplyTime () const
 
int32 GetMaxDuration () const
 
void SetMaxDuration (int32 duration)
 
int32 CalcMaxDuration () const
 
int32 CalcMaxDuration (Unit *caster) const
 
int32 GetDuration () const
 
void SetDuration (int32 duration, bool withMods=false)
 
void RefreshDuration (bool withMods=false)
 
void RefreshTimers (bool resetPeriodicTimer)
 
bool IsExpired () const
 
bool IsPermanent () const
 
uint8 GetCharges () const
 
void SetCharges (uint8 charges)
 
uint8 CalcMaxCharges (Unit *caster) const
 
uint8 CalcMaxCharges () const
 
bool ModCharges (int32 num, AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
 
bool DropCharge (AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
 
void ModChargesDelayed (int32 num, AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
 
void DropChargeDelayed (uint32 delay, AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
 
uint8 GetStackAmount () const
 
void SetStackAmount (uint8 num)
 
bool ModStackAmount (int32 num, AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT, bool resetPeriodicTimer=true)
 
uint32 CalcMaxStackAmount () const
 
bool IsUsingStacks () const
 
uint8 GetCasterLevel () const
 
bool HasMoreThanOneEffectForType (AuraType auraType) const
 
bool IsArea () const
 
bool IsPassive () const
 
bool IsDeathPersistent () const
 
bool IsRemovedOnShapeLost (Unit *target) const
 
bool CanBeSaved () const
 
bool IsRemoved () const
 
bool IsSingleTarget () const
 
bool IsSingleTargetWith (Aura const *aura) const
 
void SetIsSingleTarget (bool val)
 
void UnregisterSingleTarget ()
 
int32 CalcDispelChance (Unit const *auraTarget, bool offensive) const
 
AuraKey GenerateKey (uint32 &recalculateMask) const
 Fills a helper structure containing aura primary key for character_aura, character_aura_effect, pet_aura, pet_aura_effect tables. More...
 
void SetLoadedState (int32 maxDuration, int32 duration, int32 charges, uint8 stackAmount, uint32 recalculateMask, int32 *amount)
 
bool HasEffect (uint8 effIndex) const
 
bool HasEffectType (AuraType type) const
 
AuraEffectGetEffect (uint32 index) const
 
uint32 GetEffectMask () const
 
void RecalculateAmountOfEffects ()
 
void HandleAllEffects (AuraApplication *aurApp, uint8 mode, bool apply)
 
ApplicationMap const & GetApplicationMap ()
 
void GetApplicationVector (std::vector< AuraApplication * > &applications) const
 
AuraApplication const * GetApplicationOfTarget (ObjectGuid guid) const
 
AuraApplicationGetApplicationOfTarget (ObjectGuid guid)
 
bool IsAppliedOnTarget (ObjectGuid guid) const
 
void SetNeedClientUpdateForTargets () const
 
void HandleAuraSpecificMods (AuraApplication const *aurApp, Unit *caster, bool apply, bool onReapply)
 
bool CanBeAppliedOn (Unit *target)
 
bool CheckAreaTarget (Unit *target)
 
bool CanStackWith (Aura const *existingAura) const
 
bool IsProcOnCooldown (TimePoint now) const
 
void AddProcCooldown (SpellProcEntry const *procEntry, TimePoint now)
 
void ResetProcCooldown ()
 
bool IsUsingCharges () const
 
void SetUsingCharges (bool val)
 
void PrepareProcToTrigger (AuraApplication *aurApp, ProcEventInfo &eventInfo, TimePoint now)
 
void PrepareProcChargeDrop (SpellProcEntry const *procEntry, ProcEventInfo const &eventInfo)
 
void ConsumeProcCharges (SpellProcEntry const *procEntry)
 
uint32 GetProcEffectMask (AuraApplication *aurApp, ProcEventInfo &eventInfo, TimePoint now) const
 
float CalcProcChance (SpellProcEntry const &procEntry, ProcEventInfo &eventInfo) const
 
void TriggerProcOnEvent (uint32 procEffectMask, AuraApplication *aurApp, ProcEventInfo &eventInfo)
 
float CalcPPMProcChance (Unit *actor) const
 
void SetLastProcAttemptTime (TimePoint lastProcAttemptTime)
 
void SetLastProcSuccessTime (TimePoint lastProcSuccessTime)
 
void LoadScripts ()
 
bool CallScriptCheckAreaTargetHandlers (Unit *target)
 
void CallScriptDispel (DispelInfo *dispelInfo)
 
void CallScriptAfterDispel (DispelInfo *dispelInfo)
 
bool CallScriptEffectApplyHandlers (AuraEffect const *aurEff, AuraApplication const *aurApp, AuraEffectHandleModes mode)
 
bool CallScriptEffectRemoveHandlers (AuraEffect const *aurEff, AuraApplication const *aurApp, AuraEffectHandleModes mode)
 
void CallScriptAfterEffectApplyHandlers (AuraEffect const *aurEff, AuraApplication const *aurApp, AuraEffectHandleModes mode)
 
void CallScriptAfterEffectRemoveHandlers (AuraEffect const *aurEff, AuraApplication const *aurApp, AuraEffectHandleModes mode)
 
bool CallScriptEffectPeriodicHandlers (AuraEffect const *aurEff, AuraApplication const *aurApp)
 
void CallScriptEffectUpdatePeriodicHandlers (AuraEffect *aurEff)
 
void CallScriptEffectCalcAmountHandlers (AuraEffect const *aurEff, int32 &amount, bool &canBeRecalculated)
 
void CallScriptEffectCalcPeriodicHandlers (AuraEffect const *aurEff, bool &isPeriodic, int32 &amplitude)
 
void CallScriptEffectCalcSpellModHandlers (AuraEffect const *aurEff, SpellModifier *&spellMod)
 
void CallScriptEffectCalcCritChanceHandlers (AuraEffect const *aurEff, AuraApplication const *aurApp, Unit const *victim, float &critChance)
 
void CallScriptCalcDamageAndHealingHandlers (AuraEffect const *aurEff, AuraApplication const *aurApp, Unit *victim, int32 &damageOrHealing, int32 &flatMod, float &pctMod)
 
void CallScriptEffectAbsorbHandlers (AuraEffect *aurEff, AuraApplication const *aurApp, DamageInfo &dmgInfo, uint32 &absorbAmount, bool &defaultPrevented)
 
void CallScriptEffectAfterAbsorbHandlers (AuraEffect *aurEff, AuraApplication const *aurApp, DamageInfo &dmgInfo, uint32 &absorbAmount)
 
void CallScriptEffectAbsorbHandlers (AuraEffect *aurEff, AuraApplication const *aurApp, HealInfo &healInfo, uint32 &absorbAmount, bool &defaultPrevented)
 
void CallScriptEffectAfterAbsorbHandlers (AuraEffect *aurEff, AuraApplication const *aurApp, HealInfo &healInfo, uint32 &absorbAmount)
 
void CallScriptEffectManaShieldHandlers (AuraEffect *aurEff, AuraApplication const *aurApp, DamageInfo &dmgInfo, uint32 &absorbAmount, bool &defaultPrevented)
 
void CallScriptEffectAfterManaShieldHandlers (AuraEffect *aurEff, AuraApplication const *aurApp, DamageInfo &dmgInfo, uint32 &absorbAmount)
 
void CallScriptEffectSplitHandlers (AuraEffect *aurEff, AuraApplication const *aurApp, DamageInfo &dmgInfo, uint32 &splitAmount)
 
void CallScriptEnterLeaveCombatHandlers (AuraApplication const *aurApp, bool isNowInCombat)
 
bool CallScriptCheckProcHandlers (AuraApplication const *aurApp, ProcEventInfo &eventInfo)
 
bool CallScriptCheckEffectProcHandlers (AuraEffect const *aurEff, AuraApplication const *aurApp, ProcEventInfo &eventInfo)
 
bool CallScriptPrepareProcHandlers (AuraApplication const *aurApp, ProcEventInfo &eventInfo)
 
bool CallScriptProcHandlers (AuraApplication const *aurApp, ProcEventInfo &eventInfo)
 
void CallScriptAfterProcHandlers (AuraApplication const *aurApp, ProcEventInfo &eventInfo)
 
bool CallScriptEffectProcHandlers (AuraEffect *aurEff, AuraApplication const *aurApp, ProcEventInfo &eventInfo)
 
void CallScriptAfterEffectProcHandlers (AuraEffect *aurEff, AuraApplication const *aurApp, ProcEventInfo &eventInfo)
 
UnitAuraToUnitAura ()
 
UnitAura const * ToUnitAura () const
 
DynObjAuraToDynObjAura ()
 
DynObjAura const * ToDynObjAura () const
 
template<class Script >
ScriptGetScript () const
 
AuraEffectVector const & GetAuraEffects () const
 
virtual std::string GetDebugInfo () const
 
 Aura (Aura const &)=delete
 
 Aura (Aura &&)=delete
 
Auraoperator= (Aura const &)=delete
 
Auraoperator= (Aura &&)=delete
 

Static Public Member Functions

static uint32 BuildEffectMaskForOwner (SpellInfo const *spellProto, uint32 availableEffectMask, WorldObject *owner)
 
static AuraTryRefreshStackOrCreate (AuraCreateInfo &createInfo, bool updateEffectMask=true)
 
static AuraTryCreate (AuraCreateInfo &createInfo)
 
static AuraCreate (AuraCreateInfo &createInfo)
 
static int32 CalcMaxDuration (SpellInfo const *spellInfo, WorldObject const *caster, std::vector< SpellPowerCost > const *powerCosts)
 
static bool EffectTypeNeedsSendingAmount (AuraType type)
 

Public Attributes

std::vector< AuraScript * > m_loadedScripts
 

Protected Attributes

SpellInfo const *const m_spellInfo
 
Difficulty const m_castDifficulty
 
ObjectGuid const m_castId
 
ObjectGuid const m_casterGuid
 
ObjectGuid const m_castItemGuid
 
uint32 m_castItemId
 
int32 m_castItemLevel
 
SpellCastVisual const m_spellVisual
 
time_t const m_applyTime
 
WorldObject *const m_owner
 
int32 m_maxDuration
 
int32 m_duration
 
int32 m_timeCla
 
std::vector< SpellPowerEntry const * > m_periodicCosts
 
int32 m_updateTargetMapInterval
 
uint8 const m_casterLevel
 
uint8 m_procCharges
 
uint8 m_stackAmount
 
ApplicationMap m_applications
 
bool m_isRemoved
 
bool m_isSingleTarget
 
bool m_isUsingCharges
 
ChargeDropEventm_dropEvent
 
TimePoint m_procCooldown
 
TimePoint m_lastProcAttemptTime
 
TimePoint m_lastProcSuccessTime
 

Private Member Functions

AuraScriptGetScriptByType (std::type_info const &type) const
 
void _DeleteRemovedApplications ()
 

Private Attributes

std::vector< AuraApplication * > _removedApplications
 
AuraEffectVector _effects
 

Friends

class Unit
 

Detailed Description

Definition at line 117 of file SpellAuras.h.

Member Typedef Documentation

◆ ApplicationMap

typedef std::unordered_map<ObjectGuid, AuraApplication*> Aura::ApplicationMap

Definition at line 122 of file SpellAuras.h.

Constructor & Destructor Documentation

◆ Aura() [1/3]

Aura::Aura ( AuraCreateInfo const &  createInfo)
explicit

Definition at line 455 of file SpellAuras.cpp.

455 :
456m_spellInfo(createInfo._spellInfo), m_castDifficulty(createInfo._castDifficulty), m_castId(createInfo._castId), m_casterGuid(createInfo.CasterGUID),
457m_castItemGuid(createInfo.CastItemGUID), m_castItemId(createInfo.CastItemId),
458m_castItemLevel(createInfo.CastItemLevel), m_spellVisual({ createInfo.Caster ? createInfo.Caster->GetCastSpellXSpellVisualId(createInfo._spellInfo) : createInfo._spellInfo->GetSpellXSpellVisualId(), 0 }),
460m_casterLevel(createInfo.Caster ? createInfo.Caster->GetLevel() : m_spellInfo->SpellLevel), m_procCharges(0), m_stackAmount(1),
461m_isRemoved(false), m_isSingleTarget(false), m_isUsingCharges(false), m_dropEvent(nullptr),
462m_procCooldown(TimePoint::min()),
464{
465 for (SpellPowerEntry const* power : m_spellInfo->PowerCosts)
466 if (power && (power->ManaPerSecond != 0 || power->PowerPctPerSecond > 0.0f))
467 m_periodicCosts.push_back(power);
468
469 if (!m_periodicCosts.empty())
471
472 m_maxDuration = CalcMaxDuration(createInfo.Caster);
474 m_procCharges = CalcMaxCharges(createInfo.Caster);
476 // m_casterLevel = cast item level/caster level, caster level should be saved to db, confirmed with sniffs
477}
@ IN_MILLISECONDS
Definition: Common.h:35
std::chrono::seconds Seconds
Seconds shorthand typedef.
Definition: Duration.h:32
int32 m_maxDuration
Definition: SpellAuras.h:333
time_t const m_applyTime
Definition: SpellAuras.h:330
uint8 m_stackAmount
Definition: SpellAuras.h:341
int32 m_duration
Definition: SpellAuras.h:334
TimePoint m_procCooldown
Definition: SpellAuras.h:351
int32 m_castItemLevel
Definition: SpellAuras.h:328
TimePoint m_lastProcSuccessTime
Definition: SpellAuras.h:353
ObjectGuid const m_castItemGuid
Definition: SpellAuras.h:326
int32 m_timeCla
Definition: SpellAuras.h:335
uint32 m_castItemId
Definition: SpellAuras.h:327
int32 CalcMaxDuration() const
Definition: SpellAuras.h:169
SpellInfo const *const m_spellInfo
Definition: SpellAuras.h:322
TimePoint m_lastProcAttemptTime
Definition: SpellAuras.h:352
ObjectGuid const m_castId
Definition: SpellAuras.h:324
WorldObject *const m_owner
Definition: SpellAuras.h:331
ObjectGuid const m_casterGuid
Definition: SpellAuras.h:325
uint8 const m_casterLevel
Definition: SpellAuras.h:339
uint8 CalcMaxCharges() const
Definition: SpellAuras.h:182
bool m_isUsingCharges
Definition: SpellAuras.h:347
bool m_isRemoved
Definition: SpellAuras.h:345
std::vector< SpellPowerEntry const * > m_periodicCosts
Definition: SpellAuras.h:336
int32 m_updateTargetMapInterval
Definition: SpellAuras.h:337
Difficulty const m_castDifficulty
Definition: SpellAuras.h:323
bool m_isSingleTarget
Definition: SpellAuras.h:346
uint8 m_procCharges
Definition: SpellAuras.h:340
SpellCastVisual const m_spellVisual
Definition: SpellAuras.h:329
ChargeDropEvent * m_dropEvent
Definition: SpellAuras.h:349
std::array< SpellPowerEntry const *, MAX_POWERS_PER_SPELL > PowerCosts
Definition: SpellInfo.h:386
uint32 SpellLevel
Definition: SpellInfo.h:384
TimePoint Now()
Current chrono steady_clock time point.
Definition: GameTime.cpp:59
time_t GetGameTime()
Definition: GameTime.cpp:44
+ Here is the call graph for this function:

◆ ~Aura()

Aura::~Aura ( )
virtual

Definition at line 497 of file SpellAuras.cpp.

498{
499 // unload scripts
500 for (AuraScript* script : m_loadedScripts)
501 {
502 script->_Unload();
503 delete script;
504 }
505
506 for (AuraEffect* effect : _effects)
507 delete effect;
508
509 ASSERT(m_applications.empty());
511}
#define ASSERT
Definition: Errors.h:68
AuraEffectVector _effects
Definition: SpellAuras.h:358
ApplicationMap m_applications
Definition: SpellAuras.h:343
std::vector< AuraScript * > m_loadedScripts
Definition: SpellAuras.h:305
void _DeleteRemovedApplications()
+ Here is the call graph for this function:

◆ Aura() [2/3]

Aura::Aura ( Aura const &  )
delete

◆ Aura() [3/3]

Aura::Aura ( Aura &&  )
delete

Member Function Documentation

◆ _ApplyEffectForTargets()

void Aura::_ApplyEffectForTargets ( uint8  effIndex)

Definition at line 750 of file SpellAuras.cpp.

751{
752 // prepare list of aura targets
753 UnitList targetList;
754 for (ApplicationMap::iterator appIter = m_applications.begin(); appIter != m_applications.end(); ++appIter)
755 {
756 if ((appIter->second->GetEffectsToApply() & (1 << effIndex)) && !appIter->second->HasEffect(effIndex))
757 targetList.push_back(appIter->second->GetTarget());
758 }
759
760 // apply effect to targets
761 for (UnitList::iterator itr = targetList.begin(); itr != targetList.end(); ++itr)
762 {
763 if (GetApplicationOfTarget((*itr)->GetGUID()))
764 {
765 // owner has to be in world, or effect has to be applied to self
766 ASSERT((!GetOwner()->IsInWorld() && GetOwner() == *itr) || GetOwner()->IsInMap(*itr));
767 (*itr)->_ApplyAuraEffect(this, effIndex);
768 }
769 }
770}
std::list< Unit * > UnitList
Definition: Unit.h:114
AuraApplication const * GetApplicationOfTarget(ObjectGuid guid) const
WorldObject * GetOwner() const
Definition: SpellAuras.h:145
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _ApplyForTarget()

void Aura::_ApplyForTarget ( Unit target,
Unit caster,
AuraApplication auraApp 
)
virtual

Reimplemented in UnitAura.

Definition at line 542 of file SpellAuras.cpp.

543{
544 ASSERT(target);
545 ASSERT(auraApp);
546 // aura mustn't be already applied on target
547 ASSERT (!IsAppliedOnTarget(target->GetGUID()) && "Aura::_ApplyForTarget: aura musn't be already applied on target");
548
549 m_applications[target->GetGUID()] = auraApp;
550
551 // set infinity cooldown state for spells
552 if (caster && caster->GetTypeId() == TYPEID_PLAYER)
553 {
555 {
556 Item* castItem = !m_castItemGuid.IsEmpty() ? caster->ToPlayer()->GetItemByGuid(m_castItemGuid) : nullptr;
557 caster->GetSpellHistory()->StartCooldown(m_spellInfo, castItem ? castItem->GetEntry() : 0, nullptr, true);
558 }
559 }
560}
@ TYPEID_PLAYER
Definition: ObjectGuid.h:41
bool IsAppliedOnTarget(ObjectGuid guid) const
Definition: Item.h:170
bool IsEmpty() const
Definition: ObjectGuid.h:317
TypeID GetTypeId() const
Definition: Object.h:172
uint32 GetEntry() const
Definition: Object.h:160
static ObjectGuid GetGUID(Object const *o)
Definition: Object.h:158
static Player * ToPlayer(Object *o)
Definition: Object.h:200
Item * GetItemByGuid(ObjectGuid guid) const
Definition: Player.cpp:9542
void StartCooldown(SpellInfo const *spellInfo, uint32 itemId, Spell *spell=nullptr, bool onHold=false, Optional< Duration > forcedCooldown={})
bool IsCooldownStartedOnEvent() const
Definition: SpellInfo.cpp:1649
SpellHistory * GetSpellHistory()
Definition: Unit.h:1443
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _DeleteRemovedApplications()

void Aura::_DeleteRemovedApplications ( )
private

Definition at line 2011 of file SpellAuras.cpp.

2012{
2014 delete aurApp;
2015
2016 _removedApplications.clear();
2017}
std::vector< AuraApplication * > _removedApplications
Definition: SpellAuras.h:356
+ Here is the caller graph for this function:

◆ _InitEffects()

void Aura::_InitEffects ( uint32  effMask,
Unit caster,
int32 const *  baseAmount 
)

Definition at line 487 of file SpellAuras.cpp.

488{
489 // shouldn't be in constructor - functions in AuraEffect::AuraEffect use polymorphism
490 _effects.resize(GetSpellInfo()->GetEffects().size());
491
492 for (SpellEffectInfo const& spellEffectInfo : GetSpellInfo()->GetEffects())
493 if (effMask & (1 << spellEffectInfo.EffectIndex))
494 _effects[spellEffectInfo.EffectIndex] = new AuraEffect(this, spellEffectInfo, baseAmount ? baseAmount + spellEffectInfo.EffectIndex : nullptr, caster);
495}
SpellInfo const * GetSpellInfo() const
Definition: SpellAuras.h:133
constexpr std::size_t size()
Definition: UpdateField.h:796
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _RegisterForTargets()

void Aura::_RegisterForTargets ( )
inline

Definition at line 159 of file SpellAuras.h.

159{ Unit* caster = GetCaster(); UpdateTargetMap(caster, false); }
Unit * GetCaster() const
Definition: SpellAuras.cpp:513
void UpdateTargetMap(Unit *caster, bool apply=true)
Definition: SpellAuras.cpp:612
Definition: Unit.h:622
+ Here is the caller graph for this function:

◆ _Remove()

void Aura::_Remove ( AuraRemoveMode  removeMode)

Definition at line 592 of file SpellAuras.cpp.

593{
595 m_isRemoved = true;
596 ApplicationMap::iterator appItr = m_applications.begin();
597 for (appItr = m_applications.begin(); appItr != m_applications.end();)
598 {
599 AuraApplication * aurApp = appItr->second;
600 Unit* target = aurApp->GetTarget();
601 target->_UnapplyAura(aurApp, removeMode);
602 appItr = m_applications.begin();
603 }
604
605 if (m_dropEvent)
606 {
608 m_dropEvent = nullptr;
609 }
610}
Unit * GetTarget() const
Definition: SpellAuras.h:76
void ScheduleAbort()
void _UnapplyAura(AuraApplicationMap::iterator &i, AuraRemoveMode removeMode)
Definition: Unit.cpp:3438
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _UnapplyForTarget()

void Aura::_UnapplyForTarget ( Unit target,
Unit caster,
AuraApplication auraApp 
)
virtual
Todo:
Figure out why this happens

Reimplemented in UnitAura.

Definition at line 562 of file SpellAuras.cpp.

563{
564 ASSERT(target);
565 ASSERT(auraApp->GetRemoveMode());
566 ASSERT(auraApp);
567
568 ApplicationMap::iterator itr = m_applications.find(target->GetGUID());
569
571 if (itr == m_applications.end())
572 {
573 TC_LOG_ERROR("spells", "Aura::_UnapplyForTarget, target: {}, caster: {}, spell:{} was not found in owners application map!",
574 target->GetGUID().ToString(), caster ? caster->GetGUID().ToString().c_str() : "Empty", auraApp->GetBase()->GetSpellInfo()->Id);
575 ABORT();
576 }
577
578 // aura has to be already applied
579 ASSERT(itr->second == auraApp);
580 m_applications.erase(itr);
581
582 _removedApplications.push_back(auraApp);
583
584 // reset cooldown state for spells
585 if (caster && GetSpellInfo()->IsCooldownStartedOnEvent())
586 // note: item based cooldowns and cooldown spell mods with charges ignored (unknown existed cases)
588}
#define ABORT
Definition: Errors.h:74
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:165
Aura * GetBase() const
Definition: SpellAuras.h:77
AuraRemoveMode GetRemoveMode() const
Definition: SpellAuras.h:90
std::string ToString() const
Definition: ObjectGuid.cpp:554
void SendCooldownEvent(SpellInfo const *spellInfo, uint32 itemId=0, Spell *spell=nullptr, bool startCooldown=true)
uint32 const Id
Definition: SpellInfo.h:325
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ AddProcCooldown()

void Aura::AddProcCooldown ( SpellProcEntry const *  procEntry,
TimePoint  now 
)

Definition at line 1734 of file SpellAuras.cpp.

1735{
1736 // cooldowns should be added to the whole aura (see 51698 area aura)
1737 int32 procCooldown = procEntry->Cooldown.count();
1738 if (Unit* caster = GetCaster())
1739 if (Player* modOwner = caster->GetSpellModOwner())
1740 modOwner->ApplySpellMod(GetSpellInfo(), SpellModOp::ProcCooldown, procCooldown);
1741
1742 m_procCooldown = now + Milliseconds(procCooldown);
1743}
int32_t int32
Definition: Define.h:139
std::chrono::milliseconds Milliseconds
Milliseconds shorthand typedef.
Definition: Duration.h:29
Player * GetSpellModOwner() const
Definition: Object.cpp:2260
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ApplyForTargets()

void Aura::ApplyForTargets ( )
inline

Definition at line 160 of file SpellAuras.h.

160{ Unit* caster = GetCaster(); UpdateTargetMap(caster, true); }

◆ BuildEffectMaskForOwner()

uint32 Aura::BuildEffectMaskForOwner ( SpellInfo const *  spellProto,
uint32  availableEffectMask,
WorldObject owner 
)
static

Definition at line 307 of file SpellAuras.cpp.

308{
309 ASSERT_NODEBUGINFO(spellProto);
310 ASSERT_NODEBUGINFO(owner);
311 uint32 effMask = 0;
312 switch (owner->GetTypeId())
313 {
314 case TYPEID_UNIT:
315 case TYPEID_PLAYER:
316 for (SpellEffectInfo const& spellEffectInfo : spellProto->GetEffects())
317 {
318 if (spellEffectInfo.IsUnitOwnedAuraEffect())
319 effMask |= 1 << spellEffectInfo.EffectIndex;
320 }
321 break;
323 for (SpellEffectInfo const& spellEffectInfo : spellProto->GetEffects())
324 {
325 if (spellEffectInfo.IsEffect(SPELL_EFFECT_PERSISTENT_AREA_AURA))
326 effMask |= 1 << spellEffectInfo.EffectIndex;
327 }
328 break;
329 default:
330 ABORT();
331 break;
332 }
333
334 return effMask & availableEffectMask;
335}
uint32_t uint32
Definition: Define.h:143
#define ASSERT_NODEBUGINFO
Definition: Errors.h:69
@ TYPEID_DYNAMICOBJECT
Definition: ObjectGuid.h:44
@ TYPEID_UNIT
Definition: ObjectGuid.h:40
@ SPELL_EFFECT_PERSISTENT_AREA_AURA
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ CalcDispelChance()

int32 Aura::CalcDispelChance ( Unit const *  auraTarget,
bool  offensive 
) const

Definition at line 1196 of file SpellAuras.cpp.

1197{
1198 // we assume that aura dispel chance is 100% on start
1199 // need formula for level difference based chance
1200 int32 resistChance = 0;
1201
1202 // Apply dispel mod from aura caster
1203 if (Unit* caster = GetCaster())
1204 if (Player* modOwner = caster->GetSpellModOwner())
1205 modOwner->ApplySpellMod(GetSpellInfo(), SpellModOp::DispelResistance, resistChance);
1206
1207 RoundToInterval(resistChance, 0, 100);
1208 return 100 - resistChance;
1209}
T RoundToInterval(T &num, T floor, T ceil)
Definition: Util.h:97
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ CalcMaxCharges() [1/2]

uint8 Aura::CalcMaxCharges ( ) const
inline

Definition at line 182 of file SpellAuras.h.

182{ return CalcMaxCharges(GetCaster()); }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ CalcMaxCharges() [2/2]

uint8 Aura::CalcMaxCharges ( Unit caster) const

Definition at line 958 of file SpellAuras.cpp.

959{
960 uint32 maxProcCharges = m_spellInfo->ProcCharges;
961 if (SpellProcEntry const* procEntry = sSpellMgr->GetSpellProcEntry(GetSpellInfo()))
962 maxProcCharges = procEntry->Charges;
963
964 if (caster)
965 if (Player* modOwner = caster->GetSpellModOwner())
966 modOwner->ApplySpellMod(GetSpellInfo(), SpellModOp::ProcCharges, maxProcCharges);
967
968 return uint8(maxProcCharges);
969}
uint8_t uint8
Definition: Define.h:145
#define sSpellMgr
Definition: SpellMgr.h:849
uint32 ProcCharges
Definition: SpellInfo.h:378
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ CalcMaxDuration() [1/3]

int32 Aura::CalcMaxDuration ( ) const
inline

Definition at line 169 of file SpellAuras.h.

169{ return CalcMaxDuration(GetCaster()); }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ CalcMaxDuration() [2/3]

int32 Aura::CalcMaxDuration ( SpellInfo const *  spellInfo,
WorldObject const *  caster,
std::vector< SpellPowerCost > const *  powerCosts 
)
static

Definition at line 867 of file SpellAuras.cpp.

868{
869 Player* modOwner = nullptr;
870 int32 maxDuration;
871
872 if (caster)
873 {
874 modOwner = caster->GetSpellModOwner();
875 maxDuration = caster->CalcSpellDuration(spellInfo, powerCosts);
876 }
877 else
878 maxDuration = spellInfo->GetDuration();
879
880 if (spellInfo->IsPassive() && !spellInfo->DurationEntry)
881 maxDuration = -1;
882
883 // IsPermanent() checks max duration (which we are supposed to calculate here)
884 if (maxDuration != -1 && modOwner)
885 modOwner->ApplySpellMod(spellInfo, SpellModOp::Duration, maxDuration);
886
887 return maxDuration;
888}
void ApplySpellMod(SpellInfo const *spellInfo, SpellModOp op, T &basevalue, Spell *spell=nullptr) const
Definition: Player.cpp:22238
int32 CalcSpellDuration(SpellInfo const *spellInfo, std::vector< SpellPowerCost > const *powerCosts) const
Definition: Object.cpp:2350
+ Here is the call graph for this function:

◆ CalcMaxDuration() [3/3]

int32 Aura::CalcMaxDuration ( Unit caster) const

Definition at line 862 of file SpellAuras.cpp.

863{
864 return Aura::CalcMaxDuration(GetSpellInfo(), caster, nullptr);
865}
+ Here is the call graph for this function:

◆ CalcMaxStackAmount()

uint32 Aura::CalcMaxStackAmount ( ) const

Definition at line 1042 of file SpellAuras.cpp.

1043{
1044 int32 maxStackAmount = m_spellInfo->StackAmount;
1045 if (Unit* caster = GetCaster())
1046 if (Player* modOwner = caster->GetSpellModOwner())
1047 modOwner->ApplySpellMod(m_spellInfo, SpellModOp::MaxAuraStacks, maxStackAmount);
1048
1049 return maxStackAmount;
1050}
uint32 StackAmount
Definition: SpellInfo.h:390
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ CalcPPMProcChance()

float Aura::CalcPPMProcChance ( Unit actor) const

Definition at line 1994 of file SpellAuras.cpp.

1995{
1996 using FSeconds = std::chrono::duration<float, Seconds::period>;
1997
1998 // Formula see http://us.battle.net/wow/en/forum/topic/8197741003#1
1999 float ppm = m_spellInfo->CalcProcPPM(actor, GetCastItemLevel());
2000 float averageProcInterval = 60.0f / ppm;
2001
2002 TimePoint currentTime = GameTime::Now();
2003 float secondsSinceLastAttempt = std::min(std::chrono::duration_cast<FSeconds>(currentTime - m_lastProcAttemptTime).count(), 10.0f);
2004 float secondsSinceLastProc = std::min(std::chrono::duration_cast<FSeconds>(currentTime - m_lastProcSuccessTime).count(), 1000.0f);
2005
2006 float chance = std::max(1.0f, 1.0f + ((secondsSinceLastProc / averageProcInterval - 1.5f) * 3.0f)) * ppm * secondsSinceLastAttempt / 60.0f;
2007 RoundToInterval(chance, 0.0f, 1.0f);
2008 return chance * 100.0f;
2009}
std::chrono::steady_clock::time_point TimePoint
time_point shorthand typedefs
Definition: Duration.h:41
int32 GetCastItemLevel() const
Definition: SpellAuras.h:141
float CalcProcPPM(Unit *caster, int32 itemLevel) const
Definition: SpellInfo.cpp:4202
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ CalcProcChance()

float Aura::CalcProcChance ( SpellProcEntry const &  procEntry,
ProcEventInfo eventInfo 
) const

Definition at line 1941 of file SpellAuras.cpp.

1942{
1943 float chance = procEntry.Chance;
1944 // calculate chances depending on unit with caster's data
1945 // so talents modifying chances and judgements will have properly calculated proc chance
1946 if (Unit* caster = GetCaster())
1947 {
1948 // calculate ppm chance if present and we're using weapon
1949 if (eventInfo.GetDamageInfo() && procEntry.ProcsPerMinute != 0)
1950 {
1951 uint32 WeaponSpeed = caster->GetBaseAttackTime(eventInfo.GetDamageInfo()->GetAttackType());
1952 chance = caster->GetPPMProcChance(WeaponSpeed, procEntry.ProcsPerMinute, GetSpellInfo());
1953 }
1954
1955 if (GetSpellInfo()->ProcBasePPM > 0.0f)
1956 chance = CalcPPMProcChance(caster);
1957
1958 // apply chance modifer aura, applies also to ppm chance (see improved judgement of light spell)
1959 if (Player* modOwner = caster->GetSpellModOwner())
1960 modOwner->ApplySpellMod(GetSpellInfo(), SpellModOp::ProcChance, chance);
1961 }
1962
1963 // proc chance is reduced by an additional 3.333% per level past 60
1964 if ((procEntry.AttributesMask & PROC_ATTR_REDUCE_PROC_60) && eventInfo.GetActor()->GetLevel() > 60)
1965 chance = std::max(0.f, (1.f - ((eventInfo.GetActor()->GetLevel() - 60) * 1.f / 30.f)) * chance);
1966
1967 return chance;
1968}
@ PROC_ATTR_REDUCE_PROC_60
Definition: SpellMgr.h:303
float CalcPPMProcChance(Unit *actor) const
WeaponAttackType GetAttackType() const
Definition: Unit.h:440
DamageInfo * GetDamageInfo() const
Definition: Unit.h:500
Unit * GetActor() const
Definition: Unit.h:488
uint8 GetLevel() const
Definition: Unit.h:741
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ CallScriptAfterDispel()

void Aura::CallScriptAfterDispel ( DispelInfo dispelInfo)

Definition at line 2055 of file SpellAuras.cpp.

2056{
2057 for (AuraScript* script : m_loadedScripts)
2058 {
2059 script->_PrepareScriptCall(AURA_SCRIPT_HOOK_AFTER_DISPEL);
2060 for (AuraScript::AuraDispelHandler const& afterDispel : script->AfterDispel)
2061 afterDispel.Call(script, dispelInfo);
2062
2063 script->_FinishScriptCall();
2064 }
2065}
@ AURA_SCRIPT_HOOK_AFTER_DISPEL
Definition: SpellScript.h:1050
void Call(AuraScript *auraScript, DispelInfo *dispelInfo) const
Definition: SpellScript.h:1168
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ CallScriptAfterEffectApplyHandlers()

void Aura::CallScriptAfterEffectApplyHandlers ( AuraEffect const *  aurEff,
AuraApplication const *  aurApp,
AuraEffectHandleModes  mode 
)

Definition at line 2104 of file SpellAuras.cpp.

2105{
2106 for (AuraScript* script : m_loadedScripts)
2107 {
2108 script->_PrepareScriptCall(AURA_SCRIPT_HOOK_EFFECT_AFTER_APPLY, aurApp);
2109 for (AuraScript::EffectApplyHandler const& afterEffectApply : script->AfterEffectApply)
2110 if (afterEffectApply.IsEffectAffected(m_spellInfo, aurEff->GetEffIndex()))
2111 afterEffectApply.Call(script, aurEff, mode);
2112
2113 script->_FinishScriptCall();
2114 }
2115}
@ AURA_SCRIPT_HOOK_EFFECT_AFTER_APPLY
Definition: SpellScript.h:1033
void Call(AuraScript *auraScript, AuraEffect const *aurEff, AuraEffectHandleModes mode) const
Definition: SpellScript.h:1607
bool IsEffectAffected(SpellInfo const *spellInfo, uint8 effIndex) const
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ CallScriptAfterEffectProcHandlers()

void Aura::CallScriptAfterEffectProcHandlers ( AuraEffect aurEff,
AuraApplication const *  aurApp,
ProcEventInfo eventInfo 
)

Definition at line 2434 of file SpellAuras.cpp.

2435{
2436 for (AuraScript* script : m_loadedScripts)
2437 {
2438 script->_PrepareScriptCall(AURA_SCRIPT_HOOK_EFFECT_AFTER_PROC, aurApp);
2439 for (AuraScript::EffectProcHandler const& afterEffectProc : script->AfterEffectProc)
2440 if (afterEffectProc.IsEffectAffected(m_spellInfo, aurEff->GetEffIndex()))
2441 afterEffectProc.Call(script, aurEff, eventInfo);
2442
2443 script->_FinishScriptCall();
2444 }
2445}
@ AURA_SCRIPT_HOOK_EFFECT_AFTER_PROC
Definition: SpellScript.h:1058
SpellEffIndex GetEffIndex() const
void Call(AuraScript *auraScript, AuraEffect *aurEff, ProcEventInfo &eventInfo) const
Definition: SpellScript.h:1927
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ CallScriptAfterEffectRemoveHandlers()

void Aura::CallScriptAfterEffectRemoveHandlers ( AuraEffect const *  aurEff,
AuraApplication const *  aurApp,
AuraEffectHandleModes  mode 
)

Definition at line 2117 of file SpellAuras.cpp.

2118{
2119 for (AuraScript* script : m_loadedScripts)
2120 {
2121 script->_PrepareScriptCall(AURA_SCRIPT_HOOK_EFFECT_AFTER_REMOVE, aurApp);
2122 for (AuraScript::EffectApplyHandler const& afterEffectRemove : script->AfterEffectRemove)
2123 if (afterEffectRemove.IsEffectAffected(m_spellInfo, aurEff->GetEffIndex()))
2124 afterEffectRemove.Call(script, aurEff, mode);
2125
2126 script->_FinishScriptCall();
2127 }
2128}
@ AURA_SCRIPT_HOOK_EFFECT_AFTER_REMOVE
Definition: SpellScript.h:1035
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ CallScriptAfterProcHandlers()

void Aura::CallScriptAfterProcHandlers ( AuraApplication const *  aurApp,
ProcEventInfo eventInfo 
)

Definition at line 2388 of file SpellAuras.cpp.

2389{
2390 for (AuraScript* script : m_loadedScripts)
2391 {
2392 script->_PrepareScriptCall(AURA_SCRIPT_HOOK_AFTER_PROC, aurApp);
2393 for (AuraScript::AuraProcHandler const& afterProc : script->AfterProc)
2394 afterProc.Call(script, eventInfo);
2395
2396 script->_FinishScriptCall();
2397 }
2398}
@ AURA_SCRIPT_HOOK_AFTER_PROC
Definition: SpellScript.h:1059
void Call(AuraScript *auraScript, ProcEventInfo &eventInfo) const
Definition: SpellScript.h:1874
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ CallScriptCalcDamageAndHealingHandlers()

void Aura::CallScriptCalcDamageAndHealingHandlers ( AuraEffect const *  aurEff,
AuraApplication const *  aurApp,
Unit victim,
int32 damageOrHealing,
int32 flatMod,
float &  pctMod 
)

Definition at line 2214 of file SpellAuras.cpp.

2215{
2216 for (AuraScript* script : m_loadedScripts)
2217 {
2218 script->_PrepareScriptCall(AURA_SCRIPT_HOOK_EFFECT_CALC_DAMAGE_AND_HEALING, aurApp);
2219 for (AuraScript::EffectCalcDamageAndHealingHandler const& effectCalcDamageAndHealing : script->DoEffectCalcDamageAndHealing)
2220 if (effectCalcDamageAndHealing.IsEffectAffected(m_spellInfo, aurEff->GetEffIndex()))
2221 effectCalcDamageAndHealing.Call(script, aurEff, victim, damageOrHealing, flatMod, pctMod);
2222
2223 script->_FinishScriptCall();
2224 }
2225}
@ AURA_SCRIPT_HOOK_EFFECT_CALC_DAMAGE_AND_HEALING
Definition: SpellScript.h:1042
void Call(AuraScript *auraScript, AuraEffect const *aurEff, Unit *victim, int32 &damageOrHealing, int32 &flatMod, float &pctMod) const
Definition: SpellScript.h:1554
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ CallScriptCheckAreaTargetHandlers()

bool Aura::CallScriptCheckAreaTargetHandlers ( Unit target)

Definition at line 2029 of file SpellAuras.cpp.

2030{
2031 bool result = true;
2032 for (AuraScript* script : m_loadedScripts)
2033 {
2034 script->_PrepareScriptCall(AURA_SCRIPT_HOOK_CHECK_AREA_TARGET);
2035 for (AuraScript::CheckAreaTargetHandler const& checkAreaTarget : script->DoCheckAreaTarget)
2036 result &= checkAreaTarget.Call(script, target);
2037
2038 script->_FinishScriptCall();
2039 }
2040 return result;
2041}
@ AURA_SCRIPT_HOOK_CHECK_AREA_TARGET
Definition: SpellScript.h:1048
bool Call(AuraScript *auraScript, Unit *target) const
Definition: SpellScript.h:1116
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ CallScriptCheckEffectProcHandlers()

bool Aura::CallScriptCheckEffectProcHandlers ( AuraEffect const *  aurEff,
AuraApplication const *  aurApp,
ProcEventInfo eventInfo 
)

Definition at line 2400 of file SpellAuras.cpp.

2401{
2402 bool result = true;
2403 for (AuraScript* script : m_loadedScripts)
2404 {
2405 script->_PrepareScriptCall(AURA_SCRIPT_HOOK_CHECK_EFFECT_PROC, aurApp);
2406 for (AuraScript::CheckEffectProcHandler const& checkEffectProc : script->DoCheckEffectProc)
2407 if (checkEffectProc.IsEffectAffected(m_spellInfo, aurEff->GetEffIndex()))
2408 result &= checkEffectProc.Call(script, aurEff, eventInfo);
2409
2410 script->_FinishScriptCall();
2411 }
2412
2413 return result;
2414}
@ AURA_SCRIPT_HOOK_CHECK_EFFECT_PROC
Definition: SpellScript.h:1054
bool Call(AuraScript *auraScript, AuraEffect const *aurEff, ProcEventInfo &eventInfo) const
Definition: SpellScript.h:1822
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ CallScriptCheckProcHandlers()

bool Aura::CallScriptCheckProcHandlers ( AuraApplication const *  aurApp,
ProcEventInfo eventInfo 
)

Definition at line 2339 of file SpellAuras.cpp.

2340{
2341 bool result = true;
2342 for (AuraScript* script : m_loadedScripts)
2343 {
2344 script->_PrepareScriptCall(AURA_SCRIPT_HOOK_CHECK_PROC, aurApp);
2345 for (AuraScript::CheckProcHandler const& checkProc : script->DoCheckProc)
2346 result &= checkProc.Call(script, eventInfo);
2347
2348 script->_FinishScriptCall();
2349 }
2350
2351 return result;
2352}
@ AURA_SCRIPT_HOOK_CHECK_PROC
Definition: SpellScript.h:1053
bool Call(AuraScript *auraScript, ProcEventInfo &eventInfo) const
Definition: SpellScript.h:1769
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ CallScriptDispel()

void Aura::CallScriptDispel ( DispelInfo dispelInfo)

Definition at line 2043 of file SpellAuras.cpp.

2044{
2045 for (AuraScript* script : m_loadedScripts)
2046 {
2047 script->_PrepareScriptCall(AURA_SCRIPT_HOOK_DISPEL);
2048 for (AuraScript::AuraDispelHandler const& onDispel : script->OnDispel)
2049 onDispel.Call(script, dispelInfo);
2050
2051 script->_FinishScriptCall();
2052 }
2053}
@ AURA_SCRIPT_HOOK_DISPEL
Definition: SpellScript.h:1049
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ CallScriptEffectAbsorbHandlers() [1/2]

void Aura::CallScriptEffectAbsorbHandlers ( AuraEffect aurEff,
AuraApplication const *  aurApp,
DamageInfo dmgInfo,
uint32 absorbAmount,
bool &  defaultPrevented 
)

Definition at line 2227 of file SpellAuras.cpp.

2228{
2229 for (AuraScript* script : m_loadedScripts)
2230 {
2231 script->_PrepareScriptCall(AURA_SCRIPT_HOOK_EFFECT_ABSORB, aurApp);
2232 for (AuraScript::EffectAbsorbHandler const& onEffectAbsorb : script->OnEffectAbsorb)
2233 if (onEffectAbsorb.IsEffectAffected(m_spellInfo, aurEff->GetEffIndex()))
2234 onEffectAbsorb.Call(script, aurEff, dmgInfo, absorbAmount);
2235
2236 if (!defaultPrevented)
2237 defaultPrevented = script->_IsDefaultActionPrevented();
2238
2239 script->_FinishScriptCall();
2240 }
2241}
@ AURA_SCRIPT_HOOK_EFFECT_ABSORB
Definition: SpellScript.h:1043
void Call(AuraScript *auraScript, AuraEffect *aurEff, DamageInfo &dmgInfo, uint32 &absorbAmount) const
Definition: SpellScript.h:1664
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ CallScriptEffectAbsorbHandlers() [2/2]

void Aura::CallScriptEffectAbsorbHandlers ( AuraEffect aurEff,
AuraApplication const *  aurApp,
HealInfo healInfo,
uint32 absorbAmount,
bool &  defaultPrevented 
)

Definition at line 2256 of file SpellAuras.cpp.

2257{
2258 for (AuraScript* script : m_loadedScripts)
2259 {
2260 script->_PrepareScriptCall(AURA_SCRIPT_HOOK_EFFECT_ABSORB, aurApp);
2261 for (AuraScript::EffectAbsorbHealHandler const& onEffectAbsorbHeal : script->OnEffectAbsorbHeal)
2262 if (onEffectAbsorbHeal.IsEffectAffected(m_spellInfo, aurEff->GetEffIndex()))
2263 onEffectAbsorbHeal.Call(script, aurEff, healInfo, absorbAmount);
2264
2265 if (!defaultPrevented)
2266 defaultPrevented = script->_IsDefaultActionPrevented();
2267
2268 script->_FinishScriptCall();
2269 }
2270}
void Call(AuraScript *auraScript, AuraEffect *aurEff, HealInfo &healInfo, uint32 &absorbAmount) const
Definition: SpellScript.h:1717
+ Here is the call graph for this function:

◆ CallScriptEffectAfterAbsorbHandlers() [1/2]

void Aura::CallScriptEffectAfterAbsorbHandlers ( AuraEffect aurEff,
AuraApplication const *  aurApp,
DamageInfo dmgInfo,
uint32 absorbAmount 
)

Definition at line 2243 of file SpellAuras.cpp.

2244{
2245 for (AuraScript* script : m_loadedScripts)
2246 {
2247 script->_PrepareScriptCall(AURA_SCRIPT_HOOK_EFFECT_AFTER_ABSORB, aurApp);
2248 for (AuraScript::EffectAbsorbHandler const& afterEffectAbsorb : script->AfterEffectAbsorb)
2249 if (afterEffectAbsorb.IsEffectAffected(m_spellInfo, aurEff->GetEffIndex()))
2250 afterEffectAbsorb.Call(script, aurEff, dmgInfo, absorbAmount);
2251
2252 script->_FinishScriptCall();
2253 }
2254}
@ AURA_SCRIPT_HOOK_EFFECT_AFTER_ABSORB
Definition: SpellScript.h:1044
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ CallScriptEffectAfterAbsorbHandlers() [2/2]

void Aura::CallScriptEffectAfterAbsorbHandlers ( AuraEffect aurEff,
AuraApplication const *  aurApp,
HealInfo healInfo,
uint32 absorbAmount 
)

Definition at line 2272 of file SpellAuras.cpp.

2273{
2274 for (AuraScript* script : m_loadedScripts)
2275 {
2276 script->_PrepareScriptCall(AURA_SCRIPT_HOOK_EFFECT_AFTER_ABSORB, aurApp);
2277 for (AuraScript::EffectAbsorbHealHandler const& afterEffectAbsorbHeal : script->AfterEffectAbsorbHeal)
2278 if (afterEffectAbsorbHeal.IsEffectAffected(m_spellInfo, aurEff->GetEffIndex()))
2279 afterEffectAbsorbHeal.Call(script, aurEff, healInfo, absorbAmount);
2280
2281 script->_FinishScriptCall();
2282 }
2283}
+ Here is the call graph for this function:

◆ CallScriptEffectAfterManaShieldHandlers()

void Aura::CallScriptEffectAfterManaShieldHandlers ( AuraEffect aurEff,
AuraApplication const *  aurApp,
DamageInfo dmgInfo,
uint32 absorbAmount 
)

Definition at line 2301 of file SpellAuras.cpp.

2302{
2303 for (AuraScript* script : m_loadedScripts)
2304 {
2305 script->_PrepareScriptCall(AURA_SCRIPT_HOOK_EFFECT_AFTER_MANASHIELD, aurApp);
2306 for (AuraScript::EffectAbsorbHandler const& afterEffectManaShield : script->AfterEffectManaShield)
2307 if (afterEffectManaShield.IsEffectAffected(m_spellInfo, aurEff->GetEffIndex()))
2308 afterEffectManaShield.Call(script, aurEff, dmgInfo, absorbAmount);
2309
2310 script->_FinishScriptCall();
2311 }
2312}
@ AURA_SCRIPT_HOOK_EFFECT_AFTER_MANASHIELD
Definition: SpellScript.h:1046
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ CallScriptEffectApplyHandlers()

bool Aura::CallScriptEffectApplyHandlers ( AuraEffect const *  aurEff,
AuraApplication const *  aurApp,
AuraEffectHandleModes  mode 
)

Definition at line 2067 of file SpellAuras.cpp.

2068{
2069 bool preventDefault = false;
2070 for (AuraScript* script : m_loadedScripts)
2071 {
2072 script->_PrepareScriptCall(AURA_SCRIPT_HOOK_EFFECT_APPLY, aurApp);
2073 for (AuraScript::EffectApplyHandler const& onEffectApply : script->OnEffectApply)
2074 if (onEffectApply.IsEffectAffected(m_spellInfo, aurEff->GetEffIndex()))
2075 onEffectApply.Call(script, aurEff, mode);
2076
2077 if (!preventDefault)
2078 preventDefault = script->_IsDefaultActionPrevented();
2079
2080 script->_FinishScriptCall();
2081 }
2082
2083 return preventDefault;
2084}
@ AURA_SCRIPT_HOOK_EFFECT_APPLY
Definition: SpellScript.h:1032
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ CallScriptEffectCalcAmountHandlers()

void Aura::CallScriptEffectCalcAmountHandlers ( AuraEffect const *  aurEff,
int32 amount,
bool &  canBeRecalculated 
)

Definition at line 2162 of file SpellAuras.cpp.

2163{
2164 for (AuraScript* script : m_loadedScripts)
2165 {
2166 script->_PrepareScriptCall(AURA_SCRIPT_HOOK_EFFECT_CALC_AMOUNT);
2167 for (AuraScript::EffectCalcAmountHandler const& effectCalcAmount : script->DoEffectCalcAmount)
2168 if (effectCalcAmount.IsEffectAffected(m_spellInfo, aurEff->GetEffIndex()))
2169 effectCalcAmount.Call(script, aurEff, amount, canBeRecalculated);
2170
2171 script->_FinishScriptCall();
2172 }
2173}
@ AURA_SCRIPT_HOOK_EFFECT_CALC_AMOUNT
Definition: SpellScript.h:1038
void Call(AuraScript *auraScript, AuraEffect const *aurEff, int32 &amount, bool &canBeRecalculated) const
Definition: SpellScript.h:1342
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ CallScriptEffectCalcCritChanceHandlers()

void Aura::CallScriptEffectCalcCritChanceHandlers ( AuraEffect const *  aurEff,
AuraApplication const *  aurApp,
Unit const *  victim,
float &  critChance 
)

Definition at line 2201 of file SpellAuras.cpp.

2202{
2203 for (AuraScript* script : m_loadedScripts)
2204 {
2205 script->_PrepareScriptCall(AURA_SCRIPT_HOOK_EFFECT_CALC_CRIT_CHANCE, aurApp);
2206 for (AuraScript::EffectCalcCritChanceHandler const& effectCalcCritChance : script->DoEffectCalcCritChance)
2207 if (effectCalcCritChance.IsEffectAffected(m_spellInfo, aurEff->GetEffIndex()))
2208 effectCalcCritChance.Call(script, aurEff, victim, critChance);
2209
2210 script->_FinishScriptCall();
2211 }
2212}
@ AURA_SCRIPT_HOOK_EFFECT_CALC_CRIT_CHANCE
Definition: SpellScript.h:1041
void Call(AuraScript *auraScript, AuraEffect const *aurEff, Unit const *victim, float &critChance) const
Definition: SpellScript.h:1501
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ CallScriptEffectCalcPeriodicHandlers()

void Aura::CallScriptEffectCalcPeriodicHandlers ( AuraEffect const *  aurEff,
bool &  isPeriodic,
int32 amplitude 
)

Definition at line 2175 of file SpellAuras.cpp.

2176{
2177 for (AuraScript* script : m_loadedScripts)
2178 {
2179 script->_PrepareScriptCall(AURA_SCRIPT_HOOK_EFFECT_CALC_PERIODIC);
2180 for (AuraScript::EffectCalcPeriodicHandler const& effectCalcPeriodic : script->DoEffectCalcPeriodic)
2181 if (effectCalcPeriodic.IsEffectAffected(m_spellInfo, aurEff->GetEffIndex()))
2182 effectCalcPeriodic.Call(script, aurEff, isPeriodic, amplitude);
2183
2184 script->_FinishScriptCall();
2185 }
2186}
@ AURA_SCRIPT_HOOK_EFFECT_CALC_PERIODIC
Definition: SpellScript.h:1039
void Call(AuraScript *auraScript, AuraEffect const *aurEff, bool &isPeriodic, int32 &periodicTimer) const
Definition: SpellScript.h:1395
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ CallScriptEffectCalcSpellModHandlers()

void Aura::CallScriptEffectCalcSpellModHandlers ( AuraEffect const *  aurEff,
SpellModifier *&  spellMod 
)

Definition at line 2188 of file SpellAuras.cpp.

2189{
2190 for (AuraScript* script : m_loadedScripts)
2191 {
2192 script->_PrepareScriptCall(AURA_SCRIPT_HOOK_EFFECT_CALC_SPELLMOD);
2193 for (AuraScript::EffectCalcSpellModHandler const& effectCalcSpellMod : script->DoEffectCalcSpellMod)
2194 if (effectCalcSpellMod.IsEffectAffected(m_spellInfo, aurEff->GetEffIndex()))
2195 effectCalcSpellMod.Call(script, aurEff, spellMod);
2196
2197 script->_FinishScriptCall();
2198 }
2199}
@ AURA_SCRIPT_HOOK_EFFECT_CALC_SPELLMOD
Definition: SpellScript.h:1040
void Call(AuraScript *auraScript, AuraEffect const *aurEff, SpellModifier *&spellMod) const
Definition: SpellScript.h:1448
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ CallScriptEffectManaShieldHandlers()

void Aura::CallScriptEffectManaShieldHandlers ( AuraEffect aurEff,
AuraApplication const *  aurApp,
DamageInfo dmgInfo,
uint32 absorbAmount,
bool &  defaultPrevented 
)

Definition at line 2285 of file SpellAuras.cpp.

2286{
2287 for (AuraScript* script : m_loadedScripts)
2288 {
2289 script->_PrepareScriptCall(AURA_SCRIPT_HOOK_EFFECT_MANASHIELD, aurApp);
2290 for (AuraScript::EffectAbsorbHandler const& onEffectManaShield : script->OnEffectManaShield)
2291 if (onEffectManaShield.IsEffectAffected(m_spellInfo, aurEff->GetEffIndex()))
2292 onEffectManaShield.Call(script, aurEff, dmgInfo, absorbAmount);
2293
2294 if (!defaultPrevented)
2295 defaultPrevented = script->_IsDefaultActionPrevented();
2296
2297 script->_FinishScriptCall();
2298 }
2299}
@ AURA_SCRIPT_HOOK_EFFECT_MANASHIELD
Definition: SpellScript.h:1045
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ CallScriptEffectPeriodicHandlers()

bool Aura::CallScriptEffectPeriodicHandlers ( AuraEffect const *  aurEff,
AuraApplication const *  aurApp 
)

Definition at line 2130 of file SpellAuras.cpp.

2131{
2132 bool preventDefault = false;
2133 for (AuraScript* script : m_loadedScripts)
2134 {
2135 script->_PrepareScriptCall(AURA_SCRIPT_HOOK_EFFECT_PERIODIC, aurApp);
2136 for (AuraScript::EffectPeriodicHandler const& onEffectPeriodic : script->OnEffectPeriodic)
2137 if (onEffectPeriodic.IsEffectAffected(m_spellInfo, aurEff->GetEffIndex()))
2138 onEffectPeriodic.Call(script, aurEff);
2139
2140 if (!preventDefault)
2141 preventDefault = script->_IsDefaultActionPrevented();
2142
2143 script->_FinishScriptCall();
2144 }
2145
2146 return preventDefault;
2147}
@ AURA_SCRIPT_HOOK_EFFECT_PERIODIC
Definition: SpellScript.h:1036
void Call(AuraScript *auraScript, AuraEffect const *aurEff) const
Definition: SpellScript.h:1236
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ CallScriptEffectProcHandlers()

bool Aura::CallScriptEffectProcHandlers ( AuraEffect aurEff,
AuraApplication const *  aurApp,
ProcEventInfo eventInfo 
)

Definition at line 2416 of file SpellAuras.cpp.

2417{
2418 bool preventDefault = false;
2419 for (AuraScript* script : m_loadedScripts)
2420 {
2421 script->_PrepareScriptCall(AURA_SCRIPT_HOOK_EFFECT_PROC, aurApp);
2422 for (AuraScript::EffectProcHandler const& onEffectProc : script->OnEffectProc)
2423 if (onEffectProc.IsEffectAffected(m_spellInfo, aurEff->GetEffIndex()))
2424 onEffectProc.Call(script, aurEff, eventInfo);
2425
2426 if (!preventDefault)
2427 preventDefault = script->_IsDefaultActionPrevented();
2428
2429 script->_FinishScriptCall();
2430 }
2431 return preventDefault;
2432}
@ AURA_SCRIPT_HOOK_EFFECT_PROC
Definition: SpellScript.h:1057
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ CallScriptEffectRemoveHandlers()

bool Aura::CallScriptEffectRemoveHandlers ( AuraEffect const *  aurEff,
AuraApplication const *  aurApp,
AuraEffectHandleModes  mode 
)

Definition at line 2086 of file SpellAuras.cpp.

2087{
2088 bool preventDefault = false;
2089 for (AuraScript* script : m_loadedScripts)
2090 {
2091 script->_PrepareScriptCall(AURA_SCRIPT_HOOK_EFFECT_REMOVE, aurApp);
2092 for (AuraScript::EffectApplyHandler const& onEffectRemove : script->OnEffectRemove)
2093 if (onEffectRemove.IsEffectAffected(m_spellInfo, aurEff->GetEffIndex()))
2094 onEffectRemove.Call(script, aurEff, mode);
2095
2096 if (!preventDefault)
2097 preventDefault = script->_IsDefaultActionPrevented();
2098
2099 script->_FinishScriptCall();
2100 }
2101 return preventDefault;
2102}
@ AURA_SCRIPT_HOOK_EFFECT_REMOVE
Definition: SpellScript.h:1034
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ CallScriptEffectSplitHandlers()

void Aura::CallScriptEffectSplitHandlers ( AuraEffect aurEff,
AuraApplication const *  aurApp,
DamageInfo dmgInfo,
uint32 splitAmount 
)

Definition at line 2314 of file SpellAuras.cpp.

2315{
2316 for (AuraScript* script : m_loadedScripts)
2317 {
2318 script->_PrepareScriptCall(AURA_SCRIPT_HOOK_EFFECT_SPLIT, aurApp);
2319 for (AuraScript::EffectAbsorbHandler const& effectSplit : script->OnEffectSplit)
2320 if (effectSplit.IsEffectAffected(m_spellInfo, aurEff->GetEffIndex()))
2321 effectSplit.Call(script, aurEff, dmgInfo, splitAmount);
2322
2323 script->_FinishScriptCall();
2324 }
2325}
@ AURA_SCRIPT_HOOK_EFFECT_SPLIT
Definition: SpellScript.h:1047
+ Here is the call graph for this function:

◆ CallScriptEffectUpdatePeriodicHandlers()

void Aura::CallScriptEffectUpdatePeriodicHandlers ( AuraEffect aurEff)

Definition at line 2149 of file SpellAuras.cpp.

2150{
2151 for (AuraScript* script : m_loadedScripts)
2152 {
2153 script->_PrepareScriptCall(AURA_SCRIPT_HOOK_EFFECT_UPDATE_PERIODIC);
2154 for (AuraScript::EffectUpdatePeriodicHandler const& onEffectUpdatePeriodic : script->OnEffectUpdatePeriodic)
2155 if (onEffectUpdatePeriodic.IsEffectAffected(m_spellInfo, aurEff->GetEffIndex()))
2156 onEffectUpdatePeriodic.Call(script, aurEff);
2157
2158 script->_FinishScriptCall();
2159 }
2160}
@ AURA_SCRIPT_HOOK_EFFECT_UPDATE_PERIODIC
Definition: SpellScript.h:1037
void Call(AuraScript *auraScript, AuraEffect *aurEff) const
Definition: SpellScript.h:1289
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ CallScriptEnterLeaveCombatHandlers()

void Aura::CallScriptEnterLeaveCombatHandlers ( AuraApplication const *  aurApp,
bool  isNowInCombat 
)

Definition at line 2327 of file SpellAuras.cpp.

2328{
2329 for (AuraScript* script : m_loadedScripts)
2330 {
2331 script->_PrepareScriptCall(AURA_SCRIPT_HOOK_ENTER_LEAVE_COMBAT, aurApp);
2332 for (AuraScript::EnterLeaveCombatHandler const& onEnterLeaveCombat : script->OnEnterLeaveCombat)
2333 onEnterLeaveCombat.Call(script, isNowInCombat);
2334
2335 script->_FinishScriptCall();
2336 }
2337}
@ AURA_SCRIPT_HOOK_ENTER_LEAVE_COMBAT
Definition: SpellScript.h:1051
void Call(AuraScript *auraScript, bool isNowInCombat) const
Definition: SpellScript.h:1961
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ CallScriptPrepareProcHandlers()

bool Aura::CallScriptPrepareProcHandlers ( AuraApplication const *  aurApp,
ProcEventInfo eventInfo 
)

Definition at line 2354 of file SpellAuras.cpp.

2355{
2356 bool prepare = true;
2357 for (AuraScript* script : m_loadedScripts)
2358 {
2359 script->_PrepareScriptCall(AURA_SCRIPT_HOOK_PREPARE_PROC, aurApp);
2360 for (AuraScript::AuraProcHandler const& prepareProc : script->DoPrepareProc)
2361 prepareProc.Call(script, eventInfo);
2362
2363 if (prepare)
2364 prepare = !script->_IsDefaultActionPrevented();
2365
2366 script->_FinishScriptCall();
2367 }
2368
2369 return prepare;
2370}
@ AURA_SCRIPT_HOOK_PREPARE_PROC
Definition: SpellScript.h:1055
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ CallScriptProcHandlers()

bool Aura::CallScriptProcHandlers ( AuraApplication const *  aurApp,
ProcEventInfo eventInfo 
)

Definition at line 2372 of file SpellAuras.cpp.

2373{
2374 bool handled = false;
2375 for (AuraScript* script : m_loadedScripts)
2376 {
2377 script->_PrepareScriptCall(AURA_SCRIPT_HOOK_PROC, aurApp);
2378 for (AuraScript::AuraProcHandler const& onProc : script->OnProc)
2379 onProc.Call(script, eventInfo);
2380
2381 handled |= script->_IsDefaultActionPrevented();
2382 script->_FinishScriptCall();
2383 }
2384
2385 return handled;
2386}
@ AURA_SCRIPT_HOOK_PROC
Definition: SpellScript.h:1056
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ CanBeAppliedOn()

bool Aura::CanBeAppliedOn ( Unit target)

Definition at line 1564 of file SpellAuras.cpp.

1565{
1566 for (uint32 label : GetSpellInfo()->Labels)
1568 return false;
1569
1570 // unit not in world or during remove from world
1571 if (!target->IsInWorld() || target->IsDuringRemoveFromWorld())
1572 {
1573 // area auras mustn't be applied
1574 if (GetOwner() != target)
1575 return false;
1576 // do not apply non-selfcast single target auras
1577 if (GetCasterGUID() != GetOwner()->GetGUID() && GetSpellInfo()->IsSingleTarget())
1578 return false;
1579 return true;
1580 }
1581 else
1582 return CheckAreaTarget(target);
1583}
@ SPELL_AURA_SUPPRESS_ITEM_PASSIVE_EFFECT_BY_SPELL_LABEL
bool CheckAreaTarget(Unit *target)
ObjectGuid GetCasterGUID() const
Definition: SpellAuras.h:138
bool IsSingleTarget() const
Definition: SpellAuras.h:206
bool IsInWorld() const
Definition: Object.h:153
bool HasAuraTypeWithMiscvalue(AuraType auraType, int32 miscValue) const
Definition: Unit.cpp:4668
bool IsDuringRemoveFromWorld() const
Definition: Unit.h:1735
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ CanBeSaved()

bool Aura::CanBeSaved ( ) const

Definition at line 1127 of file SpellAuras.cpp.

1128{
1129 if (IsPassive())
1130 return false;
1131
1132 if (GetSpellInfo()->IsChanneled())
1133 return false;
1134
1135 // Check if aura is single target, not only spell info
1136 if (GetCasterGUID() != GetOwner()->GetGUID())
1137 {
1138 // owner == caster for area auras, check for possible bad data in DB
1139 for (SpellEffectInfo const& spellEffectInfo : GetSpellInfo()->GetEffects())
1140 {
1141 if (!spellEffectInfo.IsEffect())
1142 continue;
1143
1144 if (spellEffectInfo.IsTargetingArea() || spellEffectInfo.IsAreaAuraEffect())
1145 return false;
1146 }
1147
1149 return false;
1150 }
1151
1153 return false;
1154
1155 // don't save auras removed by proc system
1156 if (IsUsingCharges() && !GetCharges())
1157 return false;
1158
1159 // don't save permanent auras triggered by items, they'll be recasted on login if necessary
1160 if (!GetCastItemGUID().IsEmpty() && IsPermanent())
1161 return false;
1162
1163 return true;
1164}
@ SPELL_ATTR0_CU_AURA_CANNOT_BE_SAVED
Definition: SpellInfo.h:172
bool IsUsingCharges() const
Definition: SpellAuras.h:248
uint8 GetCharges() const
Definition: SpellAuras.h:179
ObjectGuid GetCastItemGUID() const
Definition: SpellAuras.h:139
bool IsPassive() const
bool IsPermanent() const
Definition: SpellAuras.h:177
+ Here is the call graph for this function:

◆ CanStackWith()

bool Aura::CanStackWith ( Aura const *  existingAura) const

Definition at line 1590 of file SpellAuras.cpp.

1591{
1592 // Can stack with self
1593 if (this == existingAura)
1594 return true;
1595
1596 bool sameCaster = GetCasterGUID() == existingAura->GetCasterGUID();
1597 SpellInfo const* existingSpellInfo = existingAura->GetSpellInfo();
1598
1599 // Dynobj auras do not stack when they come from the same spell cast by the same caster
1600 if (GetType() == DYNOBJ_AURA_TYPE || existingAura->GetType() == DYNOBJ_AURA_TYPE)
1601 {
1602 if (sameCaster && m_spellInfo->Id == existingSpellInfo->Id)
1603 return false;
1604 return true;
1605 }
1606
1607 // passive auras don't stack with another rank of the spell cast by same caster
1608 if (IsPassive() && sameCaster && (m_spellInfo->IsDifferentRankOf(existingSpellInfo) || (m_spellInfo->Id == existingSpellInfo->Id && m_castItemGuid.IsEmpty())))
1609 return false;
1610
1611 for (SpellEffectInfo const& spellEffectInfo : existingSpellInfo->GetEffects())
1612 {
1613 // prevent remove triggering aura by triggered aura
1614 if (spellEffectInfo.TriggerSpell == GetId())
1615 return true;
1616 }
1617
1618 for (SpellEffectInfo const& spellEffectInfo : GetSpellInfo()->GetEffects())
1619 {
1620 // prevent remove triggered aura by triggering aura refresh
1621 if (spellEffectInfo.TriggerSpell == existingAura->GetId())
1622 return true;
1623 }
1624
1625 // check spell specific stack rules
1626 if (m_spellInfo->IsAuraExclusiveBySpecificWith(existingSpellInfo)
1627 || (sameCaster && m_spellInfo->IsAuraExclusiveBySpecificPerCasterWith(existingSpellInfo)))
1628 return false;
1629
1630 // check spell group stack rules
1631 switch (sSpellMgr->CheckSpellGroupStackRules(m_spellInfo, existingSpellInfo))
1632 {
1634 case SPELL_GROUP_STACK_RULE_EXCLUSIVE_HIGHEST: // if it reaches this point, existing aura is lower/equal
1635 return false;
1637 if (sameCaster)
1638 return false;
1639 break;
1642 default:
1643 break;
1644 }
1645
1646 if (m_spellInfo->SpellFamilyName != existingSpellInfo->SpellFamilyName)
1647 return true;
1648
1649 if (!sameCaster)
1650 {
1651 // Channeled auras can stack if not forbidden by db or aura type
1652 if (existingAura->GetSpellInfo()->IsChanneled())
1653 return true;
1654
1656 return true;
1657
1658 // check same periodic auras
1659 auto hasPeriodicNonAreaEffect = [](SpellInfo const* spellInfo)
1660 {
1661 for (SpellEffectInfo const& spellEffectInfo : spellInfo->GetEffects())
1662 {
1663 switch (spellEffectInfo.ApplyAuraName)
1664 {
1665 // DOT or HOT from different casters will stack
1679 // periodic auras which target areas are not allowed to stack this way (replenishment for example)
1680 if (spellEffectInfo.IsTargetingArea())
1681 return false;
1682 return true;
1683 default:
1684 break;
1685 }
1686 }
1687 return false;
1688 };
1689
1690 if (hasPeriodicNonAreaEffect(m_spellInfo) && hasPeriodicNonAreaEffect(existingSpellInfo))
1691 return true;
1692 }
1693
1694 if (HasEffectType(SPELL_AURA_CONTROL_VEHICLE) && existingAura->HasEffectType(SPELL_AURA_CONTROL_VEHICLE))
1695 {
1696 Vehicle* veh = nullptr;
1697 if (GetOwner()->ToUnit())
1698 veh = GetOwner()->ToUnit()->GetVehicleKit();
1699
1700 if (!veh) // We should probably just let it stack. Vehicle system will prevent undefined behaviour later
1701 return true;
1702
1703 if (!veh->GetAvailableSeatCount())
1704 return false; // No empty seat available
1705
1706 return true; // Empty seat available (skip rest)
1707 }
1708
1710 if (existingAura->HasEffectType(SPELL_AURA_SHOW_CONFIRMATION_PROMPT) || existingAura->HasEffectType(SPELL_AURA_SHOW_CONFIRMATION_PROMPT_WITH_DIFFICULTY))
1711 return false;
1712
1713 // spell of same spell rank chain
1714 if (m_spellInfo->IsRankOf(existingSpellInfo))
1715 {
1716 // don't allow passive area auras to stack
1717 if (m_spellInfo->IsMultiSlotAura() && !IsArea())
1718 return true;
1719 if (!GetCastItemGUID().IsEmpty() && !existingAura->GetCastItemGUID().IsEmpty())
1720 if (GetCastItemGUID() != existingAura->GetCastItemGUID() && (m_spellInfo->HasAttribute(SPELL_ATTR0_CU_ENCHANT_PROC)))
1721 return true;
1722 // same spell with same caster should not stack
1723 return false;
1724 }
1725
1726 return true;
1727}
@ SPELL_ATTR3_DOT_STACKING_RULE
@ SPELL_AURA_PERIODIC_WEAPON_PERCENT_DAMAGE
@ SPELL_AURA_PERIODIC_DAMAGE
@ SPELL_AURA_OBS_MOD_HEALTH
@ SPELL_AURA_SHOW_CONFIRMATION_PROMPT_WITH_DIFFICULTY
@ SPELL_AURA_PERIODIC_MANA_LEECH
@ SPELL_AURA_OBS_MOD_POWER
@ SPELL_AURA_CONTROL_VEHICLE
@ SPELL_AURA_PERIODIC_HEAL
@ SPELL_AURA_PERIODIC_DAMAGE_PERCENT
@ SPELL_AURA_PERIODIC_TRIGGER_SPELL_WITH_VALUE
@ SPELL_AURA_PERIODIC_ENERGIZE
@ SPELL_AURA_PERIODIC_LEECH
@ SPELL_AURA_POWER_BURN
@ SPELL_AURA_PERIODIC_DUMMY
@ SPELL_AURA_SHOW_CONFIRMATION_PROMPT
@ SPELL_AURA_PERIODIC_TRIGGER_SPELL
@ DYNOBJ_AURA_TYPE
@ SPELL_ATTR0_CU_ENCHANT_PROC
Definition: SpellInfo.h:148
@ SPELL_GROUP_STACK_RULE_EXCLUSIVE_FROM_SAME_CASTER
Definition: SpellMgr.h:385
@ SPELL_GROUP_STACK_RULE_EXCLUSIVE
Definition: SpellMgr.h:384
@ SPELL_GROUP_STACK_RULE_DEFAULT
Definition: SpellMgr.h:383
@ SPELL_GROUP_STACK_RULE_EXCLUSIVE_SAME_EFFECT
Definition: SpellMgr.h:386
@ SPELL_GROUP_STACK_RULE_EXCLUSIVE_HIGHEST
Definition: SpellMgr.h:387
bool IsArea() const
uint32 GetId() const
Definition: SpellAuras.h:134
bool HasEffectType(AuraType type) const
AuraObjectType GetType() const
Definition: SpellAuras.cpp:537
static Unit * ToUnit(Object *o)
Definition: Object.h:212
bool IsRankOf(SpellInfo const *spellInfo) const
Definition: SpellInfo.cpp:4341
bool IsAuraExclusiveBySpecificPerCasterWith(SpellInfo const *spellInfo) const
Definition: SpellInfo.cpp:1927
bool IsAuraExclusiveBySpecificWith(SpellInfo const *spellInfo) const
Definition: SpellInfo.cpp:1895
bool IsMultiSlotAura() const
Definition: SpellInfo.cpp:1638
bool HasAttribute(SpellAttr0 attribute) const
Definition: SpellInfo.h:449
std::vector< SpellEffectInfo > const & GetEffects() const
Definition: SpellInfo.h:576
bool IsDifferentRankOf(SpellInfo const *spellInfo) const
Definition: SpellInfo.cpp:4346
uint32 SpellFamilyName
Definition: SpellInfo.h:408
Vehicle * GetVehicleKit() const
Definition: Unit.h:1696
uint8 GetAvailableSeatCount() const
Gets the available seat count.
Definition: Vehicle.cpp:690
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ CheckAreaTarget()

bool Aura::CheckAreaTarget ( Unit target)

Definition at line 1585 of file SpellAuras.cpp.

1586{
1587 return CallScriptCheckAreaTargetHandlers(target);
1588}
bool CallScriptCheckAreaTargetHandlers(Unit *target)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ConsumeProcCharges()

void Aura::ConsumeProcCharges ( SpellProcEntry const *  procEntry)

Definition at line 1777 of file SpellAuras.cpp.

1778{
1779 // Remove aura if we've used last charge to proc
1780 if (procEntry->AttributesMask & PROC_ATTR_USE_STACKS_FOR_CHARGES)
1781 {
1782 ModStackAmount(-1);
1783 }
1784 else if (IsUsingCharges())
1785 {
1786 if (!GetCharges())
1787 Remove();
1788 }
1789}
@ PROC_ATTR_USE_STACKS_FOR_CHARGES
Definition: SpellMgr.h:301
bool ModStackAmount(int32 num, AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT, bool resetPeriodicTimer=true)
virtual void Remove(AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)=0
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Create()

Aura * Aura::Create ( AuraCreateInfo createInfo)
static

Definition at line 390 of file SpellAuras.cpp.

391{
392 // try to get caster of aura
393 if (!createInfo.CasterGUID.IsEmpty())
394 {
395 if (createInfo.CasterGUID.IsUnit())
396 {
397 if (createInfo._owner->GetGUID() == createInfo.CasterGUID)
398 createInfo.Caster = createInfo._owner->ToUnit();
399 else
400 createInfo.Caster = ObjectAccessor::GetUnit(*createInfo._owner, createInfo.CasterGUID);
401 }
402 }
403 else if (createInfo.Caster)
404 createInfo.CasterGUID = createInfo.Caster->GetGUID();
405
406 // check if aura can be owned by owner
407 if (createInfo._owner->isType(TYPEMASK_UNIT))
408 if (!createInfo._owner->IsInWorld() || createInfo._owner->ToUnit()->IsDuringRemoveFromWorld())
409 // owner not in world so don't allow to own not self cast single target auras
410 if (createInfo.CasterGUID != createInfo._owner->GetGUID() && createInfo._spellInfo->IsSingleTarget())
411 return nullptr;
412
413 Aura* aura = nullptr;
414 switch (createInfo._owner->GetTypeId())
415 {
416 case TYPEID_UNIT:
417 case TYPEID_PLAYER:
418 {
419 aura = new UnitAura(createInfo);
420
421 // aura can be removed in Unit::_AddAura call
422 if (aura->IsRemoved())
423 return nullptr;
424
425 // add owner
426 uint32 effMask = createInfo._auraEffectMask;
427 if (createInfo._targetEffectMask)
428 effMask = createInfo._targetEffectMask;
429
430 effMask = Aura::BuildEffectMaskForOwner(createInfo._spellInfo, effMask, createInfo._owner);
431 ASSERT_NODEBUGINFO(effMask);
432
433 Unit* unit = createInfo._owner->ToUnit();
434 aura->ToUnitAura()->AddStaticApplication(unit, effMask);
435 break;
436 }
438 createInfo._auraEffectMask = Aura::BuildEffectMaskForOwner(createInfo._spellInfo, createInfo._auraEffectMask, createInfo._owner);
440
441 aura = new DynObjAura(createInfo);
442 break;
443 default:
444 ABORT();
445 return nullptr;
446 }
447
448 // scripts, etc.
449 if (aura->IsRemoved())
450 return nullptr;
451
452 return aura;
453}
@ TYPEMASK_UNIT
Definition: ObjectGuid.h:60
UnitAura * ToUnitAura()
Definition: SpellAuras.h:293
bool IsRemoved() const
Definition: SpellAuras.h:204
static uint32 BuildEffectMaskForOwner(SpellInfo const *spellProto, uint32 availableEffectMask, WorldObject *owner)
Definition: SpellAuras.cpp:307
bool IsUnit() const
Definition: ObjectGuid.h:325
bool isType(uint16 mask) const
Definition: Object.h:173
bool IsSingleTarget() const
Definition: SpellInfo.cpp:1886
void AddStaticApplication(Unit *target, uint32 effMask)
TC_GAME_API Unit * GetUnit(WorldObject const &, ObjectGuid const &guid)
SpellInfo const * _spellInfo
ObjectGuid CasterGUID
WorldObject * _owner
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ DropCharge()

bool Aura::DropCharge ( AuraRemoveMode  removeMode = AURA_REMOVE_BY_DEFAULT)
inline

Definition at line 184 of file SpellAuras.h.

184{ return ModCharges(-1, removeMode); }
bool ModCharges(int32 num, AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
Definition: SpellAuras.cpp:971
+ Here is the caller graph for this function:

◆ DropChargeDelayed()

void Aura::DropChargeDelayed ( uint32  delay,
AuraRemoveMode  removeMode = AURA_REMOVE_BY_DEFAULT 
)

Definition at line 1000 of file SpellAuras.cpp.

1001{
1002 // aura is already during delayed charge drop
1003 if (m_dropEvent)
1004 return;
1005 // only units have events
1006 Unit* owner = m_owner->ToUnit();
1007 if (!owner)
1008 return;
1009
1010 m_dropEvent = new ChargeDropEvent(this, removeMode);
1012}
void AddEvent(BasicEvent *event, Milliseconds e_time, bool set_addtime=true)
Milliseconds CalculateTime(Milliseconds t_offset) const
EventProcessor m_Events
Definition: Object.h:757
+ Here is the call graph for this function:

◆ EffectTypeNeedsSendingAmount()

bool Aura::EffectTypeNeedsSendingAmount ( AuraType  type)
static

Definition at line 1263 of file SpellAuras.cpp.

1264{
1265 switch (type)
1266 {
1273 return true;
1274 default:
1275 break;
1276 }
1277
1278 return false;
1279}
@ SPELL_AURA_CHARGE_RECOVERY_MOD
@ SPELL_AURA_OVERRIDE_ACTIONBAR_SPELLS_TRIGGERED
@ SPELL_AURA_MOD_SPELL_CATEGORY_COOLDOWN
@ SPELL_AURA_CHARGE_RECOVERY_MULTIPLIER
@ SPELL_AURA_MOD_MAX_CHARGES
@ SPELL_AURA_OVERRIDE_ACTIONBAR_SPELLS
+ Here is the caller graph for this function:

◆ FillTargetMap()

virtual void Aura::FillTargetMap ( std::unordered_map< Unit *, uint32 > &  targets,
Unit caster 
)
pure virtual

Implemented in UnitAura, and DynObjAura.

+ Here is the caller graph for this function:

◆ GenerateKey()

AuraKey Aura::GenerateKey ( uint32 recalculateMask) const

Fills a helper structure containing aura primary key for character_aura, character_aura_effect, pet_aura, pet_aura_effect tables.

Parameters
[out]recalculateMaskMask of effects that can be recalculated to store in database - not part of aura key.
Returns
Aura key.

Definition at line 1211 of file SpellAuras.cpp.

1212{
1213 AuraKey key;
1214 key.Caster = GetCasterGUID();
1215 key.Item = GetCastItemGUID();
1216 key.SpellId = GetId();
1217 key.EffectMask = 0;
1218 recalculateMask = 0;
1219 for (uint32 i = 0; i < _effects.size(); ++i)
1220 {
1221 if (AuraEffect const* effect = _effects[i])
1222 {
1223 key.EffectMask |= 1 << i;
1224 if (effect->CanBeRecalculated())
1225 recalculateMask |= 1 << i;
1226 }
1227 }
1228
1229 return key;
1230}
uint32 SpellId
Definition: SpellAuras.h:105
ObjectGuid Caster
Definition: SpellAuras.h:103
ObjectGuid Item
Definition: SpellAuras.h:104
uint32 EffectMask
Definition: SpellAuras.h:106
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetApplicationMap()

ApplicationMap const & Aura::GetApplicationMap ( )
inline

Definition at line 233 of file SpellAuras.h.

233{ return m_applications; }
+ Here is the caller graph for this function:

◆ GetApplicationOfTarget() [1/2]

AuraApplication * Aura::GetApplicationOfTarget ( ObjectGuid  guid)

Definition at line 1323 of file SpellAuras.cpp.

1324{
1326}
auto MapGetValuePtr(M &map, typename M::key_type const &key)
Definition: MapUtils.h:29
+ Here is the call graph for this function:

◆ GetApplicationOfTarget() [2/2]

AuraApplication const * Aura::GetApplicationOfTarget ( ObjectGuid  guid) const

Definition at line 1318 of file SpellAuras.cpp.

1319{
1321}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetApplicationVector()

void Aura::GetApplicationVector ( std::vector< AuraApplication * > &  applications) const

Definition at line 1307 of file SpellAuras.cpp.

1308{
1309 for (auto const& applicationPair : m_applications)
1310 {
1311 if (!applicationPair.second->GetEffectMask())
1312 continue;
1313
1314 applications.push_back(applicationPair.second);
1315 }
1316}
+ Here is the caller graph for this function:

◆ GetApplyTime()

time_t Aura::GetApplyTime ( ) const
inline

Definition at line 166 of file SpellAuras.h.

166{ return m_applyTime; }
+ Here is the caller graph for this function:

◆ GetAuraEffects()

AuraEffectVector const & Aura::GetAuraEffects ( ) const
inline

Definition at line 307 of file SpellAuras.h.

307{ return _effects; }
+ Here is the caller graph for this function:

◆ GetCastDifficulty()

Difficulty Aura::GetCastDifficulty ( ) const
inline

Definition at line 135 of file SpellAuras.h.

135{ return m_castDifficulty; }
+ Here is the caller graph for this function:

◆ GetCaster()

Unit * Aura::GetCaster ( ) const

Definition at line 513 of file SpellAuras.cpp.

514{
515 if (GetOwner()->GetGUID() == GetCasterGUID())
516 return GetUnitOwner();
517
519}
Unit * GetUnitOwner() const
Definition: SpellAuras.h:146
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetCasterGUID()

ObjectGuid Aura::GetCasterGUID ( ) const
inline

Definition at line 138 of file SpellAuras.h.

138{ return m_casterGuid; }
+ Here is the caller graph for this function:

◆ GetCasterLevel()

uint8 Aura::GetCasterLevel ( ) const
inline

Definition at line 194 of file SpellAuras.h.

194{ return m_casterLevel; }
+ Here is the caller graph for this function:

◆ GetCastId()

ObjectGuid Aura::GetCastId ( ) const
inline

Definition at line 137 of file SpellAuras.h.

137{ return m_castId; }
+ Here is the caller graph for this function:

◆ GetCastItemGUID()

ObjectGuid Aura::GetCastItemGUID ( ) const
inline

Definition at line 139 of file SpellAuras.h.

139{ return m_castItemGuid; }
+ Here is the caller graph for this function:

◆ GetCastItemId()

uint32 Aura::GetCastItemId ( ) const
inline

Definition at line 140 of file SpellAuras.h.

140{ return m_castItemId; }
+ Here is the caller graph for this function:

◆ GetCastItemLevel()

int32 Aura::GetCastItemLevel ( ) const
inline

Definition at line 141 of file SpellAuras.h.

141{ return m_castItemLevel; }
+ Here is the caller graph for this function:

◆ GetCharges()

uint8 Aura::GetCharges ( ) const
inline

Definition at line 179 of file SpellAuras.h.

179{ return m_procCharges; }
+ Here is the caller graph for this function:

◆ GetDebugInfo()

std::string Aura::GetDebugInfo ( ) const
virtual

Definition at line 2447 of file SpellAuras.cpp.

2448{
2449 std::stringstream sstr;
2450 sstr << std::boolalpha
2451 << "Id: " << GetId() << " Name: '" << (*GetSpellInfo()->SpellName)[sWorld->GetDefaultDbcLocale()] << "' Caster: " << GetCasterGUID().ToString()
2452 << "\nOwner: " << (GetOwner() ? GetOwner()->GetDebugInfo() : "NULL");
2453 return sstr.str();
2454}
LocalizedString const * SpellName
Definition: SpellInfo.h:403
std::string GetDebugInfo() const override
Definition: Object.cpp:3757
#define sWorld
Definition: World.h:931
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetDuration()

int32 Aura::GetDuration ( ) const
inline

Definition at line 172 of file SpellAuras.h.

172{ return m_duration; }
+ Here is the caller graph for this function:

◆ GetDynobjOwner()

DynamicObject * Aura::GetDynobjOwner ( ) const
inline

Definition at line 147 of file SpellAuras.h.

static DynamicObject * ToDynObject(Object *o)
Definition: Object.h:230
+ Here is the caller graph for this function:

◆ GetEffect()

AuraEffect * Aura::GetEffect ( uint32  index) const

Definition at line 529 of file SpellAuras.cpp.

530{
531 if (index >= _effects.size())
532 return nullptr;
533
534 return _effects[index];
535}
+ Here is the caller graph for this function:

◆ GetEffectMask()

uint32 Aura::GetEffectMask ( ) const

Definition at line 1298 of file SpellAuras.cpp.

1299{
1300 uint32 effMask = 0;
1301 for (AuraEffect* aurEff : GetAuraEffects())
1302 if (aurEff)
1303 effMask |= 1 << aurEff->GetEffIndex();
1304 return effMask;
1305}
AuraEffectVector const & GetAuraEffects() const
Definition: SpellAuras.h:307
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetId()

uint32 Aura::GetId ( ) const
inline

Definition at line 134 of file SpellAuras.h.

134{ return GetSpellInfo()->Id; }
+ Here is the caller graph for this function:

◆ GetMaxDuration()

int32 Aura::GetMaxDuration ( ) const
inline

Definition at line 167 of file SpellAuras.h.

167{ return m_maxDuration; }
+ Here is the caller graph for this function:

◆ GetOwner()

WorldObject * Aura::GetOwner ( ) const
inline

Definition at line 145 of file SpellAuras.h.

145{ return m_owner; }
+ Here is the caller graph for this function:

◆ GetProcEffectMask()

uint32 Aura::GetProcEffectMask ( AuraApplication aurApp,
ProcEventInfo eventInfo,
TimePoint  now 
) const
Todo:
Todo:
this needs to be unified for all kinds of auras

Definition at line 1791 of file SpellAuras.cpp.

1792{
1793 SpellProcEntry const* procEntry = sSpellMgr->GetSpellProcEntry(GetSpellInfo());
1794 // only auras with spell proc entry can trigger proc
1795 if (!procEntry)
1796 return 0;
1797
1798 // check spell triggering us
1799 if (Spell const* spell = eventInfo.GetProcSpell())
1800 {
1801 // Do not allow auras to proc from effect triggered from itself
1802 if (spell->IsTriggeredByAura(m_spellInfo))
1803 return 0;
1804
1805 // check if aura can proc when spell is triggered (exception for hunter auto shot & wands)
1807 if (spell->IsTriggered() && !spell->GetSpellInfo()->HasAttribute(SPELL_ATTR3_NOT_A_PROC))
1808 return 0;
1809
1810 if (spell->m_CastItem && (procEntry->AttributesMask & PROC_ATTR_CANT_PROC_FROM_ITEM_CAST))
1811 return 0;
1812
1813 if (spell->GetSpellInfo()->HasAttribute(SPELL_ATTR4_SUPPRESS_WEAPON_PROCS) && GetSpellInfo()->HasAttribute(SPELL_ATTR6_AURA_IS_WEAPON_PROC))
1814 return 0;
1815
1817 return 0;
1818
1819 if (eventInfo.GetTypeMask() & TAKEN_HIT_PROC_FLAG_MASK)
1820 {
1821 if (spell->GetSpellInfo()->HasAttribute(SPELL_ATTR3_SUPPRESS_TARGET_PROCS)
1823 return 0;
1824 }
1825 else
1826 {
1827 if (spell->GetSpellInfo()->HasAttribute(SPELL_ATTR3_SUPPRESS_CASTER_PROCS)
1828 && !spell->GetSpellInfo()->HasAttribute(SPELL_ATTR12_ENABLE_PROCS_FROM_SUPPRESSED_CASTER_PROCS)
1830 return 0;
1831 }
1832 }
1833
1834 // check don't break stealth attr present
1836 {
1837 if (SpellInfo const* spellInfo = eventInfo.GetSpellInfo())
1838 if (spellInfo->HasAttribute(SPELL_ATTR0_CU_DONT_BREAK_STEALTH))
1839 return 0;
1840 }
1841
1842 // check if we have charges to proc with
1843 if (IsUsingCharges())
1844 {
1845 if (!GetCharges())
1846 return 0;
1847
1848 if (procEntry->AttributesMask & PROC_ATTR_REQ_SPELLMOD)
1849 if (Spell const* spell = eventInfo.GetProcSpell())
1850 if (!spell->m_appliedMods.count(const_cast<Aura*>(this)))
1851 return 0;
1852 }
1853
1854 // check proc cooldown
1855 if (IsProcOnCooldown(now))
1856 return 0;
1857
1858 // do checks against db data
1859 if (!SpellMgr::CanSpellTriggerProcOnEvent(*procEntry, eventInfo))
1860 return 0;
1861
1862 // do checks using conditions table
1863 if (!sConditionMgr->IsObjectMeetingNotGroupedConditions(CONDITION_SOURCE_TYPE_SPELL_PROC, GetId(), eventInfo.GetActor(), eventInfo.GetActionTarget()))
1864 return 0;
1865
1866 // AuraScript Hook
1867 bool check = const_cast<Aura*>(this)->CallScriptCheckProcHandlers(aurApp, eventInfo);
1868 if (!check)
1869 return 0;
1870
1871 // At least one effect has to pass checks to proc aura
1872 uint32 procEffectMask = aurApp->GetEffectMask();
1873 for (uint32 i = 0; i < MAX_SPELL_EFFECTS; ++i)
1874 if (procEffectMask & (1u << i))
1875 if ((procEntry->DisableEffectsMask & (1u << i)) || !GetEffect(i)->CheckEffectProc(aurApp, eventInfo))
1876 procEffectMask &= ~(1u << i);
1877
1878 if (!procEffectMask)
1879 return 0;
1880
1882 // do allow additional requirements for procs
1883 // this is needed because this is the last moment in which you can prevent aura charge drop on proc
1884 // and possibly a way to prevent default checks (if there're going to be any)
1885
1886 // Check if current equipment meets aura requirements
1887 // do that only for passive spells
1889 Unit* target = aurApp->GetTarget();
1890 if (IsPassive() && target->GetTypeId() == TYPEID_PLAYER && GetSpellInfo()->EquippedItemClass != -1)
1891 {
1893 {
1894 Item* item = nullptr;
1896 {
1897 if (target->ToPlayer()->IsInFeralForm())
1898 return 0;
1899
1900 if (DamageInfo const* damageInfo = eventInfo.GetDamageInfo())
1901 {
1902 if (damageInfo->GetAttackType() != OFF_ATTACK)
1904 else
1906 }
1907 }
1909 {
1910 // Check if player is wearing shield
1912 }
1913
1914 if (!item || item->IsBroken() || !item->IsFitToSpellRequirements(GetSpellInfo()))
1915 return 0;
1916 }
1917 }
1918
1920 if (!target->IsOutdoors())
1921 return 0;
1922
1924 if (target->GetGUID() != GetCasterGUID())
1925 return 0;
1926
1928 if (!target->IsStandState())
1929 return 0;
1930
1931 bool success = roll_chance_f(CalcProcChance(*procEntry, eventInfo));
1932
1933 const_cast<Aura*>(this)->SetLastProcAttemptTime(now);
1934
1935 if (success)
1936 return procEffectMask;
1937
1938 return 0;
1939}
#define sConditionMgr
Definition: ConditionMgr.h:365
@ CONDITION_SOURCE_TYPE_SPELL_PROC
Definition: ConditionMgr.h:178
#define MAX_SPELL_EFFECTS
Definition: DBCEnums.h:1953
@ ITEM_CLASS_ARMOR
Definition: ItemTemplate.h:424
@ ITEM_CLASS_WEAPON
Definition: ItemTemplate.h:422
@ EQUIPMENT_SLOT_MAINHAND
Definition: Player.h:646
@ EQUIPMENT_SLOT_OFFHAND
Definition: Player.h:647
#define INVENTORY_SLOT_BAG_0
Definition: Player.h:625
bool roll_chance_f(float chance)
Definition: Random.h:53
@ SPELL_ATTR7_CAN_PROC_FROM_SUPPRESSED_TARGET_PROCS
@ SPELL_ATTR3_NOT_A_PROC
@ SPELL_ATTR3_SUPPRESS_TARGET_PROCS
@ SPELL_ATTR3_ONLY_PROC_ON_CASTER
@ SPELL_ATTR3_NO_PROC_EQUIP_REQUIREMENT
@ SPELL_ATTR3_CAN_PROC_FROM_PROCS
@ SPELL_ATTR3_ONLY_PROC_OUTDOORS
@ SPELL_ATTR3_SUPPRESS_CASTER_PROCS
@ OFF_ATTACK
@ SPELL_ATTR12_ONLY_PROC_FROM_CLASS_ABILITIES
@ SPELL_ATTR12_CAN_PROC_FROM_SUPPRESSED_CASTER_PROCS
@ SPELL_ATTR12_ENABLE_PROCS_FROM_SUPPRESSED_CASTER_PROCS
@ SPELL_ATTR13_ALLOW_CLASS_ABILITY_PROCS
@ SPELL_ATTR4_SUPPRESS_WEAPON_PROCS
@ SPELL_ATTR4_ALLOW_PROC_WHILE_SITTING
@ SPELL_ATTR6_AURA_IS_WEAPON_PROC
@ SPELL_AURA_MOD_STEALTH
@ SPELL_ATTR0_CU_DONT_BREAK_STEALTH
Definition: SpellInfo.h:154
@ PROC_ATTR_CANT_PROC_FROM_ITEM_CAST
Definition: SpellMgr.h:304
@ PROC_ATTR_TRIGGERED_CAN_PROC
Definition: SpellMgr.h:298
@ PROC_ATTR_REQ_SPELLMOD
Definition: SpellMgr.h:300
@ AUTO_ATTACK_PROC_FLAG_MASK
Definition: SpellMgr.h:191
@ TAKEN_HIT_PROC_FLAG_MASK
Definition: SpellMgr.h:218
uint32 GetEffectMask() const
Definition: SpellAuras.h:81
bool CheckEffectProc(AuraApplication *aurApp, ProcEventInfo &eventInfo) const
void SetLastProcAttemptTime(TimePoint lastProcAttemptTime)
Definition: SpellAuras.h:257
AuraEffect * GetEffect(uint32 index) const
Definition: SpellAuras.cpp:529
bool CallScriptCheckProcHandlers(AuraApplication const *aurApp, ProcEventInfo &eventInfo)
float CalcProcChance(SpellProcEntry const &procEntry, ProcEventInfo &eventInfo) const
bool IsProcOnCooldown(TimePoint now) const
bool IsBroken() const
Definition: Item.h:257
bool IsFitToSpellRequirements(SpellInfo const *spellInfo) const
Definition: Item.cpp:1387
Item * GetUseableItemByPos(uint8 bag, uint8 slot) const
Definition: Player.cpp:9575
Unit * GetActionTarget() const
Definition: Unit.h:489
Spell const * GetProcSpell() const
Definition: Unit.h:503
SpellInfo const * GetSpellInfo() const
Definition: Unit.cpp:278
ProcFlagsInit GetTypeMask() const
Definition: Unit.h:492
int32 EquippedItemClass
Definition: SpellInfo.h:396
bool HasAura(AuraType aura) const
Definition: SpellInfo.cpp:1400
static bool CanSpellTriggerProcOnEvent(SpellProcEntry const &procEntry, ProcEventInfo &eventInfo)
Definition: SpellMgr.cpp:513
Definition: Spell.h:254
bool IsStandState() const
Definition: Unit.cpp:10028
bool IsInFeralForm() const
Definition: Unit.cpp:8845
bool IsOutdoors() const
Definition: Object.h:531
uint32 DisableEffectsMask
Definition: SpellMgr.h:326
ProcAttributes AttributesMask
Definition: SpellMgr.h:325
+ Here is the call graph for this function:

◆ GetScript()

template<class Script >
Script * Aura::GetScript ( ) const
inline

Definition at line 300 of file SpellAuras.h.

301 {
302 return static_cast<Script*>(GetScriptByType(typeid(Script)));
303 }
AuraScript * GetScriptByType(std::type_info const &type) const
Definition: SpellAuras.cpp:479
+ Here is the caller graph for this function:

◆ GetScriptByType()

AuraScript * Aura::GetScriptByType ( std::type_info const &  type) const
private

Definition at line 479 of file SpellAuras.cpp.

480{
481 for (AuraScript* script : m_loadedScripts)
482 if (typeid(*script) == type)
483 return script;
484 return nullptr;
485}

◆ GetSpellInfo()

SpellInfo const * Aura::GetSpellInfo ( ) const
inline

Definition at line 133 of file SpellAuras.h.

133{ return m_spellInfo; }
+ Here is the caller graph for this function:

◆ GetSpellVisual()

SpellCastVisual Aura::GetSpellVisual ( ) const
inline

Definition at line 142 of file SpellAuras.h.

142{ return m_spellVisual; }
+ Here is the caller graph for this function:

◆ GetStackAmount()

uint8 Aura::GetStackAmount ( ) const
inline

Definition at line 188 of file SpellAuras.h.

188{ return m_stackAmount; }
+ Here is the caller graph for this function:

◆ GetType()

AuraObjectType Aura::GetType ( ) const

Definition at line 537 of file SpellAuras.cpp.

538{
540}
@ UNIT_AURA_TYPE
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetUnitOwner()

Unit * Aura::GetUnitOwner ( ) const
inline

Definition at line 146 of file SpellAuras.h.

146{ ASSERT(GetType() == UNIT_AURA_TYPE); return m_owner->ToUnit(); }
+ Here is the caller graph for this function:

◆ GetWorldObjectCaster()

WorldObject * Aura::GetWorldObjectCaster ( ) const

Definition at line 521 of file SpellAuras.cpp.

522{
523 if (GetCasterGUID().IsUnit())
524 return GetCaster();
525
527}
TC_GAME_API WorldObject * GetWorldObject(WorldObject const &, ObjectGuid const &)
+ Here is the call graph for this function:

◆ HandleAllEffects()

void Aura::HandleAllEffects ( AuraApplication aurApp,
uint8  mode,
bool  apply 
)

Definition at line 1290 of file SpellAuras.cpp.

1291{
1292 ASSERT (!IsRemoved());
1293 for (AuraEffect* effect : GetAuraEffects())
1294 if (effect && !IsRemoved())
1295 effect->HandleEffect(aurApp, mode, apply);
1296}
void apply(T *val)
Definition: ByteConverter.h:41
+ Here is the call graph for this function:

◆ HandleAuraSpecificMods()

void Aura::HandleAuraSpecificMods ( AuraApplication const *  aurApp,
Unit caster,
bool  apply,
bool  onReapply 
)

Definition at line 1340 of file SpellAuras.cpp.

1341{
1342 Unit* target = aurApp->GetTarget();
1343 AuraRemoveMode removeMode = aurApp->GetRemoveMode();
1344 // handle spell_area table
1345 SpellAreaForAreaMapBounds saBounds = sSpellMgr->GetSpellAreaForAuraMapBounds(GetId());
1346 if (saBounds.first != saBounds.second)
1347 {
1348 uint32 zone, area;
1349 target->GetZoneAndAreaId(zone, area);
1350
1351 for (SpellAreaForAreaMap::const_iterator itr = saBounds.first; itr != saBounds.second; ++itr)
1352 {
1353 // some auras remove at aura remove
1354 if (itr->second->flags & SPELL_AREA_FLAG_AUTOREMOVE && !itr->second->IsFitToRequirements(target->ToPlayer(), zone, area))
1355 target->RemoveAurasDueToSpell(itr->second->spellId);
1356 // some auras applied at aura apply
1357 else if (itr->second->flags & SPELL_AREA_FLAG_AUTOCAST)
1358 {
1359 if (!target->HasAura(itr->second->spellId))
1360 target->CastSpell(target, itr->second->spellId, CastSpellExtraArgs(TRIGGERED_FULL_MASK)
1361 .SetOriginalCastId(GetCastId()));
1362 }
1363 }
1364 }
1365
1366 // handle spell_linked_spell table
1367 if (!onReapply)
1368 {
1369 // apply linked auras
1370 if (apply)
1371 {
1372 if (std::vector<int32> const* spellTriggered = sSpellMgr->GetSpellLinked(SPELL_LINK_AURA, GetId()))
1373 {
1374 for (std::vector<int32>::const_iterator itr = spellTriggered->begin(); itr != spellTriggered->end(); ++itr)
1375 {
1376 if (*itr < 0)
1377 target->ApplySpellImmune(GetId(), IMMUNITY_ID, -(*itr), true);
1378 else if (caster)
1379 caster->AddAura(*itr, target);
1380 }
1381 }
1382 }
1383 else
1384 {
1385 // remove linked auras
1386 if (std::vector<int32> const* spellTriggered = sSpellMgr->GetSpellLinked(SPELL_LINK_REMOVE, GetId()))
1387 {
1388 for (std::vector<int32>::const_iterator itr = spellTriggered->begin(); itr != spellTriggered->end(); ++itr)
1389 {
1390 if (*itr < 0)
1391 target->RemoveAurasDueToSpell(-(*itr));
1392 else if (removeMode != AURA_REMOVE_BY_DEATH)
1393 target->CastSpell(target, *itr, CastSpellExtraArgs(TRIGGERED_FULL_MASK)
1394 .SetOriginalCaster(GetCasterGUID())
1395 .SetOriginalCastId(GetCastId()));
1396 }
1397 }
1398 if (std::vector<int32> const* spellTriggered = sSpellMgr->GetSpellLinked(SPELL_LINK_AURA, GetId()))
1399 {
1400 for (std::vector<int32>::const_iterator itr = spellTriggered->begin(); itr != spellTriggered->end(); ++itr)
1401 {
1402 if (*itr < 0)
1403 target->ApplySpellImmune(GetId(), IMMUNITY_ID, -(*itr), false);
1404 else
1405 target->RemoveAura(*itr, GetCasterGUID(), 0, removeMode);
1406 }
1407 }
1408 }
1409 }
1410 else if (apply)
1411 {
1412 // modify stack amount of linked auras
1413 if (std::vector<int32> const* spellTriggered = sSpellMgr->GetSpellLinked(SPELL_LINK_AURA, GetId()))
1414 {
1415 for (std::vector<int32>::const_iterator itr = spellTriggered->begin(); itr != spellTriggered->end(); ++itr)
1416 if (*itr > 0)
1417 if (Aura* triggeredAura = target->GetAura(*itr, GetCasterGUID()))
1418 triggeredAura->ModStackAmount(GetStackAmount() - triggeredAura->GetStackAmount());
1419 }
1420 }
1421
1422 // mods at aura apply
1423 if (apply)
1424 {
1425 switch (GetSpellInfo()->SpellFamilyName)
1426 {
1428 switch (GetId())
1429 {
1430 case 33572: // Gronn Lord's Grasp, becomes stoned
1431 if (GetStackAmount() >= 5 && !target->HasAura(33652))
1432 target->CastSpell(target, 33652, CastSpellExtraArgs(TRIGGERED_FULL_MASK)
1433 .SetOriginalCastId(GetCastId()));
1434 break;
1435 case 50836: //Petrifying Grip, becomes stoned
1436 if (GetStackAmount() >= 5 && !target->HasAura(50812))
1437 target->CastSpell(target, 50812, CastSpellExtraArgs(TRIGGERED_FULL_MASK)
1438 .SetOriginalCastId(GetCastId()));
1439 break;
1440 case 60970: // Heroic Fury (remove Intercept cooldown)
1441 if (target->GetTypeId() == TYPEID_PLAYER)
1442 target->GetSpellHistory()->ResetCooldown(20252, true);
1443 break;
1444 }
1445 break;
1446 case SPELLFAMILY_DRUID:
1447 if (!caster)
1448 break;
1449 // Rejuvenation
1450 if (GetSpellInfo()->SpellFamilyFlags[0] & 0x10 && GetEffect(EFFECT_0))
1451 {
1452 // Druid T8 Restoration 4P Bonus
1453 if (caster->HasAura(64760))
1454 {
1456 args.AddSpellMod(SPELLVALUE_BASE_POINT0, GetEffect(EFFECT_0)->GetAmount());
1457 caster->CastSpell(target, 64801, args);
1458 }
1459 }
1460 break;
1461 }
1462 }
1463 // mods at aura remove
1464 else
1465 {
1466 switch (GetSpellInfo()->SpellFamilyName)
1467 {
1468 case SPELLFAMILY_MAGE:
1469 switch (GetId())
1470 {
1471 case 66: // Invisibility
1472 if (removeMode != AURA_REMOVE_BY_EXPIRE)
1473 break;
1474 target->CastSpell(target, 32612, GetEffect(1));
1475 break;
1476 default:
1477 break;
1478 }
1479 break;
1480 case SPELLFAMILY_PRIEST:
1481 if (!caster)
1482 break;
1483 // Power word: shield
1484 if (removeMode == AURA_REMOVE_BY_ENEMY_SPELL && GetSpellInfo()->SpellFamilyFlags[0] & 0x00000001)
1485 {
1486 // Rapture
1487 if (Aura const* aura = caster->GetAuraOfRankedSpell(47535))
1488 {
1489 // check cooldown
1490 if (caster->GetTypeId() == TYPEID_PLAYER)
1491 {
1492 if (caster->GetSpellHistory()->HasCooldown(aura->GetSpellInfo()))
1493 {
1494 // This additional check is needed to add a minimal delay before cooldown in in effect
1495 // to allow all bubbles broken by a single damage source proc mana return
1496 if (caster->GetSpellHistory()->GetRemainingCooldown(aura->GetSpellInfo()) <= 11s)
1497 break;
1498 }
1499 else // and add if needed
1500 caster->GetSpellHistory()->AddCooldown(aura->GetId(), 0, 12s);
1501 }
1502
1503 // effect on caster
1504 if (AuraEffect const* aurEff = aura->GetEffect(0))
1505 {
1506 float multiplier = float(aurEff->GetAmount());
1508 args.SetOriginalCastId(GetCastId());
1509 args.AddSpellMod(SPELLVALUE_BASE_POINT0, CalculatePct(caster->GetMaxPower(POWER_MANA), multiplier));
1510 caster->CastSpell(caster, 47755, args);
1511 }
1512 }
1513 }
1514 break;
1515 case SPELLFAMILY_ROGUE:
1516 // Remove Vanish on stealth remove
1517 if (GetId() == 1784)
1518 target->RemoveAurasWithFamily(SPELLFAMILY_ROGUE, flag128(0x0000800, 0, 0, 0), target->GetGUID());
1519 break;
1520 }
1521 }
1522
1523 // mods at aura apply or remove
1524 switch (GetSpellInfo()->SpellFamilyName)
1525 {
1526 case SPELLFAMILY_HUNTER:
1527 switch (GetId())
1528 {
1529 case 19574: // Bestial Wrath
1530 // The Beast Within cast on owner if talent present
1531 if (Unit* owner = target->GetOwner())
1532 {
1533 // Search talent
1534 if (owner->HasAura(34692))
1535 {
1536 if (apply)
1537 owner->CastSpell(owner, 34471, GetEffect(0));
1538 else
1539 owner->RemoveAurasDueToSpell(34471);
1540 }
1541 }
1542 break;
1543 }
1544 break;
1546 switch (GetId())
1547 {
1548 case 31842: // Divine Favor
1549 // Item - Paladin T10 Holy 2P Bonus
1550 if (target->HasAura(70755))
1551 {
1552 if (apply)
1553 target->CastSpell(target, 71166, CastSpellExtraArgs(TRIGGERED_FULL_MASK)
1554 .SetOriginalCastId(GetCastId()));
1555 else
1556 target->RemoveAurasDueToSpell(71166);
1557 }
1558 break;
1559 }
1560 break;
1561 }
1562}
@ EFFECT_0
Definition: SharedDefines.h:30
@ IMMUNITY_ID
@ POWER_MANA
@ SPELLFAMILY_PRIEST
@ SPELLFAMILY_MAGE
@ SPELLFAMILY_GENERIC
@ SPELLFAMILY_PALADIN
@ SPELLFAMILY_HUNTER
@ SPELLFAMILY_ROGUE
@ SPELLFAMILY_DRUID
AuraRemoveMode
@ AURA_REMOVE_BY_DEATH
@ AURA_REMOVE_BY_EXPIRE
@ AURA_REMOVE_BY_ENEMY_SPELL
@ TRIGGERED_FULL_MASK
Used when doing CastSpell with triggered == true.
Definition: SpellDefines.h:266
@ SPELLVALUE_BASE_POINT0
Definition: SpellDefines.h:196
std::pair< SpellAreaForAreaMap::const_iterator, SpellAreaForAreaMap::const_iterator > SpellAreaForAreaMapBounds
Definition: SpellMgr.h:557
@ SPELL_LINK_AURA
Definition: SpellMgr.h:128
@ SPELL_LINK_REMOVE
Definition: SpellMgr.h:129
@ SPELL_AREA_FLAG_AUTOREMOVE
Definition: SpellMgr.h:529
@ SPELL_AREA_FLAG_AUTOCAST
Definition: SpellMgr.h:528
T CalculatePct(T base, U pct)
Definition: Util.h:72
ObjectGuid GetCastId() const
Definition: SpellAuras.h:137
uint8 GetStackAmount() const
Definition: SpellAuras.h:188
void AddCooldown(uint32 spellId, uint32 itemId, Duration cooldownDuration)
Definition: SpellHistory.h:107
void ResetCooldown(uint32 spellId, bool update=false)
Duration GetRemainingCooldown(SpellInfo const *spellInfo) const
bool HasCooldown(SpellInfo const *spellInfo, uint32 itemId=0) const
void ApplySpellImmune(uint32 spellId, SpellImmunity op, uint32 type, bool apply)
Definition: Unit.cpp:7819
void RemoveAura(AuraApplicationMap::iterator &i, AuraRemoveMode mode=AURA_REMOVE_BY_DEFAULT)
Definition: Unit.cpp:3666
Aura * AddAura(uint32 spellId, Unit *target)
Definition: Unit.cpp:11541
int32 GetMaxPower(Powers power) const
Definition: Unit.cpp:9346
Aura * GetAura(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, ObjectGuid itemCasterGUID=ObjectGuid::Empty, uint32 reqEffMask=0) const
Definition: Unit.cpp:4541
bool HasAura(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, ObjectGuid itemCasterGUID=ObjectGuid::Empty, uint32 reqEffMask=0) const
Definition: Unit.cpp:4645
Aura * GetAuraOfRankedSpell(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, ObjectGuid itemCasterGUID=ObjectGuid::Empty, uint32 reqEffMask=0) const
Definition: Unit.cpp:4571
void RemoveAurasWithFamily(SpellFamilyNames family, flag128 const &familyFlag, ObjectGuid casterGUID)
Definition: Unit.cpp:4117
void RemoveAurasDueToSpell(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, uint32 reqEffMask=0, AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
Definition: Unit.cpp:3812
ObjectGuid GetTarget() const
Definition: Unit.h:1746
SpellCastResult CastSpell(CastSpellTargetArg const &targets, uint32 spellId, CastSpellExtraArgs const &args={ })
Definition: Object.cpp:2884
Unit * GetOwner() const
Definition: Object.cpp:2217
void GetZoneAndAreaId(uint32 &zoneid, uint32 &areaid) const
Definition: Object.h:529
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ HasEffect()

bool Aura::HasEffect ( uint8  effIndex) const
inline

Definition at line 224 of file SpellAuras.h.

224{ return GetEffect(effIndex) != nullptr; }
+ Here is the caller graph for this function:

◆ HasEffectType()

bool Aura::HasEffectType ( AuraType  type) const

Definition at line 1253 of file SpellAuras.cpp.

1254{
1255 for (AuraEffect* effect : GetAuraEffects())
1256 {
1257 if (effect && effect->GetAuraType() == type)
1258 return true;
1259 }
1260 return false;
1261}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ HasMoreThanOneEffectForType()

bool Aura::HasMoreThanOneEffectForType ( AuraType  auraType) const

Definition at line 1090 of file SpellAuras.cpp.

1091{
1092 uint32 count = 0;
1093 for (SpellEffectInfo const& spellEffectInfo : GetSpellInfo()->GetEffects())
1094 if (HasEffect(spellEffectInfo.EffectIndex) && spellEffectInfo.ApplyAuraName == auraType)
1095 ++count;
1096
1097 return count > 1;
1098}
bool HasEffect(uint8 effIndex) const
Definition: SpellAuras.h:224
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ IsAppliedOnTarget()

bool Aura::IsAppliedOnTarget ( ObjectGuid  guid) const

Definition at line 1328 of file SpellAuras.cpp.

1329{
1330 return m_applications.contains(guid);
1331}
+ Here is the caller graph for this function:

◆ IsArea()

bool Aura::IsArea ( ) const

Definition at line 1100 of file SpellAuras.cpp.

1101{
1102 for (SpellEffectInfo const& spellEffectInfo : GetSpellInfo()->GetEffects())
1103 if (HasEffect(spellEffectInfo.EffectIndex) && spellEffectInfo.IsAreaAuraEffect())
1104 return true;
1105
1106 return false;
1107}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ IsDeathPersistent()

bool Aura::IsDeathPersistent ( ) const

Definition at line 1114 of file SpellAuras.cpp.

1115{
1116 return GetSpellInfo()->IsDeathPersistent();
1117}
bool IsDeathPersistent() const
Definition: SpellInfo.cpp:1658
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ IsExpired()

bool Aura::IsExpired ( ) const
inline

Definition at line 176 of file SpellAuras.h.

176{ return !GetDuration() && !m_dropEvent; }
int32 GetDuration() const
Definition: SpellAuras.h:172
+ Here is the caller graph for this function:

◆ IsPassive()

bool Aura::IsPassive ( ) const

Definition at line 1109 of file SpellAuras.cpp.

1110{
1111 return GetSpellInfo()->IsPassive();
1112}
bool IsPassive() const
Definition: SpellInfo.cpp:1592
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ IsPermanent()

bool Aura::IsPermanent ( ) const
inline

Definition at line 177 of file SpellAuras.h.

177{ return GetMaxDuration() == -1; }
int32 GetMaxDuration() const
Definition: SpellAuras.h:167
+ Here is the caller graph for this function:

◆ IsProcOnCooldown()

bool Aura::IsProcOnCooldown ( TimePoint  now) const

Definition at line 1729 of file SpellAuras.cpp.

1730{
1731 return m_procCooldown > now;
1732}
+ Here is the caller graph for this function:

◆ IsRemoved()

bool Aura::IsRemoved ( ) const
inline

Definition at line 204 of file SpellAuras.h.

204{ return m_isRemoved; }
+ Here is the caller graph for this function:

◆ IsRemovedOnShapeLost()

bool Aura::IsRemovedOnShapeLost ( Unit target) const

Definition at line 1119 of file SpellAuras.cpp.

1120{
1121 return GetCasterGUID() == target->GetGUID()
1125}
@ SPELL_ATTR2_ALLOW_WHILE_NOT_SHAPESHIFTED_CASTER_FORM
@ SPELL_ATTR0_NOT_SHAPESHIFTED
uint64 Stances
Definition: SpellInfo.h:347
+ Here is the call graph for this function:

◆ IsSingleTarget()

bool Aura::IsSingleTarget ( ) const
inline

Definition at line 206 of file SpellAuras.h.

206{return m_isSingleTarget; }
+ Here is the caller graph for this function:

◆ IsSingleTargetWith()

bool Aura::IsSingleTargetWith ( Aura const *  aura) const

Definition at line 1166 of file SpellAuras.cpp.

1167{
1168 // Same spell?
1169 if (GetSpellInfo()->IsRankOf(aura->GetSpellInfo()))
1170 return true;
1171
1173 // spell with single target specific types
1174 switch (spec)
1175 {
1177 if (aura->GetSpellInfo()->GetSpellSpecific() == spec)
1178 return true;
1179 break;
1180 default:
1181 break;
1182 }
1183
1184 return false;
1185}
SpellSpecificType
Definition: SpellInfo.h:119
@ SPELL_SPECIFIC_MAGE_POLYMORPH
Definition: SpellInfo.h:130
SpellSpecificType GetSpellSpecific() const
Definition: SpellInfo.cpp:2624
+ Here is the call graph for this function:

◆ IsUsingCharges()

bool Aura::IsUsingCharges ( ) const
inline

Definition at line 248 of file SpellAuras.h.

248{ return m_isUsingCharges; }
+ Here is the caller graph for this function:

◆ IsUsingStacks()

bool Aura::IsUsingStacks ( ) const

Definition at line 1037 of file SpellAuras.cpp.

1038{
1039 return m_spellInfo->StackAmount > 0 || m_stackAmount > 1;
1040}
+ Here is the caller graph for this function:

◆ LoadScripts()

void Aura::LoadScripts ( )

Definition at line 2019 of file SpellAuras.cpp.

2020{
2021 sScriptMgr->CreateAuraScripts(m_spellInfo->Id, m_loadedScripts, this);
2022 for (AuraScript* script : m_loadedScripts)
2023 {
2024 TC_LOG_DEBUG("spells", "Aura::LoadScripts: Script `{}` for aura `{}` is loaded now", script->GetScriptName(), m_spellInfo->Id);
2025 script->Register();
2026 }
2027}
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:156
#define sScriptMgr
Definition: ScriptMgr.h:1418
+ Here is the caller graph for this function:

◆ ModCharges()

bool Aura::ModCharges ( int32  num,
AuraRemoveMode  removeMode = AURA_REMOVE_BY_DEFAULT 
)

Definition at line 971 of file SpellAuras.cpp.

972{
973 if (IsUsingCharges())
974 {
975 int32 charges = m_procCharges + num;
976 int32 maxCharges = CalcMaxCharges();
977
978 // limit charges (only on charges increase, charges may be changed manually)
979 if ((num > 0) && (charges > int32(maxCharges)))
980 charges = maxCharges;
981 // we're out of charges, remove
982 else if (charges <= 0)
983 {
984 Remove(removeMode);
985 return true;
986 }
987
988 SetCharges(charges);
989 }
990
991 return false;
992}
void SetCharges(uint8 charges)
Definition: SpellAuras.cpp:948
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ModChargesDelayed()

void Aura::ModChargesDelayed ( int32  num,
AuraRemoveMode  removeMode = AURA_REMOVE_BY_DEFAULT 
)

Definition at line 994 of file SpellAuras.cpp.

995{
996 m_dropEvent = nullptr;
997 ModCharges(num, removeMode);
998}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ModStackAmount()

bool Aura::ModStackAmount ( int32  num,
AuraRemoveMode  removeMode = AURA_REMOVE_BY_DEFAULT,
bool  resetPeriodicTimer = true 
)

Definition at line 1052 of file SpellAuras.cpp.

1053{
1054 int32 stackAmount = m_stackAmount + num;
1055 int32 maxStackAmount = int32(CalcMaxStackAmount());
1056
1057 // limit the stack amount (only on stack increase, stack amount may be changed manually)
1058 if ((num > 0) && (stackAmount > maxStackAmount))
1059 {
1060 // not stackable aura - set stack amount to 1
1062 stackAmount = 1;
1063 else
1064 stackAmount = m_spellInfo->StackAmount;
1065 }
1066 // we're out of stacks, remove
1067 else if (stackAmount <= 0)
1068 {
1069 Remove(removeMode);
1070 return true;
1071 }
1072
1074
1075 // Update stack amount
1076 SetStackAmount(stackAmount);
1077
1078 if (refresh)
1079 {
1080 RefreshTimers(resetPeriodicTimer);
1081
1082 // reset charges
1084 }
1085
1087 return false;
1088}
@ SPELL_ATTR5_AURA_UNIQUE_PER_CASTER
@ SPELL_ATTR1_AURA_UNIQUE
void SetStackAmount(uint8 num)
void RefreshTimers(bool resetPeriodicTimer)
Definition: SpellAuras.cpp:926
uint32 CalcMaxStackAmount() const
void SetNeedClientUpdateForTargets() const
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ operator=() [1/2]

Aura & Aura::operator= ( Aura &&  )
delete

◆ operator=() [2/2]

Aura & Aura::operator= ( Aura const &  )
delete

◆ PrepareProcChargeDrop()

void Aura::PrepareProcChargeDrop ( SpellProcEntry const *  procEntry,
ProcEventInfo const &  eventInfo 
)

Definition at line 1767 of file SpellAuras.cpp.

1768{
1769 // take one charge, aura expiration will be handled in Aura::TriggerProcOnEvent (if needed)
1770 if (!(procEntry->AttributesMask & PROC_ATTR_USE_STACKS_FOR_CHARGES) && IsUsingCharges() && (!eventInfo.GetSpellInfo() || !eventInfo.GetSpellInfo()->HasAttribute(SPELL_ATTR6_DO_NOT_CONSUME_RESOURCES)))
1771 {
1772 --m_procCharges;
1774 }
1775}
@ SPELL_ATTR6_DO_NOT_CONSUME_RESOURCES
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ PrepareProcToTrigger()

void Aura::PrepareProcToTrigger ( AuraApplication aurApp,
ProcEventInfo eventInfo,
TimePoint  now 
)

Definition at line 1750 of file SpellAuras.cpp.

1751{
1752 bool prepare = CallScriptPrepareProcHandlers(aurApp, eventInfo);
1753 if (!prepare)
1754 return;
1755
1756 SpellProcEntry const* procEntry = sSpellMgr->GetSpellProcEntry(GetSpellInfo());
1757 ASSERT(procEntry);
1758
1759 PrepareProcChargeDrop(procEntry, eventInfo);
1760
1761 // cooldowns should be added to the whole aura (see 51698 area aura)
1762 AddProcCooldown(procEntry, now);
1763
1765}
void AddProcCooldown(SpellProcEntry const *procEntry, TimePoint now)
bool CallScriptPrepareProcHandlers(AuraApplication const *aurApp, ProcEventInfo &eventInfo)
void PrepareProcChargeDrop(SpellProcEntry const *procEntry, ProcEventInfo const &eventInfo)
void SetLastProcSuccessTime(TimePoint lastProcSuccessTime)
Definition: SpellAuras.h:258
+ Here is the call graph for this function:

◆ RecalculateAmountOfEffects()

void Aura::RecalculateAmountOfEffects ( )

Definition at line 1281 of file SpellAuras.cpp.

1282{
1283 ASSERT (!IsRemoved());
1284 Unit* caster = GetCaster();
1285 for (AuraEffect* effect : GetAuraEffects())
1286 if (effect && !IsRemoved())
1287 effect->RecalculateAmount(caster);
1288}
+ Here is the call graph for this function:

◆ RefreshDuration()

void Aura::RefreshDuration ( bool  withMods = false)

Definition at line 901 of file SpellAuras.cpp.

902{
903 Unit* caster = GetCaster();
904 if (withMods && caster)
905 {
906 int32 duration = m_spellInfo->GetMaxDuration();
907 // Calculate duration of periodics affected by haste.
909 duration = int32(duration * caster->m_unitData->ModCastingSpeed);
910
911 SetMaxDuration(duration);
912 SetDuration(duration);
913 }
914 else
916
917 if (!m_periodicCosts.empty())
919
920 // also reset periodic counters
921 for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
922 if (AuraEffect* aurEff = GetEffect(i))
923 aurEff->ResetTicks();
924}
@ SPELL_ATTR8_HASTE_AFFECTS_DURATION
void SetDuration(int32 duration, bool withMods=false)
Definition: SpellAuras.cpp:890
void SetMaxDuration(int32 duration)
Definition: SpellAuras.h:168
int32 GetMaxDuration() const
Definition: SpellInfo.cpp:3798
UF::UpdateField< UF::UnitData, 0, TYPEID_UNIT > m_unitData
Definition: Unit.h:1791
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ RefreshTimers()

void Aura::RefreshTimers ( bool  resetPeriodicTimer)

Definition at line 926 of file SpellAuras.cpp.

927{
929
930 // Pandemic Mechanic
932 {
933 // Pandemic doesn't reset periodic timer
934 resetPeriodicTimer = false;
935
936 int32 pandemicDuration = CalculatePct(m_maxDuration, 30.f);
937 m_maxDuration = std::max(GetDuration(), std::min(pandemicDuration, GetDuration()) + m_maxDuration);
938 }
939
941
942 Unit* caster = GetCaster();
943 for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
944 if (AuraEffect* aurEff = GetEffect(i))
945 aurEff->CalculatePeriodic(caster, resetPeriodicTimer, false);
946}
@ SPELL_ATTR13_PERIODIC_REFRESH_EXTENDS_DURATION
void RefreshDuration(bool withMods=false)
Definition: SpellAuras.cpp:901
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Remove()

virtual void Aura::Remove ( AuraRemoveMode  removeMode = AURA_REMOVE_BY_DEFAULT)
pure virtual

Implemented in UnitAura, and DynObjAura.

+ Here is the caller graph for this function:

◆ ResetProcCooldown()

void Aura::ResetProcCooldown ( )

Definition at line 1745 of file SpellAuras.cpp.

1746{
1748}
+ Here is the call graph for this function:

◆ SaveCasterInfo()

void Aura::SaveCasterInfo ( Unit caster)

◆ SetCharges()

void Aura::SetCharges ( uint8  charges)

Definition at line 948 of file SpellAuras.cpp.

949{
950 if (m_procCharges == charges)
951 return;
952
953 m_procCharges = charges;
956}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ SetDuration()

void Aura::SetDuration ( int32  duration,
bool  withMods = false 
)

Definition at line 890 of file SpellAuras.cpp.

891{
892 if (withMods)
893 if (Unit* caster = GetCaster())
894 if (Player* modOwner = caster->GetSpellModOwner())
895 modOwner->ApplySpellMod(GetSpellInfo(), SpellModOp::Duration, duration);
896
897 m_duration = duration;
899}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ SetIsSingleTarget()

void Aura::SetIsSingleTarget ( bool  val)
inline

Definition at line 208 of file SpellAuras.h.

208{ m_isSingleTarget = val; }
+ Here is the caller graph for this function:

◆ SetLastProcAttemptTime()

void Aura::SetLastProcAttemptTime ( TimePoint  lastProcAttemptTime)
inline

Definition at line 257 of file SpellAuras.h.

257{ m_lastProcAttemptTime = lastProcAttemptTime; }
+ Here is the caller graph for this function:

◆ SetLastProcSuccessTime()

void Aura::SetLastProcSuccessTime ( TimePoint  lastProcSuccessTime)
inline

Definition at line 258 of file SpellAuras.h.

258{ m_lastProcSuccessTime = lastProcSuccessTime; }
+ Here is the caller graph for this function:

◆ SetLoadedState()

void Aura::SetLoadedState ( int32  maxDuration,
int32  duration,
int32  charges,
uint8  stackAmount,
uint32  recalculateMask,
int32 amount 
)

Definition at line 1232 of file SpellAuras.cpp.

1233{
1234 m_maxDuration = maxDuration;
1235 m_duration = duration;
1236 m_procCharges = charges;
1238 m_stackAmount = stackAmount;
1239 Unit* caster = GetCaster();
1240 for (AuraEffect* effect : GetAuraEffects())
1241 {
1242 if (!effect)
1243 continue;
1244
1245 effect->SetAmount(amount[effect->GetEffIndex()]);
1246 effect->SetCanBeRecalculated((recalculateMask & (1 << effect->GetEffIndex())) != 0);
1247 effect->CalculatePeriodic(caster, false, true);
1248 effect->CalculateSpellMod();
1249 effect->RecalculateAmount(caster);
1250 }
1251}
+ Here is the call graph for this function:

◆ SetMaxDuration()

void Aura::SetMaxDuration ( int32  duration)
inline

Definition at line 168 of file SpellAuras.h.

168{ m_maxDuration = duration; }
+ Here is the caller graph for this function:

◆ SetNeedClientUpdateForTargets()

void Aura::SetNeedClientUpdateForTargets ( ) const

Definition at line 1333 of file SpellAuras.cpp.

1334{
1335 for (ApplicationMap::const_iterator appIter = m_applications.begin(); appIter != m_applications.end(); ++appIter)
1336 appIter->second->SetNeedClientUpdate();
1337}
+ Here is the caller graph for this function:

◆ SetStackAmount()

void Aura::SetStackAmount ( uint8  num)

Definition at line 1014 of file SpellAuras.cpp.

1015{
1016 m_stackAmount = stackAmount;
1017 Unit* caster = GetCaster();
1018
1019 std::vector<AuraApplication*> applications;
1020 GetApplicationVector(applications);
1021
1022 for (AuraApplication* aurApp : applications)
1023 if (!aurApp->GetRemoveMode())
1024 HandleAuraSpecificMods(aurApp, caster, false, true);
1025
1026 for (AuraEffect* aurEff : GetAuraEffects())
1027 if (aurEff)
1028 aurEff->ChangeAmount(aurEff->CalculateAmount(caster), false, true);
1029
1030 for (AuraApplication* aurApp : applications)
1031 if (!aurApp->GetRemoveMode())
1032 HandleAuraSpecificMods(aurApp, caster, true, true);
1033
1035}
void GetApplicationVector(std::vector< AuraApplication * > &applications) const
void HandleAuraSpecificMods(AuraApplication const *aurApp, Unit *caster, bool apply, bool onReapply)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ SetUsingCharges()

void Aura::SetUsingCharges ( bool  val)
inline

Definition at line 249 of file SpellAuras.h.

249{ m_isUsingCharges = val; }

◆ ToDynObjAura() [1/2]

DynObjAura * Aura::ToDynObjAura ( )
inline

Definition at line 296 of file SpellAuras.h.

296{ if (GetType() == DYNOBJ_AURA_TYPE) return reinterpret_cast<DynObjAura*>(this); else return nullptr; }
+ Here is the caller graph for this function:

◆ ToDynObjAura() [2/2]

DynObjAura const * Aura::ToDynObjAura ( ) const
inline

Definition at line 297 of file SpellAuras.h.

297{ if (GetType() == DYNOBJ_AURA_TYPE) return reinterpret_cast<DynObjAura const*>(this); else return nullptr; }

◆ ToUnitAura() [1/2]

UnitAura * Aura::ToUnitAura ( )
inline

Definition at line 293 of file SpellAuras.h.

293{ if (GetType() == UNIT_AURA_TYPE) return reinterpret_cast<UnitAura*>(this); else return nullptr; }
+ Here is the caller graph for this function:

◆ ToUnitAura() [2/2]

UnitAura const * Aura::ToUnitAura ( ) const
inline

Definition at line 294 of file SpellAuras.h.

294{ if (GetType() == UNIT_AURA_TYPE) return reinterpret_cast<UnitAura const*>(this); else return nullptr; }

◆ TriggerProcOnEvent()

void Aura::TriggerProcOnEvent ( uint32  procEffectMask,
AuraApplication aurApp,
ProcEventInfo eventInfo 
)

Definition at line 1970 of file SpellAuras.cpp.

1971{
1972 if (procEffectMask)
1973 {
1974 bool prevented = CallScriptProcHandlers(aurApp, eventInfo);
1975 if (!prevented)
1976 {
1977 for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
1978 {
1979 if (!(procEffectMask & (1 << i)))
1980 continue;
1981
1982 // OnEffectProc / AfterEffectProc hooks handled in AuraEffect::HandleProc()
1983 if (aurApp->HasEffect(i))
1984 GetEffect(i)->HandleProc(aurApp, eventInfo);
1985 }
1986
1987 CallScriptAfterProcHandlers(aurApp, eventInfo);
1988 }
1989 }
1990
1992}
#define ASSERT_NOTNULL(pointer)
Definition: Errors.h:84
bool HasEffect(uint8 effect) const
Definition: SpellAuras.h:82
void HandleProc(AuraApplication *aurApp, ProcEventInfo &eventInfo)
void CallScriptAfterProcHandlers(AuraApplication const *aurApp, ProcEventInfo &eventInfo)
void ConsumeProcCharges(SpellProcEntry const *procEntry)
bool CallScriptProcHandlers(AuraApplication const *aurApp, ProcEventInfo &eventInfo)
+ Here is the call graph for this function:

◆ TryCreate()

Aura * Aura::TryCreate ( AuraCreateInfo createInfo)
static

Definition at line 377 of file SpellAuras.cpp.

378{
379 uint32 effMask = createInfo._auraEffectMask;
380 if (createInfo._targetEffectMask)
381 effMask = createInfo._targetEffectMask;
382
383 effMask = Aura::BuildEffectMaskForOwner(createInfo._spellInfo, effMask, createInfo._owner);
384 if (!effMask)
385 return nullptr;
386
387 return Create(createInfo);
388}
static Aura * Create(AuraCreateInfo &createInfo)
Definition: SpellAuras.cpp:390
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ TryRefreshStackOrCreate()

Aura * Aura::TryRefreshStackOrCreate ( AuraCreateInfo createInfo,
bool  updateEffectMask = true 
)
static

Definition at line 337 of file SpellAuras.cpp.

338{
339 ASSERT_NODEBUGINFO(createInfo.Caster || !createInfo.CasterGUID.IsEmpty());
340
341 if (createInfo.IsRefresh)
342 *createInfo.IsRefresh = false;
343
344 createInfo._auraEffectMask = Aura::BuildEffectMaskForOwner(createInfo._spellInfo, createInfo._auraEffectMask, createInfo._owner);
345 createInfo._targetEffectMask &= createInfo._auraEffectMask;
346
347 uint32 effMask = createInfo._auraEffectMask;
348 if (createInfo._targetEffectMask)
349 effMask = createInfo._targetEffectMask;
350
351 if (!effMask)
352 return nullptr;
353
354 if (Aura* foundAura = createInfo._owner->ToUnit()->_TryStackingOrRefreshingExistingAura(createInfo))
355 {
356 // we've here aura, which script triggered removal after modding stack amount
357 // check the state here, so we won't create new Aura object
358 if (foundAura->IsRemoved())
359 return nullptr;
360
361 if (createInfo.IsRefresh)
362 *createInfo.IsRefresh = true;
363
364 // add owner
365 Unit* unit = createInfo._owner->ToUnit();
366
367 // check effmask on owner application (if existing)
368 if (updateEffectMask)
369 if (AuraApplication* aurApp = foundAura->GetApplicationOfTarget(unit->GetGUID()))
370 aurApp->UpdateApplyEffectMask(effMask, false);
371 return foundAura;
372 }
373 else
374 return Create(createInfo);
375}
Aura * _TryStackingOrRefreshingExistingAura(AuraCreateInfo &createInfo)
Definition: Unit.cpp:3230
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ UnregisterSingleTarget()

void Aura::UnregisterSingleTarget ( )

Definition at line 1187 of file SpellAuras.cpp.

1188{
1190 Unit* caster = GetCaster();
1191 ASSERT(caster);
1193 SetIsSingleTarget(false);
1194}
void SetIsSingleTarget(bool val)
Definition: SpellAuras.h:208
AuraList & GetSingleCastAuras()
Definition: Unit.h:1309
std::list< T, Alloc >::iterator RemoveUnique(std::list< T, Alloc > &list, T const &value)
Definition: ListUtils.h:27
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Update()

void Aura::Update ( uint32  diff,
Unit caster 
)

Definition at line 810 of file SpellAuras.cpp.

811{
812 if (m_duration > 0)
813 {
814 m_duration -= diff;
815 if (m_duration < 0)
816 m_duration = 0;
817
818 // handle manaPerSecond/manaPerSecondPerLevel
819 if (m_timeCla)
820 {
821 if (m_timeCla > int32(diff))
822 m_timeCla -= diff;
823 else if (caster && (caster == GetOwner() || !GetSpellInfo()->HasAttribute(SPELL_ATTR2_NO_TARGET_PER_SECOND_COSTS)))
824 {
825 if (!m_periodicCosts.empty())
826 {
827 m_timeCla += 1000 - diff;
828
829 for (SpellPowerEntry const* power : m_periodicCosts)
830 {
831 if (power->RequiredAuraSpellID && !caster->HasAura(power->RequiredAuraSpellID))
832 continue;
833
834 int32 manaPerSecond = power->ManaPerSecond;
835 Powers powertype = Powers(power->PowerType);
836 if (powertype != POWER_HEALTH)
837 manaPerSecond += int32(CalculatePct(caster->GetMaxPower(powertype), power->PowerPctPerSecond));
838 else
839 manaPerSecond += int32(CalculatePct(caster->GetMaxHealth(), power->PowerPctPerSecond));
840
841 if (manaPerSecond)
842 {
843 if (powertype == POWER_HEALTH)
844 {
845 if (int32(caster->GetHealth()) > manaPerSecond)
846 caster->ModifyHealth(-manaPerSecond);
847 else
848 Remove();
849 }
850 else if (int32(caster->GetPower(powertype)) >= manaPerSecond)
851 caster->ModifyPower(powertype, -manaPerSecond);
852 else
853 Remove();
854 }
855 }
856 }
857 }
858 }
859 }
860}
@ SPELL_ATTR2_NO_TARGET_PER_SECOND_COSTS
Powers
@ POWER_HEALTH
int32 ModifyPower(Powers power, int32 val, bool withPowerUpdate=true)
Definition: Unit.cpp:8253
int64 ModifyHealth(int64 val)
Definition: Unit.cpp:8155
uint64 GetMaxHealth() const
Definition: Unit.h:772
uint64 GetHealth() const
Definition: Unit.h:771
int32 GetPower(Powers power) const
Definition: Unit.cpp:9337
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ UpdateOwner()

void Aura::UpdateOwner ( uint32  diff,
WorldObject owner 
)

Definition at line 771 of file SpellAuras.cpp.

772{
773 ASSERT(owner == m_owner);
774
775 Unit* caster = GetCaster();
776 // Apply spellmods for channeled auras
777 // used for example when triggered spell of spell:10 is modded
778 Spell* modSpell = nullptr;
779 Player* modOwner = nullptr;
780 if (caster)
781 {
782 modOwner = caster->GetSpellModOwner();
783 if (modOwner)
784 {
785 modSpell = modOwner->FindCurrentSpellBySpellId(GetId());
786 if (modSpell)
787 modOwner->SetSpellModTakingSpell(modSpell, true);
788 }
789 }
790
791 Update(diff, caster);
792
793 if (m_updateTargetMapInterval <= int32(diff))
794 UpdateTargetMap(caster);
795 else
797
798 // update aura effects
799 for (AuraEffect* effect : GetAuraEffects())
800 if (effect)
801 effect->Update(diff, caster);
802
803 // remove spellmods after effects update
804 if (modSpell)
805 modOwner->SetSpellModTakingSpell(modSpell, false);
806
808}
void Update(uint32 diff, Unit *caster)
Definition: SpellAuras.cpp:810
void SetSpellModTakingSpell(Spell *spell, bool apply)
Definition: Player.cpp:22358
Spell * FindCurrentSpellBySpellId(uint32 spell_id) const
Definition: Unit.cpp:3101
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ UpdateTargetMap()

void Aura::UpdateTargetMap ( Unit caster,
bool  apply = true 
)
Todo:
There is a crash caused by shadowfiend load addon

Definition at line 612 of file SpellAuras.cpp.

613{
614 if (IsRemoved())
615 return;
616
618
619 // fill up to date target list
620 // target, effMask
621 std::unordered_map<Unit*, uint32> targets;
622
623 FillTargetMap(targets, caster);
624
625 std::vector<Unit*> targetsToRemove;
626
627 // mark all auras as ready to remove
628 for (auto const& applicationPair : m_applications)
629 {
630 auto itr = targets.find(applicationPair.second->GetTarget());
631 // not found in current area - remove the aura
632 if (itr == targets.end())
633 targetsToRemove.push_back(applicationPair.second->GetTarget());
634 else
635 {
636 // needs readding - remove now, will be applied in next update cycle
637 // (dbcs do not have auras which apply on same type of targets but have different radius, so this is not really needed)
638 if (itr->first->IsImmunedToSpell(GetSpellInfo(), caster, true) || !CanBeAppliedOn(itr->first))
639 {
640 targetsToRemove.push_back(applicationPair.second->GetTarget());
641 continue;
642 }
643
644 // check target immunities (for existing targets)
645 for (SpellEffectInfo const& spellEffectInfo : GetSpellInfo()->GetEffects())
646 if (itr->first->IsImmunedToSpellEffect(GetSpellInfo(), spellEffectInfo, caster, true))
647 itr->second &= ~(1 << spellEffectInfo.EffectIndex);
648
649 // needs to add/remove effects from application, don't remove from map so it gets updated
650 if (applicationPair.second->GetEffectMask() != itr->second)
651 continue;
652
653 // nothing to do - aura already applied
654 // remove from auras to register list
655 targets.erase(itr);
656 }
657 }
658
659 // register auras for units
660 for (auto itr = targets.begin(); itr != targets.end();)
661 {
662 bool addUnit = true;
663 AuraApplication* aurApp = GetApplicationOfTarget(itr->first->GetGUID());
664 if (!aurApp)
665 {
666 // check target immunities (for new targets)
667 for (SpellEffectInfo const& spellEffectInfo : GetSpellInfo()->GetEffects())
668 if (itr->first->IsImmunedToSpellEffect(GetSpellInfo(), spellEffectInfo, caster))
669 itr->second &= ~(1 << spellEffectInfo.EffectIndex);
670
671 if (!itr->second || itr->first->IsImmunedToSpell(GetSpellInfo(), caster) || !CanBeAppliedOn(itr->first))
672 addUnit = false;
673 }
674
675 if (addUnit && !itr->first->IsHighestExclusiveAura(this, true))
676 addUnit = false;
677
678 // Dynobj auras don't hit flying targets
679 if (GetType() == DYNOBJ_AURA_TYPE && itr->first->IsInFlight())
680 addUnit = false;
681
682 // Do not apply aura if it cannot stack with existing auras
683 if (addUnit)
684 {
685 // Allow to remove by stack when aura is going to be applied on owner
686 if (itr->first != GetOwner())
687 {
688 // check if not stacking aura already on target
689 // this one prevents unwanted usefull buff loss because of stacking and prevents overriding auras periodicaly by 2 near area aura owners
690 for (Unit::AuraApplicationMap::iterator iter = itr->first->GetAppliedAuras().begin(); iter != itr->first->GetAppliedAuras().end(); ++iter)
691 {
692 Aura const* aura = iter->second->GetBase();
693 if (!CanStackWith(aura))
694 {
695 addUnit = false;
696 break;
697 }
698 }
699 }
700 }
701
702 if (!addUnit)
703 itr = targets.erase(itr);
704 else
705 {
706 // owner has to be in world, or effect has to be applied to self
707 if (!GetOwner()->IsSelfOrInSameMap(itr->first))
708 {
710 TC_LOG_FATAL("spells", "Aura {}: Owner {} (map {}) is not in the same map as target {} (map {}).", GetSpellInfo()->Id,
711 GetOwner()->GetName(), GetOwner()->IsInWorld() ? GetOwner()->GetMap()->GetId() : uint32(-1),
712 itr->first->GetName(), itr->first->IsInWorld() ? itr->first->GetMap()->GetId() : uint32(-1));
713 ABORT();
714 }
715
716 if (aurApp)
717 {
718 aurApp->UpdateApplyEffectMask(itr->second, true); // aura is already applied, this means we need to update effects of current application
719 itr = targets.erase(itr);
720 }
721 else
722 {
723 itr->first->_CreateAuraApplication(this, itr->second);
724 ++itr;
725 }
726 }
727 }
728
729 // remove auras from units no longer needing them
730 for (Unit* unit : targetsToRemove)
731 if (AuraApplication* aurApp = GetApplicationOfTarget(unit->GetGUID()))
732 unit->_UnapplyAura(aurApp, AURA_REMOVE_BY_DEFAULT);
733
734 if (!apply)
735 return;
736
737 // apply aura effects for units
738 for (auto itr = targets.begin(); itr!= targets.end(); ++itr)
739 {
740 if (AuraApplication* aurApp = GetApplicationOfTarget(itr->first->GetGUID()))
741 {
742 // owner has to be in world, or effect has to be applied to self
743 ASSERT((!GetOwner()->IsInWorld() && GetOwner() == itr->first) || GetOwner()->IsInMap(itr->first));
744 itr->first->_ApplyAura(aurApp, itr->second);
745 }
746 }
747}
#define TC_LOG_FATAL(filterType__,...)
Definition: Log.h:168
@ AURA_REMOVE_BY_DEFAULT
#define UPDATE_TARGET_MAP_INTERVAL
Definition: SpellAuras.h:53
void UpdateApplyEffectMask(uint32 newEffMask, bool canHandleNewEffects)
Definition: SpellAuras.cpp:185
bool CanStackWith(Aura const *existingAura) const
virtual void FillTargetMap(std::unordered_map< Unit *, uint32 > &targets, Unit *caster)=0
bool CanBeAppliedOn(Unit *target)
bool IsSelfOrInSameMap(WorldObject const *obj) const
Definition: Object.cpp:1100
TC_GAME_API bool GetName(uint32 accountId, std::string &name)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Friends And Related Function Documentation

◆ Unit

friend class Unit
friend

Definition at line 119 of file SpellAuras.h.

Member Data Documentation

◆ _effects

AuraEffectVector Aura::_effects
private

Definition at line 358 of file SpellAuras.h.

◆ _removedApplications

std::vector<AuraApplication*> Aura::_removedApplications
private

Definition at line 356 of file SpellAuras.h.

◆ m_applications

ApplicationMap Aura::m_applications
protected

Definition at line 343 of file SpellAuras.h.

◆ m_applyTime

time_t const Aura::m_applyTime
protected

Definition at line 330 of file SpellAuras.h.

◆ m_castDifficulty

Difficulty const Aura::m_castDifficulty
protected

Definition at line 323 of file SpellAuras.h.

◆ m_casterGuid

ObjectGuid const Aura::m_casterGuid
protected

Definition at line 325 of file SpellAuras.h.

◆ m_casterLevel

uint8 const Aura::m_casterLevel
protected

Definition at line 339 of file SpellAuras.h.

◆ m_castId

ObjectGuid const Aura::m_castId
protected

Definition at line 324 of file SpellAuras.h.

◆ m_castItemGuid

ObjectGuid const Aura::m_castItemGuid
protected

Definition at line 326 of file SpellAuras.h.

◆ m_castItemId

uint32 Aura::m_castItemId
protected

Definition at line 327 of file SpellAuras.h.

◆ m_castItemLevel

int32 Aura::m_castItemLevel
protected

Definition at line 328 of file SpellAuras.h.

◆ m_dropEvent

ChargeDropEvent* Aura::m_dropEvent
protected

Definition at line 349 of file SpellAuras.h.

◆ m_duration

int32 Aura::m_duration
protected

Definition at line 334 of file SpellAuras.h.

◆ m_isRemoved

bool Aura::m_isRemoved
protected

Definition at line 345 of file SpellAuras.h.

◆ m_isSingleTarget

bool Aura::m_isSingleTarget
protected

Definition at line 346 of file SpellAuras.h.

◆ m_isUsingCharges

bool Aura::m_isUsingCharges
protected

Definition at line 347 of file SpellAuras.h.

◆ m_lastProcAttemptTime

TimePoint Aura::m_lastProcAttemptTime
protected

Definition at line 352 of file SpellAuras.h.

◆ m_lastProcSuccessTime

TimePoint Aura::m_lastProcSuccessTime
protected

Definition at line 353 of file SpellAuras.h.

◆ m_loadedScripts

std::vector<AuraScript*> Aura::m_loadedScripts

Definition at line 305 of file SpellAuras.h.

◆ m_maxDuration

int32 Aura::m_maxDuration
protected

Definition at line 333 of file SpellAuras.h.

◆ m_owner

WorldObject* const Aura::m_owner
protected

Definition at line 331 of file SpellAuras.h.

◆ m_periodicCosts

std::vector<SpellPowerEntry const*> Aura::m_periodicCosts
protected

Definition at line 336 of file SpellAuras.h.

◆ m_procCharges

uint8 Aura::m_procCharges
protected

Definition at line 340 of file SpellAuras.h.

◆ m_procCooldown

TimePoint Aura::m_procCooldown
protected

Definition at line 351 of file SpellAuras.h.

◆ m_spellInfo

SpellInfo const* const Aura::m_spellInfo
protected

Definition at line 322 of file SpellAuras.h.

◆ m_spellVisual

SpellCastVisual const Aura::m_spellVisual
protected

Definition at line 329 of file SpellAuras.h.

◆ m_stackAmount

uint8 Aura::m_stackAmount
protected

Definition at line 341 of file SpellAuras.h.

◆ m_timeCla

int32 Aura::m_timeCla
protected

Definition at line 335 of file SpellAuras.h.

◆ m_updateTargetMapInterval

int32 Aura::m_updateTargetMapInterval
protected

Definition at line 337 of file SpellAuras.h.


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