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 HasMoreThanOneEffectForType (AuraType auraType) const
 
bool IsArea () const
 
bool IsPassive () const
 
bool IsDeathPersistent () const
 
bool IsRemovedOnShapeLost (Unit *target) const
 
bool CanBeSaved () const
 
bool IsRemoved () const
 
bool CanBeSentToClient () const
 
bool IsSingleTarget () const
 
bool IsSingleTargetWith (Aura const *aura) const
 
void SetIsSingleTarget (bool val)
 
void UnregisterSingleTarget ()
 
int32 CalcDispelChance (Unit *auraTarget, bool offensive) const
 
void SetLoadedState (int32 maxduration, int32 duration, int32 charges, uint8 stackamount, uint8 recalculateMask, int32 *amount)
 
bool HasEffect (uint8 effIndex) const
 
bool HasEffectType (AuraType type) const
 
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 *existingAura) 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
348 :
349 m_spellInfo(spellproto), m_casterGuid(casterGUID ? casterGUID : caster->GetGUID()),
350 m_castItemGuid(itemGUID ? itemGUID : castItem ? castItem->GetGUID() : ObjectGuid::Empty), m_castItemEntry(castItem ? castItem->GetEntry() : 0), m_applyTime(GameTime::GetGameTime().count()),
352 m_casterLevel(caster ? caster->GetLevel() : m_spellInfo->SpellLevel), m_procCharges(0), m_stackAmount(1),
354{
357
362 memset(m_effects, 0, sizeof(m_effects));
363 // m_casterLevel = cast item level/caster level, caster level should be saved to db, confirmed with sniffs
364}
constexpr auto IN_MILLISECONDS
Definition Common.h:53
@ SPELL_ATTR2_NO_TARGET_PER_SECOND_COST
Definition SharedDefines.h:478
int32 m_maxDuration
Definition SpellAuras.h:257
time_t const m_applyTime
Definition SpellAuras.h:254
AuraEffect * m_effects[3]
Definition SpellAuras.h:266
uint8 m_stackAmount
Definition SpellAuras.h:264
int32 m_duration
Definition SpellAuras.h:258
uint32 const m_castItemEntry
Definition SpellAuras.h:253
ObjectGuid const m_castItemGuid
Definition SpellAuras.h:252
int32 m_timeCla
Definition SpellAuras.h:259
int32 CalcMaxDuration() const
Definition SpellAuras.h:131
SpellInfo const * m_triggeredByAuraSpellInfo
Definition SpellAuras.h:276
SpellInfo const *const m_spellInfo
Definition SpellAuras.h:250
WorldObject *const m_owner
Definition SpellAuras.h:255
ObjectGuid const m_casterGuid
Definition SpellAuras.h:251
uint8 const m_casterLevel
Definition SpellAuras.h:262
uint8 CalcMaxCharges() const
Definition SpellAuras.h:144
bool m_isUsingCharges
Definition SpellAuras.h:271
bool m_isRemoved
Definition SpellAuras.h:269
int32 m_updateTargetMapInterval
Definition SpellAuras.h:260
bool m_isSingleTarget
Definition SpellAuras.h:270
uint8 m_procCharges
Definition SpellAuras.h:263
Definition ObjectGuid.h:118
uint32 ManaPerSecondPerLevel
Definition SpellInfo.h:366
uint32 ManaPerSecond
Definition SpellInfo.h:365
bool HasAttribute(SpellAttr0 attribute) const
Definition SpellInfo.h:415
Definition GameTime.cpp:22
Seconds GetGameTime()
Definition GameTime.cpp:38

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
387{
388 // unload scripts
389 while (!m_loadedScripts.empty())
390 {
391 std::list<AuraScript*>::iterator itr = m_loadedScripts.begin();
392 (*itr)->_Unload();
393 delete (*itr);
394 m_loadedScripts.erase(itr);
395 }
396
397 // free effects memory
398 for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
399 delete m_effects[i];
400
401 ASSERT(m_applications.empty());
403}
#define MAX_SPELL_EFFECTS
Definition DBCStructure.h:1635
std::uint8_t uint8
Definition Define.h:109
#define ASSERT
Definition Errors.h:68
std::list< AuraScript * > m_loadedScripts
Definition SpellAuras.h:239
ApplicationMap m_applications
Definition SpellAuras.h:267
void _DeleteRemovedApplications()
Definition SpellAuras.cpp:2271

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

Member Function Documentation

◆ _ApplyEffectForTargets()

void Aura::_ApplyEffectForTargets ( uint8  effIndex)
678{
679 // prepare list of aura targets
680 UnitList targetList;
681 for (ApplicationMap::iterator appIter = m_applications.begin(); appIter != m_applications.end(); ++appIter)
682 {
683 if ((appIter->second->GetEffectsToApply() & (1 << effIndex)) && !appIter->second->HasEffect(effIndex))
684 targetList.push_back(appIter->second->GetTarget());
685 }
686
687 // apply effect to targets
688 for (UnitList::iterator itr = targetList.begin(); itr != targetList.end(); ++itr)
689 {
690 if (GetApplicationOfTarget((*itr)->GetGUID()))
691 {
692 // owner has to be in world, or effect has to be applied to self
693 ASSERT((!GetOwner()->IsInWorld() && GetOwner() == *itr) || GetOwner()->IsInMap(*itr));
694 (*itr)->_ApplyAuraEffect(this, effIndex);
695 }
696 }
697}
std::list< Unit * > UnitList
Definition Unit.h:78
WorldObject * GetOwner() const
Definition SpellAuras.h:107
const AuraApplication * GetApplicationOfTarget(ObjectGuid guid) const
Definition SpellAuras.h:184

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.

432{
433 ASSERT(target);
434 ASSERT(auraApp);
435 // aura mustn't be already applied on target
436 ASSERT (!IsAppliedOnTarget(target->GetGUID()) && "Aura::_ApplyForTarget: aura musn't be already applied on target");
437
438 m_applications[target->GetGUID()] = auraApp;
439
440 // set infinity cooldown state for spells
442 {
443 if (caster->IsPlayer())
444 {
445 caster->ToPlayer()->AddSpellAndCategoryCooldowns(m_spellInfo, 0, nullptr, true);
446 }
447 else
448 {
450 }
451 }
452}
static constexpr uint32 infinityCooldownDelay
Definition Unit.h:48
bool IsAppliedOnTarget(ObjectGuid guid) const
Definition SpellAuras.h:186
void AddSpellCooldown(uint32 spell_id, uint32, uint32 end_time, bool needSendToClient=false, bool forceSendToSpectator=false) override
Definition Creature.cpp:2874
bool IsPlayer() const
Definition Object.h:200
Player * ToPlayer()
Definition Object.h:201
Creature * ToCreature()
Definition Object.h:205
static ObjectGuid GetGUID(Object const *o)
Definition Object.h:113
void AddSpellAndCategoryCooldowns(SpellInfo const *spellInfo, uint32 itemId, Spell *spell=nullptr, bool infinityCooldown=false)
Definition Player.cpp:10933
bool IsCooldownStartedOnEvent() const
Definition SpellInfo.cpp:1212
uint32 Id
Definition SpellInfo.h:320

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

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

◆ _DeleteRemovedApplications()

void Aura::_DeleteRemovedApplications ( )
private
2272{
2273 while (!m_removedApplications.empty())
2274 {
2275 delete m_removedApplications.front();
2276 m_removedApplications.pop_front();
2277 }
2278}
Unit::AuraApplicationList m_removedApplications
Definition SpellAuras.h:274

References m_removedApplications.

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

◆ _InitEffects()

void Aura::_InitEffects ( uint8  effMask,
Unit caster,
int32 baseAmount 
)
375{
376 // shouldn't be in constructor - functions in AuraEffect::AuraEffect use polymorphism
377 for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
378 {
379 if (effMask & (uint8(1) << i))
380 m_effects[i] = new AuraEffect(this, i, baseAmount ? baseAmount + i : nullptr, caster);
381 else
382 m_effects[i] = nullptr;
383 }
384}
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);}
Unit * GetCaster() const
Definition SpellAuras.cpp:410
void UpdateTargetMap(Unit *caster, bool apply=true)
Definition SpellAuras.cpp:527
Definition Unit.h:655

References GetCaster(), and UpdateTargetMap().

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

◆ _Remove()

void Aura::_Remove ( AuraRemoveMode  removeMode)
514{
516 m_isRemoved = true;
517 ApplicationMap::iterator appItr = m_applications.begin();
518 for (appItr = m_applications.begin(); appItr != m_applications.end();)
519 {
520 AuraApplication* aurApp = appItr->second;
521 Unit* target = aurApp->GetTarget();
522 target->_UnapplyAura(aurApp, removeMode);
523 appItr = m_applications.begin();
524 }
525}
Definition SpellAuras.h:37
Unit * GetTarget() const
Definition SpellAuras.h:61
void _UnapplyAura(AuraApplicationMap::iterator &i, AuraRemoveMode removeMode)
Definition Unit.cpp:4676

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.

455{
456 ASSERT(target);
457 ASSERT(auraApp->GetRemoveMode());
458 ASSERT(auraApp);
459
460 ApplicationMap::iterator itr = m_applications.find(target->GetGUID());
461
463 if (itr == m_applications.end())
464 {
465 LOG_ERROR("spells.aura", "Aura::_UnapplyForTarget, target:{}, caster:{}, spell:{} was not found in owners application map!",
466 target->GetGUID().ToString(), caster ? caster->GetGUID().ToString() : "", auraApp->GetBase()->GetSpellInfo()->Id);
467 ABORT();
468 }
469
470 // aura has to be already applied
471 ASSERT(itr->second == auraApp);
472 m_applications.erase(itr);
473
474 m_removedApplications.push_back(auraApp);
475
476 // reset cooldown state for spells
478 {
479 if (caster->IsPlayer())
480 {
481 // note: item based cooldowns and cooldown spell mods with charges ignored (unknown existed cases)
483 }
484 else
485 {
486 caster->ToCreature()->AddSpellCooldown(m_spellInfo->Id, 0, 0);
487
488 if (Unit* owner = caster->GetCharmerOrOwner())
489 {
490 if (Player* playerOwner = owner->ToPlayer())
491 {
492 WorldPacket data(SMSG_COOLDOWN_EVENT, 4 + 8);
493 data << uint32(m_spellInfo->Id);
494 data << caster->GetGUID();
495 playerOwner->SendDirectMessage(&data);
496 }
497 }
498 }
499 }
500
501 if (caster && caster->IsPlayer())
502 {
503 if (GetSpellInfo()->IsCooldownStartedOnEvent() && !m_castItemGuid)
504 {
505 // note: item based cooldowns and cooldown spell mods with charges ignored (unknown existed cases)
507 }
508 }
509}
std::uint32_t uint32
Definition Define.h:107
#define ABORT
Definition Errors.h:76
#define LOG_ERROR(filterType__,...)
Definition Log.h:158
AuraRemoveMode GetRemoveMode() const
Definition SpellAuras.h:73
SpellInfo const * GetSpellInfo() const
Definition SpellAuras.h:100
std::string ToString() const
Definition ObjectGuid.cpp:47
Definition Player.h:1071
void SendCooldownEvent(SpellInfo const *spellInfo, uint32 itemId=0, Spell *spell=nullptr, bool setCooldown=true)
Definition Player.cpp:11131
Unit * GetCharmerOrOwner() const
Definition Unit.h:1271
Definition WorldPacket.h:26
@ SMSG_COOLDOWN_EVENT
Definition Opcodes.h:339

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

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

