From 7b6bf07cb0f473b96650f35427dd89470b4d4158 Mon Sep 17 00:00:00 2001 From: Flekz Date: Fri, 2 Feb 2024 10:54:53 +0000 Subject: [PATCH] Fix bots not using quest related mining or herbalism gameobjects --- playerbot/LootObjectStack.cpp | 16 +++++++--- playerbot/PlayerbotAI.cpp | 56 +++++++++++++++++++++++++++++++++++ playerbot/PlayerbotAI.h | 3 ++ 3 files changed, 71 insertions(+), 4 deletions(-) diff --git a/playerbot/LootObjectStack.cpp b/playerbot/LootObjectStack.cpp index 065dadeb8..1ee0caf7b 100644 --- a/playerbot/LootObjectStack.cpp +++ b/playerbot/LootObjectStack.cpp @@ -240,15 +240,23 @@ bool LootObject::IsLootPossible(Player* bot) if (!AI_VALUE2_LAZY(bool, "should loot object", to_string(guid.GetRawValue()))) return false; - + // Check if the game object has quest loot and bot has the quest for it if (guid.IsGameObject()) { GameObject* go = ai->GetGameObject(guid); if (go) { - if (sObjectMgr.IsGameObjectForQuests(guid.GetEntry())) //If object has quest loot bot needs the quest. - if (!go->ActivateToQuest(bot)) - return false; + // Ignore for mining nodes and herbs + if (skillId != SKILL_MINING && skillId != SKILL_HERBALISM) + { + if (sObjectMgr.IsGameObjectForQuests(guid.GetEntry())) + { + if (!go->ActivateToQuest(bot)) + { + return false; + } + } + } } } diff --git a/playerbot/PlayerbotAI.cpp b/playerbot/PlayerbotAI.cpp index 1d063f44f..e7155878c 100644 --- a/playerbot/PlayerbotAI.cpp +++ b/playerbot/PlayerbotAI.cpp @@ -4011,6 +4011,62 @@ bool PlayerbotAI::IsHealSpell(const SpellEntry* spell) return false; } +bool PlayerbotAI::IsMiningNode(const GameObject* go) +{ + if (go) + { + const GameObjectInfo* goInfo = go->GetGOInfo(); + if (goInfo) + { + const LockEntry* lockInfo = sLockStore.LookupEntry(goInfo->GetLockId()); + if (lockInfo) + { + for (int i = 0; i < 8; ++i) + { + if (lockInfo->Type[i] == LOCK_KEY_SKILL) + { + const uint32 skillId = SkillByLockType(LockType(lockInfo->Index[i])); + if (skillId == SKILL_MINING) + { + return true; + } + } + } + } + } + } + + return false; +} + +bool PlayerbotAI::IsHerb(const GameObject* go) +{ + if (go) + { + const GameObjectInfo* goInfo = go->GetGOInfo(); + if (goInfo) + { + const LockEntry* lockInfo = sLockStore.LookupEntry(goInfo->GetLockId()); + if (lockInfo) + { + for (int i = 0; i < 8; ++i) + { + if (lockInfo->Type[i] == LOCK_KEY_SKILL) + { + const uint32 skillId = SkillByLockType(LockType(lockInfo->Index[i])); + if (skillId == SKILL_HERBALISM) + { + return true; + } + } + } + } + } + } + + return false; +} + bool IsAlliance(uint8 race) { return race == RACE_HUMAN || race == RACE_DWARF || race == RACE_NIGHTELF || diff --git a/playerbot/PlayerbotAI.h b/playerbot/PlayerbotAI.h index b6ef0d143..f9677e578 100644 --- a/playerbot/PlayerbotAI.h +++ b/playerbot/PlayerbotAI.h @@ -383,6 +383,9 @@ class PlayerbotAI : public PlayerbotAIBase bool canDispel(const SpellEntry* entry, uint32 dispelType); static bool IsHealSpell(const SpellEntry* entry); + static bool IsMiningNode(const GameObject* go); + static bool IsHerb(const GameObject* go); + bool HasSpell(string name) const; bool HasSpell(uint32 spellid) const; bool HasAura(uint32 spellId, Unit* player, bool checkOwner = false);