Skip to content

Commit

Permalink
NPCBots: BG/AV: Expand mine boss wp search range to map wander nodes
Browse files Browse the repository at this point in the history
(cherry picked from commit 2d3cdd4af771f06d0e94ea768e7370ec8c69b5f3)
  • Loading branch information
trickerer authored and ikkj committed Jun 10, 2024
1 parent b986252 commit 3ea7ea8
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/server/game/AI/NpcBots/bot_ai.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19674,7 +19674,7 @@ WanderNode const* bot_ai::GetNextBGTravelNode() const
Creature const* mboss = ASSERT_NOTNULL(av->GetBGCreature(uint32(sptype)));
if (mboss->IsAlive() && !mboss->IsInCombat() && me->IsWithinDist2d(mboss, SIZE_OF_GRIDS * 0.75f))
{
WanderNode const* mineWP = ASSERT_NOTNULL(WanderNode::FindInAreaWPs(mboss->GetAreaId(), mine_pred));
WanderNode const* mineWP = ASSERT_NOTNULL(WanderNode::FindInMapWPs(mboss->GetMapId(), mine_pred));
WanderNode const* mineLink = mineWP->GetLinks().front();
NodeList mlinks = curNode->GetShortestPathLinks(mineWP, links);
if (!mlinks.empty())
Expand Down
12 changes: 12 additions & 0 deletions src/server/game/AI/NpcBots/botwanderful.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,18 @@ WanderNode* WanderNode::FindInMapWPs(uint32 mapId, node_check_ftype_c const& pre
return ci == ALL_WPS_PER_MAP.at(mapId).cend() ? nullptr : *ci;
}

WanderNode* WanderNode::FindInZoneWPs(uint32 zoneId, node_check_ftype_c const& pred)
{
lock_type lock(*GetLock());

auto cim = ALL_WPS_PER_ZONE.find(zoneId);
if (cim == ALL_WPS_PER_ZONE.cend())
return nullptr;
auto ci = std::find_if(ALL_WPS_PER_ZONE.at(zoneId).cbegin(), ALL_WPS_PER_ZONE.at(zoneId).cend(), pred);

return ci == ALL_WPS_PER_ZONE.at(zoneId).cend() ? nullptr : *ci;
}

WanderNode* WanderNode::FindInAreaWPs(uint32 areaId, node_check_ftype_c const& pred)
{
lock_type lock(*GetLock());
Expand Down
1 change: 1 addition & 0 deletions src/server/game/AI/NpcBots/botwanderful.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ class WanderNode : public Position
static WanderNode* FindInMapWPs(uint32 mapId, Creature const* creature);
static WanderNode* FindInMapWPs(uint32 mapId, uint32 wpId);
static WanderNode* FindInMapWPs(uint32 mapId, node_check_ftype_c const& pred);
static WanderNode* FindInZoneWPs(uint32 zoneId, node_check_ftype_c const& pred);
static WanderNode* FindInAreaWPs(uint32 areaId, node_check_ftype_c const& pred);

template<typename Container, typename Func>
Expand Down

0 comments on commit 3ea7ea8

Please sign in to comment.