Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
13bebcea8d | ||
|
|
1457284cd5 | ||
|
|
3cf60a89b5 | ||
|
|
bca9b113c9 | ||
|
|
0d333b2367 | ||
|
|
3ab0c52260 | ||
|
|
2a495fbf29 | ||
|
|
b9aa1d92e9 | ||
|
|
0bdd0e65e8 | ||
|
|
10d6f82d0d | ||
|
|
c42b6ac94d | ||
|
|
3381c89f12 |
No files matched your search
+185
-11
@@ -24,10 +24,13 @@ public class FullAuto : SonsMod
|
|||||||
{
|
{
|
||||||
internal const float MinRpm = 60f;
|
internal const float MinRpm = 60f;
|
||||||
internal const float MaxRpm = 3000f;
|
internal const float MaxRpm = 3000f;
|
||||||
|
internal const float ReloadMultiplier = 2f;
|
||||||
|
|
||||||
internal static bool Enabled = true;
|
internal static bool Enabled = true;
|
||||||
internal static float Rpm = 900f;
|
internal static float Rpm = 900f;
|
||||||
internal static FireMode Mode = FireMode.Auto;
|
internal static FireMode Mode = FireMode.Auto;
|
||||||
|
internal static bool FastReload;
|
||||||
|
internal static KeyCode FlashlightKey = KeyCode.F;
|
||||||
internal static bool Verbose;
|
internal static bool Verbose;
|
||||||
|
|
||||||
private static string _configPath;
|
private static string _configPath;
|
||||||
@@ -42,14 +45,21 @@ public class FullAuto : SonsMod
|
|||||||
{
|
{
|
||||||
_configPath = Path.Combine(LoaderEnvironment.UserDataDirectory, "FullAuto.txt");
|
_configPath = Path.Combine(LoaderEnvironment.UserDataDirectory, "FullAuto.txt");
|
||||||
Load();
|
Load();
|
||||||
RLog.Msg($"FullAuto loaded. RPM: {Rpm}. Guns only. Middle mouse cycles modes. Console: fullauto");
|
Save();
|
||||||
|
RLog.Msg($"FullAuto loaded. RPM: {Rpm}. Fast reload: {FastReload}. Flashlight key: {FlashlightKey}. Guns only. Middle mouse cycles modes. Console: fullauto");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnUpdate()
|
private void OnUpdate()
|
||||||
{
|
{
|
||||||
CheckFireInputPatch.UpdateTrigger();
|
CheckFireInputPatch.UpdateTrigger();
|
||||||
|
|
||||||
if (!Enabled || !GameState.IsPlayerControllable || !CheckFireInputPatch.HoldingGun)
|
if (!CheckFireInputPatch.HoldingGun)
|
||||||
|
CheckFireInputPatch.RestoreReloadSpeed();
|
||||||
|
|
||||||
|
if (Input.GetKeyDown(FlashlightKey) && CheckFireInputPatch.InGame && CheckFireInputPatch.HoldingRanged)
|
||||||
|
CheckFireInputPatch.ToggleFlashlight();
|
||||||
|
|
||||||
|
if (!Enabled || !CheckFireInputPatch.InGame || !CheckFireInputPatch.HoldingGun)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (Input.GetMouseButtonDown(2))
|
if (Input.GetMouseButtonDown(2))
|
||||||
@@ -85,14 +95,25 @@ public class FullAuto : SonsMod
|
|||||||
case "off":
|
case "off":
|
||||||
Enabled = false;
|
Enabled = false;
|
||||||
break;
|
break;
|
||||||
case "toggle":
|
|
||||||
Enabled = !Enabled;
|
|
||||||
break;
|
|
||||||
case "debug":
|
case "debug":
|
||||||
Verbose = !Verbose;
|
Verbose = !Verbose;
|
||||||
SonsTools.ShowMessage($"FullAuto debug: {Verbose}");
|
SonsTools.ShowMessage($"FullAuto debug: {Verbose}");
|
||||||
RLog.Msg($"FullAuto debug: {Verbose}");
|
RLog.Msg($"FullAuto debug: {Verbose}");
|
||||||
return;
|
return;
|
||||||
|
case "fastreload":
|
||||||
|
if (parts.Length > 1 && (parts[1].ToLowerInvariant() == "on" || parts[1].ToLowerInvariant() == "off"))
|
||||||
|
{
|
||||||
|
FastReload = parts[1].ToLowerInvariant() == "on";
|
||||||
|
if (!FastReload)
|
||||||
|
CheckFireInputPatch.RestoreReloadSpeed();
|
||||||
|
Save();
|
||||||
|
var text = $"Fast reload {(FastReload ? "ON" : "OFF")}";
|
||||||
|
SonsTools.ShowMessage(text);
|
||||||
|
RLog.Msg(text);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Usage();
|
||||||
|
return;
|
||||||
case "rpm":
|
case "rpm":
|
||||||
if (parts.Length > 1 && float.TryParse(parts[1], out var value))
|
if (parts.Length > 1 && float.TryParse(parts[1], out var value))
|
||||||
{
|
{
|
||||||
@@ -113,7 +134,7 @@ public class FullAuto : SonsMod
|
|||||||
|
|
||||||
private static void Usage()
|
private static void Usage()
|
||||||
{
|
{
|
||||||
var text = $"Usage: fullauto [on|off|toggle|debug] or fullauto rpm <{MinRpm}-{MaxRpm}>";
|
var text = $"Usage: fullauto [on|off|debug], fullauto rpm <{MinRpm}-{MaxRpm}>, fullauto fastreload on|off";
|
||||||
SonsTools.ShowMessage(text, 5f);
|
SonsTools.ShowMessage(text, 5f);
|
||||||
RLog.Msg(text);
|
RLog.Msg(text);
|
||||||
}
|
}
|
||||||
@@ -135,7 +156,8 @@ public class FullAuto : SonsMod
|
|||||||
|
|
||||||
internal static void Announce()
|
internal static void Announce()
|
||||||
{
|
{
|
||||||
var text = Enabled ? $"{ModeName()} ({Rpm} RPM)" : "FullAuto OFF";
|
var reload = FastReload ? ", fast reload on" : "";
|
||||||
|
var text = Enabled ? $"{ModeName()} ({Rpm} RPM{reload})" : $"FullAuto OFF{reload}";
|
||||||
SonsTools.ShowMessage(text);
|
SonsTools.ShowMessage(text);
|
||||||
RLog.Msg(text);
|
RLog.Msg(text);
|
||||||
}
|
}
|
||||||
@@ -158,6 +180,10 @@ public class FullAuto : SonsMod
|
|||||||
|
|
||||||
if (key == "rpm" && float.TryParse(val, out var rpm))
|
if (key == "rpm" && float.TryParse(val, out var rpm))
|
||||||
Rpm = Mathf.Clamp(rpm, MinRpm, MaxRpm);
|
Rpm = Mathf.Clamp(rpm, MinRpm, MaxRpm);
|
||||||
|
else if (key == "fastreload" && bool.TryParse(val, out var fast))
|
||||||
|
FastReload = fast;
|
||||||
|
else if (key == "flashlightkey" && Enum.TryParse<KeyCode>(val, true, out var flashKey))
|
||||||
|
FlashlightKey = flashKey;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
@@ -170,7 +196,7 @@ public class FullAuto : SonsMod
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
File.WriteAllText(_configPath, $"rpm={Rpm}\n");
|
File.WriteAllText(_configPath, $"rpm={Rpm}\nfastreload={FastReload.ToString().ToLowerInvariant()}\nflashlightkey={FlashlightKey}\n");
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
@@ -205,16 +231,151 @@ internal static class CheckFireInputPatch
|
|||||||
private static float _releasedFor;
|
private static float _releasedFor;
|
||||||
private static bool _actionFailed;
|
private static bool _actionFailed;
|
||||||
private static bool _holding;
|
private static bool _holding;
|
||||||
|
private static RangedWeaponController _speedGun;
|
||||||
|
private static Animator _speedPlayer;
|
||||||
|
private static Animator _speedWeapon;
|
||||||
|
private static float _playerSpeed = 1f;
|
||||||
|
private static float _weaponSpeed = 1f;
|
||||||
|
private static RangedWeaponController _currentRanged;
|
||||||
|
private static float _rangedTime = -1f;
|
||||||
|
private static bool _flashlightOff;
|
||||||
|
private static IntPtr _lightsOwner = IntPtr.Zero;
|
||||||
|
private static readonly List<Light> Lights = new();
|
||||||
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;
|
||||||
|
|
||||||
|
internal static bool InGame => GameState.IsPlayerControllable && !Cursor.visible && !LocalPlayer.IsInInventory && Time.timeScale > 0f;
|
||||||
|
|
||||||
|
internal static bool HoldingRanged => _currentRanged != null && _rangedTime >= 0f && Time.time - _rangedTime < 0.25f;
|
||||||
|
|
||||||
|
private static void FindLights(RangedWeaponController controller)
|
||||||
|
{
|
||||||
|
Lights.Clear();
|
||||||
|
_lightsOwner = controller.Pointer;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
foreach (var light in controller.GetComponentsInChildren<Light>(true))
|
||||||
|
{
|
||||||
|
if (light && light.type == LightType.Spot)
|
||||||
|
Lights.Add(light);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (FullAuto.Verbose)
|
||||||
|
{
|
||||||
|
foreach (var light in Lights)
|
||||||
|
RLog.Msg($"FullAuto flashlight found: {light.gameObject.name}");
|
||||||
|
if (Lights.Count == 0)
|
||||||
|
RLog.Msg($"FullAuto no flashlight found on {controller.GetIl2CppType().Name}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
RLog.Warning($"FullAuto could not find flashlight: {e.Message}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal static void ToggleFlashlight()
|
||||||
|
{
|
||||||
|
var controller = _currentRanged;
|
||||||
|
if (!controller)
|
||||||
|
return;
|
||||||
|
|
||||||
|
FindLights(controller);
|
||||||
|
|
||||||
|
if (Lights.Count == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
_flashlightOff = !_flashlightOff;
|
||||||
|
ApplyFlashlight();
|
||||||
|
|
||||||
|
if (FullAuto.Verbose)
|
||||||
|
RLog.Msg($"FullAuto flashlight {(_flashlightOff ? "off" : "on")}");
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void ApplyFlashlight()
|
||||||
|
{
|
||||||
|
foreach (var light in Lights)
|
||||||
|
{
|
||||||
|
if (light && light.enabled == _flashlightOff)
|
||||||
|
light.enabled = !_flashlightOff;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
internal static void CancelBurst()
|
internal static void CancelBurst()
|
||||||
{
|
{
|
||||||
_burstLeft = 0;
|
_burstLeft = 0;
|
||||||
_holding = false;
|
_holding = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void UpdateReloadSpeed(RangedWeaponController controller, bool allowed)
|
||||||
|
{
|
||||||
|
var want = allowed && FullAuto.FastReload && (controller._isReloading || controller.IsReloading());
|
||||||
|
|
||||||
|
if (!want)
|
||||||
|
{
|
||||||
|
RestoreReloadSpeed();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_speedGun != null && _speedGun.Pointer == controller.Pointer)
|
||||||
|
return;
|
||||||
|
|
||||||
|
RestoreReloadSpeed();
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_speedGun = controller;
|
||||||
|
_speedPlayer = controller._playerAnimator;
|
||||||
|
_speedWeapon = controller._weaponAnimator;
|
||||||
|
|
||||||
|
if (_speedPlayer)
|
||||||
|
{
|
||||||
|
_playerSpeed = _speedPlayer.speed;
|
||||||
|
_speedPlayer.speed = _playerSpeed * FullAuto.ReloadMultiplier;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_speedWeapon)
|
||||||
|
{
|
||||||
|
_weaponSpeed = _speedWeapon.speed;
|
||||||
|
_speedWeapon.speed = _weaponSpeed * FullAuto.ReloadMultiplier;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (FullAuto.Verbose)
|
||||||
|
RLog.Msg($"FullAuto fast reload start, player {_playerSpeed} weapon {_weaponSpeed}");
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
RLog.Warning($"FullAuto could not speed up reload: {e.Message}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal static void RestoreReloadSpeed()
|
||||||
|
{
|
||||||
|
if (_speedGun == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (_speedPlayer)
|
||||||
|
_speedPlayer.speed = _playerSpeed;
|
||||||
|
if (_speedWeapon)
|
||||||
|
_speedWeapon.speed = _weaponSpeed;
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
RLog.Warning($"FullAuto could not restore reload speed: {e.Message}");
|
||||||
|
}
|
||||||
|
|
||||||
|
_speedGun = null;
|
||||||
|
_speedPlayer = null;
|
||||||
|
_speedWeapon = null;
|
||||||
|
|
||||||
|
if (FullAuto.Verbose)
|
||||||
|
RLog.Msg("FullAuto fast reload end");
|
||||||
|
}
|
||||||
|
|
||||||
private static void HoldAfterBurst(RangedWeaponController controller)
|
private static void HoldAfterBurst(RangedWeaponController controller)
|
||||||
{
|
{
|
||||||
var first = !_holding;
|
var first = !_holding;
|
||||||
@@ -297,7 +458,7 @@ internal static class CheckFireInputPatch
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
_triggerDown = true;
|
_triggerDown = true;
|
||||||
if (FullAuto.Enabled && FullAuto.Mode == FireMode.Burst && HoldingGun && GameState.IsPlayerControllable)
|
if (FullAuto.Enabled && FullAuto.Mode == FireMode.Burst && HoldingGun && InGame)
|
||||||
StartBurst();
|
StartBurst();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -338,6 +499,18 @@ internal static class CheckFireInputPatch
|
|||||||
var allowed = IsAllowed(__instance);
|
var allowed = IsAllowed(__instance);
|
||||||
var ptr = __instance.Pointer;
|
var ptr = __instance.Pointer;
|
||||||
|
|
||||||
|
_currentRanged = __instance;
|
||||||
|
_rangedTime = Time.time;
|
||||||
|
|
||||||
|
if (_flashlightOff)
|
||||||
|
{
|
||||||
|
if (_lightsOwner != ptr)
|
||||||
|
FindLights(__instance);
|
||||||
|
ApplyFlashlight();
|
||||||
|
}
|
||||||
|
|
||||||
|
UpdateReloadSpeed(__instance, allowed);
|
||||||
|
|
||||||
if (allowed && FullAuto.Enabled && (!HoldingGun || ptr != _lastGunPtr))
|
if (allowed && FullAuto.Enabled && (!HoldingGun || ptr != _lastGunPtr))
|
||||||
FullAuto.ShowMode();
|
FullAuto.ShowMode();
|
||||||
|
|
||||||
@@ -354,7 +527,7 @@ internal static class CheckFireInputPatch
|
|||||||
var pressed = FirePressed();
|
var pressed = FirePressed();
|
||||||
var held = _triggerDown || pressed;
|
var held = _triggerDown || pressed;
|
||||||
|
|
||||||
if (!GameState.IsPlayerControllable)
|
if (!InGame)
|
||||||
{
|
{
|
||||||
_burstLeft = 0;
|
_burstLeft = 0;
|
||||||
return !held;
|
return !held;
|
||||||
@@ -462,4 +635,5 @@ internal static class CheckFireInputPatch
|
|||||||
RLog.Msg($"FullAuto {name}: {(allowed ? "full-auto" : "ignored")}");
|
RLog.Msg($"FullAuto {name}: {(allowed ? "full-auto" : "ignored")}");
|
||||||
return allowed;
|
return allowed;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -89,16 +89,5 @@ behavior.
|
|||||||
|
|
||||||
## Building from source
|
## Building from source
|
||||||
|
|
||||||
Requires the .NET 8 SDK and RedLoader installed with its game assemblies
|
|
||||||
generated.
|
|
||||||
|
|
||||||
```powershell
|
|
||||||
.\build.ps1 -Install
|
|
||||||
```
|
|
||||||
|
|
||||||
Use `-Package` to build `FullAuto.zip` for a release. Pass `-GameDir "path"` if
|
|
||||||
the game is not found automatically.
|
|
||||||
|
|
||||||
## Troubleshooting
|
|
||||||
|
|
||||||
Check `_RedLoader\Latest.log` in your game folder. FullAuto logs a line when it
|
|
||||||
+2
-2
@@ -3,8 +3,8 @@
|
|||||||
"id": "FullAuto",
|
"id": "FullAuto",
|
||||||
"name": "FullAuto",
|
"name": "FullAuto",
|
||||||
"author": "JustinOros",
|
"author": "JustinOros",
|
||||||
"version": "1.1.0",
|
"version": "1.4.0",
|
||||||
"description": "Hold fire to shoot any gun full-auto at a configurable rate",
|
"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",
|
||||||
"type": "Mod"
|
"type": "Mod"
|
||||||
|
|||||||
Reference in new issue
Block a user