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
This commit is contained in:
Sardelka
2022-08-15 18:25:43 +08:00
parent aa6c45b20d
commit 7a4e4182b5
3 changed files with 61 additions and 7 deletions

View File

@ -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);

View File

@ -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;

View File

@ -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<bool>(Hash.GET_PED_STEALTH_MOVEMENT, P);
*/