diff --git a/ToF_Fishing_Bot/FishingThread.cs b/ToF_Fishing_Bot/FishingThread.cs index 134157b..8710ec4 100644 --- a/ToF_Fishing_Bot/FishingThread.cs +++ b/ToF_Fishing_Bot/FishingThread.cs @@ -18,7 +18,6 @@ class FishingThread private IAppSettings settings; public bool isRunning = false; private InputSimulator InputSimulator; - public int counter = 0; private System.Windows.Shapes.Rectangle left; private System.Windows.Shapes.Rectangle right; @@ -45,8 +44,8 @@ class FishingThread private MemoryStream ms1; private MemoryStream ms2; - private double colorThreshold = 40.0; - private double middleBarCenterThreshold = 10.0; + private double colorThreshold; + private double middleBarCenterThreshold; private ScreenStateLogger screenStateLogger; @@ -94,6 +93,9 @@ public FishingThread( GameHandle = _gameHandle.Value; } + colorThreshold = settings.StaminaColorDetectionThreshold; + middleBarCenterThreshold = settings.MiddlebarColorDetectionThreshold; + screenStateLogger = new ScreenStateLogger(); } @@ -141,7 +143,7 @@ public void Start() ClickFishCaptureButton(); break; case FishingState.Captured: - ClickTapToCloseButton(); + CloseFishCaptureDialog(); ResetKeys(); break; case FishingState.Reset: @@ -157,7 +159,7 @@ public void Start() state = FishingState.Fishing; PlayerStamina_lagCompensationDone = false; LagCompensationDelay = new DispatcherTimer(DispatcherPriority.Send, dis); - LagCompensationDelay.Interval = new TimeSpan(0,0,0,5); + LagCompensationDelay.Interval = new TimeSpan(0, 0, 0, 0, settings.Delay_LagCompensation); LagCompensationDelay.Tick += (o, e) => { PlayerStamina_lagCompensationDone = true; @@ -171,7 +173,7 @@ public void Start() { state = FishingState.ReelingStart; ReelDelay = new DispatcherTimer(DispatcherPriority.Send, dis); - ReelDelay.Interval = new TimeSpan(0,0,0,2); + ReelDelay.Interval = new TimeSpan(0, 0, 0, 0, settings.Delay_FishCapture); ReelDelay.Tick += (o, e) => { state = FishingState.Reeling; @@ -187,7 +189,7 @@ public void Start() case FishingState.Reeling: state = FishingState.CaptureStart; CaptureDelay = new DispatcherTimer(DispatcherPriority.Send, dis); - CaptureDelay.Interval = new TimeSpan(0, 0, 0, 2); + CaptureDelay.Interval = new TimeSpan(0, 0, 0, 0, settings.Delay_DismissFishCaptureDialogue); CaptureDelay.Tick += (o, e) => { state = FishingState.Captured; @@ -201,7 +203,7 @@ public void Start() case FishingState.Captured: state = FishingState.ResetStart; ResetDelay = new DispatcherTimer(DispatcherPriority.Send, dis); - ResetDelay.Interval = new TimeSpan(0, 0, 0, 2); + ResetDelay.Interval = new TimeSpan(0, 0, 0, 0, settings.Delay_Restart); ResetDelay.Tick += (o, e) => { state = FishingState.Reset; @@ -364,7 +366,7 @@ public double GetMiddleBarAveragePos(Mat frame) Cv2.InRange(frame, lowerBoundsColor, upperBoundsColor, masked); /*Cv2.ImShow("masked", masked);*/ - var lineDetect = FastLineDetector.Create(lengthThreshold: 4); + var lineDetect = FastLineDetector.Create(lengthThreshold: settings.MinimumMiddleBarHeight - 1); try { var lines = lineDetect.Detect(masked); @@ -408,7 +410,7 @@ public double GetFishingCursorPos(Mat frame) var masked = new Mat(); Cv2.InRange(frame, lowerBoundsColor, upperBoundsColor, masked); /*Cv2.ImShow("masked", masked);*/ - var lineDetect = FastLineDetector.Create(lengthThreshold: 4); + var lineDetect = FastLineDetector.Create(lengthThreshold: settings.MinimumMiddleBarHeight - 1); try { @@ -452,20 +454,20 @@ public void ClickFishCaptureButton() { if (GameHandle != null) { - InputSimulator.Keyboard.KeyDownBackground(GameHandle.Value, WindowsInput.Native.VirtualKeyCode.VK_1); + InputSimulator.Keyboard.KeyDownBackground(GameHandle.Value, (WindowsInput.Native.VirtualKeyCode) settings.KeyCode_FishCapture); InputSimulator.Mouse.Sleep(25); - InputSimulator.Keyboard.KeyUpBackground(GameHandle.Value, WindowsInput.Native.VirtualKeyCode.VK_1); + InputSimulator.Keyboard.KeyUpBackground(GameHandle.Value, (WindowsInput.Native.VirtualKeyCode)settings.KeyCode_FishCapture); InputSimulator.Mouse.Sleep(25); } } - public void ClickTapToCloseButton() + public void CloseFishCaptureDialog() { if (GameHandle != null) { - InputSimulator.Keyboard.KeyDownBackground(GameHandle.Value, WindowsInput.Native.VirtualKeyCode.ESCAPE); + InputSimulator.Keyboard.KeyDownBackground(GameHandle.Value, (WindowsInput.Native.VirtualKeyCode)settings.KeyCode_DismissFishDialogue); InputSimulator.Mouse.Sleep(25); - InputSimulator.Keyboard.KeyUpBackground(GameHandle.Value, WindowsInput.Native.VirtualKeyCode.ESCAPE); + InputSimulator.Keyboard.KeyUpBackground(GameHandle.Value, (WindowsInput.Native.VirtualKeyCode)settings.KeyCode_DismissFishDialogue); InputSimulator.Mouse.Sleep(25); } } diff --git a/ToF_Fishing_Bot/IAppSettings.cs b/ToF_Fishing_Bot/IAppSettings.cs index 44adcc9..9db64a8 100644 --- a/ToF_Fishing_Bot/IAppSettings.cs +++ b/ToF_Fishing_Bot/IAppSettings.cs @@ -46,5 +46,31 @@ public interface IAppSettings int LowerRightBarPoint_Y { get; set; } [DefaultValue(0)] int IsDarkMode { get; set; } + [DefaultValue(300)] + int ZoomSize_X { get; set; } + [DefaultValue(300)] + int ZoomSize_Y { get; set; } + [DefaultValue(4)] + int ZoomFactor { get; set; } + [DefaultValue("QRSL")] + string GameProcessName { get; set; } + [DefaultValue(40.0)] + double StaminaColorDetectionThreshold { get; set; } + [DefaultValue(10.0)] + double MiddlebarColorDetectionThreshold { get; set; } + [DefaultValue(5000)] + int Delay_LagCompensation { get; set; } + [DefaultValue(2000)] + int Delay_FishCapture { get; set; } + [DefaultValue(2000)] + int Delay_DismissFishCaptureDialogue { get; set; } + [DefaultValue(2000)] + int Delay_Restart { get; set; } + [DefaultValue(5)] + int MinimumMiddleBarHeight { get; set; } + [DefaultValue(49)] + int KeyCode_FishCapture { get; set; } + [DefaultValue(27)] + int KeyCode_DismissFishDialogue{ get; set; } } } diff --git a/ToF_Fishing_Bot/MainWindow.xaml.cs b/ToF_Fishing_Bot/MainWindow.xaml.cs index 433b880..df90a58 100644 --- a/ToF_Fishing_Bot/MainWindow.xaml.cs +++ b/ToF_Fishing_Bot/MainWindow.xaml.cs @@ -213,10 +213,10 @@ private void HandleButtonClick( lens_form = new Lens_Form() { - Size = new System.Drawing.Size(300, 300), + Size = new System.Drawing.Size(settings.ZoomSize_X, settings.ZoomSize_Y), AutoClose = true, HideCursor = false, - ZoomFactor = 4, + ZoomFactor = settings.ZoomFactor, NearestNeighborInterpolation = false }; lens_form.Show(); @@ -350,7 +350,7 @@ private void StartBtn_Click(object sender, RoutedEventArgs e) var message = String.Empty; var noErrors = true; - Process[] processes = Process.GetProcessesByName("QRSL"); + Process[] processes = Process.GetProcessesByName(settings.GameProcessName); if (processes.Length == 0) {