Added rhino turret sync, added DevTool

This commit is contained in:
Sardelka 2022-05-26 17:11:37 +08:00
parent f1182dc557
commit f9d28bb5c0
7 changed files with 97 additions and 36 deletions

View File

@ -0,0 +1,51 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using GTA;
using GTA.Math;
using System.Drawing;
using System.Windows.Forms;
namespace RageCoop.Client
{
internal class DevTool:Script
{
public static Entity ToMark;
public static int Current = 0;
public DevTool()
{
Tick+=OnTick;
KeyUp+=OnKeyUp;
}
private void OnKeyUp(object sender, KeyEventArgs e)
{
switch (e.KeyCode)
{
case Keys.Right:
Current++;
DebugMenu.boneIndexItem.AltTitle= Current.ToString();
break;
case Keys.Left:
Current--;
DebugMenu.boneIndexItem.AltTitle= Current.ToString();
break;
}
}
private void OnTick(object sender, EventArgs e)
{
if(ToMark == null || !ToMark.Exists()){ return;}
if ((Current< 0)||(Current>ToMark.Bones.Count-1)) {
Current=0;
DebugMenu.boneIndexItem.AltTitle= Current.ToString();
}
var bone = ToMark.Bones[Current];
World.DrawLine(bone.Position, bone.Position+2*bone.ForwardVector, Color.Blue);
World.DrawLine(bone.Position, bone.Position+2*bone.UpVector, Color.Green);
World.DrawLine(bone.Position, bone.Position+2*bone.RightVector, Color.Yellow);
}
}
}

View File

