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:55
@ SPELL_ATTR2_NO_TARGET_PER_SECOND_COST
Definition: SharedDefines.h:467
Seconds GetGameTime()
Definition: GameTime.cpp:38
uint32 GetEntry() const
Definition: Object.h:109
static ObjectGuid GetGUID(Object const *o)
Definition: Object.h:106
static ObjectGuid const Empty
Definition: ObjectGuid.h:122
uint8 GetLevel() const
Definition: Unit.h:1432
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:358
uint32 ManaPerSecondPerLevel
Definition: SpellInfo.h:364
uint32 ManaPerSecond
Definition: SpellInfo.h:363
bool HasAttribute(SpellAttr0 attribute) const
Definition: SpellInfo.h:412

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}
#define ASSERT
Definition: Errors.h:68
std::uint8_t uint8
Definition: Define.h:110
#define MAX_SPELL_EFFECTS
Definition: DBCStructure.h:1635
std::list< AuraScript * > m_loadedScripts
Definition: SpellAuras.h:238
ApplicationMap m_applications
Definition: SpellAuras.h:266
void _DeleteRemovedApplications()
Definition: SpellAuras.cpp:2361

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

Member Function Documentation

◆ _ApplyEffectForTargets()

void Aura::_ApplyEffectForTargets ( uint8  effIndex)
750{
751 // prepare list of aura targets
752 UnitList targetList;
753 for (ApplicationMap::iterator appIter = m_applications.begin(); appIter != m_applications.end(); ++appIter)
754 {
755 if ((appIter->second->GetEffectsToApply() & (1 << effIndex)) && !appIter->second->HasEffect(effIndex))
756 targetList.push_back(appIter->second->GetTarget());
757 }
758
759 // apply effect to targets
760 for (UnitList::iterator itr = targetList.begin(); itr != targetList.end(); ++itr)
761 {
762 if (GetApplicationOfTarget((*itr)->GetGUID()))
763 {
764 // owner has to be in world, or effect has to be applied to self
765 ASSERT((!GetOwner()->IsInWorld() && GetOwner() == *itr) || GetOwner()->IsInMap(*itr));
766 (*itr)->_ApplyAuraEffect(this, effIndex);
767 }
768 }
769}
std::list< Unit * > UnitList
Definition: Unit.h:240
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:154
void AddSpellCooldown(uint32 spell_id, uint32, uint32 end_time, bool needSendToClient=false, bool forceSendToSpectator=false) override
Definition: Creature.cpp:2781
bool IsPlayer() const
Definition: Object.h:194
Player * ToPlayer()
Definition: Object.h:195
Creature * ToCreature()
Definition: Object.h:197
void AddSpellAndCategoryCooldowns(SpellInfo const *spellInfo, uint32 itemId, Spell *spell=nullptr, bool infinityCooldown=false)
Definition: Player.cpp:10826
bool IsAppliedOnTarget(ObjectGuid guid) const
Definition: SpellAuras.h:185
bool IsCooldownStartedOnEvent() const
Definition: SpellInfo.cpp:1199
uint32 Id
Definition: SpellInfo.h:318

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
2362{
2363 while (!m_removedApplications.empty())
2364 {
2365 delete m_removedApplications.front();
2366 m_removedApplications.pop_front();
2367 }
2368}
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:1302
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:4510
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->GetTypeId() == TYPEID_PLAYER)
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 ABORT
Definition: Errors.h:76
std::uint32_t uint32
Definition: Define.h:108
#define LOG_ERROR(filterType__,...)
Definition: Log.h:157
@ TYPEID_PLAYER
Definition: ObjectGuid.h:38
@ SMSG_COOLDOWN_EVENT
Definition: Opcodes.h:339
TypeID GetTypeId() const
Definition: Object.h:121
std::string ToString() const
Definition: ObjectGuid.cpp:47
Definition: Player.h:1056
void SendCooldownEvent(SpellInfo const *spellInfo, uint32 itemId=0, Spell *spell=nullptr, bool setCooldown=true)
Definition: Player.cpp:11024
Unit * GetCharmerOrOwner() const
Definition: Unit.h:1861
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(), Object::GetTypeId(), 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(), ObjectGuid::ToString(), and TYPEID_PLAYER.

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

◆ AddProcCooldown()

