mirror of
https://github.com/araxiaonline/TrinityCore2.git
synced 2026-06-13 03:22:40 -04:00
Core/Movement: Ensured object orientation is always within 0-2pi range, this fixes movement.
This commit is contained in:
@@ -249,6 +249,7 @@ void Creature::RemoveCorpse(bool setSpawnTime)
|
||||
|
||||
float x, y, z, o;
|
||||
GetRespawnPosition(x, y, z, &o);
|
||||
o = MapManager::NormalizeOrientation(o);
|
||||
SetHomePosition(x, y, z, o);
|
||||
GetMap()->CreatureRelocation(this, x, y, z, o);
|
||||
}
|
||||
@@ -2464,6 +2465,7 @@ void Creature::SetPosition(float x, float y, float z, float o)
|
||||
return;
|
||||
}
|
||||
|
||||
o = MapManager::NormalizeOrientation(o);
|
||||
GetMap()->CreatureRelocation(ToCreature(), x, y, z, o);
|
||||
if (IsVehicle())
|
||||
GetVehicleKit()->RelocatePassengers(x, y, z, o);
|
||||
|
||||
@@ -673,8 +673,8 @@ class Creature : public Unit, public GridObject<Creature>, public MapCreature
|
||||
|
||||
void SetHomePosition(float x, float y, float z, float o) { m_homePosition.Relocate(x, y, z, o); }
|
||||
void SetHomePosition(const Position &pos) { m_homePosition.Relocate(pos); }
|
||||
void GetHomePosition(float &x, float &y, float &z, float &ori) { m_homePosition.GetPosition(x, y, z, ori); }
|
||||
Position GetHomePosition() { return m_homePosition; }
|
||||
void GetHomePosition(float &x, float &y, float &z, float &ori) const { m_homePosition.GetPosition(x, y, z, ori); }
|
||||
Position GetHomePosition() const { return m_homePosition; }
|
||||
|
||||
void SetTransportHomePosition(float x, float y, float z, float o) { m_transportHomePosition.Relocate(x, y, z, o); }
|
||||
void SetTransportHomePosition(const Position &pos) { m_transportHomePosition.Relocate(pos); }
|
||||
|
||||
@@ -167,6 +167,7 @@ bool GameObject::Create(uint32 guidlow, uint32 name_id, Map* map, uint32 phaseMa
|
||||
ASSERT(map);
|
||||
SetMap(map);
|
||||
|
||||
ang = MapManager::NormalizeOrientation(ang);
|
||||
Relocate(x, y, z, ang);
|
||||
if (!IsPositionValid())
|
||||
{
|
||||
|
||||
@@ -315,7 +315,6 @@ void Object::_BuildMovementUpdate(ByteBuffer* data, uint16 flags) const
|
||||
data->WriteBit(flags & UPDATEFLAG_UNK5);
|
||||
data->WriteBit(0);
|
||||
data->WriteBit(flags & UPDATEFLAG_TRANSPORT);
|
||||
bool fullSpline = false;
|
||||
|
||||
if (flags & UPDATEFLAG_LIVING)
|
||||
{
|
||||
@@ -323,6 +322,8 @@ void Object::_BuildMovementUpdate(ByteBuffer* data, uint16 flags) const
|
||||
ObjectGuid guid = GetGUID();
|
||||
uint32 movementFlags = self->m_movementInfo.GetMovementFlags();
|
||||
uint16 movementFlagsExtra = self->m_movementInfo.GetExtraMovementFlags();
|
||||
if (GetTypeId() == TYPEID_UNIT)
|
||||
movementFlags &= MOVEMENTFLAG_MASK_CREATURE_ALLOWED;
|
||||
|
||||
data->WriteBit(!movementFlags);
|
||||
data->WriteBit(G3D::fuzzyEq(self->GetOrientation(), 0.0f)); // Has Orientation
|
||||
@@ -359,7 +360,7 @@ void Object::_BuildMovementUpdate(ByteBuffer* data, uint16 flags) const
|
||||
|
||||
data->WriteBit(guid[4]);
|
||||
if (self->IsSplineEnabled())
|
||||
Movement::PacketBuilder::WriteCreateBits(*self->movespline, *data, fullSpline);
|
||||
Movement::PacketBuilder::WriteCreateBits(*self->movespline, *data);
|
||||
|
||||
data->WriteBit(guid[6]);
|
||||
if (movementFlagsExtra & MOVEMENTFLAG2_INTERPOLATED_TURNING)
|
||||
@@ -421,6 +422,8 @@ void Object::_BuildMovementUpdate(ByteBuffer* data, uint16 flags) const
|
||||
ObjectGuid guid = GetGUID();
|
||||
uint32 movementFlags = self->m_movementInfo.GetMovementFlags();
|
||||
uint16 movementFlagsExtra = self->m_movementInfo.GetExtraMovementFlags();
|
||||
if (GetTypeId() == TYPEID_UNIT)
|
||||
movementFlags &= MOVEMENTFLAG_MASK_CREATURE_ALLOWED;
|
||||
|
||||
data->WriteByteSeq(guid[4]);
|
||||
*data << self->GetSpeed(MOVE_RUN_BACK);
|
||||
@@ -442,7 +445,7 @@ void Object::_BuildMovementUpdate(ByteBuffer* data, uint16 flags) const
|
||||
*data << float(self->m_movementInfo.splineElevation);
|
||||
|
||||
if (self->IsSplineEnabled())
|
||||
Movement::PacketBuilder::WriteCreateData(*self->movespline, *data, fullSpline);
|
||||
Movement::PacketBuilder::WriteCreateData(*self->movespline, *data);
|
||||
|
||||
*data << float(self->GetPositionZMinusOffset());
|
||||
data->WriteByteSeq(guid[5]);
|
||||
|
||||
@@ -711,7 +711,7 @@ void Transport::UpdateNPCPositions()
|
||||
void Transport::CalculatePassengerPosition(float& x, float& y, float& z, float& o)
|
||||
{
|
||||
float inx = x, iny = y, inz = z, ino = o;
|
||||
o = GetOrientation() + ino;
|
||||
o = MapManager::NormalizeOrientation(GetOrientation() + ino);
|
||||
x = GetPositionX() + (inx * cos(GetOrientation()) + iny * sin(GetOrientation() + M_PI));
|
||||
y = GetPositionY() + (iny * cos(GetOrientation()) + inx * sin(GetOrientation()));
|
||||
z = GetPositionZ() + inz;
|
||||
@@ -720,7 +720,7 @@ void Transport::CalculatePassengerPosition(float& x, float& y, float& z, float&
|
||||
//! This method transforms supplied global coordinates into local offsets
|
||||
void Transport::CalculatePassengerOffset(float& x, float& y, float& z, float& o)
|
||||
{
|
||||
o -= GetOrientation();
|
||||
o = MapManager::NormalizeOrientation(o - GetOrientation());
|
||||
z -= GetPositionZ();
|
||||
y -= GetPositionY(); // y = searchedY * cos(o) + searchedX * sin(o)
|
||||
x -= GetPositionX(); // x = searchedX * cos(o) + searchedY * sin(o + pi)
|
||||
|
||||
@@ -16257,20 +16257,20 @@ void Unit::SendMoveRoot(uint32 value)
|
||||
data.WriteBit(guid[4]);
|
||||
data.WriteBit(guid[1]);
|
||||
data.WriteBit(guid[3]);
|
||||
|
||||
|
||||
data.WriteByteSeq(guid[1]);
|
||||
data.WriteByteSeq(guid[0]);
|
||||
data.WriteByteSeq(guid[2]);
|
||||
data.WriteByteSeq(guid[5]);
|
||||
|
||||
|
||||
data << uint32(value);
|
||||
|
||||
|
||||
|
||||
|
||||
data.WriteByteSeq(guid[3]);
|
||||
data.WriteByteSeq(guid[4]);
|
||||
data.WriteByteSeq(guid[7]);
|
||||
data.WriteByteSeq(guid[6]);
|
||||
|
||||
|
||||
SendMessageToSet(&data, true);
|
||||
}
|
||||
|
||||
@@ -16286,19 +16286,19 @@ void Unit::SendMoveUnroot(uint32 value)
|
||||
data.WriteBit(guid[2]);
|
||||
data.WriteBit(guid[4]);
|
||||
data.WriteBit(guid[6]);
|
||||
|
||||
|
||||
data.WriteByteSeq(guid[3]);
|
||||
data.WriteByteSeq(guid[6]);
|
||||
data.WriteByteSeq(guid[1]);
|
||||
|
||||
|
||||
data << uint32(value);
|
||||
|
||||
|
||||
data.WriteByteSeq(guid[2]);
|
||||
data.WriteByteSeq(guid[0]);
|
||||
data.WriteByteSeq(guid[7]);
|
||||
data.WriteByteSeq(guid[4]);
|
||||
data.WriteByteSeq(guid[5]);
|
||||
|
||||
|
||||
SendMessageToSet(&data, true);
|
||||
}
|
||||
|
||||
@@ -17849,6 +17849,7 @@ bool Unit::UpdatePosition(float x, float y, float z, float orientation, bool tel
|
||||
return false;
|
||||
}
|
||||
|
||||
orientation = MapManager::NormalizeOrientation(orientation);
|
||||
bool turn = (GetOrientation() != orientation);
|
||||
bool relocated = (teleport || GetPositionX() != x || GetPositionY() != y || GetPositionZ() != z);
|
||||
|
||||
|
||||
@@ -711,6 +711,12 @@ enum MovementFlags
|
||||
MOVEMENTFLAG_MASK_MOVING_FLY =
|
||||
MOVEMENTFLAG_FLYING | MOVEMENTFLAG_ASCENDING | MOVEMENTFLAG_DESCENDING,
|
||||
|
||||
// Movement flags allowed for creature in CreateObject - we need to keep all other enabled serverside
|
||||
// to properly calculate all movement
|
||||
MOVEMENTFLAG_MASK_CREATURE_ALLOWED =
|
||||
MOVEMENTFLAG_FORWARD | MOVEMENTFLAG_DISABLE_GRAVITY | MOVEMENTFLAG_ROOT | MOVEMENTFLAG_SWIMMING |
|
||||
MOVEMENTFLAG_CAN_FLY | MOVEMENTFLAG_WATERWALKING | MOVEMENTFLAG_FALLING_SLOW | MOVEMENTFLAG_HOVER,
|
||||
|
||||
//! TODO if needed: add more flags to this masks that are exclusive to players
|
||||
MOVEMENTFLAG_MASK_PLAYER_ONLY =
|
||||
MOVEMENTFLAG_FLYING,
|
||||
@@ -1407,7 +1413,7 @@ class Unit : public WorldObject
|
||||
MountCapabilityEntry const* GetMountCapability(uint32 mountType) const;
|
||||
|
||||
void SendDurabilityLoss(Player* receiver, uint32 percent);
|
||||
|
||||
|
||||
uint16 GetMaxSkillValueForLevel(Unit const* target = NULL) const { return (target ? getLevelForTarget(target) : getLevel()) * 5; }
|
||||
void DealDamageMods(Unit* victim, uint32 &damage, uint32* absorb);
|
||||
uint32 DealDamage(Unit* victim, uint32 damage, CleanDamage const* cleanDamage = NULL, DamageEffectType damagetype = DIRECT_DAMAGE, SpellSchoolMask damageSchoolMask = SPELL_SCHOOL_MASK_NORMAL, SpellInfo const* spellProto = NULL, bool durabilityLoss = true);
|
||||
|
||||
@@ -81,7 +81,7 @@ namespace Movement
|
||||
if (args.path.empty())
|
||||
return;
|
||||
|
||||
// corrent first vertex
|
||||
// correct first vertex
|
||||
args.path[0] = real_position;
|
||||
args.initialOrientation = real_position.orientation;
|
||||
|
||||
@@ -114,7 +114,7 @@ namespace Movement
|
||||
}
|
||||
|
||||
PacketBuilder::WriteMonsterMove(move_spline, data);
|
||||
unit.SendMessageToSet(&data,true);
|
||||
unit.SendMessageToSet(&data, true);
|
||||
}
|
||||
|
||||
MoveSplineInit::MoveSplineInit(Unit& m) : unit(m)
|
||||
@@ -124,6 +124,7 @@ namespace Movement
|
||||
// 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.smoothGroundPath = true; // enabled by default, CatmullRom mode or client config "pathSmoothing" will disable this
|
||||
}
|
||||
|
||||
void MoveSplineInit::SetFacing(const Unit * target)
|
||||
|
||||
@@ -140,10 +140,9 @@ namespace Movement
|
||||
WriteLinearPath(spline, data);
|
||||
}
|
||||
|
||||
void PacketBuilder::WriteCreateBits(MoveSpline const& moveSpline, ByteBuffer& data, bool& fullData)
|
||||
void PacketBuilder::WriteCreateBits(MoveSpline const& moveSpline, ByteBuffer& data)
|
||||
{
|
||||
fullData = data.WriteBit(!moveSpline.Finalized());
|
||||
if (!fullData)
|
||||
if (!data.WriteBit(!moveSpline.Finalized()))
|
||||
return;
|
||||
|
||||
data.WriteBits(uint8(moveSpline.spline.mode()), 2);
|
||||
@@ -180,9 +179,9 @@ namespace Movement
|
||||
data.WriteBits(moveSpline.splineflags.raw(), 25);
|
||||
}
|
||||
|
||||
void PacketBuilder::WriteCreateData(MoveSpline const& moveSpline, ByteBuffer& data, bool fullData)
|
||||
void PacketBuilder::WriteCreateData(MoveSpline const& moveSpline, ByteBuffer& data)
|
||||
{
|
||||
if (fullData)
|
||||
if (!moveSpline.Finalized())
|
||||
{
|
||||
MoveSplineFlag splineFlags = moveSpline.splineflags;
|
||||
|
||||
|
||||
@@ -31,8 +31,8 @@ namespace Movement
|
||||
public:
|
||||
|
||||
static void WriteMonsterMove(const MoveSpline& mov, WorldPacket& data);
|
||||
static void WriteCreateBits(MoveSpline const& moveSpline, ByteBuffer& data, bool& fullData);
|
||||
static void WriteCreateData(MoveSpline const& moveSpline, ByteBuffer& data, bool fullData);
|
||||
static void WriteCreateBits(MoveSpline const& moveSpline, ByteBuffer& data);
|
||||
static void WriteCreateData(MoveSpline const& moveSpline, ByteBuffer& data);
|
||||
};
|
||||
}
|
||||
#endif // TRINITYSERVER_PACKET_BUILDER_H
|
||||
|
||||
@@ -303,7 +303,7 @@ class npc_coldflame : public CreatureScript
|
||||
{
|
||||
Position const* ownerPos = marrowgarAI->GetLastColdflamePosition();
|
||||
float ang = me->GetAngle(ownerPos) - static_cast<float>(M_PI);
|
||||
MapManager::NormalizeOrientation(ang);
|
||||
ang = MapManager::NormalizeOrientation(ang);
|
||||
me->SetOrientation(ang);
|
||||
owner->GetNearPosition(pos, 2.5f, 0.0f);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user