Update aura system:

* Change system logic - unify Auras, AreaAuras and PersistentAreaAuras:
  * Aura has now its owner - which is the WorldObject, which applies aura (creates AuraApplication object) dependant on aura radius, and effect type
  * Owner can be Dynobj (DynObjAura class) for PersistentAreaAuras, or Unit (UnitAura class) for Area and nonArea auras
  * Aura data is shared for all units which have AuraApplication of the Aura
   * Because of that AuraEffect handlers , and periodic tick functions can't modify AuraEffect object (they are const now)
  * Remove spell source and AreaAuraEffect classes
  * Add AuraEffect::UpdatePeriodic function, to allow periodic aura object modification (target independant)
  * Add AuraEffect::CalculateAmount and AuraEffect::CalculateSpellMod function, to allow non-default amount calculation
  * AreaAura updates are done in owner _UpdateSpells cycle
  * Since now you don't need to wait an aura update cycle to get area aura applied on it's correct target list
  * And you can access area aura target list
  * Add basic support for aura amount recalculation
  * Save recalculation state and base amount of auras to db
  * Add AuraEffect::CalculatePeriodic function to determine if aura is periodic, and to set correct tick number after aura is loaded from db
  * Add ChangeAmount function in addition to SetAmount function, to allow easy reapplication of AuraEffect handlers on all targets
  * Sort aura effect handlers in SpellAuras.cpp and .h by their use
  * Add check for already existing aura of that type to some AuraEffect handlers, to prevent incorrect effect removal
  * SPELL_AURA_CONVERT_RUNE and MOD_POWER_REGEN and MOD_REGEN hacky handlers are now implemented correctly
  * Send aura application client update only once per unit update - prevent unnecesary packet spam
 * Fix ByteBuffer::appendPackGUID function - it added additionall 0s at the end of the packet
 * Fix memory leak at player creation (not deleted auras)
 * Updated some naming conventions (too many to mention)
 * Added Unit::GetAuraOfRankedSpell() function
 * Remove procflags on aura remove, use Aura::HandleAuraSpecificMods instead
 * Added functions to maintain owned auras (GetOwnedAuras, GetOwnedAura, RemoveOwnedAura, etc)
 * Implement AURA_INTERRUPT_FLAG_LANDING
 * Implement EffectPlayerNotification (thanks to Spp)
 * Remove wrong aura 304 handler
 * Add better handler for death runes
 * Remove unnecesary variables from DynamicObject class, and cleanup related code, link dynobj duration with aura
 * Add GetAuraEffectTriggerTarget function in CreatureAi for special target selection for periodic trigger auras used in a script
 * Add many assert() procection from idiots using some functions in wrong way
 * I am to lazy to write here anything more
Thanks to Visagalis for testing this patch
PS: Do not make patches like this, please

