18#ifndef TRINITY_SPELLAURAS_H
19#define TRINITY_SPELLAURAS_H
27struct ProcTriggerSpell;
52#define UPDATE_TARGET_MAP_INTERVAL 500
70 void _InitFlags(
Unit* caster,
uint8 effMask);
71 void _HandleEffect(
uint8 effIndex,
bool apply);
85 void UpdateApplyEffectMask(
uint8 newEffMask,
bool canHandleNewEffects);
93 void ClientUpdate(
bool remove =
false);
132 static Aura* TryRefreshStackOrCreate(
AuraCreateInfo& createInfo,
bool updateEffectMask =
true);
136 void _InitEffects(
uint8 effMask,
Unit* caster,
int32 const* baseAmount);
137 void SaveCasterInfo(
Unit* caster);
145 Unit* GetCaster()
const;
158 void UpdateTargetMap(
Unit* caster,
bool apply =
true);
162 void _ApplyEffectForTargets(
uint8 effIndex);
171 int32 CalcMaxDuration(
Unit* caster)
const;
174 void SetDuration(
int32 duration,
bool withMods =
false);
175 void RefreshDuration(
bool withMods =
false);
176 void RefreshTimers(
bool resetPeriodicTimer);
177 bool IsExpired()
const {
return !GetDuration() && !m_dropEvent; }
181 void SetCharges(
uint8 charges);
182 uint8 CalcMaxCharges(
Unit* caster)
const;
190 void SetStackAmount(
uint8 num);
198 float GetDonePct()
const {
return _casterInfo.BonusDonePct; }
199 void SetDonePct(
float val) { _casterInfo.BonusDonePct = val; }
201 bool HasMoreThanOneEffectForType(
AuraType auraType)
const;
203 bool IsPassive()
const;
204 bool IsDeathPersistent()
const;
206 bool IsRemovedOnShapeLost(
Unit* target)
const;
208 bool CanBeSaved()
const;
210 bool CanBeSentToClient()
const;
213 bool IsSingleTargetWith(
Aura const* aura)
const;
215 void UnregisterSingleTarget();
216 int32 CalcDispelChance(
Unit const* auraTarget,
bool offensive)
const;
218 void SetLoadedState(
int32 maxDuration,
int32 duration,
int32 charges,
uint8 stackAmount,
uint8 recalculateMask,
float critChance,
bool applyResilience,
int32* amount);
221 bool CanPeriodicTickCrit(
Unit const* caster)
const;
222 float CalcPeriodicCritChance(
Unit const* caster)
const;
225 bool HasEffectType(
AuraType type)
const;
228 void RecalculateAmountOfEffects();
233 void GetApplicationVector(std::vector<AuraApplication*>& applicationVector)
const;
238 void SetNeedClientUpdateForTargets()
const;
239 void HandleAuraSpecificMods(
AuraApplication const* aurApp,
Unit* caster,
bool apply,
bool onReapply);
240 bool CanBeAppliedOn(
Unit* target);
241 bool CheckAreaTarget(
Unit* target);
242 bool CanStackWith(
Aura const* existingAura)
const;
244 bool IsProcOnCooldown(
TimePoint now)
const;
245 void AddProcCooldown(
TimePoint cooldownEnd);
246 void ResetProcCooldown();
256 bool CallScriptCheckAreaTargetHandlers(
Unit* target);
257 void CallScriptDispel(
DispelInfo* dispelInfo);
258 void CallScriptAfterDispel(
DispelInfo* dispelInfo);
264 void CallScriptEffectUpdatePeriodicHandlers(
AuraEffect* aurEff);
265 void CallScriptEffectCalcAmountHandlers(
AuraEffect const* aurEff,
int32& amount,
bool& canBeRecalculated);
266 void CallScriptEffectCalcPeriodicHandlers(
AuraEffect const* aurEff,
bool& isPeriodic,
int32& amplitude);
288 template <
class Script>
291 return dynamic_cast<Script*
>(GetScriptByName(scriptName));
307 AuraScript* GetScriptByName(std::string
const& scriptName)
const;
308 void _DeleteRemovedApplications();
355 void FillTargetMap(std::unordered_map<Unit*, uint8>& targets,
Unit* caster)
override;
361 void AddStaticApplication(
Unit* target,
uint8 effMask);
376 void FillTargetMap(std::unordered_map<Unit*, uint8>& targets,
Unit* caster)
override;
#define MAX_SPELL_EFFECTS
std::chrono::steady_clock::time_point TimePoint
time_point shorthand typedefs
std::string GetDebugInfo()
void SetRemoveMode(AuraRemoveMode mode)
uint8 GetEffectMask() const
bool IsNeedClientUpdate() const
uint8 GetEffectsToApply() const
void SetNeedClientUpdate()
AuraRemoveMode GetRemoveMode() const
bool HasEffect(uint8 effect) const
AuraRemoveMode _removeMode
Aura & operator=(Aura &&)=delete
static Aura * Create(AuraCreateInfo &createInfo)
int32 GetMaxDuration() const
Trinity::unique_trackable_ptr< Aura > m_scriptRef
UnitAura const * ToUnitAura() const
void SetCritChance(float val)
ApplicationMap const & GetApplicationMap()
Unit * GetUnitOwner() const
AuraApplication const * GetApplicationOfTarget(ObjectGuid guid) const
DynamicObject * GetDynobjOwner() const
void SetUsingCharges(bool val)
void _RegisterForTargets()
ObjectGuid GetCasterGUID() const
bool HasEffect(uint8 effIndex) const
std::vector< AuraApplication * > _removedApplications
float GetCritChance() const
uint8 GetCasterLevel() const
WorldObject * GetOwner() const
Aura(Aura const &)=delete
void SetCanApplyResilience(bool val)
bool IsAppliedOnTarget(ObjectGuid guid) const
ApplicationMap m_applications
int32 GetDuration() const
bool IsUsingCharges() const
AuraEffect * GetEffect(uint8 effIndex) const
ObjectGuid const m_castItemGuid
bool CanApplyResilience() const
DynObjAura * ToDynObjAura()
std::vector< AuraScript * > m_loadedScripts
int32 CalcMaxDuration() const
uint8 GetEffectMask() const
SpellInfo const *const m_spellInfo
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
AuraApplication * GetApplicationOfTarget(ObjectGuid guid)
void SetIsSingleTarget(bool val)
uint8 CalcMaxCharges() const
void SetDonePct(float val)
virtual void FillTargetMap(std::unordered_map< Unit *, uint8 > &targets, Unit *caster)=0
time_t GetApplyTime() const
int32 m_updateTargetMapInterval
DynObjAura const * ToDynObjAura() const
std::unordered_map< ObjectGuid, AuraApplication * > ApplicationMap
Script * GetScript(std::string const &scriptName) const
ChargeDropEvent * m_dropEvent
virtual void Remove(AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)=0
bool DropCharge(AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
bool IsSingleTarget() const
ChargeDropEvent(Aura *base, AuraRemoveMode mode)
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, uint8 > _staticApplications
friend std::strong_ordering operator<=>(AuraKey const &left, AuraKey const &right)=default
std::array< int32, MAX_SPELL_EFFECTS > BaseAmounts
std::array< int32, MAX_SPELL_EFFECTS > Amounts
void operator()(Aura *) const