void Aura::AddProcCooldown ( Milliseconds  msec)
2216{
2217 //m_procCooldown = std:chrono::steady_clock::now() + msec;
2218}

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:40
@ TYPEID_UNIT
Definition: ObjectGuid.h:37
@ SPELL_EFFECT_PERSISTENT_AREA_AURA
Definition: SharedDefines.h:805

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
1197{
1198 // we assume that aura dispel chance is 100% on start
1199 // need formula for level difference based chance
1200 int32 resistChance = 0;
1201
1202 // Apply dispel mod from aura caster
1203 if (Unit* caster = GetCaster())
1204 if (Player* modOwner = caster->GetSpellModOwner())
1205 modOwner->ApplySpellMod(GetId(), SPELLMOD_RESIST_DISPEL_CHANCE, resistChance);
1206
1207 // Dispel resistance from target SPELL_AURA_MOD_DISPEL_RESIST
1208 // Only affects offensive dispels
1209 if (offensive && auraTarget)
1210 resistChance += auraTarget->GetTotalAuraModifier(SPELL_AURA_MOD_DISPEL_RESIST);
1211
1212 resistChance = resistChance < 0 ? 0 : resistChance;
1213 resistChance = resistChance > 100 ? 100 : resistChance;
1214 return 100 - resistChance;
1215}
std::int32_t int32
Definition: Define.h:104
@ SPELL_AURA_MOD_DISPEL_RESIST
Definition: SpellAuraDefines.h:298
@ SPELLMOD_RESIST_DISPEL_CHANCE
Definition: SpellDefines.h:105
Player * GetSpellModOwner() const
Definition: Unit.cpp:16845
int32 GetTotalAuraModifier(AuraType auratype) const
Definition: Unit.cpp:5848
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
976{
977 uint32 maxProcCharges = m_spellInfo->ProcCharges;
978 if (SpellProcEntry const* procEntry = sSpellMgr->GetSpellProcEntry(GetId()))
979 maxProcCharges = procEntry->Charges;
980
981 if (caster)
982 if (Player* modOwner = caster->GetSpellModOwner())
983 modOwner->ApplySpellMod(GetId(), SPELLMOD_CHARGES, maxProcCharges);
984 return maxProcCharges;
985}
@ SPELLMOD_CHARGES
Definition: SpellDefines.h:81
#define sSpellMgr
Definition: SpellMgr.h:825
uint32 ProcCharges
Definition: SpellInfo.h:355
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
859{
860 Player* modOwner = nullptr;
861 int32 maxDuration;
862
863 if (caster)
864 {
865 modOwner = caster->GetSpellModOwner();
866 maxDuration = caster->CalcSpellDuration(m_spellInfo);
867 }
868 else
869 maxDuration = m_spellInfo->GetDuration();
870
872 maxDuration = -1;
873
874 sScriptMgr->OnCalcMaxDuration(this, maxDuration);
875
876 // IsPermanent() checks max duration (which we are supposed to calculate here)
877 if (maxDuration != -1 && modOwner)
878 modOwner->ApplySpellMod(GetId(), SPELLMOD_DURATION, maxDuration);
879 return maxDuration;
880}
#define sScriptMgr
Definition: ScriptMgr.h:698
@ SPELLMOD_DURATION
Definition: SpellDefines.h:78
void ApplySpellMod(uint32 spellId, SpellModOp op, T &basevalue, Spell *spell=nullptr, bool temporaryPet=false)
Definition: Player.cpp:9648
int32 CalcSpellDuration(SpellInfo const *spellProto)
Definition: Unit.cpp:14842
bool IsPassive() const
Definition: SpellAuras.cpp:1096
SpellDurationEntry const * DurationEntry
Definition: SpellInfo.h:359
int32 GetDuration() const
Definition: SpellInfo.cpp:2324

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
2326{
2327 float chance = procEntry.Chance;
2328 // calculate chances depending on unit with caster's data
2329 // so talents modifying chances and judgements will have properly calculated proc chance
2330 if (Unit* caster = GetCaster())
2331 {
2332 // calculate ppm chance if present and we're using weapon
2333 if (eventInfo.GetDamageInfo() && procEntry.ProcsPerMinute != 0)
2334 {
2335 uint32 WeaponSpeed = caster->GetAttackTime(eventInfo.GetDamageInfo()->GetAttackType());
2336 chance = caster->GetPPMProcChance(WeaponSpeed, procEntry.ProcsPerMinute, GetSpellInfo());
2337 }
2338 // apply chance modifer aura, applies also to ppm chance (see improved judgement of light spell)
2339 if (Player* modOwner = caster->GetSpellModOwner())
2340 modOwner->ApplySpellMod(GetId(), SPELLMOD_CHANCE_OF_SUCCESS, chance);
2341 }
2342 return chance;
2343}
@ SPELLMOD_CHANCE_OF_SUCCESS
Definition: SpellDefines.h:95
WeaponAttackType GetAttackType() const
Definition: Unit.h:794
DamageInfo * GetDamageInfo() const
Definition: Unit.h:880

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 
)
2664{
2665 bool result = isTriggeredAtSpellProcEvent;
2666 for (std::list<AuraScript*>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
2667 {
2668 (*scritr)->_PrepareScriptCall(AURA_SCRIPT_HOOK_AFTER_CHECK_PROC, aurApp);
2669 std::list<AuraScript::AfterCheckProcHandler>::iterator hookItrEnd = (*scritr)->DoAfterCheckProc.end(), hookItr = (*scritr)->DoAfterCheckProc.begin();
2670 for (; hookItr != hookItrEnd; ++hookItr)
2671 result &= hookItr->Call(*scritr, eventInfo, isTriggeredAtSpellProcEvent);
2672
2673 (*scritr)->_FinishScriptCall();
2674 }
2675
2676 return result;
2677}
@ 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)
2418{
2419 for (std::list<AuraScript*>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
2420 {
2421 (*scritr)->_PrepareScriptCall(AURA_SCRIPT_HOOK_AFTER_DISPEL);
2422 std::list<AuraScript::AuraDispelHandler>::iterator hookItrEnd = (*scritr)->AfterDispel.end(), hookItr = (*scritr)->AfterDispel.begin();
2423 for (; hookItr != hookItrEnd; ++hookItr)
2424 hookItr->Call(*scritr, dispelInfo);
2425
2426 (*scritr)->_FinishScriptCall();
2427 }
2428}
@ 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 
)
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_APPLY, aurApp);
2474 std::list<AuraScript::EffectApplyHandler>::iterator effEndItr = (*scritr)->AfterEffectApply.end(), effItr = (*scritr)->AfterEffectApply.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_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 
)
2748{
2749 for (std::list<AuraScript*>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
2750 {
2751 (*scritr)->_PrepareScriptCall(AURA_SCRIPT_HOOK_EFFECT_AFTER_PROC, aurApp);
2752 std::list<AuraScript::EffectProcHandler>::iterator effEndItr = (*scritr)->AfterEffectProc.end(), effItr = (*scritr)->AfterEffectProc.begin();
2753 for (; effItr != effEndItr; ++effItr)
2754 if (effItr->IsEffectAffected(m_spellInfo, aurEff->GetEffIndex()))
2755 effItr->Call(*scritr, aurEff, eventInfo);
2756
2757 (*scritr)->_FinishScriptCall();
2758 }
2759}
@ 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 
)
2484{
2485 for (std::list<AuraScript*>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
2486 {
2487 (*scritr)->_PrepareScriptCall(AURA_SCRIPT_HOOK_EFFECT_AFTER_REMOVE, aurApp);
2488 std::list<AuraScript::EffectApplyHandler>::iterator effEndItr = (*scritr)->AfterEffectRemove.end(), effItr = (*scritr)->AfterEffectRemove.begin();
2489 for (; effItr != effEndItr; ++effItr)
2490 if (effItr->IsEffectAffected(m_spellInfo, aurEff->GetEffIndex()))
2491 effItr->Call(*scritr, aurEff, mode);
2492
2493 (*scritr)->_FinishScriptCall();
2494 }
2495}
@ 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 
)
2716{
2717 for (std::list<AuraScript*>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
2718 {
2719 (*scritr)->_PrepareScriptCall(AURA_SCRIPT_HOOK_AFTER_PROC, aurApp);
2720 std::list<AuraScript::AuraProcHandler>::iterator hookItrEnd = (*scritr)->AfterProc.end(), hookItr = (*scritr)->AfterProc.begin();
2721 for (; hookItr != hookItrEnd; ++hookItr)
2722 hookItr->Call(*scritr, eventInfo);
2723
2724 (*scritr)->_FinishScriptCall();
2725 }
2726}
@ 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)
2390{
2391 bool result = true;
2392 for (std::list<AuraScript*>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
2393 {
2394 (*scritr)->_PrepareScriptCall(AURA_SCRIPT_HOOK_CHECK_AREA_TARGET);
2395 std::list<AuraScript::CheckAreaTargetHandler>::iterator hookItrEnd = (*scritr)->DoCheckAreaTarget.end(), hookItr = (*scritr)->DoCheckAreaTarget.begin();
2396 for (; hookItr != hookItrEnd; ++hookItr)
2397 result &= hookItr->Call(*scritr, target);
2398
2399 (*scritr)->_FinishScriptCall();
2400 }
2401 return result;
2402}
@ 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 
)
2648{
2649 bool result = true;
2650 for (std::list<AuraScript*>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
2651 {
2652 (*scritr)->_PrepareScriptCall(AURA_SCRIPT_HOOK_CHECK_PROC, aurApp);
2653 std::list<AuraScript::CheckProcHandler>::iterator hookItrEnd = (*scritr)->DoCheckProc.end(), hookItr = (*scritr)->DoCheckProc.begin();
2654 for (; hookItr != hookItrEnd; ++hookItr)
2655 result &= hookItr->Call(*scritr, eventInfo);
2656
2657 (*scritr)->_FinishScriptCall();
2658 }
2659
2660 return result;
2661}
@ 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)
2405{
2406 for (std::list<AuraScript*>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
2407 {
2408 (*scritr)->_PrepareScriptCall(AURA_SCRIPT_HOOK_DISPEL);
2409 std::list<AuraScript::AuraDispelHandler>::iterator hookItrEnd = (*scritr)->OnDispel.end(), hookItr = (*scritr)->OnDispel.begin();
2410 for (; hookItr != hookItrEnd; ++hookItr)
2411 hookItr->Call(*scritr, dispelInfo);
2412
2413 (*scritr)->_FinishScriptCall();
2414 }
2415}
@ 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 
)
2574{
2575 for (std::list<AuraScript*>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
2576 {
2577 (*scritr)->_PrepareScriptCall(AURA_SCRIPT_HOOK_EFFECT_ABSORB, aurApp);
2578 std::list<AuraScript::EffectAbsorbHandler>::iterator effEndItr = (*scritr)->OnEffectAbsorb.end(), effItr = (*scritr)->OnEffectAbsorb.begin();
2579 for (; effItr != effEndItr; ++effItr)
2580
2581 if (effItr->IsEffectAffected(m_spellInfo, aurEff->GetEffIndex()))
2582 effItr->Call(*scritr, aurEff, dmgInfo, absorbAmount);
2583
2584 if (!defaultPrevented)
2585 defaultPrevented = (*scritr)->_IsDefaultActionPrevented();
2586
2587 (*scritr)->_FinishScriptCall();
2588 }
2589}
@ 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 
)
2592{
2593 for (std::list<AuraScript*>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
2594 {
2595 (*scritr)->_PrepareScriptCall(AURA_SCRIPT_HOOK_EFFECT_AFTER_ABSORB, aurApp);
2596 std::list<AuraScript::EffectAbsorbHandler>::iterator effEndItr = (*scritr)->AfterEffectAbsorb.end(), effItr = (*scritr)->AfterEffectAbsorb.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_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 
)
2620{
2621 for (std::list<AuraScript*>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
2622 {
2623 (*scritr)->_PrepareScriptCall(AURA_SCRIPT_HOOK_EFFECT_AFTER_MANASHIELD, aurApp);
2624 std::list<AuraScript::EffectManaShieldHandler>::iterator effEndItr = (*scritr)->AfterEffectManaShield.end(), effItr = (*scritr)->AfterEffectManaShield.begin();
2625 for (; effItr != effEndItr; ++effItr)
2626 if (effItr->IsEffectAffected(m_spellInfo, aurEff->GetEffIndex()))
2627 effItr->Call(*scritr, aurEff, dmgInfo, absorbAmount);
2628
2629 (*scritr)->_FinishScriptCall();
2630 }
2631}
@ 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 
)
2431{
2432 bool preventDefault = false;
2433 for (std::list<AuraScript*>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
2434 {
2435 (*scritr)->_PrepareScriptCall(AURA_SCRIPT_HOOK_EFFECT_APPLY, aurApp);
2436 std::list<AuraScript::EffectApplyHandler>::iterator effEndItr = (*scritr)->OnEffectApply.end(), effItr = (*scritr)->OnEffectApply.begin();
2437 for (; effItr != effEndItr; ++effItr)
2438 if (effItr->IsEffectAffected(m_spellInfo, aurEff->GetEffIndex()))
2439 effItr->Call(*scritr, aurEff, mode);
2440
2441 if (!preventDefault)
2442 preventDefault = (*scritr)->_IsDefaultActionPrevented();
2443
2444 (*scritr)->_FinishScriptCall();
2445 }
2446
2447 return preventDefault;
2448}
@ 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 
)
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_AMOUNT);
2536 std::list<AuraScript::EffectCalcAmountHandler>::iterator effEndItr = (*scritr)->DoEffectCalcAmount.end(), effItr = (*scritr)->DoEffectCalcAmount.begin();
2537 for (; effItr != effEndItr; ++effItr)
2538 if (effItr->IsEffectAffected(m_spellInfo, aurEff->GetEffIndex()))
2539 effItr->Call(*scritr, aurEff, amount, canBeRecalculated);
2540
2541 (*scritr)->_FinishScriptCall();
2542 }
2543}
@ 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 
)
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_PERIODIC);
2550 std::list<AuraScript::EffectCalcPeriodicHandler>::iterator effEndItr = (*scritr)->DoEffectCalcPeriodic.end(), effItr = (*scritr)->DoEffectCalcPeriodic.begin();
2551 for (; effItr != effEndItr; ++effItr)
2552 if (effItr->IsEffectAffected(m_spellInfo, aurEff->GetEffIndex()))
2553 effItr->Call(*scritr, aurEff, isPeriodic, amplitude);
2554
2555 (*scritr)->_FinishScriptCall();
2556 }
2557}
@ 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 
)
2560{
2561 for (std::list<AuraScript*>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
2562 {
2563 (*scritr)->_PrepareScriptCall(AURA_SCRIPT_HOOK_EFFECT_CALC_SPELLMOD);
2564 std::list<AuraScript::EffectCalcSpellModHandler>::iterator effEndItr = (*scritr)->DoEffectCalcSpellMod.end(), effItr = (*scritr)->DoEffectCalcSpellMod.begin();
2565 for (; effItr != effEndItr; ++effItr)
2566 if (effItr->IsEffectAffected(m_spellInfo, aurEff->GetEffIndex()))
2567 effItr->Call(*scritr, aurEff, spellMod);
2568
2569 (*scritr)->_FinishScriptCall();
2570 }
2571}
@ 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 
)
2606{
2607 for (std::list<AuraScript*>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
2608 {
2609 (*scritr)->_PrepareScriptCall(AURA_SCRIPT_HOOK_EFFECT_MANASHIELD, aurApp);
2610 std::list<AuraScript::EffectManaShieldHandler>::iterator effEndItr = (*scritr)->OnEffectManaShield.end(), effItr = (*scritr)->OnEffectManaShield.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_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 
)
2498{
2499 bool preventDefault = false;
2500 for (std::list<AuraScript*>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
2501 {
2502 (*scritr)->_PrepareScriptCall(AURA_SCRIPT_HOOK_EFFECT_PERIODIC, aurApp);
2503 std::list<AuraScript::EffectPeriodicHandler>::iterator effEndItr = (*scritr)->OnEffectPeriodic.end(), effItr = (*scritr)->OnEffectPeriodic.begin();
2504 for (; effItr != effEndItr; ++effItr)
2505 if (effItr->IsEffectAffected(m_spellInfo, aurEff->GetEffIndex()))
2506 effItr->Call(*scritr, aurEff);
2507
2508 if (!preventDefault)
2509 preventDefault = (*scritr)->_IsDefaultActionPrevented();
2510
2511 (*scritr)->_FinishScriptCall();
2512 }
2513
2514 return preventDefault;
2515}
@ 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 
)
2729{
2730 bool preventDefault = false;
2731 for (std::list<AuraScript*>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
2732 {
2733 (*scritr)->_PrepareScriptCall(AURA_SCRIPT_HOOK_EFFECT_PROC, aurApp);
2734 std::list<AuraScript::EffectProcHandler>::iterator effEndItr = (*scritr)->OnEffectProc.end(), effItr = (*scritr)->OnEffectProc.begin();
2735 for (; effItr != effEndItr; ++effItr)
2736 if (effItr->IsEffectAffected(m_spellInfo, aurEff->GetEffIndex()))
2737 effItr->Call(*scritr, aurEff, eventInfo);
2738
2739 if (!preventDefault)
2740 preventDefault = (*scritr)->_IsDefaultActionPrevented();
2741
2742 (*scritr)->_FinishScriptCall();
2743 }
2744 return preventDefault;
2745}
@ 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 
)
2451{
2452 bool preventDefault = false;
2453 for (std::list<AuraScript*>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
2454 {
2455 (*scritr)->_PrepareScriptCall(AURA_SCRIPT_HOOK_EFFECT_REMOVE, aurApp);
2456 std::list<AuraScript::EffectApplyHandler>::iterator effEndItr = (*scritr)->OnEffectRemove.end(), effItr = (*scritr)->OnEffectRemove.begin();
2457 for (; effItr != effEndItr; ++effItr)
2458 if (effItr->IsEffectAffected(m_spellInfo, aurEff->GetEffIndex()))
2459 effItr->Call(*scritr, aurEff, mode);
2460
2461 if (!preventDefault)
2462 preventDefault = (*scritr)->_IsDefaultActionPrevented();
2463
2464 (*scritr)->_FinishScriptCall();
2465 }
2466 return preventDefault;
2467}
@ 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 
)
2634{
2635 for (std::list<AuraScript*>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
2636 {
2637 (*scritr)->_PrepareScriptCall(AURA_SCRIPT_HOOK_EFFECT_SPLIT, aurApp);
2638 std::list<AuraScript::EffectSplitHandler>::iterator effEndItr = (*scritr)->OnEffectSplit.end(), effItr = (*scritr)->OnEffectSplit.begin();
2639 for (; effItr != effEndItr; ++effItr)
2640 if (effItr->IsEffectAffected(m_spellInfo, aurEff->GetEffIndex()))
2641 effItr->Call(*scritr, aurEff, dmgInfo, splitAmount);
2642
2643 (*scritr)->_FinishScriptCall();
2644 }
2645}
@ 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)
2518{
2519 for (std::list<AuraScript*>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
2520 {
2521 (*scritr)->_PrepareScriptCall(AURA_SCRIPT_HOOK_EFFECT_UPDATE_PERIODIC);
2522 std::list<AuraScript::EffectUpdatePeriodicHandler>::iterator effEndItr = (*scritr)->OnEffectUpdatePeriodic.end(), effItr = (*scritr)->OnEffectUpdatePeriodic.begin();
2523 for (; effItr != effEndItr; ++effItr)
2524 if (effItr->IsEffectAffected(m_spellInfo, aurEff->GetEffIndex()))
2525 effItr->Call(*scritr, aurEff);
2526
2527 (*scritr)->_FinishScriptCall();
2528 }
2529}
@ 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 
)
2680{
2681 bool prepare = true;
2682 for (std::list<AuraScript*>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
2683 {
2684 (*scritr)->_PrepareScriptCall(AURA_SCRIPT_HOOK_PREPARE_PROC, aurApp);
2685 std::list<AuraScript::AuraProcHandler>::iterator effEndItr = (*scritr)->DoPrepareProc.end(), effItr = (*scritr)->DoPrepareProc.begin();
2686 for (; effItr != effEndItr; ++effItr)
2687 effItr->Call(*scritr, eventInfo);
2688
2689 if (prepare)
2690 prepare = !(*scritr)->_IsDefaultActionPrevented();
2691
2692 (*scritr)->_FinishScriptCall();
2693 }
2694
2695 return prepare;
2696}
@ 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 
)
2699{
2700 bool handled = false;
2701 for (std::list<AuraScript*>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
2702 {
2703 (*scritr)->_PrepareScriptCall(AURA_SCRIPT_HOOK_PROC, aurApp);
2704 std::list<AuraScript::AuraProcHandler>::iterator hookItrEnd = (*scritr)->OnProc.end(), hookItr = (*scritr)->OnProc.begin();
2705 for (; hookItr != hookItrEnd; ++hookItr)
2706 hookItr->Call(*scritr, eventInfo);
2707
2708 handled |= (*scritr)->_IsDefaultActionPrevented();
2709 (*scritr)->_FinishScriptCall();
2710 }
2711
2712 return handled;
2713}
@ 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)
1985{
1986 // unit not in world or during remove from world
1987 if (!target->IsInWorld() || target->IsDuringRemoveFromWorld())
1988 {
1989 // area auras mustn't be applied
1990 if (GetOwner() != target)
1991 return false;
1992 // not selfcasted single target auras mustn't be applied
1993 if (GetCasterGUID() != GetOwner()->GetGUID() && GetSpellInfo()->IsSingleTarget())
1994 return false;
1995 return true;
1996 }
1997 else
1998 return CheckAreaTarget(target);
1999}
bool IsInWorld() const
Definition: Object.h:101
bool IsDuringRemoveFromWorld() const
Definition: Unit.h:2410
bool CheckAreaTarget(Unit *target)
Definition: SpellAuras.cpp:2001
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
1112{
1113 SpellInfo const* spellInfo = GetSpellInfo();
1114
1116 {
1117 return true;
1118 }
1119
1121 {
1122 return false;
1123 }
1124
1125 if (IsPassive() || (spellInfo->HasAttribute(SPELL_ATTR0_DO_NOT_DISPLAY) && spellInfo->Stances))
1126 {
1127 return false;
1128 }
1129
1130 // Xinef: do not save channel auras
1131 if (GetSpellInfo()->IsChanneled())
1132 {
1133 return false;
1134 }
1135
1136 // Xinef: Check if aura is single target, not only spell info
1137 if (GetCasterGUID() != GetOwner()->GetGUID() && (GetSpellInfo()->IsSingleTarget() || IsSingleTarget()))
1138 {
1139 return false;
1140 }
1141
1142 // don't save auras removed by proc system
1143 if (IsUsingCharges() && !GetCharges())
1144 {
1145 return false;
1146 }
1147
1148 return true;
1149}
@ 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:314
uint32 Stances
Definition: SpellInfo.h:331

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
1152{
1154}
@ SPELL_AURA_ABILITY_IGNORE_AURASTATE
Definition: SpellAuraDefines.h:325
bool HasEffectType(AuraType type) const
Definition: SpellAuras.cpp:1236
bool HasAreaAuraEffect() const
Definition: SpellInfo.cpp:896

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
2036{
2037 // Can stack with self
2038 if (this == existingAura)
2039 return true;
2040
2041 SpellInfo const* existingSpellInfo = existingAura->GetSpellInfo();
2042 bool sameCaster = GetCasterGUID() == existingAura->GetCasterGUID();
2043
2044 // Dynobj auras always stack
2045 // xinef: dont allow different ranks (or the same rank) of same spell to stack (many flamestrikes for example)
2046 if (existingAura->GetType() == DYNOBJ_AURA_TYPE)
2047 {
2048 // xinef: desecration lag fix - bound this condition to periodics
2049 if (sameCaster && GetSpellInfo()->Id == existingSpellInfo->Id && GetSpellInfo()->HasAura(SPELL_AURA_PERIODIC_DAMAGE))
2050 return false;
2051 return true;
2052 }
2053
2054 // passive auras don't stack with another rank of the spell cast by same caster
2055 if (IsPassive() && sameCaster && (m_spellInfo->IsDifferentRankOf(existingSpellInfo) || (m_spellInfo->Id == existingSpellInfo->Id && m_castItemGuid.IsEmpty())))
2056 return false;
2057
2058 for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
2059 {
2060 // prevent remove triggering aura by triggered aura
2061 if (existingSpellInfo->Effects[i].TriggerSpell == GetId()
2062 // prevent remove triggered aura by triggering aura refresh
2063 || m_spellInfo->Effects[i].TriggerSpell == existingAura->GetId())
2064 return true;
2065 }
2066
2067 // check spell specific stack rules
2068 if (m_spellInfo->IsAuraExclusiveBySpecificWith(existingSpellInfo)
2069 || (sameCaster && m_spellInfo->IsAuraExclusiveBySpecificPerCasterWith(existingSpellInfo)))
2070 return false;
2071
2072 // check spell group stack rules
2073 // xinef: this assures us that both spells are in same group!
2074 SpellGroupStackFlags stackFlags = sSpellMgr->CheckSpellGroupStackRules(m_spellInfo, existingSpellInfo, remove, IsArea());
2075 if (stackFlags)
2076 {
2077 // xinef: same caster rule is bounded by spellfamily
2078 if (sameCaster && m_spellInfo->SpellFamilyName == existingSpellInfo->SpellFamilyName &&
2080 return false;
2081
2082 // xinef: normal exclusive stacking, remove if auras are equal by effects
2083 if (stackFlags & SPELL_GROUP_STACK_FLAG_EXCLUSIVE)
2084 {
2085 if (GetSpellInfo()->IsAuraEffectEqual(existingSpellInfo) || GetSpellInfo()->IsRankOf(existingSpellInfo))
2086 {
2087 if (remove)
2088 return IsAuraStronger(existingAura);
2089 else
2090 return existingAura->IsAuraStronger(this);
2091 }
2092 }
2093
2094 // xinef: check priority before effect mask
2095 SpellGroupSpecialFlags thisAuraFlag = sSpellMgr->GetSpellGroupSpecialFlags(GetId());
2096 SpellGroupSpecialFlags existingAuraFlag = sSpellMgr->GetSpellGroupSpecialFlags(existingSpellInfo->Id);
2097 if (thisAuraFlag >= SPELL_GROUP_SPECIAL_FLAG_PRIORITY1 && thisAuraFlag <= SPELL_GROUP_SPECIAL_FLAG_PRIORITY4 &&
2098 existingAuraFlag >= SPELL_GROUP_SPECIAL_FLAG_PRIORITY1 && existingAuraFlag <= SPELL_GROUP_SPECIAL_FLAG_PRIORITY4)
2099 {
2100 if (thisAuraFlag < existingAuraFlag)
2101 {
2102 return false;
2103 }
2104 }
2105
2106 // xinef: forced strongest aura in group by flag
2108 return !remove;
2110 return remove;
2111
2112 // xinef: forced return, handle all cases using available flags!
2113 return !(stackFlags & SPELL_GROUP_STACK_FLAG_NEVER_STACK);
2114 }
2115
2116 if (m_spellInfo->SpellFamilyName != existingSpellInfo->SpellFamilyName)
2117 return true;
2118
2119 if (!sameCaster)
2120 {
2121 // Channeled auras can stack if not forbidden by db or aura type
2122 if (existingAura->GetSpellInfo()->IsChanneled())
2123 return true;
2124
2126 return true;
2127
2128 // check same periodic auras
2129 for (uint32 i = 0; i < MAX_SPELL_EFFECTS; ++i)
2130 {
2131 switch (m_spellInfo->Effects[i].ApplyAuraName)
2132 {
2133 // DOT or HOT from different casters will stack
2145 // periodic auras which target areas are not allowed to stack this way (replenishment for example)
2146 if (m_spellInfo->Effects[i].IsTargetingArea() || existingSpellInfo->Effects[i].IsTargetingArea())
2147 break;
2148 return true;
2149 default:
2150 break;
2151 }
2152 }
2153 }
2154
2155 uint8 VehicleAura1 = 0;
2156 uint8 VehicleAura2 = 0;
2157 uint8 i = 0;
2158 while (i < MAX_SPELL_EFFECTS && !(VehicleAura1 && VehicleAura2))
2159 {
2160 if (m_spellInfo->Effects[i].ApplyAuraName == SPELL_AURA_CONTROL_VEHICLE)
2161 VehicleAura1 = i + 1;
2162 if (existingSpellInfo->Effects[i].ApplyAuraName == SPELL_AURA_CONTROL_VEHICLE)
2163 VehicleAura2 = i + 1;
2164
2165 ++i;
2166 }
2167
2168 if (VehicleAura1 && VehicleAura2)
2169 {
2170 Vehicle* veh = nullptr;
2171 if (GetOwner()->ToUnit())
2172 veh = GetOwner()->ToUnit()->GetVehicleKit();
2173
2174 if (!veh) // We should probably just let it stack. Vehicle system will prevent undefined behaviour later
2175 return true;
2176
2177 // xinef: allow direct auras to stack if there is no passenger in this slot
2178 if (AuraEffect* aurEff = GetEffect(VehicleAura1 - 1))
2179 if (aurEff->GetAmount() > 0)
2180 if (!veh->GetPassenger(aurEff->GetAmount() - 1))
2181 return true;
2182
2183 if (!veh->GetAvailableSeatCount())
2184 return false; // No empty seat available
2185
2186 return true; // Empty seat available (skip rest)
2187 }
2188
2189 // spell of same spell rank chain
2190 if (m_spellInfo->IsRankOf(existingSpellInfo) && !(m_spellInfo->SpellFamilyName == SPELLFAMILY_HUNTER && m_spellInfo->SpellFamilyFlags[1] & 0x80000000))
2191 {
2192 // don't allow passive area auras to stack
2193 if (m_spellInfo->IsMultiSlotAura() && !IsArea())
2194 return true;
2195 if (GetCastItemGUID() && existingAura->GetCastItemGUID())
2196 if (GetCastItemGUID() != existingAura->GetCastItemGUID() && m_spellInfo->HasAttribute(SPELL_ATTR0_CU_ENCHANT_PROC))
2197 return true;
2198 // same spell with same caster should not stack
2199 return false;
2200 }
2201
2202 return true;
2203}
@ SPELL_AURA_PERIODIC_DAMAGE
Definition: SpellAuraDefines.h:66
@ SPELL_AURA_OBS_MOD_HEALTH
Definition: SpellAuraDefines.h:83
@ SPELL_AURA_PERIODIC_MANA_LEECH
Definition: SpellAuraDefines.h:127
@ SPELL_AURA_OBS_MOD_POWER
Definition: SpellAuraDefines.h:84
@ SPELL_AURA_CONTROL_VEHICLE
Definition: SpellAuraDefines.h:299
@ SPELL_AURA_PERIODIC_HEAL
Definition: SpellAuraDefines.h:71
@ SPELL_AURA_PERIODIC_TRIGGER_SPELL_WITH_VALUE
Definition: SpellAuraDefines.h:290
@ SPELL_AURA_PERIODIC_ENERGIZE
Definition: SpellAuraDefines.h:87
@ SPELL_AURA_PERIODIC_LEECH
Definition: SpellAuraDefines.h:116
@ SPELL_AURA_POWER_BURN
Definition: SpellAuraDefines.h:225
@ SPELL_AURA_PERIODIC_DUMMY
Definition: SpellAuraDefines.h:289
@ SPELL_AURA_PERIODIC_TRIGGER_SPELL
Definition: SpellAuraDefines.h:86
@ DYNOBJ_AURA_TYPE
Definition: SpellAuraDefines.h:386
@ SPELL_ATTR0_CU_ENCHANT_PROC
Definition: SpellInfo.h:176
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_ATTR3_DOT_STACKING_RULE
Definition: SharedDefines.h:500
@ SPELLFAMILY_HUNTER
Definition: SharedDefines.h:3537
Unit * ToUnit()
Definition: Object.h:200
bool IsEmpty() const
Definition: ObjectGuid.h:163
Vehicle * GetVehicleKit() const
Definition: Unit.h:2367
Definition: Vehicle.h:30
uint8 GetAvailableSeatCount() const
Definition: Vehicle.cpp:602
Unit * GetPassenger(int8 seatId) const
Definition: Vehicle.cpp:226
bool IsArea() const
Definition: SpellAuras.cpp:1086
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:2006
bool IsRankOf(SpellInfo const *spellInfo) const
Definition: SpellInfo.cpp:2555
flag96 SpellFamilyFlags
Definition: SpellInfo.h:386
bool IsAuraExclusiveBySpecificPerCasterWith(SpellInfo const *spellInfo) const
Definition: SpellInfo.cpp:1402
bool IsAuraExclusiveBySpecificWith(SpellInfo const *spellInfo) const
Definition: SpellInfo.cpp:1370
bool IsMultiSlotAura() const
Definition: SpellInfo.cpp:1194
std::array< SpellEffectInfo, MAX_SPELL_EFFECTS > Effects
Definition: SpellInfo.h:391
bool IsDifferentRankOf(SpellInfo const *spellInfo) const
Definition: SpellInfo.cpp:2560
uint32 SpellFamilyName
Definition: SpellInfo.h:385

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)
2002{
2003 return CallScriptCheckAreaTargetHandlers(target);
2004}
bool CallScriptCheckAreaTargetHandlers(Unit *target)
Definition: SpellAuras.cpp:2389

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->isType(TYPEMASK_UNIT))
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}
@ TYPEMASK_UNIT
Definition: ObjectGuid.h:51
#define MAX_EFFECT_MASK
Definition: DBCStructure.h:1636
Unit * GetUnit(WorldObject const &, ObjectGuid const guid)
Definition: ObjectAccessor.cpp:202
bool isType(uint16 mask) const
Definition: Object.h:122
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::isType(), MAX_EFFECT_MASK, Object::ToUnit(), TYPEID_DYNAMICOBJECT, TYPEID_PLAYER, TYPEID_UNIT, and TYPEMASK_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:987

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
1264{
1265 for (Aura::ApplicationMap::const_iterator appIter = m_applications.begin(); appIter != m_applications.end(); ++appIter)
1266 {
1267 if (appIter->second->GetEffectMask())
1268 applicationList.push_back(appIter->second);
1269 }
1270}

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
2767{
2768 std::stringstream sstr;
2769 sstr << std::boolalpha
2770 << "Id: " << GetId() << " Caster: " << GetCasterGUID().ToString()
2771 << "\nOwner: " << (GetOwner() ? GetOwner()->GetDebugInfo() : "NULL");
2772 return sstr.str();
2773}
std::string GetDebugInfo() const override
Definition: Object.cpp:2472

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

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

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_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::getClass(), 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(), Object::GetTypeId(), GetUnitOwner(), WorldObject::GetZoneAndAreaId(), Unit::HasAura(), Unit::HasSpell(), Player::HasSpellCooldown(), SpellInfo::Id, IMMUNITY_ID, IN_MILLISECONDS, IsExpired(), Unit::IsFriendlyTo(), Unit::IsMounted(), 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(), Object::ToPlayer(), and TYPEID_PLAYER.

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

