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
 
UnitGetCaster () const
 
WorldObjectGetOwner () const
 
UnitGetUnitOwner () const
 
DynamicObjectGetDynobjOwner () const
 
AuraObjectType GetType () const
 
virtual void _ApplyForTarget (Unit *target, Unit *caster, AuraApplication *auraApp)
 
virtual void _UnapplyForTarget (Unit *target, Unit *caster, AuraApplication *auraApp)
 
void _Remove (AuraRemoveMode removeMode)
 
virtual void Remove (AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)=0
 
virtual void FillTargetMap (std::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
 
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 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
 
AuraEffectGetEffect (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
 
const AuraApplicationGetApplicationOfTarget (ObjectGuid guid) const
 
AuraApplicationGetApplicationOfTarget (ObjectGuid guid)
 
bool IsAppliedOnTarget (ObjectGuid guid) const
 
void SetNeedClientUpdateForTargets () const
 
void HandleAuraSpecificMods (AuraApplication const *aurApp, Unit *caster, bool apply, bool onReapply)
 
bool CanBeAppliedOn (Unit *target)
 
bool CheckAreaTarget (Unit *target)
 
bool CanStackWith (Aura const *checkAura, bool remove) const
 
bool IsAuraStronger (Aura const *newAura) const
 
bool IsProcOnCooldown () const
 
void AddProcCooldown (Milliseconds msec)
 
bool IsUsingCharges () const
 
void SetUsingCharges (bool val)
 
void PrepareProcToTrigger (AuraApplication *aurApp, ProcEventInfo &eventInfo)
 
bool IsProcTriggeredOnEvent (AuraApplication *aurApp, ProcEventInfo &eventInfo) const
 
float CalcProcChance (SpellProcEntry const &procEntry, ProcEventInfo &eventInfo) const
 
void TriggerProcOnEvent (AuraApplication *aurApp, ProcEventInfo &eventInfo)
 
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 CallScriptAfterCheckProcHandlers (AuraApplication const *aurApp, ProcEventInfo &eventInfo, bool isTriggeredAtSpellProcEvent)
 
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)
 
AuraScriptGetScriptByName (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 AuraTryRefreshStackOrCreate (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 AuraTryCreate (SpellInfo const *spellproto, uint8 effMask, WorldObject *owner, Unit *caster, int32 *baseAmount=nullptr, Item *castItem=nullptr, ObjectGuid casterGUID=ObjectGuid::Empty, ObjectGuid itemGUID=ObjectGuid::Empty)
 
static AuraCreate (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
 
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
 
AuraEffectm_effects [3]
 
ApplicationMap m_applications
 
bool m_isRemoved: 1
 
bool m_isSingleTarget: 1
 
bool m_isUsingCharges: 1
 

Private Member Functions

void _DeleteRemovedApplications ()
 

Private Attributes

Unit::AuraApplicationList m_removedApplications
 
SpellInfo const * m_triggeredByAuraSpellInfo
 

Friends

AuraUnit::_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
409 :
410 m_spellInfo(spellproto), m_casterGuid(casterGUID ? casterGUID : caster->GetGUID()),
411 m_castItemGuid(itemGUID ? itemGUID : castItem ? castItem->GetGUID() : ObjectGuid::Empty), m_castItemEntry(castItem ? castItem->GetEntry() : 0), m_applyTime(GameTime::GetGameTime().count()),
415{
418
423 memset(m_effects, 0, sizeof(m_effects));
424 // m_casterLevel = cast item level/caster level, caster level should be saved to db, confirmed with sniffs
425}
constexpr auto IN_MILLISECONDS
Definition: Common.h:53
@ SPELL_ATTR2_NO_TARGET_PER_SECOND_COST
Definition: SharedDefines.h:467
Seconds GetGameTime()
Definition: GameTime.cpp:38
uint32 GetEntry() const
Definition: Object.h:112
static ObjectGuid GetGUID(Object const *o)
Definition: Object.h:109
static ObjectGuid const Empty
Definition: ObjectGuid.h:120
uint8 GetLevel() const
Definition: Unit.h:855
int32 m_maxDuration
Definition: SpellAuras.h:256
time_t const m_applyTime
Definition: SpellAuras.h:253
AuraEffect * m_effects[3]
Definition: SpellAuras.h:265
uint8 m_stackAmount
Definition: SpellAuras.h:263
int32 m_duration
Definition: SpellAuras.h:257
uint32 const m_castItemEntry
Definition: SpellAuras.h:252
ObjectGuid const m_castItemGuid
Definition: SpellAuras.h:251
int32 m_timeCla
Definition: SpellAuras.h:258
int32 CalcMaxDuration() const
Definition: SpellAuras.h:131
SpellInfo const * m_triggeredByAuraSpellInfo
Definition: SpellAuras.h:275
SpellInfo const *const m_spellInfo
Definition: SpellAuras.h:249
WorldObject *const m_owner
Definition: SpellAuras.h:254
ObjectGuid const m_casterGuid
Definition: SpellAuras.h:250
uint8 const m_casterLevel
Definition: SpellAuras.h:261
uint8 CalcMaxCharges() const
Definition: SpellAuras.h:144
bool m_isUsingCharges
Definition: SpellAuras.h:270
bool m_isRemoved
Definition: SpellAuras.h:268
int32 m_updateTargetMapInterval
Definition: SpellAuras.h:259
bool m_isSingleTarget
Definition: SpellAuras.h:269
uint8 m_procCharges
Definition: SpellAuras.h:262
uint32 SpellLevel
Definition: SpellInfo.h:360
uint32 ManaPerSecondPerLevel
Definition: SpellInfo.h:366
uint32 ManaPerSecond
Definition: SpellInfo.h:365
bool HasAttribute(SpellAttr0 attribute) const
Definition: SpellInfo.h:415

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
448{
449 // unload scripts
450 while (!m_loadedScripts.empty())
451 {
452 std::list<AuraScript*>::iterator itr = m_loadedScripts.begin();
453 (*itr)->_Unload();
454 delete (*itr);
455 m_loadedScripts.erase(itr);
456 }
457
458 // free effects memory
459 for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
460 delete m_effects[i];
461
462 ASSERT(m_applications.empty());
464}
std::uint8_t uint8
Definition: Define.h:109
#define ASSERT
Definition: Errors.h:68
#define MAX_SPELL_EFFECTS
Definition: DBCStructure.h:1637
std::list< AuraScript * > m_loadedScripts
Definition: SpellAuras.h:238
ApplicationMap m_applications
Definition: SpellAuras.h:266
void _DeleteRemovedApplications()
Definition: SpellAuras.cpp:2347

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

Member Function Documentation

◆ _ApplyEffectForTargets()

void Aura::_ApplyEffectForTargets ( uint8  effIndex)
736{
737 // prepare list of aura targets
738 UnitList targetList;
739 for (ApplicationMap::iterator appIter = m_applications.begin(); appIter != m_applications.end(); ++appIter)
740 {
741 if ((appIter->second->GetEffectsToApply() & (1 << effIndex)) && !appIter->second->HasEffect(effIndex))
742 targetList.push_back(appIter->second->GetTarget());
743 }
744
745 // apply effect to targets
746 for (UnitList::iterator itr = targetList.begin(); itr != targetList.end(); ++itr)
747 {
748 if (GetApplicationOfTarget((*itr)->GetGUID()))
749 {
750 // owner has to be in world, or effect has to be applied to self
751 ASSERT((!GetOwner()->IsInWorld() && GetOwner() == *itr) || GetOwner()->IsInMap(*itr));
752 (*itr)->_ApplyAuraEffect(this, effIndex);
753 }
754 }
755}
std::list< Unit * > UnitList
Definition: Unit.h:76
WorldObject * GetOwner() const
Definition: SpellAuras.h:107
const AuraApplication * GetApplicationOfTarget(ObjectGuid guid) const
Definition: SpellAuras.h:183

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.

493{
494 ASSERT(target);
495 ASSERT(auraApp);
496 // aura mustn't be already applied on target
497 ASSERT (!IsAppliedOnTarget(target->GetGUID()) && "Aura::_ApplyForTarget: aura musn't be already applied on target");
498
499 m_applications[target->GetGUID()] = auraApp;
500
501 // set infinity cooldown state for spells
503 {
504 if (caster->IsPlayer())
505 {
506 caster->ToPlayer()->AddSpellAndCategoryCooldowns(m_spellInfo, 0, nullptr, true);
507 }
508 else
509 {
511 }
512 }
513}
static constexpr uint32 infinityCooldownDelay
Definition: Unit.h:46
void AddSpellCooldown(uint32 spell_id, uint32, uint32 end_time, bool needSendToClient=false, bool forceSendToSpectator=false) override
Definition: Creature.cpp:2855
bool IsPlayer() const
Definition: Object.h:197
Player * ToPlayer()
Definition: Object.h:198
Creature * ToCreature()
Definition: Object.h:202
void AddSpellAndCategoryCooldowns(SpellInfo const *spellInfo, uint32 itemId, Spell *spell=nullptr, bool infinityCooldown=false)
Definition: Player.cpp:10907
bool IsAppliedOnTarget(ObjectGuid guid) const
Definition: SpellAuras.h:185
bool IsCooldownStartedOnEvent() const
Definition: SpellInfo.cpp:1211
uint32 Id
Definition: SpellInfo.h:320

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
2348{
2349 while (!m_removedApplications.empty())
2350 {
2351 delete m_removedApplications.front();
2352 m_removedApplications.pop_front();
2353 }
2354}
Unit::AuraApplicationList m_removedApplications
Definition: SpellAuras.h:273

References m_removedApplications.

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

◆ _InitEffects()

void Aura::_InitEffects ( uint8  effMask,
Unit caster,
int32 baseAmount 
)
436{
437 // shouldn't be in constructor - functions in AuraEffect::AuraEffect use polymorphism
438 for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
439 {
440 if (effMask & (uint8(1) << i))
441 m_effects[i] = new AuraEffect(this, i, baseAmount ? baseAmount + i : nullptr, caster);
442 else
443 m_effects[i] = nullptr;
444 }
445}
Definition: SpellAuraEffects.h:39

References m_effects, and MAX_SPELL_EFFECTS.

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

◆ _RegisterForTargets()

void Aura::_RegisterForTargets ( )
inline
121{Unit* caster = GetCaster(); UpdateTargetMap(caster, false);}
Definition: Unit.h:630
Unit * GetCaster() const
Definition: SpellAuras.cpp:471
void UpdateTargetMap(Unit *caster, bool apply=true)
Definition: SpellAuras.cpp:588

References GetCaster(), and UpdateTargetMap().

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

◆ _Remove()

void Aura::_Remove ( AuraRemoveMode  removeMode)
575{
577 m_isRemoved = true;
578 ApplicationMap::iterator appItr = m_applications.begin();
579 for (appItr = m_applications.begin(); appItr != m_applications.end();)
580 {
581 AuraApplication* aurApp = appItr->second;
582 Unit* target = aurApp->GetTarget();
583 target->_UnapplyAura(aurApp, removeMode);
584 appItr = m_applications.begin();
585 }
586}
void _UnapplyAura(AuraApplicationMap::iterator &i, AuraRemoveMode removeMode)
Definition: Unit.cpp:4533
Definition: SpellAuras.h:37
Unit * GetTarget() const
Definition: SpellAuras.h:61

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.

516{
517 ASSERT(target);
518 ASSERT(auraApp->GetRemoveMode());
519 ASSERT(auraApp);
520
521 ApplicationMap::iterator itr = m_applications.find(target->GetGUID());
522
524 if (itr == m_applications.end())
525 {
526 LOG_ERROR("spells.aura", "Aura::_UnapplyForTarget, target:{}, caster:{}, spell:{} was not found in owners application map!",
527 target->GetGUID().ToString(), caster ? caster->GetGUID().ToString() : "", auraApp->GetBase()->GetSpellInfo()->Id);
528 ABORT();
529 }
530
531 // aura has to be already applied
532 ASSERT(itr->second == auraApp);
533 m_applications.erase(itr);
534
535 m_removedApplications.push_back(auraApp);
536
537 // reset cooldown state for spells
539 {
540 if (caster->IsPlayer())
541 {
542 // note: item based cooldowns and cooldown spell mods with charges ignored (unknown existed cases)
544 }
545 else
546 {
547 caster->ToCreature()->AddSpellCooldown(m_spellInfo->Id, 0, 0);
548
549 if (Unit* owner = caster->GetCharmerOrOwner())
550 {
551 if (Player* playerOwner = owner->ToPlayer())
552 {
553 WorldPacket data(SMSG_COOLDOWN_EVENT, 4 + 8);
554 data << uint32(m_spellInfo->Id);
555 data << caster->GetGUID();
556 playerOwner->SendDirectMessage(&data);
557 }
558 }
559 }
560 }
561
562 if (caster && caster->IsPlayer())
563 {
564 if (GetSpellInfo()->IsCooldownStartedOnEvent() && !m_castItemGuid)
565 {
566 // note: item based cooldowns and cooldown spell mods with charges ignored (unknown existed cases)
568 }
569 }
570}
#define LOG_ERROR(filterType__,...)
Definition: Log.h:156
std::uint32_t uint32
Definition: Define.h:107
#define ABORT
Definition: Errors.h:76
@ SMSG_COOLDOWN_EVENT
Definition: Opcodes.h:339
std::string ToString() const
Definition: ObjectGuid.cpp:47
Definition: Player.h:1064
void SendCooldownEvent(SpellInfo const *spellInfo, uint32 itemId=0, Spell *spell=nullptr, bool setCooldown=true)
Definition: Player.cpp:11105
Unit * GetCharmerOrOwner() const
Definition: Unit.h:1243
Definition: WorldPacket.h:27
Aura * GetBase() const
Definition: SpellAuras.h:62
AuraRemoveMode GetRemoveMode() const
Definition: SpellAuras.h:73
SpellInfo const * GetSpellInfo() const
Definition: SpellAuras.h:100

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, Player::SendCooldownEvent(), SMSG_COOLDOWN_EVENT, Object::ToCreature(), Object::ToPlayer(), and ObjectGuid::ToString().

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

◆ AddProcCooldown()

void Aura::AddProcCooldown ( Milliseconds  msec)
2202{
2203 //m_procCooldown = std:chrono::steady_clock::now() + msec;
2204}

Referenced by PrepareProcToTrigger().

◆ ApplyForTargets()

void Aura::ApplyForTargets ( )
inline
122{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
299{
300 ASSERT_NODEBUGINFO(spellProto);
301 ASSERT_NODEBUGINFO(owner);
302 uint8 effMask = 0;
303 switch (owner->GetTypeId())
304 {
305 case TYPEID_UNIT:
306 case TYPEID_PLAYER:
307 for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
308 {
309 if (spellProto->Effects[i].IsUnitOwnedAuraEffect())
310 effMask |= 1 << i;
311 }
312 break;
314 for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
315 {
316 if (spellProto->Effects[i].Effect == SPELL_EFFECT_PERSISTENT_AREA_AURA)
317 effMask |= 1 << i;
318 }
319 break;
320 default:
321 break;
322 }
323 return effMask & avalibleEffectMask;
324}
#define ASSERT_NODEBUGINFO
Definition: Errors.h:69
@ TYPEID_DYNAMICOBJECT
Definition: ObjectGuid.h:38
@ TYPEID_UNIT
Definition: ObjectGuid.h:35
@ TYPEID_PLAYER
Definition: ObjectGuid.h:36
@ SPELL_EFFECT_PERSISTENT_AREA_AURA
Definition: SharedDefines.h:805
TypeID GetTypeId() const
Definition: Object.h:124

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
1183{
1184 // we assume that aura dispel chance is 100% on start
1185 // need formula for level difference based chance
1186 int32 resistChance = 0;
1187
1188 // Apply dispel mod from aura caster
1189 if (Unit* caster = GetCaster())
1190 if (Player* modOwner = caster->GetSpellModOwner())
1191 modOwner->ApplySpellMod(GetId(), SPELLMOD_RESIST_DISPEL_CHANCE, resistChance);
1192
1193 // Dispel resistance from target SPELL_AURA_MOD_DISPEL_RESIST
1194 // Only affects offensive dispels
1195 if (offensive && auraTarget)
1196 resistChance += auraTarget->GetTotalAuraModifier(SPELL_AURA_MOD_DISPEL_RESIST);
1197
1198 resistChance = resistChance < 0 ? 0 : resistChance;
1199 resistChance = resistChance > 100 ? 100 : resistChance;
1200 return 100 - resistChance;
1201}
std::int32_t int32
Definition: Define.h:103
@ SPELL_AURA_MOD_DISPEL_RESIST
Definition: SpellAuraDefines.h:298
@ SPELLMOD_RESIST_DISPEL_CHANCE
Definition: SpellDefines.h:105
Player * GetSpellModOwner() const
Definition: Unit.cpp:16533
int32 GetTotalAuraModifier(AuraType auratype) const
Definition: Unit.cpp:5881
uint32 GetId() const
Definition: SpellAuras.cpp:466

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
962{
963 uint32 maxProcCharges = m_spellInfo->ProcCharges;
964 if (SpellProcEntry const* procEntry = sSpellMgr->GetSpellProcEntry(GetId()))
965 maxProcCharges = procEntry->Charges;
966
967 if (caster)
968 if (Player* modOwner = caster->GetSpellModOwner())
969 modOwner->ApplySpellMod(GetId(), SPELLMOD_CHARGES, maxProcCharges);
970 return maxProcCharges;
971}
@ SPELLMOD_CHARGES
Definition: SpellDefines.h:81
#define sSpellMgr
Definition: SpellMgr.h:825
uint32 ProcCharges
Definition: SpellInfo.h:357
Definition: SpellMgr.h:290

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
845{
846 Player* modOwner = nullptr;
847 int32 maxDuration;
848
849 if (caster)
850 {
851 modOwner = caster->GetSpellModOwner();
852 maxDuration = caster->CalcSpellDuration(m_spellInfo);
853 }
854 else
855 maxDuration = m_spellInfo->GetDuration();
856
858 maxDuration = -1;
859
860 sScriptMgr->OnCalcMaxDuration(this, maxDuration);
861
862 // IsPermanent() checks max duration (which we are supposed to calculate here)
863 if (maxDuration != -1 && modOwner)
864 modOwner->ApplySpellMod(GetId(), SPELLMOD_DURATION, maxDuration);
865 return maxDuration;
866}
#define sScriptMgr
Definition: ScriptMgr.h:708
@ SPELLMOD_DURATION
Definition: SpellDefines.h:78
void ApplySpellMod(uint32 spellId, SpellModOp op, T &basevalue, Spell *spell=nullptr, bool temporaryPet=false)
Definition: Player.cpp:9729
int32 CalcSpellDuration(SpellInfo const *spellProto)
Definition: Unit.cpp:14811
bool IsPassive() const
Definition: SpellAuras.cpp:1082
SpellDurationEntry const * DurationEntry
Definition: SpellInfo.h:361
int32 GetDuration() const
Definition: SpellInfo.cpp:2337

References Player::ApplySpellMod(), Unit::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
2312{
2313 float chance = procEntry.Chance;
2314 // calculate chances depending on unit with caster's data
2315 // so talents modifying chances and judgements will have properly calculated proc chance
2316 if (Unit* caster = GetCaster())
2317 {
2318 // calculate ppm chance if present and we're using weapon
2319 if (eventInfo.GetDamageInfo() && procEntry.ProcsPerMinute != 0)
2320 {
2321 uint32 WeaponSpeed = caster->GetAttackTime(eventInfo.GetDamageInfo()->GetAttackType());
2322 chance = caster->GetPPMProcChance(WeaponSpeed, procEntry.ProcsPerMinute, GetSpellInfo());
2323 }
2324 // apply chance modifer aura, applies also to ppm chance (see improved judgement of light spell)
2325 if (Player* modOwner = caster->GetSpellModOwner())
2326 modOwner->ApplySpellMod(GetId(), SPELLMOD_CHANCE_OF_SUCCESS, chance);
2327 }
2328 return chance;
2329}
@ SPELLMOD_CHANCE_OF_SUCCESS
Definition: SpellDefines.h:95
WeaponAttackType GetAttackType() const
Definition: Unit.h:363
DamageInfo * GetDamageInfo() const
Definition: Unit.h:449

References SpellProcEntry::Chance, DamageInfo::GetAttackType(), GetCaster(), ProcEventInfo::GetDamageInfo(), GetId(), GetSpellInfo(), Unit::GetSpellModOwner(), SpellProcEntry::ProcsPerMinute, and SPELLMOD_CHANCE_OF_SUCCESS.

Referenced by IsProcTriggeredOnEvent().

◆ CallScriptAfterCheckProcHandlers()

bool Aura::CallScriptAfterCheckProcHandlers ( AuraApplication const *  aurApp,
ProcEventInfo eventInfo,
bool  isTriggeredAtSpellProcEvent 
)
2650{
2651 bool result = isTriggeredAtSpellProcEvent;
2652 for (std::list<AuraScript*>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
2653 {
2654 (*scritr)->_PrepareScriptCall(AURA_SCRIPT_HOOK_AFTER_CHECK_PROC, aurApp);
2655 std::list<AuraScript::AfterCheckProcHandler>::iterator hookItrEnd = (*scritr)->DoAfterCheckProc.end(), hookItr = (*scritr)->DoAfterCheckProc.begin();
2656 for (; hookItr != hookItrEnd; ++hookItr)
2657 result &= hookItr->Call(*scritr, eventInfo, isTriggeredAtSpellProcEvent);
2658
2659 (*scritr)->_FinishScriptCall();
2660 }
2661
2662 return result;
2663}
@ AURA_SCRIPT_HOOK_AFTER_CHECK_PROC
Definition: SpellScript.h:502

References AURA_SCRIPT_HOOK_AFTER_CHECK_PROC, and m_loadedScripts.

Referenced by Unit::ProcDamageAndSpellFor().

◆ CallScriptAfterDispel()

void Aura::CallScriptAfterDispel ( DispelInfo dispelInfo)
2404{
2405 for (std::list<AuraScript*>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
2406 {
2407 (*scritr)->_PrepareScriptCall(AURA_SCRIPT_HOOK_AFTER_DISPEL);
2408 std::list<AuraScript::AuraDispelHandler>::iterator hookItrEnd = (*scritr)->AfterDispel.end(), hookItr = (*scritr)->AfterDispel.begin();
2409 for (; hookItr != hookItrEnd; ++hookItr)
2410 hookItr->Call(*scritr, dispelInfo);
2411
2412 (*scritr)->_FinishScriptCall();
2413 }
2414}
@ AURA_SCRIPT_HOOK_AFTER_DISPEL
Definition: SpellScript.h:499

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 
)
2456{
2457 for (std::list<AuraScript*>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
2458 {
2459 (*scritr)->_PrepareScriptCall(AURA_SCRIPT_HOOK_EFFECT_AFTER_APPLY, aurApp);
2460 std::list<AuraScript::EffectApplyHandler>::iterator effEndItr = (*scritr)->AfterEffectApply.end(), effItr = (*scritr)->AfterEffectApply.begin();
2461 for (; effItr != effEndItr; ++effItr)
2462 if (effItr->IsEffectAffected(m_spellInfo, aurEff->GetEffIndex()))
2463 effItr->Call(*scritr, aurEff, mode);
2464
2465 (*scritr)->_FinishScriptCall();
2466 }
2467}
@ AURA_SCRIPT_HOOK_EFFECT_AFTER_APPLY
Definition: SpellScript.h:484

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 
)
2734{
2735 for (std::list<AuraScript*>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
2736 {
2737 (*scritr)->_PrepareScriptCall(AURA_SCRIPT_HOOK_EFFECT_AFTER_PROC, aurApp);
2738 std::list<AuraScript::EffectProcHandler>::iterator effEndItr = (*scritr)->AfterEffectProc.end(), effItr = (*scritr)->AfterEffectProc.begin();
2739 for (; effItr != effEndItr; ++effItr)
2740 if (effItr->IsEffectAffected(m_spellInfo, aurEff->GetEffIndex()))
2741 effItr->Call(*scritr, aurEff, eventInfo);
2742
2743 (*scritr)->_FinishScriptCall();
2744 }
2745}
@ AURA_SCRIPT_HOOK_EFFECT_AFTER_PROC
Definition: SpellScript.h:506

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 
)
2470{
2471 for (std::list<AuraScript*>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
2472 {
2473 (*scritr)->_PrepareScriptCall(AURA_SCRIPT_HOOK_EFFECT_AFTER_REMOVE, aurApp);
2474 std::list<AuraScript::EffectApplyHandler>::iterator effEndItr = (*scritr)->AfterEffectRemove.end(), effItr = (*scritr)->AfterEffectRemove.begin();
2475 for (; effItr != effEndItr; ++effItr)
2476 if (effItr->IsEffectAffected(m_spellInfo, aurEff->GetEffIndex()))
2477 effItr->Call(*scritr, aurEff, mode);
2478
2479 (*scritr)->_FinishScriptCall();
2480 }
2481}
@ AURA_SCRIPT_HOOK_EFFECT_AFTER_REMOVE
Definition: SpellScript.h:486

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 
)
2702{
2703 for (std::list<AuraScript*>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
2704 {
2705 (*scritr)->_PrepareScriptCall(AURA_SCRIPT_HOOK_AFTER_PROC, aurApp);
2706 std::list<AuraScript::AuraProcHandler>::iterator hookItrEnd = (*scritr)->AfterProc.end(), hookItr = (*scritr)->AfterProc.begin();
2707 for (; hookItr != hookItrEnd; ++hookItr)
2708 hookItr->Call(*scritr, eventInfo);
2709
2710 (*scritr)->_FinishScriptCall();
2711 }
2712}
@ AURA_SCRIPT_HOOK_AFTER_PROC
Definition: SpellScript.h:507

References AURA_SCRIPT_HOOK_AFTER_PROC, and m_loadedScripts.

Referenced by TriggerProcOnEvent().

◆ CallScriptCheckAreaTargetHandlers()

bool Aura::CallScriptCheckAreaTargetHandlers ( Unit target)
2376{
2377 bool result = true;
2378 for (std::list<AuraScript*>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
2379 {
2380 (*scritr)->_PrepareScriptCall(AURA_SCRIPT_HOOK_CHECK_AREA_TARGET);
2381 std::list<AuraScript::CheckAreaTargetHandler>::iterator hookItrEnd = (*scritr)->DoCheckAreaTarget.end(), hookItr = (*scritr)->DoCheckAreaTarget.begin();
2382 for (; hookItr != hookItrEnd; ++hookItr)
2383 result &= hookItr->Call(*scritr, target);
2384
2385 (*scritr)->_FinishScriptCall();
2386 }
2387 return result;
2388}
@ AURA_SCRIPT_HOOK_CHECK_AREA_TARGET
Definition: SpellScript.h:497

References AURA_SCRIPT_HOOK_CHECK_AREA_TARGET, and m_loadedScripts.

Referenced by CheckAreaTarget().

◆ CallScriptCheckProcHandlers()

bool Aura::CallScriptCheckProcHandlers ( AuraApplication const *  aurApp,
ProcEventInfo eventInfo 
)
2634{
2635 bool result = true;
2636 for (std::list<AuraScript*>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
2637 {
2638 (*scritr)->_PrepareScriptCall(AURA_SCRIPT_HOOK_CHECK_PROC, aurApp);
2639 std::list<AuraScript::CheckProcHandler>::iterator hookItrEnd = (*scritr)->DoCheckProc.end(), hookItr = (*scritr)->DoCheckProc.begin();
2640 for (; hookItr != hookItrEnd; ++hookItr)
2641 result &= hookItr->Call(*scritr, eventInfo);
2642
2643 (*scritr)->_FinishScriptCall();
2644 }
2645
2646 return result;
2647}
@ AURA_SCRIPT_HOOK_CHECK_PROC
Definition: SpellScript.h:501

References AURA_SCRIPT_HOOK_CHECK_PROC, and m_loadedScripts.

Referenced by IsProcTriggeredOnEvent(), and Unit::ProcDamageAndSpellFor().

◆ CallScriptDispel()

void Aura::CallScriptDispel ( DispelInfo dispelInfo)
2391{
2392 for (std::list<AuraScript*>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
2393 {
2394 (*scritr)->_PrepareScriptCall(AURA_SCRIPT_HOOK_DISPEL);
2395 std::list<AuraScript::AuraDispelHandler>::iterator hookItrEnd = (*scritr)->OnDispel.end(), hookItr = (*scritr)->OnDispel.begin();
2396 for (; hookItr != hookItrEnd; ++hookItr)
2397 hookItr->Call(*scritr, dispelInfo);
2398
2399 (*scritr)->_FinishScriptCall();
2400 }
2401}
@ AURA_SCRIPT_HOOK_DISPEL
Definition: SpellScript.h:498

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 
)
2560{
2561 for (std::list<AuraScript*>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
2562 {
2563 (*scritr)->_PrepareScriptCall(AURA_SCRIPT_HOOK_EFFECT_ABSORB, aurApp);
2564 std::list<AuraScript::EffectAbsorbHandler>::iterator effEndItr = (*scritr)->OnEffectAbsorb.end(), effItr = (*scritr)->OnEffectAbsorb.begin();
2565 for (; effItr != effEndItr; ++effItr)
2566
2567 if (effItr->IsEffectAffected(m_spellInfo, aurEff->GetEffIndex()))
2568 effItr->Call(*scritr, aurEff, dmgInfo, absorbAmount);
2569
2570 if (!defaultPrevented)
2571 defaultPrevented = (*scritr)->_IsDefaultActionPrevented();
2572
2573 (*scritr)->_FinishScriptCall();
2574 }
2575}
@ AURA_SCRIPT_HOOK_EFFECT_ABSORB
Definition: SpellScript.h:492
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 
)
2578{
2579 for (std::list<AuraScript*>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
2580 {
2581 (*scritr)->_PrepareScriptCall(AURA_SCRIPT_HOOK_EFFECT_AFTER_ABSORB, aurApp);
2582 std::list<AuraScript::EffectAbsorbHandler>::iterator effEndItr = (*scritr)->AfterEffectAbsorb.end(), effItr = (*scritr)->AfterEffectAbsorb.begin();
2583 for (; effItr != effEndItr; ++effItr)
2584 if (effItr->IsEffectAffected(m_spellInfo, aurEff->GetEffIndex()))
2585 effItr->Call(*scritr, aurEff, dmgInfo, absorbAmount);
2586
2587 (*scritr)->_FinishScriptCall();
2588 }
2589}
@ AURA_SCRIPT_HOOK_EFFECT_AFTER_ABSORB
Definition: SpellScript.h:493

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 
)
2606{
2607 for (std::list<AuraScript*>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
2608 {
2609 (*scritr)->_PrepareScriptCall(AURA_SCRIPT_HOOK_EFFECT_AFTER_MANASHIELD, aurApp);
2610 std::list<AuraScript::EffectManaShieldHandler>::iterator effEndItr = (*scritr)->AfterEffectManaShield.end(), effItr = (*scritr)->AfterEffectManaShield.begin();
2611 for (; effItr != effEndItr; ++effItr)
2612 if (effItr->IsEffectAffected(m_spellInfo, aurEff->GetEffIndex()))
2613 effItr->Call(*scritr, aurEff, dmgInfo, absorbAmount);
2614
2615 (*scritr)->_FinishScriptCall();
2616 }
2617}
@ AURA_SCRIPT_HOOK_EFFECT_AFTER_MANASHIELD
Definition: SpellScript.h:495

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 
)
2417{
2418 bool preventDefault = false;
2419 for (std::list<AuraScript*>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
2420 {
2421 (*scritr)->_PrepareScriptCall(AURA_SCRIPT_HOOK_EFFECT_APPLY, aurApp);
2422 std::list<AuraScript::EffectApplyHandler>::iterator effEndItr = (*scritr)->OnEffectApply.end(), effItr = (*scritr)->OnEffectApply.begin();
2423 for (; effItr != effEndItr; ++effItr)
2424 if (effItr->IsEffectAffected(m_spellInfo, aurEff->GetEffIndex()))
2425 effItr->Call(*scritr, aurEff, mode);
2426
2427 if (!preventDefault)
2428 preventDefault = (*scritr)->_IsDefaultActionPrevented();
2429
2430 (*scritr)->_FinishScriptCall();
2431 }
2432
2433 return preventDefault;
2434}
@ AURA_SCRIPT_HOOK_EFFECT_APPLY
Definition: SpellScript.h:483

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 
)
2518{
2519 for (std::list<AuraScript*>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
2520 {
2521 (*scritr)->_PrepareScriptCall(AURA_SCRIPT_HOOK_EFFECT_CALC_AMOUNT);
2522 std::list<AuraScript::EffectCalcAmountHandler>::iterator effEndItr = (*scritr)->DoEffectCalcAmount.end(), effItr = (*scritr)->DoEffectCalcAmount.begin();
2523 for (; effItr != effEndItr; ++effItr)
2524 if (effItr->IsEffectAffected(m_spellInfo, aurEff->GetEffIndex()))
2525 effItr->Call(*scritr, aurEff, amount, canBeRecalculated);
2526
2527 (*scritr)->_FinishScriptCall();
2528 }
2529}
@ AURA_SCRIPT_HOOK_EFFECT_CALC_AMOUNT
Definition: SpellScript.h:489

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 
)
2532{
2533 for (std::list<AuraScript*>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
2534 {
2535 (*scritr)->_PrepareScriptCall(AURA_SCRIPT_HOOK_EFFECT_CALC_PERIODIC);
2536 std::list<AuraScript::EffectCalcPeriodicHandler>::iterator effEndItr = (*scritr)->DoEffectCalcPeriodic.end(), effItr = (*scritr)->DoEffectCalcPeriodic.begin();
2537 for (; effItr != effEndItr; ++effItr)
2538 if (effItr->IsEffectAffected(m_spellInfo, aurEff->GetEffIndex()))
2539 effItr->Call(*scritr, aurEff, isPeriodic, amplitude);
2540
2541 (*scritr)->_FinishScriptCall();
2542 }
2543}
@ AURA_SCRIPT_HOOK_EFFECT_CALC_PERIODIC
Definition: SpellScript.h:490

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 
)
2546{
2547 for (std::list<AuraScript*>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
2548 {
2549 (*scritr)->_PrepareScriptCall(AURA_SCRIPT_HOOK_EFFECT_CALC_SPELLMOD);
2550 std::list<AuraScript::EffectCalcSpellModHandler>::iterator effEndItr = (*scritr)->DoEffectCalcSpellMod.end(), effItr = (*scritr)->DoEffectCalcSpellMod.begin();
2551 for (; effItr != effEndItr; ++effItr)
2552 if (effItr->IsEffectAffected(m_spellInfo, aurEff->GetEffIndex()))
2553 effItr->Call(*scritr, aurEff, spellMod);
2554
2555 (*scritr)->_FinishScriptCall();
2556 }
2557}
@ AURA_SCRIPT_HOOK_EFFECT_CALC_SPELLMOD
Definition: SpellScript.h:491

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 
)
2592{
2593 for (std::list<AuraScript*>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
2594 {
2595 (*scritr)->_PrepareScriptCall(AURA_SCRIPT_HOOK_EFFECT_MANASHIELD, aurApp);
2596 std::list<AuraScript::EffectManaShieldHandler>::iterator effEndItr = (*scritr)->OnEffectManaShield.end(), effItr = (*scritr)->OnEffectManaShield.begin();
2597 for (; effItr != effEndItr; ++effItr)
2598 if (effItr->IsEffectAffected(m_spellInfo, aurEff->GetEffIndex()))
2599 effItr->Call(*scritr, aurEff, dmgInfo, absorbAmount);
2600
2601 (*scritr)->_FinishScriptCall();
2602 }
2603}
@ AURA_SCRIPT_HOOK_EFFECT_MANASHIELD
Definition: SpellScript.h:494

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 
)
2484{
2485 bool preventDefault = false;
2486 for (std::list<AuraScript*>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
2487 {
2488 (*scritr)->_PrepareScriptCall(AURA_SCRIPT_HOOK_EFFECT_PERIODIC, aurApp);
2489 std::list<AuraScript::EffectPeriodicHandler>::iterator effEndItr = (*scritr)->OnEffectPeriodic.end(), effItr = (*scritr)->OnEffectPeriodic.begin();
2490 for (; effItr != effEndItr; ++effItr)
2491 if (effItr->IsEffectAffected(m_spellInfo, aurEff->GetEffIndex()))
2492 effItr->Call(*scritr, aurEff);
2493
2494 if (!preventDefault)
2495 preventDefault = (*scritr)->_IsDefaultActionPrevented();
2496
2497 (*scritr)->_FinishScriptCall();
2498 }
2499
2500 return preventDefault;
2501}
@ AURA_SCRIPT_HOOK_EFFECT_PERIODIC
Definition: SpellScript.h:487

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 
)
2715{
2716 bool preventDefault = false;
2717 for (std::list<AuraScript*>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
2718 {
2719 (*scritr)->_PrepareScriptCall(AURA_SCRIPT_HOOK_EFFECT_PROC, aurApp);
2720 std::list<AuraScript::EffectProcHandler>::iterator effEndItr = (*scritr)->OnEffectProc.end(), effItr = (*scritr)->OnEffectProc.begin();
2721 for (; effItr != effEndItr; ++effItr)
2722 if (effItr->IsEffectAffected(m_spellInfo, aurEff->GetEffIndex()))
2723 effItr->Call(*scritr, aurEff, eventInfo);
2724
2725 if (!preventDefault)
2726 preventDefault = (*scritr)->_IsDefaultActionPrevented();
2727
2728 (*scritr)->_FinishScriptCall();
2729 }
2730 return preventDefault;
2731}
@ AURA_SCRIPT_HOOK_EFFECT_PROC
Definition: SpellScript.h:505

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 
)
2437{
2438 bool preventDefault = false;
2439 for (std::list<AuraScript*>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
2440 {
2441 (*scritr)->_PrepareScriptCall(AURA_SCRIPT_HOOK_EFFECT_REMOVE, aurApp);
2442 std::list<AuraScript::EffectApplyHandler>::iterator effEndItr = (*scritr)->OnEffectRemove.end(), effItr = (*scritr)->OnEffectRemove.begin();
2443 for (; effItr != effEndItr; ++effItr)
2444 if (effItr->IsEffectAffected(m_spellInfo, aurEff->GetEffIndex()))
2445 effItr->Call(*scritr, aurEff, mode);
2446
2447 if (!preventDefault)
2448 preventDefault = (*scritr)->_IsDefaultActionPrevented();
2449
2450 (*scritr)->_FinishScriptCall();
2451 }
2452 return preventDefault;
2453}
@ AURA_SCRIPT_HOOK_EFFECT_REMOVE
Definition: SpellScript.h:485

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 
)
2620{
2621 for (std::list<AuraScript*>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
2622 {
2623 (*scritr)->_PrepareScriptCall(AURA_SCRIPT_HOOK_EFFECT_SPLIT, aurApp);
2624 std::list<AuraScript::EffectSplitHandler>::iterator effEndItr = (*scritr)->OnEffectSplit.end(), effItr = (*scritr)->OnEffectSplit.begin();
2625 for (; effItr != effEndItr; ++effItr)
2626 if (effItr->IsEffectAffected(m_spellInfo, aurEff->GetEffIndex()))
2627 effItr->Call(*scritr, aurEff, dmgInfo, splitAmount);
2628
2629 (*scritr)->_FinishScriptCall();
2630 }
2631}
@ AURA_SCRIPT_HOOK_EFFECT_SPLIT
Definition: SpellScript.h:496

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

◆ CallScriptEffectUpdatePeriodicHandlers()

void Aura::CallScriptEffectUpdatePeriodicHandlers ( AuraEffect aurEff)
2504{
2505 for (std::list<AuraScript*>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
2506 {
2507 (*scritr)->_PrepareScriptCall(AURA_SCRIPT_HOOK_EFFECT_UPDATE_PERIODIC);
2508 std::list<AuraScript::EffectUpdatePeriodicHandler>::iterator effEndItr = (*scritr)->OnEffectUpdatePeriodic.end(), effItr = (*scritr)->OnEffectUpdatePeriodic.begin();
2509 for (; effItr != effEndItr; ++effItr)
2510 if (effItr->IsEffectAffected(m_spellInfo, aurEff->GetEffIndex()))
2511 effItr->Call(*scritr, aurEff);
2512
2513 (*scritr)->_FinishScriptCall();
2514 }
2515}
@ AURA_SCRIPT_HOOK_EFFECT_UPDATE_PERIODIC
Definition: SpellScript.h:488

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 
)
2666{
2667 bool prepare = true;
2668 for (std::list<AuraScript*>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
2669 {
2670 (*scritr)->_PrepareScriptCall(AURA_SCRIPT_HOOK_PREPARE_PROC, aurApp);
2671 std::list<AuraScript::AuraProcHandler>::iterator effEndItr = (*scritr)->DoPrepareProc.end(), effItr = (*scritr)->DoPrepareProc.begin();
2672 for (; effItr != effEndItr; ++effItr)
2673 effItr->Call(*scritr, eventInfo);
2674
2675 if (prepare)
2676 prepare = !(*scritr)->_IsDefaultActionPrevented();
2677
2678 (*scritr)->_FinishScriptCall();
2679 }
2680
2681 return prepare;
2682}
@ AURA_SCRIPT_HOOK_PREPARE_PROC
Definition: SpellScript.h:503

References AURA_SCRIPT_HOOK_PREPARE_PROC, and m_loadedScripts.

Referenced by PrepareProcToTrigger().

◆ CallScriptProcHandlers()

bool Aura::CallScriptProcHandlers ( AuraApplication const *  aurApp,
ProcEventInfo eventInfo 
)
2685{
2686 bool handled = false;
2687 for (std::list<AuraScript*>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
2688 {
2689 (*scritr)->_PrepareScriptCall(AURA_SCRIPT_HOOK_PROC, aurApp);
2690 std::list<AuraScript::AuraProcHandler>::iterator hookItrEnd = (*scritr)->OnProc.end(), hookItr = (*scritr)->OnProc.begin();
2691 for (; hookItr != hookItrEnd; ++hookItr)
2692 hookItr->Call(*scritr, eventInfo);
2693
2694 handled |= (*scritr)->_IsDefaultActionPrevented();
2695 (*scritr)->_FinishScriptCall();
2696 }
2697
2698 return handled;
2699}
@ AURA_SCRIPT_HOOK_PROC
Definition: SpellScript.h:504

References AURA_SCRIPT_HOOK_PROC, and m_loadedScripts.

Referenced by TriggerProcOnEvent().

◆ CanBeAppliedOn()

bool Aura::CanBeAppliedOn ( Unit target)
1971{
1972 // unit not in world or during remove from world
1973 if (!target->IsInWorld() || target->IsDuringRemoveFromWorld())
1974 {
1975 // area auras mustn't be applied
1976 if (GetOwner() != target)
1977 return false;
1978 // not selfcasted single target auras mustn't be applied
1979 if (GetCasterGUID() != GetOwner()->GetGUID() && GetSpellInfo()->IsSingleTarget())
1980 return false;
1981 return true;
1982 }
1983 else
1984 return CheckAreaTarget(target);
1985}
bool IsInWorld() const
Definition: Object.h:104
bool IsDuringRemoveFromWorld() const
Definition: Unit.h:1712
bool CheckAreaTarget(Unit *target)
Definition: SpellAuras.cpp:1987
ObjectGuid GetCasterGUID() const
Definition: SpellAuras.h:105
bool IsSingleTarget() const
Definition: SpellAuras.h:164

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

Referenced by UpdateTargetMap().

◆ CanBeSaved()

bool Aura::CanBeSaved ( ) const
1098{
1099 SpellInfo const* spellInfo = GetSpellInfo();
1100
1102 {
1103 return true;
1104 }
1105
1107 {
1108 return false;
1109 }
1110
1111 if (IsPassive() || (spellInfo->HasAttribute(SPELL_ATTR0_DO_NOT_DISPLAY) && spellInfo->Stances))
1112 {
1113 return false;
1114 }
1115
1116 // Xinef: do not save channel auras
1117 if (GetSpellInfo()->IsChanneled())
1118 {
1119 return false;
1120 }
1121
1122 // Xinef: Check if aura is single target, not only spell info
1123 if (GetCasterGUID() != GetOwner()->GetGUID() && (GetSpellInfo()->IsSingleTarget() || IsSingleTarget()))
1124 {
1125 return false;
1126 }
1127
1128 // don't save auras removed by proc system
1129 if (IsUsingCharges() && !GetCharges())
1130 {
1131 return false;
1132 }
1133
1134 return true;
1135}
@ SPELL_ATTR0_CU_FORCE_AURA_SAVING
Definition: SpellInfo.h:205
@ SPELL_ATTR0_CU_AURA_CANNOT_BE_SAVED
Definition: SpellInfo.h:200
@ SPELL_ATTR0_DO_NOT_DISPLAY
Definition: SharedDefines.h:389
bool IsUsingCharges() const
Definition: SpellAuras.h:200
uint8 GetCharges() const
Definition: SpellAuras.h:141
Definition: SpellInfo.h:316
uint32 Stances
Definition: SpellInfo.h:333

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
1138{
1140}
@ SPELL_AURA_ABILITY_IGNORE_AURASTATE
Definition: SpellAuraDefines.h:325
bool HasEffectType(AuraType type) const
Definition: SpellAuras.cpp:1222
bool HasAreaAuraEffect() const
Definition: SpellInfo.cpp:908

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

Referenced by Spell::EffectSummonPet().

◆ CanStackWith()

bool Aura::CanStackWith ( Aura const *  checkAura,
bool  remove 
) const
2022{
2023 // Can stack with self
2024 if (this == existingAura)
2025 return true;
2026
2027 SpellInfo const* existingSpellInfo = existingAura->GetSpellInfo();
2028 bool sameCaster = GetCasterGUID() == existingAura->GetCasterGUID();
2029
2030 // Dynobj auras always stack
2031 // xinef: dont allow different ranks (or the same rank) of same spell to stack (many flamestrikes for example)
2032 if (existingAura->GetType() == DYNOBJ_AURA_TYPE)
2033 {
2034 // xinef: desecration lag fix - bound this condition to periodics
2035 if (sameCaster && GetSpellInfo()->Id == existingSpellInfo->Id && GetSpellInfo()->HasAura(SPELL_AURA_PERIODIC_DAMAGE))
2036 return false;
2037 return true;
2038 }
2039
2040 // passive auras don't stack with another rank of the spell cast by same caster
2041 if (IsPassive() && sameCaster && (m_spellInfo->IsDifferentRankOf(existingSpellInfo) || (m_spellInfo->Id == existingSpellInfo->Id && m_castItemGuid.IsEmpty())))
2042 return false;
2043
2044 for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
2045 {
2046 // prevent remove triggering aura by triggered aura
2047 if (existingSpellInfo->Effects[i].TriggerSpell == GetId()
2048 // prevent remove triggered aura by triggering aura refresh
2049 || m_spellInfo->Effects[i].TriggerSpell == existingAura->GetId())
2050 return true;
2051 }
2052
2053 // check spell specific stack rules
2054 if (m_spellInfo->IsAuraExclusiveBySpecificWith(existingSpellInfo)
2055 || (sameCaster && m_spellInfo->IsAuraExclusiveBySpecificPerCasterWith(existingSpellInfo)))
2056 return false;
2057
2058 // check spell group stack rules
2059 // xinef: this assures us that both spells are in same group!
2060 SpellGroupStackFlags stackFlags = sSpellMgr->CheckSpellGroupStackRules(m_spellInfo, existingSpellInfo, remove, IsArea());
2061 if (stackFlags)
2062 {
2063 // xinef: same caster rule is bounded by spellfamily
2064 if (sameCaster && m_spellInfo->SpellFamilyName == existingSpellInfo->SpellFamilyName &&
2066 return false;
2067
2068 // xinef: normal exclusive stacking, remove if auras are equal by effects
2069 if (stackFlags & SPELL_GROUP_STACK_FLAG_EXCLUSIVE)
2070 {
2071 if (GetSpellInfo()->IsAuraEffectEqual(existingSpellInfo) || GetSpellInfo()->IsRankOf(existingSpellInfo))
2072 {
2073 if (remove)
2074 return IsAuraStronger(existingAura);
2075 else
2076 return existingAura->IsAuraStronger(this);
2077 }
2078 }
2079
2080 // xinef: check priority before effect mask
2081 SpellGroupSpecialFlags thisAuraFlag = sSpellMgr->GetSpellGroupSpecialFlags(GetId());
2082 SpellGroupSpecialFlags existingAuraFlag = sSpellMgr->GetSpellGroupSpecialFlags(existingSpellInfo->Id);
2083 if (thisAuraFlag >= SPELL_GROUP_SPECIAL_FLAG_PRIORITY1 && thisAuraFlag <= SPELL_GROUP_SPECIAL_FLAG_PRIORITY4 &&
2084 existingAuraFlag >= SPELL_GROUP_SPECIAL_FLAG_PRIORITY1 && existingAuraFlag <= SPELL_GROUP_SPECIAL_FLAG_PRIORITY4)
2085 {
2086 if (thisAuraFlag < existingAuraFlag)
2087 {
2088 return false;
2089 }
2090 }
2091
2092 // xinef: forced strongest aura in group by flag
2094 return !remove;
2096 return remove;
2097
2098 // xinef: forced return, handle all cases using available flags!
2099 return !(stackFlags & SPELL_GROUP_STACK_FLAG_NEVER_STACK);
2100 }
2101
2102 if (m_spellInfo->SpellFamilyName != existingSpellInfo->SpellFamilyName)
2103 return true;
2104
2105 if (!sameCaster)
2106 {
2107 // Channeled auras can stack if not forbidden by db or aura type
2108 if (existingAura->GetSpellInfo()->IsChanneled())
2109 return true;
2110
2112 return true;
2113
2114 // check same periodic auras
2115 for (uint32 i = 0; i < MAX_SPELL_EFFECTS; ++i)
2116 {
2117 switch (m_spellInfo->Effects[i].ApplyAuraName)
2118 {
2119 // DOT or HOT from different casters will stack
2131 // periodic auras which target areas are not allowed to stack this way (replenishment for example)
2132 if (m_spellInfo->Effects[i].IsTargetingArea() || existingSpellInfo->Effects[i].IsTargetingArea())
2133 break;
2134 return true;
2135 default:
2136 break;
2137 }
2138 }
2139 }
2140
2141 uint8 VehicleAura1 = 0;
2142 uint8 VehicleAura2 = 0;
2143 uint8 i = 0;
2144 while (i < MAX_SPELL_EFFECTS && !(VehicleAura1 && VehicleAura2))
2145 {
2146 if (m_spellInfo->Effects[i].ApplyAuraName == SPELL_AURA_CONTROL_VEHICLE)
2147 VehicleAura1 = i + 1;
2148 if (existingSpellInfo->Effects[i].ApplyAuraName == SPELL_AURA_CONTROL_VEHICLE)
2149 VehicleAura2 = i + 1;
2150
2151 ++i;
2152 }
2153
2154 if (VehicleAura1 && VehicleAura2)
2155 {
2156 Vehicle* veh = nullptr;
2157 if (GetOwner()->ToUnit())
2158 veh = GetOwner()->ToUnit()->GetVehicleKit();
2159
2160 if (!veh) // We should probably just let it stack. Vehicle system will prevent undefined behaviour later
2161 return true;
2162
2163 // xinef: allow direct auras to stack if there is no passenger in this slot
2164 if (AuraEffect* aurEff = GetEffect(VehicleAura1 - 1))
2165 if (aurEff->GetAmount() > 0)
2166 if (!veh->GetPassenger(aurEff->GetAmount() - 1))
2167 return true;
2168
2169 if (!veh->GetAvailableSeatCount())
2170 return false; // No empty seat available
2171
2172 return true; // Empty seat available (skip rest)
2173 }
2174
2175 // spell of same spell rank chain
2176 if (m_spellInfo->IsRankOf(existingSpellInfo) && !(m_spellInfo->SpellFamilyName == SPELLFAMILY_HUNTER && m_spellInfo->SpellFamilyFlags[1] & 0x80000000))
2177 {
2178 // don't allow passive area auras to stack
2179 if (m_spellInfo->IsMultiSlotAura() && !IsArea())
2180 return true;
2181 if (GetCastItemGUID() && existingAura->GetCastItemGUID())
2182 if (GetCastItemGUID() != existingAura->GetCastItemGUID() && m_spellInfo->HasAttribute(SPELL_ATTR0_CU_ENCHANT_PROC))
2183 return true;
2184 // same spell with same caster should not stack
2185 return false;
2186 }
2187
2188 return true;
2189}
@ 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
SpellGroupStackFlags
Definition: SpellMgr.h:356
@ SPELL_GROUP_STACK_FLAG_EXCLUSIVE
Definition: SpellMgr.h:358
@ SPELL_GROUP_STACK_FLAG_FORCED_WEAKEST
Definition: SpellMgr.h:367
@ SPELL_GROUP_STACK_FLAG_FORCED_STRONGEST
Definition: SpellMgr.h:366
@ SPELL_GROUP_STACK_FLAG_NOT_SAME_CASTER
Definition: SpellMgr.h:359
@ SPELL_GROUP_STACK_FLAG_NEVER_STACK
Definition: SpellMgr.h:361
SpellGroupSpecialFlags
Definition: SpellMgr.h:334
@ SPELL_GROUP_SPECIAL_FLAG_PRIORITY1
Definition: SpellMgr.h:344
@ SPELL_GROUP_SPECIAL_FLAG_PRIORITY4
Definition: SpellMgr.h:347
@ SPELL_ATTR0_CU_ENCHANT_PROC
Definition: SpellInfo.h:176
@ SPELL_ATTR3_DOT_STACKING_RULE
Definition: SharedDefines.h:500
@ SPELLFAMILY_HUNTER
Definition: SharedDefines.h:3537
Unit * ToUnit()
Definition: Object.h:206
bool IsEmpty() const
Definition: ObjectGuid.h:161
Vehicle * GetVehicleKit() const
Definition: Unit.h:1672
Definition: Vehicle.h:28
uint8 GetAvailableSeatCount() const
Definition: Vehicle.cpp:600
Unit * GetPassenger(int8 seatId) const
Definition: Vehicle.cpp:224
bool IsArea() const
Definition: SpellAuras.cpp:1072
AuraEffect * GetEffect(uint8 effIndex) const
Definition: SpellAuras.h:175
ObjectGuid GetCastItemGUID() const
Definition: SpellAuras.h:103
bool IsAuraStronger(Aura const *newAura) const
Definition: SpellAuras.cpp:1992
bool IsRankOf(SpellInfo const *spellInfo) const
Definition: SpellInfo.cpp:2568
flag96 SpellFamilyFlags
Definition: SpellInfo.h:388
bool IsAuraExclusiveBySpecificPerCasterWith(SpellInfo const *spellInfo) const
Definition: SpellInfo.cpp:1414
bool IsAuraExclusiveBySpecificWith(SpellInfo const *spellInfo) const
Definition: SpellInfo.cpp:1382
bool IsMultiSlotAura() const
Definition: SpellInfo.cpp:1206
std::array< SpellEffectInfo, MAX_SPELL_EFFECTS > Effects
Definition: SpellInfo.h:393
bool IsDifferentRankOf(SpellInfo const *spellInfo) const
Definition: SpellInfo.cpp:2573
uint32 SpellFamilyName
Definition: SpellInfo.h:387

References DYNOBJ_AURA_TYPE, SpellInfo::Effects, Vehicle::GetAvailableSeatCount(), GetCasterGUID(), GetCastItemGUID(), GetEffect(), GetId(), GetOwner(), Vehicle::GetPassenger(), GetSpellInfo(), GetType(), Unit::GetVehicleKit(), SpellInfo::HasAttribute(), SpellInfo::Id, IsArea(), SpellInfo::IsAuraExclusiveBySpecificPerCasterWith(), SpellInfo::IsAuraExclusiveBySpecificWith(), IsAuraStronger(), 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_SPECIAL_FLAG_PRIORITY1, SPELL_GROUP_SPECIAL_FLAG_PRIORITY4, SPELL_GROUP_STACK_FLAG_EXCLUSIVE, SPELL_GROUP_STACK_FLAG_FORCED_STRONGEST, SPELL_GROUP_STACK_FLAG_FORCED_WEAKEST, SPELL_GROUP_STACK_FLAG_NEVER_STACK, SPELL_GROUP_STACK_FLAG_NOT_SAME_CASTER, SPELLFAMILY_HUNTER, SpellInfo::SpellFamilyFlags, SpellInfo::SpellFamilyName, sSpellMgr, and Object::ToUnit().

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

◆ CheckAreaTarget()

bool Aura::CheckAreaTarget ( Unit target)
1988{
1989 return CallScriptCheckAreaTargetHandlers(target);
1990}
bool CallScriptCheckAreaTargetHandlers(Unit *target)
Definition: SpellAuras.cpp:2375

References CallScriptCheckAreaTargetHandlers().

Referenced by CanBeAppliedOn().

◆ Create()

Aura * Aura::Create ( SpellInfo const *  spellproto,
uint8  effMask,
WorldObject owner,
Unit caster,
int32 baseAmount,
Item castItem,
ObjectGuid  casterGUID,
ObjectGuid  itemGUID = ObjectGuid::Empty 
)
static
365{
366 ASSERT_NODEBUGINFO(effMask);
367 ASSERT_NODEBUGINFO(spellproto);
368 ASSERT_NODEBUGINFO(owner);
369 ASSERT_NODEBUGINFO(caster || casterGUID);
371 // try to get caster of aura
372 if (casterGUID)
373 {
374 if (owner->GetGUID() == casterGUID)
375 caster = owner->ToUnit();
376 else
377 caster = ObjectAccessor::GetUnit(*owner, casterGUID);
378 }
379 else
380 casterGUID = caster->GetGUID();
381
382 // check if aura can be owned by owner
383 if (owner->IsUnit())
384 if (!owner->IsInWorld() || ((Unit*)owner)->IsDuringRemoveFromWorld())
385 // owner not in world so don't allow to own not self casted single target auras
386 if (casterGUID != owner->GetGUID() && spellproto->IsSingleTarget())
387 return nullptr;
388
389 Aura* aura = nullptr;
390 switch (owner->GetTypeId())
391 {
392 case TYPEID_UNIT:
393 case TYPEID_PLAYER:
394 aura = new UnitAura(spellproto, effMask, owner, caster, baseAmount, castItem, casterGUID, itemGUID);
395 break;
397 aura = new DynObjAura(spellproto, effMask, owner, caster, baseAmount, castItem, casterGUID, itemGUID);
398 break;
399 default:
400 ABORT();
401 return nullptr;
402 }
403 // aura can be removed in Unit::_AddAura call
404 if (aura->IsRemoved())
405 return nullptr;
406 return aura;
407}
#define MAX_EFFECT_MASK
Definition: DBCStructure.h:1638
Unit * GetUnit(WorldObject const &, ObjectGuid const guid)
Definition: ObjectAccessor.cpp:202
bool IsUnit() const
Definition: Object.h:205
Definition: SpellAuras.h:87
bool IsRemoved() const
Definition: SpellAuras.h:161
Definition: SpellAuras.h:279
Definition: SpellAuras.h:302

References ABORT, ASSERT_NODEBUGINFO, Object::GetGUID(), Object::GetTypeId(), ObjectAccessor::GetUnit(), 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
146{ return ModCharges(-1, removeMode); }
bool ModCharges(int32 num, AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
Definition: SpellAuras.cpp:973

References ModCharges().

Referenced by AuraScript::DropCharge(), 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
1250{
1251 for (Aura::ApplicationMap::const_iterator appIter = m_applications.begin(); appIter != m_applications.end(); ++appIter)
1252 {
1253 if (appIter->second->GetEffectMask())
1254 applicationList.push_back(appIter->second);
1255 }
1256}

References m_applications.

Referenced by SetStackAmount().

◆ GetApplicationMap()

ApplicationMap const & Aura::GetApplicationMap ( )
inline

◆ GetApplicationOfTarget() [1/2]

AuraApplication * Aura::GetApplicationOfTarget ( ObjectGuid  guid)
inline
184{ 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
154{ return m_casterLevel; }

References m_casterLevel.

Referenced by AuraApplication::BuildUpdatePacket().

◆ GetCastItemEntry()

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

References m_castItemEntry.

◆ GetCastItemGUID()

◆ GetCharges()

◆ GetDebugInfo()

std::string Aura::GetDebugInfo ( ) const
virtual
2753{
2754 std::stringstream sstr;
2755 sstr << std::boolalpha
2756 << "Id: " << GetId() << " Caster: " << GetCasterGUID().ToString()
2757 << "\nOwner: " << (GetOwner() ? GetOwner()->GetDebugInfo() : "NULL");
2758 return sstr.str();
2759}
std::string GetDebugInfo() const override
Definition: Object.cpp:2484

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

◆ GetDuration()

◆ GetDynobjOwner()

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

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

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

◆ GetEffect()

◆ GetEffectMask()

uint8 Aura::GetEffectMask ( ) const
inline

◆ GetId()

◆ GetMaxDuration()

◆ GetOwner()

◆ GetScriptByName()

AuraScript * Aura::GetScriptByName ( std::string const &  scriptName) const
428{
429 for (std::list<AuraScript*>::const_iterator itr = m_loadedScripts.begin(); itr != m_loadedScripts.end(); ++itr)
430 if ((*itr)->_GetScriptName()->compare(scriptName) == 0)
431 return *itr;
432 return nullptr;
433}

References m_loadedScripts.

◆ GetSpellInfo()

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

References m_spellInfo.

Referenced by Unit::_AddAura(), Unit::_ApplyAura(), Unit::_CreateAuraApplication(), AuraApplication::_InitFlags(), Pet::_SaveAuras(), Unit::_UnapplyAura(), _UnapplyForTarget(), Player::ApplySpellMod(), AuraEffect::ApplySpellMod(), AuraApplication::BuildUpdatePacket(), CalcProcChance(), CanBeAppliedOn(), CanBeSaved(), CanBeSentToClient(), CanStackWith(), Player::CheckAreaExploreAndOutdoor(), Spell::CheckCasterAuras(), Spell::DoSpellHitOnUnit(), Spell::EffectDispelMechanic(), Spell::EffectStealBeneficialBuff(), UnitAura::FillTargetMap(), DynObjAura::FillTargetMap(), Unit::GetDispellableAuraList(), GetId(), AuraScript::GetSpellInfo(), AuraEffect::HandleAuraDummy(), Unit::HandleAuraProc(), HandleAuraSpecificMods(), spell_item_powerful_anti_venom::HandleDummy(), spell_item_strong_anti_venom::HandleDummy(), spell_item_anti_venom::HandleDummy(), ArenaSpectator::HandleResetCommand(), spell_gen_clear_debuffs::HandleScript(), spell_dru_glyph_of_starfire::HandleScriptEffect(), spell_hun_chimera_shot::HandleScriptEffect(), Unit::HasNegativeAuraWithAttribute(), IsArea(), IsDeathPersistent(), IsPassive(), IsProcTriggeredOnEvent(), IsSingleTargetWith(), Unit::IsTriggeredAtSpellProcEvent(), list_commandscript::ListAurasCommand(), Player::LoadFromDB(), 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::RemoveSpellMods(), Player::RestoreSpellMods(), ArenaSpectator::ShouldSendAura(), Unit::SpellPctDamageModsDone(), and UpdateTargetMap().

◆ GetStackAmount()

◆ GetTriggeredByAuraSpellInfo()

SpellInfo const * Aura::GetTriggeredByAuraSpellInfo ( ) const

◆ GetType()

AuraObjectType Aura::GetType ( ) const
482{
483 if (!m_owner)
484 {
485 LOG_ERROR("spells", "Aura::GetType m_owner is null!");
486 return UNIT_AURA_TYPE;
487 }
488
490}
@ UNIT_AURA_TYPE
Definition: SpellAuraDefines.h:385
bool IsDynamicObject() const
Definition: Object.h:217

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

Referenced by CanStackWith(), GetDynobjOwner(), AuraScript::GetType(), GetUnitOwner(), AuraEffect::HandlePeriodicHealAurasTick(), Unit::RemoveAuraFromStack(), and UpdateTargetMap().

◆ GetUnitOwner()

◆ HandleAllEffects()

void Aura::HandleAllEffects ( AuraApplication aurApp,
uint8  mode,
bool  apply 
)
1242{
1243 ASSERT (!IsRemoved());
1244 for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
1245 if (m_effects[i] && !IsRemoved())
1246 m_effects[i]->HandleEffect(aurApp, mode, apply);
1247}
void HandleEffect(AuraApplication *aurApp, uint8 mode, bool apply)
Definition: SpellAuraEffects.cpp:741

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.
1266{
1267 Unit* target = aurApp->GetTarget();
1268 AuraRemoveMode removeMode = aurApp->GetRemoveMode();
1269 // handle spell_area table
1270 SpellAreaForAreaMapBounds saBounds = sSpellMgr->GetSpellAreaForAuraMapBounds(GetId());
1271 if (saBounds.first != saBounds.second)
1272 {
1273 uint32 zone, area;
1274 target->GetZoneAndAreaId(zone, area);
1275
1276 for (SpellAreaForAreaMap::const_iterator itr = saBounds.first; itr != saBounds.second; ++itr)
1277 {
1278 // some auras remove at aura remove
1279 if (!itr->second->IsFitToRequirements(target->ToPlayer(), zone, area))
1280 target->RemoveAurasDueToSpell(itr->second->spellId);
1281 // some auras applied at aura apply
1282 else if (itr->second->autocast)
1283 {
1284 if (!target->HasAura(itr->second->spellId))
1285 target->CastSpell(target, itr->second->spellId, true);
1286 }
1287 }
1288 }
1289
1290 // handle spell_linked_spell table
1291 if (!onReapply)
1292 {
1293 // apply linked auras
1294 if (apply)
1295 {
1296 if (std::vector<int32> const* spellTriggered = sSpellMgr->GetSpellLinked(GetId() + SPELL_LINK_AURA))
1297 {
1298 for (std::vector<int32>::const_iterator itr = spellTriggered->begin(); itr != spellTriggered->end(); ++itr)
1299 {
1300 if (*itr < 0)
1301 target->ApplySpellImmune(GetId(), IMMUNITY_ID, -(*itr), true);
1302 else if (caster)
1303 caster->AddAura(*itr, target);
1304 }
1305 }
1306 }
1307 else
1308 {
1309 // remove linked auras
1310 if (std::vector<int32> const* spellTriggered = sSpellMgr->GetSpellLinked(-(int32)GetId()))
1311 {
1312 for (std::vector<int32>::const_iterator itr = spellTriggered->begin(); itr != spellTriggered->end(); ++itr)
1313 {
1314 if (*itr < 0)
1315 target->RemoveAurasDueToSpell(-(*itr));
1316 else if (removeMode != AURA_REMOVE_BY_DEATH)
1317 target->CastSpell(target, *itr, true, nullptr, nullptr, GetCasterGUID());
1318 }
1319 }
1320 if (std::vector<int32> const* spellTriggered = sSpellMgr->GetSpellLinked(GetId() + SPELL_LINK_AURA))
1321 {
1322 for (std::vector<int32>::const_iterator itr = spellTriggered->begin(); itr != spellTriggered->end(); ++itr)
1323 {
1324 if (*itr < 0)
1325 target->ApplySpellImmune(GetId(), IMMUNITY_ID, -(*itr), false);
1326 else
1327 target->RemoveAura(*itr, GetCasterGUID(), 0, removeMode);
1328 }
1329 }
1330 }
1331 }
1332 else if (apply)
1333 {
1334 // modify stack amount of linked auras
1335 if (std::vector<int32> const* spellTriggered = sSpellMgr->GetSpellLinked(GetId() + SPELL_LINK_AURA))
1336 {
1337 for (std::vector<int32>::const_iterator itr = spellTriggered->begin(); itr != spellTriggered->end(); ++itr)
1338 if (*itr > 0)
1339 if (Aura* triggeredAura = target->GetAura(*itr, GetCasterGUID()))
1340 triggeredAura->ModStackAmount(GetStackAmount() - triggeredAura->GetStackAmount());
1341 }
1342 }
1343
1344 // mods at aura apply
1345 if (apply)
1346 {
1347 switch (GetSpellInfo()->SpellFamilyName)
1348 {
1350 switch (GetId())
1351 {
1352 case 32474: // Buffeting Winds of Susurrus
1353 if (target->IsPlayer())
1354 target->ToPlayer()->ActivateTaxiPathTo(506, GetId());
1355 break;
1356 case 33572: // Gronn Lord's Grasp, becomes stoned
1357 if (GetStackAmount() >= 5 && !target->HasAura(33652))
1358 target->CastSpell(target, 33652, true);
1359 break;
1360 case 50836: //Petrifying Grip, becomes stoned
1361 if (GetStackAmount() >= 5 && !target->HasAura(50812))
1362 target->CastSpell(target, 50812, true);
1363 break;
1364 case 60970: // Heroic Fury (remove Intercept cooldown)
1365 if (target->IsPlayer())
1366 target->ToPlayer()->RemoveSpellCooldown(20252, true);
1367 break;
1368 }
1369 break;
1370 case SPELLFAMILY_MAGE:
1371 if (!caster)
1372 break;
1373 if (GetSpellInfo()->SpellFamilyFlags[0] & 0x00000001 && GetSpellInfo()->SpellFamilyFlags[2] & 0x00000008)
1374 {
1375 // Glyph of Fireball
1376 if (caster->HasAura(56368))
1377 SetDuration(0);
1378 }
1379 else if (GetSpellInfo()->SpellFamilyFlags[0] & 0x00000020 && GetSpellInfo()->SpellVisual[0] == 13)
1380 {
1381 // Glyph of Frostbolt
1382 if (caster->HasAura(56370))
1383 SetDuration(0);
1384 }
1386 else if (GetSpellInfo()->SpellFamilyFlags[0] & 0x01000000)
1387 {
1388 // Polymorph Sound - Sheep && Penguin
1389 if (GetSpellInfo()->SpellIconID == 82 && GetSpellInfo()->SpellVisual[0] == 12978)
1390 {
1391 // Glyph of the Penguin
1392 if (caster->HasAura(52648))
1393 caster->CastSpell(target, 61635, true);
1394 else
1395 caster->CastSpell(target, 61634, true);
1396 }
1397
1398 if (Creature* creatureTarget = target->ToCreature())
1399 {
1400 creatureTarget->CallAssistance(caster);
1401 }
1402 }
1403 switch (GetId())
1404 {
1405 case 12536: // Clearcasting
1406 case 12043: // Presence of Mind
1407 // Arcane Potency
1408 if (AuraEffect const* aurEff = caster->GetAuraEffect(SPELL_AURA_DUMMY, SPELLFAMILY_MAGE, 2120, 0))
1409 {
1410 uint32 spellId = 0;
1411
1412 switch (aurEff->GetId())
1413 {
1414 case 31571:
1415 spellId = 57529;
1416 break;
1417 case 31572:
1418 spellId = 57531;
1419 break;
1420 default:
1421 LOG_ERROR("spells.aura", "Aura::HandleAuraSpecificMods: Unknown rank of Arcane Potency ({}) found", aurEff->GetId());
1422 }
1423 if (spellId)
1424 caster->CastSpell(caster, spellId, true);
1425 }
1426 break;
1427 case 44544: // Fingers of Frost
1428 {
1429 // See if we already have the indicator aura. If not, create one.
1430 if (Aura* aur = target->GetAura(74396))
1431 {
1432 // Aura already there. Refresh duration and set original charges
1433 aur->SetCharges(2);
1434 aur->RefreshDuration();
1435 }
1436 else
1437 target->AddAura(74396, target);
1438 }
1439 break;
1440 case 12494: // Frostbite, synchronise with Fingers of Frost
1441 {
1442 // Find Fingers of Frost
1444 {
1445 if (SpellInfo const* triggeringSpellInfo = GetTriggeredByAuraSpellInfo())
1446 {
1447 uint8 fbRank = sSpellMgr->GetSpellRank(triggeringSpellInfo->Id);
1448 uint8 fofRank = sSpellMgr->GetSpellRank(aurEff->GetId());
1449 uint8 chance = uint8(std::ceil(fofRank * fbRank * 16.6f));
1450
1451 if (roll_chance_i(chance))
1452 {
1453 caster->CastSpell(caster, aurEff->GetSpellInfo()->Effects[EFFECT_0].TriggerSpell, true);
1454 }
1455 }
1456 }
1457 break;
1458 }
1459 default:
1460 break;
1461 }
1462 break;
1463 case SPELLFAMILY_DRUID:
1464 if (!caster)
1465 break;
1466 // Rejuvenation
1467 if (GetSpellInfo()->SpellFamilyFlags[0] & 0x10 && GetEffect(0))
1468 {
1469 // Druid T8 Restoration 4P Bonus
1470 if (caster->GetAuraEffectDummy(64760))
1471 {
1472 uint32 damage = GetEffect(0)->GetAmount();
1473 damage = target->SpellHealingBonusTaken(caster, GetSpellInfo(), damage, DOT);
1474
1475 int32 basepoints0 = damage;
1476 caster->CastCustomSpell(target, 64801, &basepoints0, nullptr, nullptr, true, nullptr, GetEffect(0));
1477 }
1478 }
1479 break;
1480 case SPELLFAMILY_PRIEST:
1481 if (!caster)
1482 break;
1483 // Devouring Plague
1484 if (GetSpellInfo()->SpellFamilyFlags[0] & 0x02000000 && GetEffect(0))
1485 {
1486 // Improved Devouring Plague
1487 if (AuraEffect const* aurEff = caster->GetDummyAuraEffect(SPELLFAMILY_PRIEST, 3790, 1))
1488 {
1489 uint32 damage = GetEffect(0)->GetAmount();
1490 damage = target->SpellDamageBonusTaken(caster, GetSpellInfo(), damage, DOT);
1491 int32 basepoints0 = aurEff->GetAmount() * GetEffect(0)->GetTotalTicks() * int32(damage) / 100;
1492 int32 heal = int32(CalculatePct(basepoints0, 15));
1493
1494 caster->CastCustomSpell(target, 63675, &basepoints0, nullptr, nullptr, true, nullptr, GetEffect(0));
1495 caster->CastCustomSpell(caster, 75999, &heal, nullptr, nullptr, true, nullptr, GetEffect(0));
1496 }
1497 }
1498 // Power Word: Shield
1499 else if (m_spellInfo->SpellFamilyFlags[0] & 0x1 && m_spellInfo->SpellFamilyFlags[2] & 0x400 && GetEffect(0))
1500 {
1501 // Glyph of Power Word: Shield
1502 if (AuraEffect* glyph = caster->GetAuraEffect(55672, 0))
1503 {
1504 // instantly heal m_amount% of the absorb-value
1505 int32 heal = glyph->GetAmount() * GetEffect(0)->GetAmount() / 100;
1506 caster->CastCustomSpell(GetUnitOwner(), 56160, &heal, nullptr, nullptr, true, 0, GetEffect(0));
1507 }
1508 }
1509 break;
1510 case SPELLFAMILY_ROGUE:
1511 // Sprint (skip non player casted spells by category)
1512 if (GetSpellInfo()->SpellFamilyFlags[0] & 0x40 && GetSpellInfo()->GetCategory() == 44)
1513 // in official maybe there is only one icon?
1514 if (target->HasAura(58039)) // Glyph of Blurred Speed
1515 target->CastSpell(target, 61922, true); // Sprint (waterwalk)
1516 break;
1517 case SPELLFAMILY_SHAMAN:
1518 {
1519 // Ghost Wolf Speed (PvP 58 lvl set)
1520 if (GetSpellInfo()->SpellFamilyFlags[0] & 0x00000800 && target->HasAura(22801) && target->GetLevel() <= 60)
1521 {
1522 int32 bp0 = 15;
1523 target->CastCustomSpell(target, 47017, &bp0, 0, 0, true);
1524 }
1525 break;
1526 }
1528 if (!caster)
1529 break;
1530 // Frost Fever and Blood Plague
1531 if (GetSpellInfo()->SpellFamilyFlags[2] & 0x2)
1532 {
1533 // Can't proc on self
1534 if (GetCasterGUID() == target->GetGUID())
1535 break;
1536
1537 AuraEffect* aurEff = nullptr;
1538 // Ebon Plaguebringer / Crypt Fever
1540 for (Unit::AuraEffectList::const_iterator itr = TalentAuras.begin(); itr != TalentAuras.end(); ++itr)
1541 {
1542 if ((*itr)->GetMiscValue() == 7282)
1543 {
1544 aurEff = *itr;
1545 // Ebon Plaguebringer - end search if found
1546 if ((*itr)->GetSpellInfo()->SpellIconID == 1766)
1547 break;
1548 }
1549 }
1550 if (aurEff)
1551 {
1552 uint32 spellId = 0;
1553 switch (aurEff->GetId())
1554 {
1555 // Ebon Plague
1556 case 51161:
1557 spellId = 51735;
1558 break;
1559 case 51160:
1560 spellId = 51734;
1561 break;
1562 case 51099:
1563 spellId = 51726;
1564 break;
1565 // Crypt Fever
1566 case 49632:
1567 spellId = 50510;
1568 break;
1569 case 49631:
1570 spellId = 50509;
1571 break;
1572 case 49032:
1573 spellId = 50508;
1574 break;
1575 default:
1576 LOG_ERROR("spells.aura", "Aura::HandleAuraSpecificMods: Unknown rank of Crypt Fever/Ebon Plague ({}) found", aurEff->GetId());
1577 }
1578 caster->CastSpell(target, spellId, true, 0, GetEffect(0));
1579 }
1580 }
1581 // Unholy blight
1582 if (GetId() == 50536)
1583 {
1584 if (caster->IsFriendlyTo(target))
1585 SetDuration(0);
1586 }
1587 break;
1588 case SPELLFAMILY_POTION:
1589 // Alchemy: Mixology
1590 if (caster && caster->HasAura(53042) && caster->IsPlayer() && !caster->ToPlayer()->GetSession()->PlayerLoading())
1591 {
1592 if (sSpellMgr->GetSpellGroup(GetId()) == 1) /*Elixirs*/
1593 {
1594 if (caster->HasSpell(GetSpellInfo()->Effects[EFFECT_0].TriggerSpell))
1595 {
1596 for (int i = 0; i < MAX_SPELL_EFFECTS; ++i)
1597 if (GetEffect(i))
1598 GetEffect(i)->SetAmount(CalculatePct(GetEffect(i)->GetAmount(), 100 + sSpellMgr->GetSpellMixologyBonus(GetId())));
1599
1602 }
1603 }
1604 }
1605 break;
1606 }
1607 }
1608 // mods at aura remove
1609 else
1610 {
1611 switch (GetSpellInfo()->SpellFamilyName)
1612 {
1614 if (!caster)
1615 break;
1616 switch (GetId())
1617 {
1618 case 61987: // Avenging Wrath
1619 // Remove the immunity shield marker on Avenging Wrath removal if Forbearance is not present
1620 if (target->HasAura(61988) && !target->HasAura(25771))
1621 target->RemoveAura(61988);
1622 break;
1623 case 72368: // Shared Suffering
1624 case 72369:
1625 if (AuraEffect* aurEff = GetEffect(0))
1626 {
1627 int32 remainingDamage = aurEff->GetAmount() * (aurEff->GetTotalTicks() - aurEff->GetTickNumber());
1628 if (remainingDamage > 0)
1629 caster->CastCustomSpell(caster, 72373, nullptr, &remainingDamage, nullptr, true);
1630 }
1631 break;
1632 }
1633 break;
1634 case SPELLFAMILY_MAGE:
1635 {
1636 // Polymorph
1637 if (GetSpellInfo()->SpellFamilyFlags[0] & 0x01000000)
1638 {
1639 if (Creature* creatureTarget = target->ToCreature())
1640 {
1641 creatureTarget->SetNoCallAssistance(false);
1642 }
1643 }
1644 switch (GetId())
1645 {
1646 case 66: // Invisibility
1647 if (removeMode != AURA_REMOVE_BY_EXPIRE)
1648 break;
1649 target->CastSpell(target, 32612, true, nullptr, GetEffect(1));
1650 target->CombatStop();
1651 break;
1652 case 74396: // Fingers of Frost
1653 // Remove the IGNORE_AURASTATE aura
1654 target->RemoveAurasDueToSpell(44544);
1655 break;
1656 case 44401: // Missile Barrage
1657 case 48108: // Hot Streak
1658 case 57761: // Fireball!
1659 if (removeMode != AURA_REMOVE_BY_EXPIRE || aurApp->GetBase()->IsExpired())
1660 break;
1661 if (target->HasAura(70752)) // Item - Mage T10 2P Bonus
1662 target->CastSpell(target, 70753, true);
1663 break;
1664 default:
1665 break;
1666 }
1667 if (!caster)
1668 break;
1669 // Ice barrier - dispel/absorb remove
1670 if (removeMode == AURA_REMOVE_BY_ENEMY_SPELL && GetSpellInfo()->SpellFamilyFlags[1] & 0x1)
1671 {
1672 // Shattered Barrier
1673 if (AuraEffect* absorb = GetEffect(EFFECT_0))
1674 if (absorb->GetAmount() <= 0) // removed by damage, not dispel
1675 if (AuraEffect* dummy = caster->GetDummyAuraEffect(SPELLFAMILY_MAGE, 2945, 0))
1676 if (roll_chance_i(dummy->GetSpellInfo()->ProcChance))
1677 caster->CastSpell(target, 55080, true, nullptr, GetEffect(0));
1678 }
1679 break;
1680 }
1682 if (!caster)
1683 break;
1684 [[fallthrough]];
1686 if (!caster)
1687 break;
1688 if (GetSpellInfo()->SpellFamilyFlags[1] & 0x00000400)
1689 {
1690 if (AuraEffect* aurEff = caster->GetAuraEffect(SPELL_AURA_DUMMY, SPELLFAMILY_WARLOCK, 98, 0))
1691 {
1692 uint32 spellId = 0;
1693 switch (aurEff->GetId())
1694 {
1695 case 53759:
1696 spellId = 60947;
1697 break;
1698 case 53754:
1699 spellId = 60946;
1700 break;
1701 default:
1702 LOG_ERROR("spells.aura", "Aura::HandleAuraSpecificMods: Unknown rank of Improved Fear ({}) found", aurEff->GetId());
1703 }
1704 if (spellId)
1705 caster->CastSpell(target, spellId, true);
1706 }
1707 }
1708 break;
1709 case SPELLFAMILY_PRIEST:
1710 if (!caster)
1711 break;
1712 // Shadow word: Pain // Vampiric Touch
1713 if (removeMode == AURA_REMOVE_BY_ENEMY_SPELL && (GetSpellInfo()->SpellFamilyFlags[0] & 0x00008000 || GetSpellInfo()->SpellFamilyFlags[1] & 0x00000400))
1714 {
1715 // Shadow Affinity
1716 if (AuraEffect const* aurEff = caster->GetDummyAuraEffect(SPELLFAMILY_PRIEST, 178, 1))
1717 {
1718 int32 basepoints0 = aurEff->GetAmount() * caster->GetCreateMana() / 100;
1719 caster->CastCustomSpell(caster, 64103, &basepoints0, nullptr, nullptr, true, nullptr, GetEffect(0));
1720 }
1721 }
1722 // Power word: shield
1723 else if (removeMode == AURA_REMOVE_BY_ENEMY_SPELL && GetSpellInfo()->SpellFamilyFlags[0] & 0x00000001)
1724 {
1725 // Rapture
1726 if (Aura const* aura = caster->GetAuraOfRankedSpell(47535))
1727 {
1728 // check cooldown
1729 if (caster->IsPlayer())
1730 {
1731 if (caster->ToPlayer()->HasSpellCooldown(aura->GetId()))
1732 {
1733 // This additional check is needed to add a minimal delay before cooldown in in effect
1734 // to allow all bubbles broken by a single damage source proc mana return
1735 if (caster->ToPlayer()->GetSpellCooldownDelay(aura->GetId()) <= 11500)
1736 break;
1737 }
1738 else // and add if needed
1739 caster->ToPlayer()->AddSpellCooldown(aura->GetId(), 0, 12 * IN_MILLISECONDS);
1740 }
1741
1742 // effect on caster
1743 if (AuraEffect const* aurEff = aura->GetEffect(0))
1744 {
1745 float multiplier = (float)aurEff->GetAmount();
1746 if (aurEff->GetId() == 47535)
1747 multiplier -= 0.5f;
1748 else if (aurEff->GetId() == 47537)
1749 multiplier += 0.5f;
1750
1751 int32 basepoints0 = int32(CalculatePct(caster->GetMaxPower(POWER_MANA), multiplier));
1752 caster->CastCustomSpell(caster, 47755, &basepoints0, nullptr, nullptr, true);
1753 }
1754 // effect on aura target
1755 if (AuraEffect const* aurEff = aura->GetEffect(1))
1756 {
1757 if (!roll_chance_i(aurEff->GetAmount()))
1758 break;
1759
1760 int32 triggeredSpellId = 0;
1761 switch (target->getPowerType())
1762 {
1763 case POWER_MANA:
1764 {
1765 int32 basepoints0 = int32(CalculatePct(target->GetMaxPower(POWER_MANA), 2));
1766 caster->CastCustomSpell(target, 63654, &basepoints0, nullptr, nullptr, true);
1767 break;
1768 }
1769 case POWER_RAGE:
1770 triggeredSpellId = 63653;
1771 break;
1772 case POWER_ENERGY:
1773 triggeredSpellId = (!target->HasAura(70405) ? 63655 : 0);
1774 break;
1775 case POWER_RUNIC_POWER:
1776 triggeredSpellId = 63652;
1777 break;
1778 default:
1779 break;
1780 }
1781 if (triggeredSpellId)
1782 caster->CastSpell(target, triggeredSpellId, true);
1783 }
1784 }
1785 }
1786 switch (GetId())
1787 {
1788 case 47788: // Guardian Spirit
1789 {
1790 if (removeMode != AURA_REMOVE_BY_EXPIRE)
1791 break;
1792 if (!caster->IsPlayer())
1793 break;
1794
1795 Player* player = caster->ToPlayer();
1796 // Glyph of Guardian Spirit
1797 if (AuraEffect* aurEff = player->GetAuraEffect(63231, 0))
1798 {
1799 if (!player->HasSpellCooldown(47788))
1800 break;
1801
1802 player->AddSpellCooldown(GetSpellInfo()->Id, 0, aurEff->GetAmount()*IN_MILLISECONDS);
1803
1804 WorldPacket data(SMSG_MODIFY_COOLDOWN, 4 + 8 + 4);
1805 data << uint32(GetId()); // Spell ID
1806 data << player->GetGUID(); // Player GUID
1807 data << int32(-110000); // Cooldown mod in milliseconds
1808 player->SendDirectMessage(&data);
1809 }
1810 break;
1811 }
1812 case 47585: // Dispersion (fixed bug invisible as a Shadow Priest)
1813 {
1814 if (target->IsMounted())
1815 {
1816 target->CastSpell(target, 53444, true);
1817 }
1818 break;
1819 }
1820 }
1821 break;
1822 case SPELLFAMILY_ROGUE:
1823 {
1824 // Overkill, Master of Subtlety
1825 if (caster && GetSpellInfo()->SpellIconID == 250)
1826 {
1827 if (caster->GetDummyAuraEffect(SPELLFAMILY_ROGUE, 2114, 0))
1828 caster->CastSpell(caster, 31666, true);
1829
1830 if (caster->GetAuraEffectDummy(58426))
1831 caster->CastSpell(caster, 58428, true);
1832 }
1833 // Remove Vanish on stealth remove
1834 if (GetId() == 1784)
1835 {
1837 target->RemoveAurasDueToSpell(18461);
1838 }
1839 break;
1840 }
1841 case SPELLFAMILY_SHAMAN:
1842 {
1843 // Ghost Wolf Speed (PvP 58 lvl set)
1844 if (GetSpellInfo()->SpellFamilyFlags[0] & 0x00000800)
1845 {
1846 target->RemoveAurasDueToSpell(47017);
1847 }
1848 // Lightning Shield vs The Earthshatterer 8/9 set bonus
1849 if (GetSpellInfo()->SpellFamilyFlags[0] & 0x00000400)
1850 {
1851 target->RemoveAurasDueToSpell(28820);
1852 }
1853 break;
1854 }
1856 // Blood of the North
1857 // Reaping
1858 // Death Rune Mastery
1859 if (GetSpellInfo()->SpellIconID == 3041 || GetSpellInfo()->SpellIconID == 22 || GetSpellInfo()->SpellIconID == 2622)
1860 {
1861 if (!GetEffect(0) || GetEffect(0)->GetAuraType() != SPELL_AURA_PERIODIC_DUMMY)
1862 break;
1863 if (!target->IsPlayer())
1864 break;
1866 break;
1867
1868 // aura removed - remove death runes
1870 }
1871 break;
1873 // Remove the immunity shield marker on Forbearance removal if AW marker is not present
1874 if (GetId() == 25771 && target->HasAura(61988) && !target->HasAura(61987))
1875 target->RemoveAura(61988);
1876 break;
1877 case SPELLFAMILY_HUNTER:
1878 // Glyph of Freezing Trap
1879 if ((GetSpellInfo()->SpellFamilyFlags[0] & 0x00000008) && caster && caster->HasAura(56845))
1880 {
1881 target->CastSpell(target, 61394, true);
1882 }
1883 break;
1884 }
1885 }
1886
1887 // mods at aura apply or remove
1888 switch (GetSpellInfo()->SpellFamilyName)
1889 {
1890 case SPELLFAMILY_HUNTER:
1891 switch (GetId())
1892 {
1893 case 19574: // Bestial Wrath
1894 // The Beast Within cast on owner if talent present
1895 if (Unit* owner = target->GetOwner())
1896 {
1897 // Search talent
1898 if (owner->HasAura(34692))
1899 {
1900 if (apply)
1901 owner->CastSpell(owner, 34471, true, 0, GetEffect(0));
1902 else
1903 owner->RemoveAurasDueToSpell(34471);
1904 }
1905 }
1906 break;
1907 case 34026: // Kill Command
1908 // Dungeon Set 3
1909 if (caster->HasAura(37483))
1910 {
1911 if (apply)
1912 {
1913 caster->CastSpell(caster, 37482, true);
1914 }
1915 }
1916 break;
1917 }
1918 break;
1920 switch (GetId())
1921 {
1922 case 19746:
1923 case 31821:
1924 // Aura Mastery Triggered Spell Handler
1925 // If apply Concentration Aura -> trigger -> apply Aura Mastery Immunity
1926 // If remove Concentration Aura -> trigger -> remove Aura Mastery Immunity
1927 // If remove Aura Mastery -> trigger -> remove Aura Mastery Immunity
1928 // Do effects only on aura owner
1929 if (GetCasterGUID() != target->GetGUID())
1930 break;
1931 if (apply)
1932 {
1933 if ((GetSpellInfo()->Id == 31821 && target->HasAura(19746, GetCasterGUID())) || (GetSpellInfo()->Id == 19746 && target->HasAura(31821)))
1934 target->CastSpell(target, 64364, true);
1935 }
1936 else
1937 target->RemoveAurasDueToSpell(64364, GetCasterGUID());
1938 break;
1939 case 31842:
1940 if (caster && caster->HasAura(70755))
1941 {
1942 if (apply)
1943 target->CastSpell(target, 71166, true);
1944 else
1945 target->RemoveAurasDueToSpell(71166);
1946 }
1947 break;
1948 }
1949
1950 // Sanctified Retribution, Improved Devotion Aura, Swift Retribution, Improved Concentration Aura
1951 if (caster == target && GetSpellInfo()->GetSpellSpecific() == SPELL_SPECIFIC_AURA)
1952 {
1953 if (apply)
1954 {
1955 target->CastSpell(target, 63510, true);
1956 target->CastSpell(target, 63514, true);
1957 target->CastSpell(target, 63531, true);
1958 }
1959 else
1960 {
1961 target->RemoveAura(63510);
1962 target->RemoveAura(63514);
1963 target->RemoveAura(63531);
1964 }
1965 }
1966 break;
1967 }
1968}
T CalculatePct(T base, U pct)
Definition: Util.h:61
bool roll_chance_i(int chance)
Definition: Random.h:59
@ DOT
Definition: Unit.h:250
@ CLASS_CONTEXT_ABILITY
Definition: UnitDefines.h:213
@ 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
std::pair< SpellAreaForAreaMap::const_iterator, SpellAreaForAreaMap::const_iterator > SpellAreaForAreaMapBounds
Definition: SpellMgr.h:550
@ SPELL_LINK_AURA
Definition: SpellMgr.h:98
@ SPELL_SPECIFIC_AURA
Definition: SpellInfo.h:152
@ EFFECT_0
Definition: SharedDefines.h:31
@ POWER_RAGE
Definition: SharedDefines.h:270
@ POWER_RUNIC_POWER
Definition: SharedDefines.h:275
@ POWER_ENERGY
Definition: SharedDefines.h:272
@ POWER_MANA
Definition: SharedDefines.h:269
@ CLASS_DEATH_KNIGHT
Definition: SharedDefines.h:146
@ IMMUNITY_ID
Definition: SharedDefines.h:1400
@ SPELLFAMILY_PRIEST
Definition: SharedDefines.h:3534
@ SPELLFAMILY_WARLOCK
Definition: SharedDefines.h:3533
@ SPELLFAMILY_MAGE
Definition: SharedDefines.h:3531
@ SPELLFAMILY_GENERIC
Definition: SharedDefines.h:3528
@ SPELLFAMILY_WARRIOR
Definition: SharedDefines.h:3532
@ SPELLFAMILY_PALADIN
Definition: SharedDefines.h:3538
@ SPELLFAMILY_POTION
Definition: SharedDefines.h:3541
@ SPELLFAMILY_ROGUE
Definition: SharedDefines.h:3536
@ SPELLFAMILY_SHAMAN
Definition: SharedDefines.h:3539
@ SPELLFAMILY_DRUID
Definition: SharedDefines.h:3535
@ SPELLFAMILY_DEATHKNIGHT
Definition: SharedDefines.h:3543
@ SMSG_MODIFY_COOLDOWN
Definition: Opcodes.h:1199
Definition: Creature.h:46
void GetZoneAndAreaId(uint32 &zoneid, uint32 &areaid) const
Definition: Object.cpp:3160
void RemoveRunesByAuraEffect(AuraEffect const *aura)
Definition: Player.cpp:13385
void SendDirectMessage(WorldPacket const *data) const
Definition: Player.cpp:5692
bool ActivateTaxiPathTo(std::vector< uint32 > const &nodes, Creature *npc=nullptr, uint32 spellid=1)
Definition: Player.cpp:10230
WorldSession * GetSession() const
Definition: Player.h:1978
bool HasSpellCooldown(uint32 spell_id) const override
Definition: Player.cpp:16334
void AddSpellCooldown(uint32 spell_id, uint32 itemid, uint32 end_time, bool needSendToClient=false, bool forceSendToSpectator=false) override
Definition: Player.cpp:11085
bool IsClass(Classes playerClass, ClassContext context=CLASS_CONTEXT_NONE) const override
Definition: Player.cpp:1280
uint32 GetSpellCooldownDelay(uint32 spell_id) const
Definition: Player.cpp:16346
void RemoveSpellCooldown(uint32 spell_id, bool update=false)
Definition: Player.cpp:3503
AuraEffectList const & GetAuraEffectsByType(AuraType type) const
Definition: Unit.h:1362
Aura * GetAura(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, ObjectGuid itemCasterGUID=ObjectGuid::Empty, uint8 reqEffMask=0) const
Definition: Unit.cpp:5552
void RemoveAurasWithFamily(SpellFamilyNames family, uint32 familyFlag1, uint32 familyFlag2, uint32 familyFlag3, ObjectGuid casterGUID)
Definition: Unit.cpp:5187
Unit * GetOwner() const
Definition: Unit.cpp:10562
void CombatStop(bool includingCast=false)
Definition: Unit.cpp:10398
void ApplySpellImmune(uint32 spellId, uint32 op, uint32 type, bool apply, SpellImmuneBlockType blockType=SPELL_BLOCK_TYPE_ALL)
Definition: Unit.cpp:13346
Aura * GetAuraOfRankedSpell(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, ObjectGuid itemCasterGUID=ObjectGuid::Empty, uint8 reqEffMask=0) const
Definition: Unit.cpp:5570
void RemoveAura(AuraApplicationMap::iterator &i, AuraRemoveMode mode=AURA_REMOVE_BY_DEFAULT)
Definition: Unit.cpp:4758
Aura * AddAura(uint32 spellId, Unit *target)
Definition: Unit.cpp:18819
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:1225
AuraEffect * GetAuraEffect(uint32 spellId, uint8 effIndex, ObjectGuid casterGUID=ObjectGuid::Empty) const
Definition: Unit.cpp:5465
bool HasAura(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, ObjectGuid itemCasterGUID=ObjectGuid::Empty, uint8 reqEffMask=0) const
Definition: Unit.cpp:5669
AuraEffect * GetAuraEffectDummy(uint32 spellid) const
Definition: Unit.cpp:5521
virtual bool HasSpell(uint32) const
Definition: Unit.h:1099
uint32 SpellDamageBonusTaken(Unit *caster, SpellInfo const *spellProto, uint32 pdamage, DamageEffectType damagetype, uint32 stack=1)
Definition: Unit.cpp:11748
uint32 GetMaxPower(Powers power) const
Definition: Unit.h:892
SpellCastResult CastSpell(SpellCastTargets const &targets, SpellInfo const *spellInfo, CustomSpellValues const *value, TriggerCastFlags triggerFlags=TRIGGERED_NONE, Item *castItem=nullptr, AuraEffect const *triggeredByAura=nullptr, ObjectGuid originalCaster=ObjectGuid::Empty)
Definition: Unit.cpp:1168
bool IsMounted() const
Definition: Unit.h:990
void RemoveAurasDueToSpell(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, uint8 reqEffMask=0, AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
Definition: Unit.cpp:4891
bool IsFriendlyTo(Unit const *unit) const
Definition: Unit.cpp:10203
AuraEffect * GetDummyAuraEffect(SpellFamilyNames name, uint32 iconId, uint8 effIndex) const
Definition: Unit.h:1371
Powers getPowerType() const
Definition: Unit.h:888
std::list< AuraEffect * > AuraEffectList
Definition: Unit.h:646
uint32 GetCreateMana() const
Definition: Unit.h:1436
uint32 SpellHealingBonusTaken(Unit *caster, SpellInfo const *spellProto, uint32 healamount, DamageEffectType damagetype, uint32 stack=1)
Definition: Unit.cpp:12527
ObjectGuid GetTarget() const
Definition: Unit.h:1742
bool PlayerLoading() const
Definition: WorldSession.h:337
uint32 GetTickNumber() const
Definition: SpellAuraEffects.h:87
uint32 GetId() const
Definition: SpellAuraEffects.cpp:432
int32 GetTotalTicks() const
Definition: SpellAuraEffects.cpp:7365
void SetAmount(int32 amount)
Definition: SpellAuraEffects.h:66
int32 GetAmount() const
Definition: SpellAuraEffects.h:64
int32 GetMaxDuration() const
Definition: SpellAuras.h:129
void SetDuration(int32 duration, bool withMods=false)
Definition: SpellAuras.cpp:868
uint8 GetStackAmount() const
Definition: SpellAuras.h:148
void SetMaxDuration(int32 duration)
Definition: SpellAuras.h:130
SpellInfo const * GetTriggeredByAuraSpellInfo() const
Definition: SpellAuras.cpp:2761

References Player::ActivateTaxiPathTo(), Unit::AddAura(), Player::AddSpellCooldown(), Unit::ApplySpellImmune(), AURA_REMOVE_BY_DEATH, AURA_REMOVE_BY_ENEMY_SPELL, AURA_REMOVE_BY_EXPIRE, Unit::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::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_LINK_AURA, SPELL_SPECIFIC_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, Unit::SpellHealingBonusTaken(), sSpellMgr, Object::ToCreature(), and Object::ToPlayer().

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

◆ HasEffect()

bool Aura::HasEffect ( uint8  effIndex) const
inline

◆ HasEffectType()

bool Aura::HasEffectType ( AuraType  type) const
1223{
1224 for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
1225 {
1226 if (HasEffect(i) && m_effects[i]->GetAuraType() == type)
1227 return true;
1228 }
1229 return false;
1230}
bool HasEffect(uint8 effIndex) const
Definition: SpellAuras.h:173

References HasEffect(), m_effects, and MAX_SPELL_EFFECTS.

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

◆ IsAppliedOnTarget()

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

References m_applications.

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

◆ IsArea()

bool Aura::IsArea ( ) const
1073{
1074 for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
1075 {
1076 if (HasEffect(i) && GetSpellInfo()->Effects[i].IsAreaAuraEffect())
1077 return true;
1078 }
1079 return false;
1080}

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

Referenced by CanStackWith(), and UpdateTargetMap().

◆ IsAuraStronger()

bool Aura::IsAuraStronger ( Aura const *  newAura) const
1993{
1994 for (uint8 i = EFFECT_0; i < MAX_SPELL_EFFECTS; ++i)
1995 {
1996 AuraEffect* thisEffect = GetEffect(i);
1997 if (!thisEffect)
1998 continue;
1999
2000 AuraEffect* newEffect = nullptr;
2001 for (uint8 j = EFFECT_0; j < MAX_SPELL_EFFECTS; ++j)
2002 {
2003 newEffect = newAura->GetEffect(j);
2004 if (!newEffect || thisEffect->GetAuraType() != newEffect->GetAuraType() || thisEffect->GetMiscValue() != newEffect->GetMiscValue())
2005 continue;
2006
2007 // xinef: assume that all spells are either positive or negative, otherwise they should not be in one group
2008 int32 curValue = std::abs(thisEffect->GetAmount());
2009 if (curValue < std::abs(newEffect->GetAmount()))
2010 return true;
2011
2012 if (curValue == std::abs(newEffect->GetAmount()))
2013 if (!IsPassive() && !IsPermanent() && GetDuration() < newAura->GetDuration())
2014 return true;
2015 }
2016 }
2017
2018 return false;
2019}
AuraType GetAuraType() const
Definition: SpellAuraEffects.cpp:447
int32 GetMiscValue() const
Definition: SpellAuraEffects.cpp:442
int32 GetDuration() const
Definition: SpellAuras.h:133
bool IsPermanent() const
Definition: SpellAuras.h:139

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

Referenced by CanStackWith().

◆ IsDeathPersistent()

bool Aura::IsDeathPersistent ( ) const
1088{
1089 return GetSpellInfo()->IsDeathPersistent();
1090}
bool IsDeathPersistent() const
Definition: SpellInfo.cpp:1216

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

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

◆ IsExpired()

bool Aura::IsExpired ( ) const
inline

◆ IsPassive()

◆ IsPermanent()

◆ IsProcOnCooldown()

bool Aura::IsProcOnCooldown ( ) const
2192{
2193 /*if (m_procCooldown)
2194 {
2195 if (m_procCooldown > GameTime::GetGameTime().count())
2196 return true;
2197 }*/
2198 return false;
2199}

Referenced by IsProcTriggeredOnEvent().

◆ IsProcTriggeredOnEvent()

bool Aura::IsProcTriggeredOnEvent ( AuraApplication aurApp,
ProcEventInfo eventInfo 
) const
Todo:
:
Todo:
:
Todo:
: this needs to be unified for all kinds of auras
2228{
2229 SpellProcEntry const* procEntry = sSpellMgr->GetSpellProcEntry(GetId());
2230 // only auras with spell proc entry can trigger proc
2231 if (!procEntry)
2232 return false;
2233
2234 // check if we have charges to proc with
2235 if (IsUsingCharges() && !GetCharges())
2236 return false;
2237
2238 // check proc cooldown
2239 if (IsProcOnCooldown())
2240 return false;
2241
2243 // something about triggered spells triggering, and add extra attack effect
2244
2245 // do checks against db data
2246 if (!sSpellMgr->CanSpellTriggerProcOnEvent(*procEntry, eventInfo))
2247 return false;
2248
2249 // do checks using conditions table
2250 ConditionList conditions = sConditionMgr->GetConditionsForNotGroupedEntry(CONDITION_SOURCE_TYPE_SPELL_PROC, GetId());
2251 ConditionSourceInfo condInfo = ConditionSourceInfo(eventInfo.GetActor(), eventInfo.GetActionTarget());
2252 if (!sConditionMgr->IsObjectMeetToConditions(condInfo, conditions))
2253 return false;
2254
2255 // AuraScript Hook
2256 bool check = const_cast<Aura*>(this)->CallScriptCheckProcHandlers(aurApp, eventInfo);
2257 if (!check)
2258 return false;
2259
2261 // do allow additional requirements for procs
2262 // this is needed because this is the last moment in which you can prevent aura charge drop on proc
2263 // and possibly a way to prevent default checks (if there're going to be any)
2264
2265 // Check if current equipment meets aura requirements
2266 // do that only for passive spells
2268 Unit* target = aurApp->GetTarget();
2269 if (IsPassive() && target->IsPlayer() && GetSpellInfo()->EquippedItemClass != -1)
2270 {
2272 {
2273 Item* item = nullptr;
2275 {
2276 if (target->ToPlayer()->IsInFeralForm())
2277 return false;
2278
2279 if (DamageInfo const* damageInfo = eventInfo.GetDamageInfo())
2280 {
2281 switch (damageInfo->GetAttackType())
2282 {
2283 case BASE_ATTACK:
2285 break;
2286 case OFF_ATTACK:
2288 break;
2289 default:
2291 break;
2292 }
2293 }
2294 }
2296 {
2297 // Check if player is wearing shield
2299 }
2300
2301 if (!item || item->IsBroken() || !item->IsFitToSpellRequirements(GetSpellInfo()))
2302 {
2303 return 0;
2304 }
2305 }
2306 }
2307
2308 return roll_chance_f(CalcProcChance(*procEntry, eventInfo));
2309}
bool roll_chance_f(float chance)
Definition: Random.h:53
#define sConditionMgr
Definition: ConditionMgr.h:289
@ CONDITION_SOURCE_TYPE_SPELL_PROC
Definition: ConditionMgr.h:146
std::list< Condition * > ConditionList
Definition: ConditionMgr.h:236
@ OFF_ATTACK
Definition: Unit.h:210
@ BASE_ATTACK
Definition: Unit.h:209
@ EQUIPMENT_SLOT_MAINHAND
Definition: Player.h:690
@ EQUIPMENT_SLOT_OFFHAND
Definition: Player.h:691
@ EQUIPMENT_SLOT_RANGED
Definition: Player.h:692
#define INVENTORY_SLOT_BAG_0
Definition: Player.h:670
@ ITEM_CLASS_ARMOR
Definition: ItemTemplate.h:295
@ ITEM_CLASS_WEAPON
Definition: ItemTemplate.h:293
@ SPELL_ATTR3_NO_PROC_EQUIP_REQUIREMENT
Definition: SharedDefines.h:494
Definition: ConditionMgr.h:181
Definition: Item.h:220
bool IsBroken() const
Definition: Item.h:257
bool IsFitToSpellRequirements(SpellInfo const *spellInfo) const
Definition: Item.cpp:885
Item * GetUseableItemByPos(uint8 bag, uint8 slot) const
Definition: Player.h:1244
Definition: Unit.h:330
Unit * GetActionTarget() const
Definition: Unit.h:440
Unit * GetActor()
Definition: Unit.h:439
bool IsInFeralForm() const
Definition: Unit.h:1469
bool CallScriptCheckProcHandlers(AuraApplication const *aurApp, ProcEventInfo &eventInfo)
Definition: SpellAuras.cpp:2633
bool IsProcOnCooldown() const
Definition: SpellAuras.cpp:2191
float CalcProcChance(SpellProcEntry const &procEntry, ProcEventInfo &eventInfo) const
Definition: SpellAuras.cpp:2311
int32 EquippedItemClass
Definition: SpellInfo.h:375

References BASE_ATTACK, CalcProcChance(), CallScriptCheckProcHandlers(), CONDITION_SOURCE_TYPE_SPELL_PROC, EQUIPMENT_SLOT_MAINHAND, EQUIPMENT_SLOT_OFFHAND, EQUIPMENT_SLOT_RANGED, SpellInfo::EquippedItemClass, ProcEventInfo::GetActionTarget(), ProcEventInfo::GetActor(), GetCharges(), ProcEventInfo::GetDamageInfo(), GetId(), GetSpellInfo(), AuraApplication::GetTarget(), Player::GetUseableItemByPos(), SpellInfo::HasAttribute(), INVENTORY_SLOT_BAG_0, Item::IsBroken(), Item::IsFitToSpellRequirements(), Unit::IsInFeralForm(), IsPassive(), Object::IsPlayer(), IsProcOnCooldown(), IsUsingCharges(), ITEM_CLASS_ARMOR, ITEM_CLASS_WEAPON, OFF_ATTACK, roll_chance_f(), sConditionMgr, SPELL_ATTR3_NO_PROC_EQUIP_REQUIREMENT, sSpellMgr, and Object::ToPlayer().

◆ IsRemoved()

◆ IsRemovedOnShapeLost()

bool Aura::IsRemovedOnShapeLost ( Unit target) const

◆ IsSingleTarget()

◆ IsSingleTargetWith()

bool Aura::IsSingleTargetWith ( Aura const *  aura) const
1143{
1144 // Same spell?
1145 if (GetSpellInfo()->IsRankOf(aura->GetSpellInfo()))
1146 return true;
1147
1149 // spell with single target specific types
1150 switch (spec)
1151 {
1154 if (aura->GetSpellInfo()->GetSpellSpecific() == spec)
1155 return true;
1156 break;
1157 default:
1158 break;
1159 }
1160
1162 return true;
1163
1164 return false;
1165}
SpellSpecificType
Definition: SpellInfo.h:149
@ SPELL_SPECIFIC_JUDGEMENT
Definition: SpellInfo.h:161
@ SPELL_SPECIFIC_MAGE_POLYMORPH
Definition: SpellInfo.h:160
SpellSpecificType GetSpellSpecific() const
Definition: SpellInfo.cpp:2136

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 ( )
2357{
2358 sScriptMgr->CreateAuraScripts(m_spellInfo->Id, m_loadedScripts);
2359 for (std::list<AuraScript*>::iterator itr = m_loadedScripts.begin(); itr != m_loadedScripts.end();)
2360 {
2361 if (!(*itr)->_Load(this))
2362 {
2363 std::list<AuraScript*>::iterator bitr = itr;
2364 ++itr;
2365 delete (*bitr);
2366 m_loadedScripts.erase(bitr);
2367 continue;
2368 }
2369 LOG_DEBUG("spells.aura", "Aura::LoadScripts: Script `{}` for aura `{}` is loaded now", (*itr)->_GetScriptName()->c_str(), m_spellInfo->Id);
2370 (*itr)->Register();
2371 ++itr;
2372 }
2373}
#define LOG_DEBUG(filterType__,...)
Definition: Log.h:168

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 
)
974{
975 if (IsUsingCharges())
976 {
977 int32 charges = m_procCharges + num;
978 int32 maxCharges = CalcMaxCharges();
979
980 // limit charges (only on charges increase, charges may be changed manually)
981 if ((num > 0) && (charges > int32(maxCharges)))
982 charges = maxCharges;
983 // we're out of charges, remove
984 else if (charges <= 0)
985 {
986 Remove(removeMode);
987 return true;
988 }
989
990 SetCharges(charges);
991 }
992 return false;
993}
void SetCharges(uint8 charges)
Definition: SpellAuras.cpp:952
virtual void Remove(AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)=0

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 
)
1022{
1023 int32 stackAmount = m_stackAmount + num;
1024
1025 // limit the stack amount (only on stack increase, stack amount may be changed manually)
1026 if ((num > 0) && (stackAmount > int32(m_spellInfo->StackAmount)))
1027 {
1028 // not stackable aura - set stack amount to 1
1030 stackAmount = 1;
1031 else
1032 stackAmount = m_spellInfo->StackAmount;
1033 }
1034 // we're out of stacks, remove
1035 else if (stackAmount <= 0)
1036 {
1037 Remove(removeMode);
1038 return true;
1039 }
1040
1041 bool refresh = stackAmount >= GetStackAmount() && (m_spellInfo->StackAmount || !m_spellInfo->HasAttribute(SPELL_ATTR1_AURA_UNIQUE));
1042
1043 // Update stack amount
1044 if (refresh)
1045 {
1047 RefreshTimers(periodicReset);
1048
1049 // reset charges
1051 // FIXME: not a best way to synchronize charges, but works
1052 for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
1053 if (AuraEffect* aurEff = GetEffect(i))
1054 if (aurEff->GetAuraType() == SPELL_AURA_ADD_FLAT_MODIFIER || aurEff->GetAuraType() == SPELL_AURA_ADD_PCT_MODIFIER)
1055 if (SpellModifier* mod = aurEff->GetSpellModifier())
1056 mod->charges = GetCharges();
1057 }
1058
1059 SetStackAmount(stackAmount);
1060
1062 return false;
1063}
@ SPELL_AURA_ADD_PCT_MODIFIER
Definition: SpellAuraDefines.h:171
@ SPELL_AURA_ADD_FLAT_MODIFIER
Definition: SpellAuraDefines.h:170
@ SPELL_ATTR1_AURA_UNIQUE
Definition: SharedDefines.h:430
Definition: Player.h:181
void SetStackAmount(uint8 num)
Definition: SpellAuras.cpp:995
void RefreshTimers(bool periodicReset=false)
Definition: SpellAuras.cpp:909
void SetNeedClientUpdateForTargets() const
Definition: SpellAuras.cpp:1258
void RefreshSpellMods()
Definition: SpellAuras.cpp:1065
uint32 StackAmount
Definition: SpellInfo.h:371

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

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

◆ PrepareProcToTrigger()

void Aura::PrepareProcToTrigger ( AuraApplication aurApp,
ProcEventInfo eventInfo 
)
2207{
2208 bool prepare = CallScriptPrepareProcHandlers(aurApp, eventInfo);
2209 if (!prepare)
2210 return;
2211
2212 // take one charge, aura expiration will be handled in Aura::TriggerProcOnEvent (if needed)
2214 {
2215 --m_procCharges;
2217 }
2218
2219 SpellProcEntry const* procEntry = sSpellMgr->GetSpellProcEntry(GetId());
2220
2221 ASSERT(procEntry);
2222
2223 // cooldowns should be added to the whole aura (see 51698 area aura)
2224 AddProcCooldown(procEntry->Cooldown);
2225}
@ SPELL_ATTR6_DO_NOT_CONSUME_RESOURCES
Definition: SharedDefines.h:609
SpellInfo const * GetSpellInfo() const
Definition: Unit.cpp:185
void AddProcCooldown(Milliseconds msec)
Definition: SpellAuras.cpp:2201
bool CallScriptPrepareProcHandlers(AuraApplication const *aurApp, ProcEventInfo &eventInfo)
Definition: SpellAuras.cpp:2665
Milliseconds Cooldown
Definition: SpellMgr.h:301

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 ( )
1233{
1234 ASSERT (!IsRemoved());
1235 Unit* caster = GetCaster();
1236 for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
1237 if (HasEffect(i))
1238 m_effects[i]->RecalculateAmount(caster);
1239}
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
881{
882 Unit* caster = GetCaster();
883
884 if (!caster)
885 return;
886
887 if (withMods && caster)
888 {
889 int32 duration = m_spellInfo->GetMaxDuration();
890 // Calculate duration of periodics affected by haste.
892 duration = int32(duration * caster->GetFloatValue(UNIT_MOD_CAST_SPEED));
893 SetMaxDuration(duration);
894
895 SetDuration(duration);
896 }
897 else
899
902
903 // also reset periodic counters
904 for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
905 if (AuraEffect* aurEff = m_effects[i])
906 aurEff->ResetTicks();
907}
@ UNIT_MOD_CAST_SPEED
Definition: UpdateFields.h:137
@ SPELL_AURA_PERIODIC_HASTE
Definition: SpellAuraDefines.h:379
@ SPELL_ATTR5_SPELL_HASTE_AFFECTS_PERIODIC
Definition: SharedDefines.h:580
float GetFloatValue(uint16 index) const
Definition: Object.cpp:317
bool HasAuraTypeWithAffectMask(AuraType auratype, SpellInfo const *affectedSpell) const
Definition: Unit.cpp:5709
int32 GetMaxDuration() const
Definition: SpellInfo.cpp:2344

References GetCaster(), Object::GetFloatValue(), GetMaxDuration(), SpellInfo::GetMaxDuration(), SpellInfo::HasAttribute(), Unit::HasAuraTypeWithAffectMask(), IN_MILLISECONDS, m_effects, 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(), AuraScript::RefreshDuration(), RefreshTimers(), RefreshTimersWithMods(), and AuraEffect::UpdatePeriodic().

◆ RefreshSpellMods()

void Aura::RefreshSpellMods ( )
1066{
1067 for (Aura::ApplicationMap::const_iterator appIter = m_applications.begin(); appIter != m_applications.end(); ++appIter)
1068 if (Player* player = appIter->second->GetTarget()->ToPlayer())
1069 player->RestoreAllSpellMods(0, this);
1070}

References Unit::GetTarget(), and m_applications.

Referenced by ModStackAmount().

◆ RefreshTimers()

void Aura::RefreshTimers ( bool  periodicReset = false)
910{
913 Unit* caster = GetCaster();
914
915 if (!caster)
916 {
917 return;
918 }
919
920 for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
921 {
922 if (AuraEffect* aurEff = m_effects[i])
923 {
924 aurEff->CalculatePeriodic(caster, periodicReset, false);
925 aurEff->CalculatePeriodicData();
926 }
927 }
928}
void RefreshDuration(bool withMods=false)
Definition: SpellAuras.cpp:880

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

Referenced by ModStackAmount().

◆ RefreshTimersWithMods()

void Aura::RefreshTimersWithMods ( )
932{
933 Unit* caster = GetCaster();
936 {
938 }
939
940 // xinef: we should take ModSpellDuration into account, but none of the spells using this function is affected by contents of ModSpellDuration
942
943 for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
944 {
945 if (AuraEffect* aurEff = m_effects[i])
946 {
947 aurEff->CalculatePeriodic(caster, false, false);
948 }
949 }
950}

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()

◆ 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 
)
1204{
1205 m_maxDuration = maxduration;
1206 m_duration = duration;
1207 m_procCharges = charges;
1209 m_stackAmount = stackamount;
1210 Unit* caster = GetCaster();
1211 for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
1212 if (m_effects[i])
1213 {
1214 m_effects[i]->SetAmount(amount[i]);
1215 m_effects[i]->SetCanBeRecalculated(recalculateMask & (1 << i));
1216 m_effects[i]->CalculatePeriodic(caster, false, true);
1218 m_effects[i]->RecalculateAmount(caster);
1219 }
1220}
void CalculatePeriodic(Unit *caster, bool create=false, bool load=false)
Definition: SpellAuraEffects.cpp:593
void CalculateSpellMod()
Definition: SpellAuraEffects.cpp:684
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
1259{
1260 for (ApplicationMap::const_iterator appIter = m_applications.begin(); appIter != m_applications.end(); ++appIter)
1261 appIter->second->SetNeedClientUpdate();
1262}

References m_applications.

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

◆ SetStackAmount()

void Aura::SetStackAmount ( uint8  num)
996{
997 m_stackAmount = stackAmount;
998 Unit* caster = GetCaster();
999
1000 if (!caster)
1001 return;
1002
1003 std::list<AuraApplication*> applications;
1004 GetApplicationList(applications);
1005
1006 for (std::list<AuraApplication*>::const_iterator apptItr = applications.begin(); apptItr != applications.end(); ++apptItr)
1007 if (!(*apptItr)->GetRemoveMode())
1008 HandleAuraSpecificMods(*apptItr, caster, false, true);
1009
1010 for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
1011 if (HasEffect(i))
1012 m_effects[i]->ChangeAmount(m_effects[i]->CalculateAmount(caster), false, true);
1013
1014 for (std::list<AuraApplication*>::const_iterator apptItr = applications.begin(); apptItr != applications.end(); ++apptItr)
1015 if (!(*apptItr)->GetRemoveMode())
1016 HandleAuraSpecificMods(*apptItr, caster, true, true);
1017
1019}
void ChangeAmount(int32 newAmount, bool mark=true, bool onStackOrReapply=false)
Definition: SpellAuraEffects.cpp:708
void GetApplicationList(std::list< AuraApplication * > &applicationList) const
Definition: SpellAuras.cpp:1249
void HandleAuraSpecificMods(AuraApplication const *aurApp, Unit *caster, bool apply, bool onReapply)
Definition: SpellAuras.cpp:1265

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(), ModStackAmount(), Unit::SetAuraStack(), and AuraScript::SetStackAmount().

◆ SetTriggeredByAuraSpellInfo()

void Aura::SetTriggeredByAuraSpellInfo ( SpellInfo const *  triggeredByAuraSpellInfo)
2748{
2749 m_triggeredByAuraSpellInfo = triggeredByAuraSpellInfo;
2750}

References m_triggeredByAuraSpellInfo.

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

◆ SetUsingCharges()

void Aura::SetUsingCharges ( bool  val)
inline

◆ TriggerProcOnEvent()

void Aura::TriggerProcOnEvent ( AuraApplication aurApp,
ProcEventInfo eventInfo 
)
2332{
2333 CallScriptProcHandlers(aurApp, eventInfo);
2334
2335 for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
2336 if (aurApp->HasEffect(i))
2337 // OnEffectProc / AfterEffectProc hooks handled in AuraEffect::HandleProc()
2338 GetEffect(i)->HandleProc(aurApp, eventInfo);
2339
2340 CallScriptAfterProcHandlers(aurApp, eventInfo);
2341
2342 // Remove aura if we've used last charge to proc
2343 if (IsUsingCharges() && !GetCharges())
2344 Remove();
2345}
void HandleProc(AuraApplication *aurApp, ProcEventInfo &eventInfo)
Definition: SpellAuraEffects.cpp:1169
bool HasEffect(uint8 effect) const
Definition: SpellAuras.h:67
void CallScriptAfterProcHandlers(AuraApplication const *aurApp, ProcEventInfo &eventInfo)
Definition: SpellAuras.cpp:2701
bool CallScriptProcHandlers(AuraApplication const *aurApp, ProcEventInfo &eventInfo)
Definition: SpellAuras.cpp:2684

References CallScriptAfterProcHandlers(), CallScriptProcHandlers(), GetCharges(), GetEffect(), AuraEffect::HandleProc(), AuraApplication::HasEffect(), IsUsingCharges(), MAX_SPELL_EFFECTS, and Remove().

◆ 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
353{
354 ASSERT_NODEBUGINFO(spellproto);
355 ASSERT_NODEBUGINFO(owner);
356 ASSERT_NODEBUGINFO(caster || casterGUID);
357 ASSERT_NODEBUGINFO(tryEffMask <= MAX_EFFECT_MASK);
358 uint8 effMask = Aura::BuildEffectMaskForOwner(spellproto, tryEffMask, owner);
359 if (!effMask)
360 return nullptr;
361 return Create(spellproto, effMask, owner, caster, baseAmount, castItem, casterGUID, itemGUID);
362}
static uint8 BuildEffectMaskForOwner(SpellInfo const *spellProto, uint8 avalibleEffectMask, WorldObject *owner)
Definition: SpellAuras.cpp:298
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:364

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
327{
328 ASSERT_NODEBUGINFO(spellproto);
329 ASSERT_NODEBUGINFO(owner);
330 ASSERT_NODEBUGINFO(caster || casterGUID);
331 ASSERT_NODEBUGINFO(tryEffMask <= MAX_EFFECT_MASK);
332 if (refresh)
333 *refresh = false;
334 uint8 effMask = Aura::BuildEffectMaskForOwner(spellproto, tryEffMask, owner);
335 if (!effMask)
336 return nullptr;
337 if (Aura* foundAura = owner->ToUnit()->_TryStackingOrRefreshingExistingAura(spellproto, effMask, caster, baseAmount, castItem, casterGUID, periodicReset))
338 {
339 // we've here aura, which script triggered removal after modding stack amount
340 // check the state here, so we won't create new Aura object
341 if (foundAura->IsRemoved())
342 return nullptr;
343
344 if (refresh)
345 *refresh = true;
346 return foundAura;
347 }
348 else
349 return Create(spellproto, effMask, owner, caster, baseAmount, castItem, casterGUID);
350}
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:4336

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 ( )
1168{
1170 Unit* caster = GetCaster();
1171 if (!caster)
1172 {
1173 LOG_INFO("spells", "Aura::UnregisterSingleTarget: (A1) - {}, {}, {}, {}", GetId(), GetOwner()->GetTypeId(), GetOwner()->GetEntry(), GetOwner()->GetName());
1174 LOG_ERROR("spells", "Aura::UnregisterSingleTarget: No caster was found."); //ASSERT(caster);
1175 }
1176 else
1177 caster->GetSingleCastAuras().remove(this);
1178
1179 SetIsSingleTarget(false);
1180}
#define LOG_INFO(filterType__,...)
Definition: Log.h:164
bool GetName(uint32 accountId, std::string &name)
Definition: AccountMgr.cpp:257
AuraList & GetSingleCastAuras()
Definition: Unit.h:1363
void SetIsSingleTarget(bool val)
Definition: SpellAuras.h:166

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 
)
799{
800 if (m_duration > 0)
801 {
802 m_duration -= diff;
803 if (m_duration < 0)
804 m_duration = 0;
805
806 // handle ManaPerSecond/ManaPerSecondPerLevel
807 if (m_timeCla)
808 {
809 if (m_timeCla > int32(diff))
810 m_timeCla -= diff;
811 else if (caster)
812 {
813 if (int32 ManaPerSecond = m_spellInfo->ManaPerSecond + m_spellInfo->ManaPerSecondPerLevel * caster->GetLevel())
814 {
815 m_timeCla += 1000 - diff;
816
817 Powers powertype = Powers(m_spellInfo->PowerType);
818 if (powertype == POWER_HEALTH)
819 {
820 if (int32(caster->GetHealth()) > ManaPerSecond)
821 caster->ModifyHealth(-ManaPerSecond);
822 else
823 {
824 Remove();
825 return;
826 }
827 }
828 else
829 {
830 if (int32(caster->GetPower(powertype)) >= ManaPerSecond)
831 caster->ModifyPower(powertype, -ManaPerSecond);
832 else
833 {
834 Remove();
835 return;
836 }
837 }
838 }
839 }
840 }
841 }
842}
Powers
Definition: SharedDefines.h:268
@ POWER_HEALTH
Definition: SharedDefines.h:278
int32 ModifyHealth(int32 val)
Definition: Unit.cpp:14048
int32 ModifyPower(Powers power, int32 val, bool withPowerUpdate=true)
Definition: Unit.cpp:14106
uint32 GetHealth() const
Definition: Unit.h:869
uint32 GetPower(Powers power) const
Definition: Unit.h:891
uint32 PowerType
Definition: SpellInfo.h:362

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 
)
757{
758 if (owner != m_owner)
759 {
760 ABORT();
761 }
762
763 Unit* caster = GetCaster();
764 // Apply spellmods for channeled auras
765 // used for example when triggered spell of spell:10 is modded
766 Spell* modSpell = nullptr;
767 Player* modOwner = nullptr;
768 if (caster)
769 {
770 modOwner = caster->GetSpellModOwner();
771 if (modOwner)
772 {
773 modSpell = modOwner->FindCurrentSpellBySpellId(GetId());
774 if (modSpell)
775 modOwner->SetSpellModTakingSpell(modSpell, true);
776 }
777 }
778
779 Update(diff, caster);
780
781 if (m_updateTargetMapInterval <= int32(diff))
782 UpdateTargetMap(caster);
783 else
785
786 // update aura effects
787 for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
788 if (m_effects[i])
789 m_effects[i]->Update(diff, caster);
790
791 // remove spellmods after effects update
792 if (modSpell)
793 modOwner->SetSpellModTakingSpell(modSpell, false);
794
796}
void SetSpellModTakingSpell(Spell *spell, bool apply)
Definition: Player.cpp:10077
Spell * FindCurrentSpellBySpellId(uint32 spell_id) const
Definition: Unit.cpp:4126
void Update(uint32 diff, Unit *caster)
Definition: SpellAuraEffects.cpp:897
void Update(uint32 diff, Unit *caster)
Definition: SpellAuras.cpp:798
Definition: Spell.h:284

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 Unit::_UpdateSpells(), and DynamicObject::Update().

◆ UpdateTargetMap()

void Aura::UpdateTargetMap ( Unit caster,
bool  apply = true 
)
589{
590 if (IsRemoved())
591 return;
592
594
595 // fill up to date target list
596 // target, effMask
597 std::map<Unit*, uint8> targets;
598
599 FillTargetMap(targets, caster);
600
601 UnitList targetsToRemove;
602
603 // mark all auras as ready to remove
604 for (ApplicationMap::iterator appIter = m_applications.begin(); appIter != m_applications.end(); ++appIter)
605 {
606 std::map<Unit*, uint8>::iterator existing = targets.find(appIter->second->GetTarget());
607 // not found in current area - remove the aura
608 if (existing == targets.end())
609 targetsToRemove.push_back(appIter->second->GetTarget());
610 else
611 {
612 // xinef: check immunities here, so aura wont get removed on every tick and then reapplied
613 if (IsArea())
614 for (uint8 effIndex = 0; effIndex < MAX_SPELL_EFFECTS; ++effIndex)
615 {
616 if ((existing->second & (1 << effIndex)) && existing->first->IsImmunedToSpellEffect(GetSpellInfo(), effIndex))
617 existing->second &= ~(1 << effIndex);
618 }
619
620 // needs readding - remove now, will be applied in next update cycle
621 // (dbcs do not have auras which apply on same type of targets but have different radius, so this is not really needed)
622 if (appIter->second->GetEffectMask() != existing->second || !CanBeAppliedOn(existing->first))
623 targetsToRemove.push_back(appIter->second->GetTarget());
624 // nothing todo - aura already applied
625 // remove from auras to register list
626 targets.erase(existing);
627 }
628 }
629
630 // register auras for units
631 for (std::map<Unit*, uint8>::iterator itr = targets.begin(); itr != targets.end();)
632 {
633 // aura mustn't be already applied on target
634 if (AuraApplication* aurApp = GetApplicationOfTarget(itr->first->GetGUID()))
635 {
636 // the core created 2 different units with same guid
637 // this is a major failue, which i can't fix right now
638 // let's remove one unit from aura list
639 // this may cause area aura "bouncing" between 2 units after each update
640 // but because we know the reason of a crash we can remove the assertion for now
641 if (aurApp->GetTarget() != itr->first)
642 {
643 // remove from auras to register list
644 targets.erase(itr++);
645 continue;
646 }
647 else
648 {
649 // ok, we have one unit twice in target map (impossible, but...)
650 ABORT();
651 }
652 }
653
654 bool addUnit = true;
655 // check target immunities
656 for (uint8 effIndex = 0; effIndex < MAX_SPELL_EFFECTS; ++effIndex)
657 {
658 if ((itr->second & (1 << effIndex)) && itr->first->IsImmunedToSpellEffect(GetSpellInfo(), effIndex))
659 itr->second &= ~(1 << effIndex);
660 }
661 if (!itr->second || itr->first->IsImmunedToSpell(GetSpellInfo()) || !CanBeAppliedOn(itr->first))
662 addUnit = false;
663
664 if (addUnit)
665 {
666 // persistent area aura does not hit flying targets
667 if (GetType() == DYNOBJ_AURA_TYPE)
668 {
669 if (itr->first->IsInFlight())
670 addUnit = false;
671
672 // Allow only 1 persistent area aura to affect our targets if a custom flag is set.
673 if (itr->first->HasAura(GetId()) && GetSpellInfo()->HasAttribute(SPELL_ATTR0_CU_ONLY_ONE_AREA_AURA))
674 addUnit = false;
675 }
676 // unit auras can not stack with each other
677 else // (GetType() == UNIT_AURA_TYPE)
678 {
679 // Allow to remove by stack when aura is going to be applied on owner
680 if (itr->first != GetOwner())
681 {
682 // check if not stacking aura already on target
683 // this one prevents unwanted usefull buff loss because of stacking and prevents overriding auras periodicaly by 2 near area aura owners
684 for (Unit::AuraApplicationMap::iterator iter = itr->first->GetAppliedAuras().begin(); iter != itr->first->GetAppliedAuras().end(); ++iter)
685 {
686 Aura const* aura = iter->second->GetBase();
687 if (!CanStackWith(aura, false))
688 {
689 addUnit = false;
690 break;
691 }
692 }
693 }
694 }
695 }
696 if (!addUnit)
697 targets.erase(itr++);
698 else
699 {
700 // owner has to be in world, or effect has to be applied to self
701 if (!GetOwner()->IsSelfOrInSameMap(itr->first))
702 {
703 //TODO: There is a crash caused by shadowfiend load addon
704 LOG_FATAL("spells.aura", "Aura {}: Owner {} (map {}) is not in the same map as target {} (map {}).", GetSpellInfo()->Id,
705 GetOwner()->GetName(), GetOwner()->IsInWorld() ? GetOwner()->GetMap()->GetId() : uint32(-1),
706 itr->first->GetName(), itr->first->IsInWorld() ? itr->first->GetMap()->GetId() : uint32(-1));
707 ABORT();
708 }
709 itr->first->_CreateAuraApplication(this, itr->second);
710 ++itr;
711 }
712 }
713
714 // remove auras from units no longer needing them
715 for (UnitList::iterator itr = targetsToRemove.begin(); itr != targetsToRemove.end(); ++itr)
716 if (AuraApplication* aurApp = GetApplicationOfTarget((*itr)->GetGUID()))
717 (*itr)->_UnapplyAura(aurApp, AURA_REMOVE_BY_DEFAULT);
718
719 if (!apply)
720 return;
721
722 // apply aura effects for units
723 for (std::map<Unit*, uint8>::iterator itr = targets.begin(); itr != targets.end(); ++itr)
724 {
725 if (AuraApplication* aurApp = GetApplicationOfTarget(itr->first->GetGUID()))
726 {
727 // owner has to be in world, or effect has to be applied to self
728 ASSERT((!GetOwner()->IsInWorld() && GetOwner() == itr->first) || GetOwner()->IsInMap(itr->first));
729 itr->first->_ApplyAura(aurApp, itr->second);
730 }
731 }
732}
#define LOG_FATAL(filterType__,...)
Definition: Log.h:152
@ AURA_REMOVE_BY_DEFAULT
Definition: SpellAuraDefines.h:392
static constexpr int32 UPDATE_TARGET_MAP_INTERVAL
Definition: SpellAuras.cpp:45
@ SPELL_ATTR0_CU_ONLY_ONE_AREA_AURA
Definition: SpellInfo.h:206
bool IsSelfOrInSameMap(WorldObject const *obj) const
Definition: Object.cpp:1275
virtual void FillTargetMap(std::map< Unit *, uint8 > &targets, Unit *caster)=0
bool CanStackWith(Aura const *checkAura, bool remove) const
Definition: SpellAuras.cpp:2021
bool CanBeAppliedOn(Unit *target)
Definition: SpellAuras.cpp:1970

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

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

Friends And Related Function 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_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().