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)
This commit is contained in:
hondacrx
2023-06-30 08:31:39 -04:00
parent 67aa6af3f0
commit a9544c4163
2 changed files with 10 additions and 9 deletions
+9 -8
View File
@@ -70,7 +70,7 @@ namespace Game.AI
return !_isCharmed; 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)) if (HasEscortState(SmartEscortState.Escorting))
StopPath(); StopPath();
@@ -165,22 +165,23 @@ namespace Game.AI
{ {
if (!HasEscortState(SmartEscortState.Escorting)) if (!HasEscortState(SmartEscortState.Escorting))
{ {
(uint nodeId, uint pathId) waypointInfo = new (); uint nodeId = 0;
uint pathId = 0;
if (me.GetMotionMaster().GetCurrentMovementGeneratorType() == MovementGeneratorType.Waypoint) if (me.GetMotionMaster().GetCurrentMovementGeneratorType() == MovementGeneratorType.Waypoint)
waypointInfo = me.GetCurrentWaypointInfo(); (nodeId, pathId) = me.GetCurrentWaypointInfo();
if (_despawnState != 2) if (_despawnState != 2)
SetDespawnTime(despawnTime); SetDespawnTime(despawnTime);
me.GetMotionMaster().MoveIdle(); me.GetMotionMaster().MoveIdle();
if (waypointInfo.Item1 != 0) if (pathId != 0)
GetScript().ProcessEventsFor(SmartEvents.WaypointStopped, null, waypointInfo.Item1, waypointInfo.Item2); GetScript().ProcessEventsFor(SmartEvents.WaypointStopped, null, nodeId, pathId);
if (!fail) if (!fail)
{ {
if (waypointInfo.Item1 != 0) if (pathId != 0)
GetScript().ProcessEventsFor(SmartEvents.WaypointEnded, null, waypointInfo.Item1, waypointInfo.Item2); GetScript().ProcessEventsFor(SmartEvents.WaypointEnded, null, nodeId, pathId);
if (_despawnState == 1) if (_despawnState == 1)
StartDespawn(); StartDespawn();
} }
@@ -390,7 +391,7 @@ namespace Game.AI
else if (HasEscortState(SmartEscortState.Escorting) && me.GetMotionMaster().GetCurrentMovementGeneratorType() == MovementGeneratorType.Waypoint) else if (HasEscortState(SmartEscortState.Escorting) && me.GetMotionMaster().GetCurrentMovementGeneratorType() == MovementGeneratorType.Waypoint)
{ {
WaypointPath path = Global.WaypointMgr.GetPath(pathId); WaypointPath path = Global.WaypointMgr.GetPath(pathId);
if (path != null && _currentWaypointNode == path.nodes.Count) if (path != null && _currentWaypointNode == path.nodes.Last()?.id)
_waypointPathEnded = true; _waypointPathEnded = true;
else else
SetRun(_run); SetRun(_run);
+1 -1
View File
@@ -3374,7 +3374,7 @@ namespace Game.AI
case SmartEvents.WaypointStopped: case SmartEvents.WaypointStopped:
case SmartEvents.WaypointEnded: 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; return;
ProcessAction(e, unit); ProcessAction(e, unit);
break; break;