◆ HasEffect()

bool Aura::HasEffect ( uint8  effIndex) const
inline

◆ HasEffectType()

bool Aura::HasEffectType ( AuraType  type) const
1237{
1238 for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
1239 {
1240 if (HasEffect(i) && m_effects[i]->GetAuraType() == type)
1241 return true;
1242 }
1243 return false;
1244}
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
1087{
1088 for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
1089 {
1090 if (HasEffect(i) && GetSpellInfo()->Effects[i].IsAreaAuraEffect())
1091 return true;
1092 }
1093 return false;
1094}

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

Referenced by CanStackWith(), and UpdateTargetMap().

◆ IsAuraStronger()

bool Aura::IsAuraStronger ( Aura const *  newAura) const
2007{
2008 for (uint8 i = EFFECT_0; i < MAX_SPELL_EFFECTS; ++i)
2009 {
2010 AuraEffect* thisEffect = GetEffect(i);
2011 if (!thisEffect)
2012 continue;
2013
2014 AuraEffect* newEffect = nullptr;
2015 for (uint8 j = EFFECT_0; j < MAX_SPELL_EFFECTS; ++j)
2016 {
2017 newEffect = newAura->GetEffect(j);
2018 if (!newEffect || thisEffect->GetAuraType() != newEffect->GetAuraType() || thisEffect->GetMiscValue() != newEffect->GetMiscValue())
2019 continue;
2020
2021 // xinef: assume that all spells are either positive or negative, otherwise they should not be in one group
2022 int32 curValue = std::abs(thisEffect->GetAmount());
2023 if (curValue < std::abs(newEffect->GetAmount()))
2024 return true;
2025
2026 if (curValue == std::abs(newEffect->GetAmount()))
2027 if(!IsPassive() && !IsPermanent() && GetDuration() < newAura->GetDuration())
2028 return true;
2029 }
2030 }
2031
2032 return false;
2033}
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
1102{
1103 return GetSpellInfo()->IsDeathPersistent();
1104}
bool IsDeathPersistent() const
Definition: SpellInfo.cpp:1204

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
2206{
2207 /*if (m_procCooldown)
2208 {
2209 if (m_procCooldown > GameTime::GetGameTime().count())
2210 return true;
2211 }*/
2212 return false;
2213}

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
2242{
2243 SpellProcEntry const* procEntry = sSpellMgr->GetSpellProcEntry(GetId());
2244 // only auras with spell proc entry can trigger proc
2245 if (!procEntry)
2246 return false;
2247
2248 // check if we have charges to proc with
2249 if (IsUsingCharges() && !GetCharges())
2250 return false;
2251
2252 // check proc cooldown
2253 if (IsProcOnCooldown())
2254 return false;
2255
2257 // something about triggered spells triggering, and add extra attack effect
2258
2259 // do checks against db data
2260 if (!sSpellMgr->CanSpellTriggerProcOnEvent(*procEntry, eventInfo))
2261 return false;
2262
2263 // do checks using conditions table
2264 ConditionList conditions = sConditionMgr->GetConditionsForNotGroupedEntry(CONDITION_SOURCE_TYPE_SPELL_PROC, GetId());
2265 ConditionSourceInfo condInfo = ConditionSourceInfo(eventInfo.GetActor(), eventInfo.GetActionTarget());
2266 if (!sConditionMgr->IsObjectMeetToConditions(condInfo, conditions))
2267 return false;
2268
2269 // AuraScript Hook
2270 bool check = const_cast<Aura*>(this)->CallScriptCheckProcHandlers(aurApp, eventInfo);
2271 if (!check)
2272 return false;
2273
2275 // do allow additional requirements for procs
2276 // this is needed because this is the last moment in which you can prevent aura charge drop on proc
2277 // and possibly a way to prevent default checks (if there're going to be any)
2278
2279 // Check if current equipment meets aura requirements
2280 // do that only for passive spells
2282 Unit* target = aurApp->GetTarget();
2283 if (IsPassive() && target->GetTypeId() == TYPEID_PLAYER && GetSpellInfo()->EquippedItemClass != -1)
2284 {
2286 {
2287 Item* item = nullptr;
2289 {
2290 if (target->ToPlayer()->IsInFeralForm())
2291 return false;
2292
2293 if (DamageInfo const* damageInfo = eventInfo.GetDamageInfo())
2294 {
2295 switch (damageInfo->GetAttackType())
2296 {
2297 case BASE_ATTACK:
2299 break;
2300 case OFF_ATTACK:
2302 break;
2303 default:
2305 break;
2306 }
2307 }
2308 }
2310 {
2311 // Check if player is wearing shield
2313 }
2314
2315 if (!item || item->IsBroken() || !item->IsFitToSpellRequirements(GetSpellInfo()))
2316 {
2317 return 0;
2318 }
2319 }
2320 }
2321
2322 return roll_chance_f(CalcProcChance(*procEntry, eventInfo));
2323}
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
@ ITEM_CLASS_ARMOR
Definition: ItemTemplate.h:304
@ ITEM_CLASS_WEAPON
Definition: ItemTemplate.h:302
@ EQUIPMENT_SLOT_MAINHAND
Definition: Player.h:691
@ EQUIPMENT_SLOT_OFFHAND
Definition: Player.h:692
@ EQUIPMENT_SLOT_RANGED
Definition: Player.h:693
#define INVENTORY_SLOT_BAG_0
Definition: Player.h:671
@ OFF_ATTACK
Definition: Unit.h:397
@ BASE_ATTACK
Definition: Unit.h:396
@ SPELL_ATTR3_NO_PROC_EQUIP_REQUIREMENT
Definition: SharedDefines.h:494
Definition: ConditionMgr.h:181
Definition: Item.h:214
bool IsBroken() const
Definition: Item.h:251
bool IsFitToSpellRequirements(SpellInfo const *spellInfo) const
Definition: Item.cpp:885
Item * GetUseableItemByPos(uint8 bag, uint8 slot) const
Definition: Player.h:1232
Definition: Unit.h:761
Unit * GetActionTarget() const
Definition: Unit.h:871
Unit * GetActor()
Definition: Unit.h:870
bool IsInFeralForm() const
Definition: Unit.h:2091
bool CallScriptCheckProcHandlers(AuraApplication const *aurApp, ProcEventInfo &eventInfo)
Definition: SpellAuras.cpp:2647
bool IsProcOnCooldown() const
Definition: SpellAuras.cpp:2205
float CalcProcChance(SpellProcEntry const &procEntry, ProcEventInfo &eventInfo) const
Definition: SpellAuras.cpp:2325
int32 EquippedItemClass
Definition: SpellInfo.h:373

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(), Object::GetTypeId(), Player::GetUseableItemByPos(), SpellInfo::HasAttribute(), INVENTORY_SLOT_BAG_0, Item::IsBroken(), Item::IsFitToSpellRequirements(), Unit::IsInFeralForm(), IsPassive(), IsProcOnCooldown(), IsUsingCharges(), ITEM_CLASS_ARMOR, ITEM_CLASS_WEAPON, OFF_ATTACK, roll_chance_f(), sConditionMgr, SPELL_ATTR3_NO_PROC_EQUIP_REQUIREMENT, sSpellMgr, Object::ToPlayer(), and TYPEID_PLAYER.

