Vehicle projectile weapon is now synchronized!
This commit is contained in:
parent
92a59ec8e4
commit
d6a230cd5a
@ -489,8 +489,16 @@ namespace RageCoop.Client
|
||||
|
||||
public static bool IsUsingProjectileWeapon(this Ped p)
|
||||
{
|
||||
var w = p.Weapons.Current;
|
||||
return w.Group==WeaponGroup.Thrown||ProjectileWeapons.Contains(w.Hash);
|
||||
var vp = p.VehicleWeapon;
|
||||
if (vp!=VehicleWeaponHash.Invalid)
|
||||
{
|
||||
return VehicleProjectileWeapons.Contains(vp);
|
||||
}
|
||||
else
|
||||
{
|
||||
var w = p.Weapons.Current;
|
||||
return w.Group==WeaponGroup.Thrown || ProjectileWeapons.Contains(w.Hash);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
@ -906,24 +914,11 @@ namespace RageCoop.Client
|
||||
WeaponHash.CompactGrenadeLauncher,
|
||||
WeaponHash.FlareGun,
|
||||
};
|
||||
/*
|
||||
public static readonly Dictionary<WeaponHash, ExplosionType> WeaponExplosionTypes = new Dictionary<WeaponHash, ExplosionType> {
|
||||
{ WeaponHash.Grenade,ExplosionType.Grenade},
|
||||
{ WeaponHash.GrenadeLauncher,ExplosionType.Grenade},
|
||||
{ WeaponHash.CompactGrenadeLauncher,ExplosionType.Grenade},
|
||||
{ WeaponHash.SmokeGrenade,ExplosionType.SmokeG},
|
||||
{ WeaponHash.GrenadeLauncherSmoke,ExplosionType.SmokeG},
|
||||
{ WeaponHash.StickyBomb,ExplosionType.StickyBomb},
|
||||
{ WeaponHash.Flare,ExplosionType.Flare},
|
||||
{ WeaponHash.FlareGun,ExplosionType.Flare},
|
||||
{ WeaponHash.Molotov,ExplosionType.Molotov1},
|
||||
{ WeaponHash.BZGas,ExplosionType.BZGas},
|
||||
{ WeaponHash.PipeBomb,ExplosionType.PipeBomb},
|
||||
{ WeaponHash.ProximityMine,ExplosionType.ProxMine},
|
||||
{ WeaponHash.Firework,ExplosionType.FireWork},
|
||||
{ WeaponHash.RPG,ExplosionType.Rocket},
|
||||
public static readonly HashSet<VehicleWeaponHash> VehicleProjectileWeapons = new HashSet<VehicleWeaponHash> {
|
||||
VehicleWeaponHash.PlaneRocket,
|
||||
VehicleWeaponHash.SpaceRocket,
|
||||
VehicleWeaponHash.Tank,
|
||||
};
|
||||
*/
|
||||
}
|
||||
/// <summary>
|
||||
///
|
||||
|
@ -4,6 +4,7 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using GTA;
|
||||
using GTA.Math;
|
||||
|
||||
namespace RageCoop.Client
|
||||
{
|
||||
@ -14,11 +15,14 @@ namespace RageCoop.Client
|
||||
ID=EntityPool.RequestNewID();
|
||||
IsMine=true;
|
||||
MainProjectile = p;
|
||||
var shooter = p.Owner.GetSyncEntity();
|
||||
Origin=p.Position;
|
||||
var shooter = EntityPool.GetPedByHandle(p.Owner.Handle);
|
||||
if(shooter != null)
|
||||
{
|
||||
Main.Logger.Warning($"Could not find owner for projectile, owner handle:{}");
|
||||
ShooterID=shooter.ID;
|
||||
}
|
||||
|
||||
}
|
||||
public SyncedProjectile(int id)
|
||||
{
|
||||
@ -30,6 +34,8 @@ namespace RageCoop.Client
|
||||
public Projectile MainProjectile { get; set; }
|
||||
public int ShooterID { get; set; }
|
||||
|
||||
public Vector3 Origin { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Invalid property for projectile.
|
||||
/// </summary>
|
||||
|
@ -55,6 +55,13 @@ namespace RageCoop.Client
|
||||
ID_Vehicles.Clear();
|
||||
Handle_Vehicles.Clear();
|
||||
|
||||
foreach(var p in ID_Projectiles.Values)
|
||||
{
|
||||
if (p.ShooterID!=Main.LocalPlayerID && p.MainProjectile!=null && p.MainProjectile.Exists())
|
||||
{
|
||||
p.MainProjectile.Delete();
|
||||
}
|
||||
}
|
||||
ID_Projectiles.Clear();
|
||||
Handle_Projectiles.Clear();
|
||||
}
|
||||
@ -288,6 +295,7 @@ namespace RageCoop.Client
|
||||
|
||||
Debug.TimeStamps[TimeStamp.GetAllEntities]=PerfCounter.ElapsedTicks;
|
||||
#endif
|
||||
|
||||
lock (ProjectilesLock)
|
||||
{
|
||||
|
||||
@ -296,7 +304,7 @@ namespace RageCoop.Client
|
||||
if (!Handle_Projectiles.ContainsKey(p.Handle))
|
||||
{
|
||||
Add(new SyncedProjectile(p));
|
||||
Main.Logger.Debug($"Projectile shot: {p.Handle}");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -308,6 +316,16 @@ namespace RageCoop.Client
|
||||
{
|
||||
if (p.MainProjectile.AttachedEntity==null)
|
||||
{
|
||||
|
||||
/// Prevent projectiles from exploding next to vehicle
|
||||
if (Util.VehicleProjectileWeapons.Contains((VehicleWeaponHash)p.MainProjectile.WeaponHash))
|
||||
{
|
||||
if (p.Origin.DistanceTo(p.MainProjectile.Position)<2)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
Networking.SendProjectile(p);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user