mirror of
https://github.com/mod-playerbots/mod-playerbots
synced 2025-11-29 15:58:20 +08:00
Core update item packets (#1624)
This commit is contained in:
@@ -40,6 +40,7 @@
|
|||||||
#include "StatsWeightCalculator.h"
|
#include "StatsWeightCalculator.h"
|
||||||
#include "World.h"
|
#include "World.h"
|
||||||
#include "AiObjectContext.h"
|
#include "AiObjectContext.h"
|
||||||
|
#include "ItemPackets.h"
|
||||||
|
|
||||||
const uint64 diveMask = (1LL << 7) | (1LL << 44) | (1LL << 37) | (1LL << 38) | (1LL << 26) | (1LL << 30) | (1LL << 27) |
|
const uint64 diveMask = (1LL << 7) | (1LL << 44) | (1LL << 37) | (1LL << 38) | (1LL << 26) | (1LL << 30) | (1LL << 27) |
|
||||||
(1LL << 33) | (1LL << 24) | (1LL << 34);
|
(1LL << 33) | (1LL << 24) | (1LL << 34);
|
||||||
@@ -1899,7 +1900,9 @@ void PlayerbotFactory::InitEquipment(bool incremental, bool second_chance)
|
|||||||
|
|
||||||
WorldPacket packet(CMSG_AUTOSTORE_BAG_ITEM, 3);
|
WorldPacket packet(CMSG_AUTOSTORE_BAG_ITEM, 3);
|
||||||
packet << bagIndex << slot << dstBag;
|
packet << bagIndex << slot << dstBag;
|
||||||
bot->GetSession()->HandleAutoStoreBagItemOpcode(packet);
|
WorldPackets::Item::AutoStoreBagItem nicePacket(std::move(packet));
|
||||||
|
nicePacket.Read();
|
||||||
|
bot->GetSession()->HandleAutoStoreBagItemOpcode(nicePacket);
|
||||||
}
|
}
|
||||||
|
|
||||||
oldItem = bot->GetItemByPos(INVENTORY_SLOT_BAG_0, slot);
|
oldItem = bot->GetItemByPos(INVENTORY_SLOT_BAG_0, slot);
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "EquipAction.h"
|
#include "EquipAction.h"
|
||||||
|
#include <utility>
|
||||||
|
|
||||||
#include "Event.h"
|
#include "Event.h"
|
||||||
#include "ItemCountValue.h"
|
#include "ItemCountValue.h"
|
||||||
@@ -11,6 +12,7 @@
|
|||||||
#include "ItemVisitors.h"
|
#include "ItemVisitors.h"
|
||||||
#include "Playerbots.h"
|
#include "Playerbots.h"
|
||||||
#include "StatsWeightCalculator.h"
|
#include "StatsWeightCalculator.h"
|
||||||
|
#include "ItemPackets.h"
|
||||||
|
|
||||||
bool EquipAction::Execute(Event event)
|
bool EquipAction::Execute(Event event)
|
||||||
{
|
{
|
||||||
@@ -104,7 +106,10 @@ void EquipAction::EquipItem(Item* item)
|
|||||||
WorldPacket packet(CMSG_AUTOEQUIP_ITEM_SLOT, 2);
|
WorldPacket packet(CMSG_AUTOEQUIP_ITEM_SLOT, 2);
|
||||||
ObjectGuid itemguid = item->GetGUID();
|
ObjectGuid itemguid = item->GetGUID();
|
||||||
packet << itemguid << uint8(EQUIPMENT_SLOT_RANGED);
|
packet << itemguid << uint8(EQUIPMENT_SLOT_RANGED);
|
||||||
bot->GetSession()->HandleAutoEquipItemSlotOpcode(packet);
|
|
||||||
|
WorldPackets::Item::AutoEquipItemSlot nicePacket(std::move(packet));
|
||||||
|
nicePacket.Read();
|
||||||
|
bot->GetSession()->HandleAutoEquipItemSlotOpcode(nicePacket);
|
||||||
|
|
||||||
std::ostringstream out;
|
std::ostringstream out;
|
||||||
out << "Equipping " << chat->FormatItem(itemProto) << " in ranged slot";
|
out << "Equipping " << chat->FormatItem(itemProto) << " in ranged slot";
|
||||||
@@ -199,7 +204,9 @@ void EquipAction::EquipItem(Item* item)
|
|||||||
WorldPacket eqPacket(CMSG_AUTOEQUIP_ITEM_SLOT, 2);
|
WorldPacket eqPacket(CMSG_AUTOEQUIP_ITEM_SLOT, 2);
|
||||||
ObjectGuid newItemGuid = item->GetGUID();
|
ObjectGuid newItemGuid = item->GetGUID();
|
||||||
eqPacket << newItemGuid << uint8(EQUIPMENT_SLOT_MAINHAND);
|
eqPacket << newItemGuid << uint8(EQUIPMENT_SLOT_MAINHAND);
|
||||||
bot->GetSession()->HandleAutoEquipItemSlotOpcode(eqPacket);
|
WorldPackets::Item::AutoEquipItemSlot nicePacket(std::move(eqPacket));
|
||||||
|
nicePacket.Read();
|
||||||
|
bot->GetSession()->HandleAutoEquipItemSlotOpcode(nicePacket);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Try moving old main hand weapon to offhand if beneficial
|
// Try moving old main hand weapon to offhand if beneficial
|
||||||
@@ -210,7 +217,9 @@ void EquipAction::EquipItem(Item* item)
|
|||||||
WorldPacket offhandPacket(CMSG_AUTOEQUIP_ITEM_SLOT, 2);
|
WorldPacket offhandPacket(CMSG_AUTOEQUIP_ITEM_SLOT, 2);
|
||||||
ObjectGuid oldMHGuid = mainHandItem->GetGUID();
|
ObjectGuid oldMHGuid = mainHandItem->GetGUID();
|
||||||
offhandPacket << oldMHGuid << uint8(EQUIPMENT_SLOT_OFFHAND);
|
offhandPacket << oldMHGuid << uint8(EQUIPMENT_SLOT_OFFHAND);
|
||||||
bot->GetSession()->HandleAutoEquipItemSlotOpcode(offhandPacket);
|
WorldPackets::Item::AutoEquipItemSlot nicePacket(std::move(offhandPacket));
|
||||||
|
nicePacket.Read();
|
||||||
|
bot->GetSession()->HandleAutoEquipItemSlotOpcode(nicePacket);
|
||||||
|
|
||||||
std::ostringstream moveMsg;
|
std::ostringstream moveMsg;
|
||||||
moveMsg << "Main hand upgrade found. Moving " << chat->FormatItem(oldMHProto) << " to offhand";
|
moveMsg << "Main hand upgrade found. Moving " << chat->FormatItem(oldMHProto) << " to offhand";
|
||||||
@@ -230,7 +239,9 @@ void EquipAction::EquipItem(Item* item)
|
|||||||
WorldPacket eqPacket(CMSG_AUTOEQUIP_ITEM_SLOT, 2);
|
WorldPacket eqPacket(CMSG_AUTOEQUIP_ITEM_SLOT, 2);
|
||||||
ObjectGuid newItemGuid = item->GetGUID();
|
ObjectGuid newItemGuid = item->GetGUID();
|
||||||
eqPacket << newItemGuid << uint8(EQUIPMENT_SLOT_OFFHAND);
|
eqPacket << newItemGuid << uint8(EQUIPMENT_SLOT_OFFHAND);
|
||||||
bot->GetSession()->HandleAutoEquipItemSlotOpcode(eqPacket);
|
WorldPackets::Item::AutoEquipItemSlot nicePacket(std::move(eqPacket));
|
||||||
|
nicePacket.Read();
|
||||||
|
bot->GetSession()->HandleAutoEquipItemSlotOpcode(nicePacket);
|
||||||
|
|
||||||
std::ostringstream out;
|
std::ostringstream out;
|
||||||
out << "Equipping " << chat->FormatItem(itemProto) << " in offhand";
|
out << "Equipping " << chat->FormatItem(itemProto) << " in offhand";
|
||||||
@@ -287,7 +298,9 @@ void EquipAction::EquipItem(Item* item)
|
|||||||
WorldPacket packet(CMSG_AUTOEQUIP_ITEM_SLOT, 2);
|
WorldPacket packet(CMSG_AUTOEQUIP_ITEM_SLOT, 2);
|
||||||
ObjectGuid itemguid = item->GetGUID();
|
ObjectGuid itemguid = item->GetGUID();
|
||||||
packet << itemguid << dstSlot;
|
packet << itemguid << dstSlot;
|
||||||
bot->GetSession()->HandleAutoEquipItemSlotOpcode(packet);
|
WorldPackets::Item::AutoEquipItemSlot nicePacket(std::move(packet));
|
||||||
|
nicePacket.Read();
|
||||||
|
bot->GetSession()->HandleAutoEquipItemSlotOpcode(nicePacket);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
#include "Event.h"
|
#include "Event.h"
|
||||||
#include "ItemVisitors.h"
|
#include "ItemVisitors.h"
|
||||||
#include "Playerbots.h"
|
#include "Playerbots.h"
|
||||||
|
#include "ItemPackets.h"
|
||||||
|
|
||||||
bool OutfitAction::Execute(Event event)
|
bool OutfitAction::Execute(Event event)
|
||||||
{
|
{
|
||||||
@@ -70,7 +71,9 @@ bool OutfitAction::Execute(Event event)
|
|||||||
|
|
||||||
WorldPacket packet(CMSG_AUTOSTORE_BAG_ITEM, 3);
|
WorldPacket packet(CMSG_AUTOSTORE_BAG_ITEM, 3);
|
||||||
packet << bagIndex << slot << dstBag;
|
packet << bagIndex << slot << dstBag;
|
||||||
bot->GetSession()->HandleAutoStoreBagItemOpcode(packet);
|
WorldPackets::Item::AutoStoreBagItem nicePacket(std::move(packet));
|
||||||
|
nicePacket.Read();
|
||||||
|
bot->GetSession()->HandleAutoStoreBagItemOpcode(nicePacket);
|
||||||
}
|
}
|
||||||
|
|
||||||
EquipItems(outfit);
|
EquipItems(outfit);
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
#include "ItemUsageValue.h"
|
#include "ItemUsageValue.h"
|
||||||
#include "ItemVisitors.h"
|
#include "ItemVisitors.h"
|
||||||
#include "Playerbots.h"
|
#include "Playerbots.h"
|
||||||
|
#include "ItemPackets.h"
|
||||||
|
|
||||||
class SellItemsVisitor : public IterateItemsVisitor
|
class SellItemsVisitor : public IterateItemsVisitor
|
||||||
{
|
{
|
||||||
@@ -116,7 +117,10 @@ void SellAction::Sell(Item* item)
|
|||||||
|
|
||||||
WorldPacket p;
|
WorldPacket p;
|
||||||
p << vendorguid << itemguid << count;
|
p << vendorguid << itemguid << count;
|
||||||
bot->GetSession()->HandleSellItemOpcode(p);
|
|
||||||
|
WorldPackets::Item::SellItem nicePacket(std::move(p));
|
||||||
|
nicePacket.Read();
|
||||||
|
bot->GetSession()->HandleSellItemOpcode(nicePacket);
|
||||||
|
|
||||||
if (botAI->HasCheat(BotCheatMask::gold))
|
if (botAI->HasCheat(BotCheatMask::gold))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -8,6 +8,8 @@
|
|||||||
#include "Event.h"
|
#include "Event.h"
|
||||||
#include "ItemCountValue.h"
|
#include "ItemCountValue.h"
|
||||||
#include "Playerbots.h"
|
#include "Playerbots.h"
|
||||||
|
#include "WorldSession.h"
|
||||||
|
#include "ItemPackets.h"
|
||||||
|
|
||||||
std::vector<std::string> split(std::string const s, char delim);
|
std::vector<std::string> split(std::string const s, char delim);
|
||||||
|
|
||||||
@@ -70,7 +72,9 @@ void UnequipAction::UnequipItem(Item* item)
|
|||||||
|
|
||||||
WorldPacket packet(CMSG_AUTOSTORE_BAG_ITEM, 3);
|
WorldPacket packet(CMSG_AUTOSTORE_BAG_ITEM, 3);
|
||||||
packet << bagIndex << slot << dstBag;
|
packet << bagIndex << slot << dstBag;
|
||||||
bot->GetSession()->HandleAutoStoreBagItemOpcode(packet);
|
WorldPackets::Item::AutoStoreBagItem nicePacket(std::move(packet));
|
||||||
|
nicePacket.Read();
|
||||||
|
bot->GetSession()->HandleAutoStoreBagItemOpcode(nicePacket);
|
||||||
|
|
||||||
std::ostringstream out;
|
std::ostringstream out;
|
||||||
out << chat->FormatItem(item->GetTemplate()) << " unequipped";
|
out << chat->FormatItem(item->GetTemplate()) << " unequipped";
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
#include "Event.h"
|
#include "Event.h"
|
||||||
#include "ItemUsageValue.h"
|
#include "ItemUsageValue.h"
|
||||||
#include "Playerbots.h"
|
#include "Playerbots.h"
|
||||||
|
#include "ItemPackets.h"
|
||||||
|
|
||||||
bool UseItemAction::Execute(Event event)
|
bool UseItemAction::Execute(Event event)
|
||||||
{
|
{
|
||||||
@@ -324,8 +325,8 @@ void UseItemAction::TellConsumableUse(Item* item, std::string const action, floa
|
|||||||
|
|
||||||
bool UseItemAction::SocketItem(Item* item, Item* gem, bool replace)
|
bool UseItemAction::SocketItem(Item* item, Item* gem, bool replace)
|
||||||
{
|
{
|
||||||
WorldPacket* const packet = new WorldPacket(CMSG_SOCKET_GEMS);
|
WorldPacket packet(CMSG_SOCKET_GEMS);
|
||||||
*packet << item->GetGUID();
|
packet << item->GetGUID();
|
||||||
|
|
||||||
bool fits = false;
|
bool fits = false;
|
||||||
for (uint32 enchant_slot = SOCK_ENCHANTMENT_SLOT; enchant_slot < SOCK_ENCHANTMENT_SLOT + MAX_GEM_SOCKETS;
|
for (uint32 enchant_slot = SOCK_ENCHANTMENT_SLOT; enchant_slot < SOCK_ENCHANTMENT_SLOT + MAX_GEM_SOCKETS;
|
||||||
@@ -337,14 +338,14 @@ bool UseItemAction::SocketItem(Item* item, Item* gem, bool replace)
|
|||||||
{
|
{
|
||||||
if (fits)
|
if (fits)
|
||||||
{
|
{
|
||||||
*packet << ObjectGuid::Empty;
|
packet << ObjectGuid::Empty;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32 enchant_id = item->GetEnchantmentId(EnchantmentSlot(enchant_slot));
|
uint32 enchant_id = item->GetEnchantmentId(EnchantmentSlot(enchant_slot));
|
||||||
if (!enchant_id)
|
if (!enchant_id)
|
||||||
{
|
{
|
||||||
*packet << gem->GetGUID();
|
packet << gem->GetGUID();
|
||||||
fits = true;
|
fits = true;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -352,20 +353,20 @@ bool UseItemAction::SocketItem(Item* item, Item* gem, bool replace)
|
|||||||
SpellItemEnchantmentEntry const* enchantEntry = sSpellItemEnchantmentStore.LookupEntry(enchant_id);
|
SpellItemEnchantmentEntry const* enchantEntry = sSpellItemEnchantmentStore.LookupEntry(enchant_id);
|
||||||
if (!enchantEntry || !enchantEntry->GemID)
|
if (!enchantEntry || !enchantEntry->GemID)
|
||||||
{
|
{
|
||||||
*packet << gem->GetGUID();
|
packet << gem->GetGUID();
|
||||||
fits = true;
|
fits = true;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (replace && enchantEntry->GemID != gem->GetTemplate()->ItemId)
|
if (replace && enchantEntry->GemID != gem->GetTemplate()->ItemId)
|
||||||
{
|
{
|
||||||
*packet << gem->GetGUID();
|
packet << gem->GetGUID();
|
||||||
fits = true;
|
fits = true;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
*packet << ObjectGuid::Empty;
|
packet << ObjectGuid::Empty;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fits)
|
if (fits)
|
||||||
@@ -375,7 +376,9 @@ bool UseItemAction::SocketItem(Item* item, Item* gem, bool replace)
|
|||||||
out << " with " << chat->FormatItem(gem->GetTemplate());
|
out << " with " << chat->FormatItem(gem->GetTemplate());
|
||||||
botAI->TellMaster(out);
|
botAI->TellMaster(out);
|
||||||
|
|
||||||
bot->GetSession()->HandleSocketOpcode(*packet);
|
WorldPackets::Item::SocketGems nicePacket(std::move(packet));
|
||||||
|
nicePacket.Read();
|
||||||
|
bot->GetSession()->HandleSocketOpcode(nicePacket);
|
||||||
}
|
}
|
||||||
|
|
||||||
return fits;
|
return fits;
|
||||||
|
|||||||
Reference in New Issue
Block a user