--HG--
branch : trunk
This commit is contained in:
QAston
2010-01-10 01:23:15 +01:00
parent a0f7762cab
commit 8e9d2cdf01
55 changed files with 10071 additions and 9861 deletions
+150 -362
View File
@@ -17,419 +17,207 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef TRINITY_SPELLAURAS_H
#define TRINITY_SPELLAURAS_H
#include "SpellAuraDefines.h"
class Unit;
class Unit;
struct SpellEntry;
struct SpellModifier;
struct ProcTriggerSpell;
// forward decl
class Aura;
class AuraEffect;
class Aura;
class DynamicObject;
typedef void(AuraEffect::*pAuraHandler)(bool Apply, bool Real, bool changeAmount);
// Real == true at aura add/remove
// Real == false at aura mod unapply/reapply; when adding/removing dependent aura/item/stat mods
//
// Code in aura handler can be guarded by if(Real) check if it should execution only at real add/remove of aura
//
// MAIN RULE: Code MUST NOT be guarded by if(Real) check if it modifies any stats
// (percent auras, stats mods, etc)
// Second rule: Code must be guarded by if(Real) check if it modifies object state (start/stop attack, send packets to client, etc)
//
// Other case choice: each code line moved under if(Real) check is Trinity speedup,
// each setting object update field code line moved under if(Real) check is significant Trinity speedup, and less server->client data sends
// each packet sending code moved under if(Real) check is _large_ Trinity speedup, and lot less server->client data sends
//
// changeAmount == true at changing existing aura amount - called wit real == false
// if aura has amount dependant effect handler has to allow proceeding it
// example: change speed aura, modifier aura
class AuraApplication
{
friend AuraApplication * Unit::__ApplyAura(Aura * aura);
friend void Unit::__UnapplyAura(AuraApplicationMap::iterator &i);
friend bool Unit::_ApplyAuraEffect(Aura * aura, uint8 effIndex);
private:
Unit * const m_target;
Aura * const m_base;
uint8 m_slot; // Aura slot on unit
uint8 m_flags; // Aura info flag
AuraRemoveMode m_removeMode:8; // Store info for know remove aura reason
bool m_needClientUpdate:1;
bool m_isNeedManyNegativeEffects:1;
bool m_canBeRemoved:1; // used only in aura list update of AuraBase
explicit AuraApplication(Unit * target, Unit * caster, Aura * base);
void _Remove();
private:
bool _CheckPositive(Unit * caster) const;
void _HandleEffect(uint8 effIndex, bool apply);
public:
bool _CanBeRemoved() const {return m_canBeRemoved;}
void _SetCanBeRemoved(bool val) {m_canBeRemoved = val;}
Unit * GetTarget() const { return m_target; }
Aura * GetBase() const { return m_base; }
uint8 GetSlot() const { return m_slot; }
uint8 GetFlags() const { return m_flags; }
uint8 GetEffectMask() const { return m_flags & (AFLAG_EFF_INDEX_0 | AFLAG_EFF_INDEX_1 | AFLAG_EFF_INDEX_2); }
bool HasEffect(uint8 effect) const { assert(effect < MAX_SPELL_EFFECTS); return m_flags & (1<<effect); }
bool IsPositive() const { return m_flags & AFLAG_POSITIVE; }
void SetRemoveMode(AuraRemoveMode mode) { m_removeMode = mode; }
AuraRemoveMode GetRemoveMode() const {return m_removeMode;}
void SetNeedClientUpdate() { m_needClientUpdate = true;}
bool IsNeedClientUpdate() const { return m_needClientUpdate;}
void ClientUpdate(bool remove = false);
};
class TRINITY_DLL_SPEC Aura
{
friend void Player::SendAurasForTarget(Unit *target);
public:
virtual ~Aura();
explicit Aura(SpellEntry const* spellproto, uint32 effMask, Unit *target, WorldObject *source, Unit *caster, int32 *currentBasePoints = NULL, Item *castItem = NULL);
typedef UNORDERED_MAP<uint64, AuraApplication *> ApplicationMap;
static Aura * TryCreate(SpellEntry const* spellproto, uint8 effMask, WorldObject * owner, Unit * caster, int32 *baseAmount = NULL, Item * castItem = NULL, uint64 casterGUID = 0);
static Aura * TryCreate(SpellEntry const* spellproto, WorldObject * owner, Unit * caster, int32 *baseAmount = NULL, Item * castItem = NULL, uint64 casterGUID = 0);
static Aura * Create(SpellEntry const* spellproto, uint8 effMask, WorldObject * owner, Unit * caster, int32 *baseAmount = NULL, Item * castItem = NULL, uint64 casterGUID = 0);
explicit Aura(SpellEntry const* spellproto, uint8 effMask, WorldObject * owner, Unit * caster, int32 *baseAmount, Item * castItem, uint64 casterGUID);
~Aura();
SpellEntry const* GetSpellProto() const { return m_spellProto; }
uint32 GetId() const{ return m_spellProto->Id; }
uint64 GetCastItemGUID() const { return m_castItemGuid; }
uint32 GetId() const{ return GetSpellProto()->Id; }
uint64 GetCastItemGUID() const { return m_castItemGuid; }
uint64 const& GetCasterGUID() const { return m_casterGuid; }
Unit* GetCaster() const;
uint64 const& GetSourceGUID() const { return m_sourceGuid; }
Unit *GetUnitSource() const;
Unit* GetTarget() const { return m_target; }
time_t GetAuraApplyTime() const { return m_applyTime; }
WorldObject * GetOwner() const { return m_owner; }
Unit * GetUnitOwner() const { assert(GetType() == UNIT_AURA_TYPE); return (Unit*)m_owner; }
DynamicObject * GetDynobjOwner() const { assert(GetType() == DYNOBJ_AURA_TYPE); return (DynamicObject*)m_owner; }
int32 GetAuraMaxDuration() const { return m_maxduration; }
void SetAuraMaxDuration(int32 duration) { m_maxduration = duration; }
int32 GetAuraDuration() const { return m_duration; }
void SetAuraDuration(int32 duration, bool withMods = false);
void RefreshAura() { SetAuraDuration(m_maxduration);}
bool IsExpired() const { return !GetAuraDuration() && !(IsPermanent() || IsPassive()); }
AuraObjectType GetType() const;
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();
void SetProcDamage(uint32 val) { m_procDamage = val; }
uint32 GetProcDamage() const { return m_procDamage; }
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 UpdateTargetMapForEffect(Unit * caster, uint8 effIndex) = 0;
void UpdateTargetMap(Unit * caster);
void ApplyForTargets() {Unit * caster = GetCaster(); UpdateTargetMap(caster);}
void ApplyEffectForTargets(uint8 effIndex) {Unit * caster = GetCaster(); UpdateTargetMapForEffect(caster, effIndex);}
void UpdateOwner(uint32 diff, WorldObject * owner);
void Update(uint32 diff, Unit * caster);
time_t GetApplyTime() const { return m_applyTime; }
int32 GetMaxDuration() const { return m_maxDuration; }
void SetMaxDuration(int32 duration) { m_maxDuration = duration; }
int32 GetDuration() const { return m_duration; }
void SetDuration(int32 duration, bool withMods = false);
void RefreshDuration();
bool IsExpired() const { return !GetDuration();}
bool IsPermanent() const { return GetMaxDuration() == -1; }
uint8 GetCharges() const { return m_procCharges; }
void SetCharges(uint8 charges);
bool DropCharge();
uint8 GetStackAmount() const { return m_stackAmount; }
void SetStackAmount(uint8 num, bool applied = true);
bool modStackAmount(int32 num); // return true if last charge dropped
bool ModStackAmount(int32 num); // return true if last charge dropped
void SetRemoveMode(AuraRemoveMode mode) { m_removeMode = mode; }
uint8 GetRemoveMode() const {return m_removeMode;}
uint8 GetCasterLevel() const { return m_casterLevel; }
inline uint8 GetEffectMask() const {return m_auraFlags & 7;}
AuraEffect * GetPartAura (uint8 effIndex) const {assert (effIndex < MAX_SPELL_EFFECTS); 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; }
void SetPermanent(bool val) { m_permanent = val; }
bool IsPassive() const { return m_isPassive; }
bool IsDeathPersistent() const { return m_isDeathPersist; }
bool IsRemovedOnShapeLost() const { return m_isRemovedOnShapeLost; }
bool IsPassive() const;
bool IsDeathPersistent() const;
bool IsRemovedOnShapeLost(Unit * target) const { return (GetCasterGUID() == target->GetGUID() && m_spellProto->Stances && !(m_spellProto->AttributesEx2 & SPELL_ATTR_EX2_NOT_NEED_SHAPESHIFT) && !(m_spellProto->Attributes & SPELL_ATTR_NOT_SHAPESHIFT)); }
bool CanBeSaved() const;
bool IsRemoved() const { return m_isRemoved; }
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 HandleAuraSpecificMods(bool apply);
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; }
bool IsVisible() const;
// Single cast aura helpers
void UnregisterSingleCastAura();
bool IsSingleTarget() const {return m_isSingleTargetAura;}
void SetIsSingleTarget(bool val) { m_isSingleTargetAura = val;}
bool IsSingleTarget() const {return m_isSingleTarget;}
void SetIsSingleTarget(bool val) { m_isSingleTarget = val;}
void SetLoadedState(int32 maxduration, int32 duration, int32 charges, uint8 stackamount, uint8 recalculateMask, int32 * amount);
// helpers for aura effects
bool HasEffect(uint8 effIndex) const { return bool(GetEffect(effIndex)); }
bool HasEffectType(AuraType type) const;
AuraEffect * GetEffect (uint8 effIndex) const { assert (effIndex < MAX_SPELL_EFFECTS); return m_effects[effIndex]; }
uint8 GetEffectMask() const { uint8 effMask = 0; for(uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i) if (m_effects[i]) effMask |= 1<<i; return effMask; }
void RecalculateAmountOfEffects();
void HandleAllEffects(AuraApplication const * aurApp, uint8 mode, bool apply);
// Helpers for targets
ApplicationMap const & GetApplicationMap() {return m_applications;}
const AuraApplication * GetApplicationOfTarget (uint64 const & guid) const { ApplicationMap::const_iterator itr = m_applications.find(guid); if (itr != m_applications.end()) return itr->second; return NULL; }
AuraApplication * GetApplicationOfTarget (uint64 const & guid) { ApplicationMap::iterator itr = m_applications.find(guid); if (itr != m_applications.end()) return itr->second; return NULL; }
bool IsAppliedOnTarget (uint64 const & guid) const { return m_applications.find(guid) != m_applications.end(); }
bool IsPositive(Unit * const target) const { return (GetApplicationOfTarget(target->GetGUID()))->IsPositive(); }
bool GetEffectMask(Unit * const target) const { return (GetApplicationOfTarget(target->GetGUID()))->GetEffectMask(); }
uint8 GetSlot(Unit * const target) const { return (GetApplicationOfTarget(target->GetGUID()))->GetSlot(); }
bool HasEffect(Unit * const target, uint8 eff) const { return (GetApplicationOfTarget(target->GetGUID()))->HasEffect(eff); }
void SetNeedClientUpdateForTargets() const;
void HandleAuraSpecificMods(AuraApplication const * aurApp, Unit * caster, bool apply);
private:
const SpellEntry * const m_spellProto;
Unit * const m_target;
//WorldObject * const m_source;
const uint64 m_sourceGuid;
const uint64 m_casterGuid;
const uint64 m_castItemGuid; // it is NOT safe to keep a pointer to the item because it may get deleted
const time_t m_applyTime;
void _DeleteRemovedApplications();
protected:
SpellEntry const * const m_spellProto;
uint64 const m_casterGuid;
uint64 const m_castItemGuid; // it is NOT safe to keep a pointer to the item because it may get deleted
time_t const m_applyTime;
WorldObject * const m_owner; //
int32 m_maxduration; // Max aura duration
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 const m_casterLevel; // 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
AuraEffect * m_partAuras[3];
uint32 m_procDamage; // used in aura proc code
AuraEffect * m_effects[3];
ApplicationMap m_applications;
bool m_isDeathPersist:1;
bool m_isRemovedOnShapeLost:1;
bool m_isPassive:1;
bool m_positive:1;
bool m_permanent:1;
bool m_isRemoved:1;
bool m_isSingleTargetAura:1; // true if it's a single target spell and registered at caster - can change at spell steal for example
bool m_isSingleTarget:1; // true if it's a single target spell and registered at caster - can change at spell steal for example
bool IsVisible() const;
};
class TRINITY_DLL_SPEC AuraEffect
{
public:
friend AuraEffect* CreateAuraEffect(Aura * parentAura, uint32 effIndex, int32 *currentBasePoints);
friend void Aura::SetStackAmount(uint8 stackAmount, bool applied);
//aura handlers
void HandleNULL(bool, bool, bool)
{
// NOT IMPLEMENTED
}
void HandleUnused(bool, bool, bool)
{
// NOT USED BY ANY SPELL OR USELESS
}
void HandleNoImmediateEffect(bool, bool, bool)
{
// aura not have immediate effect at add/remove and handled by ID in other code place
}
void HandleBindSight(bool Apply, bool Real, bool changeAmount);
void HandleModPossess(bool Apply, bool Real, bool changeAmount);
void HandlePeriodicDamage(bool Apply, bool Real, bool changeAmount);
void HandleAuraDummy(bool Apply, bool Real, bool changeAmount);
void HandleAuraPeriodicDummy(bool apply, bool Real, bool changeAmount);
void HandleModConfuse(bool Apply, bool Real, bool changeAmount);
void HandleModCharm(bool Apply, bool Real, bool changeAmount);
void HandleModFear(bool Apply, bool Real, bool changeAmount);
void HandlePeriodicHeal(bool Apply, bool Real, bool changeAmount);
void HandleModAttackSpeed(bool Apply, bool Real, bool changeAmount);
void HandleModMeleeRangedSpeedPct(bool apply, bool Real, bool changeAmount);
void HandleModCombatSpeedPct(bool apply, bool Real, bool changeAmount);
void HandleModThreat(bool Apply, bool Real, bool changeAmount);
void HandleModTaunt(bool Apply, bool Real, bool changeAmount);
void HandleFeignDeath(bool Apply, bool Real, bool changeAmount);
void HandleAuraModDisarm(bool Apply, bool Real, bool changeAmount);
void HandleAuraModStalked(bool Apply, bool Real, bool changeAmount);
void HandleAuraWaterWalk(bool Apply, bool Real, bool changeAmount);
void HandleAuraFeatherFall(bool Apply, bool Real, bool changeAmount);
void HandleAuraHover(bool Apply, bool Real, bool changeAmount);
void HandleAddModifier(bool Apply, bool Real, bool changeAmount);
void HandleAuraModStun(bool Apply, bool Real, bool changeAmount);
void HandleModDamageDone(bool Apply, bool Real, bool changeAmount);
void HandleAuraUntrackable(bool Apply, bool Real, bool changeAmount);
void HandleAuraEmpathy(bool Apply, bool Real, bool changeAmount);
void HandleModOffhandDamagePercent(bool apply, bool Real, bool changeAmount);
void HandleAuraModRangedAttackPower(bool Apply, bool Real, bool changeAmount);
void HandleAuraModIncreaseEnergyPercent(bool Apply, bool Real, bool changeAmount);
void HandleAuraModIncreaseHealthPercent(bool Apply, bool Real, bool changeAmount);
void HandleAuraModRegenInterrupt(bool Apply, bool Real, bool changeAmount);
void HandleHaste(bool Apply, bool Real, bool changeAmount);
void HandlePeriodicTriggerSpell(bool Apply, bool Real, bool changeAmount);
void HandlePeriodicTriggerSpellWithValue(bool apply, bool Real, bool changeAmount);
void HandlePeriodicEnergize(bool Apply, bool Real, bool changeAmount);
void HandleAuraModResistanceExclusive(bool Apply, bool Real, bool changeAmount);
void HandleAuraModPetTalentsPoints(bool Apply, bool Real, bool changeAmount);
void HandleModStealth(bool Apply, bool Real, bool changeAmount);
void HandleInvisibility(bool Apply, bool Real, bool changeAmount);
void HandleInvisibilityDetect(bool Apply, bool Real, bool changeAmount);
void HandleAuraModTotalHealthPercentRegen(bool Apply, bool Real, bool changeAmount);
void HandleAuraModTotalEnergyPercentRegen(bool Apply, bool Real, bool changeAmount);
void HandleAuraModResistance(bool Apply, bool Real, bool changeAmount);
void HandleAuraModRoot(bool Apply, bool Real, bool changeAmount);
void HandleAuraModSilence(bool Apply, bool Real, bool changeAmount);
void HandleAuraModStat(bool Apply, bool Real, bool changeAmount);
void HandleAuraModIncreaseSpeed(bool Apply, bool Real, bool changeAmount);
void HandleAuraModIncreaseMountedSpeed(bool Apply, bool Real, bool changeAmount);
void HandleAuraModIncreaseFlightSpeed(bool Apply, bool Real, bool changeAmount);
void HandleAuraModDecreaseSpeed(bool Apply, bool Real, bool changeAmount);
void HandleAuraModUseNormalSpeed(bool Apply, bool Real, bool changeAmount);
void HandleAuraModIncreaseHealth(bool Apply, bool Real, bool changeAmount);
void HandleAuraModIncreaseEnergy(bool Apply, bool Real, bool changeAmount);
void HandleAuraModShapeshift(bool Apply, bool Real, bool changeAmount);
void HandleAuraModEffectImmunity(bool Apply, bool Real, bool changeAmount);
void HandleAuraModStateImmunity(bool Apply, bool Real, bool changeAmount);
void HandleAuraModSchoolImmunity(bool Apply, bool Real, bool changeAmount);
void HandleAuraModDmgImmunity(bool Apply, bool Real, bool changeAmount);
void HandleAuraModDispelImmunity(bool Apply, bool Real, bool changeAmount);
void HandleAuraProcTriggerSpell(bool Apply, bool Real, bool changeAmount);
void HandleAuraTrackCreatures(bool Apply, bool Real, bool changeAmount);
void HandleAuraTrackResources(bool Apply, bool Real, bool changeAmount);
void HandleAuraModParryPercent(bool Apply, bool Real, bool changeAmount);
void HandleAuraModDodgePercent(bool Apply, bool Real, bool changeAmount);
void HandleAuraModBlockPercent(bool Apply, bool Real, bool changeAmount);
void HandleAuraModWeaponCritPercent(bool Apply, bool Real, bool changeAmount);
void HandlePeriodicLeech(bool Apply, bool Real, bool changeAmount);
void HandleModHitChance(bool Apply, bool Real, bool changeAmount);
void HandleModSpellHitChance(bool Apply, bool Real, bool changeAmount);
void HandleAuraModScale(bool Apply, bool Real, bool changeAmount);
void HandlePeriodicManaLeech(bool Apply, bool Real, bool changeAmount);
void HandlePeriodicHealthFunnel(bool apply, bool Real, bool changeAmount);
void HandleModCastingSpeed(bool Apply, bool Real, bool changeAmount);
void HandleAuraMounted(bool Apply, bool Real, bool changeAmount);
void HandleWaterBreathing(bool Apply, bool Real, bool changeAmount);
void HandleModBaseResistance(bool Apply, bool Real, bool changeAmount);
void HandleModRegen(bool Apply, bool Real, bool changeAmount);
void HandleModPowerRegen(bool Apply, bool Real, bool changeAmount);
void HandleModPowerRegenPCT(bool Apply, bool Real, bool changeAmount);
void HandleChannelDeathItem(bool Apply, bool Real, bool changeAmount);
void HandlePeriodicDamagePCT(bool Apply, bool Real, bool changeAmount);
void HandleAuraModAttackPower(bool Apply, bool Real, bool changeAmount);
void HandleAuraTransform(bool Apply, bool Real, bool changeAmount);
void HandleModSpellCritChance(bool Apply, bool Real, bool changeAmount);
void HandleAuraModIncreaseSwimSpeed(bool Apply, bool Real, bool changeAmount);
void HandleModPowerCostPCT(bool Apply, bool Real, bool changeAmount);
void HandleModPowerCost(bool Apply, bool Real, bool changeAmount);
void HandleFarSight(bool Apply, bool Real, bool changeAmount);
void HandleModPossessPet(bool Apply, bool Real, bool changeAmount);
void HandleModMechanicImmunity(bool Apply, bool Real, bool changeAmount);
void HandleModStateImmunityMask(bool apply, bool Real, bool changeAmount);
void HandleAuraModSkill(bool Apply, bool Real, bool changeAmount);
void HandleModDamagePercentDone(bool Apply, bool Real, bool changeAmount);
void HandleModPercentStat(bool Apply, bool Real, bool changeAmount);
void HandleModResistancePercent(bool Apply, bool Real, bool changeAmount);
void HandleAuraModBaseResistancePCT(bool Apply, bool Real, bool changeAmount);
void HandleModShieldBlockPCT(bool Apply, bool Real, bool changeAmount);
void HandleAuraTrackStealthed(bool Apply, bool Real, bool changeAmount);
void HandleModShieldBlock(bool Apply, bool Real, bool changeAmount);
void HandleForceReaction(bool Apply, bool Real, bool changeAmount);
void HandleAuraModRangedHaste(bool Apply, bool Real, bool changeAmount);
void HandleRangedAmmoHaste(bool Apply, bool Real, bool changeAmount);
void HandleModHealingDone(bool Apply, bool Real, bool changeAmount);
void HandleModTotalPercentStat(bool Apply, bool Real, bool changeAmount);
void HandleAuraModTotalThreat(bool Apply, bool Real, bool changeAmount);
void HandleModUnattackable(bool Apply, bool Real, bool changeAmount);
void HandleAuraModPacify(bool Apply, bool Real, bool changeAmount);
void HandleAuraGhost(bool Apply, bool Real, bool changeAmount);
void HandleAuraAllowFlight(bool Apply, bool Real, bool changeAmount);
void HandleModRating(bool apply, bool Real, bool changeAmount);
void HandleModRatingFromStat(bool apply, bool Real, bool changeAmount);
void HandleModTargetResistance(bool apply, bool Real, bool changeAmount);
void HandleAuraModAttackPowerPercent(bool apply, bool Real, bool changeAmount);
void HandleAuraModRangedAttackPowerPercent(bool apply, bool Real, bool changeAmount);
void HandleAuraModRangedAttackPowerOfStatPercent(bool apply, bool Real, bool changeAmount);
void HandleAuraModAttackPowerOfArmor(bool apply, bool Real, bool changeAmount);
void HandleAuraModAttackPowerOfStatPercent(bool apply, bool Real, bool changeAmount);
void HandleSpiritOfRedemption(bool apply, bool Real, bool changeAmount);
void HandleModManaRegen(bool apply, bool Real, bool changeAmount);
void HandleComprehendLanguage(bool apply, bool Real, bool changeAmount);
void HandleShieldBlockValue(bool apply, bool Real, bool changeAmount);
void HandleModSpellCritChanceShool(bool apply, bool Real, bool changeAmount);
void HandleAuraRetainComboPoints(bool apply, bool Real, bool changeAmount);
void HandleModSpellDamagePercentFromStat(bool apply, bool Real, bool changeAmount);
void HandleModSpellHealingPercentFromStat(bool apply, bool Real, bool changeAmount);
void HandleAuraControlVehicle(bool apply, bool Real, bool changeAmount);
void HandleModSpellDamagePercentFromAttackPower(bool apply, bool Real, bool changeAmount);
void HandleModSpellHealingPercentFromAttackPower(bool apply, bool Real, bool changeAmount);
void HandleAuraModPacifyAndSilence(bool Apply, bool Real, bool changeAmount);
void HandleAuraModIncreaseMaxHealth(bool apply, bool Real, bool changeAmount);
void HandleAuraModExpertise(bool apply, bool Real, bool changeAmount);
void HandleForceMoveForward(bool apply, bool Real, bool changeAmount);
void HandleAuraModResistenceOfStatPercent(bool apply, bool Real, bool changeAmount);
void HandleAuraPowerBurn(bool apply, bool Real, bool changeAmount);
void HandlePreventFleeing(bool apply, bool Real, bool changeAmount);
void HandleArenaPreparation(bool apply, bool Real, bool changeAmount);
void HandleAuraConvertRune(bool apply, bool Real, bool changeAmount);
void HandleAuraIncreaseBaseHealthPercent(bool Apply, bool Real, bool changeAmount);
void HandleNoReagentUseAura(bool Apply, bool Real, bool changeAmount);
void HandlePhase(bool Apply, bool Real, bool changeAmount);
void HandleAuraAllowOnlyAbility(bool apply, bool Real, bool changeAmount);
void HandleCharmConvert(bool apply, bool Real, bool changeAmount);
void HandleAuraInitializeImages(bool Apply, bool Real, bool changeAmount);
void HandleAuraCloneCaster(bool Apply, bool Real, bool changeAmount);
void HandleAuraModCritPct(bool Apply, bool Real, bool changeAmount);
void HandleAuraLinked(bool Apply, bool Real, bool changeAmount);
void HandleAuraModInebriation(bool apply, bool Real, bool changeAmount);
void HandleAuraEffectSpecificMods(bool apply, bool Real, bool changeAmount);
int32 CalculateCrowdControlAuraAmount(Unit * caster);
// add/remove SPELL_AURA_MOD_SHAPESHIFT (36) linked auras
void HandleShapeshiftBoosts(bool apply);
Unit * GetCaster() const { return m_parentAura->GetCaster(); }
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; }
int32 GetAuraAmplitude(){return m_amplitude;}
void ResetPeriodicTimer(){m_periodicTimer = m_amplitude;}
virtual void Update(uint32 diff);
uint32 GetTickNumber() const { return m_tickNumber; }
int32 GetTotalTicks () const { return m_amplitude ? (GetParentAura()->GetAuraMaxDuration() / m_amplitude) : 1;}
bool IsAreaAura() const { return m_isAreaAura; }
bool IsPeriodic() const { return m_isPeriodic; }
bool IsPersistent() const { return m_isPersistent; }
bool IsApplied() const { return m_isApplied; }
void SetApplied (bool val) {m_isApplied = val; }
bool isAffectedOnSpell(SpellEntry const *spell) const;
void ApplyModifier(bool apply, bool Real = false, bool changeAmount=false);
void RecalculateAmount(bool applied = true);
void HandleAuraEffect(bool apply);
void ApplyAllModifiers(bool apply, bool Real);
Unit* GetTriggerTarget() const;
void TriggerSpell();
void TriggerSpellWithValue();
void PeriodicTick();
void PeriodicDummyTick();
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();
protected:
explicit AuraEffect(Aura * parentAura, uint8 effIndex, int32 *currentBasePoints = NULL);
Aura * const m_parentAura;
Unit * const m_target;
uint32 m_tickNumber;
const SpellEntry * const m_spellProto;
const uint8 m_effIndex;
const AuraType m_auraName;
int32 m_currentBasePoints;
int32 m_amount;
SpellModifier *m_spellmod;
int32 m_periodicTimer; // Timer for periodic auras
int32 m_amplitude;
bool m_isPeriodic:1;
bool m_isAreaAura:1;
bool m_isPersistent:1;
bool m_isApplied:1;
private:
bool IsPeriodicTickCrit(Unit const * pCaster) const;
Unit::AuraApplicationList m_removedApplications;
};
class TRINITY_DLL_SPEC AreaAuraEffect : public AuraEffect
class TRINITY_DLL_SPEC UnitAura : public Aura
{
public:
friend AuraEffect* CreateAuraEffect(Aura * parentAura, uint32 effIndex, int32 *currentBasePoints);
void Update(uint32 diff);
Unit *GetSource() const { return GetParentAura()->GetUnitSource(); }
friend Aura * Aura::Create(SpellEntry const* spellproto, uint8 effMask, WorldObject * owner, Unit * caster, int32 *baseAmount, Item * castItem, uint64 casterGUID);
protected:
explicit AreaAuraEffect(Aura * parentAura, uint32 effIndex, int32 *currentBasePoints = NULL);
float m_radius;
int32 m_removeTime;
AreaAuraType m_areaAuraType;
explicit UnitAura(SpellEntry const* spellproto, uint8 effMask, WorldObject * owner, Unit * caster, int32 *baseAmount, Item * castItem, uint64 casterGUID);
public:
void _ApplyForTarget(Unit * target, Unit * caster, AuraApplication * aurApp);
void _UnapplyForTarget(Unit * target, Unit * caster, AuraApplication * aurApp);
void Remove(AuraRemoveMode removeMode = AURA_REMOVE_BY_DEFAULT);
void UpdateTargetMapForEffect(Unit * caster, uint8 effIndex);
// Allow Apply Aura Handler to modify and access m_AuraDRGroup
void SetDiminishGroup(DiminishingGroup group) { m_AuraDRGroup = group; }
DiminishingGroup GetDiminishGroup() const { return m_AuraDRGroup; }
private:
DiminishingGroup m_AuraDRGroup:8; // Diminishing
};
class TRINITY_DLL_SPEC PersistentAreaAuraEffect : public AuraEffect
class TRINITY_DLL_SPEC DynObjAura : public Aura
{
public:
friend AuraEffect* CreateAuraEffect(Aura * parentAura, uint32 effIndex, int32 *currentBasePoints);
void Update(uint32 diff);
DynamicObject *GetSource() const;
friend Aura * Aura::Create(SpellEntry const* spellproto, uint8 effMask, WorldObject * owner, Unit * caster, int32 *baseAmount, Item * castItem, uint64 casterGUID);
protected:
explicit PersistentAreaAuraEffect(Aura * parentAura, uint32 eff, int32 *currentBasePoints = NULL);
explicit DynObjAura(SpellEntry const* spellproto, uint8 effMask, WorldObject * owner, Unit * caster, int32 *baseAmount, Item * castItem, uint64 casterGUID);
public:
void Remove(AuraRemoveMode removeMode = AURA_REMOVE_BY_DEFAULT);
void UpdateTargetMapForEffect(Unit * caster, uint8 effIndex);
};
AuraEffect* CreateAuraEffect(Aura * parentAura, uint32 effIndex, int32 *currentBasePoints = NULL);
#endif