◆ AddProcCooldown()

void Aura::AddProcCooldown ( Milliseconds  msec)
2126{
2127 //m_procCooldown = std:chrono::steady_clock::now() + msec;
2128}

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
238{
239 ASSERT_NODEBUGINFO(spellProto);
240 ASSERT_NODEBUGINFO(owner);
241 uint8 effMask = 0;
242 switch (owner->GetTypeId())
243 {
244 case TYPEID_UNIT:
245 case TYPEID_PLAYER:
246 for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
247 {
248 if (spellProto->Effects[i].IsUnitOwnedAuraEffect())
249 effMask |= 1 << i;
250 }
251 break;
253 for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
254 {
255 if (spellProto->Effects[i].Effect == SPELL_EFFECT_PERSISTENT_AREA_AURA)
256 effMask |= 1 << i;
257 }
258 break;
259 default:
260 break;
261 }
262 return effMask & avalibleEffectMask;
263}
#define ASSERT_NODEBUGINFO
Definition Errors.h:69
@ TYPEID_DYNAMICOBJECT
Definition ObjectGuid.h:38
@ TYPEID_UNIT
Definition ObjectGuid.h:35
@ TYPEID_PLAYER
Definition ObjectGuid.h:36
@ SPELL_EFFECT_PERSISTENT_AREA_AURA
Definition SharedDefines.h:816
TypeID GetTypeId() const
Definition Object.h:128

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
1135{
1136 // we assume that aura dispel chance is 100% on start
1137 // need formula for level difference based chance
1138 int32 resistChance = 0;
1139
1140 // Apply dispel mod from aura caster
1141 if (Unit* caster = GetCaster())
1142 if (Player* modOwner = caster->GetSpellModOwner())
1143 modOwner->ApplySpellMod(GetId(), SPELLMOD_RESIST_DISPEL_CHANCE, resistChance);
1144
1145 // Dispel resistance from target SPELL_AURA_MOD_DISPEL_RESIST
1146 // Only affects offensive dispels
1147 if (offensive && auraTarget)
1148 resistChance += auraTarget->GetTotalAuraModifier(SPELL_AURA_MOD_DISPEL_RESIST);
1149
1150 resistChance = resistChance < 0 ? 0 : resistChance;
1151 resistChance = resistChance > 100 ? 100 : resistChance;
1152 return 100 - resistChance;
1153}
std::int32_t int32
Definition Define.h:103
@ SPELL_AURA_MOD_DISPEL_RESIST
Definition SpellAuraDefines.h:298
@ SPELLMOD_RESIST_DISPEL_CHANCE
Definition SpellDefines.h:104
uint32 GetId() const
Definition SpellAuras.cpp:405
Player * GetSpellModOwner() const
Definition Unit.cpp:16794
int32 GetTotalAuraModifier(AuraType auratype) const
Definition Unit.cpp:6126

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
904{
905 uint32 maxProcCharges = m_spellInfo->ProcCharges;
906 if (SpellProcEntry const* procEntry = sSpellMgr->GetSpellProcEntry(GetId()))
907 maxProcCharges = procEntry->Charges;
908
909 if (caster)
910 if (Player* modOwner = caster->GetSpellModOwner())
911 modOwner->ApplySpellMod(GetId(), SPELLMOD_CHARGES, maxProcCharges);
912 return maxProcCharges;
913}
@ SPELLMOD_CHARGES
Definition SpellDefines.h:80
#define sSpellMgr
Definition SpellMgr.h:825
uint32 ProcCharges
Definition SpellInfo.h:357
Definition SpellMgr.h:289

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
787{
788 Player* modOwner = nullptr;
789 int32 maxDuration;
790
791 if (caster)
792 {
793 modOwner = caster->GetSpellModOwner();
794 maxDuration = caster->CalcSpellDuration(m_spellInfo);
795 }
796 else
797 maxDuration = m_spellInfo->GetDuration();
798
800 maxDuration = -1;
801
802 sScriptMgr->OnCalcMaxDuration(this, maxDuration);
803
804 // IsPermanent() checks max duration (which we are supposed to calculate here)
805 if (maxDuration != -1 && modOwner)
806 modOwner->ApplySpellMod(GetId(), SPELLMOD_DURATION, maxDuration);
807 return maxDuration;
808}
#define sScriptMgr
Definition ScriptMgr.h:719
@ SPELLMOD_DURATION
Definition SpellDefines.h:77
bool IsPassive() const
Definition SpellAuras.cpp:1034
void ApplySpellMod(uint32 spellId, SpellModOp op, T &basevalue, Spell *spell=nullptr, bool temporaryPet=false)
Definition Player.cpp:9817
SpellDurationEntry const * DurationEntry
Definition SpellInfo.h:361
int32 GetDuration() const
Definition SpellInfo.cpp:2232
int32 CalcSpellDuration(SpellInfo const *spellProto)
Definition Unit.cpp:14961

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
2236{
2237 float chance = procEntry.Chance;
2238 // calculate chances depending on unit with caster's data
2239 // so talents modifying chances and judgements will have properly calculated proc chance
2240 if (Unit* caster = GetCaster())
2241 {
2242 // calculate ppm chance if present and we're using weapon
2243 if (eventInfo.GetDamageInfo() && procEntry.ProcsPerMinute != 0)
2244 {
2245 uint32 WeaponSpeed = caster->GetAttackTime(eventInfo.GetDamageInfo()->GetAttackType());
2246 chance = caster->GetPPMProcChance(WeaponSpeed, procEntry.ProcsPerMinute, GetSpellInfo());
2247 }
2248 // apply chance modifer aura, applies also to ppm chance (see improved judgement of light spell)
2249 if (Player* modOwner = caster->GetSpellModOwner())
2250 modOwner->ApplySpellMod(GetId(), SPELLMOD_CHANCE_OF_SUCCESS, chance);
2251 }
2252 return chance;
2253}
@ SPELLMOD_CHANCE_OF_SUCCESS
Definition SpellDefines.h:94
WeaponAttackType GetAttackType() const
Definition Unit.h:370
DamageInfo * GetDamageInfo() const
Definition Unit.h:456

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 
)
2574{
2575 bool result = isTriggeredAtSpellProcEvent;
2576 for (std::list<AuraScript*>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
2577 {
2578 (*scritr)->_PrepareScriptCall(AURA_SCRIPT_HOOK_AFTER_CHECK_PROC, aurApp);
2579 std::list<AuraScript::AfterCheckProcHandler>::iterator hookItrEnd = (*scritr)->DoAfterCheckProc.end(), hookItr = (*scritr)->DoAfterCheckProc.begin();
2580 for (; hookItr != hookItrEnd; ++hookItr)
2581 result &= hookItr->Call(*scritr, eventInfo, isTriggeredAtSpellProcEvent);
2582
2583 (*scritr)->_FinishScriptCall();
2584 }
2585
2586 return result;
2587}
@ 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)
2328{
2329 for (std::list<AuraScript*>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
2330 {
2331 (*scritr)->_PrepareScriptCall(AURA_SCRIPT_HOOK_AFTER_DISPEL);
2332 std::list<AuraScript::AuraDispelHandler>::iterator hookItrEnd = (*scritr)->AfterDispel.end(), hookItr = (*scritr)->AfterDispel.begin();
2333 for (; hookItr != hookItrEnd; ++hookItr)
2334 hookItr->Call(*scritr, dispelInfo);
2335
2336 (*scritr)->_FinishScriptCall();
2337 }
2338}
@ 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 
)
2380{
2381 for (std::list<AuraScript*>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
2382 {
2383 (*scritr)->_PrepareScriptCall(AURA_SCRIPT_HOOK_EFFECT_AFTER_APPLY, aurApp);
2384 std::list<AuraScript::EffectApplyHandler>::iterator effEndItr = (*scritr)->AfterEffectApply.end(), effItr = (*scritr)->AfterEffectApply.begin();
2385 for (; effItr != effEndItr; ++effItr)
2386 if (effItr->IsEffectAffected(m_spellInfo, aurEff->GetEffIndex()))
2387 effItr->Call(*scritr, aurEff, mode);
2388
2389 (*scritr)->_FinishScriptCall();
2390 }
2391}
@ 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 
)
2658{
2659 for (std::list<AuraScript*>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
2660 {
2661 (*scritr)->_PrepareScriptCall(AURA_SCRIPT_HOOK_EFFECT_AFTER_PROC, aurApp);
2662 std::list<AuraScript::EffectProcHandler>::iterator effEndItr = (*scritr)->AfterEffectProc.end(), effItr = (*scritr)->AfterEffectProc.begin();
2663 for (; effItr != effEndItr; ++effItr)
2664 if (effItr->IsEffectAffected(m_spellInfo, aurEff->GetEffIndex()))
2665 effItr->Call(*scritr, aurEff, eventInfo);
2666
2667 (*scritr)->_FinishScriptCall();
2668 }
2669}
@ 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 
)
2394{
2395 for (std::list<AuraScript*>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
2396 {
2397 (*scritr)->_PrepareScriptCall(AURA_SCRIPT_HOOK_EFFECT_AFTER_REMOVE, aurApp);
2398 std::list<AuraScript::EffectApplyHandler>::iterator effEndItr = (*scritr)->AfterEffectRemove.end(), effItr = (*scritr)->AfterEffectRemove.begin();
2399 for (; effItr != effEndItr; ++effItr)
2400 if (effItr->IsEffectAffected(m_spellInfo, aurEff->GetEffIndex()))
2401 effItr->Call(*scritr, aurEff, mode);
2402
2403 (*scritr)->_FinishScriptCall();
2404 }
2405}
@ 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 
)
2626{
2627 for (std::list<AuraScript*>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
2628 {
2629 (*scritr)->_PrepareScriptCall(AURA_SCRIPT_HOOK_AFTER_PROC, aurApp);
2630 std::list<AuraScript::AuraProcHandler>::iterator hookItrEnd = (*scritr)->AfterProc.end(), hookItr = (*scritr)->AfterProc.begin();
2631 for (; hookItr != hookItrEnd; ++hookItr)
2632 hookItr->Call(*scritr, eventInfo);
2633
2634 (*scritr)->_FinishScriptCall();
2635 }
2636}
@ 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)
2300{
2301 bool result = true;
2302 for (std::list<AuraScript*>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
2303 {
2304 (*scritr)->_PrepareScriptCall(AURA_SCRIPT_HOOK_CHECK_AREA_TARGET);
2305 std::list<AuraScript::CheckAreaTargetHandler>::iterator hookItrEnd = (*scritr)->DoCheckAreaTarget.end(), hookItr = (*scritr)->DoCheckAreaTarget.begin();
2306 for (; hookItr != hookItrEnd; ++hookItr)
2307 result &= hookItr->Call(*scritr, target);
2308
2309 (*scritr)->_FinishScriptCall();
2310 }
2311 return result;
2312}
@ 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 
)
2558{
2559 bool result = true;
2560 for (std::list<AuraScript*>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
2561 {
2562 (*scritr)->_PrepareScriptCall(AURA_SCRIPT_HOOK_CHECK_PROC, aurApp);
2563 std::list<AuraScript::CheckProcHandler>::iterator hookItrEnd = (*scritr)->DoCheckProc.end(), hookItr = (*scritr)->DoCheckProc.begin();
2564 for (; hookItr != hookItrEnd; ++hookItr)
2565 result &= hookItr->Call(*scritr, eventInfo);
2566
2567 (*scritr)->_FinishScriptCall();
2568 }
2569
2570 return result;
2571}
@ 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)
2315{
2316 for (std::list<AuraScript*>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
2317 {
2318 (*scritr)->_PrepareScriptCall(AURA_SCRIPT_HOOK_DISPEL);
2319 std::list<AuraScript::AuraDispelHandler>::iterator hookItrEnd = (*scritr)->OnDispel.end(), hookItr = (*scritr)->OnDispel.begin();
2320 for (; hookItr != hookItrEnd; ++hookItr)
2321 hookItr->Call(*scritr, dispelInfo);
2322
2323 (*scritr)->_FinishScriptCall();
2324 }
2325}
@ 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 
)
2484{
2485 for (std::list<AuraScript*>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
2486 {
2487 (*scritr)->_PrepareScriptCall(AURA_SCRIPT_HOOK_EFFECT_ABSORB, aurApp);
2488 std::list<AuraScript::EffectAbsorbHandler>::iterator effEndItr = (*scritr)->OnEffectAbsorb.end(), effItr = (*scritr)->OnEffectAbsorb.begin();
2489 for (; effItr != effEndItr; ++effItr)
2490
2491 if (effItr->IsEffectAffected(m_spellInfo, aurEff->GetEffIndex()))
2492 effItr->Call(*scritr, aurEff, dmgInfo, absorbAmount);
2493
2494 if (!defaultPrevented)
2495 defaultPrevented = (*scritr)->_IsDefaultActionPrevented();
2496
2497 (*scritr)->_FinishScriptCall();
2498 }
2499}
@ 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 
)
2502{
2503 for (std::list<AuraScript*>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
2504 {
2505 (*scritr)->_PrepareScriptCall(AURA_SCRIPT_HOOK_EFFECT_AFTER_ABSORB, aurApp);
2506 std::list<AuraScript::EffectAbsorbHandler>::iterator effEndItr = (*scritr)->AfterEffectAbsorb.end(), effItr = (*scritr)->AfterEffectAbsorb.begin();
2507 for (; effItr != effEndItr; ++effItr)
2508 if (effItr->IsEffectAffected(m_spellInfo, aurEff->GetEffIndex()))
2509 effItr->Call(*scritr, aurEff, dmgInfo, absorbAmount);
2510
2511 (*scritr)->_FinishScriptCall();
2512 }
2513}
@ 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 
)
2530{
2531 for (std::list<AuraScript*>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
2532 {
2533 (*scritr)->_PrepareScriptCall(AURA_SCRIPT_HOOK_EFFECT_AFTER_MANASHIELD, aurApp);
2534 std::list<AuraScript::EffectManaShieldHandler>::iterator effEndItr = (*scritr)->AfterEffectManaShield.end(), effItr = (*scritr)->AfterEffectManaShield.begin();
2535 for (; effItr != effEndItr; ++effItr)
2536 if (effItr->IsEffectAffected(m_spellInfo, aurEff->GetEffIndex()))
2537 effItr->Call(*scritr, aurEff, dmgInfo, absorbAmount);
2538
2539 (*scritr)->_FinishScriptCall();
2540 }
2541}
@ 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 
)
2341{
2342 bool preventDefault = false;
2343 for (std::list<AuraScript*>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
2344 {
2345 (*scritr)->_PrepareScriptCall(AURA_SCRIPT_HOOK_EFFECT_APPLY, aurApp);
2346 std::list<AuraScript::EffectApplyHandler>::iterator effEndItr = (*scritr)->OnEffectApply.end(), effItr = (*scritr)->OnEffectApply.begin();
2347 for (; effItr != effEndItr; ++effItr)
2348 if (effItr->IsEffectAffected(m_spellInfo, aurEff->GetEffIndex()))
2349 effItr->Call(*scritr, aurEff, mode);
2350
2351 if (!preventDefault)
2352 preventDefault = (*scritr)->_IsDefaultActionPrevented();
2353
2354 (*scritr)->_FinishScriptCall();
2355 }
2356
2357 return preventDefault;
2358}
@ 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 
)
2442{
2443 for (std::list<AuraScript*>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
2444 {
2445 (*scritr)->_PrepareScriptCall(AURA_SCRIPT_HOOK_EFFECT_CALC_AMOUNT);
2446 std::list<AuraScript::EffectCalcAmountHandler>::iterator effEndItr = (*scritr)->DoEffectCalcAmount.end(), effItr = (*scritr)->DoEffectCalcAmount.begin();
2447 for (; effItr != effEndItr; ++effItr)
2448 if (effItr->IsEffectAffected(m_spellInfo, aurEff->GetEffIndex()))
2449 effItr->Call(*scritr, aurEff, amount, canBeRecalculated);
2450
2451 (*scritr)->_FinishScriptCall();
2452 }
2453}
@ 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 
)
2456{
2457 for (std::list<AuraScript*>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
2458 {
2459 (*scritr)->_PrepareScriptCall(AURA_SCRIPT_HOOK_EFFECT_CALC_PERIODIC);
2460 std::list<AuraScript::EffectCalcPeriodicHandler>::iterator effEndItr = (*scritr)->DoEffectCalcPeriodic.end(), effItr = (*scritr)->DoEffectCalcPeriodic.begin();
2461 for (; effItr != effEndItr; ++effItr)
2462 if (effItr->IsEffectAffected(m_spellInfo, aurEff->GetEffIndex()))
2463 effItr->Call(*scritr, aurEff, isPeriodic, amplitude);
2464
2465 (*scritr)->_FinishScriptCall();
2466 }
2467}
@ 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 
)
2470{
2471 for (std::list<AuraScript*>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
2472 {
2473 (*scritr)->_PrepareScriptCall(AURA_SCRIPT_HOOK_EFFECT_CALC_SPELLMOD);
2474 std::list<AuraScript::EffectCalcSpellModHandler>::iterator effEndItr = (*scritr)->DoEffectCalcSpellMod.end(), effItr = (*scritr)->DoEffectCalcSpellMod.begin();
2475 for (; effItr != effEndItr; ++effItr)
2476 if (effItr->IsEffectAffected(m_spellInfo, aurEff->GetEffIndex()))
2477 effItr->Call(*scritr, aurEff, spellMod);
2478
2479 (*scritr)->_FinishScriptCall();
2480 }
2481}
@ 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 
)
2516{
2517 for (std::list<AuraScript*>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
2518 {
2519 (*scritr)->_PrepareScriptCall(AURA_SCRIPT_HOOK_EFFECT_MANASHIELD, aurApp);
2520 std::list<AuraScript::EffectManaShieldHandler>::iterator effEndItr = (*scritr)->OnEffectManaShield.end(), effItr = (*scritr)->OnEffectManaShield.begin();
2521 for (; effItr != effEndItr; ++effItr)
2522 if (effItr->IsEffectAffected(m_spellInfo, aurEff->GetEffIndex()))
2523 effItr->Call(*scritr, aurEff, dmgInfo, absorbAmount);
2524
2525 (*scritr)->_FinishScriptCall();
2526 }
2527}
@ 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 
)
2408{
2409 bool preventDefault = false;
2410 for (std::list<AuraScript*>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
2411 {
2412 (*scritr)->_PrepareScriptCall(AURA_SCRIPT_HOOK_EFFECT_PERIODIC, aurApp);
2413 std::list<AuraScript::EffectPeriodicHandler>::iterator effEndItr = (*scritr)->OnEffectPeriodic.end(), effItr = (*scritr)->OnEffectPeriodic.begin();
2414 for (; effItr != effEndItr; ++effItr)
2415 if (effItr->IsEffectAffected(m_spellInfo, aurEff->GetEffIndex()))
2416 effItr->Call(*scritr, aurEff);
2417
2418 if (!preventDefault)
2419 preventDefault = (*scritr)->_IsDefaultActionPrevented();
2420
2421 (*scritr)->_FinishScriptCall();
2422 }
2423
2424 return preventDefault;
2425}
@ 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 
)
2639{
2640 bool preventDefault = false;
2641 for (std::list<AuraScript*>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
2642 {
2643 (*scritr)->_PrepareScriptCall(AURA_SCRIPT_HOOK_EFFECT_PROC, aurApp);
2644 std::list<AuraScript::EffectProcHandler>::iterator effEndItr = (*scritr)->OnEffectProc.end(), effItr = (*scritr)->OnEffectProc.begin();
2645 for (; effItr != effEndItr; ++effItr)
2646 if (effItr->IsEffectAffected(m_spellInfo, aurEff->GetEffIndex()))
2647 effItr->Call(*scritr, aurEff, eventInfo);
2648
2649 if (!preventDefault)
2650 preventDefault = (*scritr)->_IsDefaultActionPrevented();
2651
2652 (*scritr)->_FinishScriptCall();
2653 }
2654 return preventDefault;
2655}
@ 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 
)
2361{
2362 bool preventDefault = false;
2363 for (std::list<AuraScript*>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
2364 {
2365 (*scritr)->_PrepareScriptCall(AURA_SCRIPT_HOOK_EFFECT_REMOVE, aurApp);
2366 std::list<AuraScript::EffectApplyHandler>::iterator effEndItr = (*scritr)->OnEffectRemove.end(), effItr = (*scritr)->OnEffectRemove.begin();
2367 for (; effItr != effEndItr; ++effItr)
2368 if (effItr->IsEffectAffected(m_spellInfo, aurEff->GetEffIndex()))
2369 effItr->Call(*scritr, aurEff, mode);
2370
2371 if (!preventDefault)
2372 preventDefault = (*scritr)->_IsDefaultActionPrevented();
2373
2374 (*scritr)->_FinishScriptCall();
2375 }
2376 return preventDefault;
2377}
@ 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 
)
2544{
2545 for (std::list<AuraScript*>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
2546 {
2547 (*scritr)->_PrepareScriptCall(AURA_SCRIPT_HOOK_EFFECT_SPLIT, aurApp);
2548 std::list<AuraScript::EffectSplitHandler>::iterator effEndItr = (*scritr)->OnEffectSplit.end(), effItr = (*scritr)->OnEffectSplit.begin();
2549 for (; effItr != effEndItr; ++effItr)
2550 if (effItr->IsEffectAffected(m_spellInfo, aurEff->GetEffIndex()))
2551 effItr->Call(*scritr, aurEff, dmgInfo, splitAmount);
2552
2553 (*scritr)->_FinishScriptCall();
2554 }
2555}
@ 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)
2428{
2429 for (std::list<AuraScript*>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
2430 {
2431 (*scritr)->_PrepareScriptCall(AURA_SCRIPT_HOOK_EFFECT_UPDATE_PERIODIC);
2432 std::list<AuraScript::EffectUpdatePeriodicHandler>::iterator effEndItr = (*scritr)->OnEffectUpdatePeriodic.end(), effItr = (*scritr)->OnEffectUpdatePeriodic.begin();
2433 for (; effItr != effEndItr; ++effItr)
2434 if (effItr->IsEffectAffected(m_spellInfo, aurEff->GetEffIndex()))
2435 effItr->Call(*scritr, aurEff);
2436
2437 (*scritr)->_FinishScriptCall();
2438 }
2439}
@ 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 
)
2590{
2591 bool prepare = true;
2592 for (std::list<AuraScript*>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
2593 {
2594 (*scritr)->_PrepareScriptCall(AURA_SCRIPT_HOOK_PREPARE_PROC, aurApp);
2595 std::list<AuraScript::AuraProcHandler>::iterator effEndItr = (*scritr)->DoPrepareProc.end(), effItr = (*scritr)->DoPrepareProc.begin();
2596 for (; effItr != effEndItr; ++effItr)
2597 effItr->Call(*scritr, eventInfo);
2598
2599 if (prepare)
2600 prepare = !(*scritr)->_IsDefaultActionPrevented();
2601
2602 (*scritr)->_FinishScriptCall();
2603 }
2604
2605 return prepare;
2606}
@ 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 
)
2609{
2610 bool handled = false;
2611 for (std::list<AuraScript*>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
2612 {
2613 (*scritr)->_PrepareScriptCall(AURA_SCRIPT_HOOK_PROC, aurApp);
2614 std::list<AuraScript::AuraProcHandler>::iterator hookItrEnd = (*scritr)->OnProc.end(), hookItr = (*scritr)->OnProc.begin();
2615 for (; hookItr != hookItrEnd; ++hookItr)
2616 hookItr->Call(*scritr, eventInfo);
2617
2618 handled |= (*scritr)->_IsDefaultActionPrevented();
2619 (*scritr)->_FinishScriptCall();
2620 }
2621
2622 return handled;
2623}
@ 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)
1923{
1924 // unit not in world or during remove from world
1925 if (!target->IsInWorld() || target->IsDuringRemoveFromWorld())
1926 {
1927 // area auras mustn't be applied
1928 if (GetOwner() != target)
1929 return false;
1930 // not selfcasted single target auras mustn't be applied
1931 if (GetCasterGUID() != GetOwner()->GetGUID() && GetSpellInfo()->IsSingleTarget())
1932 return false;
1933 return true;
1934 }
1935 else
1936 return CheckAreaTarget(target);
1937}
bool CheckAreaTarget(Unit *target)
Definition SpellAuras.cpp:1939
ObjectGuid GetCasterGUID() const
Definition SpellAuras.h:105
bool IsSingleTarget() const
Definition SpellAuras.h:165
bool IsInWorld() const
Definition Object.h:108
bool IsDuringRemoveFromWorld() const
Definition Unit.h:693

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

