mirror of
https://github.com/EQEmu/Server.git
synced 2026-06-11 03:31:08 +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:
+22
-4
@@ -1462,12 +1462,12 @@ bool Corpse::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("Corpse::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("Corpse::HasItem() - Database error, invalid item");
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -1487,12 +1487,12 @@ uint16 Corpse::CountItem(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("Corpse::CountItem() - ItemList error, null item");
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!loot_item->item_id || !database.GetItem(loot_item->item_id)) {
|
||||
LogError("NPC::CountItem() - Database error, invalid item");
|
||||
LogError("Corpse::CountItem() - Database error, invalid item");
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -1747,3 +1747,21 @@ bool Corpse::MovePlayerCorpseToNonInstance()
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
std::vector<int> Corpse::GetLootList() {
|
||||
std::vector<int> corpse_items;
|
||||
for (auto current_item = itemlist.begin(); current_item != itemlist.end(); ++current_item) {
|
||||
ServerLootItem_Struct* loot_item = *current_item;
|
||||
if (!loot_item) {
|
||||
LogError("Corpse::GetLootList() - ItemList error, null item");
|
||||
continue;
|
||||
}
|
||||
|
||||
if (std::find(corpse_items.begin(), corpse_items.end(), loot_item->item_id) != corpse_items.end()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
corpse_items.push_back(loot_item->item_id);
|
||||
}
|
||||
return corpse_items;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user