From f1ef08fc84fffb10ee4e439476a101e53dc5f9ae Mon Sep 17 00:00:00 2001 From: Ovahlord Date: Tue, 29 Sep 2020 17:40:31 +0200 Subject: [PATCH] Core/Movement: added optional velocity argument for MotionMaster::MoveTakeoff helper to manually specify velocity values --- src/server/game/Movement/MotionMaster.cpp | 6 ++++-- src/server/game/Movement/MotionMaster.h | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/server/game/Movement/MotionMaster.cpp b/src/server/game/Movement/MotionMaster.cpp index 5d509b0ffbb..645de0bcca2 100644 --- a/src/server/game/Movement/MotionMaster.cpp +++ b/src/server/game/Movement/MotionMaster.cpp @@ -343,7 +343,7 @@ void MotionMaster::MoveCloserAndStop(uint32 id, Unit* target, float distance) } } -void MotionMaster::MoveLand(uint32 id, Position const& pos, Optional velocity /*= nullptr*/) +void MotionMaster::MoveLand(uint32 id, Position const& pos, Optional velocity /*= { }*/) { 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()); @@ -357,7 +357,7 @@ void MotionMaster::MoveLand(uint32 id, Position const& pos, Optional velo Mutate(new GenericMovementGenerator(std::move(init), EFFECT_MOTION_TYPE, id), MOTION_SLOT_ACTIVE); } -void MotionMaster::MoveTakeoff(uint32 id, Position const& pos) +void MotionMaster::MoveTakeoff(uint32 id, Position const& pos, Optional 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()); @@ -366,6 +366,8 @@ void MotionMaster::MoveTakeoff(uint32 id, Position const& pos) init.SetSmooth(); init.SetFly(); init.SetAnimation(AnimationTier::Hover); + if (velocity) + init.SetVelocity(velocity.get()); Mutate(new GenericMovementGenerator(std::move(init), EFFECT_MOTION_TYPE, id), MOTION_SLOT_ACTIVE); } diff --git a/src/server/game/Movement/MotionMaster.h b/src/server/game/Movement/MotionMaster.h index 34304a596ca..72d06952be8 100644 --- a/src/server/game/Movement/MotionMaster.h +++ b/src/server/game/Movement/MotionMaster.h @@ -169,8 +169,8 @@ class TC_GAME_API MotionMaster void MoveCloserAndStop(uint32 id, Unit* target, float distance); // These two movement types should only be used with creatures having landing/takeoff animations - void MoveLand(uint32 id, Position const& pos, Optional velocity = nullptr); - void MoveTakeoff(uint32 id, Position const& pos); + void MoveLand(uint32 id, Position const& pos, Optional velocity = { }); + void MoveTakeoff(uint32 id, Position const& pos, Optional velocity = { }); void MoveCharge(float x, float y, float z, float speed = SPEED_CHARGE, uint32 id = EVENT_CHARGE, bool generatePath = false); void MoveCharge(PathGenerator const& path, float speed = SPEED_CHARGE);