good afternoon otland community I have a problem with my auto loot system it collects all the objects, the only object that allows me to separate it to a separate backpack is gold and the other objects go to another backpack that I select, I would like to create a filter that can be enabled and disabled by category. example that by means of a command the armor category can be enabled and disabled and that another example cannot be batched all the valuavles as the pearls objects of addons can also be enabled and disabled
My knowledge in c ++ in very little and what I have achieved is this by being able to separate the gold from the other objects but more than trying to separate the rest it does not leave it, and as I say I would like to make a filter that where you can enable and disable portfolios so you can't collect all the monster loot
Sorry my English is an insult to you, I only speak Spanish if someone could help me in that
Thanks I hope your prompt response
My knowledge in c ++ in very little and what I have achieved is this by being able to separate the gold from the other objects but more than trying to separate the rest it does not leave it, and as I say I would like to make a filter that where you can enable and disable portfolios so you can't collect all the monster loot
Sorry my English is an insult to you, I only speak Spanish if someone could help me in that
Lua:
void Player::lootCorpse(Container* container)
{
if (!container) {
return;
}
uint32_t corpseOwner = container->getCorpseOwner();
if (corpseOwner != 0 && !canOpenCorpse(corpseOwner)) {
return sendCancelMessage(RETURNVALUE_YOUARENOTTHEOWNER);
}
uint16_t category = 0;
uint16_t bpToLoot = 0;
std::vector<std::pair<Item*, uint16_t>> itemList;
for (ContainerIterator it = container->iterator(); it.hasNext(); it.advance()) {
Item* item = *it;
if (!item) {
return;
}
itemList.push_back(std::make_pair(item, item->getItemCount()));
}
std::vector<std::pair<Item*, uint16_t>> toMove;
for (const auto& lists : itemList) {
for (const auto& sit : quickLootInfo) {
bpToLoot = sit.first;
category = sit.second;
if (lists.first->getWorth() > 0) {
category = 0;
}
//first filter
if (category == lists.first->getMarketCategory()) { //move to each category
toMove.push_back(std::make_pair(lists.first, category == BP_UNASSIGNED_LOOT ? 0 : bpToLoot)); // move to bp
}
filterLoot(toMove);
}
toMove.push_back(std::make_pair(lists.first, category == BP_UNASSIGNED_LOOT ? 0 : bpToLoot)); // move to main bp
filterLoot(toMove);
}
std::vector<std::pair<std::string, uint16_t>> listItems;
for (const auto& loot : toMove) {
Item* itemLooted = loot.first;
Item* backpack = loot.second == 0 ? inventory[CONST_SLOT_BACKPACK] : findNonEmptyContainer(loot.second);
if (!backpack) {
continue;
}
if (!hasCapacity(itemLooted, itemLooted->getItemCount())) {
sendTextMessage(MESSAGE_STATUS_WARNING, "Attention! The loot you are trying to pick up is too heavy for you to carry.");
return;
}
ReturnValue ret = g_game.internalMoveItem(container, backpack->getContainer(), INDEX_WHEREEVER, itemLooted, itemLooted->getItemCount(), nullptr, 0, this);
if (ret != RETURNVALUE_NOERROR) {
listItems.push_back(std::make_pair(itemLooted->getWorth() > 0 ? itemLooted->getNameDescription() : "", itemLooted->getItemCount())); //esse loop ta mandando 2x entao na gambiarra deixa dividir la em baixo até fixar
}
}
std::ostringstream ss;
std::string lootMsg;
bool setedMsg = false;
if (listItems.size() == 0) {
ss << "No loot.";
setedMsg = true;
} else {
ss << "You looted ";
}
for (const auto& cid : listItems) {
lootMsg = cid.first;
if (!lootMsg.empty()) {
lootMsg = "gold";
}
if (lootMsg != "" && (listItems.size()) > 0 && setedMsg == false) {
ss << cid.second << " " << lootMsg << " and items.";
setedMsg = true;
} else if (lootMsg.empty() && listItems.size() > 0 && setedMsg == false) {
ss << "some item.";
setedMsg = true;
}
}
sendTextMessage(MESSAGE_EVENT_DEFAULT, ss.str());
}
Thanks I hope your prompt response