Revert changes
This commit is contained in:
@ -18,12 +18,6 @@ namespace CoopClient.Entities
|
||||
{
|
||||
// If this NPC is in a vehicle, we can find the handle of this vehicle in Main.NPCsVehicles[NPCVehHandle] and prevent multiple vehicles from being created
|
||||
internal long NPCVehHandle { get; set; } = 0;
|
||||
/// <summary>
|
||||
/// 0 = Nothing
|
||||
/// 1 = Character
|
||||
/// 2 = Vehicle
|
||||
/// </summary>
|
||||
private byte ModelNotFound = 0;
|
||||
private bool AllDataAvailable = false;
|
||||
internal bool LastSyncWasFull { get; set; } = false;
|
||||
/// <summary>
|
||||
@ -58,7 +52,7 @@ namespace CoopClient.Entities
|
||||
/// <summary>
|
||||
/// Get the player latency
|
||||
/// </summary>
|
||||
public float Latency { get; internal set; } = 1.5f;
|
||||
public float Latency { get; internal set; }
|
||||
|
||||
/// <summary>
|
||||
/// ?
|
||||
@ -127,26 +121,8 @@ namespace CoopClient.Entities
|
||||
AllDataAvailable = true;
|
||||
}
|
||||
|
||||
if (ModelNotFound != 0)
|
||||
{
|
||||
if (ModelNotFound == 1)
|
||||
{
|
||||
if (CurrentModelHash != LastModelHash)
|
||||
{
|
||||
ModelNotFound = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (CurrentVehicleModelHash != LastVehicleModelHash)
|
||||
{
|
||||
ModelNotFound = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#region NOT_IN_RANGE
|
||||
if (ModelNotFound != 0 || !Game.Player.Character.IsInRange(Position, 500f))
|
||||
if (!Game.Player.Character.IsInRange(Position, 500f))
|
||||
{
|
||||
if (Character != null && Character.Exists())
|
||||
{
|
||||
@ -290,7 +266,6 @@ namespace CoopClient.Entities
|
||||
if (characterModel == null)
|
||||
{
|
||||
//GTA.UI.Notification.Show($"~r~(Character)Model ({CurrentModelHash}) cannot be loaded!");
|
||||
ModelNotFound = 1;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -76,7 +76,6 @@ namespace CoopClient.Entities
|
||||
Character.Ragdoll();
|
||||
}
|
||||
|
||||
UpdateOnFootPosition(false, false, true);
|
||||
return;
|
||||
}
|
||||
else if (!IsRagdoll && Character.IsRagdoll)
|
||||
@ -89,7 +88,6 @@ namespace CoopClient.Entities
|
||||
|
||||
if (IsJumping || IsOnFire)
|
||||
{
|
||||
UpdateOnFootPosition(true, true, false);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -101,7 +99,6 @@ namespace CoopClient.Entities
|
||||
Character.Task.ReloadWeapon();
|
||||
}
|
||||
|
||||
UpdateOnFootPosition();
|
||||
return;
|
||||
}
|
||||
|
||||
@ -141,7 +138,6 @@ namespace CoopClient.Entities
|
||||
Function.Call(Hash.TASK_GO_TO_COORD_WHILE_AIMING_AT_COORD, Character.Handle, Position.X, Position.Y,
|
||||
Position.Z, AimCoords.X, AimCoords.Y, AimCoords.Z, Speed == 3 ? 3f : 2.5f, true, 0x3F000000, 0x40800000, false, 0, false,
|
||||
unchecked((int)FiringPattern.FullAuto));
|
||||
UpdateOnFootPosition();
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -155,7 +151,6 @@ namespace CoopClient.Entities
|
||||
Function.Call(Hash.TASK_GO_TO_COORD_WHILE_AIMING_AT_COORD, Character.Handle, Position.X, Position.Y,
|
||||
Position.Z, AimCoords.X, AimCoords.Y, AimCoords.Z, Speed == 3 ? 3f : 2.5f, false, 0x3F000000, 0x40800000, false, 512, false,
|
||||
unchecked((int)FiringPattern.FullAuto));
|
||||
UpdateOnFootPosition();
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -215,50 +210,6 @@ namespace CoopClient.Entities
|
||||
}
|
||||
break;
|
||||
}
|
||||
UpdateOnFootPosition();
|
||||
}
|
||||
|
||||
private byte LastStuckCount = 0;
|
||||
private ulong LastStuckTime;
|
||||
private void UpdateOnFootPosition(bool updatePosition = true, bool updateRotation = true, bool updateVelocity = true)
|
||||
{
|
||||
if (Character.Position.DistanceTo(Position) > 5f)
|
||||
{
|
||||
if (Util.GetTickCount64() - LastStuckTime < 1000)
|
||||
{
|
||||
LastStuckCount = 0;
|
||||
}
|
||||
|
||||
++LastStuckCount;
|
||||
|
||||
if (LastStuckCount >= 5)
|
||||
{
|
||||
Character.Position = Position;
|
||||
LastStuckCount = 0;
|
||||
}
|
||||
|
||||
LastStuckTime = Util.GetTickCount64();
|
||||
}
|
||||
|
||||
if (updatePosition)
|
||||
{
|
||||
float lerpValue = ((int)((Latency * 1000 / 2) + Main.MainNetworking.Latency * 1000 / 2)) * 2 / 50000f;
|
||||
|
||||
Vector2 biDimensionalPos = Vector2.Lerp(new Vector2(Character.Position.X, Character.Position.Y), new Vector2(Position.X + (Velocity.X / 5), Position.Y + (Velocity.Y / 5)), lerpValue);
|
||||
float zPos = Util.Lerp(Character.Position.Z, Position.Z, 0.1f);
|
||||
Character.PositionNoOffset = new Vector3(biDimensionalPos.X, biDimensionalPos.Y, zPos);
|
||||
}
|
||||
|
||||
if (updateRotation)
|
||||
{
|
||||
// You can find the ToQuaternion() for Rotation inside the VectorExtensions
|
||||
Character.Quaternion = Quaternion.Lerp(Character.Quaternion, Rotation.ToQuaternion(), 0.10f);
|
||||
}
|
||||
|
||||
if (updateVelocity)
|
||||
{
|
||||
Character.Velocity = Velocity;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -114,7 +114,7 @@ namespace CoopClient.Entities
|
||||
if (vehicleModel == null)
|
||||
{
|
||||
//GTA.UI.Notification.Show($"~r~(Vehicle)Model ({CurrentVehicleModelHash}) cannot be loaded!");
|
||||
ModelNotFound = 2;
|
||||
Character.IsVisible = false;
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -666,7 +666,6 @@ namespace CoopClient
|
||||
npc.IsInVehicle = false;
|
||||
npc.LastSyncWasFull = true;
|
||||
|
||||
npc.Latency = packet.Latency.Value;
|
||||
npc.LastUpdateReceived = Util.GetTickCount64();
|
||||
}
|
||||
else
|
||||
@ -691,7 +690,6 @@ namespace CoopClient
|
||||
IsInVehicle = false,
|
||||
LastSyncWasFull = true,
|
||||
|
||||
Latency = packet.Latency.Value,
|
||||
LastUpdateReceived = Util.GetTickCount64()
|
||||
});
|
||||
}
|
||||
@ -734,7 +732,6 @@ namespace CoopClient
|
||||
npc.IsInVehicle = true;
|
||||
npc.LastSyncWasFull = true;
|
||||
|
||||
npc.Latency = packet.Latency.Value;
|
||||
npc.LastUpdateReceived = Util.GetTickCount64();
|
||||
}
|
||||
else
|
||||
@ -769,7 +766,6 @@ namespace CoopClient
|
||||
IsInVehicle = true,
|
||||
LastSyncWasFull = true,
|
||||
|
||||
Latency = packet.Latency.Value,
|
||||
LastUpdateReceived = Util.GetTickCount64()
|
||||
});
|
||||
}
|
||||
@ -937,8 +933,7 @@ namespace CoopClient
|
||||
VehMods = veh.Mods.GetVehicleMods(),
|
||||
VehDamageModel = veh.GetVehicleDamageModel(),
|
||||
VehLandingGear = veh.IsPlane ? (byte)veh.LandingGearState : (byte)0,
|
||||
Flag = npc.GetVehicleFlags(veh),
|
||||
Latency = Latency
|
||||
Flag = npc.GetVehicleFlags(veh)
|
||||
}.PacketToNetOutGoingMessage(outgoingMessage);
|
||||
}
|
||||
else
|
||||
@ -955,8 +950,7 @@ namespace CoopClient
|
||||
Speed = npc.GetPedSpeed(),
|
||||
AimCoords = npc.GetPedAimCoords(true).ToLVector(),
|
||||
CurrentWeaponHash = (uint)npc.Weapons.Current.Hash,
|
||||
Flag = npc.GetPedFlags(true),
|
||||
Latency = Latency
|
||||
Flag = npc.GetPedFlags(true)
|
||||
}.PacketToNetOutGoingMessage(outgoingMessage);
|
||||
}
|
||||
|
||||
|
@ -1679,8 +1679,6 @@ namespace CoopClient
|
||||
|
||||
public byte? Flag { get; set; } = 0;
|
||||
|
||||
public float? Latency { get; set; }
|
||||
|
||||
public override void PacketToNetOutGoingMessage(NetOutgoingMessage message)
|
||||
{
|
||||
#region PacketToNetOutGoingMessage
|
||||
@ -1742,12 +1740,6 @@ namespace CoopClient
|
||||
// Write npc weapon hash
|
||||
byteArray.AddRange(BitConverter.GetBytes(CurrentWeaponHash));
|
||||
|
||||
// Write player latency
|
||||
if (Latency.HasValue)
|
||||
{
|
||||
byteArray.AddRange(BitConverter.GetBytes(Latency.Value));
|
||||
}
|
||||
|
||||
byte[] result = byteArray.ToArray();
|
||||
|
||||
message.Write(result.Length);
|
||||
@ -1832,12 +1824,6 @@ namespace CoopClient
|
||||
|
||||
// Read npc weapon hash
|
||||
CurrentWeaponHash = reader.ReadUInt();
|
||||
|
||||
// Read player latency
|
||||
if (reader.CanRead(4))
|
||||
{
|
||||
Latency = reader.ReadFloat();
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@ -1882,8 +1868,6 @@ namespace CoopClient
|
||||
|
||||
public ushort? Flag { get; set; }
|
||||
|
||||
public float? Latency { get; set; }
|
||||
|
||||
public override void PacketToNetOutGoingMessage(NetOutgoingMessage message)
|
||||
{
|
||||
#region PacketToNetOutGoingMessage
|
||||
@ -1991,12 +1975,6 @@ namespace CoopClient
|
||||
byteArray.Add(0x00);
|
||||
}
|
||||
|
||||
// Write player latency
|
||||
if (Latency.HasValue)
|
||||
{
|
||||
byteArray.AddRange(BitConverter.GetBytes(Latency.Value));
|
||||
}
|
||||
|
||||
byte[] result = byteArray.ToArray();
|
||||
|
||||
message.Write(result.Length);
|
||||
@ -2122,12 +2100,6 @@ namespace CoopClient
|
||||
PuncturedTires = reader.ReadUShort()
|
||||
};
|
||||
}
|
||||
|
||||
// Read player latency
|
||||
if (reader.CanRead(4))
|
||||
{
|
||||
Latency = reader.ReadFloat();
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
@ -1662,8 +1662,6 @@ namespace CoopServer
|
||||
|
||||
public byte? Flag { get; set; } = 0;
|
||||
|
||||
public float? Latency { get; set; }
|
||||
|
||||
public override void PacketToNetOutGoingMessage(NetOutgoingMessage message)
|
||||
{
|
||||
#region PacketToNetOutGoingMessage
|
||||
@ -1725,12 +1723,6 @@ namespace CoopServer
|
||||
// Write npc weapon hash
|
||||
byteArray.AddRange(BitConverter.GetBytes(CurrentWeaponHash));
|
||||
|
||||
// Write player latency
|
||||
if (Latency.HasValue)
|
||||
{
|
||||
byteArray.AddRange(BitConverter.GetBytes(Latency.Value));
|
||||
}
|
||||
|
||||
byte[] result = byteArray.ToArray();
|
||||
|
||||
message.Write(result.Length);
|
||||
@ -1815,12 +1807,6 @@ namespace CoopServer
|
||||
|
||||
// Read npc weapon hash
|
||||
CurrentWeaponHash = reader.ReadUInt();
|
||||
|
||||
// Read player latency
|
||||
if (reader.CanRead(4))
|
||||
{
|
||||
Latency = reader.ReadFloat();
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@ -1865,8 +1851,6 @@ namespace CoopServer
|
||||
|
||||
public ushort? Flag { get; set; }
|
||||
|
||||
public float? Latency { get; set; }
|
||||
|
||||
public override void PacketToNetOutGoingMessage(NetOutgoingMessage message)
|
||||
{
|
||||
#region PacketToNetOutGoingMessage
|
||||
@ -1974,12 +1958,6 @@ namespace CoopServer
|
||||
byteArray.Add(0x00);
|
||||
}
|
||||
|
||||
// Write player latency
|
||||
if (Latency.HasValue)
|
||||
{
|
||||
byteArray.AddRange(BitConverter.GetBytes(Latency.Value));
|
||||
}
|
||||
|
||||
byte[] result = byteArray.ToArray();
|
||||
|
||||
message.Write(result.Length);
|
||||
@ -2105,12 +2083,6 @@ namespace CoopServer
|
||||
PuncturedTires = reader.ReadUShort()
|
||||
};
|
||||
}
|
||||
|
||||
// Read player latency
|
||||
if (reader.CanRead(4))
|
||||
{
|
||||
Latency = reader.ReadFloat();
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user