Referenced by UpdateTargetMap().

◆ CanBeSaved()

bool Aura::CanBeSaved ( ) const
1050{
1051 SpellInfo const* spellInfo = GetSpellInfo();
1052
1054 {
1055 return true;
1056 }
1057
1059 {
1060 return false;
1061 }
1062
1063 if (IsPassive() || (spellInfo->HasAttribute(SPELL_ATTR0_DO_NOT_DISPLAY) && spellInfo->Stances))
1064 {
1065 return false;
1066 }
1067
1068 // Xinef: do not save channel auras
1069 if (GetSpellInfo()->IsChanneled())
1070 {
1071 return false;
1072 }
1073
1074 // Xinef: Check if aura is single target, not only spell info
1075 if (GetCasterGUID() != GetOwner()->GetGUID() && (GetSpellInfo()->IsSingleTarget() || IsSingleTarget()))
1076 {
1077 return false;
1078 }
1079
1080 // don't save auras removed by proc system
1081 if (IsUsingCharges() && !GetCharges())
1082 {
1083 return false;
1084 }
1085
1086 return true;
1087}
@ SPELL_ATTR0_DO_NOT_DISPLAY
Definition SharedDefines.h:400
@ SPELL_ATTR0_CU_FORCE_AURA_SAVING
Definition SpellInfo.h:205
@ SPELL_ATTR0_CU_AURA_CANNOT_BE_SAVED
Definition SpellInfo.h:200
bool IsUsingCharges() const
Definition SpellAuras.h:201
uint8 GetCharges() const
Definition SpellAuras.h:141
Definition SpellInfo.h:316
uint32 Stances
Definition SpellInfo.h:333

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

