Core/Movement: Backported spline stop fix from 4.3.4 branch - use Stop spline type for stopping movement instead of starting movement that ends in creature's current position
This commit is contained in:
1 parent
8332cee052
commit
1966a78b9f
8 files changed
+91
-35
No files matched your search
@@ -385,8 +385,6 @@ void Unit::MonsterMoveWithSpeed(float x, float y, float z, float speed, bool gen
|
||||
|
||||
void Unit::UpdateSplineMovement(uint32 t_diff)
|
||||
{
|
||||
uint32 const positionUpdateDelay = 400;
|
||||
|
||||
if (movespline->Finalized())
|
||||
return;
|
||||
|
||||
@@ -398,27 +396,32 @@ void Unit::UpdateSplineMovement(uint32 t_diff)
|
||||
|
||||
m_movesplineTimer.Update(t_diff);
|
||||
if (m_movesplineTimer.Passed() || arrived)
|
||||
UpdateSplinePosition();
|
||||
}
|
||||
|
||||
void Unit::UpdateSplinePosition()
|
||||
{
|
||||
static uint32 const positionUpdateDelay = 400;
|
||||
|
||||
m_movesplineTimer.Reset(positionUpdateDelay);
|
||||
Movement::Location loc = movespline->ComputePosition();
|
||||
|
||||
if (HasUnitMovementFlag(MOVEMENTFLAG_ONTRANSPORT))
|
||||
{
|
||||
m_movesplineTimer.Reset(positionUpdateDelay);
|
||||
Movement::Location loc = movespline->ComputePosition();
|
||||
Position& pos = m_movementInfo.transport.pos;
|
||||
pos.m_positionX = loc.x;
|
||||
pos.m_positionY = loc.y;
|
||||
pos.m_positionZ = loc.z;
|
||||
pos.m_orientation = loc.orientation;
|
||||
|
||||
if (HasUnitMovementFlag(MOVEMENTFLAG_ONTRANSPORT))
|
||||
{
|
||||
Position& pos = m_movementInfo.transport.pos;
|
||||
pos.m_positionX = loc.x;
|
||||
pos.m_positionY = loc.y;
|
||||
pos.m_positionZ = loc.z;
|
||||
pos.m_orientation = loc.orientation;
|
||||
|
||||
if (TransportBase* transport = GetDirectTransport())
|
||||
transport->CalculatePassengerPosition(loc.x, loc.y, loc.z, &loc.orientation);
|
||||
}
|
||||
|
||||
if (HasUnitState(UNIT_STATE_CANNOT_TURN))
|
||||
loc.orientation = GetOrientation();
|
||||
|
||||
UpdatePosition(loc.x, loc.y, loc.z, loc.orientation);
|
||||
if (TransportBase* transport = GetDirectTransport())
|
||||
transport->CalculatePassengerPosition(loc.x, loc.y, loc.z, &loc.orientation);
|
||||
}
|
||||
|
||||
if (HasUnitState(UNIT_STATE_CANNOT_TURN))
|
||||
loc.orientation = GetOrientation();
|
||||
|
||||
UpdatePosition(loc.x, loc.y, loc.z, loc.orientation);
|
||||
}
|
||||
|
||||
void Unit::DisableSpline()
|
||||
@@ -14413,14 +14416,14 @@ void Unit::StopMoving()
|
||||
{
|
||||
ClearUnitState(UNIT_STATE_MOVING);
|
||||
|
||||
// not need send any packets if not in world
|
||||
if (!IsInWorld())
|
||||
// not need send any packets if not in world or not moving
|
||||
if (!IsInWorld() || movespline->Finalized())
|
||||
return;
|
||||
|
||||
// Update position now since Stop does not start a new movement that can be updated later
|
||||
UpdateSplinePosition();
|
||||
Movement::MoveSplineInit init(this);
|
||||
init.MoveTo(GetPositionX(), GetPositionY(), GetPositionZMinusOffset(), false);
|
||||
init.SetFacing(GetOrientation());
|
||||
init.Launch();
|
||||
init.Stop();
|
||||
}
|
||||
|
||||
void Unit::SendMovementFlagUpdate(bool self /* = false */)
|
||||
|
||||
@@ -2214,6 +2214,7 @@ class Unit : public WorldObject
|
||||
bool HandleAuraRaidProcFromCharge(AuraEffect* triggeredByAura);
|
||||
|
||||
void UpdateSplineMovement(uint32 t_diff);
|
||||
void UpdateSplinePosition();
|
||||
|
||||
// player or player's pet
|
||||
float GetCombatRatingReduction(CombatRating cr) const;
|
||||
|
||||
@@ -165,6 +165,13 @@ void MoveSpline::Initialize(MoveSplineInitArgs const& args)
|
||||
vertical_acceleration = 0.f;
|
||||
effect_start_time = 0;
|
||||
|
||||
// Check if its a stop spline
|
||||
if (args.flags.done)
|
||||
{
|
||||
spline.clear();
|
||||
return;
|
||||
}
|
||||
|
||||
init_spline(args);
|
||||
|
||||
// init parabolic / animation
|
||||
@@ -259,7 +266,7 @@ MoveSpline::UpdateResult MoveSpline::_updateState(int32& ms_time_diff)
|
||||
{
|
||||
point_Idx = spline.first();
|
||||
time_passed = time_passed % Duration();
|
||||
result = Result_NextSegment;
|
||||
result = Result_NextCycle;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -109,13 +109,14 @@ namespace Movement
|
||||
if (!args.Validate(unit))
|
||||
return 0;
|
||||
|
||||
unit->m_movementInfo.SetMovementFlags((MovementFlags)moveFlags);
|
||||
unit->m_movementInfo.SetMovementFlags(moveFlags);
|
||||
move_spline.Initialize(args);
|
||||
|
||||
WorldPacket data(!transport ? SMSG_MONSTER_MOVE : SMSG_MONSTER_MOVE_TRANSPORT, 64);
|
||||
WorldPacket data(SMSG_MONSTER_MOVE, 64);
|
||||
data.append(unit->GetPackGUID());
|
||||
if (transport)
|
||||
{
|
||||
data.SetOpcode(SMSG_MONSTER_MOVE_TRANSPORT);
|
||||
data.appendPackGUID(unit->GetTransGUID());
|
||||
data << int8(unit->GetTransSeat());
|
||||
}
|
||||
@@ -126,6 +127,32 @@ namespace Movement
|
||||
return move_spline.Duration();
|
||||
}
|
||||
|
||||
void MoveSplineInit::Stop()
|
||||
{
|
||||
MoveSpline& move_spline = *unit->movespline;
|
||||
|
||||
// No need to stop if we are not moving
|
||||
if (move_spline.Finalized())
|
||||
return;
|
||||
|
||||
Location loc = move_spline.ComputePosition();
|
||||
args.flags = MoveSplineFlag::Done;
|
||||
unit->m_movementInfo.RemoveMovementFlag(MOVEMENTFLAG_FORWARD | MOVEMENTFLAG_SPLINE_ENABLED);
|
||||
move_spline.Initialize(args);
|
||||
|
||||
WorldPacket data(SMSG_MONSTER_MOVE, 64);
|
||||
data.append(unit->GetPackGUID());
|
||||
if (unit->HasUnitMovementFlag(MOVEMENTFLAG_ONTRANSPORT) && unit->GetTransGUID())
|
||||
{
|
||||
data.SetOpcode(SMSG_MONSTER_MOVE_TRANSPORT);
|
||||
data.appendPackGUID(unit->GetTransGUID());
|
||||
data << int8(unit->GetTransSeat());
|
||||
}
|
||||
|
||||
PacketBuilder::WriteStopMovement(loc, args.splineId, data);
|
||||
unit->SendMessageToSet(&data, true);
|
||||
}
|
||||
|
||||
MoveSplineInit::MoveSplineInit(Unit* m) : unit(m)
|
||||
{
|
||||
args.splineId = splineIdGen.NewId();
|
||||
|
||||
@@ -59,6 +59,10 @@ namespace Movement
|
||||
*/
|
||||
int32 Launch();
|
||||
|
||||
/* Final pass of initialization that stops movement.
|
||||
*/
|
||||
void Stop();
|
||||
|
||||
/* Adds movement by parabolic trajectory
|
||||
* @param amplitude - the maximum height of parabola, value could be negative and positive
|
||||
* @param start_time - delay between movement starting time and beginning to move by parabolic trajectory
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
|
||||
#include "MovementPacketBuilder.h"
|
||||
#include "MoveSpline.h"
|
||||
#include "WorldPacket.h"
|
||||
#include "ByteBuffer.h"
|
||||
|
||||
namespace Movement
|
||||
{
|
||||
@@ -42,7 +42,7 @@ namespace Movement
|
||||
MonsterMoveFacingAngle = 4
|
||||
};
|
||||
|
||||
void PacketBuilder::WriteCommonMonsterMovePart(const MoveSpline& move_spline, WorldPacket& data)
|
||||
void PacketBuilder::WriteCommonMonsterMovePart(const MoveSpline& move_spline, ByteBuffer& data)
|
||||
{
|
||||
MoveSplineFlag splineflags = move_spline.splineflags;
|
||||
|
||||
@@ -88,6 +88,14 @@ namespace Movement
|
||||
}
|
||||
}
|
||||
|
||||
void PacketBuilder::WriteStopMovement(Vector3 const& pos, uint32 splineId, ByteBuffer& data)
|
||||
{
|
||||
data << uint8(0); // sets/unsets MOVEMENTFLAG2_UNK7 (0x40)
|
||||
data << pos;
|
||||
data << splineId;
|
||||
data << uint8(MonsterMoveStop);
|
||||
}
|
||||
|
||||
void WriteLinearPath(const Spline<int32>& spline, ByteBuffer& data)
|
||||
{
|
||||
uint32 last_idx = spline.getPointCount() - 3;
|
||||
@@ -123,7 +131,7 @@ namespace Movement
|
||||
data.append<Vector3>(&spline.getPoint(1), count);
|
||||
}
|
||||
|
||||
void PacketBuilder::WriteMonsterMove(const MoveSpline& move_spline, WorldPacket& data)
|
||||
void PacketBuilder::WriteMonsterMove(const MoveSpline& move_spline, ByteBuffer& data)
|
||||
{
|
||||
WriteCommonMonsterMovePart(move_spline, data);
|
||||
|
||||
|
||||
@@ -21,17 +21,23 @@
|
||||
#define TRINITYSERVER_PACKET_BUILDER_H
|
||||
|
||||
class ByteBuffer;
|
||||
class WorldPacket;
|
||||
namespace G3D
|
||||
{
|
||||
class Vector3;
|
||||
}
|
||||
|
||||
namespace Movement
|
||||
{
|
||||
using G3D::Vector3;
|
||||
|
||||
class MoveSpline;
|
||||
class PacketBuilder
|
||||
{
|
||||
static void WriteCommonMonsterMovePart(const MoveSpline& mov, WorldPacket& data);
|
||||
static void WriteCommonMonsterMovePart(const MoveSpline& mov, ByteBuffer& data);
|
||||
public:
|
||||
|
||||
static void WriteMonsterMove(const MoveSpline& mov, WorldPacket& data);
|
||||
static void WriteMonsterMove(const MoveSpline& mov, ByteBuffer& data);
|
||||
static void WriteStopMovement(Vector3 const& loc, uint32 splineId, ByteBuffer& data);
|
||||
static void WriteCreate(const MoveSpline& mov, ByteBuffer& data);
|
||||
};
|
||||
}
|
||||
|
||||
@@ -77,7 +77,7 @@ namespace Movement
|
||||
{
|
||||
result = termVel * (t_passed - terminal_time) +
|
||||
start_velocity * terminal_time +
|
||||
gravity * terminal_time * terminal_time*0.5f;
|
||||
gravity * terminal_time * terminal_time * 0.5f;
|
||||
}
|
||||
else
|
||||
result = t_passed * (start_velocity + t_passed * gravity * 0.5f);
|
||||
|
||||
Reference in new issue
Block a user