mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-14 01:29:07 +00:00
fix (Core/SmartScript) Improve SMART_ACTION_START_CLOSEST_WAYPOINT. (#22364)
Co-authored-by: Yehonal <yehonal.azeroth@gmail.com>
This commit is contained in:
@@ -2506,10 +2506,6 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
|
||||
}
|
||||
case SMART_ACTION_START_CLOSEST_WAYPOINT:
|
||||
{
|
||||
std::vector<uint32> waypoints;
|
||||
std::copy_if(e.action.closestWaypointFromList.wps.begin(), e.action.closestWaypointFromList.wps.end(),
|
||||
std::back_inserter(waypoints), [](uint32 wp) { return wp != 0; });
|
||||
|
||||
float distanceToClosest = std::numeric_limits<float>::max();
|
||||
uint32 closestWpId = 0;
|
||||
|
||||
@@ -2519,13 +2515,12 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
|
||||
{
|
||||
if (IsSmart(creature))
|
||||
{
|
||||
for (uint32 wp : waypoints)
|
||||
for (uint32 wp = e.action.startClosestWaypoint.pathId1; wp <= e.action.startClosestWaypoint.pathId2; ++wp)
|
||||
{
|
||||
WPPath* path = sSmartWaypointMgr->GetPath(wp);
|
||||
if (!path || path->empty())
|
||||
continue;
|
||||
|
||||
//waypoint pointid always starts at 1, never 0!
|
||||
auto itrWp = path->find(1);
|
||||
if (itrWp != path->end())
|
||||
{
|
||||
@@ -2542,7 +2537,12 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
|
||||
}
|
||||
|
||||
if (closestWpId)
|
||||
CAST_AI(SmartAI, creature->AI())->StartPath(false, closestWpId, true);
|
||||
{
|
||||
bool repeat = e.action.startClosestWaypoint.repeat;
|
||||
bool run = e.action.startClosestWaypoint.run;
|
||||
|
||||
CAST_AI(SmartAI, creature->AI())->StartPath(repeat, closestWpId, run);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user