Auto reload waits for trigger release and paces shell reloads
This commit is contained in:
1 parent
2f41fa01c8
commit
35fc5dc2a4
2 files changed
+19
-2
No files matched your search
+18
-1
@@ -248,6 +248,7 @@ internal static class CheckFireInputPatch
|
|||||||
private const float ReleaseTime = 0.15f;
|
private const float ReleaseTime = 0.15f;
|
||||||
private const float AutoReloadDelay = 0.2f;
|
private const float AutoReloadDelay = 0.2f;
|
||||||
private const float AutoReloadNextDelay = 0.05f;
|
private const float AutoReloadNextDelay = 0.05f;
|
||||||
|
private const float AutoReloadRoundTime = 0.9f;
|
||||||
|
|
||||||
private static readonly Dictionary<string, string> Guns = new()
|
private static readonly Dictionary<string, string> Guns = new()
|
||||||
{
|
{
|
||||||
@@ -286,6 +287,8 @@ internal static class CheckFireInputPatch
|
|||||||
private static float _nextReloadTry;
|
private static float _nextReloadTry;
|
||||||
private static bool _autoReloading;
|
private static bool _autoReloading;
|
||||||
private static IntPtr _autoReloadGun = IntPtr.Zero;
|
private static IntPtr _autoReloadGun = IntPtr.Zero;
|
||||||
|
private static float _lastReloadCall = -10f;
|
||||||
|
private static bool _sawReloading;
|
||||||
private static bool _loggedHook;
|
private static bool _loggedHook;
|
||||||
|
|
||||||
internal static bool HoldingGun => _lastGunTime >= 0f && Time.time - _lastGunTime < 0.25f;
|
internal static bool HoldingGun => _lastGunTime >= 0f && Time.time - _lastGunTime < 0.25f;
|
||||||
@@ -359,6 +362,7 @@ internal static class CheckFireInputPatch
|
|||||||
|
|
||||||
if (controller._isReloading || controller.IsReloading() || controller.IsReloadQueued())
|
if (controller._isReloading || controller.IsReloading() || controller.IsReloadQueued())
|
||||||
{
|
{
|
||||||
|
_sawReloading = true;
|
||||||
_emptySince = -1f;
|
_emptySince = -1f;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -371,9 +375,16 @@ internal static class CheckFireInputPatch
|
|||||||
if (ammo == null)
|
if (ammo == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (_autoReloading && (_autoReloadGun != controller.Pointer || ammo.IsFull() || FirePressed()))
|
if (_autoReloading && (_autoReloadGun != controller.Pointer || ammo.IsFull()))
|
||||||
_autoReloading = false;
|
_autoReloading = false;
|
||||||
|
|
||||||
|
if (FirePressed())
|
||||||
|
{
|
||||||
|
_autoReloading = false;
|
||||||
|
_emptySince = -1f;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!ammo.IsEmpty() && !_autoReloading)
|
if (!ammo.IsEmpty() && !_autoReloading)
|
||||||
{
|
{
|
||||||
_emptySince = -1f;
|
_emptySince = -1f;
|
||||||
@@ -391,6 +402,10 @@ internal static class CheckFireInputPatch
|
|||||||
if (now - _emptySince < wait || now < _nextReloadTry)
|
if (now - _emptySince < wait || now < _nextReloadTry)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
var roundTime = FullAuto.FastReload ? AutoReloadRoundTime / FullAuto.ReloadMultiplier : AutoReloadRoundTime;
|
||||||
|
if (_autoReloading && !_sawReloading && now - _lastReloadCall < roundTime)
|
||||||
|
return;
|
||||||
|
|
||||||
_nextReloadTry = now + 0.3f;
|
_nextReloadTry = now + 0.3f;
|
||||||
|
|
||||||
if (!controller.CanReload())
|
if (!controller.CanReload())
|
||||||
@@ -402,6 +417,8 @@ internal static class CheckFireInputPatch
|
|||||||
controller.Reload();
|
controller.Reload();
|
||||||
_autoReloading = true;
|
_autoReloading = true;
|
||||||
_autoReloadGun = controller.Pointer;
|
_autoReloadGun = controller.Pointer;
|
||||||
|
_lastReloadCall = now;
|
||||||
|
_sawReloading = false;
|
||||||
|
|
||||||
if (FullAuto.Verbose)
|
if (FullAuto.Verbose)
|
||||||
RLog.Msg($"FullAuto auto reload {controller.GetIl2CppType().Name}, ammo {ammo.GetRemainingAmmo()}/{ammo.GetCapacity()}");
|
RLog.Msg($"FullAuto auto reload {controller.GetIl2CppType().Name}, ammo {ammo.GetRemainingAmmo()}/{ammo.GetCapacity()}");
|
||||||
|
|||||||
+1
-1
@@ -3,7 +3,7 @@
|
|||||||
"id": "FullAuto",
|
"id": "FullAuto",
|
||||||
"name": "FullAuto",
|
"name": "FullAuto",
|
||||||
"author": "JustinOros",
|
"author": "JustinOros",
|
||||||
"version": "1.5.1",
|
"version": "1.5.2",
|
||||||
"description": "Full-auto, semi-auto and 3-round burst for guns, with fast reload and a flashlight toggle",
|
"description": "Full-auto, semi-auto and 3-round burst for guns, with fast reload and a flashlight toggle",
|
||||||
"gameVersion": "1.0.0",
|
"gameVersion": "1.0.0",
|
||||||
"platform": "Client",
|
"platform": "Client",
|
||||||
|
|||||||
Reference in new issue
Block a user