From 352969a0c86f9eb441b8340568347f4ec1f17f17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=83=91=E4=BD=A9=E8=8C=B9?= Date: Thu, 23 Mar 2023 09:18:49 -0600 Subject: [PATCH] Tweak loot check for quest items --- src/strategy/actions/LootAction.cpp | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/src/strategy/actions/LootAction.cpp b/src/strategy/actions/LootAction.cpp index 8fcf2710..ad44a916 100644 --- a/src/strategy/actions/LootAction.cpp +++ b/src/strategy/actions/LootAction.cpp @@ -403,7 +403,7 @@ bool StoreLootAction::Execute(Event event) if (proto->Quality > ITEM_QUALITY_NORMAL && !urand(0, 50) && botAI->HasStrategy("emote", BOT_STATE_NON_COMBAT)) botAI->PlayEmote(TEXT_EMOTE_CHEER); - if (proto->Quality >= ITEM_QUALITY_RARE && botAI->HasStrategy("emote", BOT_STATE_NON_COMBAT)) + if (proto->Quality >= ITEM_QUALITY_RARE && !urand(0, 1) && botAI->HasStrategy("emote", BOT_STATE_NON_COMBAT)) botAI->PlayEmote(TEXT_EMOTE_CHEER); std::ostringstream out; @@ -428,14 +428,14 @@ bool StoreLootAction::IsLootAllowed(uint32 itemid, PlayerbotAI* botAI) AiObjectContext* context = botAI->GetAiObjectContext(); LootStrategy* lootStrategy = AI_VALUE(LootStrategy*, "loot strategy"); - std::set& lootItems = AI_VALUE(std::set&, "always loot list"); - if (lootItems.find(itemid) != lootItems.end()) - return true; - ItemTemplate const* proto = sObjectMgr->GetItemTemplate(itemid); if (!proto) return false; + std::set& lootItems = AI_VALUE(std::set&, "always loot list"); + if (lootItems.find(itemid) != lootItems.end()) + return true; + uint32 max = proto->MaxCount; if (max > 0 && botAI->GetBot()->HasItemCount(itemid, max, true)) return false; @@ -448,10 +448,6 @@ bool StoreLootAction::IsLootAllowed(uint32 itemid, PlayerbotAI* botAI) return true; } - //if (proto->Bonding == BIND_QUEST_ITEM || //Still testing if it works ok without these lines. - // proto->Bonding == BIND_QUEST_ITEM1 || //Eventually this has to be removed. - // proto->Class == ITEM_CLASS_QUEST) - //{ for (uint8 slot = 0; slot < MAX_QUEST_LOG_SIZE; ++slot) { uint32 entry = botAI->GetBot()->GetQuestSlotQuestId(slot); @@ -470,11 +466,16 @@ bool StoreLootAction::IsLootAllowed(uint32 itemid, PlayerbotAI* botAI) } if (AI_VALUE2(uint32, "item count", proto->Name1) < quest->RequiredItemCount[i]) - return true; + return false; } } } + //if (proto->Bonding == BIND_QUEST_ITEM || //Still testing if it works ok without these lines. + // proto->Bonding == BIND_QUEST_ITEM1 || //Eventually this has to be removed. + // proto->Class == ITEM_CLASS_QUEST) + //{ + bool canLoot = lootStrategy->CanLoot(proto, context); //if (canLoot && proto->Bonding == BIND_WHEN_PICKED_UP && botAI->HasActivePlayerMaster()) //canLoot = sPlayerbotAIConfig->IsInRandomAccountList(botAI->GetBot()->GetSession()->GetAccountId());