diff --git a/Source/Game/Movement/Generators/SplineChainMovementGenerator.cs b/Source/Game/Movement/Generators/SplineChainMovementGenerator.cs index 8b4e49cfe..c89df6a81 100644 --- a/Source/Game/Movement/Generators/SplineChainMovementGenerator.cs +++ b/Source/Game/Movement/Generators/SplineChainMovementGenerator.cs @@ -91,7 +91,7 @@ namespace Game.Movement owner.AddUnitState(UnitState.RoamingMove); Span partial = thisLink.Points.ToArray(); - SendPathSpline(owner, partial[(_nextFirstWP - 1)..]); + SendPathSpline(owner, thisLink.Velocity, partial[(_nextFirstWP - 1)..]); Log.outDebug(LogFilter.Movement, $"SplineChainMovementGenerator::Initialize: resumed spline chain generator from resume state. ({owner.GetGUID()})"); @@ -178,7 +178,7 @@ namespace Game.Movement } } - uint SendPathSpline(Unit owner, Span path) + uint SendPathSpline(Unit owner, float velocity, Span path) { int nodeCount = path.Length; Cypher.Assert(nodeCount > 1, $"SplineChainMovementGenerator::SendPathSpline: Every path must have source & destination (size > 1)! ({owner.GetGUID()})"); @@ -188,6 +188,10 @@ namespace Game.Movement init.MovebyPath(path.ToArray()); else init.MoveTo(path[1], false, true); + + if (velocity > 0.0f) + init.SetVelocity(velocity); + init.SetWalk(_walk); return (uint)init.Launch(); } @@ -198,7 +202,7 @@ namespace Game.Movement Log.outDebug(LogFilter.Movement, $"SplineChainMovementGenerator::SendSplineFor: sending spline on index: {index}. ({owner.GetGUID()})"); SplineChainLink thisLink = _chain[index]; - uint actualDuration = SendPathSpline(owner, new Span(thisLink.Points.ToArray())); + uint actualDuration = SendPathSpline(owner, thisLink.Velocity, new Span(thisLink.Points.ToArray())); if (actualDuration != thisLink.ExpectedDuration) { Log.outDebug(LogFilter.Movement, $"SplineChainMovementGenerator::SendSplineFor: sent spline on index: {index}, duration: {actualDuration} ms. Expected duration: {thisLink.ExpectedDuration} ms (delta {actualDuration - thisLink.ExpectedDuration} ms). Adjusting. ({owner.GetGUID()})"); diff --git a/Source/Game/Movement/MoveSpline.cs b/Source/Game/Movement/MoveSpline.cs index 632ffd7ce..1474d9946 100644 --- a/Source/Game/Movement/MoveSpline.cs +++ b/Source/Game/Movement/MoveSpline.cs @@ -386,22 +386,25 @@ namespace Game.Movement public class SplineChainLink { - public SplineChainLink(Vector3[] points, uint expectedDuration, uint msToNext) + public List Points = new(); + public uint ExpectedDuration; + public uint TimeToNext; + public float Velocity; + + public SplineChainLink(Vector3[] points, uint expectedDuration, uint msToNext, float velocity) { Points.AddRange(points); ExpectedDuration = expectedDuration; TimeToNext = msToNext; + Velocity = velocity; } - public SplineChainLink(uint expectedDuration, uint msToNext) + public SplineChainLink(uint expectedDuration, uint msToNext, float velocity) { ExpectedDuration = expectedDuration; TimeToNext = msToNext; + Velocity = velocity; } - - public List Points = new(); - public uint ExpectedDuration; - public uint TimeToNext; } public class SplineChainResumeInfo diff --git a/Source/Game/Scripting/ScriptManager.cs b/Source/Game/Scripting/ScriptManager.cs index 065a7be5f..b9564a56b 100644 --- a/Source/Game/Scripting/ScriptManager.cs +++ b/Source/Game/Scripting/ScriptManager.cs @@ -259,9 +259,9 @@ namespace Game.Scripting m_mSplineChainsMap.Clear(); - // 0 1 2 3 4 - SQLResult resultMeta = DB.World.Query("SELECT entry, chainId, splineId, expectedDuration, msUntilNext FROM script_spline_chain_meta ORDER BY entry asc, chainId asc, splineId asc"); - // 0 1 2 3 4 5 6 + // 0 1 2 3 4 5 + SQLResult resultMeta = DB.World.Query("SELECT entry, chainId, splineId, expectedDuration, msUntilNext, velocity FROM script_spline_chain_meta ORDER BY entry asc, chainId asc, splineId asc"); + // 0 1 2 3 4 5 6 SQLResult resultWP = DB.World.Query("SELECT entry, chainId, splineId, wpId, x, y, z FROM script_spline_chain_waypoints ORDER BY entry asc, chainId asc, splineId asc, wpId asc"); if (resultMeta.IsEmpty() || resultWP.IsEmpty()) { @@ -287,8 +287,10 @@ namespace Game.Scripting continue; } - uint expectedDuration = resultMeta.Read(3), msUntilNext = resultMeta.Read(4); - chain.Add(new SplineChainLink(expectedDuration, msUntilNext)); + uint expectedDuration = resultMeta.Read(3); + uint msUntilNext = resultMeta.Read(4); + float velocity = resultMeta.Read(5); + chain.Add(new SplineChainLink(expectedDuration, msUntilNext, velocity)); if (splineId == 0) ++chainCount; diff --git a/sql/updates/world/master/2021_12_16_13_world_2019_07_18_00_world.sql b/sql/updates/world/master/2021_12_16_13_world_2019_07_18_00_world.sql new file mode 100644 index 000000000..32a404c07 --- /dev/null +++ b/sql/updates/world/master/2021_12_16_13_world_2019_07_18_00_world.sql @@ -0,0 +1 @@ +ALTER TABLE `script_spline_chain_meta` ADD COLUMN `velocity` FLOAT(5) UNSIGNED DEFAULT 0 AFTER `msUntilNext`;