aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorclick <click@users.noreply.github.com>2015-03-15 21:32:35 +0100
committerclick <click@users.noreply.github.com>2015-03-15 21:32:35 +0100
commitcf14e9051d15e33ca9fa87be3287d2a628faedef (patch)
treedb422c5a10943a78b4b96b2ce33dade77a6adcb5
parentfc973e4a1cddbf31c777b67774d04e583b2a9508 (diff)
parent61557ee7c6a4bdf844b7bcfef552908c83b4e297 (diff)
Merge pull request #14371 from Kittnz/movecirclepath_003
Core: Move FillCirclePath function to MotionMaster Closes #14371
-rw-r--r--src/server/game/Movement/MotionMaster.cpp37
-rw-r--r--src/server/game/Movement/MotionMaster.h1
-rw-r--r--src/server/scripts/Northrend/FrozenHalls/HallsOfReflection/halls_of_reflection.cpp23
-rw-r--r--src/server/scripts/Northrend/Nexus/EyeOfEternity/boss_malygos.cpp43
-rw-r--r--src/server/scripts/Northrend/Ulduar/Ulduar/boss_yogg_saron.cpp21
5 files changed, 42 insertions, 83 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);
diff --git a/src/server/scripts/Northrend/FrozenHalls/HallsOfReflection/halls_of_reflection.cpp b/src/server/scripts/Northrend/FrozenHalls/HallsOfReflection/halls_of_reflection.cpp
index 9edde447f32..927ebfbc55c 100644
--- a/src/server/scripts/Northrend/FrozenHalls/HallsOfReflection/halls_of_reflection.cpp
+++ b/src/server/scripts/Northrend/FrozenHalls/HallsOfReflection/halls_of_reflection.cpp
@@ -2640,13 +2640,7 @@ class npc_quel_delar_sword : public CreatureScript
break;
case EVENT_QUEL_DELAR_FLIGHT:
{
- Movement::MoveSplineInit init(me);
- FillCirclePath(QuelDelarCenterPos, 18.0f, 718.046f, init.Path(), true);
- init.SetFly();
- init.SetCyclic();
- init.SetAnimation(Movement::ToFly);
- init.Launch();
-
+ me->GetMotionMaster()->MoveCirclePath(QuelDelarCenterPos.GetPositionX(), QuelDelarCenterPos.GetPositionY(), 718.046f, 18.0f, true, 16);
_events.ScheduleEvent(EVENT_QUEL_DELAR_LAND, 15000);
break;
}
@@ -2694,21 +2688,6 @@ class npc_quel_delar_sword : public CreatureScript
}
private:
- void FillCirclePath(Position const& centerPos, float radius, float z, Movement::PointsArray& path, bool clockwise)
- {
- float step = clockwise ? -M_PI / 8.0f : M_PI / 8.0f;
- float angle = centerPos.GetAngle(me->GetPositionX(), me->GetPositionY());
-
- for (uint8 i = 0; i < 16; angle += step, ++i)
- {
- G3D::Vector3 point;
- point.x = centerPos.GetPositionX() + radius * cosf(angle);
- point.y = centerPos.GetPositionY() + radius * sinf(angle);
- point.z = z;
- path.push_back(point);
- }
- }
-
EventMap _events;
InstanceScript* _instance;
bool _intro;
diff --git a/src/server/scripts/Northrend/Nexus/EyeOfEternity/boss_malygos.cpp b/src/server/scripts/Northrend/Nexus/EyeOfEternity/boss_malygos.cpp
index 43069f10464..6c3b2187325 100644
--- a/src/server/scripts/Northrend/Nexus/EyeOfEternity/boss_malygos.cpp
+++ b/src/server/scripts/Northrend/Nexus/EyeOfEternity/boss_malygos.cpp
@@ -520,11 +520,7 @@ public:
_despawned = false;
break;
case ACTION_CYCLIC_MOVEMENT:
- Movement::MoveSplineInit init(me);
- FillCirclePath(MalygosPositions[3], 120.0f, 283.2763f, init.Path(), true);
- init.SetFly();
- init.SetCyclic();
- init.Launch();
+ me->GetMotionMaster()->MoveCirclePath(MalygosPositions[3].GetPositionX(), MalygosPositions[3].GetPositionY(), 283.2763f, 120.0f, true, 16);
break;
}
}
@@ -1020,22 +1016,6 @@ public:
}
private:
- // Used to generate perfect cyclic movements (Enter Circle).
- void FillCirclePath(Position const& centerPos, float radius, float z, Movement::PointsArray& path, bool clockwise)
- {
- float step = clockwise ? float(-M_PI) / 8.0f : float(M_PI) / 8.0f;
- float angle = centerPos.GetAngle(me->GetPositionX(), me->GetPositionY());
-
- for (uint8 i = 0; i < 16; angle += step, ++i)
- {
- G3D::Vector3 point;
- point.x = centerPos.GetPositionX() + radius * cosf(angle);
- point.y = centerPos.GetPositionY() + radius * sinf(angle);
- point.z = z; // Don't use any height getters unless all bugs are fixed.
- path.push_back(point);
- }
- }
-
uint8 _phase; // Counter for phases used with a getter.
uint8 _summonDeaths; // Keeps count of arcane trash.
uint8 _preparingPulsesChecker; // In retail they use 2 preparing pulses with 7 sec CD, after they pass 2 seconds.
@@ -1326,11 +1306,7 @@ public:
{
if (action < ACTION_DELAYED_DESPAWN)
{
- Movement::MoveSplineInit init(me);
- FillCirclePath(MalygosPositions[3], 35.0f, 282.3402f, init.Path(), true);
- init.SetFly();
- init.SetCyclic();
- init.Launch();
+ me->GetMotionMaster()->MoveCirclePath(MalygosPositions[3].GetPositionX(), MalygosPositions[3].GetPositionY(), 282.3402f, 35.0f, true, 16);
}
else
{
@@ -1339,21 +1315,6 @@ public:
}
private:
- void FillCirclePath(Position const& centerPos, float radius, float z, Movement::PointsArray& path, bool clockwise)
- {
- float step = clockwise ? float(-M_PI) / 9.0f : float(M_PI) / 9.0f;
- float angle = centerPos.GetAngle(me->GetPositionX(), me->GetPositionY());
-
- for (uint8 i = 0; i < 18; angle += step, ++i)
- {
- G3D::Vector3 point;
- point.x = centerPos.GetPositionX() + radius * cosf(angle);
- point.y = centerPos.GetPositionY() + radius * sinf(angle);
- point.z = z; // Don't use any height getters unless all bugs are fixed.
- path.push_back(point);
- }
- }
-
InstanceScript* _instance;
};
diff --git a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_yogg_saron.cpp b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_yogg_saron.cpp
index a682e405d08..a7a9f8dde88 100644
--- a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_yogg_saron.cpp
+++ b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_yogg_saron.cpp
@@ -1126,30 +1126,11 @@ class npc_ominous_cloud : public CreatureScript
DoCast(me, SPELL_OMINOUS_CLOUD_VISUAL);
}
- void FillCirclePath(Position const& centerPos, float radius, float z, Movement::PointsArray& path, bool clockwise)
- {
- float step = clockwise ? float(-M_PI) / 8.0f : float(M_PI) / 8.0f;
- float angle = centerPos.GetAngle(me->GetPositionX(), me->GetPositionY());
-
- for (uint8 i = 0; i < 16; angle += step, ++i)
- {
- G3D::Vector3 point;
- point.x = centerPos.GetPositionX() + radius * cosf(angle);
- point.y = centerPos.GetPositionY() + radius * sinf(angle);
- point.z = me->GetMap()->GetHeight(me->GetPhaseMask(), point.x, point.y, z + 5.0f);
- path.push_back(point);
- }
- }
-
void UpdateAI(uint32 /*diff*/) override { }
void DoAction(int32 action) override
{
- Movement::MoveSplineInit init(me);
- FillCirclePath(YoggSaronSpawnPos, me->GetDistance2d(YoggSaronSpawnPos.GetPositionX(), YoggSaronSpawnPos.GetPositionY()), me->GetPositionZ(), init.Path(), action != 0);
- init.SetWalk(true);
- init.SetCyclic();
- init.Launch();
+ me->GetMotionMaster()->MoveCirclePath(YoggSaronSpawnPos.GetPositionX(), YoggSaronSpawnPos.GetPositionY(), me->GetPositionZ() + 5.0f, me->GetDistance2d(YoggSaronSpawnPos.GetPositionX(), YoggSaronSpawnPos.GetPositionY()), true, 16);
}
};