diff --git a/Source/Game/AI/SmartScripts/SmartAI.cs b/Source/Game/AI/SmartScripts/SmartAI.cs index fca753050..a145b4705 100644 --- a/Source/Game/AI/SmartScripts/SmartAI.cs +++ b/Source/Game/AI/SmartScripts/SmartAI.cs @@ -70,7 +70,7 @@ namespace Game.AI return !_isCharmed; } - public void StartPath(uint pathId = 0, bool repeat = false, Unit invoker = null, uint nodeId = 1) + public void StartPath(uint pathId = 0, bool repeat = false, Unit invoker = null, uint nodeId = 0) { if (HasEscortState(SmartEscortState.Escorting)) StopPath(); @@ -165,22 +165,23 @@ namespace Game.AI { if (!HasEscortState(SmartEscortState.Escorting)) { - (uint nodeId, uint pathId) waypointInfo = new (); + uint nodeId = 0; + uint pathId = 0; if (me.GetMotionMaster().GetCurrentMovementGeneratorType() == MovementGeneratorType.Waypoint) - waypointInfo = me.GetCurrentWaypointInfo(); + (nodeId, pathId) = me.GetCurrentWaypointInfo(); if (_despawnState != 2) SetDespawnTime(despawnTime); me.GetMotionMaster().MoveIdle(); - if (waypointInfo.Item1 != 0) - GetScript().ProcessEventsFor(SmartEvents.WaypointStopped, null, waypointInfo.Item1, waypointInfo.Item2); + if (pathId != 0) + GetScript().ProcessEventsFor(SmartEvents.WaypointStopped, null, nodeId, pathId); if (!fail) { - if (waypointInfo.Item1 != 0) - GetScript().ProcessEventsFor(SmartEvents.WaypointEnded, null, waypointInfo.Item1, waypointInfo.Item2); + if (pathId != 0) + GetScript().ProcessEventsFor(SmartEvents.WaypointEnded, null, nodeId, pathId); if (_despawnState == 1) StartDespawn(); } @@ -390,7 +391,7 @@ namespace Game.AI else if (HasEscortState(SmartEscortState.Escorting) && me.GetMotionMaster().GetCurrentMovementGeneratorType() == MovementGeneratorType.Waypoint) { WaypointPath path = Global.WaypointMgr.GetPath(pathId); - if (path != null && _currentWaypointNode == path.nodes.Count) + if (path != null && _currentWaypointNode == path.nodes.Last()?.id) _waypointPathEnded = true; else SetRun(_run); diff --git a/Source/Game/AI/SmartScripts/SmartScript.cs b/Source/Game/AI/SmartScripts/SmartScript.cs index 26112384f..9a715cb16 100644 --- a/Source/Game/AI/SmartScripts/SmartScript.cs +++ b/Source/Game/AI/SmartScripts/SmartScript.cs @@ -3374,7 +3374,7 @@ namespace Game.AI case SmartEvents.WaypointStopped: case SmartEvents.WaypointEnded: { - if (_me == null || (e.Event.waypoint.pointID != 0 && var0 != e.Event.waypoint.pointID) || (e.Event.waypoint.pathID != 0 && var1 != e.Event.waypoint.pathID)) + if (_me == null || (e.Event.waypoint.pointID != 0xFFFFFFFF && var0 != e.Event.waypoint.pointID) || (e.Event.waypoint.pathID != 0 && var1 != e.Event.waypoint.pathID)) return; ProcessAction(e, unit); break;