Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
1 change: 1 addition & 0 deletions Phishy/Configs/ConfigValidator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ public static ValidationResult Validate(Properties properties)
}
}


return new ValidationResult(errors);
}
}
Expand Down
8 changes: 8 additions & 0 deletions Phishy/Configs/Properties.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -46,5 +52,7 @@ public Properties()
SecondLureBuffDurationMinutes = null;
FishingChannelDurationSeconds = TimeSpan.FromSeconds(20).Seconds;
GameWindowName = "Game Window Name";
UseInteractKey = false;
KeyboardKeyInteract = "f";
}
}
46 changes: 37 additions & 9 deletions Phishy/FishingStateMachine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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));

Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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)
{
Expand All @@ -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;
Expand Down
11 changes: 10 additions & 1 deletion Phishy/Utils/KeyboardUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down