From 294cd0969d3d77cd4b4bb62734a629b1ecc80f6e Mon Sep 17 00:00:00 2001 From: iThorgrim Date: Wed, 22 Jan 2025 16:16:45 +0100 Subject: [PATCH] Feat: Add DBCStores access via Lua with getters for DBC entries --- src/LuaEngine/ElunaDBCRegistry.cpp | 6 + src/LuaEngine/ElunaDBCRegistry.h | 37 + src/LuaEngine/LuaEngine.cpp | 10 + src/LuaEngine/LuaEngine.h | 2 + src/LuaEngine/LuaFunctions.cpp | 119 +++ .../methods/GemPropertiesEntryMethods.h | 40 + src/LuaEngine/methods/GlobalMethods.h | 34 + src/LuaEngine/methods/SpellEntryMethods.h | 700 ++++++++++++++++++ 8 files changed, 948 insertions(+) create mode 100644 src/LuaEngine/ElunaDBCRegistry.cpp create mode 100644 src/LuaEngine/ElunaDBCRegistry.h create mode 100644 src/LuaEngine/methods/GemPropertiesEntryMethods.h create mode 100644 src/LuaEngine/methods/SpellEntryMethods.h diff --git a/src/LuaEngine/ElunaDBCRegistry.cpp b/src/LuaEngine/ElunaDBCRegistry.cpp new file mode 100644 index 0000000000..1b97d49355 --- /dev/null +++ b/src/LuaEngine/ElunaDBCRegistry.cpp @@ -0,0 +1,6 @@ +#include "ElunaDBCRegistry.h" + +std::vector dbcRegistry = { + REGISTER_DBC(GemProperties, GemPropertiesEntry, sGemPropertiesStore), + REGISTER_DBC(Spell, SpellEntry, sSpellStore), +}; diff --git a/src/LuaEngine/ElunaDBCRegistry.h b/src/LuaEngine/ElunaDBCRegistry.h new file mode 100644 index 0000000000..f631d50a06 --- /dev/null +++ b/src/LuaEngine/ElunaDBCRegistry.h @@ -0,0 +1,37 @@ +#ifndef ELUNADBCREGISTRY_H +#define ELUNADBCREGISTRY_H + +#include +#include +#include +#include + +#include "DBCStores.h" +#include "LuaEngine.h" + +struct DBCDefinition +{ + std::string name; + void* storage; + const std::type_info& type; + std::function lookupFunction; + std::function pushFunction; +}; + +extern std::vector dbcRegistry; + +#define REGISTER_DBC(dbcName, entryType, store) \ + { \ + #dbcName, \ + reinterpret_cast(&store), \ + typeid(DBCStorage), \ + [](uint32 id) -> const void* { \ + return store.LookupEntry(id); \ + }, \ + [](lua_State* L, const void* entry) { \ + auto cast_entry = static_cast(entry); \ + Eluna::Push(L, *cast_entry); \ + } \ + } + +#endif // ELUNADBCREGISTRY_H diff --git a/src/LuaEngine/LuaEngine.cpp b/src/LuaEngine/LuaEngine.cpp index 40cb155b3b..50bd03f375 100644 --- a/src/LuaEngine/LuaEngine.cpp +++ b/src/LuaEngine/LuaEngine.cpp @@ -690,6 +690,16 @@ void Eluna::Push(lua_State* luastate, ObjectGuid const guid) ElunaTemplate::Push(luastate, new unsigned long long(guid.GetRawValue())); } +void Eluna::Push(lua_State* luastate, GemPropertiesEntry const& gemProperties) +{ + Push(luastate, &gemProperties); +} + +void Eluna::Push(lua_State* luastate, SpellEntry const& spell) +{ + Push(luastate, &spell); +} + static int CheckIntegerRange(lua_State* luastate, int narg, int min, int max) { double value = luaL_checknumber(luastate, narg); diff --git a/src/LuaEngine/LuaEngine.h b/src/LuaEngine/LuaEngine.h index b6869f144e..ba8b297aa3 100644 --- a/src/LuaEngine/LuaEngine.h +++ b/src/LuaEngine/LuaEngine.h @@ -256,6 +256,8 @@ class ELUNA_GAME_API Eluna static void Push(lua_State* luastate, Pet const* pet); static void Push(lua_State* luastate, TempSummon const* summon); static void Push(lua_State* luastate, ObjectGuid const guid); + static void Push(lua_State* luastate, GemPropertiesEntry const& gemProperties); + static void Push(lua_State* luastate, SpellEntry const& spell); template static void Push(lua_State* luastate, T const* ptr) { diff --git a/src/LuaEngine/LuaFunctions.cpp b/src/LuaEngine/LuaFunctions.cpp index 9868b756fe..d06586917f 100644 --- a/src/LuaEngine/LuaFunctions.cpp +++ b/src/LuaEngine/LuaFunctions.cpp @@ -41,6 +41,10 @@ extern "C" #include "ItemTemplateMethods.h" #include "RollMethods.h" +// DBCStores includes +#include "GemPropertiesEntryMethods.h" +#include "SpellEntryMethods.h" + luaL_Reg GlobalMethods[] = { // Hooks @@ -160,6 +164,7 @@ luaL_Reg GlobalMethods[] = { "StopGameEvent", &LuaGlobalFunctions::StopGameEvent }, { "HttpRequest", &LuaGlobalFunctions::HttpRequest }, { "SetOwnerHalaa", &LuaGlobalFunctions::SetOwnerHalaa }, + { "LookupEntry", &LuaGlobalFunctions::LookupEntry }, { NULL, NULL } }; @@ -1290,6 +1295,114 @@ ElunaRegister RollMethods[] = { NULL, NULL } }; +ElunaRegister GemPropertiesEntryMethods[] = +{ + // Getters + { "GetId", &LuaGemPropertiesEntry::GetId }, + { "GetSpellItemEnchantement", &LuaGemPropertiesEntry::GetSpellItemEnchantement }, + + { NULL, NULL } +}; + +ElunaRegister SpellEntryMethods[] = +{ + // Getters + { "GetId", &LuaSpellEntry::GetId }, + { "GetCategory", &LuaSpellEntry::GetCategory }, + { "GetDispel", &LuaSpellEntry::GetDispel }, + { "GetMechanic", &LuaSpellEntry::GetMechanic }, + { "GetAttributes", &LuaSpellEntry::GetAttributes }, + { "GetAttributesEx", &LuaSpellEntry::GetAttributesEx }, + { "GetAttributesEx2", &LuaSpellEntry::GetAttributesEx2 }, + { "GetAttributesEx3", &LuaSpellEntry::GetAttributesEx3 }, + { "GetAttributesEx4", &LuaSpellEntry::GetAttributesEx4 }, + { "GetAttributesEx5", &LuaSpellEntry::GetAttributesEx5 }, + { "GetAttributesEx6", &LuaSpellEntry::GetAttributesEx6 }, + { "GetAttributesEx7", &LuaSpellEntry::GetAttributesEx7 }, + { "GetStances", &LuaSpellEntry::GetStances }, + { "GetStancesNot", &LuaSpellEntry::GetStancesNot }, + { "GetTargets", &LuaSpellEntry::GetTargets }, + { "GetTargetCreatureType", &LuaSpellEntry::GetTargetCreatureType }, + { "GetRequiresSpellFocus", &LuaSpellEntry::GetRequiresSpellFocus }, + { "GetFacingCasterFlags", &LuaSpellEntry::GetFacingCasterFlags }, + { "GetCasterAuraState", &LuaSpellEntry::GetCasterAuraState }, + { "GetTargetAuraState", &LuaSpellEntry::GetTargetAuraState }, + { "GetCasterAuraStateNot", &LuaSpellEntry::GetCasterAuraStateNot }, + { "GetTargetAuraStateNot", &LuaSpellEntry::GetTargetAuraStateNot }, + { "GetCasterAuraSpell", &LuaSpellEntry::GetCasterAuraSpell }, + { "GetTargetAuraSpell", &LuaSpellEntry::GetTargetAuraSpell }, + { "GetExcludeCasterAuraSpell", &LuaSpellEntry::GetExcludeCasterAuraSpell }, + { "GetExcludeTargetAuraSpell", &LuaSpellEntry::GetExcludeTargetAuraSpell }, + { "GetCastingTimeIndex", &LuaSpellEntry::GetCastingTimeIndex }, + { "GetRecoveryTime", &LuaSpellEntry::GetRecoveryTime }, + { "GetCategoryRecoveryTime", &LuaSpellEntry::GetCategoryRecoveryTime }, + { "GetInterruptFlags", &LuaSpellEntry::GetInterruptFlags }, + { "GetAuraInterruptFlags", &LuaSpellEntry::GetAuraInterruptFlags }, + { "GetChannelInterruptFlags", &LuaSpellEntry::GetChannelInterruptFlags }, + { "GetProcFlags", &LuaSpellEntry::GetProcFlags }, + { "GetProcChance", &LuaSpellEntry::GetProcChance }, + { "GetProcCharges", &LuaSpellEntry::GetProcCharges }, + { "GetMaxLevel", &LuaSpellEntry::GetMaxLevel }, + { "GetBaseLevel", &LuaSpellEntry::GetBaseLevel }, + { "GetSpellLevel", &LuaSpellEntry::GetSpellLevel }, + { "GetDurationIndex", &LuaSpellEntry::GetDurationIndex }, + { "GetPowerType", &LuaSpellEntry::GetPowerType }, + { "GetManaCost", &LuaSpellEntry::GetManaCost }, + { "GetManaCostPerlevel", &LuaSpellEntry::GetManaCostPerlevel }, + { "GetManaPerSecond", &LuaSpellEntry::GetManaPerSecond }, + { "GetManaPerSecondPerLevel", &LuaSpellEntry::GetManaPerSecondPerLevel }, + { "GetRangeIndex", &LuaSpellEntry::GetRangeIndex }, + { "GetSpeed", &LuaSpellEntry::GetSpeed }, + { "GetStackAmount", &LuaSpellEntry::GetStackAmount }, + { "GetTotem", &LuaSpellEntry::GetTotem }, + { "GetReagent", &LuaSpellEntry::GetReagent }, + { "GetReagentCount", &LuaSpellEntry::GetReagentCount }, + { "GetEquippedItemClass", &LuaSpellEntry::GetEquippedItemClass }, + { "GetEquippedItemSubClassMask", &LuaSpellEntry::GetEquippedItemSubClassMask }, + { "GetEquippedItemInventoryTypeMask", &LuaSpellEntry::GetEquippedItemInventoryTypeMask }, + { "GetEffect", &LuaSpellEntry::GetEffect }, + { "GetEffectDieSides", &LuaSpellEntry::GetEffectDieSides }, + { "GetEffectRealPointsPerLevel", &LuaSpellEntry::GetEffectRealPointsPerLevel }, + { "GetEffectBasePoints", &LuaSpellEntry::GetEffectBasePoints }, + { "GetEffectMechanic", &LuaSpellEntry::GetEffectMechanic }, + { "GetEffectImplicitTargetA", &LuaSpellEntry::GetEffectImplicitTargetA }, + { "GetEffectImplicitTargetB", &LuaSpellEntry::GetEffectImplicitTargetB }, + { "GetEffectRadiusIndex", &LuaSpellEntry::GetEffectRadiusIndex }, + { "GetEffectApplyAuraName", &LuaSpellEntry::GetEffectApplyAuraName }, + { "GetEffectAmplitude", &LuaSpellEntry::GetEffectAmplitude }, + { "GetEffectValueMultiplier", &LuaSpellEntry::GetEffectValueMultiplier }, + { "GetEffectChainTarget", &LuaSpellEntry::GetEffectChainTarget }, + { "GetEffectItemType", &LuaSpellEntry::GetEffectItemType }, + { "GetEffectMiscValue", &LuaSpellEntry::GetEffectMiscValue }, + { "GetEffectMiscValueB", &LuaSpellEntry::GetEffectMiscValueB }, + { "GetEffectTriggerSpell", &LuaSpellEntry::GetEffectTriggerSpell }, + { "GetEffectPointsPerComboPoint", &LuaSpellEntry::GetEffectPointsPerComboPoint }, + { "GetEffectSpellClassMask", &LuaSpellEntry::GetEffectSpellClassMask }, + { "GetSpellVisual", &LuaSpellEntry::GetSpellVisual }, + { "GetSpellIconID", &LuaSpellEntry::GetSpellIconID }, + { "GetActiveIconID", &LuaSpellEntry::GetActiveIconID }, + { "GetSpellPriority", &LuaSpellEntry::GetSpellPriority }, + { "GetSpellName", &LuaSpellEntry::GetSpellName }, + { "GetRank", &LuaSpellEntry::GetRank }, + { "GetManaCostPercentage", &LuaSpellEntry::GetManaCostPercentage }, + { "GetStartRecoveryCategory", &LuaSpellEntry::GetStartRecoveryCategory }, + { "GetStartRecoveryTime", &LuaSpellEntry::GetStartRecoveryTime }, + { "GetMaxTargetLevel", &LuaSpellEntry::GetMaxTargetLevel }, + { "GetSpellFamilyName", &LuaSpellEntry::GetSpellFamilyName }, + { "GetSpellFamilyFlags", &LuaSpellEntry::GetSpellFamilyFlags }, + { "GetMaxAffectedTargets", &LuaSpellEntry::GetMaxAffectedTargets }, + { "GetDmgClass", &LuaSpellEntry::GetDmgClass }, + { "GetPreventionType", &LuaSpellEntry::GetPreventionType }, + { "GetEffectDamageMultiplier", &LuaSpellEntry::GetEffectDamageMultiplier }, + { "GetTotemCategory", &LuaSpellEntry::GetTotemCategory }, + { "GetAreaGroupId", &LuaSpellEntry::GetAreaGroupId }, + { "GetSchoolMask", &LuaSpellEntry::GetSchoolMask }, + { "GetRuneCostID", &LuaSpellEntry::GetRuneCostID }, + { "GetEffectBonusMultiplier", &LuaSpellEntry::GetEffectBonusMultiplier }, + + { NULL, NULL } +}; + // fix compile error about accessing vehicle destructor template<> int ElunaTemplate::CollectGarbage(lua_State* L) { @@ -1435,6 +1548,12 @@ void RegisterFunctions(Eluna* E) ElunaTemplate::Register(E, "Roll"); ElunaTemplate::SetMethods(E, RollMethods); + ElunaTemplate::Register(E, "GemPropertiesEntry"); + ElunaTemplate::SetMethods(E, GemPropertiesEntryMethods); + + ElunaTemplate::Register(E, "SpellEntry"); + ElunaTemplate::SetMethods(E, SpellEntryMethods); + ElunaTemplate::Register(E, "long long", true); ElunaTemplate::Register(E, "unsigned long long", true); diff --git a/src/LuaEngine/methods/GemPropertiesEntryMethods.h b/src/LuaEngine/methods/GemPropertiesEntryMethods.h new file mode 100644 index 0000000000..dc58d50540 --- /dev/null +++ b/src/LuaEngine/methods/GemPropertiesEntryMethods.h @@ -0,0 +1,40 @@ +/* +* Copyright (C) 2010 - 2016 Eluna Lua Engine +* This program is free software licensed under GPL version 3 +* Please see the included DOCS/LICENSE.md for more information +*/ + +#ifndef GEMPROPERTIESENTRYMETHODS_H +#define GEMPROPERTIESENTRYMETHODS_H + +namespace LuaGemPropertiesEntry +{ + + /** + * Returns the ID of a [GemPropertiesEntry]. + * + * This method retrieves the ID from a given GemPropertiesEntry instance + * and pushes it onto the Lua stack. + * + * @return uint32 id : The ID of the specified GemPropertiesEntry. + */ + int GetId(lua_State* L, GemPropertiesEntry* gemProperties) + { + Eluna::Push(L, gemProperties->ID); + return 1; + } + + /** + * Returns the spell item enchantment of a [GemPropertiesEntry]. + * + * This function retrieves the `spellitemenchantement` attribute from the provided `GemPropertiesEntry`. + * + * @return uint32 spellitemenchantement : The spell item enchantment ID. + */ + int GetSpellItemEnchantement(lua_State* L, GemPropertiesEntry* entry) + { + Eluna::Push(L, entry->spellitemenchantement); + return 1; + } +} +#endif diff --git a/src/LuaEngine/methods/GlobalMethods.h b/src/LuaEngine/methods/GlobalMethods.h index d1f29f3e24..13007c4c0e 100644 --- a/src/LuaEngine/methods/GlobalMethods.h +++ b/src/LuaEngine/methods/GlobalMethods.h @@ -8,6 +8,7 @@ #define GLOBALMETHODS_H #include "BindingMap.h" +#include "ElunaDBCRegistry.h" #include "BanMgr.h" #include "GameTime.h" @@ -15,6 +16,7 @@ #include "OutdoorPvPMgr.h" #include "../../../../src/server/scripts/OutdoorPvP/OutdoorPvPNA.h" + enum BanMode { BAN_ACCOUNT = 1, @@ -3143,5 +3145,37 @@ namespace LuaGlobalFunctions return 0; } + + /** + * Returns the instance of the specified DBC (DatabaseClient) store. + * + * This function retrieves the DBC store associated with the provided name + * and pushes it onto the Lua stack. + * + * @param const char* dbcName : The name of the DBC store to retrieve. + * @param uint32 id : The ID used to look up within the specified DBC store. + * + * @return [DBCStore] store : The requested DBC store instance. + */ + int LookupEntry(lua_State* L) + { + const char* dbcName = Eluna::CHECKVAL(L, 1); + uint32 id = Eluna::CHECKVAL(L, 2); + + for (const auto& dbc : dbcRegistry) + { + if (dbc.name == dbcName) + { + const void* entry = dbc.lookupFunction(id); + if (!entry) + return 0; + + dbc.pushFunction(L, entry); + return 1; + } + } + + return luaL_error(L, "Invalid DBC name: %s", dbcName); + } } #endif diff --git a/src/LuaEngine/methods/SpellEntryMethods.h b/src/LuaEngine/methods/SpellEntryMethods.h new file mode 100644 index 0000000000..d5f6c540a2 --- /dev/null +++ b/src/LuaEngine/methods/SpellEntryMethods.h @@ -0,0 +1,700 @@ +/* +* Copyright (C) 2010 - 2016 Eluna Lua Engine +* This program is free software licensed under GPL version 3 +* Please see the included DOCS/LICENSE.md for more information +*/ + +#ifndef SPELLENTRYMETHODS_H +#define SPELLENTRYMETHODS_H + +namespace LuaSpellEntry +{ + int GetId(lua_State* L, SpellEntry* entry) + { + Eluna::Push(L, entry->Id); + return 1; + } + + int GetCategory(lua_State* L, SpellEntry* entry) + { + Eluna::Push(L, entry->Category); + return 1; + } + + int GetDispel(lua_State* L, SpellEntry* entry) + { + Eluna::Push(L, entry->Dispel); + return 1; + } + + int GetMechanic(lua_State* L, SpellEntry* entry) + { + Eluna::Push(L, entry->Mechanic); + return 1; + } + + int GetAttributes(lua_State* L, SpellEntry* entry) + { + Eluna::Push(L, entry->Attributes); + return 1; + } + + int GetAttributesEx(lua_State* L, SpellEntry* entry) + { + Eluna::Push(L, entry->AttributesEx); + return 1; + } + + int GetAttributesEx2(lua_State* L, SpellEntry* entry) + { + Eluna::Push(L, entry->AttributesEx2); + return 1; + } + + int GetAttributesEx3(lua_State* L, SpellEntry* entry) + { + Eluna::Push(L, entry->AttributesEx3); + return 1; + } + + int GetAttributesEx4(lua_State* L, SpellEntry* entry) + { + Eluna::Push(L, entry->AttributesEx4); + return 1; + } + + int GetAttributesEx5(lua_State* L, SpellEntry* entry) + { + Eluna::Push(L, entry->AttributesEx5); + return 1; + } + + int GetAttributesEx6(lua_State* L, SpellEntry* entry) + { + Eluna::Push(L, entry->AttributesEx6); + return 1; + } + + int GetAttributesEx7(lua_State* L, SpellEntry* entry) + { + Eluna::Push(L, entry->AttributesEx7); + return 1; + } + + int GetStances(lua_State* L, SpellEntry* entry) + { + Eluna::Push(L, entry->Stances); + return 1; + } + + int GetStancesNot(lua_State* L, SpellEntry* entry) + { + Eluna::Push(L, entry->StancesNot); + return 1; + } + + int GetTargets(lua_State* L, SpellEntry* entry) + { + Eluna::Push(L, entry->Targets); + return 1; + } + + int GetTargetCreatureType(lua_State* L, SpellEntry* entry) + { + Eluna::Push(L, entry->TargetCreatureType); + return 1; + } + + int GetRequiresSpellFocus(lua_State* L, SpellEntry* entry) + { + Eluna::Push(L, entry->RequiresSpellFocus); + return 1; + } + + int GetFacingCasterFlags(lua_State* L, SpellEntry* entry) + { + Eluna::Push(L, entry->FacingCasterFlags); + return 1; + } + + int GetCasterAuraState(lua_State* L, SpellEntry* entry) + { + Eluna::Push(L, entry->CasterAuraState); + return 1; + } + + int GetTargetAuraState(lua_State* L, SpellEntry* entry) + { + Eluna::Push(L, entry->TargetAuraState); + return 1; + } + + int GetCasterAuraStateNot(lua_State* L, SpellEntry* entry) + { + Eluna::Push(L, entry->CasterAuraStateNot); + return 1; + } + + int GetTargetAuraStateNot(lua_State* L, SpellEntry* entry) + { + Eluna::Push(L, entry->TargetAuraStateNot); + return 1; + } + + int GetCasterAuraSpell(lua_State* L, SpellEntry* entry) + { + Eluna::Push(L, entry->CasterAuraSpell); + return 1; + } + + int GetTargetAuraSpell(lua_State* L, SpellEntry* entry) + { + Eluna::Push(L, entry->TargetAuraSpell); + return 1; + } + + int GetExcludeCasterAuraSpell(lua_State* L, SpellEntry* entry) + { + Eluna::Push(L, entry->ExcludeCasterAuraSpell); + return 1; + } + + int GetExcludeTargetAuraSpell(lua_State* L, SpellEntry* entry) + { + Eluna::Push(L, entry->ExcludeTargetAuraSpell); + return 1; + } + + int GetCastingTimeIndex(lua_State* L, SpellEntry* entry) + { + Eluna::Push(L, entry->CastingTimeIndex); + return 1; + } + + int GetRecoveryTime(lua_State* L, SpellEntry* entry) + { + Eluna::Push(L, entry->RecoveryTime); + return 1; + } + + int GetCategoryRecoveryTime(lua_State* L, SpellEntry* entry) + { + Eluna::Push(L, entry->CategoryRecoveryTime); + return 1; + } + + int GetInterruptFlags(lua_State* L, SpellEntry* entry) + { + Eluna::Push(L, entry->InterruptFlags); + return 1; + } + + int GetAuraInterruptFlags(lua_State* L, SpellEntry* entry) + { + Eluna::Push(L, entry->AuraInterruptFlags); + return 1; + } + + int GetChannelInterruptFlags(lua_State* L, SpellEntry* entry) + { + Eluna::Push(L, entry->ChannelInterruptFlags); + return 1; + } + + int GetProcFlags(lua_State* L, SpellEntry* entry) + { + Eluna::Push(L, entry->ProcFlags); + return 1; + } + + int GetProcChance(lua_State* L, SpellEntry* entry) + { + Eluna::Push(L, entry->ProcChance); + return 1; + } + + int GetProcCharges(lua_State* L, SpellEntry* entry) + { + Eluna::Push(L, entry->ProcCharges); + return 1; + } + + int GetMaxLevel(lua_State* L, SpellEntry* entry) + { + Eluna::Push(L, entry->MaxLevel); + return 1; + } + + int GetBaseLevel(lua_State* L, SpellEntry* entry) + { + Eluna::Push(L, entry->BaseLevel); + return 1; + } + + int GetSpellLevel(lua_State* L, SpellEntry* entry) + { + Eluna::Push(L, entry->SpellLevel); + return 1; + } + + int GetDurationIndex(lua_State* L, SpellEntry* entry) + { + Eluna::Push(L, entry->DurationIndex); + return 1; + } + + int GetPowerType(lua_State* L, SpellEntry* entry) + { + Eluna::Push(L, entry->PowerType); + return 1; + } + + int GetManaCost(lua_State* L, SpellEntry* entry) + { + Eluna::Push(L, entry->ManaCost); + return 1; + } + + int GetManaCostPerlevel(lua_State* L, SpellEntry* entry) + { + Eluna::Push(L, entry->ManaCostPerlevel); + return 1; + } + + int GetManaPerSecond(lua_State* L, SpellEntry* entry) + { + Eluna::Push(L, entry->ManaPerSecond); + return 1; + } + + int GetManaPerSecondPerLevel(lua_State* L, SpellEntry* entry) + { + Eluna::Push(L, entry->ManaPerSecondPerLevel); + return 1; + } + + int GetRangeIndex(lua_State* L, SpellEntry* entry) + { + Eluna::Push(L, entry->RangeIndex); + return 1; + } + + int GetSpeed(lua_State* L, SpellEntry* entry) + { + Eluna::Push(L, entry->Speed); + return 1; + } + + int GetStackAmount(lua_State* L, SpellEntry* entry) + { + Eluna::Push(L, entry->StackAmount); + return 1; + } + + int GetTotem(lua_State* L, SpellEntry* entry) + { + lua_newtable(L); + for (size_t i = 0; i < entry->Totem.size(); ++i) + { + Eluna::Push(L, entry->Totem[i]); + lua_rawseti(L, -2, i + 1); + } + return 1; + } + + int GetReagent(lua_State* L, SpellEntry* entry) + { + lua_newtable(L); + for (size_t i = 0; i < entry->Reagent.size(); ++i) + { + Eluna::Push(L, entry->Reagent[i]); + lua_rawseti(L, -2, i + 1); + } + return 1; + } + + int GetReagentCount(lua_State* L, SpellEntry* entry) + { + lua_newtable(L); + for (size_t i = 0; i < entry->ReagentCount.size(); ++i) + { + Eluna::Push(L, entry->ReagentCount[i]); + lua_rawseti(L, -2, i + 1); + } + return 1; + } + + int GetEquippedItemClass(lua_State* L, SpellEntry* entry) + { + Eluna::Push(L, entry->EquippedItemClass); + return 1; + } + + int GetEquippedItemSubClassMask(lua_State* L, SpellEntry* entry) + { + Eluna::Push(L, entry->EquippedItemSubClassMask); + return 1; + } + + int GetEquippedItemInventoryTypeMask(lua_State* L, SpellEntry* entry) + { + Eluna::Push(L, entry->EquippedItemInventoryTypeMask); + return 1; + } + + int GetEffect(lua_State* L, SpellEntry* entry) + { + lua_newtable(L); + for (size_t i = 0; i < entry->Effect.size(); ++i) + { + Eluna::Push(L, entry->Effect[i]); + lua_rawseti(L, -2, i + 1); + } + return 1; + } + + int GetEffectDieSides(lua_State* L, SpellEntry* entry) + { + lua_newtable(L); + for (size_t i = 0; i < entry->EffectDieSides.size(); ++i) + { + Eluna::Push(L, entry->EffectDieSides[i]); + lua_rawseti(L, -2, i + 1); + } + return 1; + } + + int GetEffectRealPointsPerLevel(lua_State* L, SpellEntry* entry) + { + lua_newtable(L); + for (size_t i = 0; i < entry->EffectRealPointsPerLevel.size(); ++i) + { + Eluna::Push(L, entry->EffectRealPointsPerLevel[i]); + lua_rawseti(L, -2, i + 1); + } + return 1; + } + + int GetEffectBasePoints(lua_State* L, SpellEntry* entry) + { + lua_newtable(L); + for (size_t i = 0; i < entry->EffectBasePoints.size(); ++i) + { + Eluna::Push(L, entry->EffectBasePoints[i]); + lua_rawseti(L, -2, i + 1); + } + return 1; + } + + int GetEffectMechanic(lua_State* L, SpellEntry* entry) + { + lua_newtable(L); + for (size_t i = 0; i < entry->EffectMechanic.size(); ++i) + { + Eluna::Push(L, entry->EffectMechanic[i]); + lua_rawseti(L, -2, i + 1); + } + return 1; + } + + int GetEffectImplicitTargetA(lua_State* L, SpellEntry* entry) + { + lua_newtable(L); + for (size_t i = 0; i < entry->EffectImplicitTargetA.size(); ++i) + { + Eluna::Push(L, entry->EffectImplicitTargetA[i]); + lua_rawseti(L, -2, i + 1); + } + return 1; + } + + int GetEffectImplicitTargetB(lua_State* L, SpellEntry* entry) + { + lua_newtable(L); + for (size_t i = 0; i < entry->EffectImplicitTargetB.size(); ++i) + { + Eluna::Push(L, entry->EffectImplicitTargetB[i]); + lua_rawseti(L, -2, i + 1); + } + return 1; + } + + int GetEffectRadiusIndex(lua_State* L, SpellEntry* entry) + { + lua_newtable(L); + for (size_t i = 0; i < entry->EffectRadiusIndex.size(); ++i) + { + Eluna::Push(L, entry->EffectRadiusIndex[i]); + lua_rawseti(L, -2, i + 1); + } + return 1; + } + + int GetEffectApplyAuraName(lua_State* L, SpellEntry* entry) + { + lua_newtable(L); + for (size_t i = 0; i < entry->EffectApplyAuraName.size(); ++i) + { + Eluna::Push(L, entry->EffectApplyAuraName[i]); + lua_rawseti(L, -2, i + 1); + } + return 1; + } + + int GetEffectAmplitude(lua_State* L, SpellEntry* entry) + { + lua_newtable(L); + for (size_t i = 0; i < entry->EffectAmplitude.size(); ++i) + { + Eluna::Push(L, entry->EffectAmplitude[i]); + lua_rawseti(L, -2, i + 1); + } + return 1; + } + + int GetEffectValueMultiplier(lua_State* L, SpellEntry* entry) + { + lua_newtable(L); + for (size_t i = 0; i < entry->EffectValueMultiplier.size(); ++i) + { + Eluna::Push(L, entry->EffectValueMultiplier[i]); + lua_rawseti(L, -2, i + 1); + } + return 1; + } + + int GetEffectChainTarget(lua_State* L, SpellEntry* entry) + { + lua_newtable(L); + for (size_t i = 0; i < entry->EffectChainTarget.size(); ++i) + { + Eluna::Push(L, entry->EffectChainTarget[i]); + lua_rawseti(L, -2, i + 1); + } + return 1; + } + + int GetEffectItemType(lua_State* L, SpellEntry* entry) + { + lua_newtable(L); + for (size_t i = 0; i < entry->EffectItemType.size(); ++i) + { + Eluna::Push(L, entry->EffectItemType[i]); + lua_rawseti(L, -2, i + 1); + } + return 1; + } + + int GetEffectMiscValue(lua_State* L, SpellEntry* entry) + { + lua_newtable(L); + for (size_t i = 0; i < entry->EffectMiscValue.size(); ++i) + { + Eluna::Push(L, entry->EffectMiscValue[i]); + lua_rawseti(L, -2, i + 1); + } + return 1; + } + + int GetEffectMiscValueB(lua_State* L, SpellEntry* entry) + { + lua_newtable(L); + for (size_t i = 0; i < entry->EffectMiscValueB.size(); ++i) + { + Eluna::Push(L, entry->EffectMiscValueB[i]); + lua_rawseti(L, -2, i + 1); + } + return 1; + } + + int GetEffectTriggerSpell(lua_State* L, SpellEntry* entry) + { + lua_newtable(L); + for (size_t i = 0; i < entry->EffectTriggerSpell.size(); ++i) + { + Eluna::Push(L, entry->EffectTriggerSpell[i]); + lua_rawseti(L, -2, i + 1); + } + return 1; + } + + int GetEffectPointsPerComboPoint(lua_State* L, SpellEntry* entry) + { + lua_newtable(L); + for (size_t i = 0; i < entry->EffectPointsPerComboPoint.size(); ++i) + { + Eluna::Push(L, entry->EffectPointsPerComboPoint[i]); + lua_rawseti(L, -2, i + 1); + } + return 1; + } + + int GetEffectSpellClassMask(lua_State* L, SpellEntry* entry) + { + lua_newtable(L); + for (size_t i = 0; i < entry->EffectSpellClassMask.size(); ++i) + { + Eluna::Push(L, entry->EffectSpellClassMask[i]); + lua_rawseti(L, -2, i + 1); + } + return 1; + } + + int GetSpellVisual(lua_State* L, SpellEntry* entry) + { + lua_newtable(L); + for (size_t i = 0; i < entry->SpellVisual.size(); ++i) + { + Eluna::Push(L, entry->SpellVisual[i]); + lua_rawseti(L, -2, i + 1); + } + return 1; + } + + int GetSpellIconID(lua_State* L, SpellEntry* entry) + { + Eluna::Push(L, entry->SpellIconID); + return 1; + } + + int GetActiveIconID(lua_State* L, SpellEntry* entry) + { + Eluna::Push(L, entry->ActiveIconID); + return 1; + } + + int GetSpellPriority(lua_State* L, SpellEntry* entry) + { + Eluna::Push(L, entry->SpellPriority); + return 1; + } + + int GetSpellName(lua_State* L, SpellEntry* entry) + { + lua_newtable(L); + for (size_t i = 0; i < entry->SpellName.size(); ++i) + { + Eluna::Push(L, entry->SpellName[i]); + lua_rawseti(L, -2, i + 1); + } + return 1; + } + + int GetRank(lua_State* L, SpellEntry* entry) + { + lua_newtable(L); + for (size_t i = 0; i < entry->Rank.size(); ++i) + { + Eluna::Push(L, entry->Rank[i]); + lua_rawseti(L, -2, i + 1); + } + return 1; + } + + int GetManaCostPercentage(lua_State* L, SpellEntry* entry) + { + Eluna::Push(L, entry->ManaCostPercentage); + return 1; + } + + int GetStartRecoveryCategory(lua_State* L, SpellEntry* entry) + { + Eluna::Push(L, entry->StartRecoveryCategory); + return 1; + } + + int GetStartRecoveryTime(lua_State* L, SpellEntry* entry) + { + Eluna::Push(L, entry->StartRecoveryTime); + return 1; + } + + int GetMaxTargetLevel(lua_State* L, SpellEntry* entry) + { + Eluna::Push(L, entry->MaxTargetLevel); + return 1; + } + + int GetSpellFamilyName(lua_State* L, SpellEntry* entry) + { + Eluna::Push(L, entry->SpellFamilyName); + return 1; + } + + int GetSpellFamilyFlags(lua_State* L, SpellEntry* entry) + { + Eluna::Push(L, entry->SpellFamilyFlags); + return 1; + } + + int GetMaxAffectedTargets(lua_State* L, SpellEntry* entry) + { + Eluna::Push(L, entry->MaxAffectedTargets); + return 1; + } + + int GetDmgClass(lua_State* L, SpellEntry* entry) + { + Eluna::Push(L, entry->DmgClass); + return 1; + } + + int GetPreventionType(lua_State* L, SpellEntry* entry) + { + Eluna::Push(L, entry->PreventionType); + return 1; + } + + int GetEffectDamageMultiplier(lua_State* L, SpellEntry* entry) + { + lua_newtable(L); + for (size_t i = 0; i < entry->EffectDamageMultiplier.size(); ++i) + { + Eluna::Push(L, entry->EffectDamageMultiplier[i]); + lua_rawseti(L, -2, i + 1); + } + return 1; + } + + int GetTotemCategory(lua_State* L, SpellEntry* entry) + { + lua_newtable(L); + for (size_t i = 0; i < entry->TotemCategory.size(); ++i) + { + Eluna::Push(L, entry->TotemCategory[i]); + lua_rawseti(L, -2, i + 1); + } + return 1; + } + + int GetAreaGroupId(lua_State* L, SpellEntry* entry) + { + Eluna::Push(L, entry->AreaGroupId); + return 1; + } + + int GetSchoolMask(lua_State* L, SpellEntry* entry) + { + Eluna::Push(L, entry->SchoolMask); + return 1; + } + + int GetRuneCostID(lua_State* L, SpellEntry* entry) + { + Eluna::Push(L, entry->RuneCostID); + return 1; + } + + int GetEffectBonusMultiplier(lua_State* L, SpellEntry* entry) + { + lua_newtable(L); + for (size_t i = 0; i < entry->EffectBonusMultiplier.size(); ++i) + { + Eluna::Push(L, entry->EffectBonusMultiplier[i]); + lua_rawseti(L, -2, i + 1); + } + return 1; + } +} + +#endif