Skip to content

Commit

Permalink
Fix bots not using quest related mining or herbalism gameobjects
Browse files Browse the repository at this point in the history
  • Loading branch information
davidonete committed Feb 2, 2024
1 parent f7d3429 commit 7b6bf07
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 4 deletions.
16 changes: 12 additions & 4 deletions playerbot/LootObjectStack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
}
}
}

Expand Down
56 changes: 56 additions & 0 deletions playerbot/PlayerbotAI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 ||
Expand Down
3 changes: 3 additions & 0 deletions playerbot/PlayerbotAI.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 7b6bf07

Please sign in to comment.