◆ IsRemoved()

◆ IsRemovedOnShapeLost()

bool Aura::IsRemovedOnShapeLost ( Unit target) const

◆ IsSingleTarget()

◆ IsSingleTargetWith()

bool Aura::IsSingleTargetWith ( Aura const *  aura) const
1157{
1158 // Same spell?
1159 if (GetSpellInfo()->IsRankOf(aura->GetSpellInfo()))
1160 return true;
1161
1163 // spell with single target specific types
1164 switch (spec)
1165 {
1168 if (aura->GetSpellInfo()->GetSpellSpecific() == spec)
1169 return true;
1170 break;
1171 default:
1172 break;
1173 }
1174
1176 return true;
1177
1178 return false;
1179}
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:2123

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 ( )
2371{
2372 sScriptMgr->CreateAuraScripts(m_spellInfo->Id, m_loadedScripts);
2373 for (std::list<AuraScript*>::iterator itr = m_loadedScripts.begin(); itr != m_loadedScripts.end();)
2374 {
2375 if (!(*itr)->_Load(this))
2376 {
2377 std::list<AuraScript*>::iterator bitr = itr;
2378 ++itr;
2379 delete (*bitr);
2380 m_loadedScripts.erase(bitr);
2381 continue;
2382 }
2383 LOG_DEBUG("spells.aura", "Aura::LoadScripts: Script `{}` for aura `{}` is loaded now", (*itr)->_GetScriptName()->c_str(), m_spellInfo->Id);
2384 (*itr)->Register();
2385 ++itr;
2386 }
2387}
#define LOG_DEBUG(filterType__,...)
Definition: Log.h:169

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 
)
988{
989 if (IsUsingCharges())
990 {
991 int32 charges = m_procCharges + num;
992 int32 maxCharges = CalcMaxCharges();
993
994 // limit charges (only on charges increase, charges may be changed manually)
995 if ((num > 0) && (charges > int32(maxCharges)))
996 charges = maxCharges;
997 // we're out of charges, remove
998 else if (charges <= 0)
999 {
1000 Remove(removeMode);
1001 return true;
1002 }
1003
1004 SetCharges(charges);
1005 }
1006 return false;
1007}
void SetCharges(uint8 charges)
Definition: SpellAuras.cpp:966
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 
)
1036{
1037 int32 stackAmount = m_stackAmount + num;
1038
1039 // limit the stack amount (only on stack increase, stack amount may be changed manually)
1040 if ((num > 0) && (stackAmount > int32(m_spellInfo->StackAmount)))
1041 {
1042 // not stackable aura - set stack amount to 1
1044 stackAmount = 1;
1045 else
1046 stackAmount = m_spellInfo->StackAmount;
1047 }
1048 // we're out of stacks, remove
1049 else if (stackAmount <= 0)
1050 {
1051 Remove(removeMode);
1052 return true;
1053 }
1054
1055 bool refresh = stackAmount >= GetStackAmount() && (m_spellInfo->StackAmount || !m_spellInfo->HasAttribute(SPELL_ATTR1_AURA_UNIQUE));
1056
1057 // Update stack amount
1058 if (refresh)
1059 {
1061 RefreshTimers(periodicReset);
1062
1063 // reset charges
1065 // FIXME: not a best way to synchronize charges, but works
1066 for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
1067 if (AuraEffect* aurEff = GetEffect(i))
1068 if (aurEff->GetAuraType() == SPELL_AURA_ADD_FLAT_MODIFIER || aurEff->GetAuraType() == SPELL_AURA_ADD_PCT_MODIFIER)
1069 if (SpellModifier* mod = aurEff->GetSpellModifier())
1070 mod->charges = GetCharges();
1071 }
1072
1073 SetStackAmount(stackAmount);
1074
1076 return false;
1077}
@ 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:182
void SetStackAmount(uint8 num)
Definition: SpellAuras.cpp:1009
void RefreshTimers(bool periodicReset=false)
Definition: SpellAuras.cpp:923
void SetNeedClientUpdateForTargets() const
Definition: SpellAuras.cpp:1272
void RefreshSpellMods()
Definition: SpellAuras.cpp:1079
uint32 StackAmount
Definition: SpellInfo.h:369

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::spell_the_lich_king_necrotic_plague_SpellScript::AddMissingStack(), Spell::DoSpellHitOnUnit(), AuraScript::ModStackAmount(), spell_charge_shield_bomber::spell_charge_shield_bomber_SpellScript::PrepareSpellScript(), Unit::RemoveAuraFromStack(), Unit::RemoveAurasDueToSpellByDispel(), and Unit::RemoveAurasDueToSpellBySteal().

