mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-16 07:30:42 +01:00
Core/Movement: MoveCirclePath new features
* Duration limit * Customizable speed
This commit is contained in:
@@ -865,7 +865,8 @@ void MotionMaster::MoveJump(float x, float y, float z, float o, float speedXY, f
|
||||
arrivalSpellTargetGuid = arrivalCast->Target;
|
||||
}
|
||||
|
||||
GenericMovementGenerator* movement = new GenericMovementGenerator(std::move(initializer), EFFECT_MOTION_TYPE, id, arrivalSpellId, arrivalSpellTargetGuid);
|
||||
GenericMovementGenerator* movement = new GenericMovementGenerator(std::move(initializer), EFFECT_MOTION_TYPE, id,
|
||||
{ .ArrivalSpellId = arrivalSpellId, .ArrivalSpellTarget = arrivalSpellTargetGuid });
|
||||
movement->Priority = MOTION_PRIORITY_HIGHEST;
|
||||
movement->BaseUnitState = UNIT_STATE_JUMPING;
|
||||
Add(movement);
|
||||
@@ -899,14 +900,17 @@ void MotionMaster::MoveJumpWithGravity(Position const& pos, float speedXY, float
|
||||
arrivalSpellTargetGuid = arrivalCast->Target;
|
||||
}
|
||||
|
||||
GenericMovementGenerator* movement = new GenericMovementGenerator(std::move(initializer), EFFECT_MOTION_TYPE, id, arrivalSpellId, arrivalSpellTargetGuid);
|
||||
GenericMovementGenerator* movement = new GenericMovementGenerator(std::move(initializer), EFFECT_MOTION_TYPE, id,
|
||||
{ .ArrivalSpellId = arrivalSpellId, .ArrivalSpellTarget = arrivalSpellTargetGuid });
|
||||
movement->Priority = MOTION_PRIORITY_HIGHEST;
|
||||
movement->BaseUnitState = UNIT_STATE_JUMPING;
|
||||
movement->AddFlag(MOVEMENTGENERATOR_FLAG_PERSIST_ON_DEATH);
|
||||
Add(movement);
|
||||
}
|
||||
|
||||
void MotionMaster::MoveCirclePath(float x, float y, float z, float radius, bool clockwise, uint8 stepCount)
|
||||
void MotionMaster::MoveCirclePath(float x, float y, float z, float radius, bool clockwise, uint8 stepCount,
|
||||
Optional<Milliseconds> duration /*= {}*/, Optional<float> speed /*= {}*/,
|
||||
MovementWalkRunSpeedSelectionMode speedSelectionMode /*= MovementWalkRunSpeedSelectionMode::Default*/)
|
||||
{
|
||||
std::function<void(Movement::MoveSplineInit&)> initializer = [=, this](Movement::MoveSplineInit& init)
|
||||
{
|
||||
@@ -915,11 +919,11 @@ void MotionMaster::MoveCirclePath(float x, float y, float z, float radius, bool
|
||||
float angle = pos.GetAbsoluteAngle(_owner->GetPositionX(), _owner->GetPositionY());
|
||||
|
||||
// add the owner's current position as starting point as it gets removed after entering the cycle
|
||||
init.Path().push_back(G3D::Vector3(_owner->GetPositionX(), _owner->GetPositionY(), _owner->GetPositionZ()));
|
||||
init.Path().emplace_back(_owner->GetPositionX(), _owner->GetPositionY(), _owner->GetPositionZ());
|
||||
|
||||
for (uint8 i = 0; i < stepCount; angle += step, ++i)
|
||||
{
|
||||
G3D::Vector3 point;
|
||||
G3D::Vector3& point = init.Path().emplace_back();
|
||||
point.x = x + radius * cosf(angle);
|
||||
point.y = y + radius * sinf(angle);
|
||||
|
||||
@@ -927,24 +931,34 @@ void MotionMaster::MoveCirclePath(float x, float y, float z, float radius, bool
|
||||
point.z = z;
|
||||
else
|
||||
point.z = _owner->GetMapHeight(point.x, point.y, z) + _owner->GetHoverOffset();
|
||||
|
||||
init.Path().push_back(point);
|
||||
}
|
||||
|
||||
init.SetCyclic();
|
||||
if (_owner->IsFlying())
|
||||
{
|
||||
init.SetFly();
|
||||
init.SetCyclic();
|
||||
init.SetAnimation(AnimTier::Hover);
|
||||
}
|
||||
else
|
||||
{
|
||||
init.SetWalk(true);
|
||||
init.SetCyclic();
|
||||
|
||||
switch (speedSelectionMode)
|
||||
{
|
||||
case MovementWalkRunSpeedSelectionMode::ForceRun:
|
||||
init.SetWalk(false);
|
||||
break;
|
||||
case MovementWalkRunSpeedSelectionMode::ForceWalk:
|
||||
init.SetWalk(true);
|
||||
break;
|
||||
case MovementWalkRunSpeedSelectionMode::Default:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if (speed)
|
||||
init.SetVelocity(*speed);
|
||||
};
|
||||
|
||||
Add(new GenericMovementGenerator(std::move(initializer), EFFECT_MOTION_TYPE, 0));
|
||||
Add(new GenericMovementGenerator(std::move(initializer), EFFECT_MOTION_TYPE, 0, { .Duration = duration }));
|
||||
}
|
||||
|
||||
void MotionMaster::MoveSmoothPath(uint32 pointId, Position const* pathPoints, size_t pathSize, bool walk, bool fly)
|
||||
|
||||
Reference in New Issue
Block a user