◆ CanBeSentToClient()

bool Aura::CanBeSentToClient ( ) const
1090{
1092}
@ SPELL_AURA_ABILITY_IGNORE_AURASTATE
Definition SpellAuraDefines.h:325
bool HasEffectType(AuraType type) const
Definition SpellAuras.cpp:1174
bool HasAreaAuraEffect() const
Definition SpellInfo.cpp:909

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

Referenced by Spell::EffectSummonPet().

◆ CanStackWith()

bool Aura::CanStackWith ( Aura const *  existingAura) const
1974{
1975 // Can stack with self
1976 if (this == existingAura)
1977 return true;
1978
1979 SpellInfo const* existingSpellInfo = existingAura->GetSpellInfo();
1980 bool sameCaster = GetCasterGUID() == existingAura->GetCasterGUID();
1981
1982 // Dynobj auras always stack
1983 // xinef: dont allow different ranks (or the same rank) of same spell to stack (many flamestrikes for example)
1984 if (existingAura->GetType() == DYNOBJ_AURA_TYPE)
1985 {
1986 // xinef: desecration lag fix - bound this condition to periodics
1987 if (sameCaster && GetSpellInfo()->Id == existingSpellInfo->Id && GetSpellInfo()->HasAura(SPELL_AURA_PERIODIC_DAMAGE))
1988 return false;
1989 return true;
1990 }
1991
1992 // passive auras don't stack with another rank of the spell cast by same caster
1993 if (IsPassive() && sameCaster && (m_spellInfo->IsDifferentRankOf(existingSpellInfo) || (m_spellInfo->Id == existingSpellInfo->Id && m_castItemGuid.IsEmpty())))
1994 return false;
1995
1996 for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
1997 {
1998 // prevent remove triggering aura by triggered aura
1999 if (existingSpellInfo->Effects[i].TriggerSpell == GetId()
2000 // prevent remove triggered aura by triggering aura refresh
2001 || m_spellInfo->Effects[i].TriggerSpell == existingAura->GetId())
2002 return true;
2003 }
2004
2005 // check spell specific stack rules
2006 if (m_spellInfo->IsAuraExclusiveBySpecificWith(existingSpellInfo)
2007 || (sameCaster && m_spellInfo->IsAuraExclusiveBySpecificPerCasterWith(existingSpellInfo)))
2008 return false;
2009
2010 // check spell group stack rules
2011 switch (sSpellMgr->CheckSpellGroupStackRules(m_spellInfo, existingSpellInfo))
2012 {
2014 case SPELL_GROUP_STACK_RULE_EXCLUSIVE_HIGHEST: // if it reaches this point, existing aura is lower/equal
2015 return false;
2017 if (sameCaster)
2018 return false;
2019 break;
2022 default:
2023 break;
2024 }
2025
2026 if (m_spellInfo->SpellFamilyName != existingSpellInfo->SpellFamilyName)
2027 return true;
2028
2029 if (!sameCaster)
2030 {
2031 // Channeled auras can stack if not forbidden by db or aura type
2032 if (existingAura->GetSpellInfo()->IsChanneled())
2033 return true;
2034
2036 return true;
2037
2038 // check same periodic auras
2039 for (uint32 i = 0; i < MAX_SPELL_EFFECTS; ++i)
2040 {
2041 switch (m_spellInfo->Effects[i].ApplyAuraName)
2042 {
2043 // DOT or HOT from different casters will stack
2055 // periodic auras which target areas are not allowed to stack this way (replenishment for example)
2056 if (m_spellInfo->Effects[i].IsTargetingArea() || existingSpellInfo->Effects[i].IsTargetingArea())
2057 break;
2058 return true;
2059 default:
2060 break;
2061 }
2062 }
2063 }
2064
2065 uint8 VehicleAura1 = 0;
2066 uint8 VehicleAura2 = 0;
2067 uint8 i = 0;
2068 while (i < MAX_SPELL_EFFECTS && !(VehicleAura1 && VehicleAura2))
2069 {
2070 if (m_spellInfo->Effects[i].ApplyAuraName == SPELL_AURA_CONTROL_VEHICLE)
2071 VehicleAura1 = i + 1;
2072 if (existingSpellInfo->Effects[i].ApplyAuraName == SPELL_AURA_CONTROL_VEHICLE)
2073 VehicleAura2 = i + 1;
2074
2075 ++i;
2076 }
2077
2078 if (VehicleAura1 && VehicleAura2)
2079 {
2080 Vehicle* veh = nullptr;
2081 if (GetOwner()->ToUnit())
2082 veh = GetOwner()->ToUnit()->GetVehicleKit();
2083
2084 if (!veh) // We should probably just let it stack. Vehicle system will prevent undefined behaviour later
2085 return true;
2086
2087 // xinef: allow direct auras to stack if there is no passenger in this slot
2088 if (AuraEffect* aurEff = GetEffect(VehicleAura1 - 1))
2089 if (aurEff->GetAmount() > 0)
2090 if (!veh->GetPassenger(aurEff->GetAmount() - 1))
2091 return true;
2092
2093 if (!veh->GetAvailableSeatCount())
2094 return false; // No empty seat available
2095
2096 return true; // Empty seat available (skip rest)
2097 }
2098
2099 // spell of same spell rank chain
2100 if (m_spellInfo->IsRankOf(existingSpellInfo) && !(m_spellInfo->SpellFamilyName == SPELLFAMILY_HUNTER && m_spellInfo->SpellFamilyFlags[1] & 0x80000000))
2101 {
2102 // don't allow passive area auras to stack
2103 if (m_spellInfo->IsMultiSlotAura() && !IsArea())
2104 return true;
2105 if (GetCastItemGUID() && existingAura->GetCastItemGUID())
2106 if (GetCastItemGUID() != existingAura->GetCastItemGUID() && m_spellInfo->HasAttribute(SPELL_ATTR0_CU_ENCHANT_PROC))
2107 return true;
2108 // same spell with same caster should not stack
2109 return false;
2110 }
2111
2112 return true;
2113}
@ SPELL_ATTR3_DOT_STACKING_RULE
Definition SharedDefines.h:511
@ SPELLFAMILY_HUNTER
Definition SharedDefines.h:3803
@ 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
@ SPELL_GROUP_STACK_RULE_EXCLUSIVE_FROM_SAME_CASTER
Definition SpellMgr.h:366
@ SPELL_GROUP_STACK_RULE_EXCLUSIVE
Definition SpellMgr.h:365
@ SPELL_GROUP_STACK_RULE_DEFAULT
Definition SpellMgr.h:364
@ SPELL_GROUP_STACK_RULE_EXCLUSIVE_SAME_EFFECT
Definition SpellMgr.h:367
@ SPELL_GROUP_STACK_RULE_EXCLUSIVE_HIGHEST
Definition SpellMgr.h:368
bool IsArea() const
Definition SpellAuras.cpp:1024
AuraEffect * GetEffect(uint8 effIndex) const
Definition SpellAuras.h:176
ObjectGuid GetCastItemGUID() const
Definition SpellAuras.h:103
bool IsEmpty() const
Definition ObjectGuid.h:161
Unit * ToUnit()
Definition Object.h:209
bool IsRankOf(SpellInfo const *spellInfo) const
Definition SpellInfo.cpp:2469
flag96 SpellFamilyFlags
Definition SpellInfo.h:388
bool IsAuraExclusiveBySpecificPerCasterWith(SpellInfo const *spellInfo) const
Definition SpellInfo.cpp:1415
bool IsAuraExclusiveBySpecificWith(SpellInfo const *spellInfo) const
Definition SpellInfo.cpp:1383
bool IsMultiSlotAura() const
Definition SpellInfo.cpp:1207
std::array< SpellEffectInfo, MAX_SPELL_EFFECTS > Effects
Definition SpellInfo.h:393
bool IsDifferentRankOf(SpellInfo const *spellInfo) const
Definition SpellInfo.cpp:2474
uint32 SpellFamilyName
Definition SpellInfo.h:387
Vehicle * GetVehicleKit() const
Definition Unit.h:1904
Definition Vehicle.h:28
uint8 GetAvailableSeatCount() const
Definition Vehicle.cpp:620
Unit * GetPassenger(int8 seatId) const
Definition Vehicle.cpp:228

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(), SpellInfo::IsChanneled(), SpellInfo::IsDifferentRankOf(), ObjectGuid::IsEmpty(), SpellInfo::IsMultiSlotAura(), IsPassive(), SpellInfo::IsRankOf(), m_castItemGuid, m_spellInfo, MAX_SPELL_EFFECTS, SPELL_ATTR0_CU_ENCHANT_PROC, SPELL_ATTR3_DOT_STACKING_RULE, SPELL_AURA_CONTROL_VEHICLE, SPELL_AURA_OBS_MOD_HEALTH, SPELL_AURA_OBS_MOD_POWER, SPELL_AURA_PERIODIC_DAMAGE, SPELL_AURA_PERIODIC_DUMMY, SPELL_AURA_PERIODIC_ENERGIZE, SPELL_AURA_PERIODIC_HEAL, SPELL_AURA_PERIODIC_LEECH, SPELL_AURA_PERIODIC_MANA_LEECH, SPELL_AURA_PERIODIC_TRIGGER_SPELL, SPELL_AURA_PERIODIC_TRIGGER_SPELL_WITH_VALUE, SPELL_AURA_POWER_BURN, SPELL_GROUP_STACK_RULE_DEFAULT, SPELL_GROUP_STACK_RULE_EXCLUSIVE, SPELL_GROUP_STACK_RULE_EXCLUSIVE_FROM_SAME_CASTER, SPELL_GROUP_STACK_RULE_EXCLUSIVE_HIGHEST, SPELL_GROUP_STACK_RULE_EXCLUSIVE_SAME_EFFECT, SPELLFAMILY_HUNTER, SpellInfo::SpellFamilyFlags, SpellInfo::SpellFamilyName, sSpellMgr, and Object::ToUnit().

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

