From 45f487c9f4fdbe07a4d8c31bcfe10ff76db5ffbb Mon Sep 17 00:00:00 2001 From: Sardelka Date: Fri, 17 Jun 2022 11:08:49 +0800 Subject: [PATCH] Better weapon damage reproduction --- .../Sync/Entities/SyncedProjectile.cs | 3 +- RageCoop.Client/Sync/SyncEvents.cs | 23 +-------------- RageCoop.Client/Util/WeaponUtil.cs | 28 +++++++++++++++++++ 3 files changed, 30 insertions(+), 24 deletions(-) diff --git a/RageCoop.Client/Sync/Entities/SyncedProjectile.cs b/RageCoop.Client/Sync/Entities/SyncedProjectile.cs index 2ebecfd..d211a0a 100644 --- a/RageCoop.Client/Sync/Entities/SyncedProjectile.cs +++ b/RageCoop.Client/Sync/Entities/SyncedProjectile.cs @@ -70,8 +70,7 @@ namespace RageCoop.Client CreateProjectile(); return; } - MainProjectile.Position=Position; - MainProjectile.Velocity=Velocity; + MainProjectile.Velocity=Velocity+(Position+Networking.Latency*Velocity-MainProjectile.Position); MainProjectile.Rotation=Rotation; LastUpdated=Main.Ticked; } diff --git a/RageCoop.Client/Sync/SyncEvents.cs b/RageCoop.Client/Sync/SyncEvents.cs index 6f3f6e4..ea46032 100644 --- a/RageCoop.Client/Sync/SyncEvents.cs +++ b/RageCoop.Client/Sync/SyncEvents.cs @@ -189,7 +189,7 @@ namespace RageCoop.Client { _lastWeaponHash=weaponHash; } if (!_weaponAsset.IsLoaded) { _weaponAsset.Request(); } - World.ShootBullet(start, end, p, _weaponAsset, p.GetWeaponDamage(weaponHash)); + World.ShootBullet(start, end, p, _weaponAsset, (int)p.GetWeaponDamage(weaponHash)); Prop w; if(((w = p.Weapons.CurrentWeaponObject) != null)&&(p.VehicleWeapon==VehicleWeaponHash.Invalid)) { @@ -268,27 +268,6 @@ namespace RageCoop.Client { } } } - public static int GetWeaponDamage(this Ped p,uint hash) - { - if(p.IsInVehicle() && (hash!=(uint)p.Weapons.Current.Hash)) - { - // This is a vehicle weapon - p.VehicleWeapon=(VehicleWeaponHash)hash; - return 100; - } - switch (p.Weapons.Current.Group) - { - case WeaponGroup.Pistol: return 30; - case WeaponGroup.AssaultRifle: return 30; - case WeaponGroup.SMG: return 20; - case WeaponGroup.MG: return 40; - case WeaponGroup.Shotgun: return 30; - case WeaponGroup.Sniper: return 200; - case WeaponGroup.Heavy: return 30; - } - return 0; - } - #endregion diff --git a/RageCoop.Client/Util/WeaponUtil.cs b/RageCoop.Client/Util/WeaponUtil.cs index a6accd9..2187d67 100644 --- a/RageCoop.Client/Util/WeaponUtil.cs +++ b/RageCoop.Client/Util/WeaponUtil.cs @@ -4,6 +4,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using GTA; +using GTA.Native; using GTA.Math; namespace RageCoop.Client @@ -32,6 +33,33 @@ namespace RageCoop.Client return p.Bones[Bone.SkelRightHand].Position; } static long BulletsShot=0; + + public static float GetWeaponDamage(this Ped P, uint hash) + { + var comp = P.Weapons.Current.Components.GetSuppressorComponent(); + return Function.Call(Hash.GET_WEAPON_DAMAGE, hash, comp.Active ? comp.ComponentHash : WeaponComponentHash.Invalid); + + /* + if (P.IsInVehicle() && (hash!=(uint)P.Weapons.Current.Hash)) + { + // This is a vehicle weapon + P.VehicleWeapon=(VehicleWeaponHash)hash; + return 100; + } + switch (P.Weapons.Current.Group) + { + case WeaponGroup.Pistol: return 30; + case WeaponGroup.AssaultRifle: return 30; + case WeaponGroup.SMG: return 20; + case WeaponGroup.MG: return 40; + case WeaponGroup.Shotgun: return 30; + case WeaponGroup.Sniper: return 200; + case WeaponGroup.Heavy: return 30; + } + return 0; + */ + } + public static MuzzleInfo GetMuzzleInfo(this Vehicle v) { BulletsShot++;