Core/Movement: converted SMSG_ON_MONSTER_MOVE and SMSG_ON_MONSTER_MOVE_TRANSPORT to packet class
* define and use MOVEMENTFLAG2_IS_VEHICLE_EXIT_VOLUNTARY
This commit is contained in:
1 parent
e334e60103
commit
f9fdce6d4f
10 files changed
+287
-154
No files matched your search
@@ -33,118 +33,6 @@ namespace Movement
|
||||
b >> v.x >> v.y >> v.z;
|
||||
}
|
||||
|
||||
enum MonsterMoveType
|
||||
{
|
||||
MonsterMoveNormal = 0,
|
||||
MonsterMoveStop = 1,
|
||||
MonsterMoveFacingSpot = 2,
|
||||
MonsterMoveFacingTarget = 3,
|
||||
MonsterMoveFacingAngle = 4
|
||||
};
|
||||
|
||||
void PacketBuilder::WriteCommonMonsterMovePart(const MoveSpline& move_spline, WorldPacket& data)
|
||||
{
|
||||
MoveSplineFlag splineflags = move_spline.splineflags;
|
||||
|
||||
data << uint8(0); // sets/unsets MOVEMENTFLAG2_UNK7 (0x40)
|
||||
data << move_spline.spline.getPoint(move_spline.spline.first());
|
||||
data << move_spline.GetId();
|
||||
|
||||
switch (splineflags & MoveSplineFlag::Mask_Final_Facing)
|
||||
{
|
||||
case MoveSplineFlag::Final_Target:
|
||||
data << uint8(MonsterMoveFacingTarget);
|
||||
data << move_spline.facing.target;
|
||||
break;
|
||||
case MoveSplineFlag::Final_Angle:
|
||||
data << uint8(MonsterMoveFacingAngle);
|
||||
data << move_spline.facing.angle;
|
||||
break;
|
||||
case MoveSplineFlag::Final_Point:
|
||||
data << uint8(MonsterMoveFacingSpot);
|
||||
data << move_spline.facing.f.x << move_spline.facing.f.y << move_spline.facing.f.z;
|
||||
break;
|
||||
default:
|
||||
data << uint8(MonsterMoveNormal);
|
||||
break;
|
||||
}
|
||||
|
||||
data << uint32(splineflags & uint32(~MoveSplineFlag::Mask_No_Monster_Move));
|
||||
|
||||
if (splineflags.animation)
|
||||
{
|
||||
data << splineflags.getAnimationId();
|
||||
data << move_spline.effect_start_time;
|
||||
}
|
||||
|
||||
data << move_spline.Duration();
|
||||
|
||||
if (splineflags.parabolic)
|
||||
{
|
||||
data << move_spline.vertical_acceleration;
|
||||
data << move_spline.effect_start_time;
|
||||
}
|
||||
}
|
||||
|
||||
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(Spline<int32> const& spline, ByteBuffer& data)
|
||||
{
|
||||
uint32 last_idx = spline.getPointCount() - 3;
|
||||
Vector3 const* real_path = &spline.getPoint(1);
|
||||
|
||||
data << last_idx;
|
||||
data << real_path[last_idx]; // destination
|
||||
if (last_idx > 1)
|
||||
{
|
||||
Vector3 middle = (real_path[0] + real_path[last_idx]) / 2.f;
|
||||
Vector3 offset;
|
||||
// first and last points already appended
|
||||
for (uint32 i = 1; i < last_idx; ++i)
|
||||
{
|
||||
offset = middle - real_path[i];
|
||||
data.appendPackXYZ(offset.x, offset.y, offset.z);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void WriteUncompressedPath(Spline<int32> const& spline, ByteBuffer& data)
|
||||
{
|
||||
uint32 count = spline.getPointCount() - 3;
|
||||
data << count;
|
||||
data.append<Vector3>(&spline.getPoint(2), count);
|
||||
}
|
||||
|
||||
void WriteUncompressedCyclicPath(Spline<int32> const& spline, ByteBuffer& data)
|
||||
{
|
||||
uint32 count = spline.getPointCount() - 4;
|
||||
data << count;
|
||||
data.append<Vector3>(&spline.getPoint(2), count);
|
||||
}
|
||||
|
||||
void PacketBuilder::WriteMonsterMove(const MoveSpline& move_spline, WorldPacket& data)
|
||||
{
|
||||
WriteCommonMonsterMovePart(move_spline, data);
|
||||
|
||||
Spline<int32> const& spline = move_spline.spline;
|
||||
MoveSplineFlag splineflags = move_spline.splineflags;
|
||||
if (splineflags & MoveSplineFlag::UncompressedPath)
|
||||
{
|
||||
if (!splineflags.cyclic)
|
||||
WriteUncompressedPath(spline, data);
|
||||
else
|
||||
WriteUncompressedCyclicPath(spline, data);
|
||||
}
|
||||
else
|
||||
WriteLinearPath(spline, data);
|
||||
}
|
||||
|
||||
void PacketBuilder::WriteCreateBits(MoveSpline const& moveSpline, ByteBuffer& data)
|
||||
{
|
||||
if (!data.WriteBit(!moveSpline.Finalized()))
|
||||
|
||||
Reference in new issue
Block a user