Skip to content

Commit

Permalink
Accuracy improvement
Browse files Browse the repository at this point in the history
  • Loading branch information
vrachv committed May 4, 2022
1 parent 2a93db4 commit 77710f6
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 10 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@
bin
obj
Properties
*csproj.user
*csproj.user
.vs
30 changes: 21 additions & 9 deletions DeadBySkill/Program.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using OpenCvSharp;
using System.Diagnostics;
using System.Runtime.InteropServices;

namespace DeadBySkill;
Expand All @@ -10,12 +11,12 @@ class Program

static async Task Main(string[] args)
{
Console.ForegroundColor = ConsoleColor.Green;
if (args.Length == 1 && int.TryParse(args[0], out var delay))
{
Delay = delay;
Console.WriteLine("Delay: " + delay + "ms");
}
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine("Delay: " + Delay + "ms");
Console.WriteLine("Press key for skill check. Spacebar not recommended!");
SelectKey();
var lowWhite = new Scalar(253, 253, 253);
Expand Down Expand Up @@ -58,6 +59,7 @@ Mat GetArrow()

var circlePixelCount = vPixelArray.Cast<Vec3b>().Count(vec3b => vec3b != default);
var isManiac = circlePixelCount > 600;

if (circlePixelCount > 50)
{
search:
Expand All @@ -77,9 +79,15 @@ Mat GetArrow()
}
else
{
await Task.Delay(Delay);
keybd_event((byte)ConsoleKey, 0, 0x0001 | 0, 0);
keybd_event((byte)ConsoleKey, 0, 0x0002 | 0, 0);
var stopwatch = Stopwatch.StartNew();
while (true)
{
if (stopwatch.ElapsedMilliseconds >= Delay)
{
break;
}
}
PressKey();
goto start;
}
}
Expand All @@ -88,9 +96,7 @@ Mat GetArrow()

if (isManiac && count >= 18)
{
await Task.Delay(Delay);
keybd_event((byte)ConsoleKey, 0, 0x0001 | 0, 0);
keybd_event((byte)ConsoleKey, 0, 0x0002 | 0, 0);
PressKey();
}

if (rPixelArray.Cast<Vec3b>().Any(vec3b => vec3b != default))
Expand All @@ -109,7 +115,7 @@ Mat GetArrow()

private static ConsoleKey ConsoleKey;

private static int Delay = 0;
private static int Delay = 5;

private static void SelectKey()
{
Expand All @@ -125,4 +131,10 @@ private static void SelectKey()
Console.WriteLine("Selected key: " + ConsoleKey);
}
}

private static void PressKey()
{
keybd_event((byte)ConsoleKey, 0, 0x0001 | 0, 0);
keybd_event((byte)ConsoleKey, 0, 0x0002 | 0, 0);
}
}

0 comments on commit 77710f6

Please sign in to comment.