diff options
| author | click <click@users.noreply.github.com> | 2015-03-15 21:32:35 +0100 |
|---|---|---|
| committer | click <click@users.noreply.github.com> | 2015-03-15 21:32:35 +0100 |
| commit | cf14e9051d15e33ca9fa87be3287d2a628faedef (patch) | |
| tree | db422c5a10943a78b4b96b2ce33dade77a6adcb5 /src/server/game | |
| parent | fc973e4a1cddbf31c777b67774d04e583b2a9508 (diff) | |
| parent | 61557ee7c6a4bdf844b7bcfef552908c83b4e297 (diff) | |
Merge pull request #14371 from Kittnz/movecirclepath_003
Core: Move FillCirclePath function to MotionMaster
Closes #14371
Diffstat (limited to 'src/server/game')
| -rw-r--r-- | src/server/game/Movement/MotionMaster.cpp | 37 | ||||
| -rw-r--r-- | src/server/game/Movement/MotionMaster.h | 1 |
2 files changed, 38 insertions, 0 deletions
diff --git a/src/server/game/Movement/MotionMaster.cpp b/src/server/game/Movement/MotionMaster.cpp index 47e5b77a0da..bda3ad851c8 100644 --- a/src/server/game/Movement/MotionMaster.cpp +++ b/src/server/game/Movement/MotionMaster.cpp @@ -387,6 +387,43 @@ void MotionMaster::MoveJump(float x, float y, float z, float speedXY, float spee Mutate(new EffectMovementGenerator(id), MOTION_SLOT_CONTROLLED); } +void MotionMaster::MoveCirclePath(float x, float y, float z, float radius, bool clockwise, uint8 stepCount) +{ + float step = 2 * float(M_PI) / stepCount * (clockwise ? -1.0f : 1.0f); + Position const& pos = { x, y, z, 0.0f }; + float angle = pos.GetAngle(_owner->GetPositionX(), _owner->GetPositionY()); + + Movement::MoveSplineInit init(_owner); + + for (uint8 i = 0; i < stepCount; angle += step, ++i) + { + G3D::Vector3 point; + point.x = x + radius * cosf(angle); + point.y = y + radius * sinf(angle); + + if (_owner->IsFlying()) + point.z = z; + else + point.z = _owner->GetMap()->GetHeight(_owner->GetPhaseMask(), point.x, point.y, z); + + init.Path().push_back(point); + } + + if (_owner->IsFlying()) + { + init.SetFly(); + init.SetCyclic(); + init.SetAnimation(Movement::ToFly); + } + else + { + init.SetWalk(true); + init.SetCyclic(); + } + + init.Launch(); +} + void MotionMaster::MoveFall(uint32 id /*=0*/) { // use larger distance for vmap height search than in most other cases diff --git a/src/server/game/Movement/MotionMaster.h b/src/server/game/Movement/MotionMaster.h index 2821cd5a59b..0b547d96e7f 100644 --- a/src/server/game/Movement/MotionMaster.h +++ b/src/server/game/Movement/MotionMaster.h @@ -184,6 +184,7 @@ class MotionMaster //: private std::stack<MovementGenerator *> void MoveJump(Position const& pos, float speedXY, float speedZ, uint32 id = EVENT_JUMP) { MoveJump(pos.m_positionX, pos.m_positionY, pos.m_positionZ, speedXY, speedZ, id); }; void MoveJump(float x, float y, float z, float speedXY, float speedZ, uint32 id = EVENT_JUMP); + void MoveCirclePath(float x, float y, float z, float radius, bool clockwise, uint8 stepCount); void MoveFall(uint32 id = 0); void MoveSeekAssistance(float x, float y, float z); |