@ -21,6 +21,8 @@ namespace RageCoop.Client
Alignment = Main.Settings.FlipMenu ? GTA.UI.Alignment.Right : GTA.UI.Alignment.Left
};
private static NativeItem d1=new NativeItem("PositionPrediction");
private static NativeCheckboxItem devToolItem=new NativeCheckboxItem("DevTool");
public static NativeItem boneIndexItem = new NativeItem("Current bone index");
static DebugMenu()
{
d1.Activated+=(sender,e) =>
@ -29,9 +31,12 @@ namespace RageCoop.Client
catch { }
Update();
};
devToolItem.Activated+=DevToolItem_Activated;
devToolItem.Checked=false;
MainMenu.Add(d1);
MainMenu.Add(devToolItem);
MainMenu.Add(boneIndexItem);
MainMenu.AddSubMenu(DiagnosticMenu);
MainMenu.Opening+=(sender, e) =>Update();
DiagnosticMenu.Opening+=(sender, e) =>
@ -46,6 +51,19 @@ namespace RageCoop.Client
Update();
}
private static void DevToolItem_Activated(object sender, EventArgs e)
{
if (devToolItem.Checked)
{
DevTool.ToMark=Game.Player.Character.CurrentVehicle;
}
else
{
DevTool.ToMark=null;
}
}
private static void Update()
{
d1.AltTitle = SyncParameters.PositioinPrediction.ToString();

View File

@ -437,6 +437,11 @@ namespace RageCoop.Client
public static Vector3 GetAimCoord(this Ped p)
{
var weapon = p.Weapons.CurrentWeaponObject;
// Rhino
if (p.CurrentVehicle.Model.Hash==782665360)
{
return p.CurrentVehicle.Bones[35].Position+p.CurrentVehicle.Bones[35].ForwardVector*100;
}
if (p.IsOnTurretSeat()) { return p.GetLookingCoord(); }
if (weapon!=null)
{
@ -444,18 +449,6 @@ namespace RageCoop.Client
Vector3 dir = weapon.RightVector;
return weapon.Position+dir*20;
/*
RaycastResult result = World.Raycast(weapon.Position+dir, weapon.Position+dir*10000, IntersectFlags.Everything, p.IsInVehicle() ? (Entity)p : p.CurrentVehicle);
if (result.DidHit)
{
return result.HitPosition;
}
else
{
return weapon.Position+dir*20;
}
*/
}
return GetLookingCoord(p);
}

View File

@ -121,6 +121,7 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="DevTools\DevTool.cs" />
<Compile Include="Networking\Chat.cs" />
<Compile Include="COOPAPI.cs" />
<Compile Include="Debug.cs" />

View File

@ -19,10 +19,22 @@ namespace RageCoop.Client
var shooter = EntityPool.GetPedByHandle(p.Owner.Handle);
if(shooter != null)
{
Main.Logger.Warning($"Could not find owner for projectile, owner handle:{}");
ShooterID=shooter.ID;
}
else
{
// Owner will be the vehicle if projectile is shot with a vehicle
var shooterVeh = EntityPool.GetVehicleByHandle(p.Owner.Handle);
if (shooterVeh!=null && shooterVeh.MainVehicle.Driver!=null)
{
ShooterID=shooterVeh.MainVehicle.Driver.GetSyncEntity().ID;
}
else
{
Main.Logger.Warning($"Could not find owner for projectile, owner handle:{p.Owner.Handle}");
}
}
}
public SyncedProjectile(int id)
{

View File

@ -320,7 +320,7 @@ namespace RageCoop.Client
/// Prevent projectiles from exploding next to vehicle
if (Util.VehicleProjectileWeapons.Contains((VehicleWeaponHash)p.MainProjectile.WeaponHash))
{
if (p.Origin.DistanceTo(p.MainProjectile.Position)<2)
if (p.MainProjectile.WeaponHash!=(WeaponHash)VehicleWeaponHash.Tank && p.Origin.DistanceTo(p.MainProjectile.Position)<2)
{
continue;
}

View File

@ -96,7 +96,7 @@ namespace RageCoop.Client {
#region HANDLE
public static void HandleLeaveVehicle(Packets.LeaveVehicle p)
private static void HandleLeaveVehicle(Packets.LeaveVehicle p)
{
var ped = EntityPool.GetPedByID(p.ID)?.MainPed;
var flag = LeaveVehicleFlags.None;
@ -105,15 +105,15 @@ namespace RageCoop.Client {
if (ped.CurrentVehicle.Speed>5) { flag|=LeaveVehicleFlags.BailOut;}
ped.Task.LeaveVehicle(flag) ;
}
public static void HandlePedKilled(Packets.PedKilled p)
private static void HandlePedKilled(Packets.PedKilled p)
{
EntityPool.GetPedByID(p.VictimID)?.MainPed?.Kill();
}
public static void HandleEnteringVehicle(SyncedPed c, SyncedVehicle veh, VehicleSeat seat)
private static void HandleEnteringVehicle(SyncedPed c, SyncedVehicle veh, VehicleSeat seat)
{
c.MainPed?.Task.EnterVehicle(veh.MainVehicle, seat,-1,2,EnterVehicleFlags.WarpToDoor|EnterVehicleFlags.AllowJacking);
}
public static void HandleEnteredVehicle(int pedId, int vehId, VehicleSeat seat)
private static void HandleEnteredVehicle(int pedId, int vehId, VehicleSeat seat)
{
var v = EntityPool.GetVehicleByID(vehId);
var p = EntityPool.GetPedByID(pedId)?.MainPed;
@ -127,7 +127,7 @@ namespace RageCoop.Client {
}
p.SetIntoVehicle(v.MainVehicle, seat);
}
public static void HandleOwnerChanged(Packets.OwnerChanged p)
private static void HandleOwnerChanged(Packets.OwnerChanged p)
{
var v = EntityPool.GetVehicleByID(p.ID);
if (v==null) { return; }
@ -141,7 +141,7 @@ namespace RageCoop.Client {
static WeaponAsset _weaponAsset = default;
static uint _lastWeaponHash;
public static void HandleBulletShot(Vector3 start, Vector3 end, uint weaponHash, int ownerID)
private static void HandleBulletShot(Vector3 start, Vector3 end, uint weaponHash, int ownerID)
{
if (CorePFXAsset==default) {
CorePFXAsset= new ParticleEffectAsset("core");
@ -170,7 +170,6 @@ namespace RageCoop.Client {
}
}
public static void HandleEvent(PacketTypes type,byte[] data)
{
switch (type)
@ -221,7 +220,6 @@ namespace RageCoop.Client {
}
}
}
public static int GetWeaponDamage(this Ped p)
{
if (p.VehicleWeapon!=VehicleWeaponHash.Invalid)
@ -243,19 +241,7 @@ namespace RageCoop.Client {
#endregion
/*
public static List<WeaponHash> ProjectileWeapons = new List<WeaponHash>
{
WeaponHash.RPG,
WeaponHash.Grenade,
WeaponHash.GrenadeLauncher,
WeaponHash.Ball,
WeaponHash.Bottle,
WeaponHash.BZGas,
WeaponHash.Firework,
};
*/
#region CHECK EVENTS