mirror of
https://github.com/araxiaonline/TrinityCore.git
synced 2026-06-13 11:43:18 -04:00
This reverts commit05fb27dae4. (cherrypicked froma3c6880579)
This commit is contained in:
@@ -2533,6 +2533,64 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
|
||||
sGameEventMgr->StartEvent(eventId, true);
|
||||
break;
|
||||
}
|
||||
case SMART_ACTION_START_CLOSEST_WAYPOINT:
|
||||
{
|
||||
uint32 waypoints[SMART_ACTION_PARAM_COUNT];
|
||||
waypoints[0] = e.action.closestWaypointFromList.wp1;
|
||||
waypoints[1] = e.action.closestWaypointFromList.wp2;
|
||||
waypoints[2] = e.action.closestWaypointFromList.wp3;
|
||||
waypoints[3] = e.action.closestWaypointFromList.wp4;
|
||||
waypoints[4] = e.action.closestWaypointFromList.wp5;
|
||||
waypoints[5] = e.action.closestWaypointFromList.wp6;
|
||||
float distanceToClosest = std::numeric_limits<float>::max();
|
||||
WayPoint* closestWp = nullptr;
|
||||
|
||||
ObjectList* targets = GetTargets(e, unit);
|
||||
if (targets)
|
||||
{
|
||||
for (ObjectList::iterator itr = targets->begin(); itr != targets->end(); ++itr)
|
||||
{
|
||||
if (Creature* target = (*itr)->ToCreature())
|
||||
{
|
||||
if (IsSmart(target))
|
||||
{
|
||||
for (uint8 i = 0; i < SMART_ACTION_PARAM_COUNT; i++)
|
||||
{
|
||||
if (!waypoints[i])
|
||||
continue;
|
||||
|
||||
WPPath* path = sSmartWaypointMgr->GetPath(waypoints[i]);
|
||||
|
||||
if (!path || path->empty())
|
||||
continue;
|
||||
|
||||
WPPath::const_iterator itrWp = path->find(0);
|
||||
|
||||
if (itrWp != path->end())
|
||||
{
|
||||
if (WayPoint* wp = itrWp->second)
|
||||
{
|
||||
float distToThisPath = target->GetDistance(wp->x, wp->y, wp->z);
|
||||
|
||||
if (distToThisPath < distanceToClosest)
|
||||
{
|
||||
distanceToClosest = distToThisPath;
|
||||
closestWp = wp;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (closestWp)
|
||||
CAST_AI(SmartAI, target->AI())->StartPath(false, closestWp->id, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
delete targets;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case SMART_ACTION_RANDOM_SOUND:
|
||||
{
|
||||
std::vector<uint32> sounds;
|
||||
|
||||
Reference in New Issue
Block a user