From a9544c4163c6f38aff092db0432df6a68e8664ad Mon Sep 17 00:00:00 2001 From: hondacrx Date: Fri, 30 Jun 2023 08:31:39 -0400 Subject: [PATCH] Core/SAI: Fixed event SMART_EVENT_WAYPOINT_ENDED * also moved "any" pointid to 0xFFFFFFFF for waypoint sai events: * SMART_EVENT_WAYPOINT_REACHED * SMART_EVENT_WAYPOINT_RESUMED * SMART_EVENT_WAYPOINT_PAUSED * SMART_EVENT_WAYPOINT_STOPPED * SMART_EVENT_WAYPOINT_ENDED Port From (https://github.com/TrinityCore/TrinityCore/commit/76d2f29e4e4c0e14a014676aafff2f8836f96ea0) --- Source/Game/AI/SmartScripts/SmartAI.cs | 17 +++++++++-------- Source/Game/AI/SmartScripts/SmartScript.cs | 2 +- 2 files changed, 10 insertions(+), 9 deletions(-) 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;