◆ CheckAreaTarget()

bool Aura::CheckAreaTarget ( Unit target)
1940{
1941 return CallScriptCheckAreaTargetHandlers(target);
1942}
bool CallScriptCheckAreaTargetHandlers(Unit *target)
Definition SpellAuras.cpp:2299

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
304{
305 ASSERT_NODEBUGINFO(effMask);
306 ASSERT_NODEBUGINFO(spellproto);
307 ASSERT_NODEBUGINFO(owner);
308 ASSERT_NODEBUGINFO(caster || casterGUID);
310 // try to get caster of aura
311 if (casterGUID)
312 {
313 if (owner->GetGUID() == casterGUID)
314 caster = owner->ToUnit();
315 else
316 caster = ObjectAccessor::GetUnit(*owner, casterGUID);
317 }
318 else
319 casterGUID = caster->GetGUID();
320
321 // check if aura can be owned by owner
322 if (owner->IsUnit())
323 if (!owner->IsInWorld() || ((Unit*)owner)->IsDuringRemoveFromWorld())
324 // owner not in world so don't allow to own not self casted single target auras
325 if (casterGUID != owner->GetGUID() && spellproto->IsSingleTarget())
326 return nullptr;
327
328 Aura* aura = nullptr;
329 switch (owner->GetTypeId())
330 {
331 case TYPEID_UNIT:
332 case TYPEID_PLAYER:
333 aura = new UnitAura(spellproto, effMask, owner, caster, baseAmount, castItem, casterGUID, itemGUID);
334 break;
336 aura = new DynObjAura(spellproto, effMask, owner, caster, baseAmount, castItem, casterGUID, itemGUID);
337 break;
338 default:
339 ABORT();
340 return nullptr;
341 }
342 // aura can be removed in Unit::_AddAura call
343 if (aura->IsRemoved())
344 return nullptr;
345 return aura;
346}
#define MAX_EFFECT_MASK
Definition DBCStructure.h:1636
Definition SpellAuras.h:87
bool IsRemoved() const
Definition SpellAuras.h:162
Definition SpellAuras.h:303
bool IsUnit() const
Definition Object.h:208
Definition SpellAuras.h:280
Unit * GetUnit(WorldObject const &, ObjectGuid const &guid)
Definition ObjectAccessor.cpp:199

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

Referenced by TryCreate(), and TryRefreshStackOrCreate().

◆ DropCharge()

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

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
1202{
1203 for (Aura::ApplicationMap::const_iterator appIter = m_applications.begin(); appIter != m_applications.end(); ++appIter)
1204 {
1205 if (appIter->second->GetEffectMask())
1206 applicationList.push_back(appIter->second);
1207 }
1208}

References m_applications.

Referenced by SetStackAmount().

◆ GetApplicationMap()

ApplicationMap const & Aura::GetApplicationMap ( )
inline

◆ GetApplicationOfTarget() [1/2]

