Various weapon fixes and some change on vehicle sync
This commit is contained in:
@ -22,8 +22,7 @@ namespace RageCoop.Client
|
|||||||
|
|
||||||
private void OnTick(object sender, EventArgs e)
|
private void OnTick(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var wb = Game.Player.Character?.Weapons?.CurrentWeaponObject?.Bones["gun_muzzle"];
|
foreach (var p in World.GetAllPeds()) DrawWeaponBone(p);
|
||||||
if (wb?.IsValid == true) World.DrawLine(wb.Position, wb.Position + wb.RightVector, Color.Blue);
|
|
||||||
if (ToMark == null) return;
|
if (ToMark == null) return;
|
||||||
|
|
||||||
if (WeaponUtil.VehicleWeapons.TryGetValue((uint)(int)ToMark.Model, out var info))
|
if (WeaponUtil.VehicleWeapons.TryGetValue((uint)(int)ToMark.Model, out var info))
|
||||||
@ -35,6 +34,14 @@ namespace RageCoop.Client
|
|||||||
if (b != null) World.DrawLine(b.Position, b.Position + b.ForwardVector * 5, Color.Brown);
|
if (b != null) World.DrawLine(b.Position, b.Position + b.ForwardVector * 5, Color.Brown);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void DrawWeaponBone(Ped p)
|
||||||
|
{
|
||||||
|
var wb = p.Weapons?.CurrentWeaponObject?.Bones["gun_muzzle"];
|
||||||
|
if (wb?.IsValid == true) World.DrawLine(wb.Position, wb.Position + wb.RightVector, Color.Blue);
|
||||||
|
if (wb?.IsValid == true) World.DrawLine(wb.Position, wb.Position + wb.ForwardVector, Color.Red);
|
||||||
|
if (wb?.IsValid == true) World.DrawLine(wb.Position, wb.Position + wb.UpVector, Color.Green);
|
||||||
|
|
||||||
|
}
|
||||||
private void FindAndDraw()
|
private void FindAndDraw()
|
||||||
{
|
{
|
||||||
DrawBone("weapon_1a");
|
DrawBone("weapon_1a");
|
||||||
|
@ -12,6 +12,7 @@ using GTA.UI;
|
|||||||
using LemonUI.Elements;
|
using LemonUI.Elements;
|
||||||
using LemonUI.Menus;
|
using LemonUI.Menus;
|
||||||
using Lidgren.Network;
|
using Lidgren.Network;
|
||||||
|
using Newtonsoft.Json.Linq;
|
||||||
using RageCoop.Client.GUI;
|
using RageCoop.Client.GUI;
|
||||||
using RageCoop.Client.Menus;
|
using RageCoop.Client.Menus;
|
||||||
using RageCoop.Client.Scripting;
|
using RageCoop.Client.Scripting;
|
||||||
|
@ -307,7 +307,6 @@ namespace RageCoop.Client
|
|||||||
c.Flags = packet.Flags;
|
c.Flags = packet.Flags;
|
||||||
c.Heading = packet.Heading;
|
c.Heading = packet.Heading;
|
||||||
c.Position = packet.Position;
|
c.Position = packet.Position;
|
||||||
c.LastSyncedStopWatch.Restart();
|
|
||||||
if (c.IsRagdoll)
|
if (c.IsRagdoll)
|
||||||
{
|
{
|
||||||
c.HeadPosition = packet.HeadPosition;
|
c.HeadPosition = packet.HeadPosition;
|
||||||
@ -320,11 +319,13 @@ namespace RageCoop.Client
|
|||||||
c.Seat = packet.Seat;
|
c.Seat = packet.Seat;
|
||||||
}
|
}
|
||||||
|
|
||||||
c.LastSynced = Main.Ticked;
|
|
||||||
if (c.IsAiming) c.AimCoords = packet.AimCoords;
|
if (c.IsAiming) c.AimCoords = packet.AimCoords;
|
||||||
if (packet.Flags.HasPedFlag(PedDataFlags.IsFullSync))
|
bool full = packet.Flags.HasPedFlag(PedDataFlags.IsFullSync);
|
||||||
|
if (full)
|
||||||
{
|
{
|
||||||
c.CurrentWeaponHash = packet.CurrentWeaponHash;
|
if (packet.Speed == 4)
|
||||||
|
c.VehicleWeapon = packet.VehicleWeapon;
|
||||||
|
c.CurrentWeapon = packet.CurrentWeapon;
|
||||||
c.Clothes = packet.Clothes;
|
c.Clothes = packet.Clothes;
|
||||||
c.WeaponComponents = packet.WeaponComponents;
|
c.WeaponComponents = packet.WeaponComponents;
|
||||||
c.WeaponTint = packet.WeaponTint;
|
c.WeaponTint = packet.WeaponTint;
|
||||||
@ -332,8 +333,8 @@ namespace RageCoop.Client
|
|||||||
c.BlipColor = packet.BlipColor;
|
c.BlipColor = packet.BlipColor;
|
||||||
c.BlipSprite = packet.BlipSprite;
|
c.BlipSprite = packet.BlipSprite;
|
||||||
c.BlipScale = packet.BlipScale;
|
c.BlipScale = packet.BlipScale;
|
||||||
c.LastFullSynced = Main.Ticked;
|
|
||||||
}
|
}
|
||||||
|
c.SetLastSynced(full);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void VehicleSync(Packets.VehicleSync packet)
|
private static void VehicleSync(Packets.VehicleSync packet)
|
||||||
@ -345,6 +346,7 @@ namespace RageCoop.Client
|
|||||||
v.OwnerID = packet.OwnerID;
|
v.OwnerID = packet.OwnerID;
|
||||||
v.Flags = packet.Flags;
|
v.Flags = packet.Flags;
|
||||||
v.Position = packet.Position;
|
v.Position = packet.Position;
|
||||||
|
v.LastQuaternion = v.Quaternion;
|
||||||
v.Quaternion = packet.Quaternion;
|
v.Quaternion = packet.Quaternion;
|
||||||
v.SteeringAngle = packet.SteeringAngle;
|
v.SteeringAngle = packet.SteeringAngle;
|
||||||
v.ThrottlePower = packet.ThrottlePower;
|
v.ThrottlePower = packet.ThrottlePower;
|
||||||
@ -352,9 +354,8 @@ namespace RageCoop.Client
|
|||||||
v.Velocity = packet.Velocity;
|
v.Velocity = packet.Velocity;
|
||||||
v.RotationVelocity = packet.RotationVelocity;
|
v.RotationVelocity = packet.RotationVelocity;
|
||||||
v.DeluxoWingRatio = packet.DeluxoWingRatio;
|
v.DeluxoWingRatio = packet.DeluxoWingRatio;
|
||||||
v.LastSynced = Main.Ticked;
|
bool full = packet.Flags.HasVehFlag(VehicleDataFlags.IsFullSync);
|
||||||
v.LastSyncedStopWatch.Restart();
|
if (full)
|
||||||
if (packet.Flags.HasVehFlag(VehicleDataFlags.IsFullSync))
|
|
||||||
{
|
{
|
||||||
v.DamageModel = packet.DamageModel;
|
v.DamageModel = packet.DamageModel;
|
||||||
v.EngineHealth = packet.EngineHealth;
|
v.EngineHealth = packet.EngineHealth;
|
||||||
@ -367,8 +368,8 @@ namespace RageCoop.Client
|
|||||||
v.RadioStation = packet.RadioStation;
|
v.RadioStation = packet.RadioStation;
|
||||||
v.LicensePlate = packet.LicensePlate;
|
v.LicensePlate = packet.LicensePlate;
|
||||||
v.Livery = packet.Livery;
|
v.Livery = packet.Livery;
|
||||||
v.LastFullSynced = Main.Ticked;
|
|
||||||
}
|
}
|
||||||
|
v.SetLastSynced(full);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void ProjectileSync(Packets.ProjectileSync packet)
|
private static void ProjectileSync(Packets.ProjectileSync packet)
|
||||||
@ -389,8 +390,7 @@ namespace RageCoop.Client
|
|||||||
p.Shooter = packet.Flags.HasProjDataFlag(ProjectileDataFlags.IsShotByVehicle)
|
p.Shooter = packet.Flags.HasProjDataFlag(ProjectileDataFlags.IsShotByVehicle)
|
||||||
? (SyncedEntity)EntityPool.GetVehicleByID(packet.ShooterID)
|
? (SyncedEntity)EntityPool.GetVehicleByID(packet.ShooterID)
|
||||||
: EntityPool.GetPedByID(packet.ShooterID);
|
: EntityPool.GetPedByID(packet.ShooterID);
|
||||||
p.LastSynced = Main.Ticked;
|
p.SetLastSynced(false);
|
||||||
p.LastSyncedStopWatch.Restart();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -65,8 +65,9 @@ namespace RageCoop.Client
|
|||||||
sp.LastSentStopWatch.Restart();
|
sp.LastSentStopWatch.Restart();
|
||||||
if (full)
|
if (full)
|
||||||
{
|
{
|
||||||
var w = ped.VehicleWeapon;
|
if (p.Speed == 4)
|
||||||
p.CurrentWeaponHash = w != VehicleWeaponHash.Invalid ? (uint)w : (uint)ped.Weapons.Current.Hash;
|
p.VehicleWeapon = ped.VehicleWeapon;
|
||||||
|
p.CurrentWeapon = ped.Weapons.Current.Hash;
|
||||||
p.Flags |= PedDataFlags.IsFullSync;
|
p.Flags |= PedDataFlags.IsFullSync;
|
||||||
p.Clothes = ped.GetPedClothes();
|
p.Clothes = ped.GetPedClothes();
|
||||||
p.ModelHash = ped.Model.Hash;
|
p.ModelHash = ped.Model.Hash;
|
||||||
@ -177,29 +178,16 @@ namespace RageCoop.Client
|
|||||||
|
|
||||||
#region SYNC EVENTS
|
#region SYNC EVENTS
|
||||||
|
|
||||||
public static void SendBullet(Vector3 start, Vector3 end, uint weapon, int ownerID)
|
public static void SendBullet(int ownerID, uint weapon, Vector3 end)
|
||||||
{
|
{
|
||||||
SendSync(new Packets.BulletShot
|
SendSync(new Packets.BulletShot
|
||||||
{
|
{
|
||||||
StartPosition = start,
|
|
||||||
EndPosition = end,
|
EndPosition = end,
|
||||||
OwnerID = ownerID,
|
OwnerID = ownerID,
|
||||||
WeaponHash = weapon
|
WeaponHash = weapon
|
||||||
}, ConnectionChannel.SyncEvents);
|
}, ConnectionChannel.SyncEvents);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void SendVehicleBullet(uint hash, SyncedPed owner, EntityBone b)
|
|
||||||
{
|
|
||||||
SendSync(new Packets.VehicleBulletShot
|
|
||||||
{
|
|
||||||
StartPosition = b.Position,
|
|
||||||
EndPosition = b.Position + b.ForwardVector,
|
|
||||||
OwnerID = owner.ID,
|
|
||||||
Bone = (ushort)b.Index,
|
|
||||||
WeaponHash = hash
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -13,6 +13,6 @@ using System.Resources;
|
|||||||
|
|
||||||
|
|
||||||
// Version information
|
// Version information
|
||||||
[assembly: AssemblyVersion("1.6.0.21")]
|
[assembly: AssemblyVersion("1.6.0.24")]
|
||||||
[assembly: AssemblyFileVersion("1.6.0.21")]
|
[assembly: AssemblyFileVersion("1.6.0.24")]
|
||||||
[assembly: NeutralResourcesLanguageAttribute("en-US")]
|
[assembly: NeutralResourcesLanguageAttribute("en-US")]
|
@ -73,7 +73,7 @@ namespace RageCoop.Client
|
|||||||
if (!IsInCover) return "";
|
if (!IsInCover) return "";
|
||||||
var altitude = IsInLowCover ? "low" : "high";
|
var altitude = IsInLowCover ? "low" : "high";
|
||||||
|
|
||||||
var hands = GetWeaponHandsHeld(CurrentWeaponHash);
|
var hands = GetWeaponHandsHeld((uint)CurrentWeapon);
|
||||||
if (IsBlindFiring)
|
if (IsBlindFiring)
|
||||||
{
|
{
|
||||||
if (hands == 1) return "cover@weapon@1h";
|
if (hands == 1) return "cover@weapon@1h";
|
||||||
|
@ -15,12 +15,12 @@ namespace RageCoop.Client
|
|||||||
private bool _lastDriveBy;
|
private bool _lastDriveBy;
|
||||||
private bool _lastInCover;
|
private bool _lastInCover;
|
||||||
private bool _lastIsJumping;
|
private bool _lastIsJumping;
|
||||||
|
private WeaponHash _lastWeaponHash;
|
||||||
private bool _lastMoving;
|
private bool _lastMoving;
|
||||||
private bool _lastRagdoll;
|
private bool _lastRagdoll;
|
||||||
private ulong _lastRagdollTime;
|
private ulong _lastRagdollTime;
|
||||||
private Dictionary<uint, bool> _lastWeaponComponents;
|
private Dictionary<uint, bool> _lastWeaponComponents;
|
||||||
private Entity _weaponObj;
|
internal Entity WeaponObj;
|
||||||
internal BlipColor BlipColor = (BlipColor)255;
|
internal BlipColor BlipColor = (BlipColor)255;
|
||||||
internal float BlipScale = 1;
|
internal float BlipScale = 1;
|
||||||
internal BlipSprite BlipSprite = 0;
|
internal BlipSprite BlipSprite = 0;
|
||||||
@ -41,16 +41,16 @@ namespace RageCoop.Client
|
|||||||
internal SyncedVehicle CurrentVehicle { get; private set; }
|
internal SyncedVehicle CurrentVehicle { get; private set; }
|
||||||
public bool IsPlayer => OwnerID == ID && ID != 0;
|
public bool IsPlayer => OwnerID == ID && ID != 0;
|
||||||
public Ped MainPed { get; internal set; }
|
public Ped MainPed { get; internal set; }
|
||||||
internal int Health { get; set; }
|
internal int Health;
|
||||||
|
|
||||||
internal Vector3 HeadPosition { get; set; }
|
internal Vector3 HeadPosition;
|
||||||
internal Vector3 RightFootPosition { get; set; }
|
internal Vector3 RightFootPosition;
|
||||||
internal Vector3 LeftFootPosition { get; set; }
|
internal Vector3 LeftFootPosition;
|
||||||
|
|
||||||
internal byte WeaponTint { get; set; }
|
internal byte WeaponTint;
|
||||||
internal byte[] Clothes { get; set; }
|
internal byte[] Clothes;
|
||||||
|
|
||||||
internal float Heading { get; set; }
|
internal float Heading;
|
||||||
|
|
||||||
internal ulong LastSpeakingTime { get; set; } = 0;
|
internal ulong LastSpeakingTime { get; set; } = 0;
|
||||||
internal bool IsSpeaking { get; set; } = false;
|
internal bool IsSpeaking { get; set; } = false;
|
||||||
@ -70,9 +70,10 @@ namespace RageCoop.Client
|
|||||||
internal bool IsInCoverFacingLeft => Flags.HasPedFlag(PedDataFlags.IsInCoverFacingLeft);
|
internal bool IsInCoverFacingLeft => Flags.HasPedFlag(PedDataFlags.IsInCoverFacingLeft);
|
||||||
internal bool IsBlindFiring => Flags.HasPedFlag(PedDataFlags.IsBlindFiring);
|
internal bool IsBlindFiring => Flags.HasPedFlag(PedDataFlags.IsBlindFiring);
|
||||||
internal bool IsInStealthMode => Flags.HasPedFlag(PedDataFlags.IsInStealthMode);
|
internal bool IsInStealthMode => Flags.HasPedFlag(PedDataFlags.IsInStealthMode);
|
||||||
internal Prop ParachuteProp { get; set; } = null;
|
internal Prop ParachuteProp = null;
|
||||||
internal uint CurrentWeaponHash { get; set; }
|
internal WeaponHash CurrentWeapon = WeaponHash.Unarmed;
|
||||||
internal Dictionary<uint, bool> WeaponComponents { get; set; } = null;
|
internal VehicleWeaponHash VehicleWeapon = VehicleWeaponHash.Invalid;
|
||||||
internal Vector3 AimCoords { get; set; }
|
internal Dictionary<uint, bool> WeaponComponents = null;
|
||||||
|
internal Vector3 AimCoords;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -466,29 +466,45 @@ namespace RageCoop.Client
|
|||||||
|
|
||||||
private void CheckCurrentWeapon()
|
private void CheckCurrentWeapon()
|
||||||
{
|
{
|
||||||
if (MainPed.Weapons.Current.Hash != (WeaponHash)CurrentWeaponHash ||
|
if (MainPed.VehicleWeapon != VehicleWeapon) MainPed.VehicleWeapon = VehicleWeapon;
|
||||||
!WeaponComponents.Compare(_lastWeaponComponents) || (Speed <= 3 && _weaponObj?.IsVisible != true))
|
var compChanged = WeaponComponents != null && WeaponComponents.Count != 0 && WeaponComponents != _lastWeaponComponents && !WeaponComponents.Compare(_lastWeaponComponents);
|
||||||
|
if (_lastWeaponHash != CurrentWeapon || compChanged)
|
||||||
{
|
{
|
||||||
new WeaponAsset(CurrentWeaponHash).Request();
|
if (_lastWeaponHash == WeaponHash.Unarmed && WeaponObj?.Exists() == true)
|
||||||
|
{
|
||||||
|
WeaponObj.Delete();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var model = Function.Call<uint>(Hash.GET_WEAPONTYPE_MODEL, CurrentWeapon);
|
||||||
|
if (!Function.Call<bool>(Hash.HAS_MODEL_LOADED, model))
|
||||||
|
{
|
||||||
|
Function.Call(Hash.REQUEST_MODEL, model);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (WeaponObj?.Exists() == true)
|
||||||
|
WeaponObj.Delete();
|
||||||
MainPed.Weapons.RemoveAll();
|
MainPed.Weapons.RemoveAll();
|
||||||
_weaponObj = Entity.FromHandle(Function.Call<int>(Hash.CREATE_WEAPON_OBJECT, CurrentWeaponHash, -1,
|
WeaponObj = Entity.FromHandle(Function.Call<int>(Hash.CREATE_WEAPON_OBJECT, CurrentWeapon, -1, Position.X, Position.Y, Position.Z, true, 0, 0));
|
||||||
Position.X, Position.Y, Position.Z, true, 0, 0));
|
|
||||||
if (_weaponObj == null) return;
|
|
||||||
if (CurrentWeaponHash != (uint)WeaponHash.Unarmed)
|
|
||||||
{
|
|
||||||
if (WeaponComponents != null && WeaponComponents.Count != 0)
|
|
||||||
foreach (var comp in WeaponComponents)
|
|
||||||
if (comp.Value)
|
|
||||||
Function.Call(Hash.GIVE_WEAPON_COMPONENT_TO_WEAPON_OBJECT, _weaponObj, comp.Key);
|
|
||||||
Function.Call(Hash.GIVE_WEAPON_OBJECT_TO_PED, _weaponObj, MainPed.Handle);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (compChanged)
|
||||||
|
{
|
||||||
|
foreach (var comp in WeaponComponents)
|
||||||
|
{
|
||||||
|
if (comp.Value)
|
||||||
|
{
|
||||||
|
Function.Call(Hash.GIVE_WEAPON_COMPONENT_TO_WEAPON_OBJECT, WeaponObj.Handle, comp.Key);
|
||||||
|
}
|
||||||
|
}
|
||||||
_lastWeaponComponents = WeaponComponents;
|
_lastWeaponComponents = WeaponComponents;
|
||||||
}
|
}
|
||||||
|
Function.Call(Hash.GIVE_WEAPON_OBJECT_TO_PED, WeaponObj.Handle, MainPed.Handle);
|
||||||
|
_lastWeaponHash = CurrentWeapon;
|
||||||
|
}
|
||||||
|
|
||||||
if (Function.Call<int>(Hash.GET_PED_WEAPON_TINT_INDEX, MainPed, CurrentWeaponHash) != WeaponTint)
|
if (Function.Call<int>(Hash.GET_PED_WEAPON_TINT_INDEX, MainPed, CurrentWeapon) != WeaponTint)
|
||||||
Function.Call<int>(Hash.SET_PED_WEAPON_TINT_INDEX, MainPed, CurrentWeaponHash, WeaponTint);
|
Function.Call<int>(Hash.SET_PED_WEAPON_TINT_INDEX, MainPed, CurrentWeapon, WeaponTint);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void DisplayAiming()
|
private void DisplayAiming()
|
||||||
@ -633,6 +649,7 @@ namespace RageCoop.Client
|
|||||||
if (CurrentVehicle?.MainVehicle == null) return;
|
if (CurrentVehicle?.MainVehicle == null) return;
|
||||||
switch (Speed)
|
switch (Speed)
|
||||||
{
|
{
|
||||||
|
// In vehicle
|
||||||
case 4:
|
case 4:
|
||||||
if (MainPed.CurrentVehicle != CurrentVehicle.MainVehicle || MainPed.SeatIndex != Seat ||
|
if (MainPed.CurrentVehicle != CurrentVehicle.MainVehicle || MainPed.SeatIndex != Seat ||
|
||||||
(!MainPed.IsSittingInVehicle() && !MainPed.IsBeingJacked))
|
(!MainPed.IsSittingInVehicle() && !MainPed.IsBeingJacked))
|
||||||
@ -640,9 +657,10 @@ namespace RageCoop.Client
|
|||||||
if (MainPed.IsOnTurretSeat())
|
if (MainPed.IsOnTurretSeat())
|
||||||
Function.Call(Hash.TASK_VEHICLE_AIM_AT_COORD, MainPed.Handle, AimCoords.X, AimCoords.Y,
|
Function.Call(Hash.TASK_VEHICLE_AIM_AT_COORD, MainPed.Handle, AimCoords.X, AimCoords.Y,
|
||||||
AimCoords.Z);
|
AimCoords.Z);
|
||||||
if (MainPed.VehicleWeapon == VehicleWeaponHash.Invalid)
|
|
||||||
|
// Drive-by
|
||||||
|
if (VehicleWeapon == VehicleWeaponHash.Invalid)
|
||||||
{
|
{
|
||||||
// World.DrawMarker(MarkerType.DebugSphere,AimCoords,default,default,new Vector3(0.2f,0.2f,0.2f),Color.AliceBlue);
|
|
||||||
if (IsAiming)
|
if (IsAiming)
|
||||||
{
|
{
|
||||||
Function.Call(Hash.SET_DRIVEBY_TASK_TARGET, MainPed, 0, 0, AimCoords.X, AimCoords.Y,
|
Function.Call(Hash.SET_DRIVEBY_TASK_TARGET, MainPed, 0, 0, AimCoords.X, AimCoords.Y,
|
||||||
@ -660,31 +678,24 @@ namespace RageCoop.Client
|
|||||||
_lastDriveBy = false;
|
_lastDriveBy = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (MainPed.VehicleWeapon != (VehicleWeaponHash)CurrentWeaponHash)
|
|
||||||
{
|
|
||||||
MainPed.VehicleWeapon = (VehicleWeaponHash)CurrentWeaponHash;
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
// Entering vehicle
|
||||||
case 5:
|
case 5:
|
||||||
if (MainPed.VehicleTryingToEnter != CurrentVehicle.MainVehicle ||
|
if (MainPed.VehicleTryingToEnter != CurrentVehicle.MainVehicle ||
|
||||||
MainPed.GetSeatTryingToEnter() != Seat)
|
MainPed.GetSeatTryingToEnter() != Seat)
|
||||||
MainPed.Task.EnterVehicle(CurrentVehicle.MainVehicle, Seat, -1, 5,
|
MainPed.Task.EnterVehicle(CurrentVehicle.MainVehicle, Seat, -1, 5,
|
||||||
EnterVehicleFlags.AllowJacking);
|
EnterVehicleFlags.JackAnyone);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
// Leaving vehicle
|
||||||
case 6:
|
case 6:
|
||||||
if (!MainPed.IsTaskActive(TaskType.CTaskExitVehicle))
|
if (!MainPed.IsTaskActive(TaskType.CTaskExitVehicle))
|
||||||
MainPed.Task.LeaveVehicle(CurrentVehicle.Velocity.Length() > 5f
|
MainPed.Task.LeaveVehicle(CurrentVehicle.Velocity.LengthSquared() > 5 * 5
|
||||||
? LeaveVehicleFlags.BailOut
|
? LeaveVehicleFlags.BailOut
|
||||||
: LeaveVehicleFlags.None);
|
: LeaveVehicleFlags.None);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
Function.Call(Hash.SET_PED_STEALTH_MOVEMENT, P,true, 0);
|
|
||||||
return Function.Call<bool>(Hash.GET_PED_STEALTH_MOVEMENT, P);
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -10,13 +10,8 @@ namespace RageCoop.Client
|
|||||||
{
|
{
|
||||||
private float _accumulatedOff;
|
private float _accumulatedOff;
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// </summary>
|
|
||||||
protected internal bool _lastFrozen = false;
|
|
||||||
|
|
||||||
|
|
||||||
private int _ownerID;
|
private int _ownerID;
|
||||||
public Stopwatch LastSyncedStopWatch = new Stopwatch();
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Indicates whether the current player is responsible for syncing this entity.
|
/// Indicates whether the current player is responsible for syncing this entity.
|
||||||
@ -70,7 +65,11 @@ namespace RageCoop.Client
|
|||||||
|
|
||||||
protected Vector3 Predict(Vector3 input)
|
protected Vector3 Predict(Vector3 input)
|
||||||
{
|
{
|
||||||
return (Owner.PacketTravelTime + 0.001f * LastSyncedStopWatch.ElapsedMilliseconds) * Velocity + input;
|
return Diff() + input;
|
||||||
|
}
|
||||||
|
protected Vector3 Diff()
|
||||||
|
{
|
||||||
|
return (Owner.PacketTravelTime + 0.001f * LastSyncedStopWatch.ElapsedMilliseconds) * Velocity;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected bool IsOff(float thisOff, float tolerance = 3, float limit = 30)
|
protected bool IsOff(float thisOff, float tolerance = 3, float limit = 30)
|
||||||
@ -91,6 +90,24 @@ namespace RageCoop.Client
|
|||||||
|
|
||||||
#region LAST STATE
|
#region LAST STATE
|
||||||
|
|
||||||
|
public void SetLastSynced(bool full)
|
||||||
|
{
|
||||||
|
LastSyncInterval = LastSentStopWatch.ElapsedMilliseconds;
|
||||||
|
LastSynced = Main.Ticked;
|
||||||
|
if (full)
|
||||||
|
{
|
||||||
|
LastFullSynced = Main.Ticked;
|
||||||
|
}
|
||||||
|
LastSyncedStopWatch.Restart();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Stopwatch LastSyncedStopWatch = new Stopwatch();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The interval between last sync and the earlier one
|
||||||
|
/// </summary>
|
||||||
|
public long LastSyncInterval;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Last time a new sync message arrived.
|
/// Last time a new sync message arrived.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -61,9 +61,13 @@ namespace RageCoop.Client
|
|||||||
internal bool IsDeluxo;
|
internal bool IsDeluxo;
|
||||||
internal bool IsTrain;
|
internal bool IsTrain;
|
||||||
internal Vector3 TopExtent;
|
internal Vector3 TopExtent;
|
||||||
|
internal Vector3 BottomExtent;
|
||||||
internal Vector3 FrontExtent;
|
internal Vector3 FrontExtent;
|
||||||
|
internal Vector3 RearExtent;
|
||||||
internal Vector3 LeftExtent;
|
internal Vector3 LeftExtent;
|
||||||
internal Vector3 RightExtent;
|
internal Vector3 RightExtent;
|
||||||
|
private const float RotCalMult = 0.2f;
|
||||||
|
private const float ExtentLength = 5;
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
@ -74,9 +78,8 @@ namespace RageCoop.Client
|
|||||||
private bool _lastHornActive;
|
private bool _lastHornActive;
|
||||||
private bool _lastTransformed;
|
private bool _lastTransformed;
|
||||||
internal int _lastLivery = -1;
|
internal int _lastLivery = -1;
|
||||||
private readonly List<Vector3> _predictedTrace = new List<Vector3>();
|
|
||||||
private readonly List<Vector3> _orgTrace = new List<Vector3>();
|
|
||||||
private Vector3 _predictedPosition;
|
private Vector3 _predictedPosition;
|
||||||
|
internal Quaternion LastQuaternion;
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ namespace RageCoop.Client
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
||||||
DisplayVehicle();
|
DisplayVehicle(NeedUpdate);
|
||||||
// Skip update if no new sync message has arrived.
|
// Skip update if no new sync message has arrived.
|
||||||
if (!NeedUpdate) return;
|
if (!NeedUpdate) return;
|
||||||
|
|
||||||
@ -155,7 +155,7 @@ namespace RageCoop.Client
|
|||||||
LastUpdated = Main.Ticked;
|
LastUpdated = Main.Ticked;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void DisplayVehicle()
|
private void DisplayVehicle(bool updated)
|
||||||
{
|
{
|
||||||
_predictedPosition = Predict(Position);
|
_predictedPosition = Predict(Position);
|
||||||
var current = MainVehicle.ReadPosition();
|
var current = MainVehicle.ReadPosition();
|
||||||
@ -170,37 +170,22 @@ namespace RageCoop.Client
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Calibrate rotation
|
|
||||||
var curQuat = MainVehicle.Quaternion;
|
|
||||||
MainVehicle.ApplyForce(Quaternion * TopExtent - curQuat * TopExtent, TopExtent);
|
|
||||||
MainVehicle.ApplyForce(Quaternion * FrontExtent - curQuat * FrontExtent, FrontExtent);
|
|
||||||
|
|
||||||
// Calibrate position
|
// Calibrate position
|
||||||
if (distSquared < 0.03 * 0.03) return;
|
if (distSquared > 0.03 * 0.03)
|
||||||
|
{
|
||||||
if (IsTrain || distSquared > 20 * 20) MainVehicle.Velocity = Velocity + cali;
|
if (IsTrain || distSquared > 20 * 20) MainVehicle.Velocity = Velocity + cali;
|
||||||
else MainVehicle.ApplyForce(cali);
|
else MainVehicle.ApplyForce(cali);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Vector3 GetCalibrationRotation()
|
Quaternion predictedQuat = updated ? Quaternion :
|
||||||
{
|
Quaternion.Lerp(LastQuaternion, Quaternion, 1 + LastSyncedStopWatch.ElapsedMilliseconds / (float)LastSyncInterval);
|
||||||
var rot = Quaternion.LookRotation(Quaternion * Vector3.RelativeFront, Quaternion * Vector3.RelativeTop)
|
var curQuat = MainVehicle.Quaternion;
|
||||||
.ToEulerAngles();
|
MainVehicle.ApplyForce((predictedQuat * TopExtent - curQuat * TopExtent) * RotCalMult, TopExtent);
|
||||||
var curRot = Quaternion.LookRotation(MainVehicle.ReadQuaternion() * Vector3.RelativeFront,
|
MainVehicle.ApplyForce((predictedQuat * FrontExtent - curQuat * FrontExtent) * RotCalMult, FrontExtent);
|
||||||
MainVehicle.ReadQuaternion() * Vector3.RelativeTop).ToEulerAngles();
|
// MainVehicle.ApplyForce((predictedQuat * BottomExtent - curQuat * BottomExtent) * RotCalMult, BottomExtent);
|
||||||
|
|
||||||
var r = (rot - curRot).ToDegree();
|
|
||||||
if (r.X > 180)
|
|
||||||
r.X = r.X - 360;
|
|
||||||
else if (r.X < -180) r.X = 360 + r.X;
|
|
||||||
|
|
||||||
if (r.Y > 180)
|
|
||||||
r.Y = r.Y - 360;
|
|
||||||
else if (r.Y < -180) r.Y = 360 + r.Y;
|
|
||||||
|
|
||||||
if (r.Z > 180)
|
|
||||||
r.Z = r.Z - 360;
|
|
||||||
else if (r.Z < -180) r.Z = 360 + r.Z;
|
|
||||||
return r;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool CreateVehicle()
|
private bool CreateVehicle()
|
||||||
@ -257,11 +242,13 @@ namespace RageCoop.Client
|
|||||||
IsSubmarineCar = MainVehicle.IsSubmarineCar;
|
IsSubmarineCar = MainVehicle.IsSubmarineCar;
|
||||||
IsDeluxo = MainVehicle.Model == 1483171323;
|
IsDeluxo = MainVehicle.Model == 1483171323;
|
||||||
IsTrain = MainVehicle.IsTrain;
|
IsTrain = MainVehicle.IsTrain;
|
||||||
var (rbl, ftr) = MainVehicle.Model.Dimensions;
|
// var (rbl, ftr) = MainVehicle.Model.Dimensions;
|
||||||
FrontExtent = new Vector3(0, ftr.Y, 0);
|
FrontExtent = new Vector3(0, ExtentLength, 0);
|
||||||
TopExtent = new Vector3(0, 0, ftr.Z);
|
RearExtent = -FrontExtent;
|
||||||
LeftExtent = new Vector3(rbl.X, 0, 0);
|
TopExtent = new Vector3(0, ExtentLength, 5);
|
||||||
RightExtent = new Vector3(ftr.X, 0, 0);
|
BottomExtent = -TopExtent;
|
||||||
|
RightExtent = new Vector3(5, ExtentLength, 0);
|
||||||
|
LeftExtent = -RightExtent;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -239,8 +239,10 @@ namespace RageCoop.Client
|
|||||||
{
|
{
|
||||||
if (!p.IsValid) return;
|
if (!p.IsValid) return;
|
||||||
if (p.WeaponHash == (WeaponHash)VehicleWeaponHash.Tank)
|
if (p.WeaponHash == (WeaponHash)VehicleWeaponHash.Tank)
|
||||||
Networking.SendBullet(p.Position, p.Position + p.Velocity, (uint)VehicleWeaponHash.Tank,
|
{
|
||||||
((SyncedVehicle)p.Shooter).MainVehicle.Driver.GetSyncEntity().ID);
|
Networking.SendBullet(((SyncedVehicle)p.Shooter).MainVehicle.Driver.GetSyncEntity().ID, (uint)VehicleWeaponHash.Tank, p.Position + p.Velocity);
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (ProjectilesByID.ContainsKey(p.ID))
|
if (ProjectilesByID.ContainsKey(p.ID))
|
||||||
ProjectilesByID[p.ID] = p;
|
ProjectilesByID[p.ID] = p;
|
||||||
else
|
else
|
||||||
|
@ -25,24 +25,13 @@ namespace RageCoop.Client
|
|||||||
}, ConnectionChannel.SyncEvents, NetDeliveryMethod.ReliableOrdered);
|
}, ConnectionChannel.SyncEvents, NetDeliveryMethod.ReliableOrdered);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void TriggerBulletShot(uint hash, SyncedPed owner, Vector3 impactPosition)
|
public static void TriggerBulletShot(SyncedPed owner, Vector3 impactPosition)
|
||||||
{
|
{
|
||||||
// Main.Logger.Trace($"bullet shot:{(WeaponHash)hash}");
|
var hash = (uint)owner.MainPed.VehicleWeapon;
|
||||||
|
if (hash == (uint)VehicleWeaponHash.Invalid)
|
||||||
|
hash = (uint)owner.MainPed.Weapons.Current.Hash;
|
||||||
|
|
||||||
var start = owner.MainPed.GetMuzzlePosition();
|
Networking.SendBullet(owner.ID, hash, impactPosition);
|
||||||
if (start.DistanceTo(impactPosition) > 10)
|
|
||||||
// Reduce latency
|
|
||||||
start = impactPosition - (impactPosition - start).Normalized * 10;
|
|
||||||
Networking.SendBullet(start, impactPosition, hash, owner.ID);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void TriggerVehBulletShot(uint hash, Vehicle veh, SyncedPed owner)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
if ((i = veh.GetMuzzleIndex(owner.MainPed.VehicleWeapon)) != -1)
|
|
||||||
Networking.SendVehicleBullet(hash, owner, veh.Bones[i]);
|
|
||||||
else
|
|
||||||
Main.Logger.Warning($"Failed to get muzzle info for vehicle:{veh.DisplayName}");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void TriggerNozzleTransform(int vehID, bool hover)
|
public static void TriggerNozzleTransform(int vehID, bool hover)
|
||||||
@ -67,7 +56,7 @@ namespace RageCoop.Client
|
|||||||
var v = EntityPool.GetVehicleByID(p.ID);
|
var v = EntityPool.GetVehicleByID(p.ID);
|
||||||
if (v == null) return;
|
if (v == null) return;
|
||||||
v.OwnerID = p.NewOwnerID;
|
v.OwnerID = p.NewOwnerID;
|
||||||
v.LastSynced = Main.Ticked;
|
v.SetLastSynced(true);
|
||||||
v.Position = v.MainVehicle.Position;
|
v.Position = v.MainVehicle.Position;
|
||||||
v.Quaternion = v.MainVehicle.Quaternion;
|
v.Quaternion = v.MainVehicle.Quaternion;
|
||||||
}
|
}
|
||||||
@ -77,42 +66,38 @@ namespace RageCoop.Client
|
|||||||
EntityPool.GetVehicleByID(p.VehicleID)?.MainVehicle?.SetNozzleAngel(p.Hover ? 1 : 0);
|
EntityPool.GetVehicleByID(p.VehicleID)?.MainVehicle?.SetNozzleAngel(p.Hover ? 1 : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void HandleBulletShot(Vector3 start, Vector3 end, uint weaponHash, int ownerID)
|
private static void HandleBulletShot(int ownerID, uint weaponHash, Vector3 end)
|
||||||
{
|
{
|
||||||
var p = EntityPool.GetPedByID(ownerID)?.MainPed;
|
var c = EntityPool.GetPedByID(ownerID);
|
||||||
|
var p = c?.MainPed;
|
||||||
if (p == null)
|
if (p == null)
|
||||||
{
|
{
|
||||||
p = Game.Player.Character;
|
return;
|
||||||
Main.Logger.Warning("Failed to find owner for bullet");
|
// p = Game.Player.Character;
|
||||||
|
// Main.Logger.Warning("Failed to find owner for bullet");
|
||||||
}
|
}
|
||||||
|
|
||||||
var damage = (int)p.GetWeaponDamage(weaponHash);
|
var damage = (int)p.GetWeaponDamage(weaponHash);
|
||||||
|
|
||||||
|
// Some weapon hash has some firing issue, so we need to replace it with known good ones
|
||||||
weaponHash = WeaponUtil.GetWeaponFix(weaponHash);
|
weaponHash = WeaponUtil.GetWeaponFix(weaponHash);
|
||||||
|
|
||||||
|
// Request asset for muzzle flash
|
||||||
if (!CorePFXAsset.IsLoaded) CorePFXAsset.Request();
|
if (!CorePFXAsset.IsLoaded) CorePFXAsset.Request();
|
||||||
|
|
||||||
|
// Request asset for materialising the bullet
|
||||||
var asset = new WeaponAsset(weaponHash);
|
var asset = new WeaponAsset(weaponHash);
|
||||||
if (!asset.IsLoaded) asset.Request();
|
if (!asset.IsLoaded) asset.Request();
|
||||||
World.ShootBullet(start, end, p, asset, damage);
|
|
||||||
Prop w;
|
|
||||||
var turret = false;
|
|
||||||
if (((w = p.Weapons.CurrentWeaponObject) != null && p.VehicleWeapon == VehicleWeaponHash.Invalid) ||
|
|
||||||
(turret = p.IsOnTurretSeat()))
|
|
||||||
World.CreateParticleEffectNonLooped(CorePFXAsset,
|
|
||||||
p.Weapons.Current.Components.GetSuppressorComponent().Active
|
|
||||||
? "muz_pistol_silencer"
|
|
||||||
: ((WeaponHash)weaponHash).GetFlashFX(turret), p.GetMuzzlePosition(),
|
|
||||||
turret ? p.CurrentVehicle.GetMuzzleBone(p.VehicleWeapon).GetRotation() : w.Rotation);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void HandleVehicleBulletShot(Packets.VehicleBulletShot p)
|
bool isVeh = p.VehicleWeapon != VehicleWeaponHash.Invalid;
|
||||||
{
|
var bone = c.GetMuzzleBone(isVeh);
|
||||||
HandleBulletShot(p.StartPosition, p.EndPosition, p.WeaponHash, p.OwnerID);
|
|
||||||
var v = EntityPool.GetPedByID(p.OwnerID)?.MainPed.CurrentVehicle;
|
World.ShootBullet(bone.Position, end, p, asset, damage);
|
||||||
if (v == null) return;
|
|
||||||
var b = v.Bones[p.Bone];
|
|
||||||
World.CreateParticleEffectNonLooped(CorePFXAsset,
|
World.CreateParticleEffectNonLooped(CorePFXAsset,
|
||||||
((WeaponHash)p.WeaponHash).GetFlashFX(true),
|
!isVeh && p.Weapons.Current.Components.GetSuppressorComponent().Active
|
||||||
b.Position, b.GetRotation());
|
? "muz_pistol_silencer"
|
||||||
|
: ((WeaponHash)weaponHash).GetFlashFX(isVeh), bone.Position, isVeh ? bone.GetRotation() : bone.Owner.Rotation);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void HandleEvent(PacketType type, NetIncomingMessage msg)
|
public static void HandleEvent(PacketType type, NetIncomingMessage msg)
|
||||||
@ -122,12 +107,7 @@ namespace RageCoop.Client
|
|||||||
case PacketType.BulletShot:
|
case PacketType.BulletShot:
|
||||||
{
|
{
|
||||||
var p = msg.GetPacket<Packets.BulletShot>();
|
var p = msg.GetPacket<Packets.BulletShot>();
|
||||||
HandleBulletShot(p.StartPosition, p.EndPosition, p.WeaponHash, p.OwnerID);
|
HandleBulletShot(p.OwnerID, p.WeaponHash, p.EndPosition);
|
||||||
break;
|
|
||||||
}
|
|
||||||
case PacketType.VehicleBulletShot:
|
|
||||||
{
|
|
||||||
HandleVehicleBulletShot(msg.GetPacket<Packets.VehicleBulletShot>());
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case PacketType.OwnerChanged:
|
case PacketType.OwnerChanged:
|
||||||
@ -159,56 +139,43 @@ namespace RageCoop.Client
|
|||||||
var subject = c.MainPed;
|
var subject = c.MainPed;
|
||||||
|
|
||||||
// Check bullets
|
// Check bullets
|
||||||
if (subject.IsShooting)
|
if (subject.IsShooting && !subject.IsUsingProjectileWeapon())
|
||||||
{
|
|
||||||
if (!subject.IsUsingProjectileWeapon())
|
|
||||||
{
|
{
|
||||||
|
|
||||||
var i = 0;
|
var i = 0;
|
||||||
Func<bool> getBulletImpact = () =>
|
|
||||||
|
// Some weapon is not instant hit, so we may need to wait a few ticks to get the impact position
|
||||||
|
bool getBulletImpact()
|
||||||
{
|
{
|
||||||
var endPos = subject.LastWeaponImpactPosition;
|
var endPos = subject.LastWeaponImpactPosition;
|
||||||
if (endPos == default)
|
|
||||||
|
// Impact found
|
||||||
|
if (endPos != default)
|
||||||
{
|
{
|
||||||
|
TriggerBulletShot(c, endPos);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Not found, but it's shot from a vehicle
|
||||||
|
if (subject.VehicleWeapon != VehicleWeaponHash.Invalid)
|
||||||
|
{
|
||||||
|
var b = c.GetMuzzleBone(true);
|
||||||
|
TriggerBulletShot(c, b.Position + b.ForwardVector * 200);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get impact in next tick
|
||||||
if (++i <= 5) return false;
|
if (++i <= 5) return false;
|
||||||
|
|
||||||
|
// Exceeded maximum wait of 5 ticks, return (inaccurate) aim coordinate
|
||||||
endPos = subject.GetAimCoord();
|
endPos = subject.GetAimCoord();
|
||||||
if (subject.IsInVehicle() && subject.VehicleWeapon != VehicleWeaponHash.Invalid)
|
TriggerBulletShot(c, endPos);
|
||||||
{
|
|
||||||
if (subject.IsOnTurretSeat())
|
|
||||||
TriggerBulletShot((uint)subject.VehicleWeapon, c, endPos);
|
|
||||||
else
|
|
||||||
TriggerVehBulletShot((uint)subject.VehicleWeapon, subject.CurrentVehicle, c);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
TriggerBulletShot((uint)subject.Weapons.Current.Hash, c, endPos);
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
|
||||||
|
|
||||||
if (subject.IsInVehicle() && subject.VehicleWeapon != VehicleWeaponHash.Invalid)
|
|
||||||
{
|
|
||||||
if (subject.IsOnTurretSeat())
|
|
||||||
TriggerBulletShot((uint)subject.VehicleWeapon, c, endPos);
|
|
||||||
else
|
|
||||||
TriggerVehBulletShot((uint)subject.VehicleWeapon, subject.CurrentVehicle, c);
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
TriggerBulletShot((uint)subject.Weapons.Current.Hash, c, endPos);
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
};
|
|
||||||
|
|
||||||
if (!getBulletImpact()) API.QueueAction(getBulletImpact);
|
if (!getBulletImpact()) API.QueueAction(getBulletImpact);
|
||||||
}
|
}
|
||||||
else if (subject.VehicleWeapon == VehicleWeaponHash.Tank && subject.LastWeaponImpactPosition != default)
|
|
||||||
{
|
|
||||||
TriggerBulletShot((uint)VehicleWeaponHash.Tank, c, subject.LastWeaponImpactPosition);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void Check(SyncedVehicle v)
|
public static void Check(SyncedVehicle v)
|
||||||
|
@ -102,12 +102,11 @@ namespace RageCoop.Client
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Vector3 GetMuzzlePosition(this Ped p)
|
public static EntityBone GetMuzzleBone(this SyncedPed p, bool veh)
|
||||||
{
|
{
|
||||||
if (p.IsOnTurretSeat()) return p.CurrentVehicle.GetMuzzleBone(p.VehicleWeapon).Position;
|
if (veh) return p.MainPed.CurrentVehicle.GetMuzzleBone(p.VehicleWeapon);
|
||||||
var wb = p.Weapons?.CurrentWeaponObject?.Bones["gun_muzzle"];
|
|
||||||
if (wb?.IsValid == true) return wb.Position;
|
return p.MainPed?.Weapons.CurrentWeaponObject?.Bones["gun_muzzle"];
|
||||||
return p.Bones[Bone.SkelRightHand].Position;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static float GetWeaponDamage(this Ped P, uint hash)
|
public static float GetWeaponDamage(this Ped P, uint hash)
|
||||||
|
@ -22,6 +22,16 @@ namespace RageCoop.Core
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Vector3 Limit(this Vector3 v, float length)
|
||||||
|
{
|
||||||
|
// Avoid square root to gain more performance
|
||||||
|
if (v.LengthSquared() > length * length)
|
||||||
|
{
|
||||||
|
return v.Normalized * length;
|
||||||
|
}
|
||||||
|
return v;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static Vector3 ToVector(this Quaternion vec)
|
public static Vector3 ToVector(this Quaternion vec)
|
||||||
|
@ -44,7 +44,6 @@ namespace RageCoop.Core
|
|||||||
|
|
||||||
PedKilled = 30,
|
PedKilled = 30,
|
||||||
BulletShot = 31,
|
BulletShot = 31,
|
||||||
VehicleBulletShot = 32,
|
|
||||||
OwnerChanged = 35,
|
OwnerChanged = 35,
|
||||||
NozzleTransform = 37,
|
NozzleTransform = 37,
|
||||||
|
|
||||||
|
@ -68,7 +68,7 @@ namespace RageCoop.Core
|
|||||||
if (Flags.HasPedFlag(PedDataFlags.IsFullSync))
|
if (Flags.HasPedFlag(PedDataFlags.IsFullSync))
|
||||||
{
|
{
|
||||||
m.Write(ModelHash);
|
m.Write(ModelHash);
|
||||||
m.Write(CurrentWeaponHash);
|
m.Write((uint)CurrentWeapon);
|
||||||
m.Write(Clothes);
|
m.Write(Clothes);
|
||||||
if (WeaponComponents != null)
|
if (WeaponComponents != null)
|
||||||
{
|
{
|
||||||
@ -88,6 +88,10 @@ namespace RageCoop.Core
|
|||||||
|
|
||||||
m.Write(WeaponTint);
|
m.Write(WeaponTint);
|
||||||
|
|
||||||
|
// In vehicle
|
||||||
|
if (Speed == 4)
|
||||||
|
m.Write((uint)VehicleWeapon);
|
||||||
|
|
||||||
m.Write((byte)BlipColor);
|
m.Write((byte)BlipColor);
|
||||||
if ((byte)BlipColor != 255)
|
if ((byte)BlipColor != 255)
|
||||||
{
|
{
|
||||||
@ -142,7 +146,7 @@ namespace RageCoop.Core
|
|||||||
ModelHash = m.ReadInt32();
|
ModelHash = m.ReadInt32();
|
||||||
|
|
||||||
// Read player weapon hash
|
// Read player weapon hash
|
||||||
CurrentWeaponHash = m.ReadUInt32();
|
CurrentWeapon = (WeaponHash)m.ReadUInt32();
|
||||||
|
|
||||||
// Read player clothes
|
// Read player clothes
|
||||||
Clothes = m.ReadBytes(36);
|
Clothes = m.ReadBytes(36);
|
||||||
@ -157,6 +161,9 @@ namespace RageCoop.Core
|
|||||||
|
|
||||||
WeaponTint = m.ReadByte();
|
WeaponTint = m.ReadByte();
|
||||||
|
|
||||||
|
if (Speed == 4)
|
||||||
|
VehicleWeapon = (VehicleWeaponHash)m.ReadUInt32();
|
||||||
|
|
||||||
BlipColor = (BlipColor)m.ReadByte();
|
BlipColor = (BlipColor)m.ReadByte();
|
||||||
|
|
||||||
if ((byte)BlipColor != 255)
|
if ((byte)BlipColor != 255)
|
||||||
@ -181,7 +188,9 @@ namespace RageCoop.Core
|
|||||||
|
|
||||||
public int ModelHash { get; set; }
|
public int ModelHash { get; set; }
|
||||||
|
|
||||||
public uint CurrentWeaponHash { get; set; }
|
public WeaponHash CurrentWeapon { get; set; }
|
||||||
|
|
||||||
|
public VehicleWeaponHash VehicleWeapon { get; set; }
|
||||||
|
|
||||||
public byte[] Clothes { get; set; }
|
public byte[] Clothes { get; set; }
|
||||||
|
|
||||||
|
@ -12,7 +12,6 @@ namespace RageCoop.Core
|
|||||||
|
|
||||||
public uint WeaponHash { get; set; }
|
public uint WeaponHash { get; set; }
|
||||||
|
|
||||||
public Vector3 StartPosition { get; set; }
|
|
||||||
public Vector3 EndPosition { get; set; }
|
public Vector3 EndPosition { get; set; }
|
||||||
|
|
||||||
protected override void Serialize(NetOutgoingMessage m)
|
protected override void Serialize(NetOutgoingMessage m)
|
||||||
@ -23,9 +22,6 @@ namespace RageCoop.Core
|
|||||||
// Write weapon hash
|
// Write weapon hash
|
||||||
m.Write(WeaponHash);
|
m.Write(WeaponHash);
|
||||||
|
|
||||||
// Write StartPosition
|
|
||||||
m.Write(StartPosition);
|
|
||||||
|
|
||||||
// Write EndPosition
|
// Write EndPosition
|
||||||
m.Write(EndPosition);
|
m.Write(EndPosition);
|
||||||
}
|
}
|
||||||
@ -37,12 +33,9 @@ namespace RageCoop.Core
|
|||||||
// Read OwnerID
|
// Read OwnerID
|
||||||
OwnerID = m.ReadInt32();
|
OwnerID = m.ReadInt32();
|
||||||
|
|
||||||
// Read WeponHash
|
// Read WeaponHash
|
||||||
WeaponHash = m.ReadUInt32();
|
WeaponHash = m.ReadUInt32();
|
||||||
|
|
||||||
// Read StartPosition
|
|
||||||
StartPosition = m.ReadVector3();
|
|
||||||
|
|
||||||
// Read EndPosition
|
// Read EndPosition
|
||||||
EndPosition = m.ReadVector3();
|
EndPosition = m.ReadVector3();
|
||||||
|
|
||||||
|
@ -1,41 +0,0 @@
|
|||||||
using GTA.Math;
|
|
||||||
using Lidgren.Network;
|
|
||||||
|
|
||||||
namespace RageCoop.Core
|
|
||||||
{
|
|
||||||
internal partial class Packets
|
|
||||||
{
|
|
||||||
internal class VehicleBulletShot : Packet
|
|
||||||
{
|
|
||||||
public override PacketType Type => PacketType.VehicleBulletShot;
|
|
||||||
public int OwnerID { get; set; }
|
|
||||||
public ushort Bone { get; set; }
|
|
||||||
public uint WeaponHash { get; set; }
|
|
||||||
|
|
||||||
public Vector3 StartPosition { get; set; }
|
|
||||||
public Vector3 EndPosition { get; set; }
|
|
||||||
|
|
||||||
protected override void Serialize(NetOutgoingMessage m)
|
|
||||||
{
|
|
||||||
m.Write(OwnerID);
|
|
||||||
m.Write(Bone);
|
|
||||||
m.Write(WeaponHash);
|
|
||||||
m.Write(StartPosition);
|
|
||||||
m.Write(EndPosition);
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void Deserialize(NetIncomingMessage m)
|
|
||||||
{
|
|
||||||
#region NetIncomingMessageToPacket
|
|
||||||
|
|
||||||
OwnerID = m.ReadInt32();
|
|
||||||
Bone = m.ReadUInt16();
|
|
||||||
WeaponHash = m.ReadUInt32();
|
|
||||||
StartPosition = m.ReadVector3();
|
|
||||||
EndPosition = m.ReadVector3();
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,4 +1,7 @@
|
|||||||
using System.Reflection;
|
|
||||||
|
using System.Reflection;
|
||||||
|
using System.Runtime.CompilerServices;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
using System.Resources;
|
using System.Resources;
|
||||||
|
|
||||||
// General Information
|
// General Information
|
||||||
@ -12,6 +15,7 @@ using System.Resources;
|
|||||||
[assembly: AssemblyCulture("")]
|
[assembly: AssemblyCulture("")]
|
||||||
|
|
||||||
// Version information
|
// Version information
|
||||||
[assembly: AssemblyVersion("1.6.0.21")]
|
[assembly: AssemblyVersion("1.6.0.24")]
|
||||||
[assembly: AssemblyFileVersion("1.6.0.21")]
|
[assembly: AssemblyFileVersion("1.6.0.24")]
|
||||||
[assembly: NeutralResourcesLanguageAttribute( "en-US" )]
|
[assembly: NeutralResourcesLanguageAttribute( "en-US" )]
|
||||||
|
|
||||||
|
Binary file not shown.
BIN
libs/ScriptHookVDotNet.pdb
Normal file
BIN
libs/ScriptHookVDotNet.pdb
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user