From 13a3afbfac0fb20ebe9cd14e97a0a271511375ec Mon Sep 17 00:00:00 2001 From: Aeadoin <109764533+Aeadoin@users.noreply.github.com> Date: Sun, 11 Dec 2022 16:25:47 -0500 Subject: [PATCH] [Bots] Add Event_Trade Support for ^inventorygive Command (#2628) --- zone/bot.cpp | 44 +++++++++++++++++++++++++++++++------------- 1 file changed, 31 insertions(+), 13 deletions(-) diff --git a/zone/bot.cpp b/zone/bot.cpp index fc446dc54..e1d0e0652 100644 --- a/zone/bot.cpp +++ b/zone/bot.cpp @@ -5108,20 +5108,38 @@ void Bot::PerformTradeWithClient(int16 begin_slot_id, int16 end_slot_id, Client* if (event_trade.size()) { // Get Traded Items - EQ::ItemInstance* insts[8] = { 0 }; - EQ::InventoryProfile& user_inv = client->GetInv(); - for (int i = EQ::invslot::TRADE_BEGIN; i <= EQ::invslot::TRADE_END; ++i) { - insts[i - EQ::invslot::TRADE_BEGIN] = user_inv.GetItem(i); - client->DeleteItemInInventory(i); + + // Accept Items from Cursor to support bot command ^inventorygive + if (begin_slot_id == invslot::slotCursor && end_slot_id == invslot::slotCursor) { + EQ::ItemInstance* insts[1] = { 0 }; + EQ::InventoryProfile& user_inv = client->GetInv(); + insts[0] = user_inv.GetItem(invslot::slotCursor); + client->DeleteItemInInventory(invslot::slotCursor); + + // copy to be filtered by task updates, null trade slots preserved for quest event arg + std::vector items(insts, insts + std::size(insts)); + + // Check if EVENT_TRADE accepts any items + std::vector item_list(items.begin(), items.end()); + parse->EventBot(EVENT_TRADE, this, client, "", 0, &item_list); + CalcBotStats(false); + + } else { + EQ::ItemInstance* insts[8] = { 0 }; + EQ::InventoryProfile& user_inv = client->GetInv(); + for (int i = EQ::invslot::TRADE_BEGIN; i <= EQ::invslot::TRADE_END; ++i) { + insts[i - EQ::invslot::TRADE_BEGIN] = user_inv.GetItem(i); + client->DeleteItemInInventory(i); + } + + // copy to be filtered by task updates, null trade slots preserved for quest event arg + std::vector items(insts, insts + std::size(insts)); + + // Check if EVENT_TRADE accepts any items + std::vector item_list(items.begin(), items.end()); + parse->EventBot(EVENT_TRADE, this, client, "", 0, &item_list); + CalcBotStats(false); } - - // copy to be filtered by task updates, null trade slots preserved for quest event arg - std::vector items(insts, insts + std::size(insts)); - - // Check if EVENT_TRADE accepts any items - std::vector item_list(items.begin(), items.end()); - parse->EventBot(EVENT_TRADE, this, client, "", 0, &item_list); - CalcBotStats(false); } }