AuraApplication * Aura::GetApplicationOfTarget ( ObjectGuid  guid)
inline
185{ 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
128{ return m_applyTime; }

References m_applyTime.

Referenced by Player::DuelComplete(), and AuraScript::GetApplyTime().

◆ GetCaster()

◆ GetCasterGUID()

◆ GetCasterLevel()

uint8 Aura::GetCasterLevel ( ) const
inline

◆ GetCastItemEntry()

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

References m_castItemEntry.

◆ GetCastItemGUID()

◆ GetCharges()

◆ GetDebugInfo()

std::string Aura::GetDebugInfo ( ) const
virtual
2677{
2678 std::stringstream sstr;
2679 sstr << std::boolalpha
2680 << "Id: " << GetId() << " Caster: " << GetCasterGUID().ToString()
2681 << "\nOwner: " << (GetOwner() ? GetOwner()->GetDebugInfo() : "NULL");
2682 return sstr.str();
2683}
std::string GetDebugInfo() const override
Definition Object.cpp:2481

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

◆ GetDuration()

◆ GetDynobjOwner()

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

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

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

◆ GetEffect()

◆ GetEffectMask()

◆ GetId()

◆ GetMaxDuration()

◆ GetOwner()

◆ GetScriptByName()

AuraScript * Aura::GetScriptByName ( std::string const &  scriptName) const
367{
368 for (std::list<AuraScript*>::const_iterator itr = m_loadedScripts.begin(); itr != m_loadedScripts.end(); ++itr)
369 if ((*itr)->_GetScriptName()->compare(scriptName) == 0)
370 return *itr;
371 return nullptr;
372}

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(), Pet::_SaveAuras(), Unit::_UnapplyAura(), _UnapplyForTarget(), AuraEffect::ApplySpellMod(), AuraApplication::BuildUpdatePacket(), CalcProcChance(), CanBeAppliedOn(), CanBeSaved(), CanBeSentToClient(), CanStackWith(), Player::CheckAreaExploreAndOutdoor(), spell_item_luffa::CheckCast(), Spell::CheckCasterAuras(), Spell::DoSpellHitOnUnit(), Spell::EffectDispelMechanic(), Spell::EffectStealBeneficialBuff(), UnitAura::FillTargetMap(), DynObjAura::FillTargetMap(), Unit::GetDiseasesByCaster(), Unit::GetDispellableAuraList(), GetId(), AuraScript::GetSpellInfo(), AuraEffect::HandleAuraDummy(), Unit::HandleAuraProc(), HandleAuraSpecificMods(), spell_item_powerful_anti_venom::HandleDummy(), spell_item_strong_anti_venom::HandleDummy(), spell_item_anti_venom::HandleDummy(), spell_item_luffa::HandleEffect(), ArenaSpectator::HandleResetCommand(), spell_gen_clear_debuffs::HandleScript(), spell_dru_glyph_of_starfire::HandleScriptEffect(), spell_hun_chimera_shot::HandleScriptEffect(), HasMoreThanOneEffectForType(), Unit::HasNegativeAuraWithAttribute(), IsArea(), IsDeathPersistent(), Unit::IsHighestExclusiveAura(), IsPassive(), 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
421{
422 if (!m_owner)
423 {
424 LOG_ERROR("spells", "Aura::GetType m_owner is null!");
425 return UNIT_AURA_TYPE;
426 }
427
429}
@ UNIT_AURA_TYPE
Definition SpellAuraDefines.h:385
bool IsDynamicObject() const
Definition Object.h:220

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

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

◆ GetUnitOwner()

◆ HandleAllEffects()

void Aura::HandleAllEffects ( AuraApplication aurApp,
uint8  mode,
bool  apply 
)
1194{
1195 ASSERT (!IsRemoved());
1196 for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
1197 if (m_effects[i] && !IsRemoved())
1198 m_effects[i]->HandleEffect(aurApp, mode, apply);
1199}
void HandleEffect(AuraApplication *aurApp, uint8 mode, bool apply)
Definition SpellAuraEffects.cpp:756

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

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

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

◆ HasEffect()

◆ HasEffectType()

bool Aura::HasEffectType ( AuraType  type) const
1175{
1176 for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
1177 {
1178 if (HasEffect(i) && m_effects[i]->GetAuraType() == type)
1179 return true;
1180 }
1181 return false;
1182}
bool HasEffect(uint8 effIndex) const
Definition SpellAuras.h:174

References HasEffect(), m_effects, and MAX_SPELL_EFFECTS.

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

◆ HasMoreThanOneEffectForType()

bool Aura::HasMoreThanOneEffectForType ( AuraType  auraType) const
1015{
1016 uint32 count = 0;
1017 for (SpellEffectInfo const& spellEffectInfo : GetSpellInfo()->GetEffects())
1018 if (HasEffect(spellEffectInfo.EffectIndex) && spellEffectInfo.ApplyAuraName == auraType)
1019 ++count;
1020
1021 return count > 1;
1022}
Definition SpellInfo.h:249

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

Referenced by Unit::IsHighestExclusiveAuraEffect().

◆ IsAppliedOnTarget()

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

References m_applications.

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

◆ IsArea()

bool Aura::IsArea ( ) const
1025{
1026 for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
1027 {
1028 if (HasEffect(i) && GetSpellInfo()->Effects[i].IsAreaAuraEffect())
1029 return true;
1030 }
1031 return false;
1032}

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

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

◆ IsAuraStronger()

bool Aura::IsAuraStronger ( Aura const *  newAura) const
1945{
1946 for (uint8 i = EFFECT_0; i < MAX_SPELL_EFFECTS; ++i)
1947 {
1948 AuraEffect* thisEffect = GetEffect(i);
1949 if (!thisEffect)
1950 continue;
1951
1952 AuraEffect* newEffect = nullptr;
1953 for (uint8 j = EFFECT_0; j < MAX_SPELL_EFFECTS; ++j)
1954 {
1955 newEffect = newAura->GetEffect(j);
1956 if (!newEffect || thisEffect->GetAuraType() != newEffect->GetAuraType() || thisEffect->GetMiscValue() != newEffect->GetMiscValue())
1957 continue;
1958
1959 // xinef: assume that all spells are either positive or negative, otherwise they should not be in one group
1960 int32 curValue = std::abs(thisEffect->GetAmount());
1961 if (curValue < std::abs(newEffect->GetAmount()))
1962 return true;
1963
1964 if (curValue == std::abs(newEffect->GetAmount()))
1965 if (!IsPassive() && !IsPermanent() && GetDuration() < newAura->GetDuration())
1966 return true;
1967 }
1968 }
1969
1970 return false;
1971}
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.

◆ IsDeathPersistent()

bool Aura::IsDeathPersistent ( ) const
1040{
1041 return GetSpellInfo()->IsDeathPersistent();
1042}
bool IsDeathPersistent() const
Definition SpellInfo.cpp:1217

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
2116{
2117 /*if (m_procCooldown)
2118 {
2119 if (m_procCooldown > GameTime::GetGameTime().count())
2120 return true;
2121 }*/
2122 return false;
2123}

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
2152{
2153 SpellProcEntry const* procEntry = sSpellMgr->GetSpellProcEntry(GetId());
2154 // only auras with spell proc entry can trigger proc
2155 if (!procEntry)
2156 return false;
2157
2158 // check if we have charges to proc with
2159 if (IsUsingCharges() && !GetCharges())
2160 return false;
2161
2162 // check proc cooldown
2163 if (IsProcOnCooldown())
2164 return false;
2165
2167 // something about triggered spells triggering, and add extra attack effect
2168
2169 // do checks against db data
2170 if (!sSpellMgr->CanSpellTriggerProcOnEvent(*procEntry, eventInfo))
2171 return false;
2172
2173 // do checks using conditions table
2174 ConditionList conditions = sConditionMgr->GetConditionsForNotGroupedEntry(CONDITION_SOURCE_TYPE_SPELL_PROC, GetId());
2175 ConditionSourceInfo condInfo = ConditionSourceInfo(eventInfo.GetActor(), eventInfo.GetActionTarget());
2176 if (!sConditionMgr->IsObjectMeetToConditions(condInfo, conditions))
2177 return false;
2178
2179 // AuraScript Hook
2180 bool check = const_cast<Aura*>(this)->CallScriptCheckProcHandlers(aurApp, eventInfo);
2181 if (!check)
2182 return false;
2183
2185 // do allow additional requirements for procs
2186 // this is needed because this is the last moment in which you can prevent aura charge drop on proc
2187 // and possibly a way to prevent default checks (if there're going to be any)
2188
2189 // Check if current equipment meets aura requirements
2190 // do that only for passive spells
2192 Unit* target = aurApp->GetTarget();
2193 if (IsPassive() && target->IsPlayer() && GetSpellInfo()->EquippedItemClass != -1)
2194 {
2196 {
2197 Item* item = nullptr;
2199 {
2200 if (target->ToPlayer()->IsInFeralForm())
2201 return false;
2202
2203 if (DamageInfo const* damageInfo = eventInfo.GetDamageInfo())
2204 {
2205 switch (damageInfo->GetAttackType())
2206 {
2207 case BASE_ATTACK:
2209 break;
2210 case OFF_ATTACK:
2212 break;
2213 default:
2215 break;
2216 }
2217 }
2218 }
2220 {
2221 // Check if player is wearing shield
2223 }
2224
2225 if (!item || item->IsBroken() || !item->IsFitToSpellRequirements(GetSpellInfo()))
2226 {
2227 return 0;
2228 }
2229 }
2230 }
2231
2232 return roll_chance_f(CalcProcChance(*procEntry, eventInfo));
2233}
#define sConditionMgr
Definition ConditionMgr.h:291
@ CONDITION_SOURCE_TYPE_SPELL_PROC
Definition ConditionMgr.h:148
std::list< Condition * > ConditionList
Definition ConditionMgr.h:238
@ ITEM_CLASS_ARMOR
Definition ItemTemplate.h:295
@ ITEM_CLASS_WEAPON
Definition ItemTemplate.h:293
@ EQUIPMENT_SLOT_MAINHAND
Definition Player.h:685
@ EQUIPMENT_SLOT_OFFHAND
Definition Player.h:686
@ EQUIPMENT_SLOT_RANGED
Definition Player.h:687
#define INVENTORY_SLOT_BAG_0
Definition Player.h:665
bool roll_chance_f(float chance)
Definition Random.h:57
@ SPELL_ATTR3_NO_PROC_EQUIP_REQUIREMENT
Definition SharedDefines.h:505
@ OFF_ATTACK
Definition Unit.h:217
@ BASE_ATTACK
Definition Unit.h:216
bool CallScriptCheckProcHandlers(AuraApplication const *aurApp, ProcEventInfo &eventInfo)
Definition SpellAuras.cpp:2557
bool IsProcOnCooldown() const
Definition SpellAuras.cpp:2115
float CalcProcChance(SpellProcEntry const &procEntry, ProcEventInfo &eventInfo) const
Definition SpellAuras.cpp:2235
Definition Unit.h:337
Definition Item.h:220
bool IsBroken() const
Definition Item.h:257
bool IsFitToSpellRequirements(SpellInfo const *spellInfo) const
Definition Item.cpp:884
Item * GetUseableItemByPos(uint8 bag, uint8 slot) const
Definition Player.h:1250
Unit * GetActionTarget() const
Definition Unit.h:447
Unit * GetActor()
Definition Unit.h:446
int32 EquippedItemClass
Definition SpellInfo.h:375
bool IsInFeralForm() const
Definition Unit.h:1939
Definition ConditionMgr.h:183

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

◆ IsRemoved()

◆ IsRemovedOnShapeLost()

bool Aura::IsRemovedOnShapeLost ( Unit target) const

◆ IsSingleTarget()

◆ IsSingleTargetWith()

bool Aura::IsSingleTargetWith ( Aura const *  aura) const
1095{
1096 // Same spell?
1097 if (GetSpellInfo()->IsRankOf(aura->GetSpellInfo()))
1098 return true;
1099
1101 // spell with single target specific types
1102 switch (spec)
1103 {
1106 if (aura->GetSpellInfo()->GetSpellSpecific() == spec)
1107 return true;
1108 break;
1109 default:
1110 break;
1111 }
1112
1114 return true;
1115
1116 return false;
1117}
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:2029

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 ( )
2281{
2282 sScriptMgr->CreateAuraScripts(m_spellInfo->Id, m_loadedScripts);
2283 for (std::list<AuraScript*>::iterator itr = m_loadedScripts.begin(); itr != m_loadedScripts.end();)
2284 {
2285 if (!(*itr)->_Load(this))
2286 {
2287 std::list<AuraScript*>::iterator bitr = itr;
2288 ++itr;
2289 delete (*bitr);
2290 m_loadedScripts.erase(bitr);
2291 continue;
2292 }
2293 LOG_DEBUG("spells.aura", "Aura::LoadScripts: Script `{}` for aura `{}` is loaded now", (*itr)->_GetScriptName()->c_str(), m_spellInfo->Id);
2294 (*itr)->Register();
2295 ++itr;
2296 }
2297}
#define LOG_DEBUG(filterType__,...)
Definition Log.h:170

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 
)
916{
917 if (IsUsingCharges())
918 {
919 int32 charges = m_procCharges + num;
920 int32 maxCharges = CalcMaxCharges();
921
922 // limit charges (only on charges increase, charges may be changed manually)
923 if ((num > 0) && (charges > int32(maxCharges)))
924 charges = maxCharges;
925 // we're out of charges, remove
926 else if (charges <= 0)
927 {
928 Remove(removeMode);
929 return true;
930 }
931
932 SetCharges(charges);
933 }
934 return false;
935}
void SetCharges(uint8 charges)
Definition SpellAuras.cpp:894
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 
)
964{
965 int32 stackAmount = m_stackAmount + num;
966
967 // limit the stack amount (only on stack increase, stack amount may be changed manually)
968 if ((num > 0) && (stackAmount > int32(m_spellInfo->StackAmount)))
969 {
970 // not stackable aura - set stack amount to 1
972 stackAmount = 1;
973 else
974 stackAmount = m_spellInfo->StackAmount;
975 }
976 // we're out of stacks, remove
977 else if (stackAmount <= 0)
978 {
979 Remove(removeMode);
980 return true;
981 }
982
983 bool refresh = stackAmount >= GetStackAmount() && (m_spellInfo->StackAmount || !m_spellInfo->HasAttribute(SPELL_ATTR1_AURA_UNIQUE));
984
985 // Update stack amount
986 if (refresh)
987 {
989 RefreshTimers(periodicReset);
990
991 // reset charges
993 // FIXME: not a best way to synchronize charges, but works
994 for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
995 if (AuraEffect* aurEff = GetEffect(i))
996 if (aurEff->GetAuraType() == SPELL_AURA_ADD_FLAT_MODIFIER || aurEff->GetAuraType() == SPELL_AURA_ADD_PCT_MODIFIER)
997 if (SpellModifier* mod = aurEff->GetSpellModifier())
998 mod->charges = GetCharges();
999 }
1000
1001 SetStackAmount(stackAmount);
1002
1004 return false;
1005}
@ SPELL_ATTR1_AURA_UNIQUE
Definition SharedDefines.h:441
@ SPELL_AURA_ADD_PCT_MODIFIER
Definition SpellAuraDefines.h:171
@ SPELL_AURA_ADD_FLAT_MODIFIER
Definition SpellAuraDefines.h:170
void SetStackAmount(uint8 num)
Definition SpellAuras.cpp:937
void RefreshTimers(bool periodicReset=false)
Definition SpellAuras.cpp:851
void SetNeedClientUpdateForTargets() const
Definition SpellAuras.cpp:1210
void RefreshSpellMods()
Definition SpellAuras.cpp:1007
uint32 StackAmount
Definition SpellInfo.h:371
Definition Player.h:182

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

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

◆ PrepareProcToTrigger()

