mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-23 18:36:31 +01:00
*Fix the lurker below. Thanks to rat.
--HG-- branch : trunk
This commit is contained in:
@@ -57,14 +57,14 @@ bool RotateMovementGenerator::Update(Unit& owner, const uint32& diff)
|
||||
float angle = owner.GetOrientation();
|
||||
if(m_direction == ROTATE_DIRECTION_LEFT)
|
||||
{
|
||||
angle += diff / m_duration * M_PI * 2;
|
||||
if(angle >= M_PI * 2 ) angle = 0;
|
||||
angle += (float)diff * M_PI * 2 / m_maxDuration;
|
||||
while(angle >= M_PI * 2 ) angle -= M_PI * 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
angle -= diff / m_duration * M_PI * 2;
|
||||
if(angle < 0) angle = M_PI * 2;
|
||||
}
|
||||
angle -= (float)diff * M_PI * 2 / m_maxDuration;
|
||||
while(angle < 0) angle += M_PI * 2;
|
||||
}
|
||||
owner.SetOrientation(angle);
|
||||
owner.SendMovementFlagUpdate(); // this is a hack. we do not have anything correct to send in the beginning
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ extern IdleMovementGenerator si_idleMovement;
|
||||
class TRINITY_DLL_SPEC RotateMovementGenerator : public MovementGenerator
|
||||
{
|
||||
public:
|
||||
explicit RotateMovementGenerator(uint32 time, RotateDirection direction) : m_duration(time), m_direction(direction) {}
|
||||
explicit RotateMovementGenerator(uint32 time, RotateDirection direction) : m_duration(time), m_maxDuration(time), m_direction(direction) {}
|
||||
|
||||
void Initialize(Unit& owner);
|
||||
void Finalize(Unit& owner);
|
||||
@@ -48,7 +48,7 @@ class TRINITY_DLL_SPEC RotateMovementGenerator : public MovementGenerator
|
||||
MovementGeneratorType GetMovementGeneratorType() { return ROTATE_MOTION_TYPE; }
|
||||
|
||||
private:
|
||||
uint32 m_duration;
|
||||
uint32 m_duration, m_maxDuration;
|
||||
RotateDirection m_direction;
|
||||
};
|
||||
|
||||
|
||||
@@ -521,6 +521,9 @@ void MotionMaster::MovePath(uint32 path_id, bool repeatable)
|
||||
|
||||
void MotionMaster::MoveRotate(uint32 time, RotateDirection direction)
|
||||
{
|
||||
if(!time)
|
||||
return;
|
||||
|
||||
Mutate(new RotateMovementGenerator(time, direction), MOTION_SLOT_ACTIVE);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user