mirror of
https://github.com/EQEmu/Server.git
synced 2026-06-11 15:58:36 +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:
+20
-2
@@ -682,12 +682,12 @@ bool NPC::HasItem(uint32 item_id) {
|
||||
for (auto current_item = itemlist.begin(); current_item != itemlist.end(); ++current_item) {
|
||||
ServerLootItem_Struct* loot_item = *current_item;
|
||||
if (!loot_item) {
|
||||
LogError("NPC::CountItem() - ItemList error, null item");
|
||||
LogError("NPC::HasItem() - ItemList error, null item");
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!loot_item->item_id || !database.GetItem(loot_item->item_id)) {
|
||||
LogError("NPC::CountItem() - Database error, invalid item");
|
||||
LogError("NPC::HasItem() - Database error, invalid item");
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -3474,3 +3474,21 @@ bool NPC::IsGuard()
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
std::vector<int> NPC::GetLootList() {
|
||||
std::vector<int> npc_items;
|
||||
for (auto current_item = itemlist.begin(); current_item != itemlist.end(); ++current_item) {
|
||||
ServerLootItem_Struct* loot_item = *current_item;
|
||||
if (!loot_item) {
|
||||
LogError("NPC::GetLootList() - ItemList error, null item");
|
||||
continue;
|
||||
}
|
||||
|
||||
if (std::find(npc_items.begin(), npc_items.end(), loot_item->item_id) != npc_items.end()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
npc_items.push_back(loot_item->item_id);
|
||||
}
|
||||
return npc_items;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user