Skip to content

Commit

Permalink
v2.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
TaylorIsBlue committed Oct 5, 2024
1 parent 16ad8ba commit 6bcb1a4
Show file tree
Hide file tree
Showing 38 changed files with 1,233 additions and 611 deletions.
Binary file removed Aimmy-Aimmy-V2.rar
Binary file not shown.
335 changes: 237 additions & 98 deletions Aimmy2/AILogic/AIManager.cs

Large diffs are not rendered by default.

62 changes: 32 additions & 30 deletions Aimmy2/AILogic/PredictionManager.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using Accord.Statistics.Running;
using Class;
using Aimmy2.WinformsReplacement;

namespace AILogic
namespace Aimmy2.AILogic
{
internal class KalmanPrediction
{
Expand All @@ -13,17 +13,17 @@ public struct Detection
}

private readonly KalmanFilter2D kalmanFilter = new KalmanFilter2D();
private DateTime lastFilterUpdateTime = DateTime.UtcNow;
private long lastFilterUpdateTicks = DateTime.UtcNow.Ticks;

public void UpdateKalmanFilter(Detection detection)
{
kalmanFilter.Push(detection.X, detection.Y);
lastFilterUpdateTime = DateTime.UtcNow;
lastFilterUpdateTicks = DateTime.UtcNow.Ticks;
}

public Detection GetKalmanPosition()
{
double timeStep = (DateTime.UtcNow - lastFilterUpdateTime).TotalSeconds;
double timeStep = (DateTime.UtcNow.Ticks - lastFilterUpdateTicks) / TimeSpan.TicksPerSecond;

double predictedX = kalmanFilter.X + kalmanFilter.XAxisVelocity * timeStep;
double predictedY = kalmanFilter.Y + kalmanFilter.YAxisVelocity * timeStep;
Expand All @@ -32,12 +32,9 @@ public Detection GetKalmanPosition()
}
}


