diff --git a/CLAUDE.md b/CLAUDE.md index 64a47e3..7e8ccbf 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -69,6 +69,22 @@ The audio detection system is critical for fish detection: - Resource disposal for COM objects - Exit key is END (not DEL) +### Interact Key Feature + +The bot supports two fishing modes: + +1. **Traditional Mode (default)**: Uses cursor detection + mouse clicks + - Detects bobber via cursor icon changes (EVENT_OBJECT_NAMECHANGE) + - Moves mouse in spiral pattern to find bobber + - Right-clicks on bobber to catch fish + +2. **Interact Key Mode**: Uses WoW's "Interact with Target" feature + - Set `use-interact-key: true` in configuration.yaml + - Configure `keyboard-key-interact` (default: f) + - Skips bobber detection entirely + - Uses keyboard interaction instead of mouse clicks + - Requires WoW expansion that supports interact feature (not available in vanilla) + ### Testing Audio Issues If audio detection isn't working: diff --git a/Phishy/Configs/ConfigValidator.cs b/Phishy/Configs/ConfigValidator.cs index c116acc..36d0c47 100644 --- a/Phishy/Configs/ConfigValidator.cs +++ b/Phishy/Configs/ConfigValidator.cs @@ -48,6 +48,7 @@ public static ValidationResult Validate(Properties properties) } } + return new ValidationResult(errors); } } diff --git a/Phishy/Configs/Properties.cs b/Phishy/Configs/Properties.cs index 884a4ff..070bd43 100644 --- a/Phishy/Configs/Properties.cs +++ b/Phishy/Configs/Properties.cs @@ -35,6 +35,12 @@ public sealed class Properties [YamlMember(Description = "Window name of the game, when you hover over it in the taskbar")] public string GameWindowName { get; set; } + [YamlMember(Description = "Use interact key instead of mouse clicking for fishing (requires WoW expansion with interact feature, Default: false)")] + public bool UseInteractKey { get; set; } + + [YamlMember(Description = "Keyboard key binding for interact with target (Default: f)")] + public string KeyboardKeyInteract { get; set; } + public Properties() { KeyboardPressLogout = KeyboardUtils.ConvertToString(Keys.D3); @@ -46,5 +52,7 @@ public Properties() SecondLureBuffDurationMinutes = null; FishingChannelDurationSeconds = TimeSpan.FromSeconds(20).Seconds; GameWindowName = "Game Window Name"; + UseInteractKey = false; + KeyboardKeyInteract = "f"; } } \ No newline at end of file diff --git a/Phishy/FishingStateMachine.cs b/Phishy/FishingStateMachine.cs index bab74dc..01e945d 100644 --- a/Phishy/FishingStateMachine.cs +++ b/Phishy/FishingStateMachine.cs @@ -55,8 +55,15 @@ public void Update(CancellationToken cancellationToken) _isBobberFound = false; } - Console.WriteLine("[FishingStateMachine]: Moving to center of screen..."); - MouseUtils.MoveToCenterOfWindow(AppConfig.Props.GameWindowName, true, 100); + if (!AppConfig.Props.UseInteractKey) + { + Console.WriteLine("[FishingStateMachine]: Moving to center of screen..."); + MouseUtils.MoveToCenterOfWindow(AppConfig.Props.GameWindowName, true, 100); + } + else + { + Console.WriteLine("[FishingStateMachine]: Interact mode enabled - skipping mouse positioning..."); + } TryTransition(); break; @@ -123,7 +130,15 @@ public void Update(CancellationToken cancellationToken) case FishingState.CatchFish: Console.WriteLine("[FishingStateMachine]: You caught a fish!"); - MouseUtils.SendMouseInput(MouseButtons.Right); + if (AppConfig.Props.UseInteractKey) + { + Console.WriteLine($"[FishingStateMachine]: Using interact key: {AppConfig.Props.KeyboardKeyInteract}"); + KeyboardUtils.SendKeyInput(AppConfig.Props.KeyboardKeyInteract); + } + else + { + MouseUtils.SendMouseInput(MouseButtons.Right); + } _isLineCast = false; Thread.Sleep(TimeSpan.FromSeconds(1)); @@ -178,7 +193,14 @@ private void TryTransition() case FishingState.CastLine: if (_isLineCast) { - TransitionTo(FishingState.FindBobber); + if (AppConfig.Props.UseInteractKey) + { + TransitionTo(FishingState.WaitAndCatch); + } + else + { + TransitionTo(FishingState.FindBobber); + } } break; case FishingState.FindBobber: @@ -269,7 +291,8 @@ private void ListenForFish(CancellationToken cancellationToken, TimeSpan timeout float maxSoundLevel = 0f; const float FISH_DETECTION_THRESHOLD = 0.1f; - Console.WriteLine($"[FishingStateMachine]: Starting to listen for fish splash (threshold: {FISH_DETECTION_THRESHOLD})..."); + string mode = AppConfig.Props.UseInteractKey ? "interact key" : "mouse click"; + Console.WriteLine($"[FishingStateMachine]: Starting to listen for fish splash (threshold: {FISH_DETECTION_THRESHOLD}, mode: {mode})..."); while (!cancellationToken.IsCancellationRequested) { @@ -287,14 +310,19 @@ private void ListenForFish(CancellationToken cancellationToken, TimeSpan timeout maxSoundLevel = currentSoundLevel; } - // Log every 2 seconds or when significant sound detected - if (DateTime.Now - lastLogTime > TimeSpan.FromSeconds(2) || currentSoundLevel > 0.01f) + // Log every 5 seconds or when significant sound detected (higher threshold) + if (DateTime.Now - lastLogTime > TimeSpan.FromSeconds(5) || currentSoundLevel > 0.05f) { - Console.WriteLine($"[FishingStateMachine]: Listening... Bobber found: {bobberFound}, Current sound: {currentSoundLevel:F4}, Max sound: {maxSoundLevel:F4}, Checks: {checkCount}"); + string statusMsg = AppConfig.Props.UseInteractKey + ? $"Interact mode: Ready, Current sound: {currentSoundLevel:F4}, Max sound: {maxSoundLevel:F4}, Checks: {checkCount}" + : $"Bobber found: {bobberFound}, Current sound: {currentSoundLevel:F4}, Max sound: {maxSoundLevel:F4}, Checks: {checkCount}"; + Console.WriteLine($"[FishingStateMachine]: Listening... {statusMsg}"); lastLogTime = DateTime.Now; } - if (bobberFound && currentSoundLevel > FISH_DETECTION_THRESHOLD) + bool canDetectFish = AppConfig.Props.UseInteractKey || bobberFound; + + if (canDetectFish && currentSoundLevel > FISH_DETECTION_THRESHOLD) { Console.WriteLine($"[FishingStateMachine]: FISH DETECTED! Sound level: {currentSoundLevel:F4} (threshold: {FISH_DETECTION_THRESHOLD})"); _isBobberDipped = true; diff --git a/Phishy/Utils/KeyboardUtils.cs b/Phishy/Utils/KeyboardUtils.cs index a96848b..6145d33 100644 --- a/Phishy/Utils/KeyboardUtils.cs +++ b/Phishy/Utils/KeyboardUtils.cs @@ -10,7 +10,16 @@ public static void SendKeyInput(Keys key) public static void SendKeyInput(string key) { - SendKeys.SendWait("{" + key + "}"); + // For single letter keys, send without braces to get lowercase + // For special keys (like numbers converted from Keys.D1), use braces + if (key.Length == 1 && char.IsLetter(key[0])) + { + SendKeys.SendWait(key.ToLower()); + } + else + { + SendKeys.SendWait("{" + key + "}"); + } } public static string ConvertToString(Keys key)