◆ PrepareProcToTrigger()

void Aura::PrepareProcToTrigger ( AuraApplication aurApp,
ProcEventInfo eventInfo 
)
2221{
2222 bool prepare = CallScriptPrepareProcHandlers(aurApp, eventInfo);
2223 if (!prepare)
2224 return;
2225
2226 // take one charge, aura expiration will be handled in Aura::TriggerProcOnEvent (if needed)
2228 {
2229 --m_procCharges;
2231 }
2232
2233 SpellProcEntry const* procEntry = sSpellMgr->GetSpellProcEntry(GetId());
2234
2235 ASSERT(procEntry);
2236
2237 // cooldowns should be added to the whole aura (see 51698 area aura)
2238 AddProcCooldown(procEntry->Cooldown);
2239}
@ SPELL_ATTR6_DO_NOT_CONSUME_RESOURCES
Definition: SharedDefines.h:609
SpellInfo const * GetSpellInfo() const
Definition: Unit.cpp:187
void AddProcCooldown(Milliseconds msec)
Definition: SpellAuras.cpp:2215
bool CallScriptPrepareProcHandlers(AuraApplication const *aurApp, ProcEventInfo &eventInfo)
Definition: SpellAuras.cpp:2679
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 ( )
1247{
1248 ASSERT (!IsRemoved());
1249 Unit* caster = GetCaster();
1250 for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
1251 if (HasEffect(i))
1252 m_effects[i]->RecalculateAmount(caster);
1253}
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
895{
896 Unit* caster = GetCaster();
897
898 if (!caster)
899 return;
900
901 if (withMods && caster)
902 {
903 int32 duration = m_spellInfo->GetMaxDuration();
904 // Calculate duration of periodics affected by haste.
906 duration = int32(duration * caster->GetFloatValue(UNIT_MOD_CAST_SPEED));
907 SetMaxDuration(duration);
908
909 SetDuration(duration);
910 }
911 else
913
916
917 // also reset periodic counters
918 for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
919 if (AuraEffect* aurEff = m_effects[i])
920 aurEff->ResetTicks();
921}
@ 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:5676
int32 GetMaxDuration() const
Definition: SpellInfo.cpp:2331

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 ( )
1080{
1081 for (Aura::ApplicationMap::const_iterator appIter = m_applications.begin(); appIter != m_applications.end(); ++appIter)
1082 if (Player* player = appIter->second->GetTarget()->ToPlayer())
1083 player->RestoreAllSpellMods(0, this);
1084}

