Core/Movement: implement cyclic path motion master helper to allow creatures to move along hardcoded spline points that are perfect circles

This commit is contained in:
Ovahlord
2019-10-05 06:30:55 +02:00
parent 393664186a
commit e135d35551
2 changed files with 27 additions and 0 deletions

View File

@@ -512,6 +512,32 @@ void MotionMaster::MoveCirclePath(float x, float y, float z, float radius, bool
init.Launch();
}
void MotionMaster::MoveCyclicPath(Position const* pathPoints, size_t pathSize, bool walk /*= false*/, bool fly /*= false*/, float velocity /*= 0.0f*/)
{
Movement::MoveSplineInit init(_owner);
Movement::PointsArray path;
path.reserve(pathSize);
std::transform(pathPoints, pathPoints + pathSize, std::back_inserter(path), [](Position const& point)
{
return G3D::Vector3(point.GetPositionX(), point.GetPositionY(), point.GetPositionZ());
});
if (fly)
{
init.SetFly();
init.SetUncompressed();
}
if (velocity > 0.0f)
init.SetVelocity(velocity);
init.MovebyPath(path);
init.SetSmooth();
init.SetWalk(walk);
init.SetCyclic();
init.Launch();
}
void MotionMaster::MoveSmoothPath(uint32 pointId, Position const* pathPoints, size_t pathSize, bool walk /*= false*/, bool fly /*= false*/, float velocity /*= 0.0f*/)
{
Movement::MoveSplineInit init(_owner);

View File

@@ -185,6 +185,7 @@ class TC_GAME_API MotionMaster
}
void MoveJump(float x, float y, float z, float o, float speedXY, float speedZ, uint32 id = EVENT_JUMP, bool hasOrientation = false);
void MoveCirclePath(float x, float y, float z, float radius, bool clockwise, uint8 stepCount);
void MoveCyclicPath(Position const* pathPoints, size_t pathSize, bool walk = false, bool fly = false, float velocity = 0.0f);
void MoveSmoothPath(uint32 pointId, Position const* pathPoints, size_t pathSize, bool walk = false, bool fly = false, float velocity = 0.0f);
// Walk along spline chain stored in DB (script_spline_chain_meta and script_spline_chain_waypoints)
void MoveAlongSplineChain(uint32 pointId, uint16 dbChainId, bool walk);