mirror of
https://github.com/EQEmu/Server.git
synced 2026-05-17 03:08:26 +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 "corpse.h"
|
||||
#include "lua_corpse.h"
|
||||
#include "lua_client.h"
|
||||
|
||||
struct Lua_Corpse_Loot_List {
|
||||
std::vector<uint32> entries;
|
||||
};
|
||||
|
||||
uint32 Lua_Corpse::GetCharID() {
|
||||
Lua_Safe_Call_Int();
|
||||
return self->GetCharID();
|
||||
@@ -172,6 +177,18 @@ uint16 Lua_Corpse::GetFirstSlotByItemID(uint32 item_id) {
|
||||
return self->GetFirstSlotByItemID(item_id);
|
||||
}
|
||||
|
||||
Lua_Corpse_Loot_List Lua_Corpse::GetLootList(lua_State* L) {
|
||||
Lua_Safe_Call_Class(Lua_Corpse_Loot_List);
|
||||
Lua_Corpse_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_corpse() {
|
||||
return luabind::class_<Lua_Corpse, Lua_Mob>("Corpse")
|
||||
.def(luabind::constructor<>())
|
||||
@@ -209,7 +226,13 @@ luabind::scope lua_register_corpse() {
|
||||
.def("HasItem", (bool(Lua_Corpse::*)(uint32))&Lua_Corpse::HasItem)
|
||||
.def("CountItem", (uint16(Lua_Corpse::*)(uint32))&Lua_Corpse::CountItem)
|
||||
.def("GetItemIDBySlot", (uint32(Lua_Corpse::*)(uint16))&Lua_Corpse::GetItemIDBySlot)
|
||||
.def("GetFirstSlotByItemID", (uint16(Lua_Corpse::*)(uint32))&Lua_Corpse::GetFirstSlotByItemID);
|
||||
.def("GetFirstSlotByItemID", (uint16(Lua_Corpse::*)(uint32))&Lua_Corpse::GetFirstSlotByItemID)
|
||||
.def("GetLootList", (Lua_Corpse_Loot_List(Lua_Corpse::*)(lua_State* L))&Lua_Corpse::GetLootList);
|
||||
}
|
||||
|
||||
luabind::scope lua_register_corpse_loot_list() {
|
||||
return luabind::class_<Lua_Corpse_Loot_List>("CorpseLootList")
|
||||
.def_readwrite("entries", &Lua_Corpse_Loot_List::entries, luabind::return_stl_iterator);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user