diff --git a/src/PlayerbotMgr.cpp b/src/PlayerbotMgr.cpp index 1958f9aa..7389c72c 100644 --- a/src/PlayerbotMgr.cpp +++ b/src/PlayerbotMgr.cpp @@ -845,6 +845,22 @@ std::vector PlayerbotHolder::HandlePlayerbotCommand(char const* arg if (!strncmp(cmd, "initself=", 9)) { + if (!strcmp(cmd, "initself=uncommon")) + { + if (master->GetSession()->GetSecurity() >= SEC_GAMEMASTER) + { + // OnBotLogin(master); + PlayerbotFactory factory(master, master->GetLevel(), ITEM_QUALITY_UNCOMMON); + factory.Randomize(false); + messages.push_back("initself ok"); + return messages; + } + else + { + messages.push_back("ERROR: Only GM can use this command."); + return messages; + } + } if (!strcmp(cmd, "initself=rare")) { if (master->GetSession()->GetSecurity() >= SEC_GAMEMASTER) @@ -877,6 +893,22 @@ std::vector PlayerbotHolder::HandlePlayerbotCommand(char const* arg return messages; } } + if (!strcmp(cmd, "initself=legendary")) + { + if (master->GetSession()->GetSecurity() >= SEC_GAMEMASTER) + { + // OnBotLogin(master); + PlayerbotFactory factory(master, master->GetLevel(), ITEM_QUALITY_LEGENDARY); + factory.Randomize(false); + messages.push_back("initself ok"); + return messages; + } + else + { + messages.push_back("ERROR: Only GM can use this command."); + return messages; + } + } int32 gs; if (sscanf(cmd, "initself=%d", &gs) != -1) { diff --git a/src/factory/PlayerbotFactory.cpp b/src/factory/PlayerbotFactory.cpp index 3dfc50dc..a40e28a4 100644 --- a/src/factory/PlayerbotFactory.cpp +++ b/src/factory/PlayerbotFactory.cpp @@ -614,7 +614,6 @@ void PlayerbotFactory::InitPetTalents() } std::unordered_map> spells; bool diveTypePet = (1LL << ci->family) & diveMask; - LOG_INFO("playerbots", "DIVEMASK:{}", diveMask); for (uint32 i = 0; i < sTalentStore.GetNumRows(); ++i) { @@ -1513,7 +1512,7 @@ void Shuffle(std::vector& items) // } // } -void PlayerbotFactory::InitEquipment(bool incremental) +void PlayerbotFactory::InitEquipment(bool incremental, bool second_chance) { std::unordered_map> items; // int tab = AiFactory::GetPlayerSpecTab(bot); @@ -1553,16 +1552,13 @@ void PlayerbotFactory::InitEquipment(bool incremental) Item* oldItem = bot->GetItemByPos(INVENTORY_SLOT_BAG_0, slot); - if (!incremental && oldItem) - { - continue; - } - - if (oldItem) + if (second_chance && oldItem) { bot->DestroyItem(INVENTORY_SLOT_BAG_0, slot, true); } + oldItem = bot->GetItemByPos(INVENTORY_SLOT_BAG_0, slot); + uint32 desiredQuality = itemQuality; if (urand(0, 100) < 100 * sPlayerbotAIConfig->randomGearLoweringChance && desiredQuality > ITEM_QUALITY_NORMAL) { @@ -1668,17 +1664,38 @@ void PlayerbotFactory::InitEquipment(bool incremental) bestItemForSlot = newItemId; } } + if (bestItemForSlot == 0) { continue; } - uint16 dest; if (!CanEquipUnseenItem(slot, dest, bestItemForSlot)) { continue; } + + if (incremental && oldItem) + { + float old_score = calculator.CalculateItem(oldItem->GetEntry()); + if (bestScoreForSlot < 1.2f * old_score) + continue; + } + + if (oldItem) + { + uint8 bagIndex = oldItem->GetBagSlot(); + uint8 slot = oldItem->GetSlot(); + uint8 dstBag = NULL_BAG; + + WorldPacket packet(CMSG_AUTOSTORE_BAG_ITEM, 3); + packet << bagIndex << slot << dstBag; + bot->GetSession()->HandleAutoStoreBagItemOpcode(packet); + } + Item* newItem = bot->EquipNewItem(dest, bestItemForSlot, true); + bot->AutoUnequipOffhandIfNeed(); + // bot->AutoUnequipOffhandIfNeed(); if (newItem) { newItem->AddToWorld(); @@ -1686,25 +1703,10 @@ void PlayerbotFactory::InitEquipment(bool incremental) } } // secondary init for better equips - if (!incremental) - InitEquipment(true); + if (!incremental && !second_chance) + InitEquipment(incremental, true); - // for (uint8 slot = 0; slot < EQUIPMENT_SLOT_END; ++slot) - // { - // if (slot == EQUIPMENT_SLOT_TABARD || slot == EQUIPMENT_SLOT_BODY) - // continue; - // if (level < 40 && (slot == EQUIPMENT_SLOT_TRINKET1 || slot == EQUIPMENT_SLOT_TRINKET2)) - // continue; - - // if (level < 25 && slot == EQUIPMENT_SLOT_NECK) - // continue; - - // if (level < 25 && slot == EQUIPMENT_SLOT_HEAD) - // continue; - - - // } } bool PlayerbotFactory::IsDesiredReplacement(Item* item) @@ -1978,7 +1980,7 @@ bool PlayerbotFactory::CanEquipUnseenItem(uint8 slot, uint16& dest, uint32 item) if (Item* pItem = Item::CreateItem(item, 1, bot, false, 0, true)) { - InventoryResult result = bot->CanEquipItem(slot, dest, pItem, true, false); + InventoryResult result = botAI->CanEquipItem(slot, dest, pItem, true, true); pItem->RemoveFromUpdateQueueOf(bot); delete pItem; return result == EQUIP_ERR_OK; diff --git a/src/factory/PlayerbotFactory.h b/src/factory/PlayerbotFactory.h index f88ce96e..e77947e5 100644 --- a/src/factory/PlayerbotFactory.h +++ b/src/factory/PlayerbotFactory.h @@ -122,7 +122,7 @@ public: static void InitTalentsByParsedSpecLink(Player* bot, std::vector> parsedSpecLink, bool reset); void InitAvailableSpells(); void InitClassSpells(); - void InitEquipment(bool incremental); + void InitEquipment(bool incremental, bool second_chance = false); void InitPet(); void InitAmmo(); static uint32 CalcMixedGearScore(uint32 gs, uint32 quality); diff --git a/src/strategy/values/ItemUsageValue.cpp b/src/strategy/values/ItemUsageValue.cpp index 9bdf206d..ca688a2d 100644 --- a/src/strategy/values/ItemUsageValue.cpp +++ b/src/strategy/values/ItemUsageValue.cpp @@ -166,7 +166,7 @@ ItemUsage ItemUsageValue::QueryItemUsageForEquip(ItemTemplate const* itemProto) return ITEM_USAGE_NONE; uint16 dest; - InventoryResult result = botAI->CanEquipItem(NULL_SLOT, dest, pItem, true, false); + InventoryResult result = botAI->CanEquipItem(NULL_SLOT, dest, pItem, true, true); pItem->RemoveFromUpdateQueueOf(bot); delete pItem;