aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/server/game/Entities/Unit/Unit.cpp31
-rw-r--r--src/server/game/Entities/Vehicle/Vehicle.cpp14
-rw-r--r--src/server/game/Handlers/MovementHandler.cpp7
-rw-r--r--src/server/game/Movement/MotionMaster.cpp196
-rw-r--r--src/server/game/Movement/MotionMaster.h2
-rw-r--r--src/server/game/Movement/MovementGenerators/GenericMovementGenerator.cpp10
-rw-r--r--src/server/game/Movement/MovementGenerators/GenericMovementGenerator.h5
-rw-r--r--src/server/game/Movement/Spline/MoveSplineInit.h1
-rw-r--r--src/server/scripts/EasternKingdoms/ScarletEnclave/chapter1.cpp18
-rw-r--r--src/server/scripts/Kalimdor/CavernsOfTime/CullingOfStratholme/npc_arthas.cpp14
-rw-r--r--src/server/scripts/Northrend/IcecrownCitadel/boss_icecrown_gunship_battle.cpp44
-rw-r--r--src/server/scripts/Northrend/IcecrownCitadel/boss_lord_marrowgar.cpp10
-rw-r--r--src/server/scripts/Northrend/Naxxramas/naxxramas.cpp12
-rw-r--r--src/server/scripts/Northrend/Ulduar/Ulduar/boss_algalon_the_observer.cpp10
-rw-r--r--src/server/scripts/Northrend/Ulduar/Ulduar/boss_razorscale.cpp14
-rw-r--r--src/server/scripts/Northrend/Ulduar/Ulduar/boss_thorim.cpp18
-rw-r--r--src/server/scripts/Northrend/UtgardeKeep/UtgardePinnacle/boss_skadi.cpp10
-rw-r--r--src/server/scripts/Northrend/UtgardeKeep/UtgardePinnacle/boss_svala.cpp10
-rw-r--r--src/server/scripts/World/npcs_special.cpp12
19 files changed, 243 insertions, 195 deletions
diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp
index b78cfb76e25..07a5fb86fe6 100644
--- a/src/server/game/Entities/Unit/Unit.cpp
+++ b/src/server/game/Entities/Unit/Unit.cpp
@@ -525,10 +525,12 @@ bool Unit::haveOffhandWeapon() const
void Unit::MonsterMoveWithSpeed(float x, float y, float z, float speed, bool generatePath, bool forceDestination)
{
- Movement::MoveSplineInit init(this);
- init.MoveTo(x, y, z, generatePath, forceDestination);
- init.SetVelocity(speed);
- GetMotionMaster()->LaunchMoveSpline(std::move(init), 0, MOTION_PRIORITY_NORMAL, POINT_MOTION_TYPE);
+ std::function<void(Movement::MoveSplineInit&)> initializer = [=](Movement::MoveSplineInit& init)
+ {
+ init.MoveTo(x, y, z, generatePath, forceDestination);
+ init.SetVelocity(speed);
+ };
+ GetMotionMaster()->LaunchMoveSpline(std::move(initializer), 0, MOTION_PRIORITY_NORMAL, POINT_MOTION_TYPE);
}
void Unit::UpdateSplineMovement(uint32 t_diff)
@@ -12179,18 +12181,19 @@ void Unit::_ExitVehicle(Position const* exitPosition)
}
}
- float height = pos.GetPositionZ() + vehicle->GetBase()->GetCollisionHeight();
-
- Movement::MoveSplineInit init(this);
+ std::function<void(Movement::MoveSplineInit&)> initializer = [=](Movement::MoveSplineInit& init)
+ {
+ float height = pos.GetPositionZ() + vehicle->GetBase()->GetCollisionHeight();
- // Creatures without inhabit type air should begin falling after exiting the vehicle
- if (GetTypeId() == TYPEID_UNIT && !CanFly() && height > GetMap()->GetWaterOrGroundLevel(GetPhaseShift(), pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ() + vehicle->GetBase()->GetCollisionHeight(), &height))
- init.SetFall();
+ // Creatures without inhabit type air should begin falling after exiting the vehicle
+ if (GetTypeId() == TYPEID_UNIT && !CanFly() && height > GetMap()->GetWaterOrGroundLevel(GetPhaseShift(), pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ() + vehicle->GetBase()->GetCollisionHeight(), &height))
+ init.SetFall();
- init.MoveTo(pos.GetPositionX(), pos.GetPositionY(), height, false);
- init.SetFacing(pos.GetOrientation());
- init.SetTransportExit();
- GetMotionMaster()->LaunchMoveSpline(std::move(init), EVENT_VEHICLE_EXIT, MOTION_PRIORITY_HIGHEST);
+ init.MoveTo(pos.GetPositionX(), pos.GetPositionY(), height, false);
+ init.SetFacing(pos.GetOrientation());
+ init.SetTransportExit();
+ };
+ GetMotionMaster()->LaunchMoveSpline(std::move(initializer), EVENT_VEHICLE_EXIT, MOTION_PRIORITY_HIGHEST);
if (player)
player->ResummonPetTemporaryUnSummonedIfAny();
diff --git a/src/server/game/Entities/Vehicle/Vehicle.cpp b/src/server/game/Entities/Vehicle/Vehicle.cpp
index cab96560c1d..a111a07ba71 100644
--- a/src/server/game/Entities/Vehicle/Vehicle.cpp
+++ b/src/server/game/Entities/Vehicle/Vehicle.cpp
@@ -884,12 +884,14 @@ bool VehicleJoinEvent::Execute(uint64, uint32)
Passenger->SetControlled(true, UNIT_STATE_ROOT); // SMSG_FORCE_ROOT - In some cases we send SMSG_SPLINE_MOVE_ROOT here (for creatures)
// also adds MOVEMENTFLAG_ROOT
- Movement::MoveSplineInit init(Passenger);
- init.DisableTransportPathTransformations();
- init.MoveTo(x, y, z, false, true);
- init.SetFacing(o);
- init.SetTransportEnter();
- Passenger->GetMotionMaster()->LaunchMoveSpline(std::move(init), EVENT_VEHICLE_BOARD, MOTION_PRIORITY_HIGHEST);
+ std::function<void(Movement::MoveSplineInit&)> initializer = [=](Movement::MoveSplineInit& init)
+ {
+ init.DisableTransportPathTransformations();
+ init.MoveTo(x, y, z, false, true);
+ init.SetFacing(o);
+ init.SetTransportEnter();
+ };
+ Passenger->GetMotionMaster()->LaunchMoveSpline(std::move(initializer), EVENT_VEHICLE_BOARD, MOTION_PRIORITY_HIGHEST);
for (auto const& [guid, threatRef] : Passenger->GetThreatManager().GetThreatenedByMeList())
threatRef->GetOwner()->GetThreatManager().AddThreat(Target->GetBase(), threatRef->GetThreat(), nullptr, true, true);
diff --git a/src/server/game/Handlers/MovementHandler.cpp b/src/server/game/Handlers/MovementHandler.cpp
index 2c8f70db994..a8cd953abb7 100644
--- a/src/server/game/Handlers/MovementHandler.cpp
+++ b/src/server/game/Handlers/MovementHandler.cpp
@@ -320,10 +320,7 @@ void WorldSession::HandleMovementOpcode(OpcodeClient opcode, MovementInfo& movem
}
if (!movementInfo.pos.IsPositionValid())
- {
- TC_LOG_ERROR("network", "HandleMovementOpcodes: Invalid Position");
return;
- }
if (!mover->movespline->Finalized())
return;
@@ -342,15 +339,11 @@ void WorldSession::HandleMovementOpcode(OpcodeClient opcode, MovementInfo& movem
// transports size limited
// (also received at zeppelin leave by some reason with t_* as absolute in continent coordinates, can be safely skipped)
if (fabs(movementInfo.transport.pos.GetPositionX()) > 75.0f || fabs(movementInfo.transport.pos.GetPositionY()) > 75.0f || fabs(movementInfo.transport.pos.GetPositionZ()) > 75.0f)
- {
return;
- }
if (!Trinity::IsValidMapCoord(movementInfo.pos.GetPositionX() + movementInfo.transport.pos.GetPositionX(), movementInfo.pos.GetPositionY() + movementInfo.transport.pos.GetPositionY(),
movementInfo.pos.GetPositionZ() + movementInfo.transport.pos.GetPositionZ(), movementInfo.pos.GetOrientation() + movementInfo.transport.pos.GetOrientation()))
- {
return;
- }
// if we boarded a transport, add us to it
if (plrMover)
diff --git a/src/server/game/Movement/MotionMaster.cpp b/src/server/game/Movement/MotionMaster.cpp
index b0a8aa1fa70..e7dc9d6f632 100644
--- a/src/server/game/Movement/MotionMaster.cpp
+++ b/src/server/game/Movement/MotionMaster.cpp
@@ -27,6 +27,7 @@
#include "Map.h"
#include "MoveSpline.h"
#include "MoveSplineInit.h"
+#include "ObjectAccessor.h"
#include "PathGenerator.h"
#include "PetDefines.h"
#include "Player.h"
@@ -687,10 +688,13 @@ void MotionMaster::MoveCloserAndStop(uint32 id, Unit* target, float distance)
else
{
// We are already close enough. We just need to turn toward the target without changing position.
- Movement::MoveSplineInit init(_owner);
- init.MoveTo(_owner->GetPositionX(), _owner->GetPositionY(), _owner->GetPositionZ());
- init.SetFacing(target);
- Add(new GenericMovementGenerator(std::move(init), EFFECT_MOTION_TYPE, id));
+ std::function<void(Movement::MoveSplineInit&)> initializer = [=, target = target->GetGUID()](Movement::MoveSplineInit& init)
+ {
+ init.MoveTo(_owner->GetPositionX(), _owner->GetPositionY(), _owner->GetPositionZ());
+ if (Unit const* refreshedTarget = ObjectAccessor::GetUnit(*_owner, target))
+ init.SetFacing(refreshedTarget);
+ };
+ Add(new GenericMovementGenerator(std::move(initializer), EFFECT_MOTION_TYPE, id));
}
}
@@ -698,24 +702,28 @@ void MotionMaster::MoveLand(uint32 id, Position const& pos, Optional<float> velo
{
TC_LOG_DEBUG("movement.motionmaster", "MotionMaster::MoveLand: '%s', landing point Id: %u (X: %f, Y: %f, Z: %f)", _owner->GetGUID().ToString().c_str(), id, pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ());
- Movement::MoveSplineInit init(_owner);
- init.MoveTo(PositionToVector3(pos), false);
- init.SetAnimation(AnimTier::Ground);
- if (velocity)
- init.SetVelocity(*velocity);
- Add(new GenericMovementGenerator(std::move(init), EFFECT_MOTION_TYPE, id));
+ std::function<void(Movement::MoveSplineInit&)> initializer = [=](Movement::MoveSplineInit& init)
+ {
+ init.MoveTo(PositionToVector3(pos), false);
+ init.SetAnimation(AnimTier::Ground);
+ if (velocity)
+ init.SetVelocity(*velocity);
+ };
+ Add(new GenericMovementGenerator(std::move(initializer), EFFECT_MOTION_TYPE, id));
}
void MotionMaster::MoveTakeoff(uint32 id, Position const& pos, Optional<float> velocity /*= {}*/)
{
TC_LOG_DEBUG("movement.motionmaster", "MotionMaster::MoveTakeoff: '%s', landing point Id: %u (X: %f, Y: %f, Z: %f)", _owner->GetGUID().ToString().c_str(), id, pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ());
- Movement::MoveSplineInit init(_owner);
- init.MoveTo(PositionToVector3(pos), false);
- init.SetAnimation(AnimTier::Hover);
- if (velocity)
- init.SetVelocity(*velocity);
- Add(new GenericMovementGenerator(std::move(init), EFFECT_MOTION_TYPE, id));
+ std::function<void(Movement::MoveSplineInit&)> initializer = [=](Movement::MoveSplineInit& init)
+ {
+ init.MoveTo(PositionToVector3(pos), false);
+ init.SetAnimation(AnimTier::Hover);
+ if (velocity)
+ init.SetVelocity(*velocity);
+ };
+ Add(new GenericMovementGenerator(std::move(initializer), EFFECT_MOTION_TYPE, id));
}
void MotionMaster::MoveCharge(float x, float y, float z, float speed /*= SPEED_CHARGE*/, uint32 id /*= EVENT_CHARGE*/, bool generatePath /*= false*/,
@@ -778,15 +786,17 @@ void MotionMaster::MoveKnockbackFrom(Position const& origin, float speedXY, floa
// Use a mmap raycast to get a valid destination.
_owner->MovePositionToFirstCollision(dest, dist, _owner->GetRelativeAngle(origin) + float(M_PI));
- Movement::MoveSplineInit init(_owner);
- init.MoveTo(dest.GetPositionX(), dest.GetPositionY(), dest.GetPositionZ(), false);
- init.SetParabolic(max_height, 0);
- init.SetOrientationFixed(true);
- init.SetVelocity(speedXY);
- if (spellEffectExtraData)
- init.SetSpellEffectExtraData(*spellEffectExtraData);
+ std::function<void(Movement::MoveSplineInit&)> initializer = [=, effect = (spellEffectExtraData ? Optional<Movement::SpellEffectExtraData>(*spellEffectExtraData) : Optional<Movement::SpellEffectExtraData>())](Movement::MoveSplineInit& init)
+ {
+ init.MoveTo(dest.GetPositionX(), dest.GetPositionY(), dest.GetPositionZ(), false);
+ init.SetParabolic(max_height, 0);
+ init.SetOrientationFixed(true);
+ init.SetVelocity(speedXY);
+ if (effect)
+ init.SetSpellEffectExtraData(*effect);
+ };
- GenericMovementGenerator* movement = new GenericMovementGenerator(std::move(init), EFFECT_MOTION_TYPE, 0);
+ GenericMovementGenerator* movement = new GenericMovementGenerator(std::move(initializer), EFFECT_MOTION_TYPE, 0);
movement->Priority = MOTION_PRIORITY_HIGHEST;
movement->AddFlag(MOVEMENTGENERATOR_FLAG_PERSIST_ON_DEATH);
Add(movement);
@@ -825,14 +835,16 @@ void MotionMaster::MoveJump(float x, float y, float z, float o, float speedXY, f
float moveTimeHalf = speedZ / Movement::gravity;
float max_height = -Movement::computeFallElevation(moveTimeHalf, false, -speedZ);
- Movement::MoveSplineInit init(_owner);
- init.MoveTo(x, y, z, false);
- init.SetParabolic(max_height, 0);
- init.SetVelocity(speedXY);
- if (hasOrientation)
- init.SetFacing(o);
- if (spellEffectExtraData)
- init.SetSpellEffectExtraData(*spellEffectExtraData);
+ std::function<void(Movement::MoveSplineInit&)> initializer = [=, effect = (spellEffectExtraData ? Optional<Movement::SpellEffectExtraData>(*spellEffectExtraData) : Optional<Movement::SpellEffectExtraData>())](Movement::MoveSplineInit& init)
+ {
+ init.MoveTo(x, y, z, false);
+ init.SetParabolic(max_height, 0);
+ init.SetVelocity(speedXY);
+ if (hasOrientation)
+ init.SetFacing(o);
+ if (effect)
+ init.SetSpellEffectExtraData(*effect);
+ };
uint32 arrivalSpellId = 0;
ObjectGuid arrivalSpellTargetGuid;
@@ -842,7 +854,7 @@ void MotionMaster::MoveJump(float x, float y, float z, float o, float speedXY, f
arrivalSpellTargetGuid = arrivalCast->Target;
}
- GenericMovementGenerator* movement = new GenericMovementGenerator(std::move(init), EFFECT_MOTION_TYPE, id, arrivalSpellId, arrivalSpellTargetGuid);
+ GenericMovementGenerator* movement = new GenericMovementGenerator(std::move(initializer), EFFECT_MOTION_TYPE, id, arrivalSpellId, arrivalSpellTargetGuid);
movement->Priority = MOTION_PRIORITY_HIGHEST;
movement->BaseUnitState = UNIT_STATE_JUMPING;
Add(movement);
@@ -855,15 +867,17 @@ void MotionMaster::MoveJumpWithGravity(Position const& pos, float speedXY, float
if (speedXY < 0.01f)
return;
- Movement::MoveSplineInit init(_owner);
- init.MoveTo(pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), false);
- init.SetParabolicVerticalAcceleration(gravity, 0);
- init.SetUncompressed();
- init.SetVelocity(speedXY);
- if (hasOrientation)
- init.SetFacing(pos.GetOrientation());
- if (spellEffectExtraData)
- init.SetSpellEffectExtraData(*spellEffectExtraData);
+ std::function<void(Movement::MoveSplineInit&)> initializer = [=, effect = (spellEffectExtraData ? Optional<Movement::SpellEffectExtraData>(*spellEffectExtraData) : Optional<Movement::SpellEffectExtraData>())](Movement::MoveSplineInit& init)
+ {
+ init.MoveTo(pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), false);
+ init.SetParabolicVerticalAcceleration(gravity, 0);
+ init.SetUncompressed();
+ init.SetVelocity(speedXY);
+ if (hasOrientation)
+ init.SetFacing(pos.GetOrientation());
+ if (effect)
+ init.SetSpellEffectExtraData(*effect);
+ };
uint32 arrivalSpellId = 0;
ObjectGuid arrivalSpellTargetGuid;
@@ -873,7 +887,7 @@ void MotionMaster::MoveJumpWithGravity(Position const& pos, float speedXY, float
arrivalSpellTargetGuid = arrivalCast->Target;
}
- GenericMovementGenerator* movement = new GenericMovementGenerator(std::move(init), EFFECT_MOTION_TYPE, id, arrivalSpellId, arrivalSpellTargetGuid);
+ GenericMovementGenerator* movement = new GenericMovementGenerator(std::move(initializer), EFFECT_MOTION_TYPE, id, arrivalSpellId, arrivalSpellTargetGuid);
movement->Priority = MOTION_PRIORITY_HIGHEST;
movement->BaseUnitState = UNIT_STATE_JUMPING;
movement->AddFlag(MOVEMENTGENERATOR_FLAG_PERSIST_ON_DEATH);
@@ -882,67 +896,69 @@ void MotionMaster::MoveJumpWithGravity(Position const& pos, float speedXY, float
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.GetAbsoluteAngle(_owner->GetPositionX(), _owner->GetPositionY());
+ std::function<void(Movement::MoveSplineInit&)> initializer = [=](Movement::MoveSplineInit& init)
+ {
+ float step = 2 * float(M_PI) / stepCount * (clockwise ? -1.0f : 1.0f);
+ Position const& pos = { x, y, z, 0.0f };
+ float angle = pos.GetAbsoluteAngle(_owner->GetPositionX(), _owner->GetPositionY());
- Movement::MoveSplineInit init(_owner);
+ // 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()));
- // 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()));
+ for (uint8 i = 0; i < stepCount; angle += step, ++i)
+ {
+ G3D::Vector3 point;
+ point.x = x + radius * cosf(angle);
+ point.y = y + radius * sinf(angle);
- 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->GetMapHeight(point.x, point.y, z) + _owner->GetHoverOffset();
+
+ init.Path().push_back(point);
+ }
if (_owner->IsFlying())
- point.z = z;
+ {
+ init.SetFly();
+ init.SetCyclic();
+ init.SetAnimation(AnimTier::Hover);
+ }
else
- point.z = _owner->GetMapHeight(point.x, point.y, z) + _owner->GetHoverOffset();
-
- init.Path().push_back(point);
- }
-
- if (_owner->IsFlying())
- {
- init.SetFly();
- init.SetCyclic();
- init.SetAnimation(AnimTier::Hover);
- }
- else
- {
- init.SetWalk(true);
- init.SetCyclic();
- }
+ {
+ init.SetWalk(true);
+ init.SetCyclic();
+ }
+ };
- Add(new GenericMovementGenerator(std::move(init), EFFECT_MOTION_TYPE, 0));
+ Add(new GenericMovementGenerator(std::move(initializer), EFFECT_MOTION_TYPE, 0));
}
void MotionMaster::MoveSmoothPath(uint32 pointId, Position const* pathPoints, size_t pathSize, bool walk, bool fly)
{
- Movement::MoveSplineInit init(_owner);
- if (fly)
- {
- init.SetFly();
- init.SetUncompressed();
- init.SetSmooth();
- }
-
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());
});
- init.MovebyPath(path);
- init.SetWalk(walk);
+ std::function<void(Movement::MoveSplineInit&)> initializer = [=](Movement::MoveSplineInit& init)
+ {
+ init.MovebyPath(path);
+ init.SetWalk(walk);
+ if (fly)
+ {
+ init.SetFly();
+ init.SetUncompressed();
+ init.SetSmooth();
+ }
+ };
// This code is not correct
// GenericMovementGenerator does not affect UNIT_STATE_ROAMING_MOVE
// need to call PointMovementGenerator with various pointIds
- Add(new GenericMovementGenerator(std::move(init), EFFECT_MOTION_TYPE, pointId));
+ Add(new GenericMovementGenerator(std::move(initializer), EFFECT_MOTION_TYPE, pointId));
}
void MotionMaster::MoveAlongSplineChain(uint32 pointId, uint16 dbChainId, bool walk)
@@ -1005,11 +1021,13 @@ void MotionMaster::MoveFall(uint32 id/* = 0*/)
return;
}
- Movement::MoveSplineInit init(_owner);
- init.MoveTo(_owner->GetPositionX(), _owner->GetPositionY(), tz + _owner->GetHoverOffset(), false);
- init.SetFall();
+ std::function<void(Movement::MoveSplineInit&)> initializer = [=](Movement::MoveSplineInit& init)
+ {
+ init.MoveTo(_owner->GetPositionX(), _owner->GetPositionY(), tz + _owner->GetHoverOffset(), false);
+ init.SetFall();
+ };
- GenericMovementGenerator* movement = new GenericMovementGenerator(std::move(init), EFFECT_MOTION_TYPE, id);
+ GenericMovementGenerator* movement = new GenericMovementGenerator(std::move(initializer), EFFECT_MOTION_TYPE, id);
movement->Priority = MOTION_PRIORITY_HIGHEST;
Add(movement);
}
@@ -1106,7 +1124,7 @@ void MotionMaster::MoveFormation(Unit* leader, float range, float angle, uint32
}
}
-void MotionMaster::LaunchMoveSpline(Movement::MoveSplineInit&& init, uint32 id/*= 0*/, MovementGeneratorPriority priority/* = MOTION_PRIORITY_NORMAL*/, MovementGeneratorType type/*= EFFECT_MOTION_TYPE*/)
+void MotionMaster::LaunchMoveSpline(std::function<void(Movement::MoveSplineInit& init)>&& initializer, uint32 id/*= 0*/, MovementGeneratorPriority priority/* = MOTION_PRIORITY_NORMAL*/, MovementGeneratorType type/*= EFFECT_MOTION_TYPE*/)
{
if (IsInvalidMovementGeneratorType(type))
{
@@ -1116,7 +1134,7 @@ void MotionMaster::LaunchMoveSpline(Movement::MoveSplineInit&& init, uint32 id/*
TC_LOG_DEBUG("movement.motionmaster", "MotionMaster::LaunchMoveSpline: '%s', initiates spline Id: %u (Type: %u, Priority: %u)", _owner->GetGUID().ToString().c_str(), id, type, priority);
- GenericMovementGenerator* movement = new GenericMovementGenerator(std::move(init), type, id);
+ GenericMovementGenerator* movement = new GenericMovementGenerator(std::move(initializer), type, id);
movement->Priority = priority;
Add(movement);
}
diff --git a/src/server/game/Movement/MotionMaster.h b/src/server/game/Movement/MotionMaster.h
index 1b558df44d5..01b1bf125a6 100644
--- a/src/server/game/Movement/MotionMaster.h
+++ b/src/server/game/Movement/MotionMaster.h
@@ -195,7 +195,7 @@ class TC_GAME_API MotionMaster
void MoveRotate(uint32 id, uint32 time, RotateDirection direction);
void MoveFormation(Unit* leader, float range, float angle, uint32 point1, uint32 point2);
- void LaunchMoveSpline(Movement::MoveSplineInit&& init, uint32 id = 0, MovementGeneratorPriority priority = MOTION_PRIORITY_NORMAL, MovementGeneratorType type = EFFECT_MOTION_TYPE);
+ void LaunchMoveSpline(std::function<void(Movement::MoveSplineInit& init)>&& initializer, uint32 id = 0, MovementGeneratorPriority priority = MOTION_PRIORITY_NORMAL, MovementGeneratorType type = EFFECT_MOTION_TYPE);
private:
typedef std::unique_ptr<MovementGenerator, MovementGeneratorDeleter> MovementGeneratorPointer;
typedef std::multiset<MovementGenerator*, MovementGeneratorComparator> MotionMasterContainer;
diff --git a/src/server/game/Movement/MovementGenerators/GenericMovementGenerator.cpp b/src/server/game/Movement/MovementGenerators/GenericMovementGenerator.cpp
index f8a494522c4..ba61e180432 100644
--- a/src/server/game/Movement/MovementGenerators/GenericMovementGenerator.cpp
+++ b/src/server/game/Movement/MovementGenerators/GenericMovementGenerator.cpp
@@ -23,9 +23,9 @@
#include "ObjectAccessor.h"
#include "Unit.h"
-GenericMovementGenerator::GenericMovementGenerator(Movement::MoveSplineInit&& splineInit, MovementGeneratorType type, uint32 id,
+GenericMovementGenerator::GenericMovementGenerator(std::function<void(Movement::MoveSplineInit& init)>&& initializer, MovementGeneratorType type, uint32 id,
uint32 arrivalSpellId /*= 0*/, ObjectGuid const& arrivalSpellTargetGuid /*= ObjectGuid::Empty*/)
- : _splineInit(std::move(splineInit)), _type(type), _pointId(id), _duration(0),
+ : _splineInit(std::move(initializer)), _type(type), _pointId(id), _duration(0),
_arrivalSpellId(arrivalSpellId), _arrivalSpellTargetGuid(arrivalSpellTargetGuid)
{
Mode = MOTION_MODE_DEFAULT;
@@ -34,7 +34,7 @@ GenericMovementGenerator::GenericMovementGenerator(Movement::MoveSplineInit&& sp
BaseUnitState = UNIT_STATE_ROAMING;
}
-void GenericMovementGenerator::Initialize(Unit* /*owner*/)
+void GenericMovementGenerator::Initialize(Unit* owner)
{
if (HasFlag(MOVEMENTGENERATOR_FLAG_DEACTIVATED) && !HasFlag(MOVEMENTGENERATOR_FLAG_INITIALIZATION_PENDING)) // Resume spline is not supported
{
@@ -46,7 +46,9 @@ void GenericMovementGenerator::Initialize(Unit* /*owner*/)
RemoveFlag(MOVEMENTGENERATOR_FLAG_INITIALIZATION_PENDING | MOVEMENTGENERATOR_FLAG_DEACTIVATED);
AddFlag(MOVEMENTGENERATOR_FLAG_INITIALIZED);
- _duration.Reset(_splineInit.Launch());
+ Movement::MoveSplineInit init(owner);
+ _splineInit(init);
+ _duration.Reset(init.Launch());
}
void GenericMovementGenerator::Reset(Unit* owner)
diff --git a/src/server/game/Movement/MovementGenerators/GenericMovementGenerator.h b/src/server/game/Movement/MovementGenerators/GenericMovementGenerator.h
index 6655cd693a7..6b3b984c468 100644
--- a/src/server/game/Movement/MovementGenerators/GenericMovementGenerator.h
+++ b/src/server/game/Movement/MovementGenerators/GenericMovementGenerator.h
@@ -21,6 +21,7 @@
#include "MovementGenerator.h"
#include "MoveSplineInit.h"
#include "Timer.h"
+#include <functional>
class Unit;
@@ -29,7 +30,7 @@ enum MovementGeneratorType : uint8;
class GenericMovementGenerator : public MovementGenerator
{
public:
- explicit GenericMovementGenerator(Movement::MoveSplineInit&& splineInit, MovementGeneratorType type, uint32 id,
+ explicit GenericMovementGenerator(std::function<void(Movement::MoveSplineInit& init)>&& initializer, MovementGeneratorType type, uint32 id,
uint32 arrivalSpellId = 0, ObjectGuid const& arrivalSpellTargetGuid = ObjectGuid::Empty);
void Initialize(Unit*) override;
@@ -42,7 +43,7 @@ class GenericMovementGenerator : public MovementGenerator
private:
void MovementInform(Unit*);
- Movement::MoveSplineInit _splineInit;
+ std::function<void(Movement::MoveSplineInit& init)> _splineInit;
MovementGeneratorType _type;
uint32 _pointId;
TimeTracker _duration;
diff --git a/src/server/game/Movement/Spline/MoveSplineInit.h b/src/server/game/Movement/Spline/MoveSplineInit.h
index bec9b55959f..5e5a7ec0da1 100644
--- a/src/server/game/Movement/Spline/MoveSplineInit.h
+++ b/src/server/game/Movement/Spline/MoveSplineInit.h
@@ -20,6 +20,7 @@
#include "MoveSplineInitArgs.h"
+class ObjectGuid;
class Unit;
enum class AnimTier : uint8;
diff --git a/src/server/scripts/EasternKingdoms/ScarletEnclave/chapter1.cpp b/src/server/scripts/EasternKingdoms/ScarletEnclave/chapter1.cpp
index 2cd9a7f17ac..09331dc0fa5 100644
--- a/src/server/scripts/EasternKingdoms/ScarletEnclave/chapter1.cpp
+++ b/src/server/scripts/EasternKingdoms/ScarletEnclave/chapter1.cpp
@@ -476,14 +476,16 @@ struct npc_eye_of_acherus : public ScriptedAI
break;
case EVENT_LAUNCH_TOWARDS_DESTINATION:
{
- Movement::PointsArray path(EyeOfAcherusPath, EyeOfAcherusPath + EyeOfAcherusPathSize);
- Movement::MoveSplineInit init(me);
- init.MovebyPath(path);
- init.SetFly();
- if (Unit* owner = me->GetCharmerOrOwner())
- init.SetVelocity(owner->GetSpeed(MOVE_RUN));
-
- me->GetMotionMaster()->LaunchMoveSpline(std::move(init), POINT_NEW_AVALON, MOTION_PRIORITY_NORMAL, POINT_MOTION_TYPE);
+ std::function<void(Movement::MoveSplineInit&)> initializer = [=](Movement::MoveSplineInit& init)
+ {
+ Movement::PointsArray path(EyeOfAcherusPath, EyeOfAcherusPath + EyeOfAcherusPathSize);
+ init.MovebyPath(path);
+ init.SetFly();
+ if (Unit* owner = me->GetCharmerOrOwner())
+ init.SetVelocity(owner->GetSpeed(MOVE_RUN));
+ };
+
+ me->GetMotionMaster()->LaunchMoveSpline(std::move(initializer), POINT_NEW_AVALON, MOTION_PRIORITY_NORMAL, POINT_MOTION_TYPE);
break;
}
case EVENT_GRANT_CONTROL:
diff --git a/src/server/scripts/Kalimdor/CavernsOfTime/CullingOfStratholme/npc_arthas.cpp b/src/server/scripts/Kalimdor/CavernsOfTime/CullingOfStratholme/npc_arthas.cpp
index 32969c7aa04..e850034383f 100644
--- a/src/server/scripts/Kalimdor/CavernsOfTime/CullingOfStratholme/npc_arthas.cpp
+++ b/src/server/scripts/Kalimdor/CavernsOfTime/CullingOfStratholme/npc_arthas.cpp
@@ -1466,12 +1466,14 @@ public:
if (Creature* chromie = instance->instance->SummonCreature(NPC_CHROMIE_3, ArthasPositions[RP5_CHROMIE_SPAWN]))
{
chromie->RemoveNpcFlag(UNIT_NPC_FLAG_GOSSIP | UNIT_NPC_FLAG_QUESTGIVER);
- Movement::PointsArray path(ChromieSplinePos, ChromieSplinePos + chromiePathSize);
- Movement::MoveSplineInit init(chromie);
- init.SetFly();
- init.SetWalk(true);
- init.MovebyPath(path, 0);
- me->GetMotionMaster()->LaunchMoveSpline(std::move(init), 0, MOTION_PRIORITY_NORMAL, POINT_MOTION_TYPE);
+ std::function<void(Movement::MoveSplineInit&)> initializer = [](Movement::MoveSplineInit& init)
+ {
+ Movement::PointsArray path(ChromieSplinePos, ChromieSplinePos + chromiePathSize);
+ init.SetFly();
+ init.SetWalk(true);
+ init.MovebyPath(path, 0);
+ };
+ chromie->GetMotionMaster()->LaunchMoveSpline(std::move(initializer), 0, MOTION_PRIORITY_NORMAL, POINT_MOTION_TYPE);
}
break;
case RP5_EVENT_CHROMIE_LAND:
diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_icecrown_gunship_battle.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_icecrown_gunship_battle.cpp
index 5ccf6f45452..0831cda0605 100644
--- a/src/server/scripts/Northrend/IcecrownCitadel/boss_icecrown_gunship_battle.cpp
+++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_icecrown_gunship_battle.cpp
@@ -474,10 +474,12 @@ public:
if (!_owner->IsAlive())
return true;
- Movement::MoveSplineInit init(_owner);
- init.DisableTransportPathTransformations();
- init.MoveTo(_dest.GetPositionX(), _dest.GetPositionY(), _dest.GetPositionZ(), false);
- _owner->GetMotionMaster()->LaunchMoveSpline(std::move(init), EVENT_CHARGE_PREPATH, MOTION_PRIORITY_NORMAL, POINT_MOTION_TYPE);
+ std::function<void(Movement::MoveSplineInit&)> initializer = [dest = _dest](Movement::MoveSplineInit& init)
+ {
+ init.DisableTransportPathTransformations();
+ init.MoveTo(dest.GetPositionX(), dest.GetPositionY(), dest.GetPositionZ(), false);
+ };
+ _owner->GetMotionMaster()->LaunchMoveSpline(std::move(initializer), EVENT_CHARGE_PREPATH, MOTION_PRIORITY_NORMAL, POINT_MOTION_TYPE);
return true;
}
@@ -572,10 +574,12 @@ struct gunship_npc_AI : public ScriptedAI
me->GetTransport()->CalculatePassengerPosition(hx, hy, hz, &ho);
me->SetHomePosition(hx, hy, hz, ho);
- Movement::MoveSplineInit init(me);
- init.DisableTransportPathTransformations();
- init.MoveTo(x, y, z, false);
- me->GetMotionMaster()->LaunchMoveSpline(std::move(init), EVENT_CHARGE_PREPATH, MOTION_PRIORITY_NORMAL, POINT_MOTION_TYPE);
+ std::function<void(Movement::MoveSplineInit&)> initializer = [=](Movement::MoveSplineInit& init)
+ {
+ init.DisableTransportPathTransformations();
+ init.MoveTo(x, y, z, false);
+ };
+ me->GetMotionMaster()->LaunchMoveSpline(std::move(initializer), EVENT_CHARGE_PREPATH, MOTION_PRIORITY_NORMAL, POINT_MOTION_TYPE);
}
}
@@ -933,11 +937,13 @@ struct npc_high_overlord_saurfang_igb : public ScriptedAI
}
else if (action == ACTION_EXIT_SHIP)
{
- Movement::PointsArray path(SaurfangExitPath, SaurfangExitPath + SaurfangExitPathSize);
- Movement::MoveSplineInit init(me);
- init.DisableTransportPathTransformations();
- init.MovebyPath(path, 0);
- me->GetMotionMaster()->LaunchMoveSpline(std::move(init), 0, MOTION_PRIORITY_NORMAL, POINT_MOTION_TYPE);
+ std::function<void(Movement::MoveSplineInit&)> initializer = [](Movement::MoveSplineInit& init)
+ {
+ Movement::PointsArray path(SaurfangExitPath, SaurfangExitPath + SaurfangExitPathSize);
+ init.DisableTransportPathTransformations();
+ init.MovebyPath(path, 0);
+ };
+ me->GetMotionMaster()->LaunchMoveSpline(std::move(initializer), 0, MOTION_PRIORITY_NORMAL, POINT_MOTION_TYPE);
me->DespawnOrUnsummon(18s);
}
@@ -1187,11 +1193,13 @@ struct npc_muradin_bronzebeard_igb : public ScriptedAI
}
else if (action == ACTION_EXIT_SHIP)
{
- Movement::PointsArray path(MuradinExitPath, MuradinExitPath + MuradinExitPathSize);
- Movement::MoveSplineInit init(me);
- init.DisableTransportPathTransformations();
- init.MovebyPath(path, 0);
- me->GetMotionMaster()->LaunchMoveSpline(std::move(init), 0, MOTION_PRIORITY_NORMAL, POINT_MOTION_TYPE);
+ std::function<void(Movement::MoveSplineInit&)> initializer = [](Movement::MoveSplineInit& init)
+ {
+ Movement::PointsArray path(MuradinExitPath, MuradinExitPath + MuradinExitPathSize);
+ init.DisableTransportPathTransformations();
+ init.MovebyPath(path, 0);
+ };
+ me->GetMotionMaster()->LaunchMoveSpline(std::move(initializer), 0, MOTION_PRIORITY_NORMAL, POINT_MOTION_TYPE);
me->DespawnOrUnsummon(18s);
}
diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_lord_marrowgar.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_lord_marrowgar.cpp
index c8b8c4a2f6c..c468477c152 100644
--- a/src/server/scripts/Northrend/IcecrownCitadel/boss_lord_marrowgar.cpp
+++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_lord_marrowgar.cpp
@@ -455,10 +455,12 @@ struct npc_bone_spike : public ScriptedAI
/// @HACK - Change passenger offset to the one taken directly from sniffs
/// Remove this when proper calculations are implemented.
/// This fixes healing spiked people
- Movement::MoveSplineInit init(passenger);
- init.DisableTransportPathTransformations();
- init.MoveTo(-0.02206125f, -0.02132235f, 5.514783f, false);
- passenger->GetMotionMaster()->LaunchMoveSpline(std::move(init), EVENT_VEHICLE_BOARD, MOTION_PRIORITY_HIGHEST);
+ std::function<void(Movement::MoveSplineInit&)> initializer = [](Movement::MoveSplineInit& init)
+ {
+ init.DisableTransportPathTransformations();
+ init.MoveTo(-0.02206125f, -0.02132235f, 5.514783f, false);
+ };
+ passenger->GetMotionMaster()->LaunchMoveSpline(std::move(initializer), EVENT_VEHICLE_BOARD, MOTION_PRIORITY_HIGHEST);
}
void UpdateAI(uint32 diff) override
diff --git a/src/server/scripts/Northrend/Naxxramas/naxxramas.cpp b/src/server/scripts/Northrend/Naxxramas/naxxramas.cpp
index 522f1892cf4..75b66007585 100644
--- a/src/server/scripts/Northrend/Naxxramas/naxxramas.cpp
+++ b/src/server/scripts/Northrend/Naxxramas/naxxramas.cpp
@@ -118,12 +118,14 @@ struct npc_frogger_trigger_naxx : public NullCreatureAI
private:
EventMap _events;
- static void LaunchSpline(Creature* slime, Position const dest)
+ static void LaunchSpline(Creature* slime, Position const& dest)
{
- Movement::MoveSplineInit init(slime);
- init.MoveTo(dest.GetPositionX(), dest.GetPositionY(), dest.GetPositionZ());
- init.SetWalk(true);
- slime->GetMotionMaster()->LaunchMoveSpline(std::move(init));
+ std::function<void(Movement::MoveSplineInit&)> initializer = [dest = dest](Movement::MoveSplineInit& init)
+ {
+ init.MoveTo(dest.GetPositionX(), dest.GetPositionY(), dest.GetPositionZ());
+ init.SetWalk(true);
+ };
+ slime->GetMotionMaster()->LaunchMoveSpline(std::move(initializer));
}
};
diff --git a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_algalon_the_observer.cpp b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_algalon_the_observer.cpp
index 163db8cfb4a..763fa92044f 100644
--- a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_algalon_the_observer.cpp
+++ b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_algalon_the_observer.cpp
@@ -317,10 +317,12 @@ struct boss_algalon_the_observer : public BossAI
DoCastSelf(SPELL_RIDE_THE_LIGHTNING, true);
me->SetHomePosition(AlgalonLandPos);
- Movement::MoveSplineInit init(me);
- init.MoveTo(AlgalonLandPos.GetPositionX(), AlgalonLandPos.GetPositionY(), AlgalonLandPos.GetPositionZ(), false);
- init.SetOrientationFixed(true);
- me->GetMotionMaster()->LaunchMoveSpline(std::move(init), 0, MOTION_PRIORITY_NORMAL, POINT_MOTION_TYPE);
+ std::function<void(Movement::MoveSplineInit&)> initializer = [](Movement::MoveSplineInit& init)
+ {
+ init.MoveTo(AlgalonLandPos.GetPositionX(), AlgalonLandPos.GetPositionY(), AlgalonLandPos.GetPositionZ(), false);
+ init.SetOrientationFixed(true);
+ };
+ me->GetMotionMaster()->LaunchMoveSpline(std::move(initializer), 0, MOTION_PRIORITY_NORMAL, POINT_MOTION_TYPE);
events.Reset();
events.SetPhase(PHASE_ROLE_PLAY);
diff --git a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_razorscale.cpp b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_razorscale.cpp
index e9772a31be5..2cac4d62bc0 100644
--- a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_razorscale.cpp
+++ b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_razorscale.cpp
@@ -329,12 +329,14 @@ struct boss_razorscale : public BossAI
void HandleInitialMovement()
{
- Movement::PointsArray path(RazorscalePath, RazorscalePath + pathSize);
- Movement::MoveSplineInit init(me);
- init.MovebyPath(path, 0);
- init.SetCyclic();
- init.SetFly();
- me->GetMotionMaster()->LaunchMoveSpline(std::move(init), 0, MOTION_PRIORITY_NORMAL, POINT_MOTION_TYPE);
+ std::function<void(Movement::MoveSplineInit&)> initializer = [](Movement::MoveSplineInit& init)
+ {
+ Movement::PointsArray path(RazorscalePath, RazorscalePath + pathSize);
+ init.MovebyPath(path, 0);
+ init.SetCyclic();
+ init.SetFly();
+ };
+ me->GetMotionMaster()->LaunchMoveSpline(std::move(initializer), 0, MOTION_PRIORITY_NORMAL, POINT_MOTION_TYPE);
}
bool CanAIAttack(Unit const* target) const override
diff --git a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_thorim.cpp b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_thorim.cpp
index 3bae76d19c8..f1fef936a9a 100644
--- a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_thorim.cpp
+++ b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_thorim.cpp
@@ -632,16 +632,18 @@ class boss_thorim : public CreatureScript
summon->SetReactState(REACT_PASSIVE);
summon->CastSpell(summon, SPELL_LIGHTNING_DESTRUCTION, true);
- Movement::PointsArray path;
- path.reserve(LightningOrbPathSize);
- std::transform(std::begin(LightningOrbPath), std::end(LightningOrbPath), std::back_inserter(path), [](Position const& pos)
+ std::function<void(Movement::MoveSplineInit&)> initializer = [](Movement::MoveSplineInit& init)
{
- return G3D::Vector3(pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ());
- });
+ Movement::PointsArray path;
+ path.reserve(LightningOrbPathSize);
+ std::transform(std::begin(LightningOrbPath), std::end(LightningOrbPath), std::back_inserter(path), [](Position const& pos)
+ {
+ return G3D::Vector3(pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ());
+ });
- Movement::MoveSplineInit init(summon);
- init.MovebyPath(path);
- summon->GetMotionMaster()->LaunchMoveSpline(std::move(init), 0, MOTION_PRIORITY_NORMAL, POINT_MOTION_TYPE);
+ init.MovebyPath(path);
+ };
+ summon->GetMotionMaster()->LaunchMoveSpline(std::move(initializer), 0, MOTION_PRIORITY_NORMAL, POINT_MOTION_TYPE);
break;
}
case NPC_DARK_RUNE_CHAMPION:
diff --git a/src/server/scripts/Northrend/UtgardeKeep/UtgardePinnacle/boss_skadi.cpp b/src/server/scripts/Northrend/UtgardeKeep/UtgardePinnacle/boss_skadi.cpp
index 727b8397bd5..9655a4b5851 100644
--- a/src/server/scripts/Northrend/UtgardeKeep/UtgardePinnacle/boss_skadi.cpp
+++ b/src/server/scripts/Northrend/UtgardeKeep/UtgardePinnacle/boss_skadi.cpp
@@ -346,10 +346,12 @@ struct npc_grauf : public ScriptedAI
return;
}
- Movement::MoveSplineInit init(who);
- init.DisableTransportPathTransformations();
- init.MoveTo(0.3320355f, 0.05355075f, 5.196949f, false);
- who->GetMotionMaster()->LaunchMoveSpline(std::move(init), EVENT_VEHICLE_BOARD, MOTION_PRIORITY_HIGHEST);
+ std::function<void(Movement::MoveSplineInit&)> initializer = [](Movement::MoveSplineInit& init)
+ {
+ init.DisableTransportPathTransformations();
+ init.MoveTo(0.3320355f, 0.05355075f, 5.196949f, false);
+ };
+ who->GetMotionMaster()->LaunchMoveSpline(std::move(initializer), EVENT_VEHICLE_BOARD, MOTION_PRIORITY_HIGHEST);
me->setActive(true);
me->SetFarVisible(true);
diff --git a/src/server/scripts/Northrend/UtgardeKeep/UtgardePinnacle/boss_svala.cpp b/src/server/scripts/Northrend/UtgardeKeep/UtgardePinnacle/boss_svala.cpp
index b8d9fce5e4b..ed674dec990 100644
--- a/src/server/scripts/Northrend/UtgardeKeep/UtgardePinnacle/boss_svala.cpp
+++ b/src/server/scripts/Northrend/UtgardeKeep/UtgardePinnacle/boss_svala.cpp
@@ -257,10 +257,12 @@ struct boss_svala : public BossAI
arthas->CastSpell(me, SPELL_TRANSFORMING_CHANNEL, true);
me->SetDisableGravity(true);
- Movement::MoveSplineInit init(me);
- init.MoveTo(296.614f, -346.2484f, 95.62769f);
- init.SetFly();
- me->GetMotionMaster()->LaunchMoveSpline(std::move(init));
+ std::function<void(Movement::MoveSplineInit&)> initializer = [](Movement::MoveSplineInit& init)
+ {
+ init.MoveTo(296.614f, -346.2484f, 95.62769f);
+ init.SetFly();
+ };
+ me->GetMotionMaster()->LaunchMoveSpline(std::move(initializer));
// spectators flee event
std::list<Creature*> spectators;
diff --git a/src/server/scripts/World/npcs_special.cpp b/src/server/scripts/World/npcs_special.cpp
index e4c5af9010f..8b8e8a61aeb 100644
--- a/src/server/scripts/World/npcs_special.cpp
+++ b/src/server/scripts/World/npcs_special.cpp
@@ -2302,11 +2302,13 @@ public:
break;
}
- Movement::MoveSplineInit init(who);
- init.DisableTransportPathTransformations();
- init.MoveTo(x, y, z, false);
- init.SetFacing(o);
- who->GetMotionMaster()->LaunchMoveSpline(std::move(init), EVENT_VEHICLE_BOARD, MOTION_PRIORITY_HIGHEST);
+ std::function<void(Movement::MoveSplineInit&)> initializer = [=](Movement::MoveSplineInit& init)
+ {
+ init.DisableTransportPathTransformations();
+ init.MoveTo(x, y, z, false);
+ init.SetFacing(o);
+ };
+ who->GetMotionMaster()->LaunchMoveSpline(std::move(initializer), EVENT_VEHICLE_BOARD, MOTION_PRIORITY_HIGHEST);
who->m_Events.AddEvent(new CastFoodSpell(who, _chairSpells.at(who->GetEntry())), who->m_Events.CalculateTime(1s));
if (Creature* creature = who->ToCreature())
creature->SetDisplayFromModel(0);