void Aura::PrepareProcToTrigger ( AuraApplication aurApp,
ProcEventInfo eventInfo 
)
2131{
2132 bool prepare = CallScriptPrepareProcHandlers(aurApp, eventInfo);
2133 if (!prepare)
2134 return;
2135
2136 // take one charge, aura expiration will be handled in Aura::TriggerProcOnEvent (if needed)
2138 {
2139 --m_procCharges;
2141 }
2142
2143 SpellProcEntry const* procEntry = sSpellMgr->GetSpellProcEntry(GetId());
2144
2145 ASSERT(procEntry);
2146
2147 // cooldowns should be added to the whole aura (see 51698 area aura)
2148 AddProcCooldown(procEntry->Cooldown);
2149}
@ SPELL_ATTR6_DO_NOT_CONSUME_RESOURCES
Definition SharedDefines.h:620
void AddProcCooldown(Milliseconds msec)
Definition SpellAuras.cpp:2125
bool CallScriptPrepareProcHandlers(AuraApplication const *aurApp, ProcEventInfo &eventInfo)
Definition SpellAuras.cpp:2589
SpellInfo const * GetSpellInfo() const
Definition Unit.cpp:187
Milliseconds Cooldown
Definition SpellMgr.h:300

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 ( )
1185{
1186 ASSERT (!IsRemoved());
1187 Unit* caster = GetCaster();
1188 for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
1189 if (HasEffect(i))
1190 m_effects[i]->RecalculateAmount(caster);
1191}
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
823{
824 Unit* caster = GetCaster();
825
826 if (!caster)
827 return;
828
829 if (withMods && caster)
830 {
831 int32 duration = m_spellInfo->GetMaxDuration();
832 // Calculate duration of periodics affected by haste.
834 duration = int32(duration * caster->GetFloatValue(UNIT_MOD_CAST_SPEED));
835 SetMaxDuration(duration);
836
837 SetDuration(duration);
838 }
839 else
841
844
845 // also reset periodic counters
846 for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
847 if (AuraEffect* aurEff = m_effects[i])
848 aurEff->ResetTicks();
849}
@ SPELL_ATTR5_SPELL_HASTE_AFFECTS_PERIODIC
Definition SharedDefines.h:591
@ SPELL_AURA_PERIODIC_HASTE
Definition SpellAuraDefines.h:379
@ UNIT_MOD_CAST_SPEED
Definition UpdateFields.h:137
float GetFloatValue(uint16 index) const
Definition Object.cpp:306
int32 GetMaxDuration() const
Definition SpellInfo.cpp:2239
bool HasAuraTypeWithAffectMask(AuraType auratype, SpellInfo const *affectedSpell) const
Definition Unit.cpp:5880

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(), boss_shirrak_the_dead_watcher::JustEngagedWith(), AuraScript::RefreshDuration(), RefreshTimers(), RefreshTimersWithMods(), and AuraEffect::UpdatePeriodic().

◆ RefreshSpellMods()

void Aura::RefreshSpellMods ( )
1008{
1009 for (Aura::ApplicationMap::const_iterator appIter = m_applications.begin(); appIter != m_applications.end(); ++appIter)
1010 if (Player* player = appIter->second->GetTarget()->ToPlayer())
1011 player->RestoreAllSpellMods(0, this);
1012}

References Unit::GetTarget(), and m_applications.

Referenced by ModStackAmount().

◆ RefreshTimers()

void Aura::RefreshTimers ( bool  periodicReset = false)
852{
855 Unit* caster = GetCaster();
856
857 if (!caster)
858 {
859 return;
860 }
861
862 for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
863 {
864 if (AuraEffect* aurEff = m_effects[i])
865 {
866 aurEff->CalculatePeriodic(caster, periodicReset, false);
867 aurEff->CalculatePeriodicData();
868 }
869 }
870}
void RefreshDuration(bool withMods=false)
Definition SpellAuras.cpp:822

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

Referenced by ModStackAmount().

◆ RefreshTimersWithMods()

void Aura::RefreshTimersWithMods ( )
874{
875 Unit* caster = GetCaster();
878 {
880 }
881
882 // xinef: we should take ModSpellDuration into account, but none of the spells using this function is affected by contents of ModSpellDuration
884
885 for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
886 {
887 if (AuraEffect* aurEff = m_effects[i])
888 {
889 aurEff->CalculatePeriodic(caster, false, false);
890 }
891 }
892}

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 
)
1156{
1157 m_maxDuration = maxduration;
1158 m_duration = duration;
1159 m_procCharges = charges;
1161 m_stackAmount = stackamount;
1162 Unit* caster = GetCaster();
1163 for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
1164 if (m_effects[i])
1165 {
1166 m_effects[i]->SetAmount(amount[i]);
1167 m_effects[i]->SetCanBeRecalculated(recalculateMask & (1 << i));
1168 m_effects[i]->CalculatePeriodic(caster, false, true);
1170 m_effects[i]->RecalculateAmount(caster);
1171 }
1172}
void CalculatePeriodic(Unit *caster, bool create=false, bool load=false)
Definition SpellAuraEffects.cpp:598
void CalculateSpellMod()
Definition SpellAuraEffects.cpp:689
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
1211{
1212 for (ApplicationMap::const_iterator appIter = m_applications.begin(); appIter != m_applications.end(); ++appIter)
1213 appIter->second->SetNeedClientUpdate();
1214}

References m_applications.

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

◆ SetStackAmount()

void Aura::SetStackAmount ( uint8  num)
938{
939 m_stackAmount = stackAmount;
940 Unit* caster = GetCaster();
941
942 if (!caster)
943 return;
944
945 std::list<AuraApplication*> applications;
946 GetApplicationList(applications);
947
948 for (std::list<AuraApplication*>::const_iterator apptItr = applications.begin(); apptItr != applications.end(); ++apptItr)
949 if (!(*apptItr)->GetRemoveMode())
950 HandleAuraSpecificMods(*apptItr, caster, false, true);
951
952 for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
953 if (HasEffect(i))
954 m_effects[i]->ChangeAmount(m_effects[i]->CalculateAmount(caster), false, true);
955
956 for (std::list<AuraApplication*>::const_iterator apptItr = applications.begin(); apptItr != applications.end(); ++apptItr)
957 if (!(*apptItr)->GetRemoveMode())
958 HandleAuraSpecificMods(*apptItr, caster, true, true);
959
961}
void GetApplicationList(std::list< AuraApplication * > &applicationList) const
Definition SpellAuras.cpp:1201
void HandleAuraSpecificMods(AuraApplication const *aurApp, Unit *caster, bool apply, bool onReapply)
Definition SpellAuras.cpp:1217

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

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

◆ SetTriggeredByAuraSpellInfo()

void Aura::SetTriggeredByAuraSpellInfo ( SpellInfo const *  triggeredByAuraSpellInfo)
2672{
2673 m_triggeredByAuraSpellInfo = triggeredByAuraSpellInfo;
2674}

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 
)
2256{
2257 CallScriptProcHandlers(aurApp, eventInfo);
2258
2259 for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
2260 if (aurApp->HasEffect(i))
2261 // OnEffectProc / AfterEffectProc hooks handled in AuraEffect::HandleProc()
2262 GetEffect(i)->HandleProc(aurApp, eventInfo);
2263
2264 CallScriptAfterProcHandlers(aurApp, eventInfo);
2265
2266 // Remove aura if we've used last charge to proc
2267 if (IsUsingCharges() && !GetCharges())
2268 Remove();
2269}
bool HasEffect(uint8 effect) const
Definition SpellAuras.h:67
void HandleProc(AuraApplication *aurApp, ProcEventInfo &eventInfo)
Definition SpellAuraEffects.cpp:1184
void CallScriptAfterProcHandlers(AuraApplication const *aurApp, ProcEventInfo &eventInfo)
Definition SpellAuras.cpp:2625
bool CallScriptProcHandlers(AuraApplication const *aurApp, ProcEventInfo &eventInfo)
Definition SpellAuras.cpp:2608

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
292{
293 ASSERT_NODEBUGINFO(spellproto);
294 ASSERT_NODEBUGINFO(owner);
295 ASSERT_NODEBUGINFO(caster || casterGUID);
296 ASSERT_NODEBUGINFO(tryEffMask <= MAX_EFFECT_MASK);
297 uint8 effMask = Aura::BuildEffectMaskForOwner(spellproto, tryEffMask, owner);
298 if (!effMask)
299 return nullptr;
300 return Create(spellproto, effMask, owner, caster, baseAmount, castItem, casterGUID, itemGUID);
301}
static uint8 BuildEffectMaskForOwner(SpellInfo const *spellProto, uint8 avalibleEffectMask, WorldObject *owner)
Definition SpellAuras.cpp:237
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:303

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
266{
267 ASSERT_NODEBUGINFO(spellproto);
268 ASSERT_NODEBUGINFO(owner);
269 ASSERT_NODEBUGINFO(caster || casterGUID);
270 ASSERT_NODEBUGINFO(tryEffMask <= MAX_EFFECT_MASK);
271 if (refresh)
272 *refresh = false;
273 uint8 effMask = Aura::BuildEffectMaskForOwner(spellproto, tryEffMask, owner);
274 if (!effMask)
275 return nullptr;
276 if (Aura* foundAura = owner->ToUnit()->_TryStackingOrRefreshingExistingAura(spellproto, effMask, caster, baseAmount, castItem, casterGUID, periodicReset))
277 {
278 // we've here aura, which script triggered removal after modding stack amount
279 // check the state here, so we won't create new Aura object
280 if (foundAura->IsRemoved())
281 return nullptr;
282
283 if (refresh)
284 *refresh = true;
285 return foundAura;
286 }
287 else
288 return Create(spellproto, effMask, owner, caster, baseAmount, castItem, casterGUID);
289}
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:4483

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

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

◆ UnregisterSingleTarget()

