Scripts/Examples: Corrected code style in spell script examples
This commit is contained in:
@@ -20,7 +20,7 @@
|
||||
#include "SpellAuras.h"
|
||||
#include "SpellScript.h"
|
||||
|
||||
bool _SpellScript::_Validate(SpellEntry const * entry)
|
||||
bool _SpellScript::_Validate(SpellEntry const* entry)
|
||||
{
|
||||
if (!Validate(entry))
|
||||
{
|
||||
@@ -44,7 +44,7 @@ void _SpellScript::_Unload()
|
||||
m_currentScriptState = SPELL_SCRIPT_STATE_NONE;
|
||||
}
|
||||
|
||||
void _SpellScript::_Init(const std::string * scriptname, uint32 spellId)
|
||||
void _SpellScript::_Init(std::string const* scriptname, uint32 spellId)
|
||||
{
|
||||
m_currentScriptState = SPELL_SCRIPT_STATE_NONE;
|
||||
m_scriptName = scriptname;
|
||||
@@ -58,7 +58,7 @@ _SpellScript::EffectHook::EffectHook(uint8 _effIndex)
|
||||
effIndex = _effIndex;
|
||||
}
|
||||
|
||||
uint8 _SpellScript::EffectHook::GetAffectedEffectsMask(SpellEntry const * spellEntry)
|
||||
uint8 _SpellScript::EffectHook::GetAffectedEffectsMask(SpellEntry const* spellEntry)
|
||||
{
|
||||
uint8 mask = 0;
|
||||
if ((effIndex == EFFECT_ALL) || (effIndex == EFFECT_FIRST_FOUND))
|
||||
@@ -79,7 +79,7 @@ uint8 _SpellScript::EffectHook::GetAffectedEffectsMask(SpellEntry const * spellE
|
||||
return mask;
|
||||
}
|
||||
|
||||
bool _SpellScript::EffectHook::IsEffectAffected(SpellEntry const * spellEntry, uint8 effIndex)
|
||||
bool _SpellScript::EffectHook::IsEffectAffected(SpellEntry const* spellEntry, uint8 effIndex)
|
||||
{
|
||||
return GetAffectedEffectsMask(spellEntry) & 1<<effIndex;
|
||||
}
|
||||
@@ -102,7 +102,7 @@ std::string _SpellScript::EffectHook::EffIndexToString()
|
||||
return "Invalid Value";
|
||||
}
|
||||
|
||||
bool _SpellScript::EffectNameCheck::Check(SpellEntry const * spellEntry, uint8 effIndex)
|
||||
bool _SpellScript::EffectNameCheck::Check(SpellEntry const* spellEntry, uint8 effIndex)
|
||||
{
|
||||
if (!spellEntry->Effect[effIndex] && !effName)
|
||||
return true;
|
||||
@@ -124,7 +124,7 @@ std::string _SpellScript::EffectNameCheck::ToString()
|
||||
}
|
||||
}
|
||||
|
||||
bool _SpellScript::EffectAuraNameCheck::Check(SpellEntry const * spellEntry, uint8 effIndex)
|
||||
bool _SpellScript::EffectAuraNameCheck::Check(SpellEntry const* spellEntry, uint8 effIndex)
|
||||
{
|
||||
if (!spellEntry->EffectApplyAuraName[effIndex] && !effAurName)
|
||||
return true;
|
||||
@@ -167,12 +167,12 @@ std::string SpellScript::EffectHandler::ToString()
|
||||
return "Index: " + EffIndexToString() + " Name: " +_SpellScript::EffectNameCheck::ToString();
|
||||
}
|
||||
|
||||
bool SpellScript::EffectHandler::CheckEffect(SpellEntry const * spellEntry, uint8 effIndex)
|
||||
bool SpellScript::EffectHandler::CheckEffect(SpellEntry const* spellEntry, uint8 effIndex)
|
||||
{
|
||||
return _SpellScript::EffectNameCheck::Check(spellEntry, effIndex);
|
||||
}
|
||||
|
||||
void SpellScript::EffectHandler::Call(SpellScript * spellScript, SpellEffIndex effIndex)
|
||||
void SpellScript::EffectHandler::Call(SpellScript* spellScript, SpellEffIndex effIndex)
|
||||
{
|
||||
(spellScript->*pEffectHandlerScript)(effIndex);
|
||||
}
|
||||
@@ -182,7 +182,7 @@ SpellScript::HitHandler::HitHandler(SpellHitFnType _pHitHandlerScript)
|
||||
pHitHandlerScript = _pHitHandlerScript;
|
||||
}
|
||||
|
||||
void SpellScript::HitHandler::Call(SpellScript * spellScript)
|
||||
void SpellScript::HitHandler::Call(SpellScript* spellScript)
|
||||
{
|
||||
(spellScript->*pHitHandlerScript)();
|
||||
}
|
||||
@@ -200,14 +200,14 @@ std::string SpellScript::UnitTargetHandler::ToString()
|
||||
return oss.str();
|
||||
}
|
||||
|
||||
bool SpellScript::UnitTargetHandler::CheckEffect(SpellEntry const * spellEntry, uint8 effIndex)
|
||||
bool SpellScript::UnitTargetHandler::CheckEffect(SpellEntry const* spellEntry, uint8 effIndex)
|
||||
{
|
||||
if (!targetType)
|
||||
return false;
|
||||
return (effIndex == SPELL_EFFECT_ANY) || (spellEntry->EffectImplicitTargetA[effIndex] == targetType || spellEntry->EffectImplicitTargetB[effIndex] == targetType);
|
||||
}
|
||||
|
||||
void SpellScript::UnitTargetHandler::Call(SpellScript * spellScript, std::list<Unit*>& unitTargets)
|
||||
void SpellScript::UnitTargetHandler::Call(SpellScript* spellScript, std::list<Unit*>& unitTargets)
|
||||
{
|
||||
(spellScript->*pUnitTargetHandlerScript)(unitTargets);
|
||||
}
|
||||
@@ -225,7 +225,7 @@ bool SpellScript::_Validate(SpellEntry const * entry)
|
||||
return _SpellScript::_Validate(entry);
|
||||
}
|
||||
|
||||
bool SpellScript::_Load(Spell * spell)
|
||||
bool SpellScript::_Load(Spell* spell)
|
||||
{
|
||||
m_currentScriptState = SPELL_SCRIPT_STATE_LOADING;
|
||||
m_spell = spell;
|
||||
@@ -250,44 +250,44 @@ void SpellScript::_FinishScriptCall()
|
||||
m_currentScriptState = SPELL_SCRIPT_STATE_NONE;
|
||||
}
|
||||
|
||||
Unit * SpellScript::GetCaster()
|
||||
Unit* SpellScript::GetCaster()
|
||||
{
|
||||
return m_spell->GetCaster();
|
||||
}
|
||||
|
||||
Unit * SpellScript::GetOriginalCaster()
|
||||
Unit* SpellScript::GetOriginalCaster()
|
||||
{
|
||||
return m_spell->GetOriginalCaster();
|
||||
}
|
||||
|
||||
SpellEntry const * SpellScript::GetSpellInfo()
|
||||
SpellEntry const* SpellScript::GetSpellInfo()
|
||||
{
|
||||
return m_spell->GetSpellInfo();
|
||||
}
|
||||
|
||||
WorldLocation * SpellScript::GetTargetDest()
|
||||
WorldLocation* SpellScript::GetTargetDest()
|
||||
{
|
||||
if (m_spell->m_targets.HasDst())
|
||||
return &m_spell->m_targets.m_dstPos;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Unit * SpellScript::GetTargetUnit()
|
||||
Unit* SpellScript::GetTargetUnit()
|
||||
{
|
||||
return m_spell->m_targets.getUnitTarget();
|
||||
}
|
||||
|
||||
GameObject * SpellScript::GetTargetGObj()
|
||||
GameObject* SpellScript::GetTargetGObj()
|
||||
{
|
||||
return m_spell->m_targets.getGOTarget();
|
||||
}
|
||||
|
||||
Item * SpellScript::GetTargetItem()
|
||||
Item* SpellScript::GetTargetItem()
|
||||
{
|
||||
return m_spell->m_targets.getItemTarget();
|
||||
}
|
||||
|
||||
Unit * SpellScript::GetHitUnit()
|
||||
Unit* SpellScript::GetHitUnit()
|
||||
{
|
||||
if (!IsInHitPhase())
|
||||
{
|
||||
@@ -297,7 +297,7 @@ Unit * SpellScript::GetHitUnit()
|
||||
return m_spell->unitTarget;
|
||||
}
|
||||
|
||||
Creature * SpellScript::GetHitCreature()
|
||||
Creature* SpellScript::GetHitCreature()
|
||||
{
|
||||
if (!IsInHitPhase())
|
||||
{
|
||||
@@ -310,7 +310,7 @@ Creature * SpellScript::GetHitCreature()
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Player * SpellScript::GetHitPlayer()
|
||||
Player* SpellScript::GetHitPlayer()
|
||||
{
|
||||
if (!IsInHitPhase())
|
||||
{
|
||||
@@ -323,7 +323,7 @@ Player * SpellScript::GetHitPlayer()
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Item * SpellScript::GetHitItem()
|
||||
Item* SpellScript::GetHitItem()
|
||||
{
|
||||
if (!IsInHitPhase())
|
||||
{
|
||||
@@ -333,7 +333,7 @@ Item * SpellScript::GetHitItem()
|
||||
return m_spell->itemTarget;
|
||||
}
|
||||
|
||||
GameObject * SpellScript::GetHitGObj()
|
||||
GameObject* SpellScript::GetHitGObj()
|
||||
{
|
||||
if (!IsInHitPhase())
|
||||
{
|
||||
@@ -439,7 +439,7 @@ int32 SpellScript::GetEffectValue()
|
||||
return m_spell->damage;
|
||||
}
|
||||
|
||||
Item * SpellScript::GetCastItem()
|
||||
Item* SpellScript::GetCastItem()
|
||||
{
|
||||
return m_spell->m_CastItem;
|
||||
}
|
||||
@@ -520,7 +520,7 @@ AuraScript::EffectBase::EffectBase(uint8 _effIndex, uint16 _effName)
|
||||
{
|
||||
}
|
||||
|
||||
bool AuraScript::EffectBase::CheckEffect(SpellEntry const * spellEntry, uint8 effIndex)
|
||||
bool AuraScript::EffectBase::CheckEffect(SpellEntry const* spellEntry, uint8 effIndex)
|
||||
{
|
||||
return _SpellScript::EffectAuraNameCheck::Check(spellEntry, effIndex);
|
||||
}
|
||||
@@ -536,7 +536,7 @@ AuraScript::EffectPeriodicHandler::EffectPeriodicHandler(AuraEffectPeriodicFnTyp
|
||||
pEffectHandlerScript = _pEffectHandlerScript;
|
||||
}
|
||||
|
||||
void AuraScript::EffectPeriodicHandler::Call(AuraScript * auraScript, AuraEffect const * _aurEff)
|
||||
void AuraScript::EffectPeriodicHandler::Call(AuraScript* auraScript, AuraEffect const* _aurEff)
|
||||
{
|
||||
(auraScript->*pEffectHandlerScript)(_aurEff);
|
||||
}
|
||||
@@ -547,7 +547,7 @@ AuraScript::EffectUpdatePeriodicHandler::EffectUpdatePeriodicHandler(AuraEffectU
|
||||
pEffectHandlerScript = _pEffectHandlerScript;
|
||||
}
|
||||
|
||||
void AuraScript::EffectUpdatePeriodicHandler::Call(AuraScript * auraScript, AuraEffect * aurEff)
|
||||
void AuraScript::EffectUpdatePeriodicHandler::Call(AuraScript* auraScript, AuraEffect* aurEff)
|
||||
{
|
||||
(auraScript->*pEffectHandlerScript)(aurEff);
|
||||
}
|
||||
@@ -558,41 +558,41 @@ AuraScript::EffectCalcAmountHandler::EffectCalcAmountHandler(AuraEffectCalcAmoun
|
||||
pEffectHandlerScript = _pEffectHandlerScript;
|
||||
}
|
||||
|
||||
void AuraScript::EffectCalcAmountHandler::Call(AuraScript * auraScript, AuraEffect const * aurEff, int32 & amount, bool & canBeRecalculated)
|
||||
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::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)
|
||||
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::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)
|
||||
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::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, AuraEffectHandleModes _mode)
|
||||
void AuraScript::EffectApplyHandler::Call(AuraScript* auraScript, AuraEffect const * _aurEff, AuraEffectHandleModes _mode)
|
||||
{
|
||||
if (_mode & mode)
|
||||
(auraScript->*pEffectHandlerScript)(_aurEff, _mode);
|
||||
@@ -604,23 +604,23 @@ AuraScript::EffectAbsorbHandler::EffectAbsorbHandler(AuraEffectAbsorbFnType _pEf
|
||||
pEffectHandlerScript = _pEffectHandlerScript;
|
||||
}
|
||||
|
||||
void AuraScript::EffectAbsorbHandler::Call(AuraScript * auraScript, AuraEffect * aurEff, DamageInfo & dmgInfo, uint32 & absorbAmount)
|
||||
void AuraScript::EffectAbsorbHandler::Call(AuraScript* auraScript, AuraEffect* aurEff, DamageInfo& dmgInfo, uint32& absorbAmount)
|
||||
{
|
||||
(auraScript->*pEffectHandlerScript)(aurEff, dmgInfo, absorbAmount);
|
||||
}
|
||||
|
||||
AuraScript::EffectManaShieldHandler::EffectManaShieldHandler(AuraEffectAbsorbFnType _pEffectHandlerScript,uint8 _effIndex)
|
||||
AuraScript::EffectManaShieldHandler::EffectManaShieldHandler(AuraEffectAbsorbFnType _pEffectHandlerScript, uint8 _effIndex)
|
||||
: AuraScript::EffectBase(_effIndex, SPELL_AURA_MANA_SHIELD)
|
||||
{
|
||||
pEffectHandlerScript = _pEffectHandlerScript;
|
||||
}
|
||||
|
||||
void AuraScript::EffectManaShieldHandler::Call(AuraScript * auraScript, AuraEffect * aurEff, DamageInfo & dmgInfo, uint32 & absorbAmount)
|
||||
void AuraScript::EffectManaShieldHandler::Call(AuraScript* auraScript, AuraEffect* aurEff, DamageInfo& dmgInfo, uint32& absorbAmount)
|
||||
{
|
||||
(auraScript->*pEffectHandlerScript)(aurEff, dmgInfo, absorbAmount);
|
||||
}
|
||||
|
||||
bool AuraScript::_Load(Aura * aura)
|
||||
bool AuraScript::_Load(Aura* aura)
|
||||
{
|
||||
m_currentScriptState = SPELL_SCRIPT_STATE_LOADING;
|
||||
m_aura = aura;
|
||||
@@ -629,7 +629,7 @@ bool AuraScript::_Load(Aura * aura)
|
||||
return load;
|
||||
}
|
||||
|
||||
void AuraScript::_PrepareScriptCall(AuraScriptHookType hookType, AuraApplication const * aurApp)
|
||||
void AuraScript::_PrepareScriptCall(AuraScriptHookType hookType, AuraApplication const* aurApp)
|
||||
{
|
||||
m_currentScriptState = hookType;
|
||||
switch (m_currentScriptState)
|
||||
@@ -828,12 +828,12 @@ bool AuraScript::HasEffectType(AuraType type) const
|
||||
return m_aura->HasEffectType(type);
|
||||
}
|
||||
|
||||
Unit * AuraScript::GetTarget() const
|
||||
Unit* AuraScript::GetTarget() const
|
||||
{
|
||||
return m_auraApplication->GetTarget();
|
||||
}
|
||||
|
||||
AuraApplication const * AuraScript::GetTargetApplication() const
|
||||
AuraApplication const* AuraScript::GetTargetApplication() const
|
||||
{
|
||||
return m_auraApplication;
|
||||
}
|
||||
|
||||
@@ -55,45 +55,49 @@ class _SpellScript
|
||||
// internal use classes & functions
|
||||
// DO NOT OVERRIDE THESE IN SCRIPTS
|
||||
protected:
|
||||
virtual bool _Validate(SpellEntry const * entry);
|
||||
virtual bool _Validate(SpellEntry const* entry);
|
||||
|
||||
public:
|
||||
virtual ~_SpellScript() {}
|
||||
virtual void _Register();
|
||||
virtual void _Unload();
|
||||
virtual void _Init(const std::string * scriptname, uint32 spellId);
|
||||
virtual void _Init(std::string const* scriptname, uint32 spellId);
|
||||
|
||||
protected:
|
||||
class EffectHook
|
||||
{
|
||||
public:
|
||||
EffectHook(uint8 _effIndex);
|
||||
uint8 GetAffectedEffectsMask(SpellEntry const * spellEntry);
|
||||
bool IsEffectAffected(SpellEntry const * spellEntry, uint8 effIndex);
|
||||
virtual bool CheckEffect(SpellEntry const * spellEntry, uint8 effIndex) = 0;
|
||||
uint8 GetAffectedEffectsMask(SpellEntry const* spellEntry);
|
||||
bool IsEffectAffected(SpellEntry const* spellEntry, uint8 effIndex);
|
||||
virtual bool CheckEffect(SpellEntry const* spellEntry, uint8 effIndex) = 0;
|
||||
std::string EffIndexToString();
|
||||
protected:
|
||||
uint8 effIndex;
|
||||
};
|
||||
|
||||
class EffectNameCheck
|
||||
{
|
||||
public:
|
||||
EffectNameCheck(uint16 _effName) {effName = _effName;};
|
||||
bool Check(SpellEntry const * spellEntry, uint8 effIndex);
|
||||
bool Check(SpellEntry const* spellEntry, uint8 effIndex);
|
||||
std::string ToString();
|
||||
private:
|
||||
uint16 effName;
|
||||
};
|
||||
|
||||
class EffectAuraNameCheck
|
||||
{
|
||||
public:
|
||||
EffectAuraNameCheck(uint16 _effAurName) { effAurName = _effAurName; }
|
||||
bool Check(SpellEntry const * spellEntry, uint8 effIndex);
|
||||
bool Check(SpellEntry const* spellEntry, uint8 effIndex);
|
||||
std::string ToString();
|
||||
private:
|
||||
uint16 effAurName;
|
||||
};
|
||||
|
||||
uint8 m_currentScriptState;
|
||||
const std::string * m_scriptName;
|
||||
std::string const* m_scriptName;
|
||||
uint32 m_scriptSpellId;
|
||||
public:
|
||||
//
|
||||
@@ -104,13 +108,13 @@ class _SpellScript
|
||||
virtual void Register() = 0;
|
||||
// Function called on server startup, if returns false script won't be used in core
|
||||
// use for: dbc/template data presence/correctness checks
|
||||
virtual bool Validate(SpellEntry const * /*spellEntry*/) {return true;};
|
||||
virtual bool Validate(SpellEntry const* /*spellEntry*/) { return true; }
|
||||
// Function called when script is created, if returns false script will be unloaded afterwards
|
||||
// use for: initializing local script variables (DO NOT USE CONSTRUCTOR FOR THIS PURPOSE!)
|
||||
virtual bool Load() {return true;};
|
||||
virtual bool Load() { return true; }
|
||||
// Function called when script is destroyed
|
||||
// use for: deallocating memory allocated by script
|
||||
virtual void Unload() {};
|
||||
virtual void Unload() {}
|
||||
};
|
||||
|
||||
// SpellScript interface - enum used for runtime checks of script function calls
|
||||
@@ -123,6 +127,7 @@ enum SpellScriptHookType
|
||||
SPELL_SCRIPT_HOOK_UNIT_TARGET_SELECT,
|
||||
SPELL_SCRIPT_HOOK_CHECK_CAST,
|
||||
};
|
||||
|
||||
#define HOOK_SPELL_HIT_START SPELL_SCRIPT_HOOK_EFFECT
|
||||
#define HOOK_SPELL_HIT_END SPELL_SCRIPT_HOOK_AFTER_HIT + 1
|
||||
#define HOOK_SPELL_START SPELL_SCRIPT_HOOK_EFFECT
|
||||
@@ -156,8 +161,8 @@ class SpellScript : public _SpellScript
|
||||
public:
|
||||
EffectHandler(SpellEffectFnType _pEffectHandlerScript,uint8 _effIndex, uint16 _effName);
|
||||
std::string ToString();
|
||||
bool CheckEffect(SpellEntry const * spellEntry, uint8 effIndex);
|
||||
void Call(SpellScript * spellScript, SpellEffIndex effIndex);
|
||||
bool CheckEffect(SpellEntry const* spellEntry, uint8 effIndex);
|
||||
void Call(SpellScript* spellScript, SpellEffIndex effIndex);
|
||||
private:
|
||||
SpellEffectFnType pEffectHandlerScript;
|
||||
};
|
||||
@@ -166,7 +171,7 @@ class SpellScript : public _SpellScript
|
||||
{
|
||||
public:
|
||||
HitHandler(SpellHitFnType _pHitHandlerScript);
|
||||
void Call(SpellScript * spellScript);
|
||||
void Call(SpellScript* spellScript);
|
||||
private:
|
||||
SpellHitFnType pHitHandlerScript;
|
||||
};
|
||||
@@ -176,8 +181,8 @@ class SpellScript : public _SpellScript
|
||||
public:
|
||||
UnitTargetHandler(SpellUnitTargetFnType _pUnitTargetHandlerScript, uint8 _effIndex, uint16 _targetType);
|
||||
std::string ToString();
|
||||
bool CheckEffect(SpellEntry const * spellEntry, uint8 targetType);
|
||||
void Call(SpellScript * spellScript, std::list<Unit*>& unitTargets);
|
||||
bool CheckEffect(SpellEntry const* spellEntry, uint8 targetType);
|
||||
void Call(SpellScript* spellScript, std::list<Unit*>& unitTargets);
|
||||
private:
|
||||
SpellUnitTargetFnType pUnitTargetHandlerScript;
|
||||
uint16 targetType;
|
||||
@@ -191,8 +196,8 @@ class SpellScript : public _SpellScript
|
||||
|
||||
#define PrepareSpellScript(CLASSNAME) SPELLSCRIPT_FUNCTION_TYPE_DEFINES(CLASSNAME) SPELLSCRIPT_FUNCTION_CAST_DEFINES(CLASSNAME)
|
||||
public:
|
||||
bool _Validate(SpellEntry const * entry);
|
||||
bool _Load(Spell * spell);
|
||||
bool _Validate(SpellEntry const* entry);
|
||||
bool _Load(Spell* spell);
|
||||
void _InitHit();
|
||||
bool _IsEffectPrevented(SpellEffIndex effIndex) { return m_hitPreventEffectMask & (1<<effIndex); }
|
||||
bool _IsDefaultEffectPrevented(SpellEffIndex effIndex) { return m_hitPreventDefaultEffectMask & (1<<effIndex); }
|
||||
@@ -202,7 +207,7 @@ class SpellScript : public _SpellScript
|
||||
bool IsInHitPhase() const { return (m_currentScriptState >= HOOK_SPELL_HIT_START && m_currentScriptState < HOOK_SPELL_HIT_END); }
|
||||
bool IsInEffectHook() const { return (m_currentScriptState == SPELL_SCRIPT_HOOK_EFFECT); }
|
||||
private:
|
||||
Spell * m_spell;
|
||||
Spell* m_spell;
|
||||
uint8 m_hitPreventEffectMask;
|
||||
uint8 m_hitPreventDefaultEffectMask;
|
||||
public:
|
||||
@@ -246,48 +251,48 @@ class SpellScript : public _SpellScript
|
||||
// methods allowing interaction with Spell object
|
||||
//
|
||||
// methods useable during all spell handling phases
|
||||
Unit * GetCaster();
|
||||
Unit * GetOriginalCaster();
|
||||
SpellEntry const * GetSpellInfo();
|
||||
Unit* GetCaster();
|
||||
Unit* GetOriginalCaster();
|
||||
SpellEntry const* GetSpellInfo();
|
||||
|
||||
// methods useable after spell targets are set
|
||||
// accessors to the "focus" targets of the spell
|
||||
// note: do not confuse these with spell hit targets
|
||||
// returns: WorldLocation which was selected as a spell destination or NULL
|
||||
WorldLocation * GetTargetDest();
|
||||
WorldLocation* GetTargetDest();
|
||||
|
||||
// returns: Unit which was selected as a spell target or NULL
|
||||
Unit * GetTargetUnit();
|
||||
Unit* GetTargetUnit();
|
||||
|
||||
// returns: GameObject which was selected as a spell target or NULL
|
||||
GameObject * GetTargetGObj();
|
||||
GameObject* GetTargetGObj();
|
||||
|
||||
// returns: Item which was selected as a spell target or NULL
|
||||
Item * GetTargetItem();
|
||||
Item* GetTargetItem();
|
||||
|
||||
// methods useable only during spell hit on target phase:
|
||||
|
||||
// returns: target of current effect if it was Unit otherwise NULL
|
||||
Unit * GetHitUnit();
|
||||
Unit* GetHitUnit();
|
||||
// returns: target of current effect if it was Creature otherwise NULL
|
||||
Creature * GetHitCreature();
|
||||
Creature* GetHitCreature();
|
||||
// returns: target of current effect if it was Player otherwise NULL
|
||||
Player * GetHitPlayer();
|
||||
Player* GetHitPlayer();
|
||||
// returns: target of current effect if it was Item otherwise NULL
|
||||
Item * GetHitItem();
|
||||
// returns: target of current effect if it was GameObject otherwise NULL
|
||||
GameObject * GetHitGObj();
|
||||
GameObject* GetHitGObj();
|
||||
// setter/getter for for damage done by spell to target of spell hit
|
||||
int32 GetHitDamage();
|
||||
void SetHitDamage(int32 damage);
|
||||
void PreventHitDamage() { SetHitDamage(0); };
|
||||
void PreventHitDamage() { SetHitDamage(0); }
|
||||
// setter/getter for for heal done by spell to target of spell hit
|
||||
int32 GetHitHeal();
|
||||
void SetHitHeal(int32 heal);
|
||||
void PreventHitHeal() { SetHitHeal(0); };
|
||||
void PreventHitHeal() { SetHitHeal(0); }
|
||||
|
||||
// returns current spell hit target aura
|
||||
Aura * GetHitAura();
|
||||
Aura* GetHitAura();
|
||||
// prevents applying aura on current spell hit target
|
||||
void PreventHitAura();
|
||||
|
||||
@@ -306,7 +311,7 @@ class SpellScript : public _SpellScript
|
||||
int32 GetEffectValue();
|
||||
|
||||
// returns: cast item if present.
|
||||
Item * GetCastItem();
|
||||
Item* GetCastItem();
|
||||
|
||||
// Creates item. Calls Spell::DoCreateItem method.
|
||||
void CreateItem(uint32 effIndex, uint32 itemId);
|
||||
|
||||
@@ -26,6 +26,11 @@
|
||||
#include "SpellAuras.h"
|
||||
#include "SpellAuraEffects.h"
|
||||
|
||||
enum Spells
|
||||
{
|
||||
SPELL_TRIGGERED = 18282
|
||||
};
|
||||
|
||||
class spell_ex_5581 : public SpellScriptLoader
|
||||
{
|
||||
public:
|
||||
@@ -36,18 +41,14 @@ class spell_ex_5581 : public SpellScriptLoader
|
||||
// initialize script, this macro does compile time check for type of the function - prevents possible issues
|
||||
// if you have assigned wrong type of function to a hook you'll receive type conversion error during build
|
||||
// this line is required, otherwise you'll get XXXHandlerFunction - identifier not found errors
|
||||
PrepareSpellScript(spell_ex_5581SpellScript)
|
||||
enum Spells
|
||||
{
|
||||
SPELL_TRIGGERED = 18282
|
||||
};
|
||||
PrepareSpellScript(spell_ex_5581SpellScript);
|
||||
|
||||
std::string localVariable;
|
||||
char * localVariable2;
|
||||
char* localVariable2;
|
||||
|
||||
// function called on server startup
|
||||
// checks if script has data required for it to work
|
||||
bool Validate(SpellEntry const * /*spellEntry*/)
|
||||
bool Validate(SpellEntry const* /*spellEntry*/)
|
||||
{
|
||||
// check if spellid 70522 exists in dbc, we will trigger it later
|
||||
if (!sSpellStore.LookupEntry(SPELL_TRIGGERED))
|
||||
@@ -60,7 +61,7 @@ class spell_ex_5581 : public SpellScriptLoader
|
||||
bool Load()
|
||||
{
|
||||
localVariable = "we're using local variable";
|
||||
localVariable2 = new char;
|
||||
localVariable2 = new char();
|
||||
return true;
|
||||
// return false - script will be immediately removed from the spell
|
||||
// for example - we don't want this script to be executed on a creature
|
||||
@@ -80,7 +81,7 @@ class spell_ex_5581 : public SpellScriptLoader
|
||||
// we're handling SPELL_EFFECT_DUMMY in effIndex 0 here
|
||||
sLog->outString("SPELL_EFFECT_DUMMY is executed on target!");
|
||||
// make caster cast a spell on a unit target of effect
|
||||
if (Unit * target = GetHitUnit())
|
||||
if (Unit* target = GetHitUnit())
|
||||
GetCaster()->CastSpell(target, SPELL_TRIGGERED, true);
|
||||
}
|
||||
|
||||
@@ -130,7 +131,7 @@ class spell_ex_5581 : public SpellScriptLoader
|
||||
};
|
||||
|
||||
// function which creates SpellScript
|
||||
SpellScript *GetSpellScript() const
|
||||
SpellScript* GetSpellScript() const
|
||||
{
|
||||
return new spell_ex_5581SpellScript();
|
||||
}
|
||||
@@ -143,14 +144,10 @@ class spell_ex_66244 : public SpellScriptLoader
|
||||
|
||||
class spell_ex_66244AuraScript : public AuraScript
|
||||
{
|
||||
PrepareAuraScript(spell_ex_66244AuraScript)
|
||||
enum Spells
|
||||
{
|
||||
SPELL_TRIGGERED = 18282
|
||||
};
|
||||
PrepareAuraScript(spell_ex_66244AuraScript);
|
||||
// function called on server startup
|
||||
// checks if script has data required for it to work
|
||||
bool Validate(SpellEntry const * /*spellEntry*/)
|
||||
bool Validate(SpellEntry const* /*spellEntry*/)
|
||||
{
|
||||
// check if spellid exists in dbc, we will trigger it later
|
||||
if (!sSpellStore.LookupEntry(SPELL_TRIGGERED))
|
||||
@@ -163,25 +160,25 @@ class spell_ex_66244 : public SpellScriptLoader
|
||||
bool Load()
|
||||
{
|
||||
// do not load script if aura is casted by player or caster not avalible
|
||||
if (Unit * caster = GetCaster())
|
||||
if (Unit* caster = GetCaster())
|
||||
if (caster->GetTypeId() == TYPEID_PLAYER)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
void HandleEffectApply(AuraEffect const * /*aurEff*/, AuraEffectHandleModes /*mode*/)
|
||||
void HandleEffectApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
|
||||
{
|
||||
sLog->outString("Aura Effect is about to be applied on target!");
|
||||
Unit * target = GetTarget();
|
||||
Unit* target = GetTarget();
|
||||
// cast spell on target on aura apply
|
||||
target->CastSpell(target, SPELL_TRIGGERED, true);
|
||||
}
|
||||
|
||||
void HandleEffectRemove(AuraEffect const * /*aurEff*/, AuraEffectHandleModes /*mode*/)
|
||||
void HandleEffectRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
|
||||
{
|
||||
sLog->outString("Aura Effect is just removed on target!");
|
||||
Unit * target = GetTarget();
|
||||
Unit * caster = GetCaster();
|
||||
Unit* target = GetTarget();
|
||||
Unit* caster = GetCaster();
|
||||
// caster may be not avalible (logged out for example)
|
||||
if (!caster)
|
||||
return;
|
||||
@@ -189,22 +186,22 @@ class spell_ex_66244 : public SpellScriptLoader
|
||||
target->CastSpell(caster, SPELL_TRIGGERED, true);
|
||||
}
|
||||
|
||||
void HandleEffectPeriodic(AuraEffect const * /*aurEff*/)
|
||||
void HandleEffectPeriodic(AuraEffect const* /*aurEff*/)
|
||||
{
|
||||
sLog->outString("Perioidic Aura Effect is does a tick on target!");
|
||||
Unit * target = GetTarget();
|
||||
Unit* target = GetTarget();
|
||||
// aura targets damage self on tick
|
||||
target->DealDamage(target, 100);
|
||||
}
|
||||
|
||||
void HandleEffectPeriodicUpdate(AuraEffect * aurEff)
|
||||
void HandleEffectPeriodicUpdate(AuraEffect* aurEff)
|
||||
{
|
||||
sLog->outString("Perioidic Aura Effect is now updated!");
|
||||
// we're doubling aura amount every tick
|
||||
aurEff->ChangeAmount(aurEff->GetAmount() * 2);
|
||||
}
|
||||
|
||||
void HandleEffectCalcAmount(AuraEffect const * /*aurEff*/, int32 & amount, bool & canBeRecalculated)
|
||||
void HandleEffectCalcAmount(AuraEffect const* /*aurEff*/, int32& amount, bool& canBeRecalculated)
|
||||
{
|
||||
sLog->outString("Amount of Aura Effect is being calculated now!");
|
||||
// we're setting amount to 100
|
||||
@@ -213,7 +210,7 @@ class spell_ex_66244 : public SpellScriptLoader
|
||||
canBeRecalculated = false;
|
||||
}
|
||||
|
||||
void HandleEffectCalcPeriodic(AuraEffect const * /*aurEff*/, bool & isPeriodic, int32 & amplitude)
|
||||
void HandleEffectCalcPeriodic(AuraEffect const* /*aurEff*/, bool& isPeriodic, int32& amplitude)
|
||||
{
|
||||
sLog->outString("Periodic data of Aura Effect is being calculated now!");
|
||||
// we're setting aura to be periodic and tick every 10 seconds
|
||||
@@ -221,11 +218,11 @@ class spell_ex_66244 : public SpellScriptLoader
|
||||
amplitude = 2 * IN_MILLISECONDS;
|
||||
}
|
||||
|
||||
void HandleEffectCalcSpellMod(AuraEffect const * /*aurEff*/, SpellModifier *& spellMod)
|
||||
void HandleEffectCalcSpellMod(AuraEffect const* /*aurEff*/, SpellModifier*& spellMod)
|
||||
{
|
||||
sLog->outString("SpellMod data of Aura Effect is being calculated now!");
|
||||
// we don't want spellmod for example
|
||||
if(spellMod)
|
||||
if (spellMod)
|
||||
{
|
||||
delete spellMod;
|
||||
spellMod = NULL;
|
||||
@@ -272,7 +269,7 @@ class spell_ex_66244 : public SpellScriptLoader
|
||||
};
|
||||
|
||||
// function which creates AuraScript
|
||||
AuraScript *GetAuraScript() const
|
||||
AuraScript* GetAuraScript() const
|
||||
{
|
||||
return new spell_ex_66244AuraScript();
|
||||
}
|
||||
@@ -286,20 +283,16 @@ class spell_ex_absorb_aura : public SpellScriptLoader
|
||||
|
||||
class spell_ex_absorb_auraAuraScript : public AuraScript
|
||||
{
|
||||
PrepareAuraScript(spell_ex_absorb_auraAuraScript)
|
||||
enum Spells
|
||||
{
|
||||
SPELL_TRIGGERED = 18282
|
||||
};
|
||||
PrepareAuraScript(spell_ex_absorb_auraAuraScript);
|
||||
|
||||
void HandleOnEffectAbsorb(AuraEffect * /*aurEff*/, DamageInfo & dmgInfo, uint32 & absorbAmount)
|
||||
void HandleOnEffectAbsorb(AuraEffect* /*aurEff*/, DamageInfo & dmgInfo, uint32 & absorbAmount)
|
||||
{
|
||||
sLog->outString("Our aura is now absorbing damage done to us!");
|
||||
// absorb whole damage done to us
|
||||
absorbAmount = dmgInfo.GetDamage();
|
||||
}
|
||||
|
||||
void HandleAfterEffectAbsorb(AuraEffect * /*aurEff*/, DamageInfo & /*dmgInfo*/, uint32 & absorbAmount)
|
||||
void HandleAfterEffectAbsorb(AuraEffect* /*aurEff*/, DamageInfo & /*dmgInfo*/, uint32 & absorbAmount)
|
||||
{
|
||||
sLog->outString("Our aura has absorbed %u damage!", absorbAmount);
|
||||
}
|
||||
@@ -313,7 +306,7 @@ class spell_ex_absorb_aura : public SpellScriptLoader
|
||||
};
|
||||
|
||||
// function which creates AuraScript
|
||||
AuraScript *GetAuraScript() const
|
||||
AuraScript* GetAuraScript() const
|
||||
{
|
||||
return new spell_ex_absorb_auraAuraScript();
|
||||
}
|
||||
@@ -338,7 +331,8 @@ class spell_ex : public SpellScriptLoader
|
||||
|
||||
class spell_ex_SpellScript : public SpellScript
|
||||
{
|
||||
PrepareSpellScript(spell_ex_SpellScript)
|
||||
PrepareSpellScript(spell_ex_SpellScript);
|
||||
|
||||
//bool Validate(SpellEntry const * spellEntry){return true;}
|
||||
//bool Load(){return true;}
|
||||
//void Unload(){}
|
||||
@@ -350,7 +344,7 @@ class spell_ex : public SpellScriptLoader
|
||||
}
|
||||
};
|
||||
|
||||
SpellScript *GetSpellScript() const
|
||||
SpellScript* GetSpellScript() const
|
||||
{
|
||||
return new spell_ex_SpellScript();
|
||||
}
|
||||
@@ -366,23 +360,23 @@ class spell_ex : public SpellScriptLoader
|
||||
class spell_ex_AuraScript : public AuraScript
|
||||
{
|
||||
PrepareAuraScript(spell_ex)
|
||||
//bool Validate(SpellEntry const * spellEntry){return true;}
|
||||
//bool Validate(SpellEntry const* spellEntry){return true;}
|
||||
//bool Load(){return true;}
|
||||
//void Unload(){}
|
||||
|
||||
//void spell_ex_SpellScript::Function(AuraEffect const * aurEff, AuraEffectHandleModes mode) //OnEffectApply += AuraEffectApplyFn(spell_ex_SpellScript::Function, EFFECT_ANY, SPELL_AURA_ANY, AURA_EFFECT_HANDLE_REAL);
|
||||
//void spell_ex_SpellScript::Function(AuraEffect const * aurEff, AuraEffectHandleModes mode) //OnEffectRemove += AuraEffectRemoveFn(spell_ex_SpellScript::Function, EFFECT_ANY, SPELL_AURA_ANY, AURA_EFFECT_HANDLE_REAL);
|
||||
//void spell_ex_SpellScript::Function(AuraEffect const * aurEff) //OnEffectPeriodic += AuraEffectPeriodicFn(spell_ex_SpellScript::Function, EFFECT_ANY, SPELL_AURA_ANY);
|
||||
//void spell_ex_SpellScript::Function(AuraEffect * aurEff) //OnEffectUpdatePeriodic += AuraEffectUpdatePeriodicFn(spell_ex_SpellScript::Function, EFFECT_ANY, SPELL_AURA_ANY);
|
||||
//void spell_ex_SpellScript::Function(AuraEffect const * aurEff, int32 & amount, bool & canBeRecalculated) //DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_ex_SpellScript::Function, EFFECT_ANY, SPELL_AURA_ANY);
|
||||
//void spell_ex_SpellScript::Function(AuraEffect const * aurEff, bool & isPeriodic, int32 & amplitude) //OnEffectCalcPeriodic += AuraEffectCalcPeriodicFn(spell_ex_SpellScript::Function, EFFECT_ANY, SPELL_AURA_ANY);
|
||||
//void spell_ex_SpellScript::Function(AuraEffect const * aurEff, SpellModifier *& spellMod) //OnEffectCalcSpellMod += AuraEffectCalcSpellModFn(spell_ex_SpellScript::Function, EFFECT_ANY, SPELL_AURA_ANY);
|
||||
//void spell_ex_SpellScript::Function(AuraEffect const* aurEff, AuraEffectHandleModes mode) //OnEffectApply += AuraEffectApplyFn(spell_ex_SpellScript::Function, EFFECT_ANY, SPELL_AURA_ANY, AURA_EFFECT_HANDLE_REAL);
|
||||
//void spell_ex_SpellScript::Function(AuraEffect const* aurEff, AuraEffectHandleModes mode) //OnEffectRemove += AuraEffectRemoveFn(spell_ex_SpellScript::Function, EFFECT_ANY, SPELL_AURA_ANY, AURA_EFFECT_HANDLE_REAL);
|
||||
//void spell_ex_SpellScript::Function(AuraEffect const* aurEff) //OnEffectPeriodic += AuraEffectPeriodicFn(spell_ex_SpellScript::Function, EFFECT_ANY, SPELL_AURA_ANY);
|
||||
//void spell_ex_SpellScript::Function(AuraEffect* aurEff) //OnEffectUpdatePeriodic += AuraEffectUpdatePeriodicFn(spell_ex_SpellScript::Function, EFFECT_ANY, SPELL_AURA_ANY);
|
||||
//void spell_ex_SpellScript::Function(AuraEffect const* aurEff, int32& amount, bool& canBeRecalculated) //DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_ex_SpellScript::Function, EFFECT_ANY, SPELL_AURA_ANY);
|
||||
//void spell_ex_SpellScript::Function(AuraEffect const* aurEff, bool& isPeriodic, int32& amplitude) //OnEffectCalcPeriodic += AuraEffectCalcPeriodicFn(spell_ex_SpellScript::Function, EFFECT_ANY, SPELL_AURA_ANY);
|
||||
//void spell_ex_SpellScript::Function(AuraEffect const* aurEff, SpellModifier*& spellMod) //OnEffectCalcSpellMod += AuraEffectCalcSpellModFn(spell_ex_SpellScript::Function, EFFECT_ANY, SPELL_AURA_ANY);
|
||||
void Register()
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
AuraScript *GetAuraScript() const
|
||||
AuraScript* GetAuraScript() const
|
||||
{
|
||||
return new spell_ex_AuraScript();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user