AzerothCore 3.3.5a
OpenSource WoW Emulator
Loading...
Searching...
No Matches
Aura Class Referenceabstract

#include "SpellAuras.h"

Inheritance diagram for Aura:
DynObjAura UnitAura

Public Types

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

Public Member Functions

 Aura (SpellInfo const *spellproto, WorldObject *owner, Unit *caster, Item *castItem, ObjectGuid casterGUID, ObjectGuid itemGUID=ObjectGuid::Empty)
 
void _InitEffects (uint8 effMask, Unit *caster, int32 *baseAmount)
 
virtual ~Aura ()
 
SpellInfo const * GetSpellInfo () const
 
uint32 GetId () const
 
ObjectGuid GetCastItemGUID () const
 
uint32 GetCastItemEntry () const
 
ObjectGuid GetCasterGUID () const
 
Unit * GetCaster () const
 
WorldObject * GetOwner () const
 
Unit * GetUnitOwner () const
 
DynamicObject * GetDynobjOwner () 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::map< Unit *, uint8 > &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
 
bool HasCasterDiedSinceApply (Unit const *caster) 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 periodicReset=false)
 
void RefreshTimersWithMods ()
 
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)
 
uint8 GetStackAmount () const
 
void SetStackAmount (uint8 num)
 
bool ModStackAmount (int32 num, AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT, bool periodicReset=false)
 
void RefreshSpellMods ()
 
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 CanBeSentToClient () const
 
bool IsSingleTarget () const
 
bool IsSingleTargetWith (Aura const *aura) const
 
void SetIsSingleTarget (bool val)
 
void UnregisterSingleTarget ()
 
int32 CalcDispelChance (Unit *auraTarget, bool offensive) const
 
void SetLoadedState (int32 maxduration, int32 duration, int32 charges, uint8 stackamount, uint8 recalculateMask, int32 *amount)
 
bool HasEffect (uint8 effIndex) const
 
bool HasEffectType (AuraType type) const
 
AuraEffect * GetEffect (uint8 effIndex) const
 
uint8 GetEffectMask () const
 
void RecalculateAmountOfEffects ()
 
void HandleAllEffects (AuraApplication *aurApp, uint8 mode, bool apply)
 
ApplicationMap const & GetApplicationMap ()
 
void GetApplicationList (std::list< AuraApplication * > &applicationList) const
 
AuraApplication const * GetApplicationOfTarget (ObjectGuid guid) const
 
AuraApplication * GetApplicationOfTarget (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 IsAuraStronger (Aura const *newAura) const
 
bool IsProcOnCooldown (TimePoint now) const
 
void AddProcCooldown (TimePoint cooldownEnd)
 
void AddProcCooldown (SpellProcEntry const *procEntry, TimePoint now)
 
void ResetProcCooldown ()
 
bool IsUsingCharges () const
 
void SetUsingCharges (bool val)
 
void PrepareProcToTrigger (AuraApplication *aurApp, ProcEventInfo &eventInfo, TimePoint now)
 
uint8 GetProcEffectMask (AuraApplication *aurApp, ProcEventInfo &eventInfo, TimePoint now) const
 
float CalcProcChance (SpellProcEntry const &procEntry, ProcEventInfo &eventInfo) const
 
void TriggerProcOnEvent (uint8 procEffectMask, AuraApplication *aurApp, ProcEventInfo &eventInfo)
 
void ConsumeProcCharges (SpellProcEntry const *procEntry)
 
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 CallScriptEffectAbsorbHandlers (AuraEffect *aurEff, AuraApplication const *aurApp, DamageInfo &dmgInfo, uint32 &absorbAmount, bool &defaultPrevented)
 
void CallScriptEffectAfterAbsorbHandlers (AuraEffect *aurEff, AuraApplication const *aurApp, DamageInfo &dmgInfo, 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)
 
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 const *aurEff, AuraApplication const *aurApp, ProcEventInfo &eventInfo)
 
void CallScriptAfterEffectProcHandlers (AuraEffect const *aurEff, AuraApplication const *aurApp, ProcEventInfo &eventInfo)
 
AuraScript * GetScriptByName (std::string const &scriptName) const
 
template<class Script >
Script * GetScript (std::string const &scriptName) const
 
virtual std::string GetDebugInfo () const
 
void SetTriggeredByAuraSpellInfo (SpellInfo const *triggeredByAuraSpellInfo)
 
SpellInfo const * GetTriggeredByAuraSpellInfo () const
 

Static Public Member Functions

static uint8 BuildEffectMaskForOwner (SpellInfo const *spellProto, uint8 avalibleEffectMask, WorldObject *owner)
 
static Aura * TryRefreshStackOrCreate (SpellInfo const *spellproto, uint8 tryEffMask, WorldObject *owner, Unit *caster, int32 *baseAmount=nullptr, Item *castItem=nullptr, ObjectGuid casterGUID=ObjectGuid::Empty, bool *refresh=nullptr, bool periodicReset=false)
 
static Aura * TryCreate (SpellInfo const *spellproto, uint8 effMask, WorldObject *owner, Unit *caster, int32 *baseAmount=nullptr, Item *castItem=nullptr, ObjectGuid casterGUID=ObjectGuid::Empty, ObjectGuid itemGUID=ObjectGuid::Empty)
 
static Aura * Create (SpellInfo const *spellproto, uint8 effMask, WorldObject *owner, Unit *caster, int32 *baseAmount, Item *castItem, ObjectGuid casterGUID, ObjectGuid itemGUID=ObjectGuid::Empty)
 

Public Attributes

std::list< AuraScript * > m_loadedScripts
 

Protected Attributes

SpellInfo const *const m_spellInfo
 
ObjectGuid const m_casterGuid
 
ObjectGuid const m_castItemGuid
 
uint32 const m_castItemEntry
 
time_t const m_applyTime
 
Milliseconds m_refreshTime
 
WorldObject *const m_owner
 
int32 m_maxDuration
 
int32 m_duration
 
int32 m_timeCla
 
int32 m_updateTargetMapInterval
 
uint8 const m_casterLevel
 
uint8 m_procCharges
 
uint8 m_stackAmount
 
AuraEffect * m_effects [3]
 
ApplicationMap m_applications
 
bool m_isRemoved: 1
 
bool m_isSingleTarget: 1
 
bool m_isUsingCharges: 1
 
TimePoint m_procCooldown
 

Private Member Functions

void _DeleteRemovedApplications ()
 

Private Attributes

Unit::AuraApplicationList m_removedApplications
 
SpellInfo const * m_triggeredByAuraSpellInfo
 

Friends

Aura * Unit::_TryStackingOrRefreshingExistingAura (SpellInfo const *newAura, uint8 effMask, Unit *caster, int32 *baseAmount, Item *castItem, ObjectGuid casterGUID, bool noPeriodicReset)
 

Detailed Description

Member Typedef Documentation

◆ ApplicationMap

Constructor & Destructor Documentation

◆ Aura()

Aura::Aura ( SpellInfo const *  spellproto,
WorldObject *  owner,
Unit *  caster,
Item *  castItem,
ObjectGuid  casterGUID,
ObjectGuid  itemGUID = ObjectGuid::Empty 
)
explicit
360 :
361 m_spellInfo(spellproto), m_casterGuid(casterGUID ? casterGUID : (caster ? caster->GetGUID() : ObjectGuid::Empty)),
362 m_castItemGuid(itemGUID ? itemGUID : castItem ? castItem->GetGUID() : ObjectGuid::Empty), m_castItemEntry(castItem ? castItem->GetEntry() : 0), m_applyTime(GameTime::GetGameTime().count()),
364 m_casterLevel(caster ? caster->GetLevel() : m_spellInfo->SpellLevel), m_procCharges(0), m_stackAmount(1),
366{
369
374 memset(m_effects, 0, sizeof(m_effects));
375 // m_casterLevel = cast item level/caster level, caster level should be saved to db, confirmed with sniffs
376}
constexpr auto IN_MILLISECONDS
Definition Common.h:53
@ SPELL_ATTR2_NO_TARGET_PER_SECOND_COST
Definition SharedDefines.h:455
Milliseconds m_refreshTime
Definition SpellAuras.h:263
int32 m_maxDuration
Definition SpellAuras.h:266
time_t const m_applyTime
Definition SpellAuras.h:262
AuraEffect * m_effects[3]
Definition SpellAuras.h:275
uint8 m_stackAmount
Definition SpellAuras.h:273
int32 m_duration
Definition SpellAuras.h:267
uint32 const m_castItemEntry
Definition SpellAuras.h:261
ObjectGuid const m_castItemGuid
Definition SpellAuras.h:260
int32 m_timeCla
Definition SpellAuras.h:268
int32 CalcMaxDuration() const
Definition SpellAuras.h:133
SpellInfo const * m_triggeredByAuraSpellInfo
Definition SpellAuras.h:287
SpellInfo const *const m_spellInfo
Definition SpellAuras.h:258
WorldObject *const m_owner
Definition SpellAuras.h:264
ObjectGuid const m_casterGuid
Definition SpellAuras.h:259
uint8 const m_casterLevel
Definition SpellAuras.h:271
uint8 CalcMaxCharges() const
Definition SpellAuras.h:146
bool m_isUsingCharges
Definition SpellAuras.h:280
bool m_isRemoved
Definition SpellAuras.h:278
int32 m_updateTargetMapInterval
Definition SpellAuras.h:269
bool m_isSingleTarget
Definition SpellAuras.h:279
uint8 m_procCharges
Definition SpellAuras.h:272
Definition ObjectGuid.h:121
uint32 ManaPerSecondPerLevel
Definition SpellInfo.h:390
uint32 ManaPerSecond
Definition SpellInfo.h:389
bool HasAttribute(SpellAttr0 attribute) const
Definition SpellInfo.h:441
Definition GameTime.cpp:22
Milliseconds GetGameTimeMS()
Definition GameTime.cpp:44
Seconds GetGameTime()
Definition GameTime.cpp:39

References CalcMaxCharges(), CalcMaxDuration(), SpellInfo::HasAttribute(), IN_MILLISECONDS, m_duration, m_effects, m_isUsingCharges, m_maxDuration, m_procCharges, m_spellInfo, m_timeCla, SpellInfo::ManaPerSecond, SpellInfo::ManaPerSecondPerLevel, and SPELL_ATTR2_NO_TARGET_PER_SECOND_COST.

◆ ~Aura()

Aura::~Aura ( )
virtual
399{
400 // unload scripts
401 while (!m_loadedScripts.empty())
402 {
403 std::list<AuraScript*>::iterator itr = m_loadedScripts.begin();
404 (*itr)->_Unload();
405 delete (*itr);
406 m_loadedScripts.erase(itr);
407 }
408
409 // free effects memory
410 for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
411 delete m_effects[i];
412
413 ASSERT(m_applications.empty());
415}
#define MAX_SPELL_EFFECTS
Definition DBCStructure.h:1673
std::uint8_t uint8
Definition Define.h:109
#define ASSERT
Definition Errors.h:68
std::list< AuraScript * > m_loadedScripts
Definition SpellAuras.h:247
ApplicationMap m_applications
Definition SpellAuras.h:276
void _DeleteRemovedApplications()
Definition SpellAuras.cpp:2472

References _DeleteRemovedApplications(), ASSERT, m_applications, m_effects, m_loadedScripts, and MAX_SPELL_EFFECTS.

Member Function Documentation

◆ _ApplyEffectForTargets()

void Aura::_ApplyEffectForTargets ( uint8  effIndex)
787{
788 // prepare list of aura targets
789 UnitList targetList;
790 for (ApplicationMap::iterator appIter = m_applications.begin(); appIter != m_applications.end(); ++appIter)
791 {
792 if ((appIter->second->GetEffectsToApply() & (1 << effIndex)) && !appIter->second->HasEffect(effIndex))
793 targetList.push_back(appIter->second->GetTarget());
794 }
795
796 // apply effect to targets
797 for (UnitList::iterator itr = targetList.begin(); itr != targetList.end(); ++itr)
798 {
799 if (GetApplicationOfTarget((*itr)->GetGUID()))
800 {
801 // owner has to be in world, or effect has to be applied to self
802 ASSERT((!GetOwner()->IsInWorld() && GetOwner() == *itr) || GetOwner()->IsInMap(*itr));
803 (*itr)->_ApplyAuraEffect(this, effIndex);
804 }
805 }
806}
std::list< Unit * > UnitList
Definition Unit.h:79
AuraApplication const * GetApplicationOfTarget(ObjectGuid guid) const
Definition SpellAuras.h:186
WorldObject * GetOwner() const
Definition SpellAuras.h:108

References ASSERT, GetApplicationOfTarget(), GetOwner(), and m_applications.

Referenced by Spell::EffectApplyAreaAura(), Spell::EffectApplyAura(), and Spell::EffectPersistentAA().

◆ _ApplyForTarget()

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

Reimplemented in UnitAura.

450{
451 ASSERT(target);
452 ASSERT(auraApp);
453 // aura mustn't be already applied on target
454 ASSERT (!IsAppliedOnTarget(target->GetGUID()) && "Aura::_ApplyForTarget: aura musn't be already applied on target");
455
456 m_applications[target->GetGUID()] = auraApp;
457
458 // set infinity cooldown state for spells
460 {
461 if (caster->IsPlayer())
462 {
463 caster->ToPlayer()->AddSpellAndCategoryCooldowns(m_spellInfo, 0, nullptr, true);
464 }
465 else
466 {
468 }
469 }
470}
static constexpr uint32 infinityCooldownDelay
Definition Unit.h:48
bool IsAppliedOnTarget(ObjectGuid guid) const
Definition SpellAuras.h:188
void AddSpellCooldown(uint32 spell_id, uint32, uint32 end_time, bool needSendToClient=false, bool forceSendToSpectator=false) override
Definition Creature.cpp:3013
bool IsPlayer() const
Definition Object.h:207
Player * ToPlayer()
Definition Object.h:208
Creature * ToCreature()
Definition Object.h:212
static ObjectGuid GetGUID(Object const *o)
Definition Object.h:120
void AddSpellAndCategoryCooldowns(SpellInfo const *spellInfo, uint32 itemId, Spell *spell=nullptr, bool infinityCooldown=false)
Definition Player.cpp:11111
bool IsCooldownStartedOnEvent() const
Definition SpellInfo.cpp:1257
uint32 Id
Definition SpellInfo.h:344

References Player::AddSpellAndCategoryCooldowns(), Creature::AddSpellCooldown(), ASSERT, Object::GetGUID(), SpellInfo::Id, infinityCooldownDelay, IsAppliedOnTarget(), SpellInfo::IsCooldownStartedOnEvent(), Object::IsPlayer(), m_applications, m_castItemGuid, m_spellInfo, Object::ToCreature(), and Object::ToPlayer().

Referenced by UnitAura::_ApplyForTarget(), and Unit::_CreateAuraApplication().

◆ _DeleteRemovedApplications()

void Aura::_DeleteRemovedApplications ( )
private
2473{
2474 while (!m_removedApplications.empty())
2475 {
2476 delete m_removedApplications.front();
2477 m_removedApplications.pop_front();
2478 }
2479}
Unit::AuraApplicationList m_removedApplications
Definition SpellAuras.h:285

References m_removedApplications.

Referenced by UpdateOwner(), and ~Aura().

◆ _InitEffects()

void Aura::_InitEffects ( uint8  effMask,
Unit *  caster,
int32 *  baseAmount 
)
387{
388 // shouldn't be in constructor - functions in AuraEffect::AuraEffect use polymorphism
389 for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
390 {
391 if (effMask & (uint8(1) << i))
392 m_effects[i] = new AuraEffect(this, i, baseAmount ? baseAmount + i : nullptr, caster);
393 else
394 m_effects[i] = nullptr;
395 }
396}
Definition SpellAuraEffects.h:39

References m_effects, and MAX_SPELL_EFFECTS.

Referenced by DynObjAura::DynObjAura(), and UnitAura::UnitAura().

◆ _RegisterForTargets()

void Aura::_RegisterForTargets ( )
inline
122{Unit* caster = GetCaster(); UpdateTargetMap(caster, false);}
Unit * GetCaster() const
Definition SpellAuras.cpp:422
void UpdateTargetMap(Unit *caster, bool apply=true)
Definition SpellAuras.cpp:594
Definition Unit.h:670

References GetCaster(), and UpdateTargetMap().

Referenced by Spell::DoSpellHitOnUnit(), and Spell::EffectPersistentAA().

◆ _Remove()

void Aura::_Remove ( AuraRemoveMode  removeMode)
535{
537 m_isRemoved = true;
538 ApplicationMap::iterator appItr = m_applications.begin();
539 for (appItr = m_applications.begin(); appItr != m_applications.end();)
540 {
541 AuraApplication* aurApp = appItr->second;
542 Unit* target = aurApp->GetTarget();
543 target->_UnapplyAura(aurApp, removeMode);
544 appItr = m_applications.begin();
545 }
546}
Definition SpellAuras.h:37
Unit * GetTarget() const
Definition SpellAuras.h:62
void _UnapplyAura(AuraApplicationMap::iterator &i, AuraRemoveMode removeMode)
Definition Unit.cpp:4615

References Unit::_UnapplyAura(), ASSERT, AuraApplication::GetTarget(), m_applications, and m_isRemoved.

Referenced by DynObjAura::Remove(), DynamicObject::RemoveAura(), and Unit::RemoveOwnedAura().

◆ _UnapplyForTarget()

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

Reimplemented in UnitAura.

473{
474 ASSERT(target);
475 ASSERT(auraApp->GetRemoveMode());
476 ASSERT(auraApp);
477
478 ApplicationMap::iterator itr = m_applications.find(target->GetGUID());
479
481 if (itr == m_applications.end())
482 {
483 LOG_ERROR("spells.aura", "Aura::_UnapplyForTarget, target:{}, caster:{}, spell:{} was not found in owners application map!",
484 target->GetGUID().ToString(), caster ? caster->GetGUID().ToString() : "", auraApp->GetBase()->GetSpellInfo()->Id);
485 ABORT();
486 }
487
488 // aura has to be already applied
489 ASSERT(itr->second == auraApp);
490 m_applications.erase(itr);
491
492 m_removedApplications.push_back(auraApp);
493
494 // reset cooldown state for spells
496 {
497 if (caster->IsPlayer())
498 {
499 // note: item based cooldowns and cooldown spell mods with charges ignored (unknown existed cases)
501 }
502 else
503 {
504 Creature* creatureCaster = caster->ToCreature();
505 // Drop the infinite cooldown set on apply, a longer running cooldown would otherwise be kept
506 creatureCaster->RemoveSpellCooldown(m_spellInfo->Id, false);
507 creatureCaster->AddSpellCooldown(m_spellInfo->Id, 0, 0);
508
509 if (Unit* owner = caster->GetCharmerOrOwner())
510 {
511 if (Player* playerOwner = owner->ToPlayer())
512 {
513 WorldPacket data(SMSG_COOLDOWN_EVENT, 4 + 8);
514 data << uint32(m_spellInfo->Id);
515 data << caster->GetGUID();
516 playerOwner->SendDirectMessage(&data);
517 }
518 }
519 }
520 }
521
522 if (caster && caster->IsPlayer())
523 {
524 if (GetSpellInfo()->IsCooldownStartedOnEvent() && !m_castItemGuid)
525 {
526 // note: item based cooldowns and cooldown spell mods with charges ignored (unknown existed cases)
528 }
529 }
530}
std::uint32_t uint32
Definition Define.h:107
#define ABORT
Definition Errors.h:76
#define LOG_ERROR(filterType__,...)
Definition Log.h:145
AuraRemoveMode GetRemoveMode() const
Definition SpellAuras.h:74
SpellInfo const * GetSpellInfo() const
Definition SpellAuras.h:101
Definition Creature.h:47
void RemoveSpellCooldown(uint32 spell_id, bool update)
Definition Creature.cpp:3094
std::string ToString() const
Definition ObjectGuid.cpp:49
Definition Player.h:1086
void SendCooldownEvent(SpellInfo const *spellInfo, uint32 itemId=0, Spell *spell=nullptr, bool setCooldown=true)
Definition Player.cpp:11309
Unit * GetCharmerOrOwner() const
Definition Unit.h:1303
Definition WorldPacket.h:26
@ SMSG_COOLDOWN_EVENT
Definition Opcodes.h:339

References ABORT, Creature::AddSpellCooldown(), ASSERT, AuraApplication::GetBase(), Unit::GetCharmerOrOwner(), Object::GetGUID(), AuraApplication::GetRemoveMode(), GetSpellInfo(), SpellInfo::Id, SpellInfo::IsCooldownStartedOnEvent(), Object::IsPlayer(), LOG_ERROR, m_applications, m_castItemGuid, m_removedApplications, m_spellInfo, Creature::RemoveSpellCooldown(), Player::SendCooldownEvent(), SMSG_COOLDOWN_EVENT, Object::ToCreature(), Object::ToPlayer(), and ObjectGuid::ToString().

Referenced by Unit::_UnapplyAura(), and UnitAura::_UnapplyForTarget().

◆ AddProcCooldown() [1/2]

void Aura::AddProcCooldown ( SpellProcEntry const *  procEntry,
TimePoint  now 
)
2232{
2233 AddProcCooldown(now + procEntry->Cooldown);
2234}
void AddProcCooldown(TimePoint cooldownEnd)
Definition SpellAuras.cpp:2226

References AddProcCooldown(), and SpellProcEntry::Cooldown.

◆ AddProcCooldown() [2/2]

void Aura::AddProcCooldown ( TimePoint  cooldownEnd)
2227{
2228 m_procCooldown = cooldownEnd;
2229}
TimePoint m_procCooldown
Definition SpellAuras.h:282

References m_procCooldown.

Referenced by AddProcCooldown(), and PrepareProcToTrigger().

◆ ApplyForTargets()

void Aura::ApplyForTargets ( )
inline
123{Unit* caster = GetCaster(); UpdateTargetMap(caster, true);}

References GetCaster(), and UpdateTargetMap().

Referenced by Unit::AddAura().

◆ BuildEffectMaskForOwner()

uint8 Aura::BuildEffectMaskForOwner ( SpellInfo const *  spellProto,
uint8  avalibleEffectMask,
WorldObject *  owner 
)
static
243{
244 ASSERT_NODEBUGINFO(spellProto);
245 ASSERT_NODEBUGINFO(owner);
246 uint8 effMask = 0;
247 switch (owner->GetTypeId())
248 {
249 case TYPEID_UNIT:
250 case TYPEID_PLAYER:
251 for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
252 {
253 if (spellProto->Effects[i].IsUnitOwnedAuraEffect())
254 effMask |= 1 << i;
255 }
256 break;
258 for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
259 {
260 if (spellProto->Effects[i].Effect == SPELL_EFFECT_PERSISTENT_AREA_AURA)
261 effMask |= 1 << i;
262 }
263 break;
264 default:
265 break;
266 }
267 return effMask & avalibleEffectMask;
268}
#define ASSERT_NODEBUGINFO
Definition Errors.h:69
@ TYPEID_DYNAMICOBJECT
Definition ObjectGuid.h:41
@ TYPEID_UNIT
Definition ObjectGuid.h:38
@ TYPEID_PLAYER
Definition ObjectGuid.h:39
@ SPELL_EFFECT_PERSISTENT_AREA_AURA
Definition SharedDefines.h:793
TypeID GetTypeId() const
Definition Object.h:135

