mirror of
https://github.com/mod-playerbots/mod-playerbots.git
synced 2026-02-03 19:03:49 +00:00
[HOT FIX] MS build issues regarding folder / command lenght usage or rc.exe (#2038)
This commit is contained in:
41
src/Ai/Base/Actions/OpenItemAction.cpp
Normal file
41
src/Ai/Base/Actions/OpenItemAction.cpp
Normal file
@@ -0,0 +1,41 @@
|
||||
#include "OpenItemAction.h"
|
||||
#include "PlayerbotAI.h"
|
||||
#include "ItemTemplate.h"
|
||||
#include "WorldPacket.h"
|
||||
#include "Player.h"
|
||||
#include "ObjectMgr.h"
|
||||
#include "LootObjectStack.h"
|
||||
#include "AiObjectContext.h"
|
||||
|
||||
bool OpenItemAction::Execute(Event event)
|
||||
{
|
||||
bool foundOpenable = false;
|
||||
|
||||
Item* item = botAI->FindOpenableItem();
|
||||
if (item)
|
||||
{
|
||||
uint8 bag = item->GetBagSlot(); // Retrieves the bag slot (0 for main inventory)
|
||||
uint8 slot = item->GetSlot(); // Retrieves the actual slot inside the bag
|
||||
|
||||
OpenItem(item, bag, slot);
|
||||
foundOpenable = true;
|
||||
}
|
||||
|
||||
return foundOpenable;
|
||||
}
|
||||
|
||||
void OpenItemAction::OpenItem(Item* item, uint8 bag, uint8 slot)
|
||||
{
|
||||
WorldPacket packet(CMSG_OPEN_ITEM);
|
||||
packet << bag << slot;
|
||||
bot->GetSession()->HandleOpenItemOpcode(packet);
|
||||
|
||||
// Store the item GUID as the loot target
|
||||
LootObject lootObject;
|
||||
lootObject.guid = item->GetGUID();
|
||||
botAI->GetAiObjectContext()->GetValue<LootObject>("loot target")->Set(lootObject);
|
||||
|
||||
std::ostringstream out;
|
||||
out << "Opened item: " << item->GetTemplate()->Name1;
|
||||
botAI->TellMaster(out.str());
|
||||
}
|
||||
Reference in New Issue
Block a user