diff --git a/src/server/game/AI/SmartScripts/SmartScript.cpp b/src/server/game/AI/SmartScripts/SmartScript.cpp index 74193807f1..000f97a8f2 100644 --- a/src/server/game/AI/SmartScripts/SmartScript.cpp +++ b/src/server/game/AI/SmartScripts/SmartScript.cpp @@ -1207,13 +1207,15 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u Position pos = target->GetPosition(); + float speed = (float)e.action.moveOffset.speed / 10; + // Use forward/backward/left/right cartesian plane movement float x, y, z, o; o = pos.GetOrientation(); x = pos.GetPositionX() + (std::cos(o - (M_PI / 2))*e.target.x) + (std::cos(o)*e.target.y); y = pos.GetPositionY() + (std::sin(o - (M_PI / 2))*e.target.x) + (std::sin(o)*e.target.y); z = pos.GetPositionZ() + e.target.z; - target->ToCreature()->GetMotionMaster()->MovePoint(SMART_RANDOM_POINT, x, y, z); + target->ToCreature()->GetMotionMaster()->MovePoint(SMART_RANDOM_POINT, x, y, z, true, speed); } break; } @@ -1500,6 +1502,8 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u target = Trinity::Containers::SelectRandomContainerElement(targets); } + float speed = (float)e.action.MoveToPos.speed / 10; + if (!target) { G3D::Vector3 dest(e.target.x, e.target.y, e.target.z); @@ -1507,7 +1511,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u if (TransportBase* trans = me->GetDirectTransport()) trans->CalculatePassengerPosition(dest.x, dest.y, dest.z); - me->GetMotionMaster()->MovePoint(e.action.MoveToPos.pointId, dest.x, dest.y, dest.z, e.action.MoveToPos.disablePathfinding == 0); + me->GetMotionMaster()->MovePoint(e.action.MoveToPos.pointId, dest.x, dest.y, dest.z, e.action.MoveToPos.disablePathfinding == 0, speed); } else { @@ -1515,7 +1519,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u target->GetPosition(x, y, z); if (e.action.MoveToPos.ContactDistance > 0) target->GetContactPoint(me, x, y, z, e.action.MoveToPos.ContactDistance); - me->GetMotionMaster()->MovePoint(e.action.MoveToPos.pointId, x + e.target.x, y + e.target.y, z + e.target.z, e.action.MoveToPos.disablePathfinding == 0); + me->GetMotionMaster()->MovePoint(e.action.MoveToPos.pointId, x + e.target.x, y + e.target.y, z + e.target.z, e.action.MoveToPos.disablePathfinding == 0, speed); } break; } diff --git a/src/server/game/AI/SmartScripts/SmartScriptMgr.h b/src/server/game/AI/SmartScripts/SmartScriptMgr.h index 1b4e1ec0f6..7a52b0bce6 100644 --- a/src/server/game/AI/SmartScripts/SmartScriptMgr.h +++ b/src/server/game/AI/SmartScripts/SmartScriptMgr.h @@ -826,6 +826,11 @@ struct SmartAction uint32 distance; } moveRandom; + struct + { + uint32 speed; + } moveOffset; + struct { uint32 state; @@ -1027,6 +1032,7 @@ struct SmartAction uint32 transport; uint32 disablePathfinding; uint32 ContactDistance; + uint32 speed; } MoveToPos; struct diff --git a/src/server/game/Movement/MotionMaster.cpp b/src/server/game/Movement/MotionMaster.cpp index 645de0bcca..fd95d3a67c 100644 --- a/src/server/game/Movement/MotionMaster.cpp +++ b/src/server/game/Movement/MotionMaster.cpp @@ -309,17 +309,17 @@ void MotionMaster::MoveFleeing(Unit* enemy, uint32 time) Mutate(new FleeingMovementGenerator(enemy->GetGUID()), MOTION_SLOT_CONTROLLED); } -void MotionMaster::MovePoint(uint32 id, float x, float y, float z, bool generatePath) +void MotionMaster::MovePoint(uint32 id, float x, float y, float z, bool generatePath, float speed) { if (_owner->GetTypeId() == TYPEID_PLAYER) { TC_LOG_DEBUG("movement.motionmaster", "MotionMaster::MovePoint: '%s', targeted point Id: %u (X: %f, Y: %f, Z: %f)", _owner->GetGUID().ToString().c_str(), id, x, y, z); - Mutate(new PointMovementGenerator(id, x, y, z, generatePath, 0.0f), MOTION_SLOT_ACTIVE); + Mutate(new PointMovementGenerator(id, x, y, z, generatePath, speed), MOTION_SLOT_ACTIVE); } else { TC_LOG_DEBUG("movement.motionmaster", "MotionMaster::MovePoint: '%s', targeted point Id: %u (X: %f, Y: %f, Z: %f)", _owner->GetGUID().ToString().c_str(), id, x, y, z); - Mutate(new PointMovementGenerator(id, x, y, z, generatePath, 0.0f), MOTION_SLOT_ACTIVE); + Mutate(new PointMovementGenerator(id, x, y, z, generatePath, speed), MOTION_SLOT_ACTIVE); } } diff --git a/src/server/game/Movement/MotionMaster.h b/src/server/game/Movement/MotionMaster.h index 72d06952be..09d69bbfae 100644 --- a/src/server/game/Movement/MotionMaster.h +++ b/src/server/game/Movement/MotionMaster.h @@ -155,12 +155,12 @@ class TC_GAME_API MotionMaster void MoveConfused(); void MoveFleeing(Unit* enemy, uint32 time = 0); - void MovePoint(uint32 id, Position const& pos, bool generatePath = true) + void MovePoint(uint32 id, Position const& pos, bool generatePath = true, float speed = 0.f) { - MovePoint(id, pos.m_positionX, pos.m_positionY, pos.m_positionZ, generatePath); + MovePoint(id, pos.m_positionX, pos.m_positionY, pos.m_positionZ, generatePath, speed); } - void MovePoint(uint32 id, float x, float y, float z, bool generatePath = true); + void MovePoint(uint32 id, float x, float y, float z, bool generatePath = true, float speed = 0.f); /* Makes the unit move toward the target until it is at a certain distance from it. The unit then stops. Only works in 2D.