--HG--
branch : trunk
This commit is contained in:
silinoron
2010-08-23 15:13:20 -07:00
28 changed files with 1075 additions and 291 deletions
+26 -6
View File
@@ -5103,18 +5103,38 @@ void ObjectMgr::ValidateSpellScripts()
for (SpellScriptsMap::iterator itr = mSpellScripts.begin(); itr != mSpellScripts.end();)
{
SpellEntry const * spellEntry = sSpellStore.LookupEntry(itr->first);
std::vector<std::pair<SpellScript *, SpellScriptsMap::iterator> > spellScripts;
sScriptMgr.CreateSpellScripts(itr->first, spellScripts);
std::vector<std::pair<SpellScriptLoader *, SpellScriptsMap::iterator> > SpellScriptLoaders;
sScriptMgr.CreateSpellScriptLoaders(itr->first, SpellScriptLoaders);
SpellScriptsMap::iterator bitr;
itr = mSpellScripts.upper_bound(itr->first);
for (std::vector<std::pair<SpellScript *, SpellScriptsMap::iterator> >::iterator sitr = spellScripts.begin(); sitr != spellScripts.end(); ++sitr)
for (std::vector<std::pair<SpellScriptLoader *, SpellScriptsMap::iterator> >::iterator sitr = SpellScriptLoaders.begin(); sitr != SpellScriptLoaders.end(); ++sitr)
{
bar.step();
sitr->first->Register();
if (!sitr->first->_Validate(spellEntry, sObjectMgr.GetScriptName(sitr->second->second)))
SpellScript * spellScript = sitr->first->GetSpellScript();
AuraScript * auraScript = sitr->first->GetAuraScript();
bool valid = true;
if (!spellScript && !auraScript)
{
sLog.outError("TSCR: Functions GetSpellScript() and GetAuraScript() of script `%s` do not return objects - script skipped", GetScriptName(sitr->second->second));
valid = false;
}
if (spellScript)
{
spellScript->Register();
if (!spellScript->_Validate(spellEntry, sObjectMgr.GetScriptName(sitr->second->second)))
valid = false;
delete spellScript;
}
if (auraScript)
{
auraScript->Register();
if (!auraScript->_Validate(spellEntry, sObjectMgr.GetScriptName(sitr->second->second)))
valid = false;
delete auraScript;
}
if (!valid)
mSpellScripts.erase(sitr->second);
delete sitr->first;
}
}
+27 -27
View File
@@ -148,8 +148,7 @@ ScriptMgr::~ScriptMgr()
SCR_REG_LST(T).clear();
// Clear scripts for every script type.
SCR_CLEAR(SpellHandlerScript);
SCR_CLEAR(AuraHandlerScript);
SCR_CLEAR(SpellScriptLoader);
SCR_CLEAR(ServerScript);
SCR_CLEAR(WorldScript);
SCR_CLEAR(FormulaScript);
@@ -296,42 +295,50 @@ void ScriptMgr::CreateSpellScripts(uint32 spell_id, std::list<SpellScript *> & s
for (SpellScriptsMap::iterator itr = bounds.first; itr != bounds.second; ++itr)
{
SpellHandlerScript* tmpscript = ScriptRegistry<SpellHandlerScript>::GetScriptById(itr->second);
SpellScriptLoader* tmpscript = ScriptRegistry<SpellScriptLoader>::GetScriptById(itr->second);
if (!tmpscript)
continue;
SpellScript* script = tmpscript->GetSpellScript();
if (!script)
{
sLog.outError("Spell script %s for spell %u returned a NULL SpellScript pointer!", tmpscript->GetName().c_str(), spell_id);
continue;
}
script_vector.push_back(script);
}
}
void ScriptMgr::CreateSpellScripts(uint32 spell_id, std::vector<std::pair<SpellScript *, SpellScriptsMap::iterator> > & script_vector)
void ScriptMgr::CreateAuraScripts(uint32 spell_id, std::list<AuraScript *> & script_vector)
{
SpellScriptsBounds bounds = sObjectMgr.GetSpellScriptsBounds(spell_id);
for (SpellScriptsMap::iterator itr = bounds.first; itr != bounds.second; ++itr)
{
SpellScriptLoader* tmpscript = ScriptRegistry<SpellScriptLoader>::GetScriptById(itr->second);
if (!tmpscript)
continue;
AuraScript* script = tmpscript->GetAuraScript();
if (!script)
continue;
script_vector.push_back(script);
}
}
void ScriptMgr::CreateSpellScriptLoaders(uint32 spell_id, std::vector<std::pair<SpellScriptLoader *, SpellScriptsMap::iterator> > & script_vector)
{
SpellScriptsBounds bounds = sObjectMgr.GetSpellScriptsBounds(spell_id);
script_vector.reserve(std::distance(bounds.first, bounds.second));
for (SpellScriptsMap::iterator itr = bounds.first; itr != bounds.second; ++itr)
{
SpellHandlerScript* tmpscript = ScriptRegistry<SpellHandlerScript>::GetScriptById(itr->second);
SpellScriptLoader* tmpscript = ScriptRegistry<SpellScriptLoader>::GetScriptById(itr->second);
if (!tmpscript)
continue;
SpellScript* script = tmpscript->GetSpellScript();
if (!script)
{
sLog.outError("Spell script %s for spell %u returned a NULL SpellScript pointer!", tmpscript->GetName().c_str(), spell_id);
continue;
}
script_vector.push_back(std::make_pair(script, itr));
script_vector.push_back(std::make_pair(tmpscript, itr));
}
}
@@ -1154,16 +1161,10 @@ void ScriptMgr::OnGuildDisband(Guild *guild)
FOREACH_SCRIPT(GuildScript)->OnDisband(guild);
}
SpellHandlerScript::SpellHandlerScript(const char* name)
SpellScriptLoader::SpellScriptLoader(const char* name)
: ScriptObject(name)
{
ScriptMgr::ScriptRegistry<SpellHandlerScript>::AddScript(this);
}
AuraHandlerScript::AuraHandlerScript(const char* name)
: ScriptObject(name)
{
ScriptMgr::ScriptRegistry<AuraHandlerScript>::AddScript(this);
ScriptMgr::ScriptRegistry<SpellScriptLoader>::AddScript(this);
}
ServerScript::ServerScript(const char* name)
@@ -1312,8 +1313,7 @@ template<class TScript> std::map<uint32, TScript*> ScriptMgr::ScriptRegistry<TSc
template<class TScript> uint32 ScriptMgr::ScriptRegistry<TScript>::_scriptIdCounter = 0;
// Specialize for each script type class like so:
template class ScriptMgr::ScriptRegistry<SpellHandlerScript>;
template class ScriptMgr::ScriptRegistry<AuraHandlerScript>;
template class ScriptMgr::ScriptRegistry<SpellScriptLoader>;
template class ScriptMgr::ScriptRegistry<ServerScript>;
template class ScriptMgr::ScriptRegistry<WorldScript>;
template class ScriptMgr::ScriptRegistry<FormulaScript>;
+8 -23
View File
@@ -42,6 +42,7 @@ class Creature;
class CreatureAI;
class InstanceScript;
class SpellScript;
class AuraScript;
class Quest;
class Item;
class GameObject;
@@ -180,32 +181,20 @@ template<class TObject> class UpdatableScript
virtual void OnUpdate(TObject* /*obj*/, uint32 /*diff*/) { }
};
class SpellHandlerScript : public ScriptObject
class SpellScriptLoader : public ScriptObject
{
protected:
SpellHandlerScript(const char* name);
SpellScriptLoader(const char* name);
public:
bool IsDatabaseBound() const { return true; }
// Should return a fully valid SpellScript pointer.
virtual SpellScript* GetSpellScript() const = 0;
};
class AuraHandlerScript : public ScriptObject
{
protected:
AuraHandlerScript(const char* name);
public:
bool IsDatabaseBound() const { return true; }
virtual SpellScript* GetSpellScript() const { return NULL; };
// Should return a fully valid AuraScript pointer.
// virtual AuraScript* GetAuraScript() const = 0;
virtual AuraScript* GetAuraScript() const { return NULL; };
};
class ServerScript : public ScriptObject
@@ -742,15 +731,11 @@ class ScriptMgr
void IncrementScriptCount() { ++_scriptCount; }
uint32 GetScriptCount() const { return _scriptCount; }
public: /* SpellHandlerScript */
public: /* SpellScriptLoader */
void CreateSpellScripts(uint32 spell_id, std::list<SpellScript*>& script_vector);
void CreateSpellScripts(uint32 spell_id, std::vector<std::pair<SpellScript*, SpellScriptsMap::iterator> >& script_vector);
public: /* AuraHandlerScript */
// void CreateAuraScripts(uint32 spell_id, std::list<AuraScript*>& script_vector);
// void CreateAuraScripts(uint32 spell_id, std::vector<std::pair<AuraScript*, SpellScriptsMap::iterator> >& script_vector);
void CreateAuraScripts(uint32 spell_id, std::list<AuraScript*>& script_vector);
void CreateSpellScriptLoaders(uint32 spell_id, std::vector<std::pair<SpellScriptLoader*, SpellScriptsMap::iterator> >& script_vector);
public: /* ServerScript */
@@ -35,6 +35,18 @@ enum AURA_FLAGS
AFLAG_NEGATIVE = 0x80
};
enum AuraEffectHandleModes
{
AURA_EFFECT_HANDLE_DEFAULT = 0x0,
AURA_EFFECT_HANDLE_REAL = 0x01,
AURA_EFFECT_HANDLE_SEND_FOR_CLIENT = 0x02,
AURA_EFFECT_HANDLE_CHANGE_AMOUNT = 0x04,
AURA_EFFECT_HANDLE_STAT = 0x08,
AURA_EFFECT_HANDLE_SEND_FOR_CLIENT_MASK = (AURA_EFFECT_HANDLE_SEND_FOR_CLIENT | AURA_EFFECT_HANDLE_REAL),
AURA_EFFECT_HANDLE_CHANGE_AMOUNT_MASK = (AURA_EFFECT_HANDLE_CHANGE_AMOUNT | AURA_EFFECT_HANDLE_REAL),
AURA_EFFECT_HANDLE_CHANGE_AMOUNT_SEND_FOR_CLIENT_MASK = (AURA_EFFECT_HANDLE_CHANGE_AMOUNT_MASK | AURA_EFFECT_HANDLE_SEND_FOR_CLIENT_MASK),
};
//m_schoolAbsorb
enum DAMAGE_ABSORB_TYPE
{
@@ -737,6 +737,8 @@ int32 AuraEffect::CalculateAmount(Unit * caster)
DoneActualBenefit *= caster->CalculateLevelPenalty(GetSpellProto());
amount += (int32)DoneActualBenefit;
}
GetBase()->CallScriptEffectCalcAmountHandlers(const_cast<AuraEffect const *>(this), amount, m_canBeRecalculated);
amount *= GetBase()->GetStackAmount();
return amount;
}
@@ -787,6 +789,8 @@ void AuraEffect::CalculatePeriodic(Unit * caster, bool create)
break;
}
GetBase()->CallScriptEffectCalcPeriodicHandlers(const_cast<AuraEffect const *>(this), m_isPeriodic, m_amplitude);
if (!m_isPeriodic)
return;
@@ -907,6 +911,7 @@ void AuraEffect::CalculateSpellMod()
default:
break;
}
GetBase()->CallScriptEffectCalcSpellModHandlers(const_cast<AuraEffect const *>(this), m_spellmod);
}
void AuraEffect::ChangeAmount(int32 newAmount, bool mark)
@@ -946,7 +951,14 @@ void AuraEffect::HandleEffect(AuraApplication const * aurApp, uint8 mode, bool a
if (mode & AURA_EFFECT_HANDLE_CHANGE_AMOUNT_MASK)
ApplySpellMod(aurApp->GetTarget(), apply);
(*this.*AuraEffectHandler [GetAuraType()])(aurApp, mode, apply);
bool prevented = false;
if (apply)
prevented = GetBase()->CallScriptEffectApplyHandlers(const_cast<AuraEffect const *>(this), aurApp, (AuraEffectHandleModes)mode);
else
prevented = GetBase()->CallScriptEffectRemoveHandlers(const_cast<AuraEffect const *>(this), aurApp, (AuraEffectHandleModes)mode);
if (!prevented)
(*this.*AuraEffectHandler [GetAuraType()])(aurApp, mode, apply);
}
void AuraEffect::HandleEffect(Unit * target, uint8 mode, bool apply)
@@ -1203,6 +1215,7 @@ void AuraEffect::UpdatePeriodic(Unit * caster)
default:
break;
}
GetBase()->CallScriptEffectUpdatePeriodicHandlers(this);
}
bool AuraEffect::IsPeriodicTickCrit(Unit * target, Unit const * caster) const
@@ -1244,6 +1257,10 @@ void AuraEffect::PeriodicTick(Unit * target, Unit * caster) const
return;
}
bool prevented = GetBase()->CallScriptEffectPeriodicHandlers(const_cast<AuraEffect const *>(this), GetBase()->GetApplicationOfTarget(target->GetGUID()));
if (prevented)
return;
switch(GetAuraType())
{
case SPELL_AURA_PERIODIC_DAMAGE:
@@ -9,15 +9,6 @@ class Aura;
#include "SpellAuras.h"
#define AURA_EFFECT_HANDLE_DEFAULT 0
#define AURA_EFFECT_HANDLE_REAL 0x01
#define AURA_EFFECT_HANDLE_SEND_FOR_CLIENT 0x02
#define AURA_EFFECT_HANDLE_CHANGE_AMOUNT 0x04
#define AURA_EFFECT_HANDLE_STAT 0x08
#define AURA_EFFECT_HANDLE_SEND_FOR_CLIENT_MASK (AURA_EFFECT_HANDLE_SEND_FOR_CLIENT | AURA_EFFECT_HANDLE_REAL)
#define AURA_EFFECT_HANDLE_CHANGE_AMOUNT_MASK (AURA_EFFECT_HANDLE_CHANGE_AMOUNT | AURA_EFFECT_HANDLE_REAL)
#define AURA_EFFECT_HANDLE_CHANGE_AMOUNT_SEND_FOR_CLIENT_MASK (AURA_EFFECT_HANDLE_CHANGE_AMOUNT_MASK | AURA_EFFECT_HANDLE_SEND_FOR_CLIENT_MASK)
typedef void(AuraEffect::*pAuraEffectHandler)(AuraApplication const * aurApp, uint8 mode, bool apply) const;
class AuraEffect
@@ -91,11 +82,11 @@ class AuraEffect
int32 const m_baseAmount;
int32 m_amount;
bool m_canBeRecalculated:1;
bool m_canBeRecalculated;
SpellModifier *m_spellmod;
bool m_isPeriodic:1;
bool m_isPeriodic;
int32 m_periodicTimer;
int32 m_amplitude;
uint32 m_tickNumber;
+128
View File
@@ -34,6 +34,8 @@
#include "GridNotifiers.h"
#include "GridNotifiersImpl.h"
#include "CellImpl.h"
#include "ScriptMgr.h"
#include "SpellScript.h"
AuraApplication::AuraApplication(Unit * target, Unit * caster, Aura * aura, uint8 effMask):
m_target(target), m_base(aura), m_slot(MAX_AURAS), m_flags(AFLAG_NONE),
@@ -326,6 +328,8 @@ m_owner(owner), m_timeCla(0), m_updateTargetMapInterval(0),
m_casterLevel(caster ? caster->getLevel() : m_spellProto->spellLevel), m_procCharges(0), m_stackAmount(1),
m_isRemoved(false), m_isSingleTarget(false)
{
LoadScripts();
if (m_spellProto->manaPerSecond || m_spellProto->manaPerSecondPerLevel)
m_timeCla = 1 * IN_MILLISECONDS;
@@ -1593,6 +1597,130 @@ void Aura::_DeleteRemovedApplications()
}
}
void Aura::LoadScripts()
{
sLog.outDebug("Aura::LoadScripts");
sScriptMgr.CreateAuraScripts(m_spellProto->Id, m_loadedScripts);
for(std::list<AuraScript *>::iterator itr = m_loadedScripts.begin(); itr != m_loadedScripts.end() ;)
{
if (!(*itr)->_Load(this))
{
std::list<AuraScript *>::iterator bitr = itr;
++itr;
m_loadedScripts.erase(bitr);
continue;
}
(*itr)->Register();
++itr;
}
}
bool Aura::CallScriptEffectApplyHandlers(AuraEffect const * aurEff, AuraApplication const * aurApp, AuraEffectHandleModes mode)
{
bool preventDefault = false;
for(std::list<AuraScript *>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end() ; ++scritr)
{
(*scritr)->_ResetDefault();
std::list<AuraScript::EffectApplyHandler>::iterator effEndItr = (*scritr)->OnEffectApply.end(), effItr = (*scritr)->OnEffectApply.begin();
for(; effItr != effEndItr ; ++effItr)
{
if ((*effItr).IsEffectAffected(m_spellProto, aurEff->GetEffIndex()))
(*effItr).Call(*scritr, aurEff, aurApp, mode);
}
if (!preventDefault)
preventDefault = (*scritr)->_IsDefaultActionPrevented((SpellEffIndex)aurEff->GetEffIndex());
}
return preventDefault;
}
bool Aura::CallScriptEffectRemoveHandlers(AuraEffect const * aurEff, AuraApplication const * aurApp, AuraEffectHandleModes mode)
{
bool preventDefault = false;
for(std::list<AuraScript *>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end() ; ++scritr)
{
(*scritr)->_ResetDefault();
std::list<AuraScript::EffectApplyHandler>::iterator effEndItr = (*scritr)->OnEffectRemove.end(), effItr = (*scritr)->OnEffectRemove.begin();
for(; effItr != effEndItr ; ++effItr)
{
if ((*effItr).IsEffectAffected(m_spellProto, aurEff->GetEffIndex()))
(*effItr).Call(*scritr, aurEff, aurApp, mode);
}
if (!preventDefault)
preventDefault = (*scritr)->_IsDefaultActionPrevented((SpellEffIndex)aurEff->GetEffIndex());
}
return preventDefault;
}
bool Aura::CallScriptEffectPeriodicHandlers(AuraEffect const * aurEff, AuraApplication const * aurApp)
{
bool preventDefault = false;
for(std::list<AuraScript *>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end() ; ++scritr)
{
(*scritr)->_ResetDefault();
std::list<AuraScript::EffectPeriodicHandler>::iterator effEndItr = (*scritr)->OnEffectPeriodic.end(), effItr = (*scritr)->OnEffectPeriodic.begin();
for(; effItr != effEndItr ; ++effItr)
{
if ((*effItr).IsEffectAffected(m_spellProto, aurEff->GetEffIndex()))
(*effItr).Call(*scritr, aurEff, aurApp);
}
if (!preventDefault)
preventDefault = (*scritr)->_IsDefaultActionPrevented((SpellEffIndex)aurEff->GetEffIndex());
}
return preventDefault;
}
void Aura::CallScriptEffectUpdatePeriodicHandlers(AuraEffect * aurEff)
{
for(std::list<AuraScript *>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end() ; ++scritr)
{
std::list<AuraScript::EffectUpdatePeriodicHandler>::iterator effEndItr = (*scritr)->OnEffectUpdatePeriodic.end(), effItr = (*scritr)->OnEffectUpdatePeriodic.begin();
for(; effItr != effEndItr ; ++effItr)
{
if ((*effItr).IsEffectAffected(m_spellProto, aurEff->GetEffIndex()))
(*effItr).Call(*scritr, aurEff);
}
}
}
void Aura::CallScriptEffectCalcAmountHandlers(AuraEffect const * aurEff, int32 & amount, bool & canBeRecalculated)
{
for(std::list<AuraScript *>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end() ; ++scritr)
{
std::list<AuraScript::EffectCalcAmountHandler>::iterator effEndItr = (*scritr)->OnEffectCalcAmount.end(), effItr = (*scritr)->OnEffectCalcAmount.begin();
for(; effItr != effEndItr ; ++effItr)
{
if ((*effItr).IsEffectAffected(m_spellProto, aurEff->GetEffIndex()))
(*effItr).Call(*scritr, aurEff, amount, canBeRecalculated);
}
}
}
void Aura::CallScriptEffectCalcPeriodicHandlers(AuraEffect const * aurEff, bool & isPeriodic, int32 & amplitude)
{
for(std::list<AuraScript *>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end() ; ++scritr)
{
std::list<AuraScript::EffectCalcPeriodicHandler>::iterator effEndItr = (*scritr)->OnEffectCalcPeriodic.end(), effItr = (*scritr)->OnEffectCalcPeriodic.begin();
for(; effItr != effEndItr ; ++effItr)
{
if ((*effItr).IsEffectAffected(m_spellProto, aurEff->GetEffIndex()))
(*effItr).Call(*scritr, aurEff, isPeriodic, amplitude);
}
}
}
void Aura::CallScriptEffectCalcSpellModHandlers(AuraEffect const * aurEff, SpellModifier *& spellMod)
{
for(std::list<AuraScript *>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end() ; ++scritr)
{
std::list<AuraScript::EffectCalcSpellModHandler>::iterator effEndItr = (*scritr)->OnEffectCalcSpellMod.end(), effItr = (*scritr)->OnEffectCalcSpellMod.begin();
for(; effItr != effEndItr ; ++effItr)
{
if ((*effItr).IsEffectAffected(m_spellProto, aurEff->GetEffIndex()))
(*effItr).Call(*scritr, aurEff, spellMod);
}
}
}
UnitAura::UnitAura(SpellEntry const* spellproto, uint8 effMask, WorldObject * owner, Unit * caster, int32 *baseAmount, Item * castItem, uint64 casterGUID)
: Aura(spellproto, effMask, owner, caster, baseAmount, castItem, casterGUID)
{
+14 -2
View File
@@ -32,6 +32,7 @@ struct ProcTriggerSpell;
class AuraEffect;
class Aura;
class DynamicObject;
class AuraScript;
// update aura target map every 500 ms instead of every update - reduce amount of grid searcher calls
#define UPDATE_TARGET_MAP_INTERVAL 500
@@ -150,7 +151,7 @@ class Aura
// 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]; }
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);
@@ -159,12 +160,23 @@ class Aura
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 IsAppliedOnTarget(uint64 const & guid) const { return m_applications.find(guid) != m_applications.end(); }
void SetNeedClientUpdateForTargets() const;
void HandleAuraSpecificMods(AuraApplication const * aurApp, Unit * caster, bool apply);
bool CanBeAppliedOn(Unit *target);
bool CheckAreaTarget(Unit *target);
// AuraScript
void LoadScripts();
bool CallScriptEffectApplyHandlers(AuraEffect const * aurEff, AuraApplication const * aurApp, AuraEffectHandleModes mode);
bool CallScriptEffectRemoveHandlers(AuraEffect const * aurEff, AuraApplication const * aurApp, AuraEffectHandleModes mode);
bool CallScriptEffectPeriodicHandlers(AuraEffect const * aurEff, AuraApplication const * aurApp);
void CallScriptEffectUpdatePeriodicHandlers(AuraEffect * aurEff);
void CallScriptEffectCalcAmountHandlers(AuraEffect const * aurEff, int32 & amount, bool & canBeRecalculated);
void CallScriptEffectCalcPeriodicHandlers(AuraEffect const * aurEff, bool & isPeriodic, int32 & amplitude);
void CallScriptEffectCalcSpellModHandlers(AuraEffect const * aurEff, SpellModifier *& spellMod);
std::list<AuraScript *> m_loadedScripts;
private:
void _DeleteRemovedApplications();
protected:
+1 -1
View File
@@ -7312,7 +7312,7 @@ bool Spell::CallScriptEffectHandlers(SpellEffIndex effIndex)
bool preventDefault = false;
for(std::list<SpellScript *>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end() ; ++scritr)
{
std::list<SpellScript::EffectHandler>::iterator effEndItr = (*scritr)->EffectHandlers.end(), effItr = (*scritr)->EffectHandlers.begin();
std::list<SpellScript::EffectHandler>::iterator effEndItr = (*scritr)->OnEffect.end(), effItr = (*scritr)->OnEffect.begin();
for(; effItr != effEndItr ; ++effItr)
{
// effect execution can be prevented
+270 -2
View File
@@ -126,7 +126,7 @@ std::string _SpellScript::EffectAuraNameCheck::ToString()
}
}
SpellScript::EffectHandler::EffectHandler(EffectHandlerFnType _pEffectHandlerScript,uint8 _effIndex, uint16 _effName)
SpellScript::EffectHandler::EffectHandler(SpellEffectFnType _pEffectHandlerScript,uint8 _effIndex, uint16 _effName)
: _SpellScript::EffectNameCheck(_effName), _SpellScript::EffectHook(_effIndex)
{
pEffectHandlerScript = _pEffectHandlerScript;
@@ -149,7 +149,7 @@ void SpellScript::EffectHandler::Call(SpellScript * spellScript, SpellEffIndex e
bool SpellScript::_Validate(SpellEntry const * entry, const char * scriptname)
{
for (std::list<EffectHandler>::iterator itr = EffectHandlers.begin(); itr != EffectHandlers.end(); ++itr)
for (std::list<EffectHandler>::iterator itr = OnEffect.begin(); itr != OnEffect.end(); ++itr)
{
if (!(*itr).GetAffectedEffectsMask(entry))
{
@@ -284,3 +284,271 @@ void SpellScript::CreateItem(uint32 effIndex, uint32 itemId)
{
m_spell->DoCreateItem(effIndex, itemId);
}
bool AuraScript::_Validate(SpellEntry const * entry, const char * scriptname)
{
for (std::list<EffectApplyHandler>::iterator itr = OnEffectApply.begin(); itr != OnEffectApply.end(); ++itr)
if (!(*itr).GetAffectedEffectsMask(entry))
sLog.outError("TSCR: Spell `%u` Effect `%s` of script`%s` did not match dbc effect data - bound handler won't be executed", entry->Id, (*itr).ToString().c_str(), scriptname);
for (std::list<EffectApplyHandler>::iterator itr = OnEffectRemove.begin(); itr != OnEffectRemove.end(); ++itr)
if (!(*itr).GetAffectedEffectsMask(entry))
sLog.outError("TSCR: Spell `%u` Effect `%s` of script`%s` did not match dbc effect data - bound handler won't be executed", entry->Id, (*itr).ToString().c_str(), scriptname);
for (std::list<EffectPeriodicHandler>::iterator itr = OnEffectPeriodic.begin(); itr != OnEffectPeriodic.end(); ++itr)
if (!(*itr).GetAffectedEffectsMask(entry))
sLog.outError("TSCR: Spell `%u` Effect `%s` of script`%s` did not match dbc effect data - bound handler won't be executed", entry->Id, (*itr).ToString().c_str(), scriptname);
for (std::list<EffectUpdatePeriodicHandler>::iterator itr = OnEffectUpdatePeriodic.begin(); itr != OnEffectUpdatePeriodic.end(); ++itr)
if (!(*itr).GetAffectedEffectsMask(entry))
sLog.outError("TSCR: Spell `%u` Effect `%s` of script`%s` did not match dbc effect data - bound handler won't be executed", entry->Id, (*itr).ToString().c_str(), scriptname);
for (std::list<EffectCalcAmountHandler>::iterator itr = OnEffectCalcAmount.begin(); itr != OnEffectCalcAmount.end(); ++itr)
if (!(*itr).GetAffectedEffectsMask(entry))
sLog.outError("TSCR: Spell `%u` Effect `%s` of script`%s` did not match dbc effect data - bound handler won't be executed", entry->Id, (*itr).ToString().c_str(), scriptname);
for (std::list<EffectCalcPeriodicHandler>::iterator itr = OnEffectCalcPeriodic.begin(); itr != OnEffectCalcPeriodic.end(); ++itr)
if (!(*itr).GetAffectedEffectsMask(entry))
sLog.outError("TSCR: Spell `%u` Effect `%s` of script`%s` did not match dbc effect data - bound handler won't be executed", entry->Id, (*itr).ToString().c_str(), scriptname);
for (std::list<EffectCalcSpellModHandler>::iterator itr = OnEffectCalcSpellMod.begin(); itr != OnEffectCalcSpellMod.end(); ++itr)
if (!(*itr).GetAffectedEffectsMask(entry))
sLog.outError("TSCR: Spell `%u` Effect `%s` of script`%s` did not match dbc effect data - bound handler won't be executed", entry->Id, (*itr).ToString().c_str(), scriptname);
return _SpellScript::_Validate(entry, scriptname);
}
AuraScript::EffectBase::EffectBase(uint8 _effIndex, uint16 _effName)
: _SpellScript::EffectAuraNameCheck(_effName), _SpellScript::EffectHook(_effIndex)
{
}
bool AuraScript::EffectBase::CheckEffect(SpellEntry const * spellEntry, uint8 effIndex)
{
return _SpellScript::EffectAuraNameCheck::Check(spellEntry, effIndex);
}
std::string AuraScript::EffectBase::ToString()
{
return "Index: " + EffIndexToString() + " AuraName: " +_SpellScript::EffectAuraNameCheck::ToString();
}
AuraScript::EffectPeriodicHandler::EffectPeriodicHandler(AuraEffectPeriodicFnType _pEffectHandlerScript,uint8 _effIndex, uint16 _effName)
: AuraScript::EffectBase(_effIndex, _effName)
{
pEffectHandlerScript = _pEffectHandlerScript;
}
void AuraScript::EffectPeriodicHandler::Call(AuraScript * auraScript, AuraEffect const * _aurEff, AuraApplication const * _aurApp)
{
(auraScript->*pEffectHandlerScript)(_aurEff, _aurApp);
}
AuraScript::EffectUpdatePeriodicHandler::EffectUpdatePeriodicHandler(AuraEffectUpdatePeriodicFnType _pEffectHandlerScript,uint8 _effIndex, uint16 _effName)
: AuraScript::EffectBase(_effIndex, _effName)
{
pEffectHandlerScript = _pEffectHandlerScript;
}
void AuraScript::EffectUpdatePeriodicHandler::Call(AuraScript * auraScript, AuraEffect * aurEff)
{
(auraScript->*pEffectHandlerScript)(aurEff);
}
AuraScript::EffectCalcAmountHandler::EffectCalcAmountHandler(AuraEffectCalcAmountFnType _pEffectHandlerScript,uint8 _effIndex, uint16 _effName)
: AuraScript::EffectBase(_effIndex, _effName)
{
pEffectHandlerScript = _pEffectHandlerScript;
}
void AuraScript::EffectCalcAmountHandler::Call(AuraScript * auraScript, AuraEffect const * aurEff, int32 & amount, bool & canBeRecalculated)
{
(auraScript->*pEffectHandlerScript)(aurEff, amount, canBeRecalculated);
}
AuraScript::EffectCalcPeriodicHandler::EffectCalcPeriodicHandler(AuraEffectCalcPeriodicFnType _pEffectHandlerScript,uint8 _effIndex, uint16 _effName)
: AuraScript::EffectBase(_effIndex, _effName)
{
pEffectHandlerScript = _pEffectHandlerScript;
}
void AuraScript::EffectCalcPeriodicHandler::Call(AuraScript * auraScript, AuraEffect const * aurEff, bool & isPeriodic, int32 & periodicTimer)
{
(auraScript->*pEffectHandlerScript)(aurEff, isPeriodic, periodicTimer);
}
AuraScript::EffectCalcSpellModHandler::EffectCalcSpellModHandler(AuraEffectCalcSpellModFnType _pEffectHandlerScript,uint8 _effIndex, uint16 _effName)
: AuraScript::EffectBase(_effIndex, _effName)
{
pEffectHandlerScript = _pEffectHandlerScript;
}
void AuraScript::EffectCalcSpellModHandler::Call(AuraScript * auraScript, AuraEffect const * aurEff, SpellModifier *& spellMod)
{
(auraScript->*pEffectHandlerScript)(aurEff, spellMod);
}
AuraScript::EffectApplyHandler::EffectApplyHandler(AuraEffectApplicationModeFnType _pEffectHandlerScript,uint8 _effIndex, uint16 _effName, AuraEffectHandleModes _mode)
: AuraScript::EffectBase(_effIndex, _effName)
{
pEffectHandlerScript = _pEffectHandlerScript;
mode = _mode;
}
void AuraScript::EffectApplyHandler::Call(AuraScript * auraScript, AuraEffect const * _aurEff, AuraApplication const * _aurApp, AuraEffectHandleModes _mode)
{
if (_mode & mode)
(auraScript->*pEffectHandlerScript)(_aurEff, _aurApp, _mode);
}
bool AuraScript::_Load(Aura * aura)
{
m_aura = aura;
return Load();
}
SpellEntry const* AuraScript::GetSpellProto() const
{
return m_aura->GetSpellProto();
}
uint32 AuraScript::GetId() const
{
return m_aura->GetId();
}
uint64 const& AuraScript::GetCasterGUID() const
{
return m_aura->GetCasterGUID();
}
Unit* AuraScript::GetCaster() const
{
return m_aura->GetCaster();
}
WorldObject* AuraScript::GetOwner() const
{
return m_aura->GetOwner();
}
Unit* AuraScript::GetUnitOwner() const
{
return m_aura->GetUnitOwner();
}
DynamicObject* AuraScript::GetDynobjOwner() const
{
return m_aura->GetDynobjOwner();
}
void AuraScript::Remove(uint32 removeMode)
{
m_aura->Remove((AuraRemoveMode)removeMode);
}
Aura* AuraScript::GetAura() const
{
return m_aura;
}
AuraObjectType AuraScript::GetType() const
{
return m_aura->GetType();
}
int32 AuraScript::GetDuration() const
{
return m_aura->GetDuration();
}
void AuraScript::SetDuration(int32 duration, bool withMods)
{
m_aura->SetDuration(duration, withMods);
}
void AuraScript::RefreshDuration()
{
m_aura->RefreshDuration();
}
time_t AuraScript::GetApplyTime() const
{
return m_aura->GetApplyTime();
}
int32 AuraScript::GetMaxDuration() const
{
return m_aura->GetMaxDuration();
}
void AuraScript::SetMaxDuration(int32 duration)
{
m_aura->SetMaxDuration(duration);
}
bool AuraScript::IsExpired() const
{
return m_aura->IsExpired();
}
bool AuraScript::IsPermanent() const
{
return m_aura->IsPermanent();
}
uint8 AuraScript::GetCharges() const
{
return m_aura->GetCharges();
}
void AuraScript::SetCharges(uint8 charges)
{
m_aura->SetCharges(charges);
}
bool AuraScript::DropCharge()
{
return m_aura->DropCharge();
}
uint8 AuraScript::GetStackAmount() const
{
return m_aura->GetStackAmount();
}
void AuraScript::SetStackAmount(uint8 num, bool applied)
{
m_aura->SetStackAmount(num, applied);
}
bool AuraScript::ModStackAmount(int32 num)
{
return m_aura->ModStackAmount(num);
}
bool AuraScript::IsPassive() const
{
return m_aura->IsPassive();
}
bool AuraScript::IsDeathPersistent() const
{
return m_aura->IsDeathPersistent();
}
bool AuraScript::HasEffect(uint8 effIndex) const
{
return m_aura->HasEffect(effIndex);
}
AuraEffect* AuraScript::GetEffect(uint8 effIndex) const
{
return m_aura->GetEffect(effIndex);
}
bool AuraScript::HasEffectType(AuraType type) const
{
return m_aura->HasEffectType(type);
}
+208 -29
View File
@@ -21,20 +21,22 @@
#include "Util.h"
#include "SharedDefines.h"
#include "SpellAuraDefines.h"
class Unit;
struct SpellEntry;
class SpellScript;
class Spell;
class Aura;
class AuraEffect;
struct SpellModifier;
class Creature;
class GameObject;
class DynamicObject;
class Player;
class Item;
class WorldLocation;
typedef void(SpellScript::*EffectHandlerFnType)(SpellEffIndex);
typedef void(SpellScript::*HitHandlerFnType)();
class WorldObject;
#define SPELL_EFFECT_ANY (uint16)-1
#define SPELL_AURA_ANY (uint16)-1
@@ -99,17 +101,20 @@ class SpellScript : public _SpellScript
// internal use classes & functions
// DO NOT OVERRIDE THESE IN SCRIPTS
public:
typedef void(SpellScript::*SpellEffectFnType)(SpellEffIndex);
typedef void(SpellScript::*SpellHitFnType)();
class EffectHandler : public _SpellScript::EffectNameCheck, public _SpellScript::EffectHook
{
public:
EffectHandler(EffectHandlerFnType _pEffectHandlerScript,uint8 _effIndex, uint16 _effName);
EffectHandler(SpellEffectFnType _pEffectHandlerScript,uint8 _effIndex, uint16 _effName);
std::string ToString();
bool CheckEffect(SpellEntry const * spellEntry, uint8 effIndex);
void Call(SpellScript * spellScript, SpellEffIndex effIndex);
private:
EffectHandlerFnType pEffectHandlerScript;
SpellEffectFnType pEffectHandlerScript;
};
typedef HitHandlerFnType HitHandler;
typedef SpellHitFnType HitHandler;
public:
bool _Validate(SpellEntry const * entry, const char * scriptname);
bool _Load(Spell * spell);
@@ -125,22 +130,23 @@ class SpellScript : public _SpellScript
// SpellScript interface
// hooks to which you can attach your functions
//
// List of functions registered by EffectHandlerFn
// allows more than one hook
// example EffectHandlers += EffectHandlerFn(class::function, EffectIndexSpecifier, EffectNameSpecifier);
HookList<EffectHandler> EffectHandlers;
// List of functions registered by HitHandlerFn
// allows more than one hook
// example: BeforeHit += HitHandlerFn(class::function);
// example: OnEffect += SpellEffectFn(class::function, EffectIndexSpecifier, EffectNameSpecifier);
// where function is void function(SpellEffIndex effIndex)
HookList<EffectHandler> OnEffect;
#define SpellEffectFn(F, I, N) EffectHandler((SpellEffectFnType)&F, I, N)
// example: BeforeHit += SpellHitFn(class::function);
HookList<HitHandler> BeforeHit;
// example: OnHit += HitHandlerFn(class::function);
// example: OnHit += SpellHitFn(class::function);
HookList<HitHandler> OnHit;
// example: AfterHit += HitHandlerFn(class::function);
// example: AfterHit += SpellHitFn(class::function);
HookList<HitHandler> AfterHit;
// where function is: void function()
#define SpellHitFn(F) (SpellHitFnType)&F
// hooks are executed in following order, at specified event of spell:
// 1. BeforeHit - executed just before spell hits a target
// 2. EffectHandlers - executed just before specified effect handler call
// 2. OnEffect - executed just before specified effect handler call
// 3. OnHit - executed just before spell deals damage and procs auras
// 4. AfterHit - executed just after spell finishes all it's jobs for target
@@ -202,20 +208,193 @@ class SpellScript : public _SpellScript
// Creates item. Calls Spell::DoCreateItem method.
void CreateItem(uint32 effIndex, uint32 itemId);
};
// SpellScript interface
//
// function registering macros, should be used only in Register()
//
// EffectHandlerFn
// called at: Spell hit on unit, just before default effect handler, called for effects matching EffectIndexSpecifier and EffectNameSpecifier conditions
// hook parameter is current effect index
// parameters: function to call, EffectIndexSpecifier, EffectNameSpecifier
#define EffectHandlerFn(F, I, N) EffectHandler((EffectHandlerFnType)&F, I, N)
// HitHandlerFn
// called at: Spell hit on unit, before or after effect handlers, depends if bound to OnHit or AfterHit
// parameters: function to call
#define HitHandlerFn(F) (HitHandlerFnType)&F
class AuraScript : public _SpellScript
{
// internal use classes & functions
// DO NOT OVERRIDE THESE IN SCRIPTS
public:
typedef void(AuraScript::*AuraEffectApplicationModeFnType)(AuraEffect const *, AuraApplication const *, AuraEffectHandleModes mode);
typedef void(AuraScript::*AuraEffectPeriodicFnType)(AuraEffect const *, AuraApplication const *);
typedef void(AuraScript::*AuraEffectUpdatePeriodicFnType)(AuraEffect *);
typedef void(AuraScript::*AuraEffectCalcAmountFnType)(AuraEffect const *, int32 &, bool &);
typedef void(AuraScript::*AuraEffectCalcPeriodicFnType)(AuraEffect const *, bool &, int32 &);
typedef void(AuraScript::*AuraEffectCalcSpellModFnType)(AuraEffect const *, SpellModifier *&);
class EffectBase : public _SpellScript::EffectAuraNameCheck, public _SpellScript::EffectHook
{
public:
EffectBase(uint8 _effIndex, uint16 _effName);
std::string ToString();
bool CheckEffect(SpellEntry const * spellEntry, uint8 effIndex);
};
class EffectPeriodicHandler : public EffectBase
{
public:
EffectPeriodicHandler(AuraEffectPeriodicFnType _pEffectHandlerScript,uint8 _effIndex, uint16 _effName);
void Call(AuraScript * auraScript, AuraEffect const * _aurEff, AuraApplication const * _aurApp);
private:
AuraEffectPeriodicFnType pEffectHandlerScript;
};
class EffectUpdatePeriodicHandler : public EffectBase
{
public:
EffectUpdatePeriodicHandler(AuraEffectUpdatePeriodicFnType _pEffectHandlerScript,uint8 _effIndex, uint16 _effName);
void Call(AuraScript * auraScript, AuraEffect * aurEff);
private:
AuraEffectUpdatePeriodicFnType pEffectHandlerScript;
};
class EffectCalcAmountHandler : public EffectBase
{
public:
EffectCalcAmountHandler(AuraEffectCalcAmountFnType _pEffectHandlerScript,uint8 _effIndex, uint16 _effName);
void Call(AuraScript * auraScript, AuraEffect const* aurEff, int32 & amount, bool & canBeRecalculated);
private:
AuraEffectCalcAmountFnType pEffectHandlerScript;
};
class EffectCalcPeriodicHandler : public EffectBase
{
public:
EffectCalcPeriodicHandler(AuraEffectCalcPeriodicFnType _pEffectHandlerScript,uint8 _effIndex, uint16 _effName);
void Call(AuraScript * auraScript, AuraEffect const* aurEff, bool & isPeriodic, int32 & periodicTimer);
private:
AuraEffectCalcPeriodicFnType pEffectHandlerScript;
};
class EffectCalcSpellModHandler : public EffectBase
{
public:
EffectCalcSpellModHandler(AuraEffectCalcSpellModFnType _pEffectHandlerScript,uint8 _effIndex, uint16 _effName);
void Call(AuraScript * auraScript, AuraEffect const* aurEff, SpellModifier *& spellMod);
private:
AuraEffectCalcSpellModFnType pEffectHandlerScript;
};
class EffectApplyHandler : public EffectBase
{
public:
EffectApplyHandler(AuraEffectApplicationModeFnType _pEffectHandlerScript,uint8 _effIndex, uint16 _effName, AuraEffectHandleModes _mode);
void Call(AuraScript * auraScript, AuraEffect const * _aurEff, AuraApplication const * _aurApp, AuraEffectHandleModes _mode);
private:
AuraEffectApplicationModeFnType pEffectHandlerScript;
AuraEffectHandleModes mode;
};
public:
bool _Validate(SpellEntry const * entry, const char * scriptname);
bool _Load(Aura * aura);
void _ResetDefault() { m_default = true; }
bool _IsDefaultActionPrevented(SpellEffIndex effIndex) {return !m_default;};
bool PreventDefaultAction() { m_default = false; };
private:
Aura * m_aura;
bool m_default;
public:
//
// AuraScript interface
// hooks to which you can attach your functions
//
// executed when periodic aura effect is applied with specified mode to target
// example: OnEffectApply += AuraEffectApplyFn(class::function, EffectIndexSpecifier, EffectAuraNameSpecifier, AuraEffectHandleModes);
HookList<EffectApplyHandler> OnEffectApply;
#define AuraEffectApplyFn(F, I, N, M) EffectApplyHandler((AuraEffectApplicationModeFnType)&F, I, N, M)
// executed when periodic aura effect is removed with specified mode from target
// example: OnEffectRemove += AuraEffectRemoveFn(class::function, EffectIndexSpecifier, EffectAuraNameSpecifier, AuraEffectHandleModes);
// where function is: void function (AuraEffect const * aurEff, AuraApplication const * aurApp, AuraEffectHandleModes mode);
HookList<EffectApplyHandler> OnEffectRemove;
#define AuraEffectRemoveFn(F, I, N, M) EffectApplyHandler((AuraEffectApplicationModeFnType)&F, I, N, M)
// executed when periodic aura effect ticks on target
// example: OnEffectPeriodic += AuraEffectPeriodicFn(class::function, EffectIndexSpecifier, EffectAuraNameSpecifier);
// where function is: void function (AuraEffect const * aurEff, AuraApplication const * aurApp, AuraEffectHandleModes mode);
HookList<EffectPeriodicHandler> OnEffectPeriodic;
#define AuraEffectPeriodicFn(F, I, N) EffectPeriodicHandler((AuraEffectPeriodicFnType)&F, I, N)
// executed when periodic aura effect is updated
// example: OnEffectUpdatePeriodic += AuraEffectUpdatePeriodicFn(class::function, EffectIndexSpecifier, EffectAuraNameSpecifier);
// where function is: void function (AuraEffect const * aurEff, AuraApplication const * aurApp);
HookList<EffectUpdatePeriodicHandler> OnEffectUpdatePeriodic;
#define AuraEffectUpdatePeriodicFn(F, I, N) EffectUpdatePeriodicHandler((AuraEffectUpdatePeriodicFnType)&F, I, N)
// executed when aura effect calculates amount
// example: OnEffectCalcAmount += AuraEffectCalcAmounFn(class::function, EffectIndexSpecifier, EffectAuraNameSpecifier);
// where function is: void function (AuraEffect * aurEff, int32 & amount, bool & canBeRecalculated);
HookList<EffectCalcAmountHandler> OnEffectCalcAmount;
#define AuraEffectCalcAmountFn(F, I, N) EffectCalcAmountHandler((AuraEffectCalcAmountFnType)&F, I, N)
// executed when aura effect calculates periodic data
// example: OnEffectCalcPeriodic += AuraEffectCalcPeriodicFn(class::function, EffectIndexSpecifier, EffectAuraNameSpecifier);
// where function is: void function (AuraEffect const * aurEff, bool & isPeriodic, int32 & amplitude);
HookList<EffectCalcPeriodicHandler> OnEffectCalcPeriodic;
#define AuraEffectCalcPeriodicFn(F, I, N) EffectCalcPeriodicHandler((AuraEffectCalcPeriodicFnType)&F, I, N)
// executed when aura effect calculates spellmod
// example: OnEffectCalcSpellMod += AuraEffectCalcSpellModFn(class::function, EffectIndexSpecifier, EffectAuraNameSpecifier);
// where function is: void function (AuraEffect const * aurEff, SpellModifier *& spellMod);
HookList<EffectCalcSpellModHandler> OnEffectCalcSpellMod;
#define AuraEffectCalcSpellModFn(F, I, N) EffectCalcSpellModHandler((AuraEffectCalcSpellModFnType)&F, I, N)
// AuraScript interface - functions which are redirecting to Aura class
// returns proto of the spell
SpellEntry const* GetSpellProto() const;
// returns spellid of the spell
uint32 GetId() const;
// returns guid of object which casted the aura (m_originalCaster of the Spell class)
uint64 const& GetCasterGUID() const;
// returns unit which casted the aura or NULL if not avalible (caster logged out for example)
Unit* GetCaster() const;
// returns object on which aura was casted, target for non-area auras, area aura source for area auras
WorldObject * GetOwner() const;
// returns owner if it's unit, NULL otherwise
Unit * GetUnitOwner() const;
// returns owner if it's dynobj, NULL otherwise
DynamicObject * GetDynobjOwner() const;
// removes aura with remove mode (see AuraRemoveMode enum)
void Remove(uint32 removeMode = 0);
// returns aura object of script
Aura * GetAura() const;
// returns type of the aura, may be dynobj owned aura or unit owned aura
AuraObjectType GetType() const;
// aura duration manipulation - when duration goes to 0 aura is removed
int32 GetDuration() const;
void SetDuration(int32 duration, bool withMods = false);
// sets duration to maxduration
void RefreshDuration();
time_t GetApplyTime() const;
int32 GetMaxDuration() const;
void SetMaxDuration(int32 duration);
// expired - duration just went to 0
bool IsExpired() const;
// permament - has infinite duration
bool IsPermanent() const;
// charges manipulation - 0 - not charged aura
uint8 GetCharges() const;
void SetCharges(uint8 charges);
// returns true if last charge dropped
bool DropCharge();
// stack amount manipulation
uint8 GetStackAmount() const;
void SetStackAmount(uint8 num, bool applied = true);
bool ModStackAmount(int32 num);
// passive - "working in background", not saved, not removed by immonities, not seen by player
bool IsPassive() const;
// death persistent - not removed on death
bool IsDeathPersistent() const;
// check if aura has effect of given effindex
bool HasEffect(uint8 effIndex) const;
// returns aura effect of given effect index or NULL
AuraEffect * GetEffect(uint8 effIndex) const;
// check if aura has effect of given aura type
bool HasEffectType(AuraType type) const;
};
//
// definitions: