diff --git a/playerbot/PlayerbotAI.cpp b/playerbot/PlayerbotAI.cpp index c10bdf86..847d0b04 100644 --- a/playerbot/PlayerbotAI.cpp +++ b/playerbot/PlayerbotAI.cpp @@ -6837,9 +6837,25 @@ std::list PlayerbotAI::GetAllHostileUnitsAroundWO(WorldObject* wo, float MaNGOS::UnitListSearcher searcher(hostileUnits, u_check); Cell::VisitAllObjects(wo, searcher, distanceAround); + //bugs out with players very rarely - returns friendly as hostile to bots + return hostileUnits; } +std::list PlayerbotAI::GetAllHostileNonPlayerUnitsAroundWO(WorldObject* wo, float distanceAround) +{ + std::list hostileUnitsNonPlayers; + for (auto hostileUnit : GetAllHostileUnitsAroundWO(wo, distanceAround)) + { + if (!hostileUnit->IsPlayer()) + { + hostileUnitsNonPlayers.push_back(hostileUnit); + } + } + + return hostileUnitsNonPlayers; +} + std::string PlayerbotAI::InventoryParseOutfitName(std::string outfit) { int pos = outfit.find("="); diff --git a/playerbot/PlayerbotAI.h b/playerbot/PlayerbotAI.h index 8f6d9da9..315bd528 100644 --- a/playerbot/PlayerbotAI.h +++ b/playerbot/PlayerbotAI.h @@ -508,6 +508,7 @@ class PlayerbotAI : public PlayerbotAIBase void AccelerateRespawn(ObjectGuid guid, float accelMod = 0) { Creature* creature = GetCreature(guid); if (creature) AccelerateRespawn(creature,accelMod); } std::list GetAllHostileUnitsAroundWO(WorldObject* wo, float distanceAround); + std::list GetAllHostileNonPlayerUnitsAroundWO(WorldObject* wo, float distanceAround); public: std::vector GetInventoryAndEquippedItems(); diff --git a/playerbot/strategy/actions/AddLootAction.cpp b/playerbot/strategy/actions/AddLootAction.cpp index 8a724cef..7a8c714c 100644 --- a/playerbot/strategy/actions/AddLootAction.cpp +++ b/playerbot/strategy/actions/AddLootAction.cpp @@ -113,7 +113,7 @@ bool AddAllLootAction::AddLoot(Player* requester, ObjectGuid guid) if (isInGroup && !isGroupLeader) { float MOB_AGGRO_DISTANCE = 30.0f; - std::list hostiles = ai->GetAllHostileUnitsAroundWO(wo, MOB_AGGRO_DISTANCE); + std::list hostiles = ai->GetAllHostileNonPlayerUnitsAroundWO(wo, MOB_AGGRO_DISTANCE); if (hostiles.size() > 0) { @@ -208,7 +208,7 @@ bool AddGatheringLootAction::AddLoot(Player* requester, ObjectGuid guid) //check hostile units after distance checks, to avoid unnecessary calculations float MOB_AGGRO_DISTANCE = 30.0f; - std::list hostiles = ai->GetAllHostileUnitsAroundWO(wo, MOB_AGGRO_DISTANCE); + std::list hostiles = ai->GetAllHostileNonPlayerUnitsAroundWO(wo, MOB_AGGRO_DISTANCE); std::list strongHostiles; for (auto hostile : hostiles) {