Skip to content

Commit

Permalink
Only try to loot quest objects if has items or not used
Browse files Browse the repository at this point in the history
  • Loading branch information
celguar committed May 26, 2024
1 parent 7a470b5 commit 9c5267f
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 13 deletions.
10 changes: 9 additions & 1 deletion playerbot/LootObjectStack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,15 @@ bool LootObject::IsLootPossible(Player* bot)
{
if (go->ActivateToQuest(bot))
{
return true;
bool hasQuestItems = false;
for (auto& entry : GAI_VALUE2(std::list<uint32>, "entry loot list", -go->GetEntry()))

This comment has been minimized.

Copy link
@XandrKhv

XandrKhv May 27, 2024

warning C4146, applying a unary minus to an unsigned type; the result is left unsigned

{
if (IsNeededForQuest(bot, entry))
{
hasQuestItems = true;
}
}
return hasQuestItems || go->GetLootState() != GO_READY;
}
}
}
Expand Down
6 changes: 4 additions & 2 deletions playerbot/strategy/actions/LootAction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include "playerbot/strategy/values/LootStrategyValue.h"
#include "playerbot/strategy/values/ItemUsageValue.h"
#include "playerbot/ServerFacade.h"
#include "playerbot/strategy/values/SharedValueContext.h"


using namespace ai;
Expand Down Expand Up @@ -127,11 +128,12 @@ bool OpenLootAction::DoLoot(LootObject& lootObject)
{
// herb-like quest objects
bool isForQuest = false;
if (sObjectMgr.IsGameObjectForQuests(lootObject.guid.GetEntry()))
if (go && sObjectMgr.IsGameObjectForQuests(lootObject.guid.GetEntry()))
{
if (go->ActivateToQuest(bot))
{
isForQuest = true;
std::list<uint32> lootItems = GAI_VALUE2(std::list<uint32>, "entry loot list", -go->GetEntry());

This comment has been minimized.

Copy link
@XandrKhv

XandrKhv May 27, 2024

warning C4146, applying a unary minus to an unsigned type; the result is left unsigned

This comment has been minimized.

Copy link
@davidonete

davidonete May 27, 2024

Contributor

is the negative number intended? -go->GetEntry()

isForQuest = !lootItems.empty() || go->GetLootState() != GO_READY;
}
}

Expand Down
18 changes: 8 additions & 10 deletions playerbot/strategy/values/LootValues.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,16 +175,14 @@ std::list<uint32> EntryLootListValue::Calculate()

std::list<uint32> items;

LootTemplateAccess const* lTemplateA;

if (entry > 0)
lTemplateA = DropMapValue::GetLootTemplate(ObjectGuid(HIGHGUID_UNIT, entry, uint32(1)), LOOT_CORPSE);
else
lTemplateA = DropMapValue::GetLootTemplate(ObjectGuid(HIGHGUID_GAMEOBJECT, entry, uint32(1)), LOOT_CORPSE);

if (lTemplateA)
for (LootStoreItem const& lItem : lTemplateA->Entries)
items.push_back(lItem.itemid);
DropMap* dropMap = GAI_VALUE(DropMap*, "drop map");
for (auto it = dropMap->begin(); it != dropMap->end(); ++it)
{
if (it->second == entry)
{
items.push_back(it->first);
}
}

return items;
}
Expand Down

0 comments on commit 9c5267f

Please sign in to comment.