internal class WiseTheFoxPrediction
{
/// <summary>
/// Proof of Concept Prediction as written by @wisethef0x
/// "Exponential Moving Average"
/// </summary>
{ // Proof of Concept Prediction as written by @wisethef0x
public struct WTFDetection
{
public int X;
Expand All @@ -51,15 +48,18 @@ public struct WTFDetection
private double emaX;
private double emaY;

public WiseTheFoxPrediction()
{
lastUpdateTime = DateTime.UtcNow;
}

public void UpdateDetection(WTFDetection detection)
{
emaX = lastUpdateTime == DateTime.MinValue ? detection.X : alpha * detection.X + (1 - alpha) * emaX;
emaY = lastUpdateTime == DateTime.MinValue ? detection.Y : alpha * detection.Y + (1 - alpha) * emaY;
if (lastUpdateTime == DateTime.MinValue)
{
emaX = detection.X;
emaY = detection.Y;
}
else
{
emaX = alpha * detection.X + (1 - alpha) * emaX;
emaY = alpha * detection.Y + (1 - alpha) * emaY;
}

lastUpdateTime = DateTime.UtcNow;
}
Expand All @@ -74,31 +74,33 @@ internal class ShalloePredictionV2
{
public static List<int> xValues = [];
public static List<int> yValues = [];

private static int currentIndex = 0;
private static int sumX = 0;
private static int sumY = 0;
public static int AmountCount = 2;

public static void AddValues(int x, int y)
{
if (xValues.Count >= AmountCount)
{
xValues.RemoveAt(0);
}
if (yValues.Count >= AmountCount)
{
yValues.RemoveAt(0);
}
xValues.Add(x);
yValues.Add(y);
sumX -= xValues[currentIndex];
sumY -= yValues[currentIndex];

xValues[currentIndex] = x;
yValues[currentIndex] = y;

sumX += x;
sumY += y;

currentIndex = (currentIndex + 1) % AmountCount;
}

public static int GetSPX()
{
return (int)(xValues.Average() * AmountCount + WinAPICaller.GetCursorPosition().X);
return (int)(sumX / (double)AmountCount + WinAPICaller.GetCursorPosition().X);
}

public static int GetSPY()
{
return (int)(yValues.Average() * AmountCount + WinAPICaller.GetCursorPosition().Y);
return (int)(sumY / (double)AmountCount + WinAPICaller.GetCursorPosition().Y);
}
}

Expand Down
4 changes: 2 additions & 2 deletions Aimmy2/Aimmy2.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@

<ItemGroup>
<PackageReference Include="Accord.Statistics" Version="3.8.0" />
<PackageReference Include="AntWpf" Version="1.0.3" />
<PackageReference Include="AntWpf" Version="1.0.5" />
<PackageReference Include="Costura.Fody" Version="5.8.0-alpha0098">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand All @@ -70,7 +70,7 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="MaterialDesignThemes" Version="4.9.0" />
<PackageReference Include="Microsoft.ML.OnnxRuntime.Gpu" Version="1.18.1" />
<PackageReference Include="Microsoft.ML.OnnxRuntime.Gpu" Version="1.19.2" />
<PackageReference Include="MouseKeyHook" Version="5.7.1" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="Supercluster.KDTree" Version="1.0.4" />
Expand Down
2 changes: 1 addition & 1 deletion Aimmy2/Class/Animator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace AimmyWPF.Class
namespace Aimmy2.Class
{
public static class Animator
{
Expand Down
23 changes: 20 additions & 3 deletions Aimmy2/Class/Dictionary.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Visuality;
using Vortice.DXGI;

namespace Aimmy2.Class
{
Expand Down Expand Up @@ -27,7 +28,7 @@ public static class Dictionary
{ "FOV Size", 640 },
{ "Dynamic FOV Size", 200 },
{ "Mouse Sensitivity (+/-)", 0.80 },
{ "Mouse Jitter", 4 },
{ "Mouse Jitter", 0 },
{ "Y Offset (Up/Down)", 0 },
{ "Y Offset (%)", 50 },
{ "X Offset (Left/Right)", 0 },
Expand Down Expand Up @@ -66,7 +67,7 @@ public static class Dictionary
{ "X Axis Percentage Adjustment", false },
{ "Y Axis Percentage Adjustment", false },
{ "Debug Mode", false },
{ "Show FPS", false }
{ "Show FPS", false },
};

public static Dictionary<string, dynamic> minimizeState = new()
Expand All @@ -89,9 +90,13 @@ public static class Dictionary
{ "Aiming Boundaries Alignment", "Center" },
{ "Mouse Movement Method", "Mouse Event" },
{ "Screen Capture Method", "DirectX" },
{ "Monitor Selection", "\\\\.\\DISPLAY1"}
{ "Execution Provider Type", "CUDA" }
};

//public static IDXGIAdapter1 SelectedAdapter = null;
//public static List<IDXGIAdapter1> adapters = new List<IDXGIAdapter1>();

// public static List<(int adapterIndex, int outputIndex, IDXGIOutput output)> monitors = new List<(int, int, IDXGIOutput)>();
public static Dictionary<string, dynamic> colorState = new()
{
{ "FOV Color", "#FF8080FF"},
Expand All @@ -112,5 +117,17 @@ public static class Dictionary
{ "Gun 1 Config", "" },
{ "Gun 2 Config", "" }
};

public static T GetValueOrDefault<T>(Dictionary<string, T> dictionary, string key, T defaultValue)
{
if (dictionary.TryGetValue(key, out T? value))
{
return value;
}
else
{
return defaultValue;
}
}
}
}
2 changes: 1 addition & 1 deletion Aimmy2/Class/SaveDictionary.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using System.IO;
using MessageBox = System.Windows.MessageBox;

namespace Class
namespace Aimmy2.Class
{
internal class SaveDictionary
{
Expand Down
2 changes: 1 addition & 1 deletion Aimmy2/Class/Theming.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace Class
namespace Aimmy2.Class
{
public class Theming
{
Expand Down
15 changes: 6 additions & 9 deletions Aimmy2/Class/UI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@
using System.Windows.Controls;
using UILibrary;

namespace Class
namespace Aimmy2.Class
{
public class UI
{
// Aim Menu
public ATitle? AT_Aim { get; set; }
public APButton? B_Testing { get; set; }

public AToggle? T_AimAligner { get; set; }

Expand All @@ -16,8 +17,6 @@ public class UI
public AToggle? T_Predictions { get; set; }
public AToggle? T_EMASmoothing { get; set; }
public AKeyChanger? C_EmergencyKeybind { get; set; }
public AToggle? T_EnableModelSwitchKeybind { get; set; }
public AKeyChanger? C_ModelSwitchKeybind { get; set; }

//Aim Config
public ATitle? AT_AimConfig { get; set; }
Expand All @@ -42,9 +41,7 @@ public class UI

// Anti Recoil
public ATitle? AT_AntiRecoil { get; set; }

public AToggle? T_AntiRecoil { get; set; }

public AKeyChanger? C_AntiRecoilKeybind { get; set; }
public AKeyChanger? C_ToggleAntiRecoilKeybind { get; set; }
public ASlider? S_HoldTime { get; set; }
Expand All @@ -55,9 +52,7 @@ public class UI

// Anti Recoil Config
public ATitle? AT_AntiRecoilConfig { get; set; }

public AToggle? T_EnableGunSwitchingKeybind { get; set; }

public APButton? B_SaveRecoilConfig { get; set; }
public AKeyChanger? C_Gun1Key { get; set; }
public AFileLocator? AFL_Gun1Config { get; set; }
Expand All @@ -68,9 +63,7 @@ public class UI

// FOV
public ATitle? AT_FOV { get; set; }

public AToggle? T_FOV { get; set; }

public AToggle? T_DynamicFOV { get; set; }
public AKeyChanger? C_DynamicFOV { get; set; }
public AColorChanger? CC_FOVColor { get; set; }
Expand All @@ -94,7 +87,11 @@ public class UI
public AToggle? T_CollectDataWhilePlaying { get; set; }
public AToggle? T_AutoLabelData { get; set; }
public ADropdown? D_MouseMovementMethod { get; set; }
public ADropdown? D_ScreenCaptureMethod { get; set; }
public ADropdown? D_MonitorSelection { get; set; }
public ADropdown? D_ExecutionProvider { get; set; }
public ComboBoxItem? DDI_CUDA { get; set; }
public ComboBoxItem? DDI_TensorRT { get; set; }
public ComboBoxItem? DDI_LGHUB { get; set; }
public ComboBoxItem? DDI_RazerSynapse { get; set; }
public ASlider? S_AIMinimumConfidence { get; set; }
Expand Down
2 changes: 1 addition & 1 deletion Aimmy2/InputLogic/InputBindingManager.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using Gma.System.MouseKeyHook;
using System.Windows.Forms;

namespace InputLogic
namespace Aimmy2.InputLogic
{
internal class InputBindingManager
{
Expand Down
66 changes: 34 additions & 32 deletions Aimmy2/InputLogic/MouseManager.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
using Aimmy2.Class;
using Aimmy2.MouseMovementLibraries.GHubSupport;
using Class;
using MouseMovementLibraries.ddxoftSupport;
using MouseMovementLibraries.RazerSupport;
using MouseMovementLibraries.SendInputSupport;
using Aimmy2.MouseMovementLibraries.RazerSupport;
using Aimmy2.MouseMovementLibraries.SendInputSupport;
using Aimmy2.WinformsReplacement;
using System.Drawing;
using System.Runtime.InteropServices;

namespace InputLogic
namespace Aimmy2.InputLogic
{
internal class MouseManager
{
Expand Down Expand Up @@ -35,9 +34,11 @@ private static Point CubicBezier(Point start, Point end, Point control1, Point c
double u = 1 - t;
double tt = t * t;
double uu = u * u;
double uuu = uu * u;
double ttt = tt * t;

double x = uu * u * start.X + 3 * uu * t * control1.X + 3 * u * tt * control2.X + tt * t * end.X;
double y = uu * u * start.Y + 3 * uu * t * control1.Y + 3 * u * tt * control2.Y + tt * t * end.Y;
double x = uuu * start.X + 3 * uu * t * control1.X + 3 * u * tt * control2.X + ttt * end.X;
double y = uuu * start.Y + 3 * uu * t * control1.Y + 3 * u * tt * control2.Y + ttt * end.Y;

if (IsEMASmoothingEnabled)
{
Expand All @@ -48,7 +49,7 @@ private static Point CubicBezier(Point start, Point end, Point control1, Point c
return new Point((int)x, (int)y);
}

private static double EmaSmoothing(double previousValue, double currentValue, double smoothingFactor) => (currentValue * smoothingFactor) + (previousValue * (1 - smoothingFactor));
private static double EmaSmoothing(double previousValue, double currentValue, double smoothingFactor) => currentValue * smoothingFactor + previousValue * (1 - smoothingFactor);

public static async Task DoTriggerClick()
{
Expand All @@ -62,37 +63,38 @@ public static async Task DoTriggerClick()
}

string mouseMovementMethod = Dictionary.dropdownState["Mouse Movement Method"];
Action mouseDownAction;
Action mouseUpAction;
Action mouseDownAction, mouseUpAction;

switch (mouseMovementMethod)
{
case "SendInput":
mouseDownAction = () => SendInputMouse.SendMouseCommand(MOUSEEVENTF_LEFTDOWN);
mouseUpAction = () => SendInputMouse.SendMouseCommand(MOUSEEVENTF_LEFTUP);
break;

case "LG HUB":
mouseDownAction = () => LGMouse.Move(1, 0, 0, 0);
mouseUpAction = () => LGMouse.Move(0, 0, 0, 0);
break;

case "Razer Synapse (Require Razer Peripheral)":
mouseDownAction = () => RZMouse.mouse_click(1);
mouseUpAction = () => RZMouse.mouse_click(0);
break;

default:
mouseDownAction = () => mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0);
mouseUpAction = () => mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
break;
}
(mouseDownAction, mouseUpAction) = GetMouseActions(mouseMovementMethod);

mouseDownAction.Invoke();
await Task.Delay(clickDelayMilliseconds);
mouseUpAction.Invoke();

LastClickTime = DateTime.UtcNow;

static (Action, Action) GetMouseActions(string method)
{
return method switch
{
"SendInput" => (
() => SendInputMouse.SendMouseCommand(MOUSEEVENTF_LEFTDOWN),
() => SendInputMouse.SendMouseCommand(MOUSEEVENTF_LEFTUP)
),
"LG HUB" => (
() => LGMouse.Move(1, 0, 0, 0),
() => LGMouse.Move(0, 0, 0, 0)
),
"Razer Synapse (Require Razer Peripheral)" => (
() => RZMouse.mouse_click(1),
() => RZMouse.mouse_click(0)
),
_ => (
() => mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0),
() => mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0)
)
};
}
}

public static void DoAntiRecoil()
Expand Down
Loading

0 comments on commit 6bcb1a4

Please sign in to comment.