Fixed: flare gun not working properly, menu bug

This commit is contained in:
sausage 2022-05-25 21:54:25 +08:00
parent b1277584fd
commit fd30a899c1
8 changed files with 97 additions and 24 deletions

View File

@ -178,15 +178,18 @@ namespace RageCoop.Client
MainChat.OnKeyDown(e.KeyCode);
return;
}
if (Game.IsControlPressed(GTA.Control.FrontendPause))
if (Networking.IsOnServer)
{
Function.Call(Hash.ACTIVATE_FRONTEND_MENU, Function.Call<int>(Hash.GET_HASH_KEY, "FE_MENU_VERSION_SP_PAUSE"), false, 0);
return;
}
if (Game.IsControlPressed(GTA.Control.FrontendPauseAlternate)&&Settings.DisableAlternatePause)
{
Function.Call(Hash.ACTIVATE_FRONTEND_MENU, Function.Call<int>(Hash.GET_HASH_KEY, "FE_MENU_VERSION_SP_PAUSE"), false, 0);
return;
if (Game.IsControlPressed(GTA.Control.FrontendPause))
{
Function.Call(Hash.ACTIVATE_FRONTEND_MENU, Function.Call<int>(Hash.GET_HASH_KEY, "FE_MENU_VERSION_SP_PAUSE"), false, 0);
return;
}
if (Game.IsControlPressed(GTA.Control.FrontendPauseAlternate)&&Settings.DisableAlternatePause)
{
Function.Call(Hash.ACTIVATE_FRONTEND_MENU, Function.Call<int>(Hash.GET_HASH_KEY, "FE_MENU_VERSION_SP_PAUSE"), false, 0);
return;
}
}
if (e.KeyCode == Settings.MenuKey)
{

View File

@ -97,8 +97,6 @@ namespace RageCoop.Client.Menus
{
MainMenu.Items[2].Enabled = true;
MainMenu.Items[2].Title = "Disconnect";
SubSettings.MainMenu.Items[1].Enabled = !Main.Settings.DisableTraffic && Main.NPCsAllowed;
MainMenu.Visible = false;
}

View File

@ -25,6 +25,7 @@ namespace RageCoop.Client.Menus.Sub
private static NativeItem _menuKey = new NativeItem("Menu Key","The key to open menu", Main.Settings.MenuKey.ToString());
private static NativeItem _passengerKey = new NativeItem("Passenger Key", "The key to enter a vehicle as passenger", Main.Settings.PassengerKey.ToString());
private static NativeItem _vehicleSoftLimit = new NativeItem("Vehicle limit (soft)", "The game won't spawn more NPC traffic if the limit is exceeded. \n-1 for unlimited (not recommended).",Main.Settings.WorldVehicleSoftLimit.ToString());
/// <summary>
/// Don't use it!
@ -40,6 +41,7 @@ namespace RageCoop.Client.Menus.Sub
_showNetworkInfoItem.CheckboxChanged += ShowNetworkInfoCheckboxChanged;
_menuKey.Activated+=ChaneMenuKey;
_passengerKey.Activated+=ChangePassengerKey;
_vehicleSoftLimit.Activated+=vehicleSoftLimit_Activated;
MainMenu.Add(_disableTrafficItem);
MainMenu.Add(_disablePauseAlt);
@ -47,14 +49,28 @@ namespace RageCoop.Client.Menus.Sub
MainMenu.Add(_showNetworkInfoItem);
MainMenu.Add(_menuKey);
MainMenu.Add(_passengerKey);
MainMenu.Add(_vehicleSoftLimit);
}
private void _disablePauseAlt_CheckboxChanged(object sender, EventArgs e)
{
Main.Settings.DisableAlternatePause=_disablePauseAlt.Checked;
Util.SaveSettings();
}
private void vehicleSoftLimit_Activated(object sender, EventArgs e)
{
try
{
Main.Settings.WorldVehicleSoftLimit =int.Parse(
Game.GetUserInput(WindowTitle.EnterMessage20,
Main.Settings.WorldVehicleSoftLimit.ToString(), 20));
_menuKey.AltTitle=Main.Settings.WorldVehicleSoftLimit.ToString();
Util.SaveSettings();
}
catch { }
}
private void ChaneMenuKey(object sender, EventArgs e)
{
try

View File

@ -903,7 +903,8 @@ namespace RageCoop.Client
WeaponHash.UpNAtomizer,
WeaponHash.GrenadeLauncher,
WeaponHash.GrenadeLauncherSmoke,
WeaponHash.CompactGrenadeLauncher
WeaponHash.CompactGrenadeLauncher,
WeaponHash.FlareGun,
};
/*
public static readonly Dictionary<WeaponHash, ExplosionType> WeaponExplosionTypes = new Dictionary<WeaponHash, ExplosionType> {

View File

@ -50,6 +50,11 @@ namespace RageCoop.Client
/// </summary>
public bool DisableAlternatePause { get; set; } = true;
/// <summary>
/// The game won't spawn more NPC traffic if the limit is exceeded. -1 for unlimited (not recommended).
/// </summary>
public int WorldVehicleSoftLimit { get; set; } = 35;
}
}

View File

@ -496,6 +496,11 @@ namespace RageCoop.Client
if (IsReloading)
{
if (!MainPed.IsTaskActive(TaskType.CTaskReloadGun))
{
MainPed.Task.ReloadWeapon();
}
/*
if (!_isPlayingAnimation)
{
string[] reloadingAnim = MainPed.GetReloadingAnimation();
@ -506,6 +511,7 @@ namespace RageCoop.Client
MainPed.Task.PlayAnimation(_currentAnimation[0], _currentAnimation[1], 8f, -1, AnimationFlags.AllowRotation | AnimationFlags.UpperBodyOnly);
}
}
*/
SmoothTransition();
}
else if (_currentAnimation[1] == "reload_aim")
@ -563,6 +569,7 @@ namespace RageCoop.Client
}
#region WEAPON
WeaponHash appliedWeaponhash = WeaponHash.Unarmed;
private void CheckCurrentWeapon()
{
if (MainPed.Weapons.Current.Hash != (WeaponHash)CurrentWeaponHash || !WeaponComponents.Compare(_lastWeaponComponents))
@ -593,7 +600,6 @@ namespace RageCoop.Client
}
}
private void DisplayAiming()
{
if (Velocity==default)

View File

@ -14,7 +14,11 @@ namespace RageCoop.Client
ID=EntityPool.RequestNewID();
IsMine=true;
MainProjectile = p;
ShooterID=p.Owner.GetSyncEntity().ID;
var shooter = p.Owner.GetSyncEntity();
if(shooter != null)
{
ShooterID=shooter.ID;
}
}
public SyncedProjectile(int id)
{

View File

@ -1,4 +1,5 @@
using System;

using System;
using GTA;
using GTA.Native;
using RageCoop.Core;
@ -16,7 +17,10 @@ namespace RageCoop.Client
public static object PedsLock = new object();
private static Dictionary<int, SyncedPed> ID_Peds = new Dictionary<int, SyncedPed>();
public static int CharactersCount { get { return ID_Peds.Count; } }
#if BENCHMARK
private static Stopwatch PerfCounter=new Stopwatch();
private static Stopwatch PerfCounter2=Stopwatch.StartNew();
#endif
/// <summary>
/// Faster access to Character with Handle, but values may not equal to <see cref="ID_Peds"/> since Ped might not have been created.
/// </summary>
@ -54,6 +58,8 @@ namespace RageCoop.Client
ID_Projectiles.Clear();
Handle_Projectiles.Clear();
}
#region PEDS
public static SyncedPed GetPedByID(int id)
{
return ID_Peds.ContainsKey(id) ? ID_Peds[id] : null;
@ -140,6 +146,7 @@ namespace RageCoop.Client
Main.Logger.Debug($"Removing ped {c.ID}. Reason:{reason}");
p.AttachedBlip?.Delete();
p.Kill();
p.MarkAsNoLongerNeeded();
p.Delete();
}
c.PedBlip?.Delete();
@ -147,8 +154,9 @@ namespace RageCoop.Client
ID_Peds.Remove(id);
}
}
#endregion
#region VEHICLES
public static SyncedVehicle GetVehicleByID(int id)
{
return ID_Vehicles.ContainsKey(id) ? ID_Vehicles[id] : null;
@ -195,13 +203,16 @@ namespace RageCoop.Client
}
Main.Logger.Debug($"Removing vehicle {v.ID}. Reason:{reason}");
veh.AttachedBlip?.Delete();
veh.MarkAsNoLongerNeeded();
veh.Delete();
}
ID_Vehicles.Remove(id);
}
}
#endregion
#region PROJECTILES
public static SyncedProjectile GetProjectileByID(int id)
{
return ID_Projectiles.ContainsKey(id) ? ID_Projectiles[id] : null;
@ -257,16 +268,26 @@ namespace RageCoop.Client
{
return ID_Projectiles.ContainsKey(id);
}
#endregion
public static void DoSync()
{
#if BENCHMARK
PerfCounter.Restart();
Debug.TimeStamps[TimeStamp.CheckProjectiles]=PerfCounter.ElapsedTicks;
#endif
var allPeds = World.GetAllPeds();
var allVehicles=World.GetAllVehicles();
var allProjectiles=World.GetAllProjectiles();
if (Main.Settings.WorldVehicleSoftLimit>-1)
{
if (Main.Ticked%100==0) { if (allVehicles.Length>Main.Settings.WorldVehicleSoftLimit) { SetBudget(0); } else { SetBudget(1); } }
}
#if BENCHMARK
if (Main.Ticked%100==0) { if (allVehicles.Length>50) { SetBudget(0); } else { SetBudget(1); } }
Debug.TimeStamps[TimeStamp.GetAllEntities]=PerfCounter.ElapsedTicks;
#endif
lock (ProjectilesLock)
{
@ -306,6 +327,8 @@ namespace RageCoop.Client
}
}
lock (PedsLock)
{
EntityPool.AddPlayer();
@ -323,8 +346,10 @@ namespace RageCoop.Client
}
}
Debug.TimeStamps[TimeStamp.AddPeds]=PerfCounter.ElapsedTicks;
#if BENCHMARK
Debug.TimeStamps[TimeStamp.AddPeds]=PerfCounter.ElapsedTicks;
#endif
foreach (SyncedPed c in ID_Peds.Values.ToArray())
{
@ -337,7 +362,9 @@ namespace RageCoop.Client
// Outgoing sync
if (c.IsMine)
{
#if BENCHMARK
var start = PerfCounter2.ElapsedTicks;
#endif
// event check
SyncEvents.Check(c);
@ -349,20 +376,31 @@ namespace RageCoop.Client
{
Networking.SendPed(c);
}
#if BENCHMARK
Debug.TimeStamps[TimeStamp.SendPed]=PerfCounter2.ElapsedTicks-start;
#endif
}
else // Incoming sync
{
#if BENCHMARK
var start = PerfCounter2.ElapsedTicks;
#endif
c.Update();
if (c.IsOutOfSync)
{
RemovePed(c.ID, "OutOfSync");
}
#if BENCHMARK
Debug.TimeStamps[TimeStamp.UpdatePed]=PerfCounter2.ElapsedTicks-start;
#endif
}
}
Debug.TimeStamps[TimeStamp.PedTotal]=PerfCounter.ElapsedTicks;
#if BENCHMARK
Debug.TimeStamps[TimeStamp.PedTotal]=PerfCounter.ElapsedTicks;
#endif
}
lock (VehiclesLock)
{
@ -378,8 +416,10 @@ namespace RageCoop.Client
}
}
Debug.TimeStamps[TimeStamp.AddVehicles]=PerfCounter.ElapsedTicks;
#if BENCHMARK
Debug.TimeStamps[TimeStamp.AddVehicles]=PerfCounter.ElapsedTicks;
#endif
foreach (SyncedVehicle v in ID_Vehicles.Values.ToArray())
{
if ((v.MainVehicle!=null)&&(!v.MainVehicle.Exists()))
@ -415,9 +455,9 @@ namespace RageCoop.Client
}
}
#if BENCHMARK
Debug.TimeStamps[TimeStamp.VehicleTotal]=PerfCounter.ElapsedTicks;
#endif
}