18#ifndef TRINITY_SPELLAURAS_H
19#define TRINITY_SPELLAURAS_H
30struct ProcTriggerSpell;
58#define UPDATE_TARGET_MAP_INTERVAL 500
78 void _HandleEffect(
uint8 effIndex,
bool apply);
92 void UpdateApplyEffectMask(
uint32 newEffMask,
bool canHandleNewEffects);
93 void AddEffectToApplyEffectMask(
SpellEffIndex spellEffectIndex);
98 void SetNeedClientUpdate();
101 void ClientUpdate(
bool remove =
false);
133 bool* IsRefresh =
nullptr;
135 bool ResetPeriodicTimer =
true;
163 std::array<SpellEffectValue, MAX_SPELL_EFFECTS>
Amounts;
175 static Aura* TryRefreshStackOrCreate(
AuraCreateInfo& createInfo,
bool updateEffectMask =
true);
193 Unit* GetCaster()
const;
207 void UpdateTargetMap(
Unit* caster,
bool apply =
true);
211 void _ApplyEffectForTargets(
uint8 effIndex);
220 int32 CalcMaxDuration(
Unit* caster)
const;
221 static int32 CalcMaxDuration(
SpellInfo const* spellInfo,
WorldObject const* caster, std::vector<SpellPowerCost>
const* powerCosts);
223 void SetDuration(
int32 duration,
bool withMods =
false);
224 void RefreshDuration(
bool withMods =
false);
225 void RefreshTimers(
bool resetPeriodicTimer);
226 bool IsExpired()
const {
return !GetDuration() && !m_dropEvent; }
230 void SetCharges(
uint8 charges);
231 uint8 CalcMaxCharges(
Unit* caster)
const;
239 void SetStackAmount(
uint8 num);
241 uint32 CalcMaxStackAmount()
const;
242 bool IsUsingStacks()
const;
246 bool HasMoreThanOneEffectForType(
AuraType auraType)
const;
248 bool IsPassive()
const;
249 bool IsDeathPersistent()
const;
251 bool IsRemovedOnShapeLost(
Unit* target)
const;
253 bool CanBeSaved()
const;
257 bool IsSingleTargetWith(
Aura const* aura)
const;
259 void UnregisterSingleTarget();
260 int32 CalcDispelChance(
Unit const* auraTarget,
bool offensive)
const;
275 bool CanPeriodicTickCrit()
const;
278 bool HasEffectType(
AuraType type)
const;
279 static bool EffectTypeNeedsSendingAmount(
AuraType type);
281 uint32 GetEffectMask()
const;
282 void RecalculateAmountOfEffects();
287 void GetApplicationVector(std::vector<AuraApplication*>& applications)
const;
290 bool IsAppliedOnTarget(
ObjectGuid guid)
const;
292 void SetNeedClientUpdateForTargets()
const;
293 void HandleAuraSpecificMods(
AuraApplication const* aurApp,
Unit* caster,
bool apply,
bool onReapply);
294 bool CanBeAppliedOn(
Unit* target);
295 bool CheckAreaTarget(
Unit* target);
296 bool CanStackWith(
Aura const* existingAura)
const;
298 bool IsProcOnCooldown(
TimePoint now)
const;
300 void ResetProcCooldown();
309 float CalcPPMProcChance(
Unit* actor)
const;
316 bool CallScriptCheckAreaTargetHandlers(
Unit* target);
317 void CallScriptDispel(
DispelInfo* dispelInfo);
318 void CallScriptAfterDispel(
DispelInfo* dispelInfo);
319 void CallScriptOnHeartbeat();
325 void CallScriptEffectUpdatePeriodicHandlers(
AuraEffect* aurEff);
327 void CallScriptEffectCalcPeriodicHandlers(
AuraEffect const* aurEff,
bool& isPeriodic,
int32& amplitude);
338 void CallScriptEnterLeaveCombatHandlers(
AuraApplication const* aurApp,
bool isNowInCombat);
354 template <
class Script>
357 return static_cast<Script*
>(GetScriptByType(
typeid(
Script)));
388 AuraScript* GetScriptByType(std::type_info
const& type)
const;
389 void _DeleteRemovedApplications();
445 void FillTargetMap(std::unordered_map<Unit*, uint32>& targets,
Unit* caster)
override;
451 void AddStaticApplication(
Unit* target,
uint32 effMask);
453 void Heartbeat()
override;
454 void HandlePeriodicFoodSpellVisualKit();
467 DynObjAura(
SpellInfo const* spellproto,
ObjectGuid castId,
uint32 effMask,
WorldObject* owner,
Unit* caster,
Difficulty castDifficulty,
int32 *baseAmount,
Item* castItem,
ObjectGuid casterGUID,
ObjectGuid castItemGuid,
uint32 castItemId,
int32 castItemLevel);
471 void FillTargetMap(std::unordered_map<Unit*, uint32>& targets,
Unit* caster)
override;
#define MAX_SPELL_EFFECTS
std::chrono::steady_clock::time_point TimePoint
time_point shorthand typedefs
std::string GetDebugInfo()
std::optional< T > Optional
Optional helper class to wrap optional values within.
double SpellEffectValue
This is a double instead of float to be able to store full range of int32.
std::vector< AuraEffect * > AuraEffectVector
void SetRemoveMode(AuraRemoveMode mode)
bool IsNeedClientUpdate() const
uint32 GetEffectsToApply() const
uint32 GetEffectMask() const
AuraRemoveMode GetRemoveMode() const
bool HasEffect(uint8 effect) const
AuraRemoveMode _removeMode
Aura & operator=(Aura &&)=delete
ObjectGuid GetCastId() const
static Aura * Create(AuraCreateInfo &createInfo)
int32 GetMaxDuration() const
SpellCastVisual m_spellVisual
Trinity::unique_weak_ptr< AuraEffect > GetEffectWeakPtr(SpellEffIndex index) const
Trinity::unique_trackable_ptr< Aura > m_scriptRef
UnitAura const * ToUnitAura() const
ApplicationMap const & GetApplicationMap()
int32 GetCastItemLevel() const
AuraEffectVector _effects
Unit * GetUnitOwner() const
void SetLastProcAttemptTime(TimePoint lastProcAttemptTime)
Trinity::IteratorPair< DBStorageIterator< AuraEffect * > > GetAuraEffects()
Trinity::IteratorPair< DBStorageIterator< AuraEffect const * > > GetAuraEffects() const
DynamicObject * GetDynobjOwner() const
void SetUsingCharges(bool val)
void _RegisterForTargets()
ObjectGuid GetCasterGUID() const
bool HasEffect(uint8 effIndex) const
std::vector< AuraApplication * > _removedApplications
uint8 GetCasterLevel() const
WorldObject * GetOwner() const
Aura(Aura const &)=delete
ApplicationMap m_applications
int32 GetDuration() const
bool IsUsingCharges() const
uint32 GetCastItemId() const
TimePoint m_lastProcSuccessTime
ObjectGuid const m_castItemGuid
virtual void FillTargetMap(std::unordered_map< Unit *, uint32 > &targets, Unit *caster)=0
DynObjAura * ToDynObjAura()
std::vector< AuraScript * > m_loadedScripts
int32 CalcMaxDuration() const
std::size_t GetAuraEffectCount() const
SpellInfo const *const m_spellInfo
TimePoint m_lastProcAttemptTime
ObjectGuid const m_castId
uint8 GetStackAmount() const
Aura & operator=(Aura const &)=delete
Trinity::unique_weak_ptr< Aura > GetWeakPtr() const
WorldObject *const m_owner
SpellInfo const * GetSpellInfo() const
ObjectGuid GetCastItemGUID() const
void SetMaxDuration(int32 duration)
ObjectGuid const m_casterGuid
uint8 const m_casterLevel
Script * GetScript() const
void SetLastProcSuccessTime(TimePoint lastProcSuccessTime)
Difficulty GetCastDifficulty() const
void SetIsSingleTarget(bool val)
uint8 CalcMaxCharges() const
time_t GetApplyTime() const
std::vector< SpellPowerEntry const * > m_periodicCosts
int32 m_updateTargetMapInterval
Difficulty const m_castDifficulty
DynObjAura const * ToDynObjAura() const
std::unordered_map< ObjectGuid, AuraApplication * > ApplicationMap
ChargeDropEvent * m_dropEvent
SpellCastVisual GetSpellVisual() const
virtual void Remove(AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)=0
bool DropCharge(AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
bool IsSingleTarget() const
DynObjAura(SpellInfo const *spellproto, ObjectGuid castId, uint32 effMask, WorldObject *owner, Unit *caster, Difficulty castDifficulty, int32 *baseAmount, Item *castItem, ObjectGuid casterGUID, ObjectGuid castItemGuid, uint32 castItemId, int32 castItemLevel)
Utility class to enable range for loop syntax for multimap.equal_range uses.
Specialized variant of std::shared_ptr that enforces unique ownership and/or std::unique_ptr with std...
Trinity::unique_trackable_ptr companion class, replicating what std::weak_ptr is to std::shared_ptr.
DiminishingGroup m_AuraDRGroup
void SetDiminishGroup(DiminishingGroup group)
DiminishingGroup GetDiminishGroup() const
std::unordered_map< ObjectGuid, uint32 > _staticApplications
constexpr IteratorPair< iterator, end_iterator > MakeIteratorPair(iterator first, end_iterator second)
AuraCreateInfo & SetSpellVisual(SpellCastVisual const &spellVisual)
AuraCreateInfo & SetCaster(Unit *caster)
AuraCreateInfo & SetCastItem(ObjectGuid const &guid, uint32 itemId, int32 itemLevel)
AuraCreateInfo & SetCasterGUID(ObjectGuid const &guid)
uint32 GetAuraEffectMask() const
SpellInfo const * GetSpellInfo() const
Optional< SpellCastVisual > _spellVisual
AuraCreateInfo & SetBaseAmount(SpellEffectValue const *bp)
AuraCreateInfo & SetIsRefresh(bool *isRefresh)
AuraCreateInfo & SetOwnerEffectMask(uint32 effMask)
AuraCreateInfo & SetStackAmount(int32 stackAmount)
AuraCreateInfo & SetPeriodicReset(bool reset)
friend std::strong_ordering operator<=>(AuraKey const &left, AuraKey const &right)=default
std::array< SpellEffectValue, MAX_SPELL_EFFECTS > Amounts
std::array< SpellEffectValue, MAX_SPELL_EFFECTS > BaseAmounts
void operator()(Aura *) const