From 7a4e4182b5eae03e7173e2c8122f11dc7ca7b671 Mon Sep 17 00:00:00 2001 From: Sardelka Date: Mon, 15 Aug 2022 18:25:43 +0800 Subject: [PATCH] Add drive-by weapon display This still have some issues: ped not aiming consistently sometimes not working at all doesn't work for throwable weapons --- RageCoop.Client/Main.cs | 29 +++++++++++++-- RageCoop.Client/Networking/Send.cs | 3 +- .../Sync/Entities/Ped/SyncedPed.cs | 36 +++++++++++++++++-- 3 files changed, 61 insertions(+), 7 deletions(-) diff --git a/RageCoop.Client/Main.cs b/RageCoop.Client/Main.cs index 2480e09..d2b35c6 100644 --- a/RageCoop.Client/Main.cs +++ b/RageCoop.Client/Main.cs @@ -110,6 +110,21 @@ namespace RageCoop.Client private bool _lastDead; private void OnTick(object sender, EventArgs e) { + P= Game.Player.Character; + PlayerPosition=P.ReadPosition(); + FPS=Game.FPS; + /* + try + { + P.CurrentVehicle.Passengers[0].Delete(); + } + catch { } + var p = P.CurrentVehicle.CreateRandomPedOnSeat(VehicleSeat.Passenger); + p.Weapons.Current.InfiniteAmmoClip = true; + p.Weapons.Give(WeaponHash.MicroSMG, 100, true, true); + // Function.Call(Hash.SET_DRIVEBY_TASK_TARGET, p, 0, 0, 0f, 0f, 0f); + Function.Call(Hash.TASK_DRIVE_BY, p, 0, 0, 0f, 0f, 0f, 0, 0, 1, unchecked((int)FiringPattern.FullAuto)); + */ if (Game.IsLoading) { return; @@ -125,9 +140,6 @@ namespace RageCoop.Client CoopMenu.MenuPool.Process(); #endif - P= Game.Player.Character; - PlayerPosition=P.ReadPosition(); - FPS=Game.FPS; DoQueuedActions(); if (!Networking.IsOnServer) @@ -184,11 +196,22 @@ namespace RageCoop.Client { Scripting.API.Events.InvokePlayerDied(); } + _lastDead=P.IsDead; Ticked++; } + float p1; + float p2; private void OnKeyDown(object sender, KeyEventArgs e) { + if (e.KeyCode==Keys.Right) + { + p1+=0.05f; + } + if (e.KeyCode==Keys.Up) + { + p2+=0.05f; + } if (MainChat.Focused) { MainChat.OnKeyDown(e.KeyCode); diff --git a/RageCoop.Client/Networking/Send.cs b/RageCoop.Client/Networking/Send.cs index 4f27adc..f207f70 100644 --- a/RageCoop.Client/Networking/Send.cs +++ b/RageCoop.Client/Networking/Send.cs @@ -78,7 +78,8 @@ namespace RageCoop.Client sp.LastSentStopWatch.Restart(); if (full) { - p.CurrentWeaponHash = p.Speed>=4 ? (uint)ped.VehicleWeapon : (uint)ped.Weapons.Current.Hash; + var w = ped.VehicleWeapon; + p.CurrentWeaponHash = (w!=VehicleWeaponHash.Invalid)? (uint)w:(uint)ped.Weapons.Current.Hash; p.Flags |= PedDataFlags.IsFullSync; p.Clothes=ped.GetPedClothes(); p.ModelHash=ped.Model.Hash; diff --git a/RageCoop.Client/Sync/Entities/Ped/SyncedPed.cs b/RageCoop.Client/Sync/Entities/Ped/SyncedPed.cs index ef68414..7e73819 100644 --- a/RageCoop.Client/Sync/Entities/Ped/SyncedPed.cs +++ b/RageCoop.Client/Sync/Entities/Ped/SyncedPed.cs @@ -345,7 +345,6 @@ namespace RageCoop.Client private void DisplayOnFoot() { - MainPed.Task.ClearAll(); CheckCurrentWeapon(); if (IsInParachuteFreeFall) { @@ -632,6 +631,7 @@ namespace RageCoop.Client private bool LastMoving; private void WalkTo() { + MainPed.Task.ClearAll(); Function.Call(Hash.SET_PED_STEALTH_MOVEMENT, MainPed, IsInStealthMode, 0); Vector3 predictPosition = Position + (Position - MainPed.ReadPosition()) + Velocity * 0.5f; float range = predictPosition.DistanceToSquared(MainPed.ReadPosition()); @@ -753,7 +753,38 @@ namespace RageCoop.Client // Function.Call(Hash.SET_VEHICLE_TURRET_SPEED_THIS_FRAME, MainPed.CurrentVehicle, 100); Function.Call(Hash.TASK_VEHICLE_AIM_AT_COORD, MainPed.Handle, AimCoords.X, AimCoords.Y, AimCoords.Z); } - if (MainPed.VehicleWeapon!=(VehicleWeaponHash)CurrentWeaponHash) + if (MainPed.VehicleWeapon==VehicleWeaponHash.Invalid) + { + // World.DrawMarker(MarkerType.DebugSphere,AimCoords,default,default,new Vector3(0.2f,0.2f,0.2f),Color.AliceBlue); + CheckCurrentWeapon(); + if (IsAiming) + { + if (MainPed.IsTaskActive(TaskType.CTaskAimGunVehicleDriveBy)) + { + + Function.Call(Hash.SET_DRIVEBY_TASK_TARGET, MainPed , 0, 0, AimCoords.X, AimCoords.Y, AimCoords.Z); + } + else + { + Function.Call(Hash.SET_PED_INFINITE_AMMO_CLIP, MainPed, true); + /* + Main.QueueAction(() => + { + if (!IsAiming) { return true; } + Function.Call(Hash.SET_PED_AMMO, MainPed, CurrentWeaponHash, 0); + return false; + }); + */ + Function.Call(Hash.TASK_DRIVE_BY, MainPed, 0, 0, AimCoords.X, AimCoords.Y, AimCoords.Z, 1, 100, 1,FiringPattern.SingleShot); + } + } + else if (MainPed.IsTaskActive(TaskType.CTaskAimGunVehicleDriveBy)) + { + MainPed.Task.ClearAll(); + } + + } + else if (MainPed.VehicleWeapon!=(VehicleWeaponHash)CurrentWeaponHash) { MainPed.VehicleWeapon=(VehicleWeaponHash)CurrentWeaponHash; } @@ -775,7 +806,6 @@ namespace RageCoop.Client /* - Function.Call(Hash.TASK_SWEEP_AIM_ENTITY,P, "random@paparazzi@pap_anims", "sweep_low", "sweep_med", "sweep_high", -1,V, 1.57f, 0.25f); Function.Call(Hash.SET_PED_STEALTH_MOVEMENT, P,true, 0); return Function.Call(Hash.GET_PED_STEALTH_MOVEMENT, P); */