mirror of
https://github.com/azerothcore/mod-ale
synced 2025-11-29 15:38:17 +08:00
feat: Add Spell:GetReagentCost() function (#165)
This commit is contained in:
@@ -1085,6 +1085,7 @@ ElunaRegister<Spell> SpellMethods[] =
|
||||
{ "GetEntry", &LuaSpell::GetEntry },
|
||||
{ "GetDuration", &LuaSpell::GetDuration },
|
||||
{ "GetPowerCost", &LuaSpell::GetPowerCost },
|
||||
{ "GetReagentCost", &LuaSpell::GetReagentCost },
|
||||
{ "GetTargetDest", &LuaSpell::GetTargetDest },
|
||||
{ "GetTarget", &LuaSpell::GetTarget },
|
||||
|
||||
|
||||
@@ -69,6 +69,30 @@ namespace LuaSpell
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the reagents needed for the [Spell].
|
||||
*
|
||||
* @return table reagents : a table containing the [ItemTemplate]s and amount of reagents needed for the [Spell]
|
||||
*/
|
||||
int GetReagentCost(lua_State* L, Spell* spell)
|
||||
{
|
||||
auto spellInfo = spell->GetSpellInfo();
|
||||
auto reagents = spellInfo->Reagent;
|
||||
auto reagentCounts = spellInfo->ReagentCount;
|
||||
lua_newtable(L);
|
||||
for (auto i = 0; i < MAX_SPELL_REAGENTS; ++i)
|
||||
{
|
||||
if (reagents[i] <= 0)
|
||||
continue;
|
||||
auto reagent = eObjectMgr->GetItemTemplate(reagents[i]);
|
||||
auto count = reagentCounts[i];
|
||||
Eluna::Push(L, reagent);
|
||||
Eluna::Push(L, count);
|
||||
lua_settable(L, -3);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the spell duration of the [Spell].
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user