References ASSERT_NODEBUGINFO, SpellInfo::Effects, Object::GetTypeId(), MAX_SPELL_EFFECTS, SPELL_EFFECT_PERSISTENT_AREA_AURA, TYPEID_DYNAMICOBJECT, TYPEID_PLAYER, and TYPEID_UNIT.

Referenced by TryCreate(), and TryRefreshStackOrCreate().

◆ CalcDispelChance()

int32 Aura::CalcDispelChance ( Unit *  auraTarget,
bool  offensive 
) const
1256{
1257 // we assume that aura dispel chance is 100% on start
1258 // need formula for level difference based chance
1259 int32 resistChance = 0;
1260
1261 // Apply dispel mod from aura caster
1262 if (Unit* caster = GetCaster())
1263 if (Player* modOwner = caster->GetSpellModOwner())
1264 modOwner->ApplySpellMod(GetId(), SPELLMOD_RESIST_DISPEL_CHANCE, resistChance);
1265
1266 // Dispel resistance from target SPELL_AURA_MOD_DISPEL_RESIST
1267 // Only affects offensive dispels
1268 if (offensive && auraTarget)
1269 resistChance += auraTarget->GetTotalAuraModifier(SPELL_AURA_MOD_DISPEL_RESIST);
1270
1271 resistChance = resistChance < 0 ? 0 : resistChance;
1272 resistChance = resistChance > 100 ? 100 : resistChance;
1273 return 100 - resistChance;
1274}
std::int32_t int32
Definition Define.h:103
@ SPELL_AURA_MOD_DISPEL_RESIST
Definition SpellAuraDefines.h:298
@ SPELLMOD_RESIST_DISPEL_CHANCE
Definition SpellDefines.h:112
uint32 GetId() const
Definition SpellAuras.cpp:417
Player * GetSpellModOwner() const override
Definition Unit.cpp:12637
int32 GetTotalAuraModifier(AuraType auratype) const
Definition Unit.cpp:6086

References GetCaster(), GetId(), Unit::GetSpellModOwner(), Unit::GetTotalAuraModifier(), SPELL_AURA_MOD_DISPEL_RESIST, and SPELLMOD_RESIST_DISPEL_CHANCE.

Referenced by Spell::EffectDispelMechanic().

◆ CalcMaxCharges() [1/2]

uint8 Aura::CalcMaxCharges ( ) const
inline

◆ CalcMaxCharges() [2/2]

uint8 Aura::CalcMaxCharges ( Unit *  caster) const
1015{
1016 uint32 maxProcCharges = m_spellInfo->ProcCharges;
1017 if (SpellProcEntry const* procEntry = sSpellMgr->GetSpellProcEntry(GetId()))
1018 maxProcCharges = procEntry->Charges;
1019
1020 if (caster)
1021 if (Player* modOwner = caster->GetSpellModOwner())
1022 modOwner->ApplySpellMod(GetId(), SPELLMOD_CHARGES, maxProcCharges);
1023 return maxProcCharges;
1024}
@ SPELLMOD_CHARGES
Definition SpellDefines.h:88
#define sSpellMgr
Definition SpellMgr.h:851
uint32 ProcCharges
Definition SpellInfo.h:381
Definition SpellMgr.h:286

References GetId(), Unit::GetSpellModOwner(), m_spellInfo, SpellInfo::ProcCharges, SPELLMOD_CHARGES, and sSpellMgr.

Referenced by AuraScript::CalcMaxCharges().

◆ CalcMaxDuration() [1/2]

int32 Aura::CalcMaxDuration ( ) const
inline

◆ CalcMaxDuration() [2/2]

int32 Aura::CalcMaxDuration ( Unit *  caster) const
896{
897 Player* modOwner = nullptr;
898 int32 maxDuration;
899
900 if (caster)
901 {
902 modOwner = caster->GetSpellModOwner();
903 maxDuration = caster->CalcSpellDuration(m_spellInfo);
904 }
905 else
906 maxDuration = m_spellInfo->GetDuration();
907
909 maxDuration = -1;
910
911 sScriptMgr->OnCalcMaxDuration(this, maxDuration);
912
913 // IsPermanent() checks max duration (which we are supposed to calculate here)
914 if (maxDuration != -1 && modOwner)
915 modOwner->ApplySpellMod(GetId(), SPELLMOD_DURATION, maxDuration);
916 return maxDuration;
917}
#define sScriptMgr
Definition ScriptMgr.h:769
@ SPELLMOD_DURATION
Definition SpellDefines.h:85
bool IsPassive() const
Definition SpellAuras.cpp:1148
void ApplySpellMod(uint32 spellId, SpellModOp op, T &basevalue, Spell *spell=nullptr, bool temporaryPet=false)
Definition Player.cpp:10035
SpellDurationEntry const * DurationEntry
Definition SpellInfo.h:385
int32 GetDuration() const
Definition SpellInfo.cpp:2778
int32 CalcSpellDuration(SpellInfo const *spellProto) const
Definition Object.cpp:3383

References Player::ApplySpellMod(), WorldObject::CalcSpellDuration(), SpellInfo::DurationEntry, SpellInfo::GetDuration(), GetId(), Unit::GetSpellModOwner(), IsPassive(), m_spellInfo, SPELLMOD_DURATION, and sScriptMgr.

◆ CalcProcChance()

float Aura::CalcProcChance ( SpellProcEntry const &  procEntry,
ProcEventInfo &  eventInfo 
) const
2399{
2400 float chance = procEntry.Chance;
2401 // calculate chances depending on unit with caster's data
2402 // so talents modifying chances and judgements will have properly calculated proc chance
2403 if (Unit* caster = GetCaster())
2404 {
2405 // If PPM exists calculate chance from PPM
2406 if ((eventInfo.GetDamageInfo() || eventInfo.GetHealInfo()) && procEntry.ProcsPerMinute != 0)
2407 {
2408 SpellInfo const* procSpell = eventInfo.GetSpellInfo();
2409 uint32 attackSpeed = 0;
2410 if (!procSpell || procSpell->DmgClass == SPELL_DAMAGE_CLASS_MELEE || procSpell->IsRangedWeaponSpell())
2411 {
2412 attackSpeed = caster->GetAttackTime(eventInfo.GetDamageInfo()->GetAttackType());
2413 }
2414 else // spells use their cast time for PPM calculations
2415 {
2416 if (procSpell->CastTimeEntry)
2417 attackSpeed = procSpell->CastTimeEntry->CastTime;
2418
2419 // instants and fast spells use 1.5s cast speed
2420 if (attackSpeed < 1500)
2421 attackSpeed = 1500;
2422 }
2423 chance = caster->GetPPMProcChance(attackSpeed, procEntry.ProcsPerMinute, GetSpellInfo());
2424 }
2425 // apply chance modifer aura, applies also to ppm chance (see improved judgement of light spell)
2426 if (Player* modOwner = caster->GetSpellModOwner())
2427 modOwner->ApplySpellMod(GetId(), SPELLMOD_CHANCE_OF_SUCCESS, chance);
2428 }
2429
2430 // proc chance is reduced by an additional 3.333% per level past 60
2431 if ((procEntry.AttributesMask & PROC_ATTR_REDUCE_PROC_60) && eventInfo.GetActor()->GetLevel() > 60)
2432 chance = std::max(0.f, (1.f - ((eventInfo.GetActor()->GetLevel() - 60) * 1.f / 30.f)) * chance);
2433
2434 return chance;
2435}
@ SPELL_DAMAGE_CLASS_MELEE
Definition SharedDefines.h:1551
@ SPELLMOD_CHANCE_OF_SUCCESS
Definition SpellDefines.h:102
@ PROC_ATTR_REDUCE_PROC_60
Definition SpellMgr.h:281
WeaponAttackType GetAttackType() const
Definition Unit.h:380
HealInfo * GetHealInfo() const
Definition Unit.h:479
SpellInfo const * GetSpellInfo() const
Definition Unit.cpp:301
Unit * GetActor()
Definition Unit.h:468
DamageInfo * GetDamageInfo() const
Definition Unit.h:478
Definition SpellInfo.h:340
SpellCastTimesEntry const * CastTimeEntry
Definition SpellInfo.h:371
uint32 DmgClass
Definition SpellInfo.h:413
bool IsRangedWeaponSpell() const
Definition SpellInfo.cpp:1321
uint8 GetLevel() const
Definition Unit.h:1117
int32 CastTime
Definition DBCStructure.h:1796

References SpellProcEntry::AttributesMask, SpellCastTimesEntry::CastTime, SpellInfo::CastTimeEntry, SpellProcEntry::Chance, SpellInfo::DmgClass, ProcEventInfo::GetActor(), DamageInfo::GetAttackType(), GetCaster(), ProcEventInfo::GetDamageInfo(), ProcEventInfo::GetHealInfo(), GetId(), Unit::GetLevel(), ProcEventInfo::GetSpellInfo(), GetSpellInfo(), Unit::GetSpellModOwner(), SpellInfo::IsRangedWeaponSpell(), PROC_ATTR_REDUCE_PROC_60, SpellProcEntry::ProcsPerMinute, SPELL_DAMAGE_CLASS_MELEE, and SPELLMOD_CHANCE_OF_SUCCESS.

Referenced by GetProcEffectMask().

◆ CallScriptAfterDispel()

