*Update of aura system.
--HG-- branch : trunk
This commit is contained in:
+164
-166
@@ -22,14 +22,6 @@
|
||||
|
||||
#include "SpellAuraDefines.h"
|
||||
|
||||
struct Modifier
|
||||
{
|
||||
AuraType m_auraname;
|
||||
int32 m_amount;
|
||||
int32 m_miscvalue;
|
||||
uint32 periodictime;
|
||||
};
|
||||
|
||||
class Unit;
|
||||
struct SpellEntry;
|
||||
struct SpellModifier;
|
||||
@@ -37,8 +29,9 @@ struct ProcTriggerSpell;
|
||||
|
||||
// forward decl
|
||||
class Aura;
|
||||
class AuraEffect;
|
||||
|
||||
typedef void(Aura::*pAuraHandler)(bool Apply, bool Real);
|
||||
typedef void(AuraEffect::*pAuraHandler)(bool Apply, bool Real);
|
||||
// Real == true at aura add/remove
|
||||
// Real == false at aura mod unapply/reapply; when adding/removing dependent aura/item/stat mods
|
||||
//
|
||||
@@ -54,9 +47,121 @@ typedef void(Aura::*pAuraHandler)(bool Apply, bool Real);
|
||||
|
||||
class TRINITY_DLL_SPEC Aura
|
||||
{
|
||||
friend Aura* CreateAura(SpellEntry const* spellproto, uint32 eff, int32 *currentBasePoints, Unit *target, Unit *caster, Item* castItem);
|
||||
|
||||
friend void Player::SendAurasForTarget(Unit *target);
|
||||
public:
|
||||
virtual ~Aura();
|
||||
Aura(SpellEntry const* spellproto, uint32 effMask, int32 *currentBasePoints, Unit *target, Unit *caster = NULL, Item* castItem = NULL);
|
||||
|
||||
SpellEntry const* GetSpellProto() const { return m_spellProto; }
|
||||
uint32 GetId() const{ return m_spellProto->Id; }
|
||||
uint64 GetCastItemGUID() const { return m_castItemGuid; }
|
||||
|
||||
uint64 const& GetCasterGUID() const { return m_caster_guid; }
|
||||
Unit* GetCaster() const;
|
||||
Unit* GetTarget() const { return m_target; }
|
||||
|
||||
time_t GetAuraApplyTime() const { return m_applyTime; }
|
||||
|
||||
int32 GetAuraMaxDuration() const { return m_maxduration; }
|
||||
void SetAuraMaxDuration(int32 duration) { m_maxduration = duration; }
|
||||
int32 GetAuraDuration() const { return m_duration; }
|
||||
void SetAuraDuration(int32 duration);
|
||||
void RefreshAura(){ SetAuraDuration (m_maxduration); }
|
||||
|
||||
void SendAuraUpdate();
|
||||
uint8 GetAuraSlot() const { return m_auraSlot; }
|
||||
void SetAuraSlot(uint8 slot) { m_auraSlot = slot; }
|
||||
uint8 GetAuraCharges() const { return m_procCharges; }
|
||||
void SetAuraCharges(uint8 charges);
|
||||
bool DropAuraCharge();
|
||||
|
||||
int8 GetStackAmount() const {return m_stackAmount;}
|
||||
void SetStackAmount(uint8 num);
|
||||
bool modStackAmount(int32 num); // return true if last charge dropped
|
||||
uint32 GetAuraStateMask(){return m_auraStateMask;}
|
||||
void SetAuraState(uint8 num){m_auraStateMask |= 1<<(num-1);} //modifies aura's aura state (not unit!)
|
||||
|
||||
void SetRemoveMode(AuraRemoveMode mode) { m_removeMode = mode; }
|
||||
uint8 GetRemoveMode() const {return m_removeMode;}
|
||||
|
||||
inline uint8 GetEffectMask() const {return m_auraFlags & 7;}
|
||||
AuraEffect * GetPartAura (uint8 effIndex) const {return m_partAuras[effIndex];}
|
||||
bool SetPartAura(AuraEffect* aurEff, uint8 effIndex);
|
||||
|
||||
bool IsPositive() const { return m_positive; }
|
||||
void SetNegative() { m_positive = false; }
|
||||
void SetPositive() { m_positive = true; }
|
||||
bool IsPermanent() const { return m_permanent; }
|
||||
bool IsPassive() const { return m_isPassive; }
|
||||
bool IsDeathPersistent() const { return m_isDeathPersist; }
|
||||
bool IsRemovedOnShapeLost() const { return m_isRemovedOnShapeLost; }
|
||||
bool IsUpdated() const { return m_updated; }
|
||||
void SetUpdated(bool val) { m_updated = val; }
|
||||
|
||||
bool IsInUse() const;
|
||||
bool IsPersistent() const;
|
||||
bool IsAreaAura() const;
|
||||
bool IsAuraType(AuraType type) const;
|
||||
void SetLoadedState(uint64 caster_guid,int32 maxduration,int32 duration,int32 charges, uint8 stackamount, int32 * amount);
|
||||
bool HasEffect(uint8 effIndex) const {return bool (m_partAuras[effIndex]);}
|
||||
inline void HandleEffects(bool apply)
|
||||
{
|
||||
for (uint8 i = 0; i<MAX_SPELL_EFFECTS;++i)
|
||||
if (m_partAuras[i])
|
||||
m_target->HandleAuraEffect(m_partAuras[i], apply);
|
||||
}
|
||||
void ApplyAllModifiers(bool apply, bool Real=false);
|
||||
|
||||
void Update(uint32 diff);
|
||||
|
||||
void _AddAura();
|
||||
void _RemoveAura();
|
||||
|
||||
// Allow Apply Aura Handler to modify and access m_AuraDRGroup
|
||||
void setDiminishGroup(DiminishingGroup group) { m_AuraDRGroup = group; }
|
||||
DiminishingGroup getDiminishGroup() const { return m_AuraDRGroup; }
|
||||
|
||||
// Single cast aura helpers
|
||||
void UnregisterSingleCastAura();
|
||||
bool IsSingleTarget() const {return m_isSingleTargetAura;}
|
||||
void SetIsSingleTarget(bool val) { m_isSingleTargetAura = val;}
|
||||
|
||||
private:
|
||||
SpellEntry const *m_spellProto;
|
||||
Unit * const m_target;
|
||||
uint64 m_caster_guid;
|
||||
uint64 m_castItemGuid; // it is NOT safe to keep a pointer to the item because it may get deleted
|
||||
time_t m_applyTime;
|
||||
|
||||
int32 m_maxduration; // Max aura duration
|
||||
int32 m_duration; // Current time
|
||||
int32 m_timeCla; // Timer for power per sec calcultion
|
||||
|
||||
AuraRemoveMode m_removeMode:8; // Store info for know remove aura reason
|
||||
DiminishingGroup m_AuraDRGroup:8; // Diminishing
|
||||
|
||||
uint8 m_auraSlot; // Aura slot on unit (for show in client)
|
||||
uint8 m_auraFlags; // Aura info flag (for send data to client)
|
||||
uint8 m_auraLevel; // Aura level (store caster level for correct show level dep amount)
|
||||
uint8 m_procCharges; // Aura charges (0 for infinite)
|
||||
uint32 m_procDamage; // used in aura proc code
|
||||
uint8 m_stackAmount; // Aura stack amount
|
||||
uint32 m_auraStateMask;
|
||||
AuraEffect * m_partAuras[3];
|
||||
|
||||
bool m_isDeathPersist:1;
|
||||
bool m_isRemovedOnShapeLost:1;
|
||||
bool m_isPassive:1;
|
||||
bool m_positive:1;
|
||||
bool m_permanent:1;
|
||||
bool m_updated:1; // Prevent remove aura by stack if set
|
||||
bool m_isSingleTargetAura:1; // true if it's a single target spell and registered at caster - can change at spell steal for example
|
||||
};
|
||||
class TRINITY_DLL_SPEC AuraEffect
|
||||
{
|
||||
public:
|
||||
friend AuraEffect* CreateAuraEffect(Aura * parentAura, uint32 effIndex, int32 *currentBasePoints, Unit * caster, Item * castItem);
|
||||
friend void Aura::SetStackAmount(uint8 stackAmount);
|
||||
//aura handlers
|
||||
void HandleNULL(bool, bool)
|
||||
{
|
||||
@@ -211,192 +316,85 @@ class TRINITY_DLL_SPEC Aura
|
||||
void HandleAuraIncreaseBaseHealthPercent(bool Apply, bool Real);
|
||||
void HandleNoReagentUseAura(bool Apply, bool Real);
|
||||
void HandlePhase(bool Apply, bool Real);
|
||||
|
||||
void HandleAuraStateFrozen(bool apply);
|
||||
|
||||
virtual ~Aura();
|
||||
|
||||
void SetModifier(AuraType t, int32 a, uint32 pt, int32 miscValue);
|
||||
Modifier* GetModifier() {return &m_modifier;}
|
||||
int32 GetMiscValue() {return m_spellProto->EffectMiscValue[m_effIndex];}
|
||||
int32 GetMiscBValue() {return m_spellProto->EffectMiscValueB[m_effIndex];}
|
||||
|
||||
SpellEntry const* GetSpellProto() const { return m_spellProto; }
|
||||
uint32 GetId() const{ return m_spellProto->Id; }
|
||||
uint64 GetCastItemGUID() const { return m_castItemGuid; }
|
||||
uint32 GetEffIndex() const{ return m_effIndex; }
|
||||
int32 GetBasePoints() const { return m_currentBasePoints; }
|
||||
|
||||
int32 GetAuraMaxDuration() const { return m_maxduration; }
|
||||
void SetAuraMaxDuration(int32 duration) { m_maxduration = duration; }
|
||||
int32 GetAuraDuration() const { return m_duration; }
|
||||
void SetAuraDuration(int32 duration)
|
||||
{
|
||||
m_duration = duration;
|
||||
if (duration<0)
|
||||
m_permanent=true;
|
||||
else
|
||||
m_permanent=false;
|
||||
}
|
||||
void SetAuraDurationAndUpdate(int32 duration)
|
||||
{
|
||||
SetAuraDuration (duration);
|
||||
m_target->UpdateAuraForGroup(GetAuraSlot());
|
||||
}
|
||||
time_t GetAuraApplyTime() { return m_applyTime; }
|
||||
|
||||
SpellModifier *getAuraSpellMod() {return m_spellmod; }
|
||||
|
||||
uint64 const& GetCasterGUID() const { return m_caster_guid; }
|
||||
Unit* GetCaster() const;
|
||||
Unit* GetTarget() const { return m_target; }
|
||||
void SetTarget(Unit* target) { m_target = target; }
|
||||
void SetLoadedState(uint64 caster_guid,int32 damage,int32 maxduration,int32 duration,int32 charges)
|
||||
{
|
||||
m_caster_guid = caster_guid;
|
||||
m_modifier.m_amount = damage;
|
||||
m_maxduration = maxduration;
|
||||
m_duration = duration;
|
||||
m_procCharges = charges;
|
||||
}
|
||||
|
||||
uint8 GetAuraSlot() const { return m_auraSlot; }
|
||||
void SetAuraSlot(uint8 slot) { m_auraSlot = slot; }
|
||||
uint8 GetAuraCharges() const { return m_procCharges; }
|
||||
void SetAuraCharges(uint8 charges)
|
||||
{
|
||||
if (m_procCharges == charges)
|
||||
return;
|
||||
m_procCharges = charges;
|
||||
m_target->UpdateAuraForGroup(GetAuraSlot());
|
||||
}
|
||||
bool DropAuraCharge() // return true if last charge dropped
|
||||
{
|
||||
if (m_procCharges == 0)
|
||||
return false;
|
||||
m_procCharges--;
|
||||
m_target->UpdateAuraForGroup(GetAuraSlot());
|
||||
return m_procCharges == 0;
|
||||
}
|
||||
|
||||
void UnregisterSingleCastAura();
|
||||
|
||||
int8 GetStackAmount() {return m_stackAmount;}
|
||||
//int32 GetModifierValuePerStack() {return m_modifier.m_amount / m_stackAmount;}
|
||||
void SetStackAmount(uint8 num);
|
||||
bool modStackAmount(int32 num); // return true if last charge dropped
|
||||
void InitStackAmount(uint8 stackAmount);
|
||||
uint32 GetAuraStateMask(){return m_auraStateMask;}
|
||||
void SetAuraState(uint8 num){m_auraStateMask |= 1<<(num-1);} //modifies aura's aura state (not unit!)
|
||||
void RefreshAura();
|
||||
|
||||
bool IsPositive() { return m_positive; }
|
||||
void SetNegative() { m_positive = false; }
|
||||
void SetPositive() { m_positive = true; }
|
||||
|
||||
bool IsPermanent() const { return m_permanent; }
|
||||
bool IsAreaAura() const { return m_isAreaAura; }
|
||||
bool IsPeriodic() const { return m_isPeriodic; }
|
||||
bool IsPassive() const { return m_isPassive; }
|
||||
bool IsPersistent() const { return m_isPersistent; }
|
||||
bool IsDeathPersistent() const { return m_isDeathPersist; }
|
||||
bool IsRemovedOnShapeLost() const { return m_isRemovedOnShapeLost; }
|
||||
bool IsInUse() const { return m_in_use;}
|
||||
void CleanupTriggeredSpells();
|
||||
|
||||
virtual void Update(uint32 diff);
|
||||
void ApplyModifier(bool apply, bool Real = false);
|
||||
|
||||
void _AddAura();
|
||||
void _RemoveAura();
|
||||
|
||||
bool IsUpdated() { return m_updated; }
|
||||
void SetUpdated(bool val) { m_updated = val; }
|
||||
|
||||
bool IsSingleTarget() {return m_isSingleTargetAura;}
|
||||
void SetIsSingleTarget(bool val) { m_isSingleTargetAura = val;}
|
||||
|
||||
void SetRemoveMode(AuraRemoveMode mode) { m_removeMode = mode; }
|
||||
|
||||
Unit* GetTriggerTarget() const;
|
||||
void HandleAuraAllowOnlyAbility(bool apply, bool Real);
|
||||
|
||||
// add/remove SPELL_AURA_MOD_SHAPESHIFT (36) linked auras
|
||||
void HandleAuraAllowOnlyAbility(bool apply, bool Real);
|
||||
void HandleShapeshiftBoosts(bool apply);
|
||||
|
||||
// Allow Apply Aura Handler to modify and access m_AuraDRGroup
|
||||
void setDiminishGroup(DiminishingGroup group) { m_AuraDRGroup = group; }
|
||||
DiminishingGroup getDiminishGroup() const { return m_AuraDRGroup; }
|
||||
inline Unit * GetCaster() const{ return m_parentAura->GetCaster(); }
|
||||
inline uint64 GetCasterGUID() const{ return m_parentAura->GetCasterGUID(); }
|
||||
Aura * GetParentAura() const { return m_parentAura; }
|
||||
|
||||
SpellEntry const* GetSpellProto() const { return m_spellProto; }
|
||||
uint32 GetId() const { return m_spellProto->Id; }
|
||||
uint32 GetEffIndex() const { return m_effIndex; }
|
||||
int32 GetBasePoints() const { return m_currentBasePoints; }
|
||||
void Update(uint32 diff);
|
||||
|
||||
bool IsAreaAura() const { return m_isAreaAura; }
|
||||
bool IsPeriodic() const { return m_isPeriodic; }
|
||||
bool IsInUse() const { return m_in_use;}
|
||||
bool IsPersistent() const { return m_isPersistent; }
|
||||
bool isAffectedOnSpell(SpellEntry const *spell) const;
|
||||
|
||||
void ApplyModifier(bool apply, bool Real = false);
|
||||
void HandleAuraEffect(bool apply);
|
||||
void ApplyAllModifiers(bool apply, bool Real);
|
||||
|
||||
Unit* GetTriggerTarget() const;
|
||||
void TriggerSpell();
|
||||
void TriggerSpellWithValue();
|
||||
void PeriodicTick();
|
||||
void PeriodicDummyTick();
|
||||
|
||||
bool isAffectedOnSpell(SpellEntry const *spell) const;
|
||||
protected:
|
||||
Aura(SpellEntry const* spellproto, uint32 eff, int32 *currentBasePoints, Unit *target, Unit *caster = NULL, Item* castItem = NULL);
|
||||
int32 GetMiscBValue() const {return m_spellProto->EffectMiscValueB[m_effIndex];}
|
||||
int32 GetMiscValue() const {return m_spellProto->EffectMiscValue[m_effIndex];}
|
||||
uint32 GetAuraName() const {return m_auraName;}
|
||||
int32 GetAmount() const {return m_amount;}
|
||||
void SetAmount(int32 amount) { m_amount = amount; }
|
||||
void CleanupTriggeredSpells();
|
||||
|
||||
Modifier m_modifier;
|
||||
SpellModifier *m_spellmod;
|
||||
protected:
|
||||
AuraEffect (Aura * parentAura, uint8 effIndex, int32 * currentBasePoints , Unit * caster,Item * castItem);
|
||||
Aura * const m_parentAura;
|
||||
Unit * const m_target;
|
||||
|
||||
SpellEntry const *m_spellProto;
|
||||
Unit* m_target;
|
||||
uint64 m_caster_guid;
|
||||
uint64 m_castItemGuid; // it is NOT safe to keep a pointer to the item because it may get deleted
|
||||
time_t m_applyTime;
|
||||
|
||||
int32 m_currentBasePoints; // cache SpellEntry::EffectBasePoints and use for set custom base points
|
||||
int32 m_maxduration; // Max aura duration
|
||||
int32 m_duration; // Current time
|
||||
int32 m_timeCla; // Timer for power per sec calcultion
|
||||
uint8 m_effIndex;
|
||||
AuraType m_auraName;
|
||||
int32 m_currentBasePoints;
|
||||
int32 m_amount;
|
||||
|
||||
SpellModifier *m_spellmod;
|
||||
|
||||
int32 m_periodicTimer; // Timer for periodic auras
|
||||
int32 m_amplitude;
|
||||
|
||||
AuraRemoveMode m_removeMode:8; // Store info for know remove aura reason
|
||||
DiminishingGroup m_AuraDRGroup:8; // Diminishing
|
||||
|
||||
uint8 m_effIndex; // Aura effect index in spell
|
||||
uint8 m_auraSlot; // Aura slot on unit (for show in client)
|
||||
uint8 m_auraFlags; // Aura info flag (for send data to client)
|
||||
uint8 m_auraLevel; // Aura level (store caster level for correct show level dep amount)
|
||||
uint8 m_procCharges; // Aura charges (0 for infinite)
|
||||
uint8 m_stackAmount; // Aura stack amount
|
||||
uint32 m_auraStateMask;
|
||||
|
||||
bool m_positive:1;
|
||||
bool m_permanent:1;
|
||||
bool m_isPeriodic:1;
|
||||
bool m_isAreaAura:1;
|
||||
bool m_isPassive:1;
|
||||
bool m_isPersistent:1;
|
||||
bool m_isDeathPersist:1;
|
||||
bool m_isRemovedOnShapeLost:1;
|
||||
bool m_updated:1; // Prevent remove aura by stack if set
|
||||
bool m_in_use:1; // true while in Aura::ApplyModifier call
|
||||
bool m_isSingleTargetAura:1; // true if it's a single target spell and registered at caster - can change at spell steal for example
|
||||
|
||||
private:
|
||||
bool m_isPersistent:1;
|
||||
};
|
||||
|
||||
class TRINITY_DLL_SPEC AreaAura : public Aura
|
||||
class TRINITY_DLL_SPEC AreaAuraEffect : public AuraEffect
|
||||
{
|
||||
public:
|
||||
AreaAura(SpellEntry const* spellproto, uint32 eff, int32 *currentBasePoints, Unit *target, Unit *caster = NULL, Item* castItem = NULL);
|
||||
~AreaAura();
|
||||
AreaAuraEffect(Aura * parentAura, uint32 effIndex, int32 * currentBasePoints, Unit * caster=NULL, Item * castItem=NULL);
|
||||
~AreaAuraEffect();
|
||||
void Update(uint32 diff);
|
||||
private:
|
||||
float m_radius;
|
||||
int32 m_removeTime;
|
||||
AreaAuraType m_areaAuraType;
|
||||
};
|
||||
|
||||
class TRINITY_DLL_SPEC PersistentAreaAura : public Aura
|
||||
class TRINITY_DLL_SPEC PersistentAreaAuraEffect : public AuraEffect
|
||||
{
|
||||
public:
|
||||
PersistentAreaAura(SpellEntry const* spellproto, uint32 eff, int32 *currentBasePoints, Unit *target, Unit *caster = NULL, Item* castItem = NULL);
|
||||
~PersistentAreaAura();
|
||||
PersistentAreaAuraEffect(Aura * parentAura, uint32 eff, int32 *currentBasePoints, Unit *caster = NULL, Item* castItem = NULL);
|
||||
~PersistentAreaAuraEffect();
|
||||
void Update(uint32 diff);
|
||||
};
|
||||
|
||||
Aura* CreateAura(SpellEntry const* spellproto, uint32 eff, int32 *currentBasePoints, Unit *target, Unit *caster = NULL, Item* castItem = NULL);
|
||||
AuraEffect* CreateAuraEffect(Aura * parentAura, uint32 effIndex, int32 *currentBasePoints, Unit * caster, Item * castItem = NULL);
|
||||
#endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user