mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-02-05 08:28:57 +01:00
Core/Movement: ported some movement flag updates from master branch in order to properly fix swim movement for creatures
This commit is contained in:
@@ -2907,10 +2907,7 @@ void Creature::UpdateMovementFlags()
|
||||
RemoveUnitMovementFlag(MOVEMENTFLAG_FALLING);
|
||||
|
||||
if (GetMovementTemplate().IsSwimAllowed())
|
||||
{
|
||||
SetSwim(IsInWater());
|
||||
SetDisableGravity(IsUnderWater());
|
||||
}
|
||||
}
|
||||
|
||||
void Creature::SetObjectScale(float scale)
|
||||
|
||||
@@ -185,7 +185,6 @@ bool ChaseMovementGenerator::Update(Unit* owner, uint32 diff)
|
||||
init.MovebyPath(_path->GetPath());
|
||||
init.SetWalk(false);
|
||||
init.SetFacing(target);
|
||||
|
||||
init.Launch();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@ Location MoveSpline::ComputePosition() const
|
||||
c.orientation = std::atan2(hermite.y, hermite.x);
|
||||
}
|
||||
|
||||
if (splineflags.orientationInversed)
|
||||
if (splineflags.backward)
|
||||
c.orientation = -c.orientation;
|
||||
}
|
||||
return c;
|
||||
@@ -334,7 +334,7 @@ std::string MoveSpline::ToString() const
|
||||
if (splineflags.final_angle)
|
||||
str << "facing angle: " << facing.angle;
|
||||
else if (splineflags.final_target)
|
||||
str << "facing target: " << facing.target;
|
||||
str << "facing target: " << facing.target.ToString();
|
||||
else if (splineflags.final_point)
|
||||
str << "facing point: " << facing.f.x << " " << facing.f.y << " " << facing.f.z;
|
||||
str << std::endl;
|
||||
|
||||
@@ -48,9 +48,9 @@ namespace Movement
|
||||
TransportExit = 0x00010000,
|
||||
Unknown3 = 0x00020000, // NOT VERIFIED
|
||||
Unknown4 = 0x00040000, // NOT VERIFIED
|
||||
OrientationInversed = 0x00080000,
|
||||
Backward = 0x00080000,
|
||||
SmoothGroundPath = 0x00100000,
|
||||
Walkmode = 0x00200000,
|
||||
CanSwim = 0x00200000,
|
||||
UncompressedPath = 0x00400000,
|
||||
Unknown6 = 0x00800000, // NOT VERIFIED
|
||||
Animation = 0x01000000, // Plays animation after some time passed
|
||||
@@ -69,7 +69,7 @@ namespace Movement
|
||||
// flags that shouldn't be appended into SMSG_MONSTER_MOVE\SMSG_MONSTER_MOVE_TRANSPORT packet, should be more probably
|
||||
Mask_No_Monster_Move = Mask_Final_Facing | Mask_Animations | Done,
|
||||
// Unused, not suported flags
|
||||
Mask_Unused = No_Spline|Enter_Cycle|Frozen|Unknown0|Unknown2|Unknown3|Unknown4|Unknown6|Unknown7|Unknown8|Unknown9
|
||||
Mask_Unused = No_Spline|Frozen|Unknown0|Unknown2|Unknown3|Unknown4|Unknown6|Unknown7|Unknown8|Unknown9
|
||||
};
|
||||
|
||||
inline uint32& raw() { return (uint32&)*this; }
|
||||
@@ -125,9 +125,9 @@ namespace Movement
|
||||
bool transportExit : 1;
|
||||
bool unknown3 : 1;
|
||||
bool unknown4 : 1;
|
||||
bool orientationInversed : 1;
|
||||
bool backward : 1;
|
||||
bool smoothGroundPath : 1;
|
||||
bool walkmode : 1;
|
||||
bool canSwim : 1;
|
||||
bool uncompressedPath : 1;
|
||||
bool unknown6 : 1;
|
||||
bool animation : 1;
|
||||
|
||||
@@ -92,17 +92,17 @@ namespace Movement
|
||||
move_spline.onTransport = (unit->GetTransGUID() != 0);
|
||||
|
||||
uint32 moveFlags = unit->m_movementInfo.GetMovementFlags();
|
||||
moveFlags |= MOVEMENTFLAG_FORWARD;
|
||||
|
||||
if (moveFlags & MOVEMENTFLAG_ROOT)
|
||||
moveFlags &= ~MOVEMENTFLAG_MASK_MOVING;
|
||||
if (!args.flags.backward)
|
||||
moveFlags = (moveFlags & ~MOVEMENTFLAG_BACKWARD) | MOVEMENTFLAG_FORWARD;
|
||||
else
|
||||
moveFlags = (moveFlags & ~MOVEMENTFLAG_FORWARD) | MOVEMENTFLAG_BACKWARD;
|
||||
|
||||
if (!args.HasVelocity)
|
||||
{
|
||||
// If spline is initialized with SetWalk method it only means we need to select
|
||||
// walk move speed for it but not add walk flag to unit
|
||||
uint32 moveFlagsForSpeed = moveFlags;
|
||||
if (args.flags.walkmode)
|
||||
if (args.walk)
|
||||
moveFlagsForSpeed |= MOVEMENTFLAG_WALKING;
|
||||
else
|
||||
moveFlagsForSpeed &= ~MOVEMENTFLAG_WALKING;
|
||||
@@ -179,10 +179,11 @@ namespace Movement
|
||||
{
|
||||
args.splineId = splineIdGen.NewId();
|
||||
// Elevators also use MOVEMENTFLAG_ONTRANSPORT but we do not keep track of their position changes
|
||||
args.TransformForTransport = unit->GetTransGUID() != 0;
|
||||
args.TransformForTransport = !unit->GetTransGUID().IsEmpty();
|
||||
// mix existing state into new
|
||||
args.flags.walkmode = unit->m_movementInfo.HasMovementFlag(MOVEMENTFLAG_WALKING);
|
||||
args.flags.flying = unit->m_movementInfo.HasMovementFlag(MovementFlags(MOVEMENTFLAG_CAN_FLY | MOVEMENTFLAG_DISABLE_GRAVITY));
|
||||
args.flags.canSwim = unit->CanSwim();
|
||||
args.walk = unit->HasUnitMovementFlag(MOVEMENTFLAG_WALKING);
|
||||
args.flags.flying = unit->HasUnitMovementFlag(MovementFlags(MOVEMENTFLAG_CAN_FLY | MOVEMENTFLAG_DISABLE_GRAVITY));
|
||||
args.flags.smoothGroundPath = true; // enabled by default, CatmullRom mode or client config "pathSmoothing" will disable this
|
||||
}
|
||||
|
||||
@@ -201,7 +202,7 @@ namespace Movement
|
||||
void MoveSplineInit::SetFacing(Unit const* target)
|
||||
{
|
||||
args.flags.EnableFacingTarget();
|
||||
args.facing.target = target->GetGUID().GetRawValue();
|
||||
args.facing.target = target->GetGUID();
|
||||
}
|
||||
|
||||
void MoveSplineInit::SetFacing(float angle)
|
||||
|
||||
@@ -135,7 +135,7 @@ namespace Movement
|
||||
|
||||
/* Inverses unit model orientation. Disabled by default
|
||||
*/
|
||||
void SetOrientationInversed();
|
||||
void SetBackward();
|
||||
|
||||
/* Fixes unit's model rotation. Disabled by default
|
||||
*/
|
||||
@@ -160,12 +160,12 @@ namespace Movement
|
||||
};
|
||||
|
||||
inline void MoveSplineInit::SetFly() { args.flags.EnableFlying(); }
|
||||
inline void MoveSplineInit::SetWalk(bool enable) { args.flags.walkmode = enable; }
|
||||
inline void MoveSplineInit::SetWalk(bool enable) { args.walk = enable; }
|
||||
inline void MoveSplineInit::SetSmooth() { args.flags.EnableCatmullRom(); }
|
||||
inline void MoveSplineInit::SetUncompressed() { args.flags.uncompressedPath = true; }
|
||||
inline void MoveSplineInit::SetCyclic() { args.flags.cyclic = true; }
|
||||
inline void MoveSplineInit::SetVelocity(float vel) { args.velocity = vel; args.HasVelocity = true; }
|
||||
inline void MoveSplineInit::SetOrientationInversed() { args.flags.orientationInversed = true;}
|
||||
inline void MoveSplineInit::SetBackward() { args.flags.backward = true;}
|
||||
inline void MoveSplineInit::SetTransportEnter() { args.flags.EnableTransportEnter(); }
|
||||
inline void MoveSplineInit::SetTransportExit() { args.flags.EnableTransportExit(); }
|
||||
inline void MoveSplineInit::SetOrientationFixed(bool enable) { args.flags.orientationFixed = enable; }
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
#define TRINITYSERVER_MOVESPLINEINIT_ARGS_H
|
||||
|
||||
#include "MoveSplineFlag.h"
|
||||
#include "ObjectGuid.h"
|
||||
#include <vector>
|
||||
|
||||
class Unit;
|
||||
@@ -28,22 +29,21 @@ namespace Movement
|
||||
{
|
||||
typedef std::vector<Vector3> PointsArray;
|
||||
|
||||
union FacingInfo
|
||||
struct FacingInfo
|
||||
{
|
||||
struct {
|
||||
struct
|
||||
{
|
||||
float x, y, z;
|
||||
} f;
|
||||
uint64 target;
|
||||
float angle;
|
||||
ObjectGuid target;
|
||||
float angle;
|
||||
|
||||
FacingInfo(float o) : angle(o) { }
|
||||
FacingInfo(uint64 t) : target(t) { }
|
||||
FacingInfo() { }
|
||||
FacingInfo() : angle(0.0f) { f.x = f.y = f.z = 0.0f; }
|
||||
};
|
||||
|
||||
struct MoveSplineInitArgs
|
||||
{
|
||||
MoveSplineInitArgs(size_t path_capacity = 16);
|
||||
explicit MoveSplineInitArgs(size_t path_capacity = 16);
|
||||
~MoveSplineInitArgs();
|
||||
|
||||
PointsArray path;
|
||||
@@ -55,6 +55,7 @@ namespace Movement
|
||||
float time_perc;
|
||||
uint32 splineId;
|
||||
float initialOrientation;
|
||||
bool walk;
|
||||
bool HasVelocity;
|
||||
bool TransformForTransport;
|
||||
|
||||
|
||||
@@ -164,9 +164,9 @@ namespace Movement
|
||||
STR(TransportExit ), // 0x00010000
|
||||
STR(Unknown3 ), // 0x00020000,
|
||||
STR(Unknown4 ), // 0x00040000,
|
||||
STR(OrientationInversed), // 0x00080000, // Appears With Runmode Flag, Nodes ), // 1, Handles Orientation
|
||||
STR(Backward ), // 0x00080000, // Appears With Runmode Flag, Nodes ), // 1, Handles Orientation
|
||||
STR(SmoothGroundPath ), // 0x00100000,
|
||||
STR(Walkmode ), // 0x00200000,
|
||||
STR(CanSwim ), // 0x00200000,
|
||||
STR(UncompressedPath ), // 0x00400000,
|
||||
STR(Unknown6 ), // 0x00800000,
|
||||
STR(Animation ), // 0x01000000, // Animationid (0...3), Uint32 Time, Not Compartible With Trajectory And Fall Movement
|
||||
|
||||
Reference in New Issue
Block a user