void Aura::CallScriptAfterDispel ( DispelInfo *  dispelInfo)
2529{
2530 for (std::list<AuraScript*>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
2531 {
2532 (*scritr)->_PrepareScriptCall(AURA_SCRIPT_HOOK_AFTER_DISPEL);
2533 std::list<AuraScript::AuraDispelHandler>::iterator hookItrEnd = (*scritr)->AfterDispel.end(), hookItr = (*scritr)->AfterDispel.begin();
2534 for (; hookItr != hookItrEnd; ++hookItr)
2535 hookItr->Call(*scritr, dispelInfo);
2536
2537 (*scritr)->_FinishScriptCall();
2538 }
2539}
@ AURA_SCRIPT_HOOK_AFTER_DISPEL
Definition SpellScript.h:500

References AURA_SCRIPT_HOOK_AFTER_DISPEL, and m_loadedScripts.

Referenced by Unit::RemoveAurasDueToSpellByDispel().

◆ CallScriptAfterEffectApplyHandlers()

void Aura::CallScriptAfterEffectApplyHandlers ( AuraEffect const *  aurEff,
AuraApplication const *  aurApp,
AuraEffectHandleModes  mode 
)
2581{
2582 for (std::list<AuraScript*>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
2583 {
2584 (*scritr)->_PrepareScriptCall(AURA_SCRIPT_HOOK_EFFECT_AFTER_APPLY, aurApp);
2585 std::list<AuraScript::EffectApplyHandler>::iterator effEndItr = (*scritr)->AfterEffectApply.end(), effItr = (*scritr)->AfterEffectApply.begin();
2586 for (; effItr != effEndItr; ++effItr)
2587 if (effItr->IsEffectAffected(m_spellInfo, aurEff->GetEffIndex()))
2588 effItr->Call(*scritr, aurEff, mode);
2589
2590 (*scritr)->_FinishScriptCall();
2591 }
2592}
@ AURA_SCRIPT_HOOK_EFFECT_AFTER_APPLY
Definition SpellScript.h:485

References AURA_SCRIPT_HOOK_EFFECT_AFTER_APPLY, AuraEffect::GetEffIndex(), m_loadedScripts, and m_spellInfo.

Referenced by AuraEffect::HandleEffect().

◆ CallScriptAfterEffectProcHandlers()

void Aura::CallScriptAfterEffectProcHandlers ( AuraEffect const *  aurEff,
AuraApplication const *  aurApp,
ProcEventInfo &  eventInfo 
)
2860{
2861 for (std::list<AuraScript*>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
2862 {
2863 (*scritr)->_PrepareScriptCall(AURA_SCRIPT_HOOK_EFFECT_AFTER_PROC, aurApp);
2864 std::list<AuraScript::EffectProcHandler>::iterator effEndItr = (*scritr)->AfterEffectProc.end(), effItr = (*scritr)->AfterEffectProc.begin();
2865 for (; effItr != effEndItr; ++effItr)
2866 if (effItr->IsEffectAffected(m_spellInfo, aurEff->GetEffIndex()))
2867 effItr->Call(*scritr, aurEff, eventInfo);
2868
2869 (*scritr)->_FinishScriptCall();
2870 }
2871}
@ AURA_SCRIPT_HOOK_EFFECT_AFTER_PROC
Definition SpellScript.h:507

References AURA_SCRIPT_HOOK_EFFECT_AFTER_PROC, AuraEffect::GetEffIndex(), m_loadedScripts, and m_spellInfo.

Referenced by AuraEffect::HandleProc().

◆ CallScriptAfterEffectRemoveHandlers()

void Aura::CallScriptAfterEffectRemoveHandlers ( AuraEffect const *  aurEff,
AuraApplication const *  aurApp,
AuraEffectHandleModes  mode 
)
2595{
2596 for (std::list<AuraScript*>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
2597 {
2598 (*scritr)->_PrepareScriptCall(AURA_SCRIPT_HOOK_EFFECT_AFTER_REMOVE, aurApp);
2599 std::list<AuraScript::EffectApplyHandler>::iterator effEndItr = (*scritr)->AfterEffectRemove.end(), effItr = (*scritr)->AfterEffectRemove.begin();
2600 for (; effItr != effEndItr; ++effItr)
2601 if (effItr->IsEffectAffected(m_spellInfo, aurEff->GetEffIndex()))
2602 effItr->Call(*scritr, aurEff, mode);
2603
2604 (*scritr)->_FinishScriptCall();
2605 }
2606}
@ AURA_SCRIPT_HOOK_EFFECT_AFTER_REMOVE
Definition SpellScript.h:487

References AURA_SCRIPT_HOOK_EFFECT_AFTER_REMOVE, AuraEffect::GetEffIndex(), m_loadedScripts, and m_spellInfo.

Referenced by AuraEffect::HandleEffect().

◆ CallScriptAfterProcHandlers()

void Aura::CallScriptAfterProcHandlers ( AuraApplication const *  aurApp,
ProcEventInfo &  eventInfo 
)
2828{
2829 for (std::list<AuraScript*>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
2830 {
2831 (*scritr)->_PrepareScriptCall(AURA_SCRIPT_HOOK_AFTER_PROC, aurApp);
2832 std::list<AuraScript::AuraProcHandler>::iterator hookItrEnd = (*scritr)->AfterProc.end(), hookItr = (*scritr)->AfterProc.begin();
2833 for (; hookItr != hookItrEnd; ++hookItr)
2834 hookItr->Call(*scritr, eventInfo);
2835
2836 (*scritr)->_FinishScriptCall();
2837 }
2838}
@ AURA_SCRIPT_HOOK_AFTER_PROC
Definition SpellScript.h:508

References AURA_SCRIPT_HOOK_AFTER_PROC, and m_loadedScripts.

Referenced by TriggerProcOnEvent().

◆ CallScriptCheckAreaTargetHandlers()

bool Aura::CallScriptCheckAreaTargetHandlers ( Unit *  target)
2501{
2502 bool result = true;
2503 for (std::list<AuraScript*>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
2504 {
2505 (*scritr)->_PrepareScriptCall(AURA_SCRIPT_HOOK_CHECK_AREA_TARGET);
2506 std::list<AuraScript::CheckAreaTargetHandler>::iterator hookItrEnd = (*scritr)->DoCheckAreaTarget.end(), hookItr = (*scritr)->DoCheckAreaTarget.begin();
2507 for (; hookItr != hookItrEnd; ++hookItr)
2508 result &= hookItr->Call(*scritr, target);
2509
2510 (*scritr)->_FinishScriptCall();
2511 }
2512 return result;
2513}
@ AURA_SCRIPT_HOOK_CHECK_AREA_TARGET
Definition SpellScript.h:498

References AURA_SCRIPT_HOOK_CHECK_AREA_TARGET, and m_loadedScripts.

Referenced by CheckAreaTarget().

◆ CallScriptCheckEffectProcHandlers()

bool Aura::CallScriptCheckEffectProcHandlers ( AuraEffect const *  aurEff,
AuraApplication const *  aurApp,
ProcEventInfo &  eventInfo 
)
2775{
2776 bool result = true;
2777 for (std::list<AuraScript*>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
2778 {
2779 (*scritr)->_PrepareScriptCall(AURA_SCRIPT_HOOK_CHECK_EFFECT_PROC, aurApp);
2780 std::list<AuraScript::CheckEffectProcHandler>::iterator effEndItr = (*scritr)->DoCheckEffectProc.end(), effItr = (*scritr)->DoCheckEffectProc.begin();
2781 for (; effItr != effEndItr; ++effItr)
2782 if (effItr->IsEffectAffected(m_spellInfo, aurEff->GetEffIndex()))
2783 result &= effItr->Call(*scritr, aurEff, eventInfo);
2784
2785 (*scritr)->_FinishScriptCall();
2786 }
2787
2788 return result;
2789}
@ AURA_SCRIPT_HOOK_CHECK_EFFECT_PROC
Definition SpellScript.h:503

References AURA_SCRIPT_HOOK_CHECK_EFFECT_PROC, AuraEffect::GetEffIndex(), m_loadedScripts, and m_spellInfo.

Referenced by AuraEffect::CheckEffectProc().

◆ CallScriptCheckProcHandlers()

bool Aura::CallScriptCheckProcHandlers ( AuraApplication const *  aurApp,
ProcEventInfo &  eventInfo 
)
2759{
2760 bool result = true;
2761 for (std::list<AuraScript*>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
2762 {
2763 (*scritr)->_PrepareScriptCall(AURA_SCRIPT_HOOK_CHECK_PROC, aurApp);
2764 std::list<AuraScript::CheckProcHandler>::iterator hookItrEnd = (*scritr)->DoCheckProc.end(), hookItr = (*scritr)->DoCheckProc.begin();
2765 for (; hookItr != hookItrEnd; ++hookItr)
2766 result &= hookItr->Call(*scritr, eventInfo);
2767
2768 (*scritr)->_FinishScriptCall();
2769 }
2770
2771 return result;
2772}
@ AURA_SCRIPT_HOOK_CHECK_PROC
Definition SpellScript.h:502

References AURA_SCRIPT_HOOK_CHECK_PROC, and m_loadedScripts.

Referenced by GetProcEffectMask().

◆ CallScriptDispel()

void Aura::CallScriptDispel ( DispelInfo *  dispelInfo)
2516{
2517 for (std::list<AuraScript*>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
2518 {
2519 (*scritr)->_PrepareScriptCall(AURA_SCRIPT_HOOK_DISPEL);
2520 std::list<AuraScript::AuraDispelHandler>::iterator hookItrEnd = (*scritr)->OnDispel.end(), hookItr = (*scritr)->OnDispel.begin();
2521 for (; hookItr != hookItrEnd; ++hookItr)
2522 hookItr->Call(*scritr, dispelInfo);
2523
2524 (*scritr)->_FinishScriptCall();
2525 }
2526}
@ AURA_SCRIPT_HOOK_DISPEL
Definition SpellScript.h:499

References AURA_SCRIPT_HOOK_DISPEL, and m_loadedScripts.

Referenced by Unit::RemoveAurasDueToSpellByDispel().

◆ CallScriptEffectAbsorbHandlers()

void Aura::CallScriptEffectAbsorbHandlers ( AuraEffect *  aurEff,
AuraApplication const *  aurApp,
DamageInfo &  dmgInfo,
uint32 &  absorbAmount,
bool &  defaultPrevented 
)
2685{
2686 for (std::list<AuraScript*>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
2687 {
2688 (*scritr)->_PrepareScriptCall(AURA_SCRIPT_HOOK_EFFECT_ABSORB, aurApp);
2689 std::list<AuraScript::EffectAbsorbHandler>::iterator effEndItr = (*scritr)->OnEffectAbsorb.end(), effItr = (*scritr)->OnEffectAbsorb.begin();
2690 for (; effItr != effEndItr; ++effItr)
2691
2692 if (effItr->IsEffectAffected(m_spellInfo, aurEff->GetEffIndex()))
2693 effItr->Call(*scritr, aurEff, dmgInfo, absorbAmount);
2694
2695 if (!defaultPrevented)
2696 defaultPrevented = (*scritr)->_IsDefaultActionPrevented();
2697
2698 (*scritr)->_FinishScriptCall();
2699 }
2700}
@ AURA_SCRIPT_HOOK_EFFECT_ABSORB
Definition SpellScript.h:493
uint32 GetEffIndex() const
Definition SpellAuraEffects.h:56

References AURA_SCRIPT_HOOK_EFFECT_ABSORB, AuraEffect::GetEffIndex(), m_loadedScripts, and m_spellInfo.

Referenced by Unit::CalcAbsorbResist().

◆ CallScriptEffectAfterAbsorbHandlers()

void Aura::CallScriptEffectAfterAbsorbHandlers ( AuraEffect *  aurEff,
AuraApplication const *  aurApp,
DamageInfo &  dmgInfo,
uint32 &  absorbAmount 
)
2703{
2704 for (std::list<AuraScript*>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
2705 {
2706 (*scritr)->_PrepareScriptCall(AURA_SCRIPT_HOOK_EFFECT_AFTER_ABSORB, aurApp);
2707 std::list<AuraScript::EffectAbsorbHandler>::iterator effEndItr = (*scritr)->AfterEffectAbsorb.end(), effItr = (*scritr)->AfterEffectAbsorb.begin();
2708 for (; effItr != effEndItr; ++effItr)
2709 if (effItr->IsEffectAffected(m_spellInfo, aurEff->GetEffIndex()))
2710 effItr->Call(*scritr, aurEff, dmgInfo, absorbAmount);
2711
2712 (*scritr)->_FinishScriptCall();
2713 }
2714}
@ AURA_SCRIPT_HOOK_EFFECT_AFTER_ABSORB
Definition SpellScript.h:494

References AURA_SCRIPT_HOOK_EFFECT_AFTER_ABSORB, AuraEffect::GetEffIndex(), m_loadedScripts, and m_spellInfo.

Referenced by Unit::CalcAbsorbResist().

◆ CallScriptEffectAfterManaShieldHandlers()

void Aura::CallScriptEffectAfterManaShieldHandlers ( AuraEffect *  aurEff,
AuraApplication const *  aurApp,
DamageInfo &  dmgInfo,
uint32 &  absorbAmount 
)
2731{
2732 for (std::list<AuraScript*>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
2733 {
2734 (*scritr)->_PrepareScriptCall(AURA_SCRIPT_HOOK_EFFECT_AFTER_MANASHIELD, aurApp);
2735 std::list<AuraScript::EffectManaShieldHandler>::iterator effEndItr = (*scritr)->AfterEffectManaShield.end(), effItr = (*scritr)->AfterEffectManaShield.begin();
2736 for (; effItr != effEndItr; ++effItr)
2737 if (effItr->IsEffectAffected(m_spellInfo, aurEff->GetEffIndex()))
2738 effItr->Call(*scritr, aurEff, dmgInfo, absorbAmount);
2739
2740 (*scritr)->_FinishScriptCall();
2741 }
2742}
@ AURA_SCRIPT_HOOK_EFFECT_AFTER_MANASHIELD
Definition SpellScript.h:496

References AURA_SCRIPT_HOOK_EFFECT_AFTER_MANASHIELD, AuraEffect::GetEffIndex(), m_loadedScripts, and m_spellInfo.

Referenced by Unit::CalcAbsorbResist().

◆ CallScriptEffectApplyHandlers()

bool Aura::CallScriptEffectApplyHandlers ( AuraEffect const *  aurEff,
AuraApplication const *  aurApp,
AuraEffectHandleModes  mode 
)
2542{
2543 bool preventDefault = false;
2544 for (std::list<AuraScript*>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
2545 {
2546 (*scritr)->_PrepareScriptCall(AURA_SCRIPT_HOOK_EFFECT_APPLY, aurApp);
2547 std::list<AuraScript::EffectApplyHandler>::iterator effEndItr = (*scritr)->OnEffectApply.end(), effItr = (*scritr)->OnEffectApply.begin();
2548 for (; effItr != effEndItr; ++effItr)
2549 if (effItr->IsEffectAffected(m_spellInfo, aurEff->GetEffIndex()))
2550 effItr->Call(*scritr, aurEff, mode);
2551
2552 if (!preventDefault)
2553 preventDefault = (*scritr)->_IsDefaultActionPrevented();
2554
2555 (*scritr)->_FinishScriptCall();
2556 }
2557
2558 return preventDefault;
2559}
@ AURA_SCRIPT_HOOK_EFFECT_APPLY
Definition SpellScript.h:484

References AURA_SCRIPT_HOOK_EFFECT_APPLY, AuraEffect::GetEffIndex(), m_loadedScripts, and m_spellInfo.

Referenced by AuraEffect::HandleEffect().

◆ CallScriptEffectCalcAmountHandlers()

void Aura::CallScriptEffectCalcAmountHandlers ( AuraEffect const *  aurEff,
int32 &  amount,
bool &  canBeRecalculated 
)
2643{
2644 for (std::list<AuraScript*>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
2645 {
2646 (*scritr)->_PrepareScriptCall(AURA_SCRIPT_HOOK_EFFECT_CALC_AMOUNT);
2647 std::list<AuraScript::EffectCalcAmountHandler>::iterator effEndItr = (*scritr)->DoEffectCalcAmount.end(), effItr = (*scritr)->DoEffectCalcAmount.begin();
2648 for (; effItr != effEndItr; ++effItr)
2649 if (effItr->IsEffectAffected(m_spellInfo, aurEff->GetEffIndex()))
2650 effItr->Call(*scritr, aurEff, amount, canBeRecalculated);
2651
2652 (*scritr)->_FinishScriptCall();
2653 }
2654}
@ AURA_SCRIPT_HOOK_EFFECT_CALC_AMOUNT
Definition SpellScript.h:490

References AURA_SCRIPT_HOOK_EFFECT_CALC_AMOUNT, AuraEffect::GetEffIndex(), m_loadedScripts, and m_spellInfo.

Referenced by AuraEffect::CalculateAmount().

◆ CallScriptEffectCalcPeriodicHandlers()

void Aura::CallScriptEffectCalcPeriodicHandlers ( AuraEffect const *  aurEff,
bool &  isPeriodic,
int32 &  amplitude 
)
2657{
2658 for (std::list<AuraScript*>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
2659 {
2660 (*scritr)->_PrepareScriptCall(AURA_SCRIPT_HOOK_EFFECT_CALC_PERIODIC);
2661 std::list<AuraScript::EffectCalcPeriodicHandler>::iterator effEndItr = (*scritr)->DoEffectCalcPeriodic.end(), effItr = (*scritr)->DoEffectCalcPeriodic.begin();
2662 for (; effItr != effEndItr; ++effItr)
2663 if (effItr->IsEffectAffected(m_spellInfo, aurEff->GetEffIndex()))
2664 effItr->Call(*scritr, aurEff, isPeriodic, amplitude);
2665
2666 (*scritr)->_FinishScriptCall();
2667 }
2668}
@ AURA_SCRIPT_HOOK_EFFECT_CALC_PERIODIC
Definition SpellScript.h:491

References AURA_SCRIPT_HOOK_EFFECT_CALC_PERIODIC, AuraEffect::GetEffIndex(), m_loadedScripts, and m_spellInfo.

Referenced by AuraEffect::CalculatePeriodic().

◆ CallScriptEffectCalcSpellModHandlers()

void Aura::CallScriptEffectCalcSpellModHandlers ( AuraEffect const *  aurEff,
SpellModifier *&  spellMod 
)
2671{
2672 for (std::list<AuraScript*>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
2673 {
2674 (*scritr)->_PrepareScriptCall(AURA_SCRIPT_HOOK_EFFECT_CALC_SPELLMOD);
2675 std::list<AuraScript::EffectCalcSpellModHandler>::iterator effEndItr = (*scritr)->DoEffectCalcSpellMod.end(), effItr = (*scritr)->DoEffectCalcSpellMod.begin();
2676 for (; effItr != effEndItr; ++effItr)
2677 if (effItr->IsEffectAffected(m_spellInfo, aurEff->GetEffIndex()))
2678 effItr->Call(*scritr, aurEff, spellMod);
2679
2680 (*scritr)->_FinishScriptCall();
2681 }
2682}
@ AURA_SCRIPT_HOOK_EFFECT_CALC_SPELLMOD
Definition SpellScript.h:492

References AURA_SCRIPT_HOOK_EFFECT_CALC_SPELLMOD, AuraEffect::GetEffIndex(), m_loadedScripts, and m_spellInfo.

Referenced by AuraEffect::CalculateSpellMod().

◆ CallScriptEffectManaShieldHandlers()

void Aura::CallScriptEffectManaShieldHandlers ( AuraEffect *  aurEff,
AuraApplication const *  aurApp,
DamageInfo &  dmgInfo,
uint32 &  absorbAmount,
bool &  defaultPrevented 
)
2717{
2718 for (std::list<AuraScript*>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
2719 {
2720 (*scritr)->_PrepareScriptCall(AURA_SCRIPT_HOOK_EFFECT_MANASHIELD, aurApp);
2721 std::list<AuraScript::EffectManaShieldHandler>::iterator effEndItr = (*scritr)->OnEffectManaShield.end(), effItr = (*scritr)->OnEffectManaShield.begin();
2722 for (; effItr != effEndItr; ++effItr)
2723 if (effItr->IsEffectAffected(m_spellInfo, aurEff->GetEffIndex()))
2724 effItr->Call(*scritr, aurEff, dmgInfo, absorbAmount);
2725
2726 (*scritr)->_FinishScriptCall();
2727 }
2728}
@ AURA_SCRIPT_HOOK_EFFECT_MANASHIELD
Definition SpellScript.h:495

References AURA_SCRIPT_HOOK_EFFECT_MANASHIELD, AuraEffect::GetEffIndex(), m_loadedScripts, and m_spellInfo.

Referenced by Unit::CalcAbsorbResist().

◆ CallScriptEffectPeriodicHandlers()

bool Aura::CallScriptEffectPeriodicHandlers ( AuraEffect const *  aurEff,
AuraApplication const *  aurApp 
)
2609{
2610 bool preventDefault = false;
2611 for (std::list<AuraScript*>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
2612 {
2613 (*scritr)->_PrepareScriptCall(AURA_SCRIPT_HOOK_EFFECT_PERIODIC, aurApp);
2614 std::list<AuraScript::EffectPeriodicHandler>::iterator effEndItr = (*scritr)->OnEffectPeriodic.end(), effItr = (*scritr)->OnEffectPeriodic.begin();
2615 for (; effItr != effEndItr; ++effItr)
2616 if (effItr->IsEffectAffected(m_spellInfo, aurEff->GetEffIndex()))
2617 effItr->Call(*scritr, aurEff);
2618
2619 if (!preventDefault)
2620 preventDefault = (*scritr)->_IsDefaultActionPrevented();
2621
2622 (*scritr)->_FinishScriptCall();
2623 }
2624
2625 return preventDefault;
2626}
@ AURA_SCRIPT_HOOK_EFFECT_PERIODIC
Definition SpellScript.h:488

References AURA_SCRIPT_HOOK_EFFECT_PERIODIC, AuraEffect::GetEffIndex(), m_loadedScripts, and m_spellInfo.

Referenced by AuraEffect::PeriodicTick().

◆ CallScriptEffectProcHandlers()

bool Aura::CallScriptEffectProcHandlers ( AuraEffect const *  aurEff,
AuraApplication const *  aurApp,
ProcEventInfo &  eventInfo 
)
2841{
2842 bool preventDefault = false;
2843 for (std::list<AuraScript*>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
2844 {
2845 (*scritr)->_PrepareScriptCall(AURA_SCRIPT_HOOK_EFFECT_PROC, aurApp);
2846 std::list<AuraScript::EffectProcHandler>::iterator effEndItr = (*scritr)->OnEffectProc.end(), effItr = (*scritr)->OnEffectProc.begin();
2847 for (; effItr != effEndItr; ++effItr)
2848 if (effItr->IsEffectAffected(m_spellInfo, aurEff->GetEffIndex()))
2849 effItr->Call(*scritr, aurEff, eventInfo);
2850
2851 if (!preventDefault)
2852 preventDefault = (*scritr)->_IsDefaultActionPrevented();
2853
2854 (*scritr)->_FinishScriptCall();
2855 }
2856 return preventDefault;
2857}
@ AURA_SCRIPT_HOOK_EFFECT_PROC
Definition SpellScript.h:506

References AURA_SCRIPT_HOOK_EFFECT_PROC, AuraEffect::GetEffIndex(), m_loadedScripts, and m_spellInfo.

Referenced by AuraEffect::HandleProc().

◆ CallScriptEffectRemoveHandlers()

bool Aura::CallScriptEffectRemoveHandlers ( AuraEffect const *  aurEff,
AuraApplication const *  aurApp,
AuraEffectHandleModes  mode 
)
2562{
2563 bool preventDefault = false;
2564 for (std::list<AuraScript*>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
2565 {
2566 (*scritr)->_PrepareScriptCall(AURA_SCRIPT_HOOK_EFFECT_REMOVE, aurApp);
2567 std::list<AuraScript::EffectApplyHandler>::iterator effEndItr = (*scritr)->OnEffectRemove.end(), effItr = (*scritr)->OnEffectRemove.begin();
2568 for (; effItr != effEndItr; ++effItr)
2569 if (effItr->IsEffectAffected(m_spellInfo, aurEff->GetEffIndex()))
2570 effItr->Call(*scritr, aurEff, mode);
2571
2572 if (!preventDefault)
2573 preventDefault = (*scritr)->_IsDefaultActionPrevented();
2574
2575 (*scritr)->_FinishScriptCall();
2576 }
2577 return preventDefault;
2578}
@ AURA_SCRIPT_HOOK_EFFECT_REMOVE
Definition SpellScript.h:486

References AURA_SCRIPT_HOOK_EFFECT_REMOVE, AuraEffect::GetEffIndex(), m_loadedScripts, and m_spellInfo.

Referenced by AuraEffect::HandleEffect().

◆ CallScriptEffectSplitHandlers()

void Aura::CallScriptEffectSplitHandlers ( AuraEffect *  aurEff,
AuraApplication const *  aurApp,
DamageInfo &  dmgInfo,
uint32 &  splitAmount 
)
2745{
2746 for (std::list<AuraScript*>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
2747 {
2748 (*scritr)->_PrepareScriptCall(AURA_SCRIPT_HOOK_EFFECT_SPLIT, aurApp);
2749 std::list<AuraScript::EffectSplitHandler>::iterator effEndItr = (*scritr)->OnEffectSplit.end(), effItr = (*scritr)->OnEffectSplit.begin();
2750 for (; effItr != effEndItr; ++effItr)
2751 if (effItr->IsEffectAffected(m_spellInfo, aurEff->GetEffIndex()))
2752 effItr->Call(*scritr, aurEff, dmgInfo, splitAmount);
2753
2754 (*scritr)->_FinishScriptCall();
2755 }
2756}
@ AURA_SCRIPT_HOOK_EFFECT_SPLIT
Definition SpellScript.h:497

References AURA_SCRIPT_HOOK_EFFECT_SPLIT, AuraEffect::GetEffIndex(), m_loadedScripts, and m_spellInfo.

◆ CallScriptEffectUpdatePeriodicHandlers()

void Aura::CallScriptEffectUpdatePeriodicHandlers ( AuraEffect *  aurEff)
2629{
2630 for (std::list<AuraScript*>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
2631 {
2632 (*scritr)->_PrepareScriptCall(AURA_SCRIPT_HOOK_EFFECT_UPDATE_PERIODIC);
2633 std::list<AuraScript::EffectUpdatePeriodicHandler>::iterator effEndItr = (*scritr)->OnEffectUpdatePeriodic.end(), effItr = (*scritr)->OnEffectUpdatePeriodic.begin();
2634 for (; effItr != effEndItr; ++effItr)
2635 if (effItr->IsEffectAffected(m_spellInfo, aurEff->GetEffIndex()))
2636 effItr->Call(*scritr, aurEff);
2637
2638 (*scritr)->_FinishScriptCall();
2639 }
2640}
@ AURA_SCRIPT_HOOK_EFFECT_UPDATE_PERIODIC
Definition SpellScript.h:489

References AURA_SCRIPT_HOOK_EFFECT_UPDATE_PERIODIC, AuraEffect::GetEffIndex(), m_loadedScripts, and m_spellInfo.

Referenced by AuraEffect::UpdatePeriodic().

◆ CallScriptPrepareProcHandlers()

bool Aura::CallScriptPrepareProcHandlers ( AuraApplication const *  aurApp,
ProcEventInfo &  eventInfo 
)
2792{
2793 bool prepare = true;
2794 for (std::list<AuraScript*>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
2795 {
2796 (*scritr)->_PrepareScriptCall(AURA_SCRIPT_HOOK_PREPARE_PROC, aurApp);
2797 std::list<AuraScript::AuraProcHandler>::iterator effEndItr = (*scritr)->DoPrepareProc.end(), effItr = (*scritr)->DoPrepareProc.begin();
2798 for (; effItr != effEndItr; ++effItr)
2799 effItr->Call(*scritr, eventInfo);
2800
2801 if (prepare)
2802 prepare = !(*scritr)->_IsDefaultActionPrevented();
2803
2804 (*scritr)->_FinishScriptCall();
2805 }
2806
2807 return prepare;
2808}
@ AURA_SCRIPT_HOOK_PREPARE_PROC
Definition SpellScript.h:504

References AURA_SCRIPT_HOOK_PREPARE_PROC, and m_loadedScripts.

Referenced by PrepareProcToTrigger().

◆ CallScriptProcHandlers()

bool Aura::CallScriptProcHandlers ( AuraApplication const *  aurApp,
ProcEventInfo &  eventInfo 
)
2811{
2812 bool handled = false;
2813 for (std::list<AuraScript*>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
2814 {
2815 (*scritr)->_PrepareScriptCall(AURA_SCRIPT_HOOK_PROC, aurApp);
2816 std::list<AuraScript::AuraProcHandler>::iterator hookItrEnd = (*scritr)->OnProc.end(), hookItr = (*scritr)->OnProc.begin();
2817 for (; hookItr != hookItrEnd; ++hookItr)
2818 hookItr->Call(*scritr, eventInfo);
2819
2820 handled |= (*scritr)->_IsDefaultActionPrevented();
2821 (*scritr)->_FinishScriptCall();
2822 }
2823
2824 return handled;
2825}
@ AURA_SCRIPT_HOOK_PROC
Definition SpellScript.h:505

References AURA_SCRIPT_HOOK_PROC, and m_loadedScripts.

Referenced by TriggerProcOnEvent().

◆ CanBeAppliedOn()

bool Aura::CanBeAppliedOn ( Unit *  target)
2011{
2012 // unit not in world or during remove from world
2013 if (!target->IsInWorld() || target->IsDuringRemoveFromWorld())
2014 {
2015 // area auras mustn't be applied
2016 if (GetOwner() != target)
2017 return false;
2018 // not selfcasted single target auras mustn't be applied
2019 if (GetCasterGUID() != GetOwner()->GetGUID() && GetSpellInfo()->IsSingleTarget())
2020 return false;
2021 return true;
2022 }
2023 else
2024 return CheckAreaTarget(target);
2025}
bool CheckAreaTarget(Unit *target)
Definition SpellAuras.cpp:2027
ObjectGuid GetCasterGUID() const
Definition SpellAuras.h:106
bool IsSingleTarget() const
Definition SpellAuras.h:167
bool IsInWorld() const
Definition Object.h:115
bool IsDuringRemoveFromWorld() const
Definition Unit.h:709

References CheckAreaTarget(), GetCasterGUID(), GetOwner(), GetSpellInfo(), Unit::IsDuringRemoveFromWorld(), Object::IsInWorld(), and IsSingleTarget().

Referenced by UpdateTargetMap().

◆ CanBeSaved()

bool Aura::CanBeSaved ( ) const
1164{
1165 SpellInfo const* spellInfo = GetSpellInfo();
1166
1168 {
1169 return true;
1170 }
1171
1173 {
1174 return false;
1175 }
1176
1177 if (IsPassive() || (spellInfo->HasAttribute(SPELL_ATTR0_DO_NOT_DISPLAY) && spellInfo->Stances))
1178 {
1179 return false;
1180 }
1181
1182 // GameObject-cast auras have no caster guid (cleared in Aura::Create) and cannot
1183 // be restored on login - do not save them
1184 if (!GetCasterGUID())
1185 {
1186 return false;
1187 }
1188
1189 // Xinef: do not save channel auras
1190 if (GetSpellInfo()->IsChanneled())
1191 {
1192 return false;
1193 }
1194
1195 // Xinef: Check if aura is single target, not only spell info
1196 if (GetCasterGUID() != GetOwner()->GetGUID() && (GetSpellInfo()->IsSingleTarget() || IsSingleTarget()))
1197 {
1198 return false;
1199 }
1200
1201 // don't save auras removed by proc system
1202 if (IsUsingCharges() && !GetCharges())
1203 {
1204 return false;
1205 }
1206
1207 return true;
1208}
@ SPELL_ATTR0_DO_NOT_DISPLAY
Definition SharedDefines.h:377
@ SPELL_ATTR0_CU_FORCE_AURA_SAVING
Definition SpellInfo.h:206
@ SPELL_ATTR0_CU_AURA_CANNOT_BE_SAVED
Definition SpellInfo.h:201
bool IsUsingCharges() const
Definition SpellAuras.h:202
uint8 GetCharges() const
Definition SpellAuras.h:143
uint32 Stances
Definition SpellInfo.h:357

References GetCasterGUID(), GetCharges(), GetOwner(), GetSpellInfo(), SpellInfo::HasAttribute(), IsPassive(), IsSingleTarget(), IsUsingCharges(), SPELL_ATTR0_CU_AURA_CANNOT_BE_SAVED, SPELL_ATTR0_CU_FORCE_AURA_SAVING, SPELL_ATTR0_DO_NOT_DISPLAY, and SpellInfo::Stances.

◆ CanBeSentToClient()

bool Aura::CanBeSentToClient ( ) const
1211{
1213}
@ SPELL_AURA_ABILITY_IGNORE_AURASTATE
Definition SpellAuraDefines.h:325
bool HasEffectType(AuraType type) const
Definition SpellAuras.cpp:1296
bool HasAreaAuraEffect() const
Definition SpellInfo.cpp:922

References GetSpellInfo(), SpellInfo::HasAreaAuraEffect(), HasEffectType(), IsPassive(), and SPELL_AURA_ABILITY_IGNORE_AURASTATE.

Referenced by Spell::EffectSummonPet().

◆ CanStackWith()

bool Aura::CanStackWith ( Aura const *  existingAura) const
2062{
2063 // Can stack with self
2064 if (this == existingAura)
2065 return true;
2066
2067 SpellInfo const* existingSpellInfo = existingAura->GetSpellInfo();
2068 bool sameCaster = GetCasterGUID() == existingAura->GetCasterGUID();
2069
2070 // Dynobj auras always stack
2071 // xinef: dont allow different ranks (or the same rank) of same spell to stack (many flamestrikes for example)
2072 if (existingAura->GetType() == DYNOBJ_AURA_TYPE)
2073 {
2074 // xinef: desecration lag fix - bound this condition to periodics
2075 if (sameCaster && GetSpellInfo()->Id == existingSpellInfo->Id && GetSpellInfo()->HasAura(SPELL_AURA_PERIODIC_DAMAGE))
2076 return false;
2077 return true;
2078 }
2079
2080 // passive auras don't stack with another rank of the spell cast by same caster
2081 // Exception: item-sourced auras from different items can stack (e.g., weapon imbues on MH/OH)
2082 if (IsPassive() && sameCaster && (m_spellInfo->IsDifferentRankOf(existingSpellInfo) || (m_spellInfo->Id == existingSpellInfo->Id && m_castItemGuid.IsEmpty())))
2083 {
2084 // Allow stacking if both auras are from different items
2085 if (!(GetCastItemGUID() && existingAura->GetCastItemGUID() && GetCastItemGUID() != existingAura->GetCastItemGUID()))
2086 return false;
2087 }
2088
2089 for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
2090 {
2091 // prevent remove triggering aura by triggered aura
2092 if (existingSpellInfo->Effects[i].TriggerSpell == GetId()
2093 // prevent remove triggered aura by triggering aura refresh
2094 || m_spellInfo->Effects[i].TriggerSpell == existingAura->GetId())
2095 return true;
2096 }
2097
2098 // check spell specific stack rules
2099 if (m_spellInfo->IsAuraExclusiveBySpecificWith(existingSpellInfo)
2100 || (sameCaster && m_spellInfo->IsAuraExclusiveBySpecificPerCasterWith(existingSpellInfo)))
2101 return false;
2102
2103 // check spell group stack rules
2104 switch (sSpellMgr->CheckSpellGroupStackRules(m_spellInfo, existingSpellInfo))
2105 {
2107 case SPELL_GROUP_STACK_RULE_EXCLUSIVE_HIGHEST: // if it reaches this point, existing aura is lower/equal
2108 return false;
2110 if (sameCaster)
2111 return false;
2112 break;
2115 default:
2116 break;
2117 }
2118
2119 if (m_spellInfo->SpellFamilyName != existingSpellInfo->SpellFamilyName)
2120 return true;
2121
2122 if (!sameCaster)
2123 {
2124 // Channeled auras can stack if not forbidden by db or aura type
2125 if (existingAura->GetSpellInfo()->IsChanneled())
2126 return true;
2127
2129 return true;
2130
2131 // check same periodic auras
2132 for (uint32 i = 0; i < MAX_SPELL_EFFECTS; ++i)
2133 {
2134 switch (m_spellInfo->Effects[i].ApplyAuraName)
2135 {
2136 // DOT or HOT from different casters will stack
2148 // periodic auras which target areas are not allowed to stack this way (replenishment for example)
2149 if (m_spellInfo->Effects[i].IsTargetingArea() || existingSpellInfo->Effects[i].IsTargetingArea())
2150 break;
2151 return true;
2152 default:
2153 break;
2154 }
2155 }
2156 }
2157
2158 uint8 VehicleAura1 = 0;
2159 uint8 VehicleAura2 = 0;
2160 uint8 i = 0;
2161 while (i < MAX_SPELL_EFFECTS && !(VehicleAura1 && VehicleAura2))
2162 {
2163 if (m_spellInfo->Effects[i].ApplyAuraName == SPELL_AURA_CONTROL_VEHICLE)
2164 VehicleAura1 = i + 1;
2165 if (existingSpellInfo->Effects[i].ApplyAuraName == SPELL_AURA_CONTROL_VEHICLE)
2166 VehicleAura2 = i + 1;
2167
2168 ++i;
2169 }
2170
2171 if (VehicleAura1 && VehicleAura2)
2172 {
2173 Vehicle* veh = nullptr;
2174 if (GetOwner()->ToUnit())
2175 veh = GetOwner()->ToUnit()->GetVehicleKit();
2176
2177 if (!veh) // We should probably just let it stack. Vehicle system will prevent undefined behaviour later
2178 return true;
2179
2180 // xinef: allow direct auras to stack if there is no passenger in this slot
2181 if (AuraEffect* aurEff = GetEffect(VehicleAura1 - 1))
2182 if (aurEff->GetAmount() > 0)
2183 if (!veh->GetPassenger(aurEff->GetAmount() - 1))
2184 return true;
2185
2186 if (!veh->GetAvailableSeatCount())
2187 return false; // No empty seat available
2188
2189 return true; // Empty seat available (skip rest)
2190 }
2191
2192 // spell of same spell rank chain
2193 if (m_spellInfo->IsRankOf(existingSpellInfo) && !(m_spellInfo->SpellFamilyName == SPELLFAMILY_HUNTER && m_spellInfo->SpellFamilyFlags[1] & 0x80000000))
2194 {
2195 // Each paladin's aura applies independently to group members (Aura Mastery and the
2196 // improved-aura talents depend on the caster's own aura being applied); only the
2197 // strongest keeps its effects on a shared target, see Aura::UpdateTargetMap.
2198 if (!sameCaster && m_spellInfo->GetSpellSpecific() == SPELL_SPECIFIC_AURA)
2199 return true;
2200
2201 // don't allow passive area auras to stack
2202 if (m_spellInfo->IsMultiSlotAura() && !IsArea())
2203 return true;
2204
2205 // Allow item-sourced auras from different items to stack (e.g., weapon imbues on MH/OH, enchant procs)
2206 if ((IsPassive() || m_spellInfo->HasAttribute(SPELL_ATTR0_CU_ENCHANT_PROC)) && GetCastItemGUID() && existingAura->GetCastItemGUID() && GetCastItemGUID() != existingAura->GetCastItemGUID())
2207 return true;
2208
2209 // same spell with same caster should not stack
2210 return false;
2211 }
2212
2213 return true;
2214}
@ SPELL_ATTR3_DOT_STACKING_RULE
Definition SharedDefines.h:488
@ SPELLFAMILY_HUNTER
Definition SharedDefines.h:3793
@ SPELL_AURA_PERIODIC_DAMAGE
Definition SpellAuraDefines.h:66
@ SPELL_AURA_OBS_MOD_HEALTH
Definition SpellAuraDefines.h:83
@ SPELL_AURA_PERIODIC_MANA_LEECH
Definition SpellAuraDefines.h:127
@ SPELL_AURA_OBS_MOD_POWER
Definition SpellAuraDefines.h:84
@ SPELL_AURA_CONTROL_VEHICLE
Definition SpellAuraDefines.h:299
@ SPELL_AURA_PERIODIC_HEAL
Definition SpellAuraDefines.h:71
@ SPELL_AURA_PERIODIC_TRIGGER_SPELL_WITH_VALUE
Definition SpellAuraDefines.h:290
@ SPELL_AURA_PERIODIC_ENERGIZE
Definition SpellAuraDefines.h:87
@ SPELL_AURA_PERIODIC_LEECH
Definition SpellAuraDefines.h:116
@ SPELL_AURA_POWER_BURN
Definition SpellAuraDefines.h:225
@ SPELL_AURA_PERIODIC_DUMMY
Definition SpellAuraDefines.h:289
@ SPELL_AURA_PERIODIC_TRIGGER_SPELL
Definition SpellAuraDefines.h:86
@ DYNOBJ_AURA_TYPE
Definition SpellAuraDefines.h:386
@ SPELL_ATTR0_CU_ENCHANT_PROC
Definition SpellInfo.h:177
@ SPELL_SPECIFIC_AURA
Definition SpellInfo.h:153
@ SPELL_GROUP_STACK_RULE_EXCLUSIVE_FROM_SAME_CASTER
Definition SpellMgr.h:364
@ SPELL_GROUP_STACK_RULE_EXCLUSIVE
Definition SpellMgr.h:363
@ SPELL_GROUP_STACK_RULE_DEFAULT
Definition SpellMgr.h:362
@ SPELL_GROUP_STACK_RULE_EXCLUSIVE_SAME_EFFECT
Definition SpellMgr.h:365
@ SPELL_GROUP_STACK_RULE_EXCLUSIVE_HIGHEST
Definition SpellMgr.h:366
bool IsArea() const
Definition SpellAuras.cpp:1138
AuraEffect * GetEffect(uint8 effIndex) const
Definition SpellAuras.h:178
ObjectGuid GetCastItemGUID() const
Definition SpellAuras.h:104
bool IsEmpty() const
Definition ObjectGuid.h:165
Unit * ToUnit()
Definition Object.h:216
bool IsRankOf(SpellInfo const *spellInfo) const
Definition SpellInfo.cpp:3020
flag96 SpellFamilyFlags
Definition SpellInfo.h:412
bool IsAuraExclusiveBySpecificPerCasterWith(SpellInfo const *spellInfo) const
Definition SpellInfo.cpp:1449
bool IsAuraExclusiveBySpecificWith(SpellInfo const *spellInfo) const
Definition SpellInfo.cpp:1406
SpellSpecificType GetSpellSpecific() const
Definition SpellInfo.cpp:2090
bool IsMultiSlotAura() const
Definition SpellInfo.cpp:1252
std::array< SpellEffectInfo, MAX_SPELL_EFFECTS > Effects
Definition SpellInfo.h:417
bool IsDifferentRankOf(SpellInfo const *spellInfo) const
Definition SpellInfo.cpp:3025
uint32 SpellFamilyName
Definition SpellInfo.h:411
Vehicle * GetVehicleKit() const
Definition Unit.h:1947
Definition Vehicle.h:28
uint8 GetAvailableSeatCount() const
Definition Vehicle.cpp:690
Unit * GetPassenger(int8 seatId) const
Definition Vehicle.cpp:266

References DYNOBJ_AURA_TYPE, SpellInfo::Effects, Vehicle::GetAvailableSeatCount(), GetCasterGUID(), GetCastItemGUID(), GetEffect(), GetId(), GetOwner(), Vehicle::GetPassenger(), GetSpellInfo(), SpellInfo::GetSpellSpecific(), GetType(), Unit::GetVehicleKit(), SpellInfo::HasAttribute(), SpellInfo::Id, IsArea(), SpellInfo::IsAuraExclusiveBySpecificPerCasterWith(), SpellInfo::IsAuraExclusiveBySpecificWith(), SpellInfo::IsChanneled(), SpellInfo::IsDifferentRankOf(), ObjectGuid::IsEmpty(), SpellInfo::IsMultiSlotAura(), IsPassive(), SpellInfo::IsRankOf(), m_castItemGuid, m_spellInfo, MAX_SPELL_EFFECTS, SPELL_ATTR0_CU_ENCHANT_PROC, SPELL_ATTR3_DOT_STACKING_RULE, SPELL_AURA_CONTROL_VEHICLE, SPELL_AURA_OBS_MOD_HEALTH, SPELL_AURA_OBS_MOD_POWER, SPELL_AURA_PERIODIC_DAMAGE, SPELL_AURA_PERIODIC_DUMMY, SPELL_AURA_PERIODIC_ENERGIZE, SPELL_AURA_PERIODIC_HEAL, SPELL_AURA_PERIODIC_LEECH, SPELL_AURA_PERIODIC_MANA_LEECH, SPELL_AURA_PERIODIC_TRIGGER_SPELL, SPELL_AURA_PERIODIC_TRIGGER_SPELL_WITH_VALUE, SPELL_AURA_POWER_BURN, SPELL_GROUP_STACK_RULE_DEFAULT, SPELL_GROUP_STACK_RULE_EXCLUSIVE, SPELL_GROUP_STACK_RULE_EXCLUSIVE_FROM_SAME_CASTER, SPELL_GROUP_STACK_RULE_EXCLUSIVE_HIGHEST, SPELL_GROUP_STACK_RULE_EXCLUSIVE_SAME_EFFECT, SPELL_SPECIFIC_AURA, SPELLFAMILY_HUNTER, SpellInfo::SpellFamilyFlags, SpellInfo::SpellFamilyName, sSpellMgr, and Object::ToUnit().

Referenced by Unit::_RemoveNoStackAurasDueToAura(), and UpdateTargetMap().

◆ CheckAreaTarget()

bool Aura::CheckAreaTarget ( Unit *  target)
2028{
2029 return CallScriptCheckAreaTargetHandlers(target);
2030}
bool CallScriptCheckAreaTargetHandlers(Unit *target)
Definition SpellAuras.cpp:2500

References CallScriptCheckAreaTargetHandlers().

Referenced by CanBeAppliedOn().

◆ ConsumeProcCharges()

void Aura::ConsumeProcCharges ( SpellProcEntry const *  procEntry)
2459{
2460 // Remove aura if we've used last charge to proc
2461 if (procEntry->AttributesMask & PROC_ATTR_USE_STACKS_FOR_CHARGES)
2462 {
2463 ModStackAmount(-1);
2464 }
2465 else if (IsUsingCharges())
2466 {
2467 if (!GetCharges())
2468 Remove();
2469 }
2470}
@ PROC_ATTR_USE_STACKS_FOR_CHARGES
Definition SpellMgr.h:280
bool ModStackAmount(int32 num, AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT, bool periodicReset=false)
Definition SpellAuras.cpp:1083
virtual void Remove(AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)=0

References SpellProcEntry::AttributesMask, GetCharges(), IsUsingCharges(), ModStackAmount(), PROC_ATTR_USE_STACKS_FOR_CHARGES, and Remove().

Referenced by TriggerProcOnEvent().

◆ Create()

Aura * Aura::Create ( SpellInfo const *  spellproto,
uint8  effMask,
WorldObject *  owner,
Unit *  caster,
int32 *  baseAmount,
Item *  castItem,
ObjectGuid  casterGUID,
ObjectGuid  itemGUID = ObjectGuid::Empty 
)
static
309{
310 ASSERT_NODEBUGINFO(effMask);
311 ASSERT_NODEBUGINFO(spellproto);
312 ASSERT_NODEBUGINFO(owner);
313 ASSERT_NODEBUGINFO(caster || casterGUID);
315 // try to get caster of aura
316 if (casterGUID)
317 {
318 // world gameobjects can't own auras and they send empty casterguid
319 // checked on sniffs with spell 22247
320 if (casterGUID.IsGameObject())
321 {
322 caster = nullptr;
323 casterGUID.Clear();
324 }
325 else if (owner->GetGUID() == casterGUID)
326 caster = owner->ToUnit();
327 else
328 caster = ObjectAccessor::GetUnit(*owner, casterGUID);
329 }
330 else
331 casterGUID = caster->GetGUID();
332
333 // check if aura can be owned by owner
334 if (owner->IsUnit())
335 if (!owner->IsInWorld() || ((Unit*)owner)->IsDuringRemoveFromWorld())
336 // owner not in world so don't allow to own not self casted single target auras
337 if (casterGUID != owner->GetGUID() && spellproto->IsSingleTarget())
338 return nullptr;
339
340 Aura* aura = nullptr;
341 switch (owner->GetTypeId())
342 {
343 case TYPEID_UNIT:
344 case TYPEID_PLAYER:
345 aura = new UnitAura(spellproto, effMask, owner, caster, baseAmount, castItem, casterGUID, itemGUID);
346 break;
348 aura = new DynObjAura(spellproto, effMask, owner, caster, baseAmount, castItem, casterGUID, itemGUID);
349 break;
350 default:
351 ABORT();
352 return nullptr;
353 }
354 // aura can be removed in Unit::_AddAura call
355 if (aura->IsRemoved())
356 return nullptr;
357 return aura;
358}
#define MAX_EFFECT_MASK
Definition DBCStructure.h:1674
Definition SpellAuras.h:88
bool IsRemoved() const
Definition SpellAuras.h:164
Definition SpellAuras.h:314
bool IsGameObject() const
Definition ObjectGuid.h:175
void Clear()
Definition ObjectGuid.h:141
bool IsUnit() const
Definition Object.h:215
Definition SpellAuras.h:291
Unit * GetUnit(WorldObject const &, ObjectGuid const &guid)
Definition ObjectAccessor.cpp:223

References ABORT, ASSERT_NODEBUGINFO, ObjectGuid::Clear(), Object::GetGUID(), Object::GetTypeId(), ObjectAccessor::GetUnit(), ObjectGuid::IsGameObject(), Object::IsInWorld(), IsRemoved(), SpellInfo::IsSingleTarget(), Object::IsUnit(), MAX_EFFECT_MASK, Object::ToUnit(), TYPEID_DYNAMICOBJECT, TYPEID_PLAYER, and TYPEID_UNIT.

Referenced by TryCreate(), and TryRefreshStackOrCreate().

◆ DropCharge()

bool Aura::DropCharge ( AuraRemoveMode  removeMode = AURA_REMOVE_BY_DEFAULT)
inline
148{ return ModCharges(-1, removeMode); }
bool ModCharges(int32 num, AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
Definition SpellAuras.cpp:1026

References ModCharges().

Referenced by AuraScript::DropCharge(), spell_sha_static_shock::HandleProc(), and Player::RemoveSpellMods().

◆ FillTargetMap()

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

Implemented in UnitAura, and DynObjAura.

Referenced by UpdateTargetMap().

◆ GetApplicationList()

void Aura::GetApplicationList ( std::list< AuraApplication * > &  applicationList) const
1324{
1325 for (Aura::ApplicationMap::const_iterator appIter = m_applications.begin(); appIter != m_applications.end(); ++appIter)
1326 {
1327 if (appIter->second->GetEffectMask())
1328 applicationList.push_back(appIter->second);
1329 }
1330}

References m_applications.

Referenced by SetStackAmount().

◆ GetApplicationMap()

ApplicationMap const & Aura::GetApplicationMap ( )
inline

◆ GetApplicationOfTarget() [1/2]

AuraApplication * Aura::GetApplicationOfTarget ( ObjectGuid  guid)
inline
187{ ApplicationMap::iterator itr = m_applications.find(guid); if (itr != m_applications.end()) return itr->second; return nullptr; }

References m_applications.

◆ GetApplicationOfTarget() [2/2]

◆ GetApplyTime()

time_t Aura::GetApplyTime ( ) const
inline

◆ GetCaster()

◆ GetCasterGUID()

◆ GetCasterLevel()

uint8 Aura::GetCasterLevel ( ) const
inline

◆ GetCastItemEntry()

uint32 Aura::GetCastItemEntry ( ) const
inline
105{ return m_castItemEntry; }

References m_castItemEntry.

◆ GetCastItemGUID()

◆ GetCharges()

◆ GetDebugInfo()

std::string Aura::GetDebugInfo ( ) const
virtual
2879{
2880 std::stringstream sstr;
2881 sstr << std::boolalpha
2882 << "Id: " << GetId() << " Caster: " << GetCasterGUID().ToString()
2883 << "\nOwner: " << (GetOwner() ? GetOwner()->GetDebugInfo() : "NULL");
2884 return sstr.str();
2885}
std::string GetDebugInfo() const override
Definition Object.cpp:2603

References GetCasterGUID(), WorldObject::GetDebugInfo(), GetId(), GetOwner(), and ObjectGuid::ToString().

◆ GetDuration()

◆ GetDynobjOwner()

DynamicObject * Aura::GetDynobjOwner ( ) const
inline
AuraObjectType GetType() const
Definition SpellAuras.cpp:438
Definition DynamicObject.h:35

References ASSERT, DYNOBJ_AURA_TYPE, GetType(), and m_owner.

Referenced by DynObjAura::DynObjAura(), Spell::EffectPersistentAA(), DynObjAura::FillTargetMap(), and AuraScript::GetDynobjOwner().

◆ GetEffect()

◆ GetEffectMask()

◆ GetId()

◆ GetMaxDuration()

◆ GetOwner()

◆ GetProcEffectMask()

uint8 Aura::GetProcEffectMask ( AuraApplication *  aurApp,
ProcEventInfo &  eventInfo,
TimePoint  now 
) const
2263{
2264 SpellProcEntry const* procEntry = sSpellMgr->GetSpellProcEntry(GetId());
2265
2266 // only auras with spell proc entry can trigger proc
2267 if (!procEntry)
2268 return 0;
2269
2270 // check spell triggering us
2271 if (Spell const* spell = eventInfo.GetProcSpell())
2272 {
2273 // Do not allow auras to proc from effect triggered from itself
2274 if (spell->GetTriggeredByAuraSpellInfo() == m_spellInfo)
2275 return 0;
2276
2277 // check if aura can proc when spell is triggered (exception for hunter auto shot & wands)
2278 // Kill/killed/death events should not be blocked by the triggered-spell check -
2279 // the kill itself is the proc trigger, not the spell that dealt the killing blow
2280 if (!GetSpellInfo()->HasAttribute(SPELL_ATTR3_CAN_PROC_FROM_PROCS) &&
2282 !(eventInfo.GetTypeMask() & AUTO_ATTACK_PROC_FLAG_MASK) &&
2284 {
2285 if (spell->IsTriggered() && !spell->GetSpellInfo()->HasAttribute(SPELL_ATTR3_NOT_A_PROC))
2286 return 0;
2287 }
2288
2289 // do not allow aura proc if proc is caused by a spell cast by item
2290 if (spell->m_CastItem && (procEntry->AttributesMask & PROC_ATTR_CANT_PROC_FROM_ITEM_CAST))
2291 return 0;
2292 }
2293
2294 // Don't consume stealth charges from friendly spells
2296 {
2297 if (SpellInfo const* spellInfo = eventInfo.GetSpellInfo())
2298 if (spellInfo->IsPositive() || !eventInfo.GetActor()->IsHostileTo(aurApp->GetTarget()) || spellInfo->HasAttribute(SPELL_ATTR0_CU_DONT_BREAK_STEALTH))
2299 return 0;
2300 }
2301
2302 // check if we have charges to proc with
2303 if (IsUsingCharges() && !GetCharges())
2304 return 0;
2305
2306 // check proc cooldown
2307 if (IsProcOnCooldown(now))
2308 return 0;
2309
2310 // do checks against db data
2311 if (!sSpellMgr->CanSpellTriggerProcOnEvent(*procEntry, eventInfo))
2312 return 0;
2313
2314 // check if spell was affected by this aura's spellmod (used by Arcane Potency and similar effects)
2315 // only applies when consuming charges or stacks
2317 {
2318 Spell const* procSpell = eventInfo.GetProcSpell();
2319 if (!procSpell || procSpell->m_appliedMods.find(const_cast<Aura*>(this)) == procSpell->m_appliedMods.end())
2320 return 0;
2321 }
2322
2323 // do checks using conditions table
2324 ConditionList conditions = sConditionMgr->GetConditionsForNotGroupedEntry(CONDITION_SOURCE_TYPE_SPELL_PROC, GetId());
2325 ConditionSourceInfo condInfo = ConditionSourceInfo(eventInfo.GetActor(), eventInfo.GetActionTarget());
2326 if (!sConditionMgr->IsObjectMeetToConditions(condInfo, conditions))
2327 return 0;
2328
2329 // AuraScript Hook
2330 if (!const_cast<Aura*>(this)->CallScriptCheckProcHandlers(aurApp, eventInfo))
2331 return 0;
2332
2333 // At least one effect has to pass checks to proc aura
2334 uint8 procEffectMask = aurApp->GetEffectMask();
2335 for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
2336 {
2337 if (AuraEffect* aurEff = GetEffect(i))
2338 {
2339 if (procEffectMask & (1 << i))
2340 {
2341 if ((procEntry->DisableEffectsMask & (1u << i)) || !aurEff->CheckEffectProc(aurApp, eventInfo))
2342 procEffectMask &= ~(1 << i);
2343 }
2344 }
2345 }
2346
2347 if (!procEffectMask)
2348 return 0;
2349
2350 // Check if current equipment meets aura requirements
2351 // do that only for passive spells
2352 Unit* target = aurApp->GetTarget();
2353 if (IsPassive() && target->IsPlayer() && GetSpellInfo()->EquippedItemClass != -1)
2354 {
2356 {
2357 Item* item = nullptr;
2359 {
2360 if (target->ToPlayer()->IsInFeralForm())
2361 return 0;
2362
2363 if (DamageInfo const* damageInfo = eventInfo.GetDamageInfo())
2364 {
2365 switch (damageInfo->GetAttackType())
2366 {
2367 case BASE_ATTACK:
2369 break;
2370 case OFF_ATTACK:
2372 break;
2373 default:
2375 break;
2376 }
2377 }
2378 }
2380 {
2381 // Check if player is wearing shield
2383 }
2384
2385 if (!item || item->IsBroken() || !item->IsFitToSpellRequirements(GetSpellInfo()))
2386 return 0;
2387 }
2388 }
2389
2390 float procChance = CalcProcChance(*procEntry, eventInfo);
2391
2392 if (roll_chance_f(procChance))
2393 return procEffectMask;
2394
2395 return 0;
2396}
#define sConditionMgr
Definition ConditionMgr.h:296
@ CONDITION_SOURCE_TYPE_SPELL_PROC
Definition ConditionMgr.h:150
std::list< Condition * > ConditionList
Definition ConditionMgr.h:240
@ ITEM_CLASS_ARMOR
Definition ItemTemplate.h:295
@ ITEM_CLASS_WEAPON
Definition ItemTemplate.h:293
@ EQUIPMENT_SLOT_MAINHAND
Definition Player.h:677
@ EQUIPMENT_SLOT_OFFHAND
Definition Player.h:678
@ EQUIPMENT_SLOT_RANGED
Definition Player.h:679
#define INVENTORY_SLOT_BAG_0
Definition Player.h:657
bool roll_chance_f(float chance)
Definition Random.h:57
@ SPELL_ATTR3_NOT_A_PROC
Definition SharedDefines.h:490
@ SPELL_ATTR3_NO_PROC_EQUIP_REQUIREMENT
Definition SharedDefines.h:482
@ SPELL_ATTR3_CAN_PROC_FROM_PROCS
Definition SharedDefines.h:507
@ SPELL_AURA_MOD_STEALTH
Definition SpellAuraDefines.h:79
@ SPELL_ATTR0_CU_DONT_BREAK_STEALTH
Definition SpellInfo.h:183
@ PROC_ATTR_CANT_PROC_FROM_ITEM_CAST
Definition SpellMgr.h:282
@ PROC_ATTR_TRIGGERED_CAN_PROC
Definition SpellMgr.h:277
@ PROC_ATTR_REQ_SPELLMOD
Definition SpellMgr.h:279
@ AUTO_ATTACK_PROC_FLAG_MASK
Definition SpellMgr.h:149
@ PROC_FLAG_KILLED
Definition SpellMgr.h:110
@ PROC_FLAG_DEATH
Definition SpellMgr.h:146
@ PROC_FLAG_KILL
Definition SpellMgr.h:111
@ OFF_ATTACK
Definition Unit.h:224
@ BASE_ATTACK
Definition Unit.h:223
uint8 GetEffectMask() const
Definition SpellAuras.h:67
bool CallScriptCheckProcHandlers(AuraApplication const *aurApp, ProcEventInfo &eventInfo)
Definition SpellAuras.cpp:2758
float CalcProcChance(SpellProcEntry const &procEntry, ProcEventInfo &eventInfo) const
Definition SpellAuras.cpp:2398
bool IsProcOnCooldown(TimePoint now) const
Definition SpellAuras.cpp:2216
Definition Unit.h:344
Definition Item.h:220
bool IsBroken() const
Definition Item.h:257
bool IsFitToSpellRequirements(SpellInfo const *spellInfo) const
Definition Item.cpp:878
Item * GetUseableItemByPos(uint8 bag, uint8 slot) const
Definition Player.h:1270
Unit * GetActionTarget() const
Definition Unit.h:469
Spell const * GetProcSpell() const
Definition Unit.h:477
uint32 GetTypeMask() const
Definition Unit.h:471
int32 EquippedItemClass
Definition SpellInfo.h:399
bool HasAura(AuraType aura) const
Definition SpellInfo.cpp:906
Definition Spell.h:298
UsedSpellMods m_appliedMods
Definition Spell.h:560
bool IsInFeralForm() const
Definition Unit.h:1982
bool IsHostileTo(Unit const *unit) const
Definition Unit.cpp:7074
Definition ConditionMgr.h:185
uint32 AttributesMask
Definition SpellMgr.h:294
uint32 DisableEffectsMask
Definition SpellMgr.h:295

References SpellProcEntry::AttributesMask, AUTO_ATTACK_PROC_FLAG_MASK, BASE_ATTACK, CalcProcChance(), CallScriptCheckProcHandlers(), CONDITION_SOURCE_TYPE_SPELL_PROC, SpellProcEntry::DisableEffectsMask, EQUIPMENT_SLOT_MAINHAND, EQUIPMENT_SLOT_OFFHAND, EQUIPMENT_SLOT_RANGED, SpellInfo::EquippedItemClass, ProcEventInfo::GetActionTarget(), ProcEventInfo::GetActor(), GetCharges(), ProcEventInfo::GetDamageInfo(), GetEffect(), AuraApplication::GetEffectMask(), GetId(), ProcEventInfo::GetProcSpell(), ProcEventInfo::GetSpellInfo(), GetSpellInfo(), AuraApplication::GetTarget(), ProcEventInfo::GetTypeMask(), Player::GetUseableItemByPos(), SpellInfo::HasAttribute(), SpellInfo::HasAura(), INVENTORY_SLOT_BAG_0, Item::IsBroken(), Item::IsFitToSpellRequirements(), Unit::IsHostileTo(), Unit::IsInFeralForm(), IsPassive(), Object::IsPlayer(), IsProcOnCooldown(), IsUsingCharges(), ITEM_CLASS_ARMOR, ITEM_CLASS_WEAPON, Spell::m_appliedMods, m_spellInfo, MAX_SPELL_EFFECTS, OFF_ATTACK, PROC_ATTR_CANT_PROC_FROM_ITEM_CAST, PROC_ATTR_REQ_SPELLMOD, PROC_ATTR_TRIGGERED_CAN_PROC, PROC_ATTR_USE_STACKS_FOR_CHARGES, PROC_FLAG_DEATH, PROC_FLAG_KILL, PROC_FLAG_KILLED, roll_chance_f(), sConditionMgr, SPELL_ATTR0_CU_DONT_BREAK_STEALTH, SPELL_ATTR3_CAN_PROC_FROM_PROCS, SPELL_ATTR3_NO_PROC_EQUIP_REQUIREMENT, SPELL_ATTR3_NOT_A_PROC, SPELL_AURA_MOD_STEALTH, sSpellMgr, and Object::ToPlayer().

◆ GetScript()

template<class Script >
Script * Aura::GetScript ( std::string const &  scriptName) const
inline
243 {
244 return dynamic_cast<Script*>(GetScriptByName(scriptName));
245 }
AuraScript * GetScriptByName(std::string const &scriptName) const
Definition SpellAuras.cpp:378

References GetScriptByName().

◆ GetScriptByName()

AuraScript * Aura::GetScriptByName ( std::string const &  scriptName) const
379{
380 for (std::list<AuraScript*>::const_iterator itr = m_loadedScripts.begin(); itr != m_loadedScripts.end(); ++itr)
381 if ((*itr)->_GetScriptName()->compare(scriptName) == 0)
382 return *itr;
383 return nullptr;
384}

References m_loadedScripts.

Referenced by GetScript().

◆ GetSpellInfo()

SpellInfo const * Aura::GetSpellInfo ( ) const
inline
101{ return m_spellInfo; }

References m_spellInfo.

Referenced by Unit::_AddAura(), Unit::_ApplyAura(), Unit::_CreateAuraApplication(), Pet::_SaveAuras(), Unit::_UnapplyAura(), _UnapplyForTarget(), SpellInfo::ApplyAllSpellImmunitiesTo(), AuraEffect::ApplySpellMod(), AuraApplication::BuildUpdatePacket(), CalcProcChance(), CanBeAppliedOn(), CanBeSaved(), CanBeSentToClient(), CanStackWith(), Player::CheckAreaExploreAndOutdoor(), spell_item_luffa::CheckCast(), Spell::CheckCasterAuras(), Spell::DoSpellHitOnUnit(), Spell::EffectDispelMechanic(), Spell::EffectStealBeneficialBuff(), UnitAura::FillTargetMap(), DynObjAura::FillTargetMap(), Unit::GetDiseasesByCaster(), Unit::GetDispellableAuraList(), GetId(), GetProcEffectMask(), AuraScript::GetSpellInfo(), AuraEffect::HandleAuraDummy(), HandleAuraSpecificMods(), spell_item_powerful_anti_venom::HandleDummy(), spell_item_strong_anti_venom::HandleDummy(), spell_item_anti_venom::HandleDummy(), spell_item_luffa::HandleEffect(), ArenaSpectator::HandleResetCommand(), spell_gen_clear_debuffs::HandleScript(), spell_dru_glyph_of_starfire::HandleScriptEffect(), spell_hun_chimera_shot::HandleScriptEffect(), HasMoreThanOneEffectForType(), Unit::HasNegativeAuraWithAttribute(), IsArea(), IsDeathPersistent(), Unit::IsHighestExclusiveAura(), IsPassive(), IsSingleTargetWith(), list_commandscript::ListAurasCommand(), Player::LoadFromDB(), spell_hor_shared_suffering_aura::OnRemove(), Unit::RemoveAllAurasExceptType(), Unit::RemoveAllAurasOnDeath(), Unit::RemoveAllAurasRequiringDeadTarget(), Unit::RemoveArenaAuras(), Unit::RemoveAurasByShapeShift(), Unit::RemoveAurasDueToSpellByDispel(), Unit::RemoveAurasDueToSpellBySteal(), Unit::RemoveAurasWithFamily(), Unit::RemoveAurasWithInterruptFlags(), Unit::RemoveAurasWithMechanic(), Unit::RemoveEvadeAuras(), Player::RemoveItemDependentAurasAndCasts(), Unit::RemoveMovementImpairingAuras(), Player::RestoreSpellMods(), ArenaSpectator::ShouldSendAura(), Unit::SpellPctDamageModsDone(), and UpdateTargetMap().

◆ GetStackAmount()

◆ GetTriggeredByAuraSpellInfo()

SpellInfo const * Aura::GetTriggeredByAuraSpellInfo ( ) const

◆ GetType()

AuraObjectType Aura::GetType ( ) const
439{
440 if (!m_owner)
441 {
442 LOG_ERROR("spells", "Aura::GetType m_owner is null!");
443 return UNIT_AURA_TYPE;
444 }
445
447}
@ UNIT_AURA_TYPE
Definition SpellAuraDefines.h:385
bool IsDynamicObject() const
Definition Object.h:227

References DYNOBJ_AURA_TYPE, Object::IsDynamicObject(), LOG_ERROR, m_owner, and UNIT_AURA_TYPE.

Referenced by CanStackWith(), GetDynobjOwner(), AuraScript::GetType(), GetUnitOwner(), Spell::handle_immediate(), IsProcOnCooldown(), Unit::RemoveAuraFromStack(), and UpdateTargetMap().

◆ GetUnitOwner()

◆ HandleAllEffects()

void Aura::HandleAllEffects ( AuraApplication *  aurApp,
uint8  mode,
bool  apply 
)
1316{
1317 ASSERT (!IsRemoved());
1318 for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
1319 if (m_effects[i] && !IsRemoved())
1320 m_effects[i]->HandleEffect(aurApp, mode, apply);
1321}
void HandleEffect(AuraApplication *aurApp, uint8 mode, bool apply)
Definition SpellAuraEffects.cpp:755

References ASSERT, AuraEffect::HandleEffect(), IsRemoved(), m_effects, and MAX_SPELL_EFFECTS.

Referenced by Player::CheckAreaExploreAndOutdoor(), and Player::LoadFromDB().

◆ HandleAuraSpecificMods()

void Aura::HandleAuraSpecificMods ( AuraApplication const *  aurApp,
Unit *  caster,
bool  apply,
bool  onReapply 
)
Todo:
: This should be moved to similar function in spell::hit
Todo:
: Not sure whether the fallthrough was a mistake (forgetting a break) or intended. This should be double-checked.
1340{
1341 Unit* target = aurApp->GetTarget();
1342 AuraRemoveMode removeMode = aurApp->GetRemoveMode();
1343 // handle spell_area table
1344 SpellAreaForAreaMapBounds saBounds = sSpellMgr->GetSpellAreaForAuraMapBounds(GetId());
1345 if (saBounds.first != saBounds.second)
1346 {
1347 uint32 zone, area;
1348 target->GetZoneAndAreaId(zone, area);
1349
1350 for (SpellAreaForAreaMap::const_iterator itr = saBounds.first; itr != saBounds.second; ++itr)
1351 {
1352 // some auras remove at aura remove
1353 if (!itr->second->IsFitToRequirements(target->ToPlayer(), zone, area) && !apply)
1354 target->RemoveAurasDueToSpell(itr->second->spellId);
1355 // some auras applied at aura apply
1356 else if (itr->second->autocast)
1357 {
1358 if (!target->HasAura(itr->second->spellId))
1359 target->CastSpell(target, itr->second->spellId, true);
1360 }
1361 }
1362 }
1363
1364 // handle spell_linked_spell table
1365 if (!onReapply)
1366 {
1367 // apply linked auras
1368 if (apply)
1369 {
1370 if (std::vector<int32> const* spellTriggered = sSpellMgr->GetSpellLinked(GetId() + SPELL_LINK_AURA))
1371 {
1372 for (std::vector<int32>::const_iterator itr = spellTriggered->begin(); itr != spellTriggered->end(); ++itr)
1373 {
1374 if (*itr < 0)
1375 target->ApplySpellImmune(GetId(), IMMUNITY_ID, -(*itr), true);
1376 else if (caster)
1377 caster->AddAura(*itr, target);
1378 }
1379 }
1380 }
1381 else
1382 {
1383 // remove linked auras
1384 if (std::vector<int32> const* spellTriggered = sSpellMgr->GetSpellLinked(-(int32)GetId()))
1385 {
1386 for (std::vector<int32>::const_iterator itr = spellTriggered->begin(); itr != spellTriggered->end(); ++itr)
1387 {
1388 if (*itr < 0)
1389 target->RemoveAurasDueToSpell(-(*itr));
1390 else if (removeMode != AURA_REMOVE_BY_DEATH)
1391 target->CastSpell(target, *itr, true, nullptr, nullptr, GetCasterGUID());
1392 }
1393 }
1394 if (std::vector<int32> const* spellTriggered = sSpellMgr->GetSpellLinked(GetId() + SPELL_LINK_AURA))
1395 {
1396 for (std::vector<int32>::const_iterator itr = spellTriggered->begin(); itr != spellTriggered->end(); ++itr)
1397 {
1398 if (*itr < 0)
1399 target->ApplySpellImmune(GetId(), IMMUNITY_ID, -(*itr), false);
1400 else
1401 target->RemoveAura(*itr, GetCasterGUID(), 0, removeMode);
1402 }
1403 }
1404 }
1405 }
1406 else if (apply)
1407 {
1408 // modify stack amount of linked auras
1409 if (std::vector<int32> const* spellTriggered = sSpellMgr->GetSpellLinked(GetId() + SPELL_LINK_AURA))
1410 {
1411 for (std::vector<int32>::const_iterator itr = spellTriggered->begin(); itr != spellTriggered->end(); ++itr)
1412 if (*itr > 0)
1413 if (Aura* triggeredAura = target->GetAura(*itr, GetCasterGUID()))
1414 triggeredAura->ModStackAmount(GetStackAmount() - triggeredAura->GetStackAmount());
1415 }
1416 }
1417
1418 // mods at aura apply
1419 if (apply)
1420 {
1421 switch (GetSpellInfo()->SpellFamilyName)
1422 {
1424 switch (GetId())
1425 {
1426 case 32474: // Buffeting Winds of Susurrus
1427 if (target->IsPlayer())
1428 target->ToPlayer()->ActivateTaxiPathTo(506, GetId());
1429 break;
1430 case 33572: // Gronn Lord's Grasp, becomes stoned
1431 if (GetStackAmount() >= 5 && !target->HasAura(33652))
1432 target->CastSpell(target, 33652, true);
1433 break;
1434 case 50836: //Petrifying Grip, becomes stoned
1435 if (GetStackAmount() >= 5 && !target->HasAura(50812))
1436 target->CastSpell(target, 50812, true);
1437 break;
1438 case 60970: // Heroic Fury (remove Intercept cooldown)
1439 if (target->IsPlayer())
1440 target->ToPlayer()->RemoveSpellCooldown(20252, true);
1441 break;
1442 }
1443 break;
1444 case SPELLFAMILY_MAGE:
1445 if (!caster)
1446 break;
1447 if (GetSpellInfo()->SpellFamilyFlags[0] & 0x00000001 && GetSpellInfo()->SpellFamilyFlags[2] & 0x00000008)
1448 {
1449 // Glyph of Fireball
1450 if (caster->HasAura(56368))
1451 SetDuration(0);
1452 }
1453 else if (GetSpellInfo()->SpellFamilyFlags[0] & 0x00000020 && GetSpellInfo()->SpellVisual[0] == 13)
1454 {
1455 // Glyph of Frostbolt
1456 if (caster->HasAura(56370))
1457 SetDuration(0);
1458 }
1460 else if (GetSpellInfo()->SpellFamilyFlags[0] & 0x01000000)
1461 {
1462 // Polymorph Sound - Sheep && Penguin
1463 if (GetSpellInfo()->SpellIconID == 82 && GetSpellInfo()->SpellVisual[0] == 12978)
1464 {
1465 // Glyph of the Penguin
1466 if (caster->HasAura(52648))
1467 caster->CastSpell(target, 61635, true);
1468 else
1469 caster->CastSpell(target, 61634, true);
1470 }
1471
1472 if (Creature* creatureTarget = target->ToCreature())
1473 {
1474 creatureTarget->CallAssistance(caster);
1475 }
1476 }
1477 switch (GetId())
1478 {
1479 case 44544: // Fingers of Frost
1480 {
1481 // See if we already have the indicator aura. If not, create one.
1482 if (Aura* aur = target->GetAura(74396))
1483 {
1484 // Aura already there. Refresh duration and set original charges
1485 aur->SetCharges(2);
1486 aur->RefreshDuration();
1487 }
1488 else
1489 target->AddAura(74396, target);
1490 }
1491 break;
1492 case 12494: // Frostbite, synchronise with Fingers of Frost
1493 {
1494 // Find Fingers of Frost
1496 {
1497 if (SpellInfo const* triggeringSpellInfo = GetTriggeredByAuraSpellInfo())
1498 {
1499 uint8 fbRank = sSpellMgr->GetSpellRank(triggeringSpellInfo->Id);
1500 uint8 fofRank = sSpellMgr->GetSpellRank(aurEff->GetId());
1501 uint8 chance = uint8(std::ceil(fofRank * fbRank * 16.6f));
1502
1503 if (roll_chance_i(chance))
1504 {
1505 caster->CastSpell(caster, aurEff->GetSpellInfo()->Effects[EFFECT_0].TriggerSpell, true);
1506 }
1507 }
1508 }
1509 break;
1510 }
1511 default:
1512 break;
1513 }
1514 break;
1515 case SPELLFAMILY_DRUID:
1516 if (!caster)
1517 break;
1518 // Rejuvenation
1519 if (GetSpellInfo()->SpellFamilyFlags[0] & 0x10 && GetEffect(0))
1520 {
1521 // Druid T8 Restoration 4P Bonus
1522 if (caster->GetAuraEffectDummy(64760))
1523 {
1524 // 50% of an unmodified tick: 64801's own heal adds spell power (0.188),
1525 // Empowered Rejuvenation and healing done/taken mods once
1526 int32 basepoints0 = CalculatePct(GetSpellInfo()->Effects[EFFECT_0].CalcValue(caster), 50);
1527 caster->CastCustomSpell(target, 64801, &basepoints0, nullptr, nullptr, true, nullptr, GetEffect(0));
1528 }
1529 }
1530 break;
1531 case SPELLFAMILY_PRIEST:
1532 if (!caster)
1533 break;
1534 // Devouring Plague
1535 if (GetSpellInfo()->SpellFamilyFlags[0] & 0x02000000 && GetEffect(0))
1536 {
1537 // Improved Devouring Plague
1538 if (AuraEffect const* aurEff = caster->GetDummyAuraEffect(SPELLFAMILY_PRIEST, 3790, 1))
1539 {
1540 uint32 damage = GetEffect(0)->GetAmount();
1541 damage = target->SpellDamageBonusTaken(caster, GetSpellInfo(), damage, DOT);
1542 int32 basepoints0 = aurEff->GetAmount() * GetEffect(0)->GetTotalTicks() * int32(damage) / 100;
1543 int32 heal = int32(CalculatePct(basepoints0, 15));
1544
1545 caster->CastCustomSpell(target, 63675, &basepoints0, nullptr, nullptr, true, nullptr, GetEffect(0));
1546 caster->CastCustomSpell(caster, 75999, &heal, nullptr, nullptr, true, nullptr, GetEffect(0));
1547 }
1548 }
1549 // Power Word: Shield
1550 else if (m_spellInfo->SpellFamilyFlags[0] & 0x1 && m_spellInfo->SpellFamilyFlags[2] & 0x400 && GetEffect(0))
1551 {
1552 // Glyph of Power Word: Shield
1553 if (AuraEffect* glyph = caster->GetAuraEffect(55672, 0))
1554 {
1555 // instantly heal m_amount% of the absorb-value
1556 int32 heal = glyph->GetAmount() * GetEffect(0)->GetAmount() / 100;
1557 caster->CastCustomSpell(GetUnitOwner(), 56160, &heal, nullptr, nullptr, true, 0, GetEffect(0));
1558 }
1559 }
1560 break;
1561 case SPELLFAMILY_ROGUE:
1562 // Sprint (skip non player casted spells by category)
1563 if (GetSpellInfo()->SpellFamilyFlags[0] & 0x40 && GetSpellInfo()->GetCategory() == 44)
1564 // in official maybe there is only one icon?
1565 if (target->HasAura(58039)) // Glyph of Blurred Speed
1566 target->CastSpell(target, 61922, true); // Sprint (waterwalk)
1567 break;
1568 case SPELLFAMILY_SHAMAN:
1569 {
1570 // Ghost Wolf Speed (PvP 58 lvl set)
1571 if (GetSpellInfo()->SpellFamilyFlags[0] & 0x00000800 && target->HasAura(22801) && target->GetLevel() <= 60)
1572 {
1573 int32 bp0 = 15;
1574 target->CastCustomSpell(target, 47017, &bp0, 0, 0, true);
1575 }
1576 break;
1577 }
1579 if (!caster)
1580 break;
1581 // Frost Fever and Blood Plague
1582 if (GetSpellInfo()->SpellFamilyFlags[2] & 0x2)
1583 {
1584 // Can't proc on self
1585 if (GetCasterGUID() == target->GetGUID())
1586 break;
1587
1588 AuraEffect* aurEff = nullptr;
1589 // Ebon Plaguebringer / Crypt Fever
1591 for (Unit::AuraEffectList::const_iterator itr = TalentAuras.begin(); itr != TalentAuras.end(); ++itr)
1592 {
1593 if ((*itr)->GetMiscValue() == 7282)
1594 {
1595 aurEff = *itr;
1596 // Ebon Plaguebringer - end search if found
1597 if ((*itr)->GetSpellInfo()->SpellIconID == 1766)
1598 break;
1599 }
1600 }
1601 if (aurEff)
1602 {
1603 uint32 spellId = 0;
1604 switch (aurEff->GetId())
1605 {
1606 // Ebon Plague
1607 case 51161:
1608 spellId = 51735;
1609 break;
1610 case 51160:
1611 spellId = 51734;
1612 break;
1613 case 51099:
1614 spellId = 51726;
1615 break;
1616 // Crypt Fever
1617 case 49632:
1618 spellId = 50510;
1619 break;
1620 case 49631:
1621 spellId = 50509;
1622 break;
1623 case 49032:
1624 spellId = 50508;
1625 break;
1626 default:
1627 LOG_ERROR("spells.aura", "Aura::HandleAuraSpecificMods: Unknown rank of Crypt Fever/Ebon Plague ({}) found", aurEff->GetId());
1628 }
1629 caster->CastSpell(target, spellId, true, 0, GetEffect(0));
1630 }
1631 }
1632 // Unholy blight
1633 if (GetId() == 50536)
1634 {
1635 if (caster->IsFriendlyTo(target))
1636 SetDuration(0);
1637 }
1638 break;
1639 case SPELLFAMILY_POTION:
1640 // Alchemy: Mixology
1641 if (caster && caster->HasAura(53042) && caster->IsPlayer() && !caster->ToPlayer()->GetSession()->PlayerLoading())
1642 {
1643 if (sSpellMgr->IsSpellMemberOfSpellGroup(GetId(), SPELL_GROUP_ELIXIR_BATTLE) || sSpellMgr->IsSpellMemberOfSpellGroup(GetId(), SPELL_GROUP_ELIXIR_GUARDIAN))
1644 {
1645 if (caster->HasSpell(GetSpellInfo()->Effects[EFFECT_0].TriggerSpell))
1646 {
1647 for (int i = 0; i < MAX_SPELL_EFFECTS; ++i)
1648 if (GetEffect(i))
1649 GetEffect(i)->SetAmount(CalculatePct(GetEffect(i)->GetAmount(), 100 + sSpellMgr->GetSpellMixologyBonus(GetId())));
1650
1653 }
1654 }
1655 }
1656 break;
1657 }
1658 }
1659 // mods at aura remove
1660 else
1661 {
1662 switch (GetSpellInfo()->SpellFamilyName)
1663 {
1665 if (!caster)
1666 break;
1667 switch (GetId())
1668 {
1669 case 61987: // Avenging Wrath
1670 // Remove the immunity shield marker on Avenging Wrath removal if Forbearance is not present
1671 if (target->HasAura(61988) && !target->HasAura(25771))
1672 target->RemoveAura(61988);
1673 break;
1674 case 72368: // Shared Suffering
1675 case 72369:
1676 if (AuraEffect* aurEff = GetEffect(0))
1677 {
1678 int32 remainingDamage = aurEff->GetAmount() * (aurEff->GetTotalTicks() - aurEff->GetTickNumber());
1679 if (remainingDamage > 0)
1680 caster->CastCustomSpell(caster, 72373, nullptr, &remainingDamage, nullptr, true);
1681 }
1682 break;
1683 }
1684 break;
1685 case SPELLFAMILY_MAGE:
1686 {
1687 // Polymorph
1688 if (GetSpellInfo()->SpellFamilyFlags[0] & 0x01000000)
1689 {
1690 if (Creature* creatureTarget = target->ToCreature())
1691 {
1692 creatureTarget->SetNoCallAssistance(false);
1693 }
1694 }
1695 switch (GetId())
1696 {
1697 case 66: // Invisibility
1698 if (removeMode != AURA_REMOVE_BY_EXPIRE)
1699 break;
1700 target->CastSpell(target, 32612, true, nullptr, GetEffect(1));
1701 target->CombatStop();
1702 break;
1703 case 74396: // Fingers of Frost
1704 // Remove the IGNORE_AURASTATE aura
1705 target->RemoveAurasDueToSpell(44544);
1706 break;
1707 case 44401: // Missile Barrage
1708 case 48108: // Hot Streak
1709 case 57761: // Fireball!
1710 if (removeMode != AURA_REMOVE_BY_EXPIRE || aurApp->GetBase()->IsExpired())
1711 break;
1712 if (target->HasAura(70752)) // Item - Mage T10 2P Bonus
1713 target->CastSpell(target, 70753, true); // Pushing the Limit
1714 break;
1715 default:
1716 break;
1717 }
1718 if (!caster)
1719 break;
1720 // Ice barrier - dispel/absorb remove
1721 if (removeMode == AURA_REMOVE_BY_ENEMY_SPELL && GetSpellInfo()->SpellFamilyFlags[1] & 0x1)
1722 {
1723 // Shattered Barrier
1724 if (AuraEffect* absorb = GetEffect(EFFECT_0))
1725 if (absorb->GetAmount() <= 0) // removed by damage, not dispel
1726 if (AuraEffect* dummy = caster->GetDummyAuraEffect(SPELLFAMILY_MAGE, 2945, 0))
1727 if (roll_chance_i(dummy->GetSpellInfo()->ProcChance))
1728 caster->CastSpell(target, 55080, true, nullptr, GetEffect(0));
1729 }
1730 break;
1731 }
1733 if (!caster)
1734 break;
1735 [[fallthrough]];
1737 if (!caster)
1738 break;
1739 if (GetSpellInfo()->SpellFamilyFlags[1] & 0x00000400)
1740 {
1741 if (AuraEffect* aurEff = caster->GetAuraEffect(SPELL_AURA_DUMMY, SPELLFAMILY_WARLOCK, 98, 0))
1742 {
1743 uint32 spellId = 0;
1744 switch (aurEff->GetId())
1745 {
1746 case 53759:
1747 spellId = 60947;
1748 break;
1749 case 53754:
1750 spellId = 60946;
1751 break;
1752 default:
1753 LOG_ERROR("spells.aura", "Aura::HandleAuraSpecificMods: Unknown rank of Improved Fear ({}) found", aurEff->GetId());
1754 }
1755 if (spellId)
1756 caster->CastSpell(target, spellId, true);
1757 }
1758 }
1759 break;
1760 case SPELLFAMILY_PRIEST:
1761 if (!caster)
1762 break;
1763 // Shadow word: Pain // Vampiric Touch
1764 if (removeMode == AURA_REMOVE_BY_ENEMY_SPELL && (GetSpellInfo()->SpellFamilyFlags[0] & 0x00008000 || GetSpellInfo()->SpellFamilyFlags[1] & 0x00000400))
1765 {
1766 // Shadow Affinity
1767 if (AuraEffect const* aurEff = caster->GetDummyAuraEffect(SPELLFAMILY_PRIEST, 178, 1))
1768 {
1769 int32 basepoints0 = aurEff->GetAmount() * caster->GetCreateMana() / 100;
1770 caster->CastCustomSpell(caster, 64103, &basepoints0, nullptr, nullptr, true, nullptr, GetEffect(0));
1771 }
1772 }
1773 // Power word: shield
1774 else if (removeMode == AURA_REMOVE_BY_ENEMY_SPELL && GetSpellInfo()->SpellFamilyFlags[0] & 0x00000001)
1775 {
1776 // Rapture
1777 if (Aura const* aura = caster->GetAuraOfRankedSpell(47535))
1778 {
1779 // check cooldown
1780 if (caster->IsPlayer())
1781 {
1782 if (caster->ToPlayer()->HasSpellCooldown(aura->GetId()))
1783 {
1784 // This additional check is needed to add a minimal delay before cooldown in in effect
1785 // to allow all bubbles broken by a single damage source proc mana return
1786 if (caster->ToPlayer()->GetSpellCooldownDelay(aura->GetId()) <= 11500)
1787 break;
1788 }
1789 else // and add if needed
1790 caster->ToPlayer()->AddSpellCooldown(aura->GetId(), 0, 12 * IN_MILLISECONDS);
1791 }
1792
1793 // effect on caster
1794 if (AuraEffect const* aurEff = aura->GetEffect(0))
1795 {
1796 float multiplier = (float)aurEff->GetAmount();
1797 if (aurEff->GetId() == 47535)
1798 multiplier -= 0.5f;
1799 else if (aurEff->GetId() == 47537)
1800 multiplier += 0.5f;
1801
1802 int32 basepoints0 = int32(CalculatePct(caster->GetMaxPower(POWER_MANA), multiplier));
1803 caster->CastCustomSpell(caster, 47755, &basepoints0, nullptr, nullptr, true);
1804 }
1805 // effect on aura target
1806 if (AuraEffect const* aurEff = aura->GetEffect(1))
1807 {
1808 if (!roll_chance_i(aurEff->GetAmount()))
1809 break;
1810
1811 int32 triggeredSpellId = 0;
1812 switch (target->getPowerType())
1813 {
1814 case POWER_MANA:
1815 {
1816 int32 basepoints0 = int32(CalculatePct(target->GetMaxPower(POWER_MANA), 2));
1817 caster->CastCustomSpell(target, 63654, &basepoints0, nullptr, nullptr, true);
1818 break;
1819 }
1820 case POWER_RAGE:
1821 triggeredSpellId = 63653;
1822 break;
1823 case POWER_ENERGY:
1824 triggeredSpellId = (!target->HasAura(70405) ? 63655 : 0);
1825 break;
1826 case POWER_RUNIC_POWER:
1827 triggeredSpellId = 63652;
1828 break;
1829 default:
1830 break;
1831 }
1832 if (triggeredSpellId)
1833 caster->CastSpell(target, triggeredSpellId, true);
1834 }
1835 }
1836 }
1837 switch (GetId())
1838 {
1839 case 47788: // Guardian Spirit
1840 {
1841 if (removeMode != AURA_REMOVE_BY_EXPIRE)
1842 break;
1843 if (!caster->IsPlayer())
1844 break;
1845
1846 Player* player = caster->ToPlayer();
1847 // Glyph of Guardian Spirit
1848 if (AuraEffect* aurEff = player->GetAuraEffect(63231, 0))
1849 {
1850 if (!player->HasSpellCooldown(47788))
1851 break;
1852
1853 player->AddSpellCooldown(GetSpellInfo()->Id, 0, aurEff->GetAmount()*IN_MILLISECONDS);
1854
1855 WorldPacket data(SMSG_MODIFY_COOLDOWN, 4 + 8 + 4);
1856 data << uint32(GetId()); // Spell ID
1857 data << player->GetGUID(); // Player GUID
1858 data << int32(-110000); // Cooldown mod in milliseconds
1859 player->SendDirectMessage(&data);
1860 }
1861 break;
1862 }
1863 case 47585: // Dispersion (fixed bug invisible as a Shadow Priest)
1864 {
1865 if (target->IsMounted())
1866 {
1867 target->CastSpell(target, 53444, true);
1868 }
1869 break;
1870 }
1871 }
1872 break;
1873 case SPELLFAMILY_ROGUE:
1874 // Remove Vanish on stealth remove
1875 if (GetId() == 1784)
1876 {
1878 target->RemoveAurasDueToSpell(18461);
1879 }
1880 break;
1881 case SPELLFAMILY_SHAMAN:
1882 {
1883 // Ghost Wolf Speed (PvP 58 lvl set)
1884 if (GetSpellInfo()->SpellFamilyFlags[0] & 0x00000800)
1885 {
1886 target->RemoveAurasDueToSpell(47017);
1887 }
1888 // Lightning Shield vs The Earthshatterer 8/9 set bonus
1889 if (GetSpellInfo()->SpellFamilyFlags[0] & 0x00000400)
1890 {
1891 target->RemoveAurasDueToSpell(28820);
1892 }
1893 break;
1894 }
1896 // Blood of the North
1897 // Reaping
1898 // Death Rune Mastery
1899 if (GetSpellInfo()->SpellIconID == 3041 || GetSpellInfo()->SpellIconID == 22 || GetSpellInfo()->SpellIconID == 2622)
1900 {
1901 if (!GetEffect(0) || GetEffect(0)->GetAuraType() != SPELL_AURA_PERIODIC_DUMMY)
1902 break;
1903 if (!target->IsPlayer())
1904 break;
1906 break;
1907
1908 // aura removed - remove death runes
1910 }
1911 break;
1913 // Remove the immunity shield marker on Forbearance removal if AW marker is not present
1914 if (GetId() == 25771 && target->HasAura(61988) && !target->HasAura(61987))
1915 target->RemoveAura(61988);
1916 break;
1917 case SPELLFAMILY_HUNTER:
1918 // Glyph of Freezing Trap
1919 if ((GetSpellInfo()->SpellFamilyFlags[0] & 0x00000008) && caster && caster->HasAura(56845))
1920 {
1921 target->CastSpell(target, 61394, true);
1922 }
1923 break;
1924 }
1925 }
1926
1927 // mods at aura apply or remove
1928 switch (GetSpellInfo()->SpellFamilyName)
1929 {
1930 case SPELLFAMILY_ROGUE:
1931 // Stealth
1932 if (GetSpellInfo()->SpellFamilyFlags[0] & 0x00400000)
1933 {
1934 // Master of Subtlety
1935 if (AuraEffect const* aurEff = target->GetAuraEffectOfRankedSpell(31221, 0))
1936 {
1937 if (!apply)
1938 target->CastSpell(target, 31666, true);
1939 else
1940 {
1941 // Remove counter aura
1942 target->RemoveAurasDueToSpell(31666);
1943
1944 int32 amount = aurEff->GetAmount();
1945 target->CastCustomSpell(target, 31665, &amount, nullptr, nullptr, true);
1946 }
1947 }
1948 // Overkill
1949 if (target->HasAura(58426))
1950 {
1951 if (!apply)
1952 target->CastSpell(target, 58428, true);
1953 else
1954 {
1955 // Remove counter aura
1956 target->RemoveAurasDueToSpell(58428);
1957
1958 target->CastSpell(target, 58427, true);
1959 }
1960 }
1961 }
1962 break;
1963 case SPELLFAMILY_HUNTER:
1964 switch (GetId())
1965 {
1966 case 19574: // Bestial Wrath
1967 // The Beast Within cast on owner if talent present
1968 if (Unit* owner = target->GetOwner())
1969 {
1970 // Search talent
1971 if (owner->HasAura(34692))
1972 {
1973 if (apply)
1974 owner->CastSpell(owner, 34471, true, 0, GetEffect(0));
1975 else
1976 owner->RemoveAurasDueToSpell(34471);
1977 }
1978 }
1979 break;
1980 case 34026: // Kill Command
1981 // Dungeon Set 3
1982 if (caster->HasAura(37483))
1983 {
1984 if (apply)
1985 {
1986 caster->CastSpell(caster, 37482, true);
1987 }
1988 }
1989 break;
1990 }
1991 break;
1993 switch (GetId())
1994 {
1995 case 31842: // Divine Illumination
1996 // Item - Paladin T10 Holy 2P Bonus
1997 if (caster && caster->HasAura(70755))
1998 {
1999 if (apply)
2000 target->CastSpell(target, 71166, true);
2001 else
2002 target->RemoveAurasDueToSpell(71166);
2003 }
2004 break;
2005 }
2006 break;
2007 }
2008}
bool roll_chance_i(int chance)
Definition Random.h:63
@ EFFECT_0
Definition SharedDefines.h:31
@ POWER_RAGE
Definition SharedDefines.h:258
@ POWER_RUNIC_POWER
Definition SharedDefines.h:263
@ POWER_ENERGY
Definition SharedDefines.h:260
@ POWER_MANA
Definition SharedDefines.h:257
@ CLASS_DEATH_KNIGHT
Definition SharedDefines.h:131
@ IMMUNITY_ID
Definition SharedDefines.h:1404
@ SPELLFAMILY_PRIEST
Definition SharedDefines.h:3790
@ SPELLFAMILY_WARLOCK
Definition SharedDefines.h:3789
@ SPELLFAMILY_MAGE
Definition SharedDefines.h:3787
@ SPELLFAMILY_GENERIC
Definition SharedDefines.h:3784
@ SPELLFAMILY_WARRIOR
Definition SharedDefines.h:3788
@ SPELLFAMILY_PALADIN
Definition SharedDefines.h:3794
@ SPELLFAMILY_POTION
Definition SharedDefines.h:3797
@ SPELLFAMILY_ROGUE
Definition SharedDefines.h:3792
@ SPELLFAMILY_SHAMAN
Definition SharedDefines.h:3795
@ SPELLFAMILY_DRUID
Definition SharedDefines.h:3791
@ SPELLFAMILY_DEATHKNIGHT
Definition SharedDefines.h:3799
@ SPELL_AURA_PROC_TRIGGER_SPELL
Definition SpellAuraDefines.h:105
@ SPELL_AURA_DUMMY
Definition SpellAuraDefines.h:67
@ SPELL_AURA_OVERRIDE_CLASS_SCRIPTS
Definition SpellAuraDefines.h:175
AuraRemoveMode
Definition SpellAuraDefines.h:390
@ AURA_REMOVE_BY_DEATH
Definition SpellAuraDefines.h:396
@ AURA_REMOVE_BY_EXPIRE
Definition SpellAuraDefines.h:395
@ AURA_REMOVE_BY_ENEMY_SPELL
Definition SpellAuraDefines.h:394
@ SPELL_GROUP_ELIXIR_BATTLE
Definition SpellMgr.h:333
@ SPELL_GROUP_ELIXIR_GUARDIAN
Definition SpellMgr.h:334
std::pair< SpellAreaForAreaMap::const_iterator, SpellAreaForAreaMap::const_iterator > SpellAreaForAreaMapBounds
Definition SpellMgr.h:549
@ SPELL_LINK_AURA
Definition SpellMgr.h:101
@ CLASS_CONTEXT_ABILITY
Definition UnitDefines.h:241
@ DOT
Definition Unit.h:264
T CalculatePct(T base, U pct)
Definition Util.h:52
uint32 GetTickNumber() const
Definition SpellAuraEffects.h:87
uint32 GetId() const
Definition SpellAuraEffects.cpp:432
int32 GetTotalTicks() const
Definition SpellAuraEffects.cpp:7096
void SetAmount(int32 amount)
Definition SpellAuraEffects.h:66
int32 GetAmount() const
Definition SpellAuraEffects.h:64
int32 GetMaxDuration() const
Definition SpellAuras.h:131
void SetDuration(int32 duration, bool withMods=false)
Definition SpellAuras.cpp:919
uint8 GetStackAmount() const
Definition SpellAuras.h:150
void SetMaxDuration(int32 duration)
Definition SpellAuras.h:132
SpellInfo const * GetTriggeredByAuraSpellInfo() const
Definition SpellAuras.cpp:2887
static ObjectGuid const Empty
Definition ObjectGuid.h:123
void RemoveRunesByAuraEffect(AuraEffect const *aura)
Definition Player.cpp:13781
void SendDirectMessage(WorldPacket const *data) const
Definition Player.cpp:5886
bool ActivateTaxiPathTo(std::vector< uint32 > const &nodes, Creature *npc=nullptr, uint32 spellid=1)
Definition Player.cpp:10430
WorldSession * GetSession() const
Definition Player.h:2032
bool HasSpellCooldown(uint32 spell_id) const override
Definition Player.cpp:16784
void AddSpellCooldown(uint32 spell_id, uint32 itemid, uint32 end_time, bool needSendToClient=false, bool forceSendToSpectator=false) override
Definition Player.cpp:11289
bool IsClass(Classes playerClass, ClassContext context=CLASS_CONTEXT_NONE) const override
Definition Player.cpp:1351
uint32 GetSpellCooldownDelay(uint32 spell_id) const
Definition Player.cpp:16796
void RemoveSpellCooldown(uint32 spell_id, bool update=false)
Definition Player.cpp:3705
std::array< uint32, 2 > SpellVisual
Definition SpellInfo.h:403
uint32 SpellIconID
Definition SpellInfo.h:404
AuraEffectList const & GetAuraEffectsByType(AuraType type) const
Definition Unit.h:1445
std::vector< AuraEffect * > AuraEffectList
Definition Unit.h:686
Aura * GetAura(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, ObjectGuid itemCasterGUID=ObjectGuid::Empty, uint8 reqEffMask=0) const
Definition Unit.cpp:5658
void RemoveAurasWithFamily(SpellFamilyNames family, uint32 familyFlag1, uint32 familyFlag2, uint32 familyFlag3, ObjectGuid casterGUID)
Definition Unit.cpp:5284
Unit * GetOwner() const
Definition Unit.cpp:7517
void ApplySpellImmune(uint32 spellId, uint32 op, uint32 type, bool apply, SpellImmuneBlockType blockType=SPELL_BLOCK_TYPE_ALL)
Definition Unit.cpp:10247
Aura * GetAuraOfRankedSpell(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, ObjectGuid itemCasterGUID=ObjectGuid::Empty, uint8 reqEffMask=0) const
Definition Unit.cpp:5676
void RemoveAura(AuraApplicationMap::iterator &i, AuraRemoveMode mode=AURA_REMOVE_BY_DEFAULT)
Definition Unit.cpp:4830
Aura * AddAura(uint32 spellId, Unit *target)
Definition Unit.cpp:14825
SpellCastResult CastCustomSpell(Unit *victim, uint32 spellId, int32 const *bp0, int32 const *bp1, int32 const *bp2, bool triggered, Item *castItem=nullptr, AuraEffect const *triggeredByAura=nullptr, ObjectGuid originalCaster=ObjectGuid::Empty)
Definition Unit.cpp:1435
AuraEffect * GetAuraEffect(uint32 spellId, uint8 effIndex, ObjectGuid casterGUID=ObjectGuid::Empty) const
Definition Unit.cpp:5571
bool HasAura(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, ObjectGuid itemCasterGUID=ObjectGuid::Empty, uint8 reqEffMask=0) const
Definition Unit.cpp:5798
AuraEffect * GetAuraEffectDummy(uint32 spellid) const
Definition Unit.cpp:5627
virtual bool HasSpell(uint32) const
Definition Unit.h:1599
void CombatStop(bool includingCast=false, bool mutualPvP=true, bool keepPvPForOthers=false)
Definition Unit.cpp:7303
uint32 SpellDamageBonusTaken(Unit *caster, SpellInfo const *spellProto, uint32 pdamage, DamageEffectType damagetype, uint32 stack=1)
Definition Unit.cpp:8711
uint32 GetMaxPower(Powers power) const
Definition Unit.h:1150
AuraEffect * GetAuraEffectOfRankedSpell(uint32 spellId, uint8 effIndex, ObjectGuid casterGUID=ObjectGuid::Empty) const
Definition Unit.cpp:5585
SpellCastResult CastSpell(SpellCastTargets const &targets, SpellInfo const *spellInfo, CustomSpellValues const *value, TriggerCastFlags triggerFlags=TRIGGERED_NONE, Item *castItem=nullptr, AuraEffect const *triggeredByAura=nullptr, ObjectGuid originalCaster=ObjectGuid::Empty)
Definition Unit.cpp:1378
bool IsMounted() const
Definition Unit.h:1908
void RemoveAurasDueToSpell(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, uint8 reqEffMask=0, AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
Definition Unit.cpp:4969
bool IsFriendlyTo(Unit const *unit) const
Definition Unit.cpp:7079
AuraEffect * GetDummyAuraEffect(SpellFamilyNames name, uint32 iconId, uint8 effIndex) const
Definition Unit.h:1454
Powers getPowerType() const
Definition Unit.h:1145
uint32 GetCreateMana() const
Definition Unit.h:1162
ObjectGuid GetTarget() const
Definition Unit.h:867
void GetZoneAndAreaId(uint32 &zoneid, uint32 &areaid) const
Definition Object.cpp:3194
bool PlayerLoading() const
Definition WorldSession.h:450
@ SMSG_MODIFY_COOLDOWN
Definition Opcodes.h:1199
void apply(T *val)
Definition ByteConverter.h:40

References Player::ActivateTaxiPathTo(), Unit::AddAura(), Player::AddSpellCooldown(), Unit::ApplySpellImmune(), AURA_REMOVE_BY_DEATH, AURA_REMOVE_BY_ENEMY_SPELL, AURA_REMOVE_BY_EXPIRE, WorldObject::CalcSpellDuration(), CalculatePct(), Unit::CastCustomSpell(), Unit::CastSpell(), CLASS_CONTEXT_ABILITY, CLASS_DEATH_KNIGHT, Unit::CombatStop(), DOT, EFFECT_0, ObjectGuid::Empty, AuraEffect::GetAmount(), Unit::GetAura(), Unit::GetAuraEffect(), Unit::GetAuraEffectDummy(), Unit::GetAuraEffectOfRankedSpell(), Unit::GetAuraEffectsByType(), Unit::GetAuraOfRankedSpell(), AuraApplication::GetBase(), GetCasterGUID(), Unit::GetCreateMana(), Unit::GetDummyAuraEffect(), GetEffect(), Object::GetGUID(), AuraEffect::GetId(), GetId(), Unit::GetLevel(), GetMaxDuration(), Unit::GetMaxPower(), Unit::GetOwner(), Unit::getPowerType(), AuraApplication::GetRemoveMode(), Player::GetSession(), Player::GetSpellCooldownDelay(), GetSpellInfo(), GetStackAmount(), AuraApplication::GetTarget(), AuraEffect::GetTotalTicks(), GetTriggeredByAuraSpellInfo(), GetUnitOwner(), WorldObject::GetZoneAndAreaId(), Unit::HasAura(), Unit::HasSpell(), Player::HasSpellCooldown(), SpellInfo::Id, IMMUNITY_ID, IN_MILLISECONDS, Player::IsClass(), IsExpired(), Unit::IsFriendlyTo(), Unit::IsMounted(), Object::IsPlayer(), LOG_ERROR, m_spellInfo, MAX_SPELL_EFFECTS, WorldSession::PlayerLoading(), POWER_ENERGY, POWER_MANA, POWER_RAGE, POWER_RUNIC_POWER, Unit::RemoveAura(), Unit::RemoveAurasDueToSpell(), Unit::RemoveAurasWithFamily(), Player::RemoveRunesByAuraEffect(), Player::RemoveSpellCooldown(), roll_chance_i(), Player::SendDirectMessage(), AuraEffect::SetAmount(), SetDuration(), SetMaxDuration(), SMSG_MODIFY_COOLDOWN, SPELL_AURA_DUMMY, SPELL_AURA_OVERRIDE_CLASS_SCRIPTS, SPELL_AURA_PERIODIC_DUMMY, SPELL_AURA_PROC_TRIGGER_SPELL, SPELL_GROUP_ELIXIR_BATTLE, SPELL_GROUP_ELIXIR_GUARDIAN, SPELL_LINK_AURA, Unit::SpellDamageBonusTaken(), SPELLFAMILY_DEATHKNIGHT, SPELLFAMILY_DRUID, SPELLFAMILY_GENERIC, SPELLFAMILY_HUNTER, SPELLFAMILY_MAGE, SPELLFAMILY_PALADIN, SPELLFAMILY_POTION, SPELLFAMILY_PRIEST, SPELLFAMILY_ROGUE, SPELLFAMILY_SHAMAN, SPELLFAMILY_WARLOCK, SPELLFAMILY_WARRIOR, SpellInfo::SpellFamilyFlags, SpellInfo::SpellFamilyName, SpellInfo::SpellIconID, SpellInfo::SpellVisual, sSpellMgr, Object::ToCreature(), and Object::ToPlayer().

Referenced by Unit::_ApplyAura(), Unit::_UnapplyAura(), and SetStackAmount().

◆ HasCasterDiedSinceApply()

bool Aura::HasCasterDiedSinceApply ( Unit const *  caster) const
433{
434 // auras on the caster itself that survive its death are passives or death persistent, never left behind
435 return caster && caster != GetOwner() && caster->GetLastDeathTime() >= m_refreshTime;
436}

References Unit::GetLastDeathTime(), GetOwner(), and m_refreshTime.

Referenced by Spell::prepare().

◆ HasEffect()

◆ HasEffectType()

bool Aura::HasEffectType ( AuraType  type) const
1297{
1298 for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
1299 {
1300 if (HasEffect(i) && m_effects[i]->GetAuraType() == type)
1301 return true;
1302 }
1303 return false;
1304}
bool HasEffect(uint8 effIndex) const
Definition SpellAuras.h:176

References HasEffect(), m_effects, and MAX_SPELL_EFFECTS.

Referenced by Unit::_AddAura(), Battleground::_ProcessJoin(), CanBeSentToClient(), AuraScript::HasEffectType(), IsSingleTargetWith(), and Unit::RemoveAura().

◆ HasMoreThanOneEffectForType()

bool Aura::HasMoreThanOneEffectForType ( AuraType  auraType) const
1129{
1130 uint32 count = 0;
1131 for (SpellEffectInfo const& spellEffectInfo : GetSpellInfo()->GetEffects())
1132 if (HasEffect(spellEffectInfo.EffectIndex) && spellEffectInfo.ApplyAuraName == auraType)
1133 ++count;
1134
1135 return count > 1;
1136}
Definition SpellInfo.h:270

References SpellInfo::GetEffects(), GetSpellInfo(), and HasEffect().

Referenced by Unit::IsHighestExclusiveAuraEffect().

◆ IsAppliedOnTarget()

bool Aura::IsAppliedOnTarget ( ObjectGuid  guid) const
inline
188{ return m_applications.find(guid) != m_applications.end(); }

References m_applications.

Referenced by _ApplyForTarget(), and Unit::_CreateAuraApplication().

◆ IsArea()

bool Aura::IsArea ( ) const
1139{
1140 for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
1141 {
1142 if (HasEffect(i) && GetSpellInfo()->Effects[i].IsAreaAuraEffect())
1143 return true;
1144 }
1145 return false;
1146}

References GetSpellInfo(), HasEffect(), and MAX_SPELL_EFFECTS.

Referenced by CanStackWith(), Unit::IsHighestExclusiveAuraEffect(), and UpdateTargetMap().

◆ IsAuraStronger()

bool Aura::IsAuraStronger ( Aura const *  newAura) const
2033{
2034 for (uint8 i = EFFECT_0; i < MAX_SPELL_EFFECTS; ++i)
2035 {
2036 AuraEffect* thisEffect = GetEffect(i);
2037 if (!thisEffect)
2038 continue;
2039
2040 AuraEffect* newEffect = nullptr;
2041 for (uint8 j = EFFECT_0; j < MAX_SPELL_EFFECTS; ++j)
2042 {
2043 newEffect = newAura->GetEffect(j);
2044 if (!newEffect || thisEffect->GetAuraType() != newEffect->GetAuraType() || thisEffect->GetMiscValue() != newEffect->GetMiscValue())
2045 continue;
2046
2047 // xinef: assume that all spells are either positive or negative, otherwise they should not be in one group
2048 int32 curValue = std::abs(thisEffect->GetAmount());
2049 if (curValue < std::abs(newEffect->GetAmount()))
2050 return true;
2051
2052 if (curValue == std::abs(newEffect->GetAmount()))
2053 if (!IsPassive() && !IsPermanent() && GetDuration() < newAura->GetDuration())
2054 return true;
2055 }
2056 }
2057
2058 return false;
2059}
AuraType GetAuraType() const
Definition SpellAuraEffects.cpp:447
int32 GetMiscValue() const
Definition SpellAuraEffects.cpp:442
int32 GetDuration() const
Definition SpellAuras.h:135
bool IsPermanent() const
Definition SpellAuras.h:141

References EFFECT_0, AuraEffect::GetAmount(), AuraEffect::GetAuraType(), GetDuration(), GetEffect(), AuraEffect::GetMiscValue(), IsPassive(), IsPermanent(), and MAX_SPELL_EFFECTS.

◆ IsDeathPersistent()

bool Aura::IsDeathPersistent ( ) const
1154{
1155 return GetSpellInfo()->IsDeathPersistent();
1156}
bool IsDeathPersistent() const
Definition SpellInfo.cpp:1262

References GetSpellInfo(), and SpellInfo::IsDeathPersistent().

Referenced by AuraScript::IsDeathPersistent(), and Unit::RemoveAllAurasOnDeath().

◆ IsExpired()

bool Aura::IsExpired ( ) const
inline

◆ IsPassive()

◆ IsPermanent()

◆ IsProcOnCooldown()

bool Aura::IsProcOnCooldown ( TimePoint  now) const
2217{
2218 if (GetType() == UNIT_AURA_TYPE)
2219 if (Player* player = GetUnitOwner()->ToPlayer())
2220 if (player->GetCommandStatus(CHEAT_COOLDOWN))
2221 return false;
2222
2223 return m_procCooldown > now;
2224}
@ CHEAT_COOLDOWN
Definition Player.h:999

References CHEAT_COOLDOWN, GetType(), GetUnitOwner(), m_procCooldown, and UNIT_AURA_TYPE.

Referenced by GetProcEffectMask().

◆ IsRemoved()

◆ IsRemovedOnShapeLost()

bool Aura::IsRemovedOnShapeLost ( Unit *  target) const

◆ IsSingleTarget()

◆ IsSingleTargetWith()

bool Aura::IsSingleTargetWith ( Aura const *  aura) const
1216{
1217 // Same spell?
1218 if (GetSpellInfo()->IsRankOf(aura->GetSpellInfo()))
1219 return true;
1220
1222 // spell with single target specific types
1223 switch (spec)
1224 {
1227 if (aura->GetSpellInfo()->GetSpellSpecific() == spec)
1228 return true;
1229 break;
1230 default:
1231 break;
1232 }
1233
1235 return true;
1236
1237 return false;
1238}
SpellSpecificType
Definition SpellInfo.h:150
@ SPELL_SPECIFIC_JUDGEMENT
Definition SpellInfo.h:162
@ SPELL_SPECIFIC_MAGE_POLYMORPH
Definition SpellInfo.h:161

References GetSpellInfo(), SpellInfo::GetSpellSpecific(), HasEffectType(), SPELL_AURA_CONTROL_VEHICLE, SPELL_SPECIFIC_JUDGEMENT, and SPELL_SPECIFIC_MAGE_POLYMORPH.

Referenced by Unit::_AddAura().

◆ IsUsingCharges()

◆ LoadScripts()

void Aura::LoadScripts ( )
2482{
2483 sScriptMgr->CreateAuraScripts(m_spellInfo->Id, m_loadedScripts);
2484 for (std::list<AuraScript*>::iterator itr = m_loadedScripts.begin(); itr != m_loadedScripts.end();)
2485 {
2486 if (!(*itr)->_Load(this))
2487 {
2488 std::list<AuraScript*>::iterator bitr = itr;
2489 ++itr;
2490 delete (*bitr);
2491 m_loadedScripts.erase(bitr);
2492 continue;
2493 }
2494 LOG_DEBUG("spells.aura", "Aura::LoadScripts: Script `{}` for aura `{}` is loaded now", (*itr)->_GetScriptName()->c_str(), m_spellInfo->Id);
2495 (*itr)->Register();
2496 ++itr;
2497 }
2498}
#define LOG_DEBUG(filterType__,...)
Definition Log.h:157

References SpellInfo::Id, LOG_DEBUG, m_loadedScripts, m_spellInfo, and sScriptMgr.

Referenced by DynObjAura::DynObjAura(), and UnitAura::UnitAura().

◆ ModCharges()

bool Aura::ModCharges ( int32  num,
AuraRemoveMode  removeMode = AURA_REMOVE_BY_DEFAULT 
)
1027{
1028 if (IsUsingCharges())
1029 {
1030 int32 charges = m_procCharges + num;
1031 int32 maxCharges = CalcMaxCharges();
1032
1033 // limit charges (only on charges increase, charges may be changed manually)
1034 if ((num > 0) && (charges > int32(maxCharges)))
1035 charges = maxCharges;
1036 // we're out of charges, remove
1037 else if (charges <= 0)
1038 {
1039 Remove(removeMode);
1040 return true;
1041 }
1042
1043 SetCharges(charges);
1044 }
1045 return false;
1046}
void SetCharges(uint8 charges)
Definition SpellAuras.cpp:1005

References CalcMaxCharges(), IsUsingCharges(), m_procCharges, Remove(), and SetCharges().

Referenced by DropCharge(), AuraScript::ModCharges(), Unit::RemoveAurasDueToSpellByDispel(), and Unit::RemoveAurasDueToSpellBySteal().

◆ ModStackAmount()

bool Aura::ModStackAmount ( int32  num,
AuraRemoveMode  removeMode = AURA_REMOVE_BY_DEFAULT,
bool  periodicReset = false 
)
1084{
1085 int32 stackAmount = m_stackAmount + num;
1086
1087 // limit the stack amount (only on stack increase, stack amount may be changed manually)
1088 if ((num > 0) && (stackAmount > int32(m_spellInfo->StackAmount)))
1089 {
1090 // not stackable aura - set stack amount to 1
1092 stackAmount = 1;
1093 else
1094 stackAmount = m_spellInfo->StackAmount;
1095 }
1096 // we're out of stacks, remove
1097 else if (stackAmount <= 0)
1098 {
1099 Remove(removeMode);
1100 return true;
1101 }
1102
1103 bool refresh = stackAmount >= GetStackAmount() && (m_spellInfo->StackAmount || !m_spellInfo->HasAttribute(SPELL_ATTR1_AURA_UNIQUE));
1104
1105 // Update stack amount
1106 if (refresh)
1107 {
1109 RefreshTimers(periodicReset);
1110
1111 // reset charges
1113 }
1114
1115 SetStackAmount(stackAmount);
1116
1118 return false;
1119}
@ SPELL_ATTR1_AURA_UNIQUE
Definition SharedDefines.h:418
void SetStackAmount(uint8 num)
Definition SpellAuras.cpp:1048
void RefreshTimers(bool periodicReset=false)
Definition SpellAuras.cpp:962
void SetNeedClientUpdateForTargets() const
Definition SpellAuras.cpp:1332
void RefreshSpellMods()
Definition SpellAuras.cpp:1121
uint32 StackAmount
Definition SpellInfo.h:395

References CalcMaxCharges(), GetStackAmount(), SpellInfo::HasAttribute(), m_spellInfo, m_stackAmount, RefreshSpellMods(), RefreshTimers(), Remove(), SetCharges(), SetNeedClientUpdateForTargets(), SetStackAmount(), SPELL_ATTR1_AURA_UNIQUE, and SpellInfo::StackAmount.

Referenced by spell_the_lich_king_necrotic_plague_jump::AddMissingStack(), ConsumeProcCharges(), Spell::DoSpellHitOnUnit(), misc_commandscript::HandleAuraStacksCommand(), spell_charge_shield_bomber::HandleDummy(), spell_freya_attuned_to_nature_dose_reduction::HandleScript(), AuraScript::ModStackAmount(), Unit::RemoveAuraFromStack(), Unit::RemoveAurasDueToSpellByDispel(), and Unit::RemoveAurasDueToSpellBySteal().

◆ PrepareProcToTrigger()

void Aura::PrepareProcToTrigger ( AuraApplication *  aurApp,
ProcEventInfo &  eventInfo,
TimePoint  now 
)
2242{
2243 bool prepare = CallScriptPrepareProcHandlers(aurApp, eventInfo);
2244 if (!prepare)
2245 return;
2246
2247 // take one charge, aura expiration will be handled in Aura::TriggerProcOnEvent (if needed)
2249 {
2250 --m_procCharges;
2252 }
2253
2254 SpellProcEntry const* procEntry = sSpellMgr->GetSpellProcEntry(GetId());
2255
2256 ASSERT(procEntry);
2257
2258 // cooldowns should be added to the whole aura (see 51698 area aura)
2259 AddProcCooldown(now + procEntry->Cooldown);
2260}
@ SPELL_ATTR6_DO_NOT_CONSUME_RESOURCES
Definition SharedDefines.h:597
bool CallScriptPrepareProcHandlers(AuraApplication const *aurApp, ProcEventInfo &eventInfo)
Definition SpellAuras.cpp:2791
Milliseconds Cooldown
Definition SpellMgr.h:298

References AddProcCooldown(), ASSERT, CallScriptPrepareProcHandlers(), SpellProcEntry::Cooldown, GetId(), ProcEventInfo::GetSpellInfo(), SpellInfo::HasAttribute(), IsUsingCharges(), m_procCharges, SetNeedClientUpdateForTargets(), SPELL_ATTR6_DO_NOT_CONSUME_RESOURCES, and sSpellMgr.

◆ RecalculateAmountOfEffects()

void Aura::RecalculateAmountOfEffects ( )
1307{
1308 ASSERT (!IsRemoved());
1309 Unit* caster = GetCaster();
1310 for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
1311 if (HasEffect(i))
1312 m_effects[i]->RecalculateAmount(caster);
1313}
void RecalculateAmount()
Definition SpellAuraEffects.h:76

References ASSERT, GetCaster(), HasEffect(), IsRemoved(), m_effects, MAX_SPELL_EFFECTS, and AuraEffect::RecalculateAmount().

◆ RefreshDuration()

void Aura::RefreshDuration ( bool  withMods = false)
Todo:
  • Look to convert to std::chrono
932{
933 Unit* caster = GetCaster();
934
935 if (!caster)
936 return;
937
939
940 if (withMods && caster)
941 {
942 int32 duration = m_spellInfo->GetMaxDuration();
943 // Calculate duration of periodics affected by haste.
945 duration = int32(duration * caster->GetFloatValue(UNIT_MOD_CAST_SPEED));
946 SetMaxDuration(duration);
947
948 SetDuration(duration);
949 }
950 else
952
955
956 // also reset periodic counters
957 for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
958 if (AuraEffect* aurEff = m_effects[i])
959 aurEff->ResetTicks();
960}
@ SPELL_ATTR5_SPELL_HASTE_AFFECTS_PERIODIC
Definition SharedDefines.h:568
@ SPELL_AURA_PERIODIC_HASTE
Definition SpellAuraDefines.h:379
@ UNIT_MOD_CAST_SPEED
Definition UpdateFields.h:137
float GetFloatValue(uint16 index) const
Definition Object.cpp:315
int32 GetMaxDuration() const
Definition SpellInfo.cpp:2785
bool HasAuraTypeWithAffectMask(AuraType auratype, SpellInfo const *affectedSpell) const
Definition Unit.cpp:5838

References GetCaster(), Object::GetFloatValue(), GameTime::GetGameTimeMS(), GetMaxDuration(), SpellInfo::GetMaxDuration(), SpellInfo::HasAttribute(), Unit::HasAuraTypeWithAffectMask(), IN_MILLISECONDS, m_effects, m_refreshTime, m_spellInfo, m_timeCla, SpellInfo::ManaPerSecond, SpellInfo::ManaPerSecondPerLevel, MAX_SPELL_EFFECTS, SetDuration(), SetMaxDuration(), SPELL_ATTR2_NO_TARGET_PER_SECOND_COST, SPELL_ATTR5_SPELL_HASTE_AFFECTS_PERIODIC, SPELL_AURA_PERIODIC_HASTE, and UNIT_MOD_CAST_SPEED.

Referenced by spell_hun_chimera_shot::HandleScriptEffect(), boss_shirrak_the_dead_watcher::JustEngagedWith(), AuraScript::RefreshDuration(), RefreshTimers(), RefreshTimersWithMods(), and AuraEffect::UpdatePeriodic().

◆ RefreshSpellMods()

void Aura::RefreshSpellMods ( )
1122{
1123 for (Aura::ApplicationMap::const_iterator appIter = m_applications.begin(); appIter != m_applications.end(); ++appIter)
1124 if (Player* player = appIter->second->GetTarget()->ToPlayer())
1125 player->RestoreAllSpellMods(0, this);
1126}

References Unit::GetTarget(), and m_applications.

Referenced by ModStackAmount().

◆ RefreshTimers()

void Aura::RefreshTimers ( bool  periodicReset = false)
963{
966 Unit* caster = GetCaster();
967
968 if (!caster)
969 {
970 return;
971 }
972
973 for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
974 {
975 if (AuraEffect* aurEff = m_effects[i])
976 {
977 aurEff->CalculatePeriodic(caster, periodicReset, false);
978 aurEff->CalculatePeriodicData();
979 }
980 }
981}
void RefreshDuration(bool withMods=false)
Definition SpellAuras.cpp:931

References CalcMaxDuration(), GetCaster(), m_effects, m_maxDuration, MAX_SPELL_EFFECTS, and RefreshDuration().

Referenced by ModStackAmount().

◆ RefreshTimersWithMods()

void Aura::RefreshTimersWithMods ( )
985{
986 Unit* caster = GetCaster();
989 {
991 }
992
993 // xinef: we should take ModSpellDuration into account, but none of the spells using this function is affected by contents of ModSpellDuration
995
996 for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
997 {
998 if (AuraEffect* aurEff = m_effects[i])
999 {
1000 aurEff->CalculatePeriodic(caster, false, false);
1001 }
1002 }
1003}

References CalcMaxDuration(), GetCaster(), Object::GetFloatValue(), SpellInfo::HasAttribute(), Unit::HasAuraTypeWithAffectMask(), m_effects, m_maxDuration, m_spellInfo, MAX_SPELL_EFFECTS, RefreshDuration(), SPELL_ATTR5_SPELL_HASTE_AFFECTS_PERIODIC, SPELL_AURA_PERIODIC_HASTE, and UNIT_MOD_CAST_SPEED.

◆ Remove()

◆ ResetProcCooldown()

void Aura::ResetProcCooldown ( )
2237{
2238 m_procCooldown = std::chrono::steady_clock::now();
2239}

References m_procCooldown.

◆ SetCharges()

◆ SetDuration()

◆ SetIsSingleTarget()

void Aura::SetIsSingleTarget ( bool  val)
inline

◆ SetLoadedState()

void Aura::SetLoadedState ( int32  maxduration,
int32  duration,
int32  charges,
uint8  stackamount,
uint8  recalculateMask,
int32 *  amount 
)
1277{
1278 m_maxDuration = maxduration;
1279 m_duration = duration;
1280 m_procCharges = charges;
1282 m_stackAmount = stackamount;
1283 Unit* caster = GetCaster();
1284 for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
1285 if (m_effects[i])
1286 {
1287 m_effects[i]->SetAmount(amount[i]);
1288 m_effects[i]->SetCanBeRecalculated(recalculateMask & (1 << i));
1289 m_effects[i]->CalculatePeriodic(caster, false, true);
1291 if (caster)
1292 m_effects[i]->RecalculateAmount(caster);
1293 }
1294}
void CalculatePeriodic(Unit *caster, bool create=false, bool load=false)
Definition SpellAuraEffects.cpp:599
void CalculateSpellMod()
Definition SpellAuraEffects.cpp:690
void SetCanBeRecalculated(bool val)
Definition SpellAuraEffects.h:79

References AuraEffect::CalculatePeriodic(), AuraEffect::CalculateSpellMod(), GetCaster(), m_duration, m_effects, m_isUsingCharges, m_maxDuration, m_procCharges, m_stackAmount, MAX_SPELL_EFFECTS, AuraEffect::RecalculateAmount(), AuraEffect::SetAmount(), and AuraEffect::SetCanBeRecalculated().

◆ SetMaxDuration()

◆ SetNeedClientUpdateForTargets()

void Aura::SetNeedClientUpdateForTargets ( ) const
1333{
1334 for (ApplicationMap::const_iterator appIter = m_applications.begin(); appIter != m_applications.end(); ++appIter)
1335 appIter->second->SetNeedClientUpdate();
1336}

References m_applications.

Referenced by Unit::DelayOwnedAuras(), ModStackAmount(), PrepareProcToTrigger(), SetCharges(), SetDuration(), and SetStackAmount().

◆ SetStackAmount()

void Aura::SetStackAmount ( uint8  num)
1049{
1050 uint8 const oldStackAmount = m_stackAmount;
1051 m_stackAmount = stackAmount;
1052 Unit* caster = GetCaster();
1053
1054 if (!caster)
1055 {
1056 // can't recalc without the caster (its bonuses would be lost), so scale the current amount instead
1057 if (oldStackAmount && oldStackAmount != stackAmount)
1058 for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
1059 if (HasEffect(i))
1061 int32(int64(m_effects[i]->GetAmount()) * stackAmount / oldStackAmount), false, false);
1062 return;
1063 }
1064
1065 std::list<AuraApplication*> applications;
1066 GetApplicationList(applications);
1067
1068 for (std::list<AuraApplication*>::const_iterator apptItr = applications.begin(); apptItr != applications.end(); ++apptItr)
1069 if (!(*apptItr)->GetRemoveMode())
1070 HandleAuraSpecificMods(*apptItr, caster, false, true);
1071
1072 for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
1073 if (HasEffect(i))
1074 m_effects[i]->ChangeAmount(m_effects[i]->CalculateAmount(caster), false, true);
1075
1076 for (std::list<AuraApplication*>::const_iterator apptItr = applications.begin(); apptItr != applications.end(); ++apptItr)
1077 if (!(*apptItr)->GetRemoveMode())
1078 HandleAuraSpecificMods(*apptItr, caster, true, true);
1079
1081}
std::int64_t int64
Definition Define.h:102
void ChangeAmount(int32 newAmount, bool mark=true, bool onStackOrReapply=false)
Definition SpellAuraEffects.cpp:713
void GetApplicationList(std::list< AuraApplication * > &applicationList) const
Definition SpellAuras.cpp:1323
void HandleAuraSpecificMods(AuraApplication const *aurApp, Unit *caster, bool apply, bool onReapply)
Definition SpellAuras.cpp:1339

References AuraEffect::ChangeAmount(), GetApplicationList(), GetCaster(), HandleAuraSpecificMods(), HasEffect(), m_effects, m_stackAmount, MAX_SPELL_EFFECTS, and SetNeedClientUpdateForTargets().

Referenced by Spell::DoSpellHitOnUnit(), AuraEffect::HandleAuraDummy(), spell_brewfest_main_ram_buff::HandleEffectPeriodic(), spell_rotface_large_ooze_combine::HandleScript(), boss_shirrak_the_dead_watcher::JustEngagedWith(), ModStackAmount(), Unit::SetAuraStack(), and AuraScript::SetStackAmount().

◆ SetTriggeredByAuraSpellInfo()

void Aura::SetTriggeredByAuraSpellInfo ( SpellInfo const *  triggeredByAuraSpellInfo)
2874{
2875 m_triggeredByAuraSpellInfo = triggeredByAuraSpellInfo;
2876}

References m_triggeredByAuraSpellInfo.

Referenced by Spell::DoSpellHitOnUnit(), and Spell::EffectPersistentAA().

◆ SetUsingCharges()

void Aura::SetUsingCharges ( bool  val)
inline

◆ TriggerProcOnEvent()

void Aura::TriggerProcOnEvent ( uint8  procEffectMask,
AuraApplication *  aurApp,
ProcEventInfo &  eventInfo 
)
2438{
2439 bool prevented = CallScriptProcHandlers(aurApp, eventInfo);
2440 if (!prevented)
2441 {
2442 for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
2443 {
2444 if (!(procEffectMask & (1 << i)))
2445 continue;
2446
2447 // OnEffectProc / AfterEffectProc hooks handled in AuraEffect::HandleProc()
2448 if (aurApp->HasEffect(i))
2449 GetEffect(i)->HandleProc(aurApp, eventInfo);
2450 }
2451
2452 CallScriptAfterProcHandlers(aurApp, eventInfo);
2453 }
2454
2455 ConsumeProcCharges(sSpellMgr->GetSpellProcEntry(GetId()));
2456}
bool HasEffect(uint8 effect) const
Definition SpellAuras.h:68
void HandleProc(AuraApplication *aurApp, ProcEventInfo &eventInfo)
Definition SpellAuraEffects.cpp:1308
void CallScriptAfterProcHandlers(AuraApplication const *aurApp, ProcEventInfo &eventInfo)
Definition SpellAuras.cpp:2827
void ConsumeProcCharges(SpellProcEntry const *procEntry)
Definition SpellAuras.cpp:2458
bool CallScriptProcHandlers(AuraApplication const *aurApp, ProcEventInfo &eventInfo)
Definition SpellAuras.cpp:2810

References CallScriptAfterProcHandlers(), CallScriptProcHandlers(), ConsumeProcCharges(), GetEffect(), GetId(), AuraEffect::HandleProc(), AuraApplication::HasEffect(), MAX_SPELL_EFFECTS, and sSpellMgr.

◆ TryCreate()

Aura * Aura::TryCreate ( SpellInfo const *  spellproto,
uint8  effMask,
WorldObject *  owner,
Unit *  caster,
int32 *  baseAmount = nullptr,
Item *  castItem = nullptr,
ObjectGuid  casterGUID = ObjectGuid::Empty,
ObjectGuid  itemGUID = ObjectGuid::Empty 
)
static
297{
298 ASSERT_NODEBUGINFO(spellproto);
299 ASSERT_NODEBUGINFO(owner);
300 ASSERT_NODEBUGINFO(caster || casterGUID);
301 ASSERT_NODEBUGINFO(tryEffMask <= MAX_EFFECT_MASK);
302 uint8 effMask = Aura::BuildEffectMaskForOwner(spellproto, tryEffMask, owner);
303 if (!effMask)
304 return nullptr;
305 return Create(spellproto, effMask, owner, caster, baseAmount, castItem, casterGUID, itemGUID);
306}
static uint8 BuildEffectMaskForOwner(SpellInfo const *spellProto, uint8 avalibleEffectMask, WorldObject *owner)
Definition SpellAuras.cpp:242
static Aura * Create(SpellInfo const *spellproto, uint8 effMask, WorldObject *owner, Unit *caster, int32 *baseAmount, Item *castItem, ObjectGuid casterGUID, ObjectGuid itemGUID=ObjectGuid::Empty)
Definition SpellAuras.cpp:308

References ASSERT_NODEBUGINFO, BuildEffectMaskForOwner(), Create(), and MAX_EFFECT_MASK.

Referenced by Pet::_LoadAuras(), Player::_LoadAuras(), Spell::EffectPersistentAA(), and Unit::RemoveAurasDueToSpellByDispel().

◆ TryRefreshStackOrCreate()

Aura * Aura::TryRefreshStackOrCreate ( SpellInfo const *  spellproto,
uint8  tryEffMask,
WorldObject *  owner,
Unit *  caster,
int32 *  baseAmount = nullptr,
Item *  castItem = nullptr,
ObjectGuid  casterGUID = ObjectGuid::Empty,
bool *  refresh = nullptr,
bool  periodicReset = false 
)
static
271{
272 ASSERT_NODEBUGINFO(spellproto);
273 ASSERT_NODEBUGINFO(owner);
274 ASSERT_NODEBUGINFO(caster || casterGUID);
275 ASSERT_NODEBUGINFO(tryEffMask <= MAX_EFFECT_MASK);
276 if (refresh)
277 *refresh = false;
278 uint8 effMask = Aura::BuildEffectMaskForOwner(spellproto, tryEffMask, owner);
279 if (!effMask)
280 return nullptr;
281 if (Aura* foundAura = owner->ToUnit()->_TryStackingOrRefreshingExistingAura(spellproto, effMask, caster, baseAmount, castItem, casterGUID, periodicReset))
282 {
283 // we've here aura, which script triggered removal after modding stack amount
284 // check the state here, so we won't create new Aura object
285 if (foundAura->IsRemoved())
286 return nullptr;
287
288 if (refresh)
289 *refresh = true;
290 return foundAura;
291 }
292 else
293 return Create(spellproto, effMask, owner, caster, baseAmount, castItem, casterGUID);
294}
Aura * _TryStackingOrRefreshingExistingAura(SpellInfo const *newAura, uint8 effMask, Unit *caster, int32 *baseAmount=nullptr, Item *castItem=nullptr, ObjectGuid casterGUID=ObjectGuid::Empty, bool periodicReset=false)
Definition Unit.cpp:4418

References Unit::_TryStackingOrRefreshingExistingAura(), ASSERT_NODEBUGINFO, BuildEffectMaskForOwner(), Create(), MAX_EFFECT_MASK, and Object::ToUnit().

Referenced by Unit::AddAura(), Spell::DoSpellHitOnUnit(), misc_commandscript::HandleAuraCommand(), misc_commandscript::HandleFreezeCommand(), spell_putricide_slime_puddle::HandleScript(), Unit::HandleSpellClick(), and Unit::RemoveAurasDueToSpellBySteal().

◆ UnregisterSingleTarget()

void Aura::UnregisterSingleTarget ( )
1241{
1243 Unit* caster = GetCaster();
1244 if (!caster)
1245 {
1246 LOG_INFO("spells", "Aura::UnregisterSingleTarget: (A1) - {}, {}, {}, {}", GetId(), GetOwner()->GetTypeId(), GetOwner()->GetEntry(), GetOwner()->GetName());
1247 LOG_ERROR("spells", "Aura::UnregisterSingleTarget: No caster was found."); //ASSERT(caster);
1248 }
1249 else
1250 caster->GetSingleCastAuras().remove(this);
1251
1252 SetIsSingleTarget(false);
1253}
#define LOG_INFO(filterType__,...)
Definition Log.h:153
void SetIsSingleTarget(bool val)
Definition SpellAuras.h:169
AuraList & GetSingleCastAuras()
Definition Unit.h:1446

References ASSERT, GetCaster(), GetId(), GetOwner(), Unit::GetSingleCastAuras(), LOG_ERROR, LOG_INFO, m_isSingleTarget, and SetIsSingleTarget().

Referenced by Unit::RemoveAurasDueToSpellBySteal(), and Unit::RemoveOwnedAura().

◆ Update()

void Aura::Update ( uint32  diff,
Unit *  caster 
)
850{
851 if (m_duration > 0)
852 {
853 m_duration -= diff;
854 if (m_duration < 0)
855 m_duration = 0;
856
857 // handle ManaPerSecond/ManaPerSecondPerLevel
858 if (m_timeCla)
859 {
860 if (m_timeCla > int32(diff))
861 m_timeCla -= diff;
862 else if (caster)
863 {
864 if (int32 ManaPerSecond = m_spellInfo->ManaPerSecond + m_spellInfo->ManaPerSecondPerLevel * caster->GetLevel())
865 {
866 m_timeCla += 1000 - diff;
867
868 Powers powertype = Powers(m_spellInfo->PowerType);
869 if (powertype == POWER_HEALTH)
870 {
871 if (int32(caster->GetHealth()) > ManaPerSecond)
872 caster->ModifyHealth(-ManaPerSecond);
873 else
874 {
875 Remove();
876 return;
877 }
878 }
879 else
880 {
881 if (int32(caster->GetPower(powertype)) >= ManaPerSecond)
882 caster->ModifyPower(powertype, -ManaPerSecond);
883 else
884 {
885 Remove();
886 return;
887 }
888 }
889 }
890 }
891 }
892 }
893}
Powers
Definition SharedDefines.h:256
@ POWER_HEALTH
Definition SharedDefines.h:266
uint32 PowerType
Definition SpellInfo.h:386
int32 ModifyHealth(int32 val)
Definition Unit.cpp:10784
int32 ModifyPower(Powers power, int32 val, bool withPowerUpdate=true)
Definition Unit.cpp:10842
uint32 GetHealth() const
Definition Unit.h:1122
uint32 GetPower(Powers power) const
Definition Unit.h:1149

References Unit::GetHealth(), Unit::GetLevel(), Unit::GetPower(), m_duration, m_spellInfo, m_timeCla, SpellInfo::ManaPerSecond, SpellInfo::ManaPerSecondPerLevel, Unit::ModifyHealth(), Unit::ModifyPower(), POWER_HEALTH, SpellInfo::PowerType, and Remove().

Referenced by UpdateOwner().

◆ UpdateOwner()

void Aura::UpdateOwner ( uint32  diff,
WorldObject *  owner 
)
808{
809 if (owner != m_owner)
810 {
811 ABORT();
812 }
813
814 Unit* caster = GetCaster();
815 // Apply spellmods for channeled auras
816 // used for example when triggered spell of spell:10 is modded
817 Spell* modSpell = nullptr;
818 Player* modOwner = nullptr;
819 if (caster)
820 {
821 modOwner = caster->GetSpellModOwner();
822 if (modOwner)
823 {
824 modSpell = modOwner->FindCurrentSpellBySpellId(GetId());
825 if (modSpell)
826 modOwner->SetSpellModTakingSpell(modSpell, true);
827 }
828 }
829
830 Update(diff, caster);
831
832 if (m_updateTargetMapInterval <= int32(diff))
833 UpdateTargetMap(caster);
834 else
836
837 // update aura effects
838 for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
839 if (m_effects[i])
840 m_effects[i]->Update(diff, caster);
841
842 // remove spellmods after effects update
843 if (modSpell)
844 modOwner->SetSpellModTakingSpell(modSpell, false);
845
847}
void Update(uint32 diff, Unit *caster)
Definition SpellAuraEffects.cpp:926
void Update(uint32 diff, Unit *caster)
Definition SpellAuras.cpp:849
void SetSpellModTakingSpell(Spell *spell, bool apply)
Definition Player.cpp:10286
Spell * FindCurrentSpellBySpellId(uint32 spell_id) const
Definition Unit.cpp:4103

References _DeleteRemovedApplications(), ABORT, Unit::FindCurrentSpellBySpellId(), GetCaster(), GetId(), Unit::GetSpellModOwner(), m_effects, m_owner, m_updateTargetMapInterval, MAX_SPELL_EFFECTS, Player::SetSpellModTakingSpell(), AuraEffect::Update(), Update(), and UpdateTargetMap().

Referenced by DynamicObject::Update().

◆ UpdateTargetMap()

void Aura::UpdateTargetMap ( Unit *  caster,
bool  apply = true 
)
595{
596 if (IsRemoved())
597 return;
598
600
601 // fill up to date target list
602 // target, effMask
603 std::map<Unit*, uint8> targets;
604
605 FillTargetMap(targets, caster);
606
607 UnitList targetsToRemove;
608
609 // mark all auras as ready to remove
610 for (ApplicationMap::iterator appIter = m_applications.begin(); appIter != m_applications.end(); ++appIter)
611 {
612 std::map<Unit*, uint8>::iterator existing = targets.find(appIter->second->GetTarget());
613 // not found in current area - remove the aura
614 if (existing == targets.end())
615 targetsToRemove.push_back(appIter->second->GetTarget());
616 else
617 {
618 // xinef: check immunities here, so aura wont get removed on every tick and then reapplied
619 if (IsArea())
620 for (uint8 effIndex = 0; effIndex < MAX_SPELL_EFFECTS; ++effIndex)
621 {
622 if ((existing->second & (1 << effIndex)) && existing->first->IsImmunedToSpellEffect(GetSpellInfo(), effIndex, GetCaster()))
623 existing->second &= ~(1 << effIndex);
624 }
625
626 // paladin auras of the same spell coexist per caster, but only the strongest one keeps
627 // its effects on the target. If a stronger duplicate from another paladin is present,
628 // strip this aura's effects and keep the application effect-free (Aura Mastery needs it
629 // applied) without removing it, which would otherwise churn every update cycle.
630 bool keepEffectless = false;
632 {
633 if (AuraApplication* otherApp = GetDominantOtherSameSpellApp(existing->first, GetId(), GetCasterGUID()))
634 {
635 if (!IsPaladinAuraDominant(this, otherApp->GetBase(), existing->first))
636 {
637 for (uint8 effIndex = 0; effIndex < MAX_SPELL_EFFECTS; ++effIndex)
638 if (appIter->second->HasEffect(effIndex))
639 appIter->second->_HandleEffect(effIndex, false);
640 keepEffectless = true;
641 }
642 }
643 }
644
645 // needs readding - remove now, will be applied in next update cycle
646 // (dbcs do not have auras which apply on same type of targets but have different radius, so this is not really needed)
647 if ((appIter->second->GetEffectMask() != existing->second && !keepEffectless) || !CanBeAppliedOn(existing->first))
648 targetsToRemove.push_back(appIter->second->GetTarget());
649 // nothing todo - aura already applied
650 // remove from auras to register list
651 targets.erase(existing);
652 }
653 }
654
655 // register auras for units
656 for (std::map<Unit*, uint8>::iterator itr = targets.begin(); itr != targets.end();)
657 {
658 // aura mustn't be already applied on target
659 if (AuraApplication* aurApp = GetApplicationOfTarget(itr->first->GetGUID()))
660 {
661 // the core created 2 different units with same guid
662 // this is a major failue, which i can't fix right now
663 // let's remove one unit from aura list
664 // this may cause area aura "bouncing" between 2 units after each update
665 // but because we know the reason of a crash we can remove the assertion for now
666 if (aurApp->GetTarget() != itr->first)
667 {
668 // remove from auras to register list
669 targets.erase(itr++);
670 continue;
671 }
672 else
673 {
674 // ok, we have one unit twice in target map (impossible, but...)
675 ABORT();
676 }
677 }
678
679 bool addUnit = true;
680 // check target immunities
681 for (uint8 effIndex = 0; effIndex < MAX_SPELL_EFFECTS; ++effIndex)
682 {
683 if ((itr->second & (1 << effIndex)) && itr->first->IsImmunedToSpellEffect(GetSpellInfo(), effIndex, GetCaster()))
684 itr->second &= ~(1 << effIndex);
685 }
686 if (!itr->second || itr->first->IsImmunedToSpell(GetSpellInfo(), GetCaster()) || !CanBeAppliedOn(itr->first))
687 addUnit = false;
688
689 if (addUnit && !itr->first->IsHighestExclusiveAura(this, true))
690 addUnit = false;
691
692 if (addUnit)
693 {
694 // persistent area aura does not hit flying targets
695 if (GetType() == DYNOBJ_AURA_TYPE)
696 {
697 if (itr->first->IsInFlight())
698 addUnit = false;
699
700 // Allow only 1 persistent area aura to affect our targets if a custom flag is set.
701 if (itr->first->HasAura(GetId()) && GetSpellInfo()->HasAttribute(SPELL_ATTR0_CU_ONLY_ONE_AREA_AURA))
702 addUnit = false;
703 }
704 // unit auras can not stack with each other
705 else // (GetType() == UNIT_AURA_TYPE)
706 {
707 // Allow to remove by stack when aura is going to be applied on owner
708 if (itr->first != GetOwner())
709 {
710 // check if not stacking aura already on target
711 // this one prevents unwanted usefull buff loss because of stacking and prevents overriding auras periodicaly by 2 near area aura owners
712 for (Unit::AuraApplicationMap::iterator iter = itr->first->GetAppliedAuras().begin(); iter != itr->first->GetAppliedAuras().end(); ++iter)
713 {
714 Aura const* aura = iter->second->GetBase();
715 if (!CanStackWith(aura))
716 {
717 addUnit = false;
718 break;
719 }
720 }
721 }
722 }
723 }
724 if (!addUnit)
725 targets.erase(itr++);
726 else
727 {
728 // owner has to be in world, or effect has to be applied to self
729 if (!GetOwner()->IsSelfOrInSameMap(itr->first))
730 {
731 //TODO: There is a crash caused by shadowfiend load addon
732 LOG_FATAL("spells.aura", "Aura {}: Owner {} (map {}) is not in the same map as target {} (map {}).", GetSpellInfo()->Id,
733 GetOwner()->GetName(), GetOwner()->IsInWorld() ? GetOwner()->GetMap()->GetId() : uint32(-1),
734 itr->first->GetName(), itr->first->IsInWorld() ? itr->first->GetMap()->GetId() : uint32(-1));
735 ABORT();
736 }
737
738 // paladin auras of the same spell coexist per caster, but only the strongest one keeps
739 // its effects on the target; weaker duplicates are applied without effects so each
740 // paladin's Aura Mastery can still detect their own aura on the target.
741 uint8 effMask = itr->second;
743 {
744 if (AuraApplication* otherApp = GetDominantOtherSameSpellApp(itr->first, GetId(), GetCasterGUID()))
745 {
746 if (IsPaladinAuraDominant(this, otherApp->GetBase(), itr->first))
747 {
748 // this aura is stronger - strip the other aura's effects on this target
749 for (uint8 effIndex = 0; effIndex < MAX_SPELL_EFFECTS; ++effIndex)
750 if (otherApp->HasEffect(effIndex))
751 otherApp->_HandleEffect(effIndex, false);
752 }
753 else
754 {
755 effMask = 0;
756 }
757 }
758 }
759 itr->second = effMask;
760 itr->first->_CreateAuraApplication(this, effMask);
761 ++itr;
762 }
763 }
764
765 // remove auras from units no longer needing them
766 for (UnitList::iterator itr = targetsToRemove.begin(); itr != targetsToRemove.end(); ++itr)
767 if (AuraApplication* aurApp = GetApplicationOfTarget((*itr)->GetGUID()))
768 (*itr)->_UnapplyAura(aurApp, AURA_REMOVE_BY_DEFAULT);
769
770 if (!apply)
771 return;
772
773 // apply aura effects for units
774 for (std::map<Unit*, uint8>::iterator itr = targets.begin(); itr != targets.end(); ++itr)
775 {
776 if (AuraApplication* aurApp = GetApplicationOfTarget(itr->first->GetGUID()))
777 {
778 // owner has to be in world, or effect has to be applied to self
779 ASSERT((!GetOwner()->IsInWorld() && GetOwner() == itr->first) || GetOwner()->IsInMap(itr->first));
780 itr->first->_ApplyAura(aurApp, itr->second);
781 }
782 }
783}
#define LOG_FATAL(filterType__,...)
Definition Log.h:141
@ AURA_REMOVE_BY_DEFAULT
Definition SpellAuraDefines.h:392
static bool IsPaladinAuraDominant(Aura const *aura, Aura const *other, Unit const *target)
Definition SpellAuras.cpp:551
static AuraApplication * GetDominantOtherSameSpellApp(Unit *target, uint32 spellId, ObjectGuid casterGUID)
Definition SpellAuras.cpp:576
static constexpr int32 UPDATE_TARGET_MAP_INTERVAL
Definition SpellAuras.cpp:45
@ SPELL_ATTR0_CU_ONLY_ONE_AREA_AURA
Definition SpellInfo.h:207
virtual void FillTargetMap(std::map< Unit *, uint8 > &targets, Unit *caster)=0
bool CanStackWith(Aura const *existingAura) const
Definition SpellAuras.cpp:2061
bool CanBeAppliedOn(Unit *target)
Definition SpellAuras.cpp:2010
bool IsSelfOrInSameMap(WorldObject const *obj) const
Definition Object.cpp:1334

References ABORT, ASSERT, AURA_REMOVE_BY_DEFAULT, CanBeAppliedOn(), CanStackWith(), DYNOBJ_AURA_TYPE, FillTargetMap(), GetApplicationOfTarget(), GetCaster(), GetCasterGUID(), GetDominantOtherSameSpellApp(), GetId(), GetOwner(), GetSpellInfo(), SpellInfo::GetSpellSpecific(), GetType(), SpellInfo::HasAttribute(), IsArea(), IsPaladinAuraDominant(), IsRemoved(), WorldObject::IsSelfOrInSameMap(), LOG_FATAL, m_applications, m_spellInfo, m_updateTargetMapInterval, MAX_SPELL_EFFECTS, SPELL_ATTR0_CU_ONLY_ONE_AREA_AURA, SPELL_SPECIFIC_AURA, and UPDATE_TARGET_MAP_INTERVAL.

Referenced by _RegisterForTargets(), ApplyForTargets(), and UpdateOwner().

Friends And Related Symbol Documentation

◆ Unit::_TryStackingOrRefreshingExistingAura

Aura * Unit::_TryStackingOrRefreshingExistingAura ( SpellInfo const *  newAura,
uint8  effMask,
Unit *  caster,
int32 *  baseAmount,
Item *  castItem,
ObjectGuid  casterGUID,
bool  noPeriodicReset 
)
friend

Member Data Documentation

◆ m_applications

◆ m_applyTime

time_t const Aura::m_applyTime
protected

Referenced by GetApplyTime().

◆ m_casterGuid

ObjectGuid const Aura::m_casterGuid
protected

Referenced by GetCasterGUID().

◆ m_casterLevel

uint8 const Aura::m_casterLevel
protected

Referenced by GetCasterLevel().

◆ m_castItemEntry

uint32 const Aura::m_castItemEntry
protected

Referenced by GetCastItemEntry().

◆ m_castItemGuid

ObjectGuid const Aura::m_castItemGuid
protected

◆ m_duration

int32 Aura::m_duration
protected

◆ m_effects

◆ m_isRemoved

bool Aura::m_isRemoved
protected

Referenced by _Remove(), and IsRemoved().

◆ m_isSingleTarget

bool Aura::m_isSingleTarget
protected

◆ m_isUsingCharges

bool Aura::m_isUsingCharges
protected

◆ m_loadedScripts

◆ m_maxDuration

◆ m_owner

WorldObject* const Aura::m_owner
protected

◆ m_procCharges

uint8 Aura::m_procCharges
protected

◆ m_procCooldown

TimePoint Aura::m_procCooldown
protected

◆ m_refreshTime

Milliseconds Aura::m_refreshTime
protected

◆ m_removedApplications

Unit::AuraApplicationList Aura::m_removedApplications
private

◆ m_spellInfo

◆ m_stackAmount

uint8 Aura::m_stackAmount
protected

◆ m_timeCla

int32 Aura::m_timeCla
protected

Referenced by Aura(), RefreshDuration(), and Update().

◆ m_triggeredByAuraSpellInfo

SpellInfo const* Aura::m_triggeredByAuraSpellInfo
private

◆ m_updateTargetMapInterval

int32 Aura::m_updateTargetMapInterval
protected

Referenced by UpdateOwner(), and UpdateTargetMap().


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