From eb7c68244307e45e99bb855a5cfc76757c679993 Mon Sep 17 00:00:00 2001 From: JJ Date: Mon, 24 Nov 2025 15:25:14 -0500 Subject: [PATCH] Update 0.01 F --- Lithium/MainWindow.xaml.cs | 3 +- Lithium/RecoilEngine.cs | 63 ++++++++++++++++++++------------------ 2 files changed, 36 insertions(+), 30 deletions(-) diff --git a/Lithium/MainWindow.xaml.cs b/Lithium/MainWindow.xaml.cs index 6988a66..21a4796 100644 --- a/Lithium/MainWindow.xaml.cs +++ b/Lithium/MainWindow.xaml.cs @@ -52,7 +52,8 @@ namespace Lithium t.Start(); } - private void RecoilLoop() => RecoilEngine.Start(); + private void RecoilLoop() => RecoilEngine.Start(this); + private void HotkeyLoop() => HotkeyHandler.Start(this); diff --git a/Lithium/RecoilEngine.cs b/Lithium/RecoilEngine.cs index 688a57c..1074bf8 100644 --- a/Lithium/RecoilEngine.cs +++ b/Lithium/RecoilEngine.cs @@ -1,4 +1,5 @@ -using System; +using Lithium; +using System; using System.Threading; namespace Lua @@ -15,11 +16,11 @@ namespace Lua private static double _remainderX, _remainderY; private static double _jitterMultiplierX, _jitterMultiplierY; - public static void Start() + public static void Start(MainWindow window) { while (true) { - if (Utils.IsCapsLockOn() && Utils.IsPressed(VK_RBUTTON)) + if (window.IsRecoilEnabled && Utils.IsPressed(VK_LBUTTON) && Utils.IsPressed(VK_RBUTTON)) { HandleRecoilTick(); } @@ -28,10 +29,14 @@ namespace Lua _remainderX = _remainderY = 0; _jitterActive = false; } + + Thread.Sleep(2); } } + + private static void HandleRecoilTick() { if (!Utils.IsPressed(VK_LBUTTON)) return; @@ -48,48 +53,47 @@ namespace Lua private static void HandleJitter(int now) { - if (ConfigLoader.jitterEnabled) + if (!ConfigLoader.jitterEnabled) return; + + if (!_jitterActive && now - _lastJitterEnd >= ConfigLoader.jitterCooldown) { - if (!_jitterActive && now - _lastJitterEnd >= ConfigLoader.jitterCooldown) - { - _jitterActive = true; - _jitterStart = now; + _jitterActive = true; + _jitterStart = now; - double strength = 0.1 + _rng.NextDouble() * 0.8; - _jitterMultiplierX = _jitterMultiplierY = 0; + // Set small random jitter multipliers + _jitterMultiplierX = (_rng.NextDouble() - 0.5) * 0.2; // ±0.1 + _jitterMultiplierY = (_rng.NextDouble() - 0.5) * 0.2; + } - switch (_rng.Next(1, 5)) - { - case 1: _jitterMultiplierX = -strength; break; - case 2: _jitterMultiplierX = strength; break; - case 3: _jitterMultiplierY = -strength; break; - case 4: _jitterMultiplierY = strength; break; - } - } - - if (_jitterActive && now - _jitterStart >= ConfigLoader.jitterBurstTime) - { - _jitterActive = false; - _lastJitterEnd = now; - _jitterMultiplierX = _jitterMultiplierY = 0; - } + if (_jitterActive && now - _jitterStart >= ConfigLoader.jitterBurstTime) + { + _jitterActive = false; + _lastJitterEnd = now; + _jitterMultiplierX = _jitterMultiplierY = 0; } } private static void ApplyRecoil((double recoilX, double recoilY) recoil) { - double jitterX = recoil.recoilX * _jitterMultiplierX; - double jitterY = recoil.recoilY * _jitterMultiplierY; + // Apply base recoil first + double moveX = recoil.recoilX; + double moveY = recoil.recoilY; - double moveX = recoil.recoilX + _remainderX + jitterX; - double moveY = recoil.recoilY + _remainderY + jitterY; + // Apply optional multiplier for jitter + moveX += recoil.recoilX * _jitterMultiplierX; + moveY += recoil.recoilY * _jitterMultiplierY; + // Apply any global scaling if (ConfigLoader.debitFlag1) { moveX *= 1.282; moveY *= 1.351; } + // Add remainder for precision + moveX += _remainderX; + moveY += _remainderY; + int ix = (int)Math.Round(moveX); int iy = (int)Math.Round(moveY); @@ -98,5 +102,6 @@ namespace Lua Utils.MoveMouse(ix, iy); } + } } \ No newline at end of file