mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-14 01:29:07 +00:00
feature(SmartAI/Movement) - Unify waypoint systems (#23251)
This commit is contained in:
@@ -1723,7 +1723,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
|
||||
StoreCounter(e.action.setCounter.counterId, e.action.setCounter.value, e.action.setCounter.reset, e.action.setCounter.subtract);
|
||||
break;
|
||||
}
|
||||
case SMART_ACTION_WP_START:
|
||||
case SMART_ACTION_ESCORT_START:
|
||||
{
|
||||
if (!IsSmart())
|
||||
break;
|
||||
@@ -1750,16 +1750,16 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
|
||||
CAST_AI(SmartAI, me->AI())->SetDespawnTime(DespawnTime);
|
||||
break;
|
||||
}
|
||||
case SMART_ACTION_WP_PAUSE:
|
||||
case SMART_ACTION_ESCORT_PAUSE:
|
||||
{
|
||||
if (!IsSmart())
|
||||
break;
|
||||
|
||||
uint32 delay = e.action.wpPause.delay;
|
||||
CAST_AI(SmartAI, me->AI())->PausePath(delay, e.GetEventType() == SMART_EVENT_WAYPOINT_REACHED ? false : true);
|
||||
CAST_AI(SmartAI, me->AI())->PausePath(delay, e.GetEventType() == SMART_EVENT_ESCORT_REACHED ? false : true);
|
||||
break;
|
||||
}
|
||||
case SMART_ACTION_WP_STOP:
|
||||
case SMART_ACTION_ESCORT_STOP:
|
||||
{
|
||||
if (!IsSmart())
|
||||
break;
|
||||
@@ -1770,7 +1770,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
|
||||
CAST_AI(SmartAI, me->AI())->StopPath(DespawnTime, quest, fail);
|
||||
break;
|
||||
}
|
||||
case SMART_ACTION_WP_RESUME:
|
||||
case SMART_ACTION_ESCORT_RESUME:
|
||||
{
|
||||
if (!IsSmart())
|
||||
break;
|
||||
@@ -2519,21 +2519,19 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
|
||||
{
|
||||
for (uint32 wp = e.action.startClosestWaypoint.pathId1; wp <= e.action.startClosestWaypoint.pathId2; ++wp)
|
||||
{
|
||||
WPPath* path = sSmartWaypointMgr->GetPath(wp);
|
||||
WaypointPath* path = sSmartWaypointMgr->GetPath(wp);
|
||||
if (!path || path->empty())
|
||||
continue;
|
||||
|
||||
auto itrWp = path->find(1);
|
||||
if (itrWp != path->end())
|
||||
{
|
||||
if (WayPoint* wpData = itrWp->second)
|
||||
WaypointData& wpData = itrWp->second;
|
||||
float distToThisPath = creature->GetExactDistSq(wpData.x, wpData.y, wpData.z);
|
||||
if (distToThisPath < distanceToClosest)
|
||||
{
|
||||
float distToThisPath = creature->GetExactDistSq(wpData->x, wpData->y, wpData->z);
|
||||
if (distToThisPath < distanceToClosest)
|
||||
{
|
||||
distanceToClosest = distToThisPath;
|
||||
closestWpId = wp;
|
||||
}
|
||||
distanceToClosest = distToThisPath;
|
||||
closestWpId = wp;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3221,7 +3219,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
|
||||
}
|
||||
break;
|
||||
}
|
||||
case SMART_ACTION_WAYPOINT_DATA_START:
|
||||
case SMART_ACTION_WAYPOINT_START:
|
||||
{
|
||||
if (e.action.wpData.pathId)
|
||||
{
|
||||
@@ -3230,7 +3228,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
|
||||
if (IsCreature(target))
|
||||
{
|
||||
target->ToCreature()->LoadPath(e.action.wpData.pathId);
|
||||
target->ToCreature()->GetMotionMaster()->MovePath(e.action.wpData.pathId, e.action.wpData.repeat);
|
||||
target->ToCreature()->GetMotionMaster()->MoveWaypoint(e.action.wpData.pathId, e.action.wpData.repeat, e.action.wpData.pathSource);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3247,7 +3245,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
|
||||
{
|
||||
uint32 path = urand(e.action.wpDataRandom.pathId1, e.action.wpDataRandom.pathId2);
|
||||
target->ToCreature()->LoadPath(path);
|
||||
target->ToCreature()->GetMotionMaster()->MovePath(path, e.action.wpDataRandom.repeat);
|
||||
target->ToCreature()->GetMotionMaster()->MoveWaypoint(path, e.action.wpDataRandom.repeat);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4398,22 +4396,24 @@ void SmartScript::ProcessEvent(SmartScriptHolder& e, Unit* unit, uint32 var0, ui
|
||||
{
|
||||
if ((e.event.movementInform.type && var0 != e.event.movementInform.type) || (e.event.movementInform.id && var1 != e.event.movementInform.id))
|
||||
return;
|
||||
if (e.event.movementInform.pathId != 0 && e.event.movementInform.pathId != me->GetWaypointPath())
|
||||
return;
|
||||
ProcessAction(e, unit, var0, var1);
|
||||
break;
|
||||
}
|
||||
case SMART_EVENT_TRANSPORT_RELOCATE:
|
||||
case SMART_EVENT_WAYPOINT_START:
|
||||
case SMART_EVENT_ESCORT_START:
|
||||
{
|
||||
if (e.event.waypoint.pathID && var0 != e.event.waypoint.pathID)
|
||||
return;
|
||||
ProcessAction(e, unit, var0);
|
||||
break;
|
||||
}
|
||||
case SMART_EVENT_WAYPOINT_REACHED:
|
||||
case SMART_EVENT_WAYPOINT_RESUMED:
|
||||
case SMART_EVENT_WAYPOINT_PAUSED:
|
||||
case SMART_EVENT_WAYPOINT_STOPPED:
|
||||
case SMART_EVENT_WAYPOINT_ENDED:
|
||||
case SMART_EVENT_ESCORT_REACHED:
|
||||
case SMART_EVENT_ESCORT_RESUMED:
|
||||
case SMART_EVENT_ESCORT_PAUSED:
|
||||
case SMART_EVENT_ESCORT_STOPPED:
|
||||
case SMART_EVENT_ESCORT_ENDED:
|
||||
{
|
||||
if (!me || (e.event.waypoint.pointID && var0 != e.event.waypoint.pointID) || (e.event.waypoint.pathID && GetPathId() != e.event.waypoint.pathID))
|
||||
return;
|
||||
@@ -4807,8 +4807,8 @@ void SmartScript::ProcessEvent(SmartScriptHolder& e, Unit* unit, uint32 var0, ui
|
||||
RecalcTimer(e, 1200, 1200);
|
||||
break;
|
||||
}
|
||||
case SMART_EVENT_WAYPOINT_DATA_REACHED:
|
||||
case SMART_EVENT_WAYPOINT_DATA_ENDED:
|
||||
case SMART_EVENT_WAYPOINT_REACHED:
|
||||
case SMART_EVENT_WAYPOINT_ENDED:
|
||||
{
|
||||
if (!me || (e.event.wpData.pointId && var0 != e.event.wpData.pointId) || (e.event.wpData.pathId && me->GetWaypointPath() != e.event.wpData.pathId))
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user