18#ifndef TRINITY_SPELLAURAS_H
19#define TRINITY_SPELLAURAS_H
27struct ProcTriggerSpell;
44#define UPDATE_TARGET_MAP_INTERVAL 500
62 void _InitFlags(
Unit* caster,
uint8 effMask);
63 void _HandleEffect(
uint8 effIndex,
bool apply);
77 void UpdateApplyEffectMask(
uint8 newEffMask,
bool canHandleNewEffects);
84 void BuildUpdatePacket(
ByteBuffer& data,
bool remove)
const;
85 void ClientUpdate(
bool remove =
false);
107 static Aura* TryRefreshStackOrCreate(
AuraCreateInfo& createInfo,
bool updateEffectMask =
true);
111 void _InitEffects(
uint8 effMask,
Unit* caster,
int32 const* baseAmount);
112 void SaveCasterInfo(
Unit* caster);
120 Unit* GetCaster()
const;
133 void UpdateTargetMap(
Unit* caster,
bool apply =
true);
137 void _ApplyEffectForTargets(
uint8 effIndex);
146 int32 CalcMaxDuration(
Unit* caster)
const;
149 void SetDuration(
int32 duration,
bool withMods =
false);
150 void RefreshDuration(
bool withMods =
false);
151 void RefreshTimers(
bool resetPeriodicTimer);
152 bool IsExpired()
const {
return !GetDuration() && !m_dropEvent; }
156 void SetCharges(
uint8 charges);
157 uint8 CalcMaxCharges(
Unit* caster)
const;
165 void SetStackAmount(
uint8 num);
173 float GetDonePct()
const {
return _casterInfo.BonusDonePct; }
174 void SetDonePct(
float val) { _casterInfo.BonusDonePct = val; }
176 bool HasMoreThanOneEffectForType(
AuraType auraType)
const;
178 bool IsPassive()
const;
179 bool IsDeathPersistent()
const;
181 bool IsRemovedOnShapeLost(
Unit* target)
const;
183 bool CanBeSaved()
const;
185 bool CanBeSentToClient()
const;
188 bool IsSingleTargetWith(
Aura const* aura)
const;
190 void UnregisterSingleTarget();
191 int32 CalcDispelChance(
Unit const* auraTarget,
bool offensive)
const;
193 void SetLoadedState(
int32 maxduration,
int32 duration,
int32 charges,
uint8 stackamount,
uint8 recalculateMask,
float critChance,
bool applyResilience,
int32* amount);
196 bool CanPeriodicTickCrit(
Unit const* caster)
const;
197 float CalcPeriodicCritChance(
Unit const* caster)
const;
200 bool HasEffectType(
AuraType type)
const;
203 void RecalculateAmountOfEffects();
208 void GetApplicationVector(std::vector<AuraApplication*>& applicationVector)
const;
213 void SetNeedClientUpdateForTargets()
const;
214 void HandleAuraSpecificMods(
AuraApplication const* aurApp,
Unit* caster,
bool apply,
bool onReapply);
215 bool CanBeAppliedOn(
Unit* target);
216 bool CheckAreaTarget(
Unit* target);
217 bool CanStackWith(
Aura const* existingAura)
const;
219 bool IsProcOnCooldown(
TimePoint now)
const;
220 void AddProcCooldown(
TimePoint cooldownEnd);
221 void ResetProcCooldown();
231 bool CallScriptCheckAreaTargetHandlers(
Unit* target);
232 void CallScriptDispel(
DispelInfo* dispelInfo);
233 void CallScriptAfterDispel(
DispelInfo* dispelInfo);
239 void CallScriptEffectUpdatePeriodicHandlers(
AuraEffect* aurEff);
240 void CallScriptEffectCalcAmountHandlers(
AuraEffect const* aurEff,
int32& amount,
bool& canBeRecalculated);
241 void CallScriptEffectCalcPeriodicHandlers(
AuraEffect const* aurEff,
bool& isPeriodic,
int32& amplitude);
263 template <
class Script>
266 return dynamic_cast<Script*
>(GetScriptByName(scriptName));
282 AuraScript* GetScriptByName(std::string
const& scriptName)
const;
283 void _DeleteRemovedApplications();
330 void FillTargetMap(std::unordered_map<Unit*, uint8>& targets,
Unit* caster)
override;
336 void AddStaticApplication(
Unit* target,
uint8 effMask);
351 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
void operator()(Aura *) const