diff --git a/sql/updates/world/custom/custom_2019_07_08_00_world.sql b/sql/updates/world/custom/custom_2019_07_08_00_world.sql new file mode 100644 index 0000000000..bbab9a679c --- /dev/null +++ b/sql/updates/world/custom/custom_2019_07_08_00_world.sql @@ -0,0 +1 @@ +ALTER TABLE `script_spline_chain_meta` ADD COLUMN `velocity` FLOAT(5) UNSIGNED DEFAULT 0 NULL AFTER `msUntilNext`; diff --git a/src/server/game/Movement/MovementGenerators/SplineChainMovementGenerator.cpp b/src/server/game/Movement/MovementGenerators/SplineChainMovementGenerator.cpp index 3d075d0bb3..a8ea253eba 100644 --- a/src/server/game/Movement/MovementGenerators/SplineChainMovementGenerator.cpp +++ b/src/server/game/Movement/MovementGenerators/SplineChainMovementGenerator.cpp @@ -22,7 +22,7 @@ #include "MoveSpline.h" #include "Log.h" -uint32 SplineChainMovementGenerator::SendPathSpline(Unit* me, Movement::PointsArray const& wp) const +uint32 SplineChainMovementGenerator::SendPathSpline(Unit* me, float velocity, Movement::PointsArray const& wp) const { uint32 numWp = wp.size(); ASSERT(numWp > 1 && "Every path must have source & destination"); @@ -31,6 +31,9 @@ uint32 SplineChainMovementGenerator::SendPathSpline(Unit* me, Movement::PointsAr init.MovebyPath(wp); else init.MoveTo(wp[1], false, true); + + if (velocity > 0.f) + init.SetVelocity(velocity); init.SetWalk(_walk); return init.Launch(); } @@ -41,7 +44,7 @@ void SplineChainMovementGenerator::SendSplineFor(Unit* me, uint32 index, uint32& TC_LOG_DEBUG("movement.splinechain", "%s: Sending spline for %u.", me->GetGUID().ToString().c_str(), index); SplineChainLink const& thisLink = _chain[index]; - uint32 actualDuration = SendPathSpline(me, thisLink.Points); + uint32 actualDuration = SendPathSpline(me, thisLink.Velocity, thisLink.Points); if (actualDuration != thisLink.ExpectedDuration) { TC_LOG_DEBUG("movement.splinechain", "%s: Sent spline for %u, duration is %u ms. Expected was %u ms (delta %d ms). Adjusting.", me->GetGUID().ToString().c_str(), index, actualDuration, thisLink.ExpectedDuration, int32(actualDuration) - int32(thisLink.ExpectedDuration)); @@ -68,7 +71,7 @@ void SplineChainMovementGenerator::Initialize(Unit* me) _nextFirstWP = thisLink.Points.size()-1; } Movement::PointsArray partial(thisLink.Points.begin() + (_nextFirstWP-1), thisLink.Points.end()); - SendPathSpline(me, partial); + SendPathSpline(me, thisLink.Velocity, partial); TC_LOG_DEBUG("movement.splinechain", "%s: Resumed spline chain generator from resume state.", me->GetGUID().ToString().c_str()); ++_nextIndex; if (_nextIndex >= _chainSize) diff --git a/src/server/game/Movement/MovementGenerators/SplineChainMovementGenerator.h b/src/server/game/Movement/MovementGenerators/SplineChainMovementGenerator.h index 44e15fa3fd..3c6ec871ab 100644 --- a/src/server/game/Movement/MovementGenerators/SplineChainMovementGenerator.h +++ b/src/server/game/Movement/MovementGenerators/SplineChainMovementGenerator.h @@ -39,7 +39,7 @@ class TC_GAME_API SplineChainMovementGenerator : public MovementGenerator private: void SendSplineFor(Unit* me, uint32 index, uint32& toNext); - uint32 SendPathSpline(Unit* me, Movement::PointsArray const& wp) const; + uint32 SendPathSpline(Unit* me, float velocity, Movement::PointsArray const& wp) const; uint32 const _id; std::vector const& _chain; uint8 const _chainSize; diff --git a/src/server/game/Movement/Spline/SplineChain.h b/src/server/game/Movement/Spline/SplineChain.h index 96722ffca8..24148960b4 100644 --- a/src/server/game/Movement/Spline/SplineChain.h +++ b/src/server/game/Movement/Spline/SplineChain.h @@ -23,12 +23,13 @@ struct TC_GAME_API SplineChainLink { - SplineChainLink(Movement::PointsArray const& points, uint32 expectedDuration, uint32 msToNext) : Points(points), ExpectedDuration(expectedDuration), TimeToNext(msToNext) { } - template SplineChainLink(iteratorType begin, iteratorType end, uint32 expectedDuration, uint32 msToNext) : Points(begin, end), ExpectedDuration(expectedDuration), TimeToNext(msToNext) { } - SplineChainLink(uint32 expectedDuration, uint32 msToNext) : Points(), ExpectedDuration(expectedDuration), TimeToNext(msToNext) { } + SplineChainLink(Movement::PointsArray const& points, uint32 expectedDuration, uint32 msToNext, float velocity) : Points(points), ExpectedDuration(expectedDuration), TimeToNext(msToNext), Velocity(velocity) { } + template SplineChainLink(iteratorType begin, iteratorType end, uint32 expectedDuration, uint32 msToNext, float velocity) : Points(begin, end), ExpectedDuration(expectedDuration), TimeToNext(msToNext), Velocity(velocity) { } + SplineChainLink(uint32 expectedDuration, uint32 msToNext, float velocity) : Points(), ExpectedDuration(expectedDuration), TimeToNext(msToNext), Velocity(velocity) { } Movement::PointsArray Points; uint32 ExpectedDuration; uint32 TimeToNext; + float Velocity; }; struct TC_GAME_API SplineChainResumeInfo diff --git a/src/server/game/Scripting/ScriptSystem.cpp b/src/server/game/Scripting/ScriptSystem.cpp index 56673675f4..425147f32e 100644 --- a/src/server/game/Scripting/ScriptSystem.cpp +++ b/src/server/game/Scripting/ScriptSystem.cpp @@ -95,8 +95,8 @@ void SystemMgr::LoadScriptSplineChains() m_mSplineChainsMap.clear(); - // 0 1 2 3 4 - QueryResult resultMeta = WorldDatabase.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 + QueryResult resultMeta = WorldDatabase.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 QueryResult resultWP = WorldDatabase.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 || !resultWP) @@ -122,7 +122,8 @@ void SystemMgr::LoadScriptSplineChains() uint32 expectedDuration = fieldsMeta[3].GetUInt32(); uint32 msUntilNext = fieldsMeta[4].GetUInt32(); - chain.emplace_back(expectedDuration, msUntilNext); + float velocity = fieldsMeta[5].GetFloat(); + chain.emplace_back(expectedDuration, msUntilNext, velocity); if (splineId == 0) ++chainCount;