mirror of
https://github.com/EQEmu/Server.git
synced 2026-06-10 02:31:03 +00:00
[Quest API] Add corpse->GetLootList() and npc->GetLootList() to Perl and Lua. (#1529)
* [Quest API] Add corpse->GetLootList() and npc->GetLootList() to Perl and Lua. - Add $corpse->GetLootList() to Perl. - Add $npc->GetLootList() to Perl. - Add corpse:GetLootList() to Lua. - Add npc:GetLootList() to Lua. Returns an array of item IDs for use with corpse and NPC methods such as HasItem(item_id), CountItem(item_id), and GetFirstSlotByItemID(item_id). * Categories. * Modify Lua to use classes.
This commit is contained in:
+24
-1
@@ -2,11 +2,16 @@
|
||||
|
||||
#include "lua.hpp"
|
||||
#include <luabind/luabind.hpp>
|
||||
#include <luabind/iterator_policy.hpp>
|
||||
|
||||
#include "npc.h"
|
||||
#include "lua_npc.h"
|
||||
#include "lua_client.h"
|
||||
|
||||
struct Lua_NPC_Loot_List {
|
||||
std::vector<uint32> entries;
|
||||
};
|
||||
|
||||
void Lua_NPC::Signal(int id) {
|
||||
Lua_Safe_Call_Void();
|
||||
self->SignalNPC(id);
|
||||
@@ -618,6 +623,18 @@ float Lua_NPC::GetSpellScale()
|
||||
return self->GetSpellScale();
|
||||
}
|
||||
|
||||
Lua_NPC_Loot_List Lua_NPC::GetLootList(lua_State* L) {
|
||||
Lua_Safe_Call_Class(Lua_NPC_Loot_List);
|
||||
Lua_NPC_Loot_List ret;
|
||||
auto loot_list = self->GetLootList();
|
||||
|
||||
for (auto item_id : loot_list) {
|
||||
ret.entries.push_back(item_id);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
luabind::scope lua_register_npc() {
|
||||
return luabind::class_<Lua_NPC, Lua_Mob>("NPC")
|
||||
.def(luabind::constructor<>())
|
||||
@@ -740,7 +757,13 @@ luabind::scope lua_register_npc() {
|
||||
.def("GetItemIDBySlot", (uint32(Lua_NPC::*)(uint16))&Lua_NPC::GetItemIDBySlot)
|
||||
.def("GetFirstSlotByItemID", (uint16(Lua_NPC::*)(uint32))&Lua_NPC::GetFirstSlotByItemID)
|
||||
.def("GetHealScale", (float(Lua_NPC::*)(void))&Lua_NPC::GetHealScale)
|
||||
.def("GetSpellScale", (float(Lua_NPC::*)(void))&Lua_NPC::GetSpellScale);
|
||||
.def("GetSpellScale", (float(Lua_NPC::*)(void))&Lua_NPC::GetSpellScale)
|
||||
.def("GetLootList", (Lua_NPC_Loot_List(Lua_NPC::*)(lua_State* L))&Lua_NPC::GetLootList);
|
||||
}
|
||||
|
||||
luabind::scope lua_register_npc_loot_list() {
|
||||
return luabind::class_<Lua_NPC_Loot_List>("NPCLootList")
|
||||
.def_readwrite("entries", &Lua_NPC_Loot_List::entries, luabind::return_stl_iterator);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user