diff --git a/src/LootObjectStack.cpp b/src/LootObjectStack.cpp index 3d34987f..e1d2bc46 100644 --- a/src/LootObjectStack.cpp +++ b/src/LootObjectStack.cpp @@ -85,7 +85,7 @@ void LootObject::Refresh(Player* bot, ObjectGuid lootGUID) bool hasAnyQuestItems = false; GameObjectQuestItemList const* items = sObjectMgr->GetGameObjectQuestItemList(go->GetEntry()); - for (int i = 0; i < MAX_GAMEOBJECT_QUEST_ITEMS; i++) + for (size_t i = 0; i < MAX_GAMEOBJECT_QUEST_ITEMS; i++) { if (!items || i >= items->size()) break; @@ -297,6 +297,11 @@ bool LootObject::IsLootPossible(Player* bot) return false; } + // Prevent bot from running to chests that are unlootable (e.g. Gunship Armory before completing the event) + GameObject* go = botAI->GetGameObject(guid); + if (go && go->HasFlag(GAMEOBJECT_FLAGS, GO_FLAG_INTERACT_COND | GO_FLAG_NOT_SELECTABLE)) + return false; + if (skillId == SKILL_NONE) return true; diff --git a/src/LootObjectStack.h b/src/LootObjectStack.h index 24153930..b17e7fcc 100644 --- a/src/LootObjectStack.h +++ b/src/LootObjectStack.h @@ -29,6 +29,7 @@ public: LootObject() : skillId(0), reqSkillValue(0), reqItem(0) {} LootObject(Player* bot, ObjectGuid guid); LootObject(LootObject const& other); + LootObject& operator=(LootObject const& other) = default; bool IsEmpty() { return !guid; } bool IsLootPossible(Player* bot); diff --git a/src/strategy/actions/LootAction.cpp b/src/strategy/actions/LootAction.cpp index a80ab306..ee5f50c2 100644 --- a/src/strategy/actions/LootAction.cpp +++ b/src/strategy/actions/LootAction.cpp @@ -18,8 +18,8 @@ #include "GuildMgr.h" #include "BroadcastHelper.h" -bool LootAction::Execute(Event event) -{ +bool LootAction::Execute(Event /*event*/) +{ if (!AI_VALUE(bool, "has available loot")) return false; @@ -61,7 +61,7 @@ enum ProfessionSpells TAILORING = 3908 }; -bool OpenLootAction::Execute(Event event) +bool OpenLootAction::Execute(Event /*event*/) { LootObject lootObject = AI_VALUE(LootObject, "loot target"); bool result = DoLoot(lootObject); @@ -70,7 +70,6 @@ bool OpenLootAction::Execute(Event event) AI_VALUE(LootObjectStack*, "available loot")->Remove(lootObject.guid); context->GetValue("loot target")->Set(LootObject()); } - return result; } @@ -131,6 +130,14 @@ bool OpenLootAction::DoLoot(LootObject& lootObject) if (go && (go->GetGoState() != GO_STATE_READY)) return false; + // This prevents dungeon chests like Tribunal Chest (Halls of Stone) from being ninja'd by the bots + if (go && go->HasFlag(GAMEOBJECT_FLAGS, GO_FLAG_INTERACT_COND)) + return false; + + // This prevents raid chests like Gunship Armory (ICC) from being ninja'd by the bots + if (go && go->HasFlag(GAMEOBJECT_FLAGS, GO_FLAG_NOT_SELECTABLE)) + return false; + if (lootObject.skillId == SKILL_MINING) return botAI->HasSkill(SKILL_MINING) ? botAI->CastSpell(MINING, bot) : false; @@ -189,7 +196,7 @@ uint32 OpenLootAction::GetOpeningSpell(LootObject& lootObject, GameObject* go) return sPlayerbotAIConfig->openGoSpell; } -bool OpenLootAction::CanOpenLock(LootObject& lootObject, SpellInfo const* spellInfo, GameObject* go) +bool OpenLootAction::CanOpenLock(LootObject& /*lootObject*/, SpellInfo const* spellInfo, GameObject* go) { for (uint8 effIndex = 0; effIndex <= EFFECT_2; effIndex++) { @@ -205,8 +212,6 @@ bool OpenLootAction::CanOpenLock(LootObject& lootObject, SpellInfo const* spellI if (!lockInfo) return false; - bool reqKey = false; // some locks not have reqs - for (uint8 j = 0; j < 8; ++j) { switch (lockInfo->Type[j]) @@ -369,7 +374,6 @@ bool StoreLootAction::Execute(Event event) uint32 itemcount; uint8 lootslot_type; uint8 itemindex; - bool grab = false; p >> itemindex; p >> itemid; @@ -506,7 +510,7 @@ bool StoreLootAction::IsLootAllowed(uint32 itemid, PlayerbotAI* botAI) return canLoot; } -bool ReleaseLootAction::Execute(Event event) +bool ReleaseLootAction::Execute(Event /*event*/) { GuidVector gos = context->GetValue("nearest game objects")->Get(); for (ObjectGuid const guid : gos)