References Unit::GetTarget(), and m_applications.

Referenced by ModStackAmount().

◆ RefreshTimers()

void Aura::RefreshTimers ( bool  periodicReset = false)
924{
927 Unit* caster = GetCaster();
928
929 if (!caster)
930 {
931 return;
932 }
933
934 for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
935 {
936 if (AuraEffect* aurEff = m_effects[i])
937 {
938 aurEff->CalculatePeriodic(caster, periodicReset, false);
939 aurEff->CalculatePeriodicData();
940 }
941 }
942}
void RefreshDuration(bool withMods=false)
Definition: SpellAuras.cpp:894

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

Referenced by ModStackAmount().

◆ RefreshTimersWithMods()

void Aura::RefreshTimersWithMods ( )
946{
947 Unit* caster = GetCaster();
950 {
952 }
953
954 // xinef: we should take ModSpellDuration into account, but none of the spells using this function is affected by contents of ModSpellDuration
956
957 for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
958 {
959 if (AuraEffect* aurEff = m_effects[i])
960 {
961 aurEff->CalculatePeriodic(caster, false, false);
962 }
963 }
964}

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 
)
1218{
1219 m_maxDuration = maxduration;
1220 m_duration = duration;
1221 m_procCharges = charges;
1223 m_stackAmount = stackamount;
1224 Unit* caster = GetCaster();
1225 for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
1226 if (m_effects[i])
1227 {
1228 m_effects[i]->SetAmount(amount[i]);
1229 m_effects[i]->SetCanBeRecalculated(recalculateMask & (1 << i));
1230 m_effects[i]->CalculatePeriodic(caster, false, true);
1232 m_effects[i]->RecalculateAmount(caster);
1233 }
1234}
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
1273{
1274 for (ApplicationMap::const_iterator appIter = m_applications.begin(); appIter != m_applications.end(); ++appIter)
1275 appIter->second->SetNeedClientUpdate();
1276}

