diff --git a/ElunaIncludes.h b/ElunaIncludes.h index c5a2c88bd8..3d4a82dbff 100644 --- a/ElunaIncludes.h +++ b/ElunaIncludes.h @@ -40,6 +40,7 @@ #include "ScriptMgr.h" #include "Spell.h" #include "SpellAuras.h" +#include "SpellAuraEffects.h" #include "SpellMgr.h" #include "TemporarySummon.h" #include "WorldPacket.h" diff --git a/ElunaProcInfo.cpp b/ElunaProcInfo.cpp new file mode 100644 index 0000000000..0e46d82e92 --- /dev/null +++ b/ElunaProcInfo.cpp @@ -0,0 +1,113 @@ +#include "ElunaProcInfo.h" +#include "ElunaIncludes.h" +#include "ElunaTemplate.h" + +ElunaProcInfo::ElunaProcInfo(Unit* actor, Unit* actionTarget, uint32 typeMask, + uint32 spellTypeMask, uint32 spellPhaseMask, uint32 hitMask, + Spell* spell, SpellInfo const* spellInfo, SpellSchoolMask schoolMask, Map* map) + : _actor(actor), _actionTarget(actionTarget), _typeMask(typeMask), _spellTypeMask(spellTypeMask), _spellPhaseMask(spellPhaseMask) + , _hitMask(hitMask), _spell(spell), _spellInfo(spellInfo), _schoolMask(schoolMask), _damage(0) + , _damageType(DIRECT_DAMAGE), _attackType(BASE_ATTACK), _damageAbsorb(0), _resist(0), _block(0) + , _heal(0), _effectiveHeal(0), _healAbsorb(0), _map(map), m_scriptRef(this, NoopAuraDeleter()) +{ +} + +ElunaProcInfo::ElunaProcInfo(ProcEventInfo& procInfo, Map* map) + : _actor(procInfo.GetActor()), _actionTarget(procInfo.GetActionTarget()), _typeMask(procInfo.GetTypeMask()), _spellTypeMask(procInfo.GetSpellTypeMask()), _spellPhaseMask(procInfo.GetSpellPhaseMask()) + , _hitMask(procInfo.GetHitMask()), _spell(const_cast(procInfo.GetProcSpell())), _spellInfo(procInfo.GetSpellInfo()), _schoolMask(procInfo.GetSchoolMask()), _damage(0) + , _damageType(DIRECT_DAMAGE), _attackType(BASE_ATTACK), _damageAbsorb(0), _resist(0), _block(0) + , _heal(0), _effectiveHeal(0), _healAbsorb(0), _map(map), m_scriptRef(this, NoopAuraDeleter()) +{ + if (DamageInfo* damageInfo = procInfo.GetDamageInfo()) + { + _damage = damageInfo->GetDamage(); + _damageType = damageInfo->GetDamageType(); + _attackType = damageInfo->GetAttackType(); + _damageAbsorb = damageInfo->GetAbsorb(); + _resist = damageInfo->GetResist(); + _block = damageInfo->GetBlock(); + + if (damageInfo->GetSpellInfo()) + { + _spellInfo = damageInfo->GetSpellInfo(); + _schoolMask = damageInfo->GetSchoolMask(); + } + } + + if (HealInfo* healInfo = procInfo.GetHealInfo()) + { + _heal = healInfo->GetHeal(); + _effectiveHeal = healInfo->GetEffectiveHeal(); + _healAbsorb = healInfo->GetAbsorb(); + + if (healInfo->GetSpellInfo() && !_spellInfo) + { + _spellInfo = healInfo->GetSpellInfo(); + _schoolMask = healInfo->GetSchoolMask(); + } + } +} + +SpellInfo const* ElunaProcInfo::GetSpellInfo() const +{ + if (_spellInfo) + return _spellInfo; + if (_spell) + return _spell->GetSpellInfo(); + return nullptr; +} + +void ElunaProcInfo::SetDamage(uint32 damage, DamageEffectType damageType, WeaponAttackType attackType) +{ + _damage = damage; + _damageType = damageType; + _attackType = attackType; +} + +void ElunaProcInfo::SetHeal(uint32 heal) +{ + _heal = heal; + _effectiveHeal = heal; +} + +void ElunaProcInfo::ApplyToProcEventInfo(ProcEventInfo& procInfo) const +{ + if (DamageInfo* damageInfo = procInfo.GetDamageInfo()) + { + if (HasDamage()) + { + int32 damageDiff = static_cast(_damage) - static_cast(damageInfo->GetDamage()); + if (damageDiff != 0) + damageInfo->ModifyDamage(damageDiff); + + uint32 currentAbsorb = damageInfo->GetAbsorb(); + uint32 currentResist = damageInfo->GetResist(); + uint32 currentBlock = damageInfo->GetBlock(); + + uint32 absorbToAdd = (_damageAbsorb > currentAbsorb) ? (_damageAbsorb - currentAbsorb) : 0; + uint32 resistToAdd = (_resist > currentResist) ? (_resist - currentResist) : 0; + uint32 blockToAdd = (_block > currentBlock) ? (_block - currentBlock) : 0; + + if (absorbToAdd > 0) + damageInfo->AbsorbDamage(absorbToAdd); + if (resistToAdd > 0) + damageInfo->ResistDamage(resistToAdd); + if (blockToAdd > 0) + damageInfo->BlockDamage(blockToAdd); + } + } + + if (HealInfo* healInfo = procInfo.GetHealInfo()) + { + if (HasHeal()) + { + uint32 currentAbsorb = healInfo->GetAbsorb(); + uint32 absorbToAdd = (_healAbsorb > currentAbsorb) ? (_healAbsorb - currentAbsorb) : 0; + + if (absorbToAdd > 0) + healInfo->AbsorbHeal(absorbToAdd); + + healInfo->SetEffectiveHeal(_effectiveHeal); + } + } +} diff --git a/ElunaProcInfo.h b/ElunaProcInfo.h new file mode 100644 index 0000000000..2504db56fb --- /dev/null +++ b/ElunaProcInfo.h @@ -0,0 +1,102 @@ +#ifndef _ELUNA_PROCINFO_H +#define _ELUNA_PROCINFO_H + +class Unit; +class Spell; +class Map; +class SpellInfo; +class ProcEventInfo; +class DamageInfo; +class HealInfo; +enum SpellSchoolMask : uint32; +enum DamageEffectType : uint8; +enum WeaponAttackType : uint8; + +namespace Trinity +{ + template + class unique_trackable_ptr; + + template + class unique_weak_ptr; +} + +class ElunaProcInfo +{ +private: + Unit* _actor; + Unit* _actionTarget; + uint32 _typeMask; + uint32 _spellTypeMask; + uint32 _spellPhaseMask; + uint32 _hitMask; + Spell* _spell; + + SpellInfo const* _spellInfo; + SpellSchoolMask _schoolMask; + + uint32 _damage; + DamageEffectType _damageType; + WeaponAttackType _attackType; + uint32 _damageAbsorb; + uint32 _resist; + uint32 _block; + + uint32 _heal; + uint32 _effectiveHeal; + uint32 _healAbsorb; + Map* _map; + + struct NoopAuraDeleter { void operator()(ElunaProcInfo*) const { } }; + Trinity::unique_trackable_ptr m_scriptRef; + +public: + ElunaProcInfo(Unit* actor, Unit* actionTarget, uint32 typeMask, + uint32 spellTypeMask, uint32 spellPhaseMask, uint32 hitMask, + Spell* spell, SpellInfo const* spellInfo, SpellSchoolMask schoolMask, Map* map); + + explicit ElunaProcInfo(ProcEventInfo& procInfo, Map* map); + + Unit* GetActor() const { return _actor; } + Unit* GetActionTarget() const { return _actionTarget; } + uint32 GetTypeMask() const { return _typeMask; } + uint32 GetSpellTypeMask() const { return _spellTypeMask; } + uint32 GetSpellPhaseMask() const { return _spellPhaseMask; } + uint32 GetHitMask() const { return _hitMask; } + Spell const* GetProcSpell() const { return _spell; } + + SpellInfo const* GetSpellInfo() const; + SpellSchoolMask GetSchoolMask() const { return _schoolMask; } + + uint32 GetDamage() const { return _damage; } + DamageEffectType GetDamageType() const { return _damageType; } + WeaponAttackType GetAttackType() const { return _attackType; } + uint32 GetDamageAbsorb() const { return _damageAbsorb; } + uint32 GetResist() const { return _resist; } + uint32 GetBlock() const { return _block; } + + uint32 GetHeal() const { return _heal; } + uint32 GetEffectiveHeal() const { return _effectiveHeal; } + uint32 GetHealAbsorb() const { return _healAbsorb; } + + bool HasDamage() const { return _damage > 0; } + bool HasHeal() const { return _heal > 0; } + + void SetDamage(int32 amount) { _damage = amount; } + void SetAbsorbDamage(uint32 amount) { _damageAbsorb = amount; } + void SetResistDamage(uint32 amount) { _resist = amount; } + void SetBlockDamage(uint32 amount) { _block = amount; } + + void SetAbsorbHeal(uint32 amount) { _healAbsorb = amount; } + void SetEffectiveHeal(uint32 amount) { _effectiveHeal = amount; } + void SetHeal(int32 amount) { _heal = amount; } + + void SetDamage(uint32 damage, DamageEffectType damageType, WeaponAttackType attackType); + void SetHeal(uint32 heal); + + const Map* GetMap() const { return _map; } + Trinity::unique_weak_ptr GetWeakPtr() const { return m_scriptRef; } + void ApplyToProcEventInfo(ProcEventInfo& procInfo) const; +}; + +#endif diff --git a/ElunaTemplate.cpp b/ElunaTemplate.cpp index 462ea92d65..f896d16787 100644 --- a/ElunaTemplate.cpp +++ b/ElunaTemplate.cpp @@ -20,6 +20,17 @@ ElunaConstrainedObjectRef GetWeakPtrFor(Aura const* obj) #endif return { obj->GetWeakPtr(), map }; } + +ElunaConstrainedObjectRef GetWeakPtrFor(AuraEffect const* obj) +{ + Map* map = obj->GetBase()->GetOwner()->GetMap(); + return { obj->GetWeakPtr(), map }; +} + +ElunaConstrainedObjectRef GetWeakPtrFor(ElunaProcInfo const* obj) +{ + return { obj->GetWeakPtr(), obj->GetMap()}; +} ElunaConstrainedObjectRef GetWeakPtrFor(BattleGround const* obj) { return { obj->GetWeakPtr(), obj->GetBgMap() }; } ElunaConstrainedObjectRef GetWeakPtrFor(Group const* obj) { return { obj->GetWeakPtr(), nullptr }; } ElunaConstrainedObjectRef GetWeakPtrFor(Guild const* obj) { return { obj->GetWeakPtr(), nullptr }; } diff --git a/ElunaTemplate.h b/ElunaTemplate.h index 74d98f3bf2..3c2fbc6437 100644 --- a/ElunaTemplate.h +++ b/ElunaTemplate.h @@ -17,6 +17,7 @@ extern "C" #include "ElunaUtility.h" #include "ElunaCompat.h" #include "ElunaConfig.h" +#include "ElunaProcInfo.h" #if !defined ELUNA_CMANGOS #include "SharedDefines.h" #else @@ -62,6 +63,8 @@ struct ElunaConstrainedObjectRef }; ElunaConstrainedObjectRef GetWeakPtrFor(Aura const* obj); +ElunaConstrainedObjectRef GetWeakPtrFor(AuraEffect const* obj); +ElunaConstrainedObjectRef GetWeakPtrFor(ElunaProcInfo const* obj); ElunaConstrainedObjectRef GetWeakPtrFor(BattleGround const* obj); ElunaConstrainedObjectRef GetWeakPtrFor(Group const* obj); ElunaConstrainedObjectRef GetWeakPtrFor(Guild const* obj); diff --git a/LuaEngine.h b/LuaEngine.h index b9b2fd94a3..8d4bca1976 100644 --- a/LuaEngine.h +++ b/LuaEngine.h @@ -35,6 +35,7 @@ #include #include +#include "ElunaProcInfo.h" extern "C" { @@ -623,6 +624,14 @@ class ELUNA_GAME_API Eluna /* Spell */ void OnSpellCast(Spell* pSpell, bool skipCheck); + bool OnAuraApplication(Aura* aura, AuraEffect const* auraEff, Unit* target, uint8 mode, bool apply); + void OnAuraDispel(Aura* aura, DispelInfo* dispelInfo); + bool OnPerodicTick(Aura* aura, AuraEffect const* auraEff, Unit* target); + void OnPerodicUpdate(Aura* aura, AuraEffect const* auraEff); + void OnAuraCalcAmount(Aura* aura, AuraEffect const* auraEff, int32& amount, bool& canBeRecalculated); + void OnCalcPerodic(Aura* aura, AuraEffect const* auraEff, bool& isPeriodic, int32& amplitude); + bool OnAuraCanProc(Aura* aura, ProcEventInfo& procInfo); + bool OnAuraProc(Aura* aura, ProcEventInfo& procInfo); }; template<> Unit* Eluna::CHECKOBJ(int narg, bool error); template<> Object* Eluna::CHECKOBJ(int narg, bool error); diff --git a/hooks/Hooks.h b/hooks/Hooks.h index 297278d135..bbb42361f6 100644 --- a/hooks/Hooks.h +++ b/hooks/Hooks.h @@ -361,7 +361,15 @@ namespace Hooks // SPELL EVENTS #define SPELL_EVENTS_LIST(X) \ - X(SPELL_EVENT_ON_CAST, 1, "on_cast") + X(SPELL_EVENT_ON_CAST, 1, "on_cast") \ + X(SPELL_EVENT_ON_AURA_APPLICATION, 2, "on_aura_application") \ + X(SPELL_EVENT_ON_DISPEL, 3, "on_dispel") \ + X(SPELL_EVENT_ON_PERODIC_TICK, 4, "on_periodic_tick") \ + X(SPELL_EVENT_ON_PERODIC_UPDATE, 5, "on_periodic_update") \ + X(SPELL_EVENT_ON_AURA_CALC_AMOUNT, 6, "on_aura_calc_amount") \ + X(SPELL_EVENT_ON_CALC_PERODIC, 7, "on_calc_periodic") \ + X(SPELL_EVENT_ON_CHECK_PROC, 7, "on_check_proc") \ + X(SPELL_EVENT_ON_PROC, 8, "on_proc") \ enum SpellEvents { diff --git a/hooks/SpellHooks.cpp b/hooks/SpellHooks.cpp index a5ef8a30a6..6506ae21b9 100644 --- a/hooks/SpellHooks.cpp +++ b/hooks/SpellHooks.cpp @@ -15,13 +15,13 @@ using namespace Hooks; #define START_HOOK(EVENT, SPELL) \ auto binding = GetBinding>(REGTYPE_SPELL);\ - auto key = EntryKey(EVENT, SPELL->m_spellInfo->Id);\ + auto key = EntryKey(EVENT, SPELL->GetSpellInfo()->Id);\ if (!binding->HasBindingsFor(key))\ return; #define START_HOOK_WITH_RETVAL(EVENT, SPELL, RETVAL) \ auto binding = GetBinding>(REGTYPE_SPELL);\ - auto key = EntryKey(EVENT, SPELL->m_spellInfo->Id);\ + auto key = EntryKey(EVENT, SPELL->GetSpellInfo()->Id);\ if (!binding->HasBindingsFor(key))\ return RETVAL; @@ -32,3 +32,134 @@ void Eluna::OnSpellCast(Spell* pSpell, bool skipCheck) HookPush(skipCheck); CallAllFunctions(binding, key); } + +bool Eluna::OnAuraApplication(Aura* aura, AuraEffect const* auraEff, Unit* target, uint8 mode, bool apply) +{ + START_HOOK_WITH_RETVAL(SPELL_EVENT_ON_AURA_APPLICATION, aura, false); + HookPush(aura); + HookPush(auraEff); + HookPush(target); + HookPush(mode); + HookPush(apply); + return CallAllFunctionsBool(binding, key, false); +} + +void Eluna::OnAuraDispel(Aura* aura, DispelInfo* dispelInfo) +{ + START_HOOK(SPELL_EVENT_ON_DISPEL, aura); + HookPush(aura); + HookPush(dispelInfo->GetDispeller()); + HookPush(dispelInfo->GetDispellerSpellId()); + HookPush(dispelInfo->GetRemovedCharges()); + CallAllFunctions(binding, key); +} + +bool Eluna::OnPerodicTick(Aura* aura, AuraEffect const* auraEff, Unit* target) +{ + START_HOOK_WITH_RETVAL(SPELL_EVENT_ON_PERODIC_TICK, aura, false); + HookPush(aura); + HookPush(auraEff); + HookPush(target); + return CallAllFunctionsBool(binding, key, false); +} + +void Eluna::OnPerodicUpdate(Aura* aura, AuraEffect const* auraEff) +{ + START_HOOK(SPELL_EVENT_ON_PERODIC_UPDATE, aura); + HookPush(aura); + HookPush(auraEff); + CallAllFunctions(binding, key); +} + +void Eluna::OnAuraCalcAmount(Aura* aura, AuraEffect const* auraEff, int32& amount, bool& canBeRecalculated) +{ + START_HOOK(SPELL_EVENT_ON_AURA_CALC_AMOUNT, aura); + HookPush(aura); + HookPush(auraEff); + HookPush(amount); + int amountIndex = lua_gettop(L); + HookPush(canBeRecalculated); + int canBeRecalculatedIndex = lua_gettop(L); + int n = SetupStack(binding, key, 4); + + while (n > 0) + { + int r = CallOneFunction(n--, 4, 2); + + if (lua_isnumber(L, r + 0)) + { + amount = CHECKVAL(r + 0); + // Update the stack for subsequent calls. + ReplaceArgument(amount, amountIndex); + } + + + if (lua_isboolean(L, r + 1)) + { + canBeRecalculated = lua_toboolean(L, r + 1); + // Update the stack for subsequent calls. + ReplaceArgument(amount, canBeRecalculatedIndex); + } + + lua_pop(L, 2); + } + + CleanUpStack(2); +} + +void Eluna::OnCalcPerodic(Aura* aura, AuraEffect const* auraEff, bool& isPeriodic, int32& amplitude) +{ + START_HOOK(SPELL_EVENT_ON_AURA_CALC_AMOUNT, aura); + HookPush(aura); + HookPush(auraEff); + HookPush(isPeriodic); + int isPeriodicIndex = lua_gettop(L); + HookPush(amplitude); + int amplitudeIndex = lua_gettop(L); + int n = SetupStack(binding, key, 4); + + while (n > 0) + { + int r = CallOneFunction(n--, 4, 2); + + if (lua_isboolean(L, r + 0)) + { + isPeriodic = lua_toboolean(L, r + 0); + // Update the stack for subsequent calls. + ReplaceArgument(isPeriodic, isPeriodicIndex); + } + + if (lua_isnumber(L, r + 1)) + { + amplitude = CHECKVAL(r + 1); + // Update the stack for subsequent calls. + ReplaceArgument(amplitude, amplitudeIndex); + } + + lua_pop(L, 2); + } + + CleanUpStack(2); +} + +bool Eluna::OnAuraCanProc(Aura* aura, ProcEventInfo& procInfo) +{ + START_HOOK_WITH_RETVAL(SPELL_EVENT_ON_CHECK_PROC, aura, true); + ElunaProcInfo luaProcInfo(procInfo, aura->GetCaster()->GetMap()); + HookPush(aura); + HookPush(&luaProcInfo); + bool retVal = CallAllFunctionsBool(binding, key, true); + luaProcInfo.ApplyToProcEventInfo(procInfo); + return retVal; +} + +bool Eluna::OnAuraProc(Aura* aura, ProcEventInfo& procInfo) +{ + START_HOOK_WITH_RETVAL(SPELL_EVENT_ON_CHECK_PROC, aura, false); + ElunaProcInfo luaProcInfo(procInfo, aura->GetCaster()->GetMap()); + HookPush(aura); + HookPush(&luaProcInfo); + bool defaultPrevented = CallAllFunctionsBool(binding, key, false); + luaProcInfo.ApplyToProcEventInfo(procInfo); + return defaultPrevented; +} diff --git a/methods/Methods.cpp b/methods/Methods.cpp index ae2bf4d229..40ca7801fa 100644 --- a/methods/Methods.cpp +++ b/methods/Methods.cpp @@ -23,6 +23,8 @@ #include "GameObjectMethods.h" #include "ElunaQueryMethods.h" #include "AuraMethods.h" +#include "AuraEffectMethods.h" +#include "ElunaProcInfoMethods.h" #include "ItemMethods.h" #include "WorldPacketMethods.h" #include "SpellMethods.h" @@ -90,6 +92,12 @@ void RegisterMethods(Eluna* E) ElunaTemplate::Register(E, "Aura"); ElunaTemplate::SetMethods(E, LuaAura::AuraMethods); + ElunaTemplate::Register(E, "AuraEffect"); + ElunaTemplate::SetMethods(E, LuaAuraEffects::AuraEffectMethods); + + ElunaTemplate::Register(E, "ElunaProcInfo"); + ElunaTemplate::SetMethods(E, LuaElunaProcInfo::ElunaProcInfoMethods); + ElunaTemplate::Register(E, "Spell"); ElunaTemplate::SetMethods(E, LuaSpell::SpellMethods); diff --git a/methods/TrinityCore/AuraEffectMethods.h b/methods/TrinityCore/AuraEffectMethods.h new file mode 100644 index 0000000000..6e5ba509d2 --- /dev/null +++ b/methods/TrinityCore/AuraEffectMethods.h @@ -0,0 +1,194 @@ +/* +* Copyright (C) 2010 - 2024 Eluna Lua Engine +* This program is free software licensed under GPL version 3 +* Please see the included DOCS/LICENSE.md for more information +*/ + +#ifndef AURAEFFECTMETHODS_H +#define AURAEFFECTMETHODS_H + + +namespace LuaAuraEffects +{ + int GetBase(Eluna* E, AuraEffect* aurEff) + { + E->Push(aurEff->GetBase()); + return 1; + } + + int GetBaseAmount(Eluna* E, AuraEffect* aurEff) + { + E->Push(aurEff->GetBaseAmount()); + return 1; + } + + int GetAmplitude(Eluna* E, AuraEffect* aurEff) + { + E->Push(aurEff->GetAmplitude()); + return 1; + } + + int GetAmount(Eluna* E, AuraEffect* aurEff) + { + E->Push(aurEff->GetAmount()); + return 1; + } + + int SetAmount(Eluna* E, AuraEffect* aurEff) + { + int32 amount = E->CHECKVAL(2); + aurEff->SetAmount(amount); + return 0; + } + + int GetPeriodicTimer(Eluna* E, AuraEffect* aurEff) + { + E->Push(aurEff->GetPeriodicTimer()); + return 1; + } + + int SetPeriodicTimer(Eluna* E, AuraEffect* aurEff) + { + int32 timer = E->CHECKVAL(2); + aurEff->SetPeriodicTimer(timer); + return 0; + } + + int CalculateAmount(Eluna* E, AuraEffect* aurEff) + { + Unit* caster = E->CHECKOBJ(2); + E->Push(aurEff->CalculateAmount(caster)); + return 1; + } + + int CalculatePeriodic(Eluna* E, AuraEffect* aurEff) + { + Unit* caster = E->CHECKOBJ(2); + bool resetPeriodicTimer = E->CHECKVAL(3, false); + bool load = E->CHECKVAL(4, false); + aurEff->CalculatePeriodic(caster, resetPeriodicTimer, load); + return 0; + } + + int ChangeAmount(Eluna* E, AuraEffect* aurEff) + { + int32 newAmount = E->CHECKVAL(2); + bool mark = E->CHECKVAL(3, true); + bool onStackOrReapply = E->CHECKVAL(4, false); + aurEff->ChangeAmount(newAmount, mark, onStackOrReapply); + return 0; + } + + int RecalculateAmount(Eluna* /*E*/, AuraEffect* aurEff) + { + aurEff->RecalculateAmount(); + return 0; + } + + int CanBeRecalculated(Eluna* E, AuraEffect* aurEff) + { + E->Push(aurEff->CanBeRecalculated()); + return 1; + } + + int SetCanBeRecalculated(Eluna* E, AuraEffect* aurEff) + { + bool val = E->CHECKVAL(2, true); + aurEff->SetCanBeRecalculated(val); + return 0; + } + + int GetTickNumber(Eluna* E, AuraEffect* aurEff) + { + E->Push(aurEff->GetTickNumber()); + return 1; + } + + int GetRemainingTicks(Eluna* E, AuraEffect* aurEff) + { + E->Push(aurEff->GetRemainingTicks()); + return 1; + } + + int GetTotalTicks(Eluna* E, AuraEffect* aurEff) + { + E->Push(aurEff->GetTotalTicks()); + return 1; + } + + int GetTargetList(Eluna* E, AuraEffect* aurEff) + { + std::list list; + aurEff->GetTargetList(list); + lua_createtable(E->L, list.size(), 0); + int tbl = lua_gettop(E->L); + uint32 i = 0; + + for (std::list::const_iterator it = list.begin(); it != list.end(); ++it) + { + E->Push(*it); + lua_rawseti(E->L, tbl, ++i); + } + + lua_settop(E->L, tbl); + return 1; + } + + int GetId(Eluna* E, AuraEffect* aurEff) + { + E->Push(aurEff->GetId()); + return 1; + } + + int GetEffIndex(Eluna* E, AuraEffect* aurEff) + { + E->Push(uint8(aurEff->GetEffIndex())); + return 1; + } + + int GetAuraType(Eluna* E, AuraEffect* aurEff) + { + E->Push(uint16(aurEff->GetAuraType())); + return 1; + } + + int GetCaster(Eluna* E, AuraEffect* aurEff) + { + E->Push(aurEff->GetCaster()); + return 1; + } + + int GetCasterGUID(Eluna* E, AuraEffect* aurEff) + { + E->Push(aurEff->GetCasterGUID()); + return 1; + } + + ElunaRegister AuraEffectMethods[] = + { + {"GetBase", &LuaAuraEffects::GetBase}, + {"GetBaseAmount", &LuaAuraEffects::GetBaseAmount}, + {"GetAmplitude", &LuaAuraEffects::GetAmplitude}, + {"GetAmount", &LuaAuraEffects::GetAmount}, + {"SetAmount", &LuaAuraEffects::SetAmount}, + {"GetPeriodicTimer", &LuaAuraEffects::GetPeriodicTimer}, + {"SetPeriodicTimer", &LuaAuraEffects::SetPeriodicTimer}, + {"CalculateAmount", &LuaAuraEffects::CalculateAmount}, + {"CalculatePeriodic", &LuaAuraEffects::CalculatePeriodic}, + {"ChangeAmount", &LuaAuraEffects::ChangeAmount}, + {"RecalculateAmount", &LuaAuraEffects::RecalculateAmount}, + {"CanBeRecalculated", &LuaAuraEffects::CanBeRecalculated}, + {"SetCanBeRecalculated", &LuaAuraEffects::SetCanBeRecalculated}, + {"GetTickNumber", &LuaAuraEffects::GetTickNumber}, + {"GetRemainingTicks", &LuaAuraEffects::GetRemainingTicks}, + {"GetTotalTicks", &LuaAuraEffects::GetTotalTicks}, + {"GetTargetList", &LuaAuraEffects::GetTargetList}, + {"GetId", &LuaAuraEffects::GetId}, + {"GetEffIndex", &LuaAuraEffects::GetEffIndex}, + {"GetAuraType", &LuaAuraEffects::GetAuraType}, + {"GetCaster", &LuaAuraEffects::GetCaster}, + {"GetCasterGUID", &LuaAuraEffects::GetCasterGUID} + }; +}; +#endif + diff --git a/methods/TrinityCore/ElunaProcInfoMethods.h b/methods/TrinityCore/ElunaProcInfoMethods.h new file mode 100644 index 0000000000..8cd3fd3056 --- /dev/null +++ b/methods/TrinityCore/ElunaProcInfoMethods.h @@ -0,0 +1,213 @@ +#ifndef ELUNAPROCINFOMETHODS_H +#define ELUNAPROCINFOMETHODS_H + +namespace LuaElunaProcInfo +{ + int GetActor(Eluna* E, ElunaProcInfo* procInfo) + { + E->Push(procInfo->GetActor()); + return 1; + } + + int GetActionTarget(Eluna* E, ElunaProcInfo* procInfo) + { + E->Push(procInfo->GetActionTarget()); + return 1; + } + + int GetTypeMask(Eluna* E, ElunaProcInfo* procInfo) + { + E->Push(procInfo->GetTypeMask()); + return 1; + } + + int GetSpellTypeMask(Eluna* E, ElunaProcInfo* procInfo) + { + E->Push(procInfo->GetSpellTypeMask()); + return 1; + } + + int GetSpellPhaseMask(Eluna* E, ElunaProcInfo* procInfo) + { + E->Push(procInfo->GetSpellPhaseMask()); + return 1; + } + + int GetHitMask(Eluna* E, ElunaProcInfo* procInfo) + { + E->Push(procInfo->GetHitMask()); + return 1; + } + + int GetProcSpell(Eluna* E, ElunaProcInfo* procInfo) + { + E->Push(procInfo->GetProcSpell()); + return 1; + } + + /*int GetSpellInfo(Eluna* E, ElunaProcInfo* procInfo) + { + E->Push(procInfo->GetSpellInfo()); + return 1; + }*/ + + int GetSchoolMask(Eluna* E, ElunaProcInfo* procInfo) + { + E->Push(procInfo->GetSchoolMask()); + return 1; + } + + int GetDamage(Eluna* E, ElunaProcInfo* procInfo) + { + E->Push(procInfo->GetDamage()); + return 1; + } + + int GetDamageType(Eluna* E, ElunaProcInfo* procInfo) + { + E->Push(procInfo->GetDamageType()); + return 1; + } + + int GetAttackType(Eluna* E, ElunaProcInfo* procInfo) + { + E->Push(procInfo->GetAttackType()); + return 1; + } + + int GetDamageAbsorb(Eluna* E, ElunaProcInfo* procInfo) + { + E->Push(procInfo->GetDamageAbsorb()); + return 1; + } + + int GetResist(Eluna* E, ElunaProcInfo* procInfo) + { + E->Push(procInfo->GetResist()); + return 1; + } + + int GetBlock(Eluna* E, ElunaProcInfo* procInfo) + { + E->Push(procInfo->GetBlock()); + return 1; + } + + int GetHeal(Eluna* E, ElunaProcInfo* procInfo) + { + E->Push(procInfo->GetHeal()); + return 1; + } + + int GetEffectiveHeal(Eluna* E, ElunaProcInfo* procInfo) + { + E->Push(procInfo->GetEffectiveHeal()); + return 1; + } + + int GetHealAbsorb(Eluna* E, ElunaProcInfo* procInfo) + { + E->Push(procInfo->GetHealAbsorb()); + return 1; + } + + int HasDamage(Eluna* E, ElunaProcInfo* procInfo) + { + E->Push(procInfo->HasDamage()); + return 1; + } + + int HasHeal(Eluna* E, ElunaProcInfo* procInfo) + { + E->Push(procInfo->HasHeal()); + return 1; + } + + int SetDamage(Eluna* E, ElunaProcInfo* procInfo) + { + int32 damage = E->CHECKVAL(2); + procInfo->SetDamage(damage); + return 0; + } + + int SetAbsorbDamage(Eluna* E, ElunaProcInfo* procInfo) + { + uint32 absorb = E->CHECKVAL(2); + procInfo->SetAbsorbDamage(absorb); + return 0; + } + + int SetResistDamage(Eluna* E, ElunaProcInfo* procInfo) + { + uint32 resist = E->CHECKVAL(2); + procInfo->SetResistDamage(resist); + return 0; + } + + int SetBlockDamage(Eluna* E, ElunaProcInfo* procInfo) + { + uint32 block = E->CHECKVAL(2); + procInfo->SetBlockDamage(block); + return 0; + } + + int SetHeal(Eluna* E, ElunaProcInfo* procInfo) + { + int32 heal = E->CHECKVAL(2); + procInfo->SetHeal(heal); + return 0; + } + + int SetAbsorbHeal(Eluna* E, ElunaProcInfo* procInfo) + { + uint32 absorb = E->CHECKVAL(2); + procInfo->SetAbsorbHeal(absorb); + return 0; + } + + int SetEffectiveHeal(Eluna* E, ElunaProcInfo* procInfo) + { + uint32 effectiveHeal = E->CHECKVAL(2); + procInfo->SetEffectiveHeal(effectiveHeal); + return 0; + } + + int GetMap(Eluna* E, ElunaProcInfo* procInfo) + { + E->Push(procInfo->GetMap()); + return 1; + } + + ElunaRegister ElunaProcInfoMethods[] = + { + { "GetActor", &LuaElunaProcInfo::GetActor }, + { "GetActionTarget", &LuaElunaProcInfo::GetActionTarget }, + { "GetTypeMask", &LuaElunaProcInfo::GetTypeMask }, + { "GetSpellTypeMask", &LuaElunaProcInfo::GetSpellTypeMask }, + { "GetSpellPhaseMask", &LuaElunaProcInfo::GetSpellPhaseMask }, + { "GetHitMask", &LuaElunaProcInfo::GetHitMask }, + { "GetProcSpell", &LuaElunaProcInfo::GetProcSpell }, + //{ "GetSpellInfo", &LuaElunaProcInfo::GetSpellInfo }, + { "GetSchoolMask", &LuaElunaProcInfo::GetSchoolMask }, + { "GetDamage", &LuaElunaProcInfo::GetDamage }, + { "GetDamageType", &LuaElunaProcInfo::GetDamageType }, + { "GetAttackType", &LuaElunaProcInfo::GetAttackType }, + { "GetDamageAbsorb", &LuaElunaProcInfo::GetDamageAbsorb }, + { "GetResist", &LuaElunaProcInfo::GetResist }, + { "GetBlock", &LuaElunaProcInfo::GetBlock }, + { "SetDamage", &LuaElunaProcInfo::SetDamage }, + { "SetAbsorbDamage", &LuaElunaProcInfo::SetAbsorbDamage }, + { "SetResistDamage", &LuaElunaProcInfo::SetResistDamage }, + { "SetBlockDamage", &LuaElunaProcInfo::SetBlockDamage }, + { "GetHeal", &LuaElunaProcInfo::GetHeal }, + { "GetEffectiveHeal", &LuaElunaProcInfo::GetEffectiveHeal }, + { "GetHealAbsorb", &LuaElunaProcInfo::GetHealAbsorb }, + { "SetHeal", &LuaElunaProcInfo::SetHeal }, + { "SetAbsorbHeal", &LuaElunaProcInfo::SetAbsorbHeal }, + { "SetEffectiveHeal", &LuaElunaProcInfo::SetEffectiveHeal }, + { "HasDamage", &LuaElunaProcInfo::HasDamage }, + { "HasHeal", &LuaElunaProcInfo::HasHeal }, + }; +} + +#endif