From c335eb8e14b42fad05606e1b4da0216a593d81a2 Mon Sep 17 00:00:00 2001 From: Yunfan Li Date: Tue, 8 Aug 2023 17:26:40 +0800 Subject: [PATCH] set ammo, fix enchantment --- src/PlayerbotAI.cpp | 2 +- src/PlayerbotFactory.cpp | 13 +++++-------- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/src/PlayerbotAI.cpp b/src/PlayerbotAI.cpp index 0b0c410a..cb8e42cc 100644 --- a/src/PlayerbotAI.cpp +++ b/src/PlayerbotAI.cpp @@ -4013,7 +4013,7 @@ void PlayerbotAI::ImbueItem(Item* item, uint32 targetFlag, ObjectGuid targetGUID void PlayerbotAI::EnchantItemT(uint32 spellid, uint8 slot) { Item* pItem = bot->GetItemByPos(INVENTORY_SLOT_BAG_0, slot); - if (!pItem) + if (!pItem || !pItem->IsInWorld()) return; SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellid); diff --git a/src/PlayerbotFactory.cpp b/src/PlayerbotFactory.cpp index e1d118e4..db0e6194 100644 --- a/src/PlayerbotFactory.cpp +++ b/src/PlayerbotFactory.cpp @@ -2154,18 +2154,15 @@ void PlayerbotFactory::InitAmmo() return; uint32 entry = sRandomItemMgr->GetAmmo(level, subClass); - uint32 count = bot->GetItemCount(entry) / 200; - uint32 maxCount = 5 + level / 10; + uint32 count = bot->GetItemCount(entry); + uint32 maxCount = 10000; - if (count < maxCount) + if (count < maxCount / 2) { - for (uint32 i = 0; i < maxCount - count; i++) - { - if (Item* newItem = StoreNewItemInInventorySlot(bot, entry, 200)) - newItem->AddToUpdateQueueOf(bot); + if (Item* newItem = StoreNewItemInInventorySlot(bot, entry, maxCount / 2)) { + newItem->AddToUpdateQueueOf(bot); } } - bot->SetAmmo(entry); }