References m_applications.

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

◆ SetStackAmount()

void Aura::SetStackAmount ( uint8  num)
1010{
1011 m_stackAmount = stackAmount;
1012 Unit* caster = GetCaster();
1013
1014 if (!caster)
1015 return;
1016
1017 std::list<AuraApplication*> applications;
1018 GetApplicationList(applications);
1019
1020 for (std::list<AuraApplication*>::const_iterator apptItr = applications.begin(); apptItr != applications.end(); ++apptItr)
1021 if (!(*apptItr)->GetRemoveMode())
1022 HandleAuraSpecificMods(*apptItr, caster, false, true);
1023
1024 for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
1025 if (HasEffect(i))
1026 m_effects[i]->ChangeAmount(m_effects[i]->CalculateAmount(caster), false, true);
1027
1028 for (std::list<AuraApplication*>::const_iterator apptItr = applications.begin(); apptItr != applications.end(); ++apptItr)
1029 if (!(*apptItr)->GetRemoveMode())
1030 HandleAuraSpecificMods(*apptItr, caster, true, true);
1031
1033}
void ChangeAmount(int32 newAmount, bool mark=true, bool onStackOrReapply=false)
Definition: SpellAuraEffects.cpp:708
void GetApplicationList(std::list< AuraApplication * > &applicationList) const
Definition: SpellAuras.cpp:1263
void HandleAuraSpecificMods(AuraApplication const *aurApp, Unit *caster, bool apply, bool onReapply)
Definition: SpellAuras.cpp:1279

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

◆ SetTriggeredByAuraSpellInfo()

void Aura::SetTriggeredByAuraSpellInfo ( SpellInfo const *  triggeredByAuraSpellInfo)
2762{
2763 m_triggeredByAuraSpellInfo = triggeredByAuraSpellInfo;
2764}

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 
)
2346{
2347 CallScriptProcHandlers(aurApp, eventInfo);
2348
2349 for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
2350 if (aurApp->HasEffect(i))
2351 // OnEffectProc / AfterEffectProc hooks handled in AuraEffect::HandleProc()
2352 GetEffect(i)->HandleProc(aurApp, eventInfo);
2353
2354 CallScriptAfterProcHandlers(aurApp, eventInfo);
2355
2356 // Remove aura if we've used last charge to proc
2357 if (IsUsingCharges() && !GetCharges())
2358 Remove();
2359}
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:2715
bool CallScriptProcHandlers(AuraApplication const *aurApp, ProcEventInfo &eventInfo)
Definition: SpellAuras.cpp:2698

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:4306

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::spell_putricide_slime_puddle_SpellScript::HandleScript(), Unit::HandleSpellClick(), boss_ahune::JustSummoned(), and Unit::RemoveAurasDueToSpellBySteal().

