Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/server/game/LuaEngine
3 changes: 2 additions & 1 deletion src/server/game/Spells/Auras/SpellAuraEffects.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ AuraEffect::AuraEffect(Aura* base, SpellEffectInfo const& spellEfffectInfo, int3
m_base(base), m_spellInfo(base->GetSpellInfo()), m_spellEffectInfo(spellEfffectInfo),
m_baseAmount(baseAmount ? *baseAmount : spellEfffectInfo.BasePoints),
_amount(), m_spellmod(nullptr), _periodicTimer(0), _amplitude(0), _ticksDone(0),
m_canBeRecalculated(true), m_isPeriodic(false)
m_canBeRecalculated(true), m_isPeriodic(false), m_scriptRef(this, NoopAuraEffectDeleter())
{
CalculatePeriodic(caster, true, false);

Expand All @@ -396,6 +396,7 @@ m_canBeRecalculated(true), m_isPeriodic(false)

AuraEffect::~AuraEffect()
{
m_scriptRef = nullptr;
delete m_spellmod;
}

Expand Down
3 changes: 3 additions & 0 deletions src/server/game/Spells/Auras/SpellAuraEffects.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ class TC_GAME_API AuraEffect

SpellEffectInfo const& GetSpellEffectInfo() const { return m_spellEffectInfo; }

Trinity::unique_weak_ptr<AuraEffect> GetWeakPtr() const { return m_scriptRef; }
private:
Aura* const m_base;

Expand All @@ -120,6 +121,8 @@ class TC_GAME_API AuraEffect

float GetCritChanceFor(Unit const* caster, Unit const* target) const;

struct NoopAuraEffectDeleter { void operator()(AuraEffect*) const { /*noop - not managed*/ } };
Trinity::unique_trackable_ptr<AuraEffect> m_scriptRef;
public:
// aura effect apply/remove handlers
void HandleNULL(AuraApplication const* /*aurApp*/, uint8 /*mode*/, bool /*apply*/) const
Expand Down
53 changes: 53 additions & 0 deletions src/server/game/Spells/Auras/SpellAuras.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@
#include "Vehicle.h"
#include "World.h"
#include "WorldPacket.h"
#ifdef ELUNA
#include "LuaEngine.h"
#endif

AuraCreateInfo::AuraCreateInfo(SpellInfo const* spellInfo, uint8 auraEffMask, WorldObject* owner) :
_spellInfo(spellInfo), _auraEffectMask(auraEffMask), _owner(owner)
Expand Down Expand Up @@ -2203,6 +2206,12 @@ void Aura::CallScriptDispel(DispelInfo* dispelInfo)

(*scritr)->_FinishScriptCall();
}

#ifdef ELUNA
if (GetCaster())
if (Eluna* e = GetCaster()->GetEluna())
e->OnAuraDispel(this, dispelInfo);
#endif
}

void Aura::CallScriptAfterDispel(DispelInfo* dispelInfo)
Expand Down Expand Up @@ -2235,6 +2244,15 @@ bool Aura::CallScriptEffectApplyHandlers(AuraEffect const* aurEff, AuraApplicati
(*scritr)->_FinishScriptCall();
}

#ifdef ELUNA
if (!preventDefault)
{
if (aurApp->GetTarget())
if (Eluna* e = aurApp->GetTarget()->GetEluna())
preventDefault = e->OnAuraApplication(aurApp->GetBase(), aurEff, aurApp->GetTarget(), mode, true);
}
#endif

return preventDefault;
}

Expand All @@ -2254,6 +2272,16 @@ bool Aura::CallScriptEffectRemoveHandlers(AuraEffect const* aurEff, AuraApplicat

(*scritr)->_FinishScriptCall();
}

#ifdef ELUNA
if (!preventDefault)
{
if (aurApp->GetTarget())
if (Eluna* e = aurApp->GetTarget()->GetEluna())
preventDefault = e->OnAuraApplication(aurApp->GetBase(), aurEff, aurApp->GetTarget(), mode, false);
}
#endif

return preventDefault;
}

Expand Down Expand Up @@ -2302,6 +2330,15 @@ bool Aura::CallScriptEffectPeriodicHandlers(AuraEffect const* aurEff, AuraApplic
(*scritr)->_FinishScriptCall();
}

#ifdef ELUNA
if (!preventDefault)
{
if (aurApp->GetTarget())
if (Eluna* e = aurApp->GetTarget()->GetEluna())
preventDefault = e->OnPerodicTick(aurApp->GetBase(), aurEff, aurApp->GetTarget());
}
#endif

return preventDefault;
}

Expand All @@ -2317,6 +2354,12 @@ void Aura::CallScriptEffectUpdatePeriodicHandlers(AuraEffect* aurEff)

(*scritr)->_FinishScriptCall();
}

#ifdef ELUNA
if (aurEff->GetCaster())
if (Eluna* e = aurEff->GetCaster()->GetEluna())
e->OnPerodicTick(aurEff->GetBase(), aurEff);
#endif
}

void Aura::CallScriptEffectCalcAmountHandlers(AuraEffect const* aurEff, int32& amount, bool& canBeRecalculated)
Expand All @@ -2331,6 +2374,11 @@ void Aura::CallScriptEffectCalcAmountHandlers(AuraEffect const* aurEff, int32& a

(*scritr)->_FinishScriptCall();
}
#ifdef ELUNA
if (aurEff->GetCaster())
if (Eluna* e = aurEff->GetCaster()->GetEluna())
e->OnAuraCalcAmount(aurEff->GetBase(), aurEff, amount, canBeRecalculated);
#endif
}

void Aura::CallScriptEffectCalcPeriodicHandlers(AuraEffect const* aurEff, bool& isPeriodic, int32& amplitude)
Expand All @@ -2345,6 +2393,11 @@ void Aura::CallScriptEffectCalcPeriodicHandlers(AuraEffect const* aurEff, bool&

(*scritr)->_FinishScriptCall();
}
#ifdef ELUNA
if (aurEff->GetCaster())
if (Eluna* e = aurEff->GetCaster()->GetEluna())
e->OnCalcPerodic(aurEff->GetBase(), aurEff, isPeriodic, amplitude);
#endif
}

void Aura::CallScriptEffectCalcSpellModHandlers(AuraEffect const* aurEff, SpellModifier*& spellMod)
Expand Down
Loading