void Aura::UnregisterSingleTarget ( )
1120{
1122 Unit* caster = GetCaster();
1123 if (!caster)
1124 {
1125 LOG_INFO("spells", "Aura::UnregisterSingleTarget: (A1) - {}, {}, {}, {}", GetId(), GetOwner()->GetTypeId(), GetOwner()->GetEntry(), GetOwner()->GetName());
1126 LOG_ERROR("spells", "Aura::UnregisterSingleTarget: No caster was found."); //ASSERT(caster);
1127 }
1128 else
1129 caster->GetSingleCastAuras().remove(this);
1130
1131 SetIsSingleTarget(false);
1132}
#define LOG_INFO(filterType__,...)
Definition Log.h:166
void SetIsSingleTarget(bool val)
Definition SpellAuras.h:167
AuraList & GetSingleCastAuras()
Definition Unit.h:1414
bool GetName(uint32 accountId, std::string &name)
Definition AccountMgr.cpp:264

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 
)
741{
742 if (m_duration > 0)
743 {
744 m_duration -= diff;
745 if (m_duration < 0)
746 m_duration = 0;
747
748 // handle ManaPerSecond/ManaPerSecondPerLevel
749 if (m_timeCla)
750 {
751 if (m_timeCla > int32(diff))
752 m_timeCla -= diff;
753 else if (caster)
754 {
755 if (int32 ManaPerSecond = m_spellInfo->ManaPerSecond + m_spellInfo->ManaPerSecondPerLevel * caster->GetLevel())
756 {
757 m_timeCla += 1000 - diff;
758
759 Powers powertype = Powers(m_spellInfo->PowerType);
760 if (powertype == POWER_HEALTH)
761 {
762 if (int32(caster->GetHealth()) > ManaPerSecond)
763 caster->ModifyHealth(-ManaPerSecond);
764 else
765 {
766 Remove();
767 return;
768 }
769 }
770 else
771 {
772 if (int32(caster->GetPower(powertype)) >= ManaPerSecond)
773 caster->ModifyPower(powertype, -ManaPerSecond);
774 else
775 {
776 Remove();
777 return;
778 }
779 }
780 }
781 }
782 }
783 }
784}
Powers
Definition SharedDefines.h:279
@ POWER_HEALTH
Definition SharedDefines.h:289
uint32 PowerType
Definition SpellInfo.h:362
int32 ModifyHealth(int32 val)
Definition Unit.cpp:14264
int32 ModifyPower(Powers power, int32 val, bool withPowerUpdate=true)
Definition Unit.cpp:14322
uint32 GetHealth() const
Definition Unit.h:1093
uint32 GetPower(Powers power) const
Definition Unit.h:1120

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 
)
699{
700 if (owner != m_owner)
701 {
702 ABORT();
703 }
704
705 Unit* caster = GetCaster();
706 // Apply spellmods for channeled auras
707 // used for example when triggered spell of spell:10 is modded
708 Spell* modSpell = nullptr;
709 Player* modOwner = nullptr;
710 if (caster)
711 {
712 modOwner = caster->GetSpellModOwner();
713 if (modOwner)
714 {
715 modSpell = modOwner->FindCurrentSpellBySpellId(GetId());
716 if (modSpell)
717 modOwner->SetSpellModTakingSpell(modSpell, true);
718 }
719 }
720
721 Update(diff, caster);
722
723 if (m_updateTargetMapInterval <= int32(diff))
724 UpdateTargetMap(caster);
725 else
727
728 // update aura effects
729 for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
730 if (m_effects[i])
731 m_effects[i]->Update(diff, caster);
732
733 // remove spellmods after effects update
734 if (modSpell)
735 modOwner->SetSpellModTakingSpell(modSpell, false);
736
738}
void Update(uint32 diff, Unit *caster)
Definition SpellAuraEffects.cpp:912
void Update(uint32 diff, Unit *caster)
Definition SpellAuras.cpp:740
void SetSpellModTakingSpell(Spell *spell, bool apply)
Definition Player.cpp:10111
Definition Spell.h:295
Spell * FindCurrentSpellBySpellId(uint32 spell_id) const
Definition Unit.cpp:4200

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 
)
528{
529 if (IsRemoved())
530 return;
531
533
534 // fill up to date target list
535 // target, effMask
536 std::map<Unit*, uint8> targets;
537
538 FillTargetMap(targets, caster);
539
540 UnitList targetsToRemove;
541
542 // mark all auras as ready to remove
543 for (ApplicationMap::iterator appIter = m_applications.begin(); appIter != m_applications.end(); ++appIter)
544 {
545 std::map<Unit*, uint8>::iterator existing = targets.find(appIter->second->GetTarget());
546 // not found in current area - remove the aura
547 if (existing == targets.end())
548 targetsToRemove.push_back(appIter->second->GetTarget());
549 else
550 {
551 // xinef: check immunities here, so aura wont get removed on every tick and then reapplied
552 if (IsArea())
553 for (uint8 effIndex = 0; effIndex < MAX_SPELL_EFFECTS; ++effIndex)
554 {
555 if ((existing->second & (1 << effIndex)) && existing->first->IsImmunedToSpellEffect(GetSpellInfo(), effIndex))
556 existing->second &= ~(1 << effIndex);
557 }
558
559 // needs readding - remove now, will be applied in next update cycle
560 // (dbcs do not have auras which apply on same type of targets but have different radius, so this is not really needed)
561 if (appIter->second->GetEffectMask() != existing->second || !CanBeAppliedOn(existing->first))
562 targetsToRemove.push_back(appIter->second->GetTarget());
563 // nothing todo - aura already applied
564 // remove from auras to register list
565 targets.erase(existing);
566 }
567 }
568
569 // register auras for units
570 for (std::map<Unit*, uint8>::iterator itr = targets.begin(); itr != targets.end();)
571 {
572 // aura mustn't be already applied on target
573 if (AuraApplication* aurApp = GetApplicationOfTarget(itr->first->GetGUID()))
574 {
575 // the core created 2 different units with same guid
576 // this is a major failue, which i can't fix right now
577 // let's remove one unit from aura list
578 // this may cause area aura "bouncing" between 2 units after each update
579 // but because we know the reason of a crash we can remove the assertion for now
580 if (aurApp->GetTarget() != itr->first)
581 {
582 // remove from auras to register list
583 targets.erase(itr++);
584 continue;
585 }
586 else
587 {
588 // ok, we have one unit twice in target map (impossible, but...)
589 ABORT();
590 }
591 }
592
593 bool addUnit = true;
594 // check target immunities
595 for (uint8 effIndex = 0; effIndex < MAX_SPELL_EFFECTS; ++effIndex)
596 {
597 if ((itr->second & (1 << effIndex)) && itr->first->IsImmunedToSpellEffect(GetSpellInfo(), effIndex))
598 itr->second &= ~(1 << effIndex);
599 }
600 if (!itr->second || itr->first->IsImmunedToSpell(GetSpellInfo()) || !CanBeAppliedOn(itr->first))
601 addUnit = false;
602
603 if (addUnit && !itr->first->IsHighestExclusiveAura(this, true))
604 addUnit = false;
605
606 if (addUnit)
607 {
608 // persistent area aura does not hit flying targets
609 if (GetType() == DYNOBJ_AURA_TYPE)
610 {
611 if (itr->first->IsInFlight())
612 addUnit = false;
613
614 // Allow only 1 persistent area aura to affect our targets if a custom flag is set.
615 if (itr->first->HasAura(GetId()) && GetSpellInfo()->HasAttribute(SPELL_ATTR0_CU_ONLY_ONE_AREA_AURA))
616 addUnit = false;
617 }
618 // unit auras can not stack with each other
619 else // (GetType() == UNIT_AURA_TYPE)
620 {
621 // Allow to remove by stack when aura is going to be applied on owner
622 if (itr->first != GetOwner())
623 {
624 // check if not stacking aura already on target
625 // this one prevents unwanted usefull buff loss because of stacking and prevents overriding auras periodicaly by 2 near area aura owners
626 for (Unit::AuraApplicationMap::iterator iter = itr->first->GetAppliedAuras().begin(); iter != itr->first->GetAppliedAuras().end(); ++iter)
627 {
628 Aura const* aura = iter->second->GetBase();
629 if (!CanStackWith(aura))
630 {
631 addUnit = false;
632 break;
633 }
634 }
635 }
636 }
637 }
638 if (!addUnit)
639 targets.erase(itr++);
640 else
641 {
642 // owner has to be in world, or effect has to be applied to self
643 if (!GetOwner()->IsSelfOrInSameMap(itr->first))
644 {
645 //TODO: There is a crash caused by shadowfiend load addon
646 LOG_FATAL("spells.aura", "Aura {}: Owner {} (map {}) is not in the same map as target {} (map {}).", GetSpellInfo()->Id,
647 GetOwner()->GetName(), GetOwner()->IsInWorld() ? GetOwner()->GetMap()->GetId() : uint32(-1),
648 itr->first->GetName(), itr->first->IsInWorld() ? itr->first->GetMap()->GetId() : uint32(-1));
649 ABORT();
650 }
651 itr->first->_CreateAuraApplication(this, itr->second);
652 ++itr;
653 }
654 }
655
656 // remove auras from units no longer needing them
657 for (UnitList::iterator itr = targetsToRemove.begin(); itr != targetsToRemove.end(); ++itr)
658 if (AuraApplication* aurApp = GetApplicationOfTarget((*itr)->GetGUID()))
659 (*itr)->_UnapplyAura(aurApp, AURA_REMOVE_BY_DEFAULT);
660
661 if (!apply)
662 return;
663
664 // apply aura effects for units
665 for (std::map<Unit*, uint8>::iterator itr = targets.begin(); itr != targets.end(); ++itr)
666 {
667 if (AuraApplication* aurApp = GetApplicationOfTarget(itr->first->GetGUID()))
668 {
669 // owner has to be in world, or effect has to be applied to self
670 ASSERT((!GetOwner()->IsInWorld() && GetOwner() == itr->first) || GetOwner()->IsInMap(itr->first));
671 itr->first->_ApplyAura(aurApp, itr->second);
672 }
673 }
674}
#define LOG_FATAL(filterType__,...)
Definition Log.h:154
@ AURA_REMOVE_BY_DEFAULT
Definition SpellAuraDefines.h:392
static constexpr int32 UPDATE_TARGET_MAP_INTERVAL
Definition SpellAuras.cpp:45
@ SPELL_ATTR0_CU_ONLY_ONE_AREA_AURA
Definition SpellInfo.h:206
virtual void FillTargetMap(std::map< Unit *, uint8 > &targets, Unit *caster)=0
bool CanStackWith(Aura const *existingAura) const
Definition SpellAuras.cpp:1973
bool CanBeAppliedOn(Unit *target)
Definition SpellAuras.cpp:1922
bool IsSelfOrInSameMap(WorldObject const *obj) const
Definition Object.cpp:1301

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

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

Friends And Related Symbol Documentation

◆ Unit::_TryStackingOrRefreshingExistingAura

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

Member Data Documentation

◆ m_applications

◆ m_applyTime

time_t const Aura::m_applyTime
protected

Referenced by GetApplyTime().

◆ m_casterGuid

ObjectGuid const Aura::m_casterGuid
protected

Referenced by GetCasterGUID().

◆ m_casterLevel

uint8 const Aura::m_casterLevel
protected

Referenced by GetCasterLevel().

◆ m_castItemEntry

uint32 const Aura::m_castItemEntry
protected

Referenced by GetCastItemEntry().

◆ m_castItemGuid

ObjectGuid const Aura::m_castItemGuid
protected

◆ m_duration

int32 Aura::m_duration
protected

◆ m_effects

◆ m_isRemoved

bool Aura::m_isRemoved
protected

Referenced by _Remove(), and IsRemoved().

◆ m_isSingleTarget

bool Aura::m_isSingleTarget
protected

◆ m_isUsingCharges

bool Aura::m_isUsingCharges
protected

◆ m_loadedScripts

◆ m_maxDuration

◆ m_owner

WorldObject* const Aura::m_owner
protected

◆ m_procCharges

uint8 Aura::m_procCharges
protected

◆ m_removedApplications

Unit::AuraApplicationList Aura::m_removedApplications
private

◆ m_spellInfo

◆ m_stackAmount

uint8 Aura::m_stackAmount
protected

◆ m_timeCla

int32 Aura::m_timeCla
protected

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

◆ m_triggeredByAuraSpellInfo

SpellInfo const* Aura::m_triggeredByAuraSpellInfo
private

◆ m_updateTargetMapInterval

int32 Aura::m_updateTargetMapInterval
protected

Referenced by UpdateOwner(), and UpdateTargetMap().


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