◆ UnregisterSingleTarget()

void Aura::UnregisterSingleTarget ( )
1182{
1184 Unit* caster = GetCaster();
1185 if (!caster)
1186 {
1187 LOG_INFO("spells", "Aura::UnregisterSingleTarget: (A1) - {}, {}, {}, {}", GetId(), GetOwner()->GetTypeId(), GetOwner()->GetEntry(), GetOwner()->GetName());
1188 LOG_ERROR("spells", "Aura::UnregisterSingleTarget: No caster was found."); //ASSERT(caster);
1189 }
1190 else
1191 caster->GetSingleCastAuras().remove(this);
1192
1193 SetIsSingleTarget(false);
1194}
#define LOG_INFO(filterType__,...)
Definition: Log.h:165
bool GetName(uint32 accountId, std::string &name)
Definition: AccountMgr.cpp:228
AuraList & GetSingleCastAuras()
Definition: Unit.h:1982
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 
)
813{
814 if (m_duration > 0)
815 {
816 m_duration -= diff;
817 if (m_duration < 0)
818 m_duration = 0;
819
820 // handle ManaPerSecond/ManaPerSecondPerLevel
821 if (m_timeCla)
822 {
823 if (m_timeCla > int32(diff))
824 m_timeCla -= diff;
825 else if (caster)
826 {
827 if (int32 ManaPerSecond = m_spellInfo->ManaPerSecond + m_spellInfo->ManaPerSecondPerLevel * caster->GetLevel())
828 {
829 m_timeCla += 1000 - diff;
830
831 Powers powertype = Powers(m_spellInfo->PowerType);
832 if (powertype == POWER_HEALTH)
833 {
834 if (int32(caster->GetHealth()) > ManaPerSecond)
835 caster->ModifyHealth(-ManaPerSecond);
836 else
837 {
838 Remove();
839 return;
840 }
841 }
842 else
843 {
844 if (int32(caster->GetPower(powertype)) >= ManaPerSecond)
845 caster->ModifyPower(powertype, -ManaPerSecond);
846 else
847 {
848 Remove();
849 return;
850 }
851 }
852 }
853 }
854 }
855 }
856}
Powers
Definition: SharedDefines.h:268
@ POWER_HEALTH
Definition: SharedDefines.h:278
int32 ModifyHealth(int32 val)
Definition: Unit.cpp:14079
int32 ModifyPower(Powers power, int32 val, bool withPowerUpdate=true)
Definition: Unit.cpp:14137
uint32 GetHealth() const
Definition: Unit.h:1454
uint32 GetPower(Powers power) const
Definition: Unit.h:1475
uint32 PowerType
Definition: SpellInfo.h:360

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 
)
771{
772 if (owner != m_owner)
773 {
774 ABORT();
775 }
776
777 Unit* caster = GetCaster();
778 // Apply spellmods for channeled auras
779 // used for example when triggered spell of spell:10 is modded
780 Spell* modSpell = nullptr;
781 Player* modOwner = nullptr;
782 if (caster)
783 {
784 modOwner = caster->GetSpellModOwner();
785 if (modOwner)
786 {
787 modSpell = modOwner->FindCurrentSpellBySpellId(GetId());
788 if (modSpell)
789 modOwner->SetSpellModTakingSpell(modSpell, true);
790 }
791 }
792
793 Update(diff, caster);
794
795 if (m_updateTargetMapInterval <= int32(diff))
796 UpdateTargetMap(caster);
797 else
799
800 // update aura effects
801 for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
802 if (m_effects[i])
803 m_effects[i]->Update(diff, caster);
804
805 // remove spellmods after effects update
806 if (modSpell)
807 modOwner->SetSpellModTakingSpell(modSpell, false);
808
810}
void SetSpellModTakingSpell(Spell *spell, bool apply)
Definition: Player.cpp:9996
Spell * FindCurrentSpellBySpellId(uint32 spell_id) const
Definition: Unit.cpp:4096
void Update(uint32 diff, Unit *caster)
Definition: SpellAuraEffects.cpp:897
void Update(uint32 diff, Unit *caster)
Definition: SpellAuras.cpp:812
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
662 || itr->first->IsImmunedToSpell(GetSpellInfo())
663 || !CanBeAppliedOn(itr->first))
664 addUnit = false;
665
666 if (addUnit)
667 {
668 // persistent area aura does not hit flying targets
669 if (GetType() == DYNOBJ_AURA_TYPE)
670 {
671 if (itr->first->IsInFlight())
672 addUnit = false;
673
674 switch( GetId() )
675 {
676 case 62821: // Ulduar, Hodir, Toasty Fire
677 case 62807: // Ulduar, Hodir, Starlight
678 case 51103: // Oculus, Mage-Lord Urom, Frostbomb
679 case 69146:
680 case 70823:
681 case 70824:
682 case 70825: // Icecrown Citadel, Lord Marrowgar, Coldflame
683 {
684 if( itr->first->HasAura(GetId()) )
685 addUnit = false;
686 }
687 break;
688 }
689 }
690 // unit auras can not stack with each other
691 else // (GetType() == UNIT_AURA_TYPE)
692 {
693 // Allow to remove by stack when aura is going to be applied on owner
694 if (itr->first != GetOwner())
695 {
696 // check if not stacking aura already on target
697 // this one prevents unwanted usefull buff loss because of stacking and prevents overriding auras periodicaly by 2 near area aura owners
698 for (Unit::AuraApplicationMap::iterator iter = itr->first->GetAppliedAuras().begin(); iter != itr->first->GetAppliedAuras().end(); ++iter)
699 {
700 Aura const* aura = iter->second->GetBase();
701 if (!CanStackWith(aura, false))
702 {
703 addUnit = false;
704 break;
705 }
706 }
707 }
708 }
709 }
710 if (!addUnit)
711 targets.erase(itr++);
712 else
713 {
714 // owner has to be in world, or effect has to be applied to self
715 if (!GetOwner()->IsSelfOrInSameMap(itr->first))
716 {
717 //TODO: There is a crash caused by shadowfiend load addon
718 LOG_FATAL("spells.aura", "Aura {}: Owner {} (map {}) is not in the same map as target {} (map {}).", GetSpellInfo()->Id,
719 GetOwner()->GetName(), GetOwner()->IsInWorld() ? GetOwner()->GetMap()->GetId() : uint32(-1),
720 itr->first->GetName(), itr->first->IsInWorld() ? itr->first->GetMap()->GetId() : uint32(-1));
721 ABORT();
722 }
723 itr->first->_CreateAuraApplication(this, itr->second);
724 ++itr;
725 }
726 }
727
728 // remove auras from units no longer needing them
729 for (UnitList::iterator itr = targetsToRemove.begin(); itr != targetsToRemove.end(); ++itr)
730 if (AuraApplication* aurApp = GetApplicationOfTarget((*itr)->GetGUID()))
731 (*itr)->_UnapplyAura(aurApp, AURA_REMOVE_BY_DEFAULT);
732
733 if (!apply)
734 return;
735
736 // apply aura effects for units
737 for (std::map<Unit*, uint8>::iterator itr = targets.begin(); itr != targets.end(); ++itr)
738 {
739 if (AuraApplication* aurApp = GetApplicationOfTarget(itr->first->GetGUID()))
740 {
741 // owner has to be in world, or effect has to be applied to self
742 ASSERT((!GetOwner()->IsInWorld() && GetOwner() == itr->first) || GetOwner()->IsInMap(itr->first));
743 itr->first->_ApplyAura(aurApp, itr->second);
744 }
745 }
746}
#define LOG_FATAL(filterType__,...)
Definition: Log.h:153
@ AURA_REMOVE_BY_DEFAULT
Definition: SpellAuraDefines.h:392
static constexpr int32 UPDATE_TARGET_MAP_INTERVAL
Definition: SpellAuras.cpp:45
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:2035
bool CanBeAppliedOn(Unit *target)
Definition: SpellAuras.cpp:1984

References ABORT, ASSERT, AURA_REMOVE_BY_DEFAULT, CanBeAppliedOn(), CanStackWith(), DYNOBJ_AURA_TYPE, FillTargetMap(), GetApplicationOfTarget(), GetId(), GetOwner(), GetSpellInfo(), GetType(), IsArea(), IsRemoved(), WorldObject::IsSelfOrInSameMap(), LOG_FATAL, m_applications, m_updateTargetMapInterval, MAX_SPELL_EFFECTS, 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().