Skip to content

Commit 8effb75

Browse files
authored
Merge pull request #129 from NaNraptor/CSharp
Major update pull request, please look at @daniel-widrick 's fork and mine for more information
2 parents 32bb925 + 4ed73f4 commit 8effb75

27 files changed

+1565
-615
lines changed

.travis.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
language: csharp
2+
solution: UltimateFishBot.sln
3+
os:
4+
- windows

README.md

Lines changed: 37 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,9 @@ UltimateFishbot
22
===============
33
A simple World of Warcraft fishbot written in C#.
44

5-
[![Build status](https://ci.appveyor.com/api/projects/status/rjlp159797lfbf72?svg=true)](https://ci.appveyor.com/project/RobPaulson/ultimatefishbot)
6-
75
Introduction
86

9-
I started this project during my freshman year of college…many, many years ago.
7+
I started this project during my freshman year of college… Many, many years ago.
108
It’s been years since I’ve played Wow and I no longer have the amounts of free
119
time I used to. I’ve revised the code a few times since, but I can’t pretend
1210
it’s a shining example of anything; still, it remains a popular project and I
@@ -16,48 +14,71 @@ some value from this.
1614
Coding Overview
1715

1816
This is originaly written in VB.NET (I know, I know….). It has been now ported
19-
in C#. You can get a free copy of Visual Studio Express.
17+
to C#. You can get a free copy of Visual Studio Community.
2018

2119
The general idea is that the bot works by ‘listening’ to the output from the
2220
game (whereas most bots at the time were reading pixels and trying to find the
23-
bobber, or reading the game’s memory (which means updating the offsets after
24-
each patch). This works with the CoreAudio DLL file – I didn’t write it and
21+
bobber, or reading the game’s memory - which means updating the offsets after
22+
each patch). This works with the CoreAudio DLL file – I didn’t write it and
2523
I don’t believe it works with Windows XP.
2624

2725
The bot uses standard win32 API calls to move the mouse and send keystrokes.
2826
I’ve never had any problems, but I’ve gotten reports from users saying it
2927
doesn’t work on their machine.
3028

3129
It starts by sending the ‘cast’ key, then moving the cursor systematically and
32-
using the GetCursorInfo api call to detect a change in the icon. We assume
33-
that change is the fish bobber. Then it monitors the sound output (via
34-
CoreAudio) until there is a change and we assume that is the splash of a fish.
35-
Then the bot sends the click mouse event. Rinse. Repeat.
30+
using the GetCursorInfo api call to detect a change in the icon. We assume that
31+
that change is the fish bobber. Then it monitors the sound output (via
32+
CoreAudio) until there is a change above a threshold and we assume that this is the splash of a fish.
33+
Then the bot sends the click mouse event. Rinse. Repeat.
3634

37-
There are quite a few ‘nice-to-haves’ I never got around to doing….adding
35+
There are quite a few ‘nice-to-haves’ I never got around to doing… Adding
3836
lures, improving the scanning, ironing out the hearth home functionality…
39-
maybe someone will get a chance.
37+
Maybe someone will get a chance.
4038

4139
Thanks to everyone who supported the project and thanks to anyone reading this
4240
for your interest.
4341

44-
Updated for Mists of Pandaria
42+
Updated for Mists of Pandaria & Warlords of Draenor
4543
=============================
4644

4745
Updated by justanotherprogrammer to support MoP items such as the Ancient
4846
Pandaren Fishing Charm and the Angler's Fishing Raft. Also added support for
4947
people who don't use Auto-loot.
5048

51-
Updated for Warlords of Draenor
52-
===============================
53-
5449
Updated by Henrik Hermansen to support WoD bait.
5550

5651
Updated in C#
5752
===============================
5853

5954
Updated by Pierre Ghiot (Mograine) in C#.
6055

56+
Updated by daniel-widrick & Szabka
57+
===============================
58+
-Hearing optimisation.
59+
60+
-Bobber finding and Hearing is put in parallel threads.
61+
62+
-Bobber finding searches the differences between "before cast" and "after cast" screenshots, than previous bobber positions ordered by occurence.
63+
64+
-If bobber is still not found when fish is heard, it searches 2 seconds more for bobber, so that it still has a possibility to catch fish.
65+
66+
-Bobber recheck on hook, so if bobber moves a little it will find the fish again.
67+
68+
-Has log file for debugging purposes.
69+
70+
-Can capture fishing cursor with hotkey for more precision bobber finding.
71+
72+
-Hungarian translation.
73+
74+
-Bulgarian translation.
75+
76+
-Wow window handle searched when starts fishing(and not when fishbot starts).
77+
78+
-Hotkey actions disabled in settings screen.
79+
80+
-Stop fishing after 10 consecutive fish failures.
81+
6182
Happy Fishing!
6283

6384
Gorden

UltimateFishBot.sln

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
3-
# Visual Studio 14
4-
VisualStudioVersion = 14.0.23107.0
3+
# Visual Studio 15
4+
VisualStudioVersion = 15.0.27428.2015
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UltimateFishBot", "UltimateFishBot\UltimateFishBot.csproj", "{E4705D9F-56CD-48CB-863B-4363D03C8424}"
77
EndProject
@@ -13,16 +13,25 @@ EndProject
1313
Global
1414
GlobalSection(SolutionConfigurationPlatforms) = preSolution
1515
Debug|Any CPU = Debug|Any CPU
16+
Debug|x64 = Debug|x64
1617
Release|Any CPU = Release|Any CPU
18+
Release|x64 = Release|x64
1719
EndGlobalSection
1820
GlobalSection(ProjectConfigurationPlatforms) = postSolution
1921
{E4705D9F-56CD-48CB-863B-4363D03C8424}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
2022
{E4705D9F-56CD-48CB-863B-4363D03C8424}.Debug|Any CPU.Build.0 = Debug|Any CPU
2123
{E4705D9F-56CD-48CB-863B-4363D03C8424}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
24+
{E4705D9F-56CD-48CB-863B-4363D03C8424}.Debug|x64.ActiveCfg = Debug|x64
25+
{E4705D9F-56CD-48CB-863B-4363D03C8424}.Debug|x64.Build.0 = Debug|x64
2226
{E4705D9F-56CD-48CB-863B-4363D03C8424}.Release|Any CPU.ActiveCfg = Release|Any CPU
2327
{E4705D9F-56CD-48CB-863B-4363D03C8424}.Release|Any CPU.Build.0 = Release|Any CPU
28+
{E4705D9F-56CD-48CB-863B-4363D03C8424}.Release|x64.ActiveCfg = Release|x64
29+
{E4705D9F-56CD-48CB-863B-4363D03C8424}.Release|x64.Build.0 = Release|x64
2430
EndGlobalSection
2531
GlobalSection(SolutionProperties) = preSolution
2632
HideSolutionNode = FALSE
2733
EndGlobalSection
34+
GlobalSection(ExtensibilityGlobals) = postSolution
35+
SolutionGuid = {9D9545D2-DE63-4ED7-AC09-41C3F8E7D147}
36+
EndGlobalSection
2837
EndGlobal

UltimateFishBot/App.config

Lines changed: 32 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,24 +6,24 @@
66
</sectionGroup>
77
</configSections>
88
<startup>
9-
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6"/>
9+
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1"/>
1010
</startup>
1111
<userSettings>
1212
<UltimateFishBot.Properties.Settings>
13-
<setting name="ScanningSteps" serializeAs="String">
14-
<value>10</value>
13+
<setting name="ScanningStepsLow" serializeAs="String">
14+
<value>15</value>
1515
</setting>
16-
<setting name="ScanningDelay" serializeAs="String">
17-
<value>30</value>
16+
<setting name="ScanningDelayLow" serializeAs="String">
17+
<value>23</value>
1818
</setting>
1919
<setting name="ScanningRetries" serializeAs="String">
2020
<value>2</value>
2121
</setting>
22-
<setting name="CastingDelay" serializeAs="String">
22+
<setting name="CastingDelayLow" serializeAs="String">
2323
<value>1500</value>
2424
</setting>
25-
<setting name="LootingDelay" serializeAs="String">
26-
<value>3000</value>
25+
<setting name="LootingDelayLow" serializeAs="String">
26+
<value>2600</value>
2727
</setting>
2828
<setting name="SplashLimit" serializeAs="String">
2929
<value>15</value>
@@ -79,11 +79,11 @@
7979
<setting name="ShiftLoot" serializeAs="String">
8080
<value>False</value>
8181
</setting>
82-
<setting name="FishWait" serializeAs="String">
83-
<value>22000</value>
82+
<setting name="FishWaitLow" serializeAs="String">
83+
<value>21500</value>
8484
</setting>
8585
<setting name="AudioDevice" serializeAs="String">
86-
<value/>
86+
<value />
8787
</setting>
8888
<setting name="AutoBait" serializeAs="String">
8989
<value>False</value>
@@ -160,6 +160,27 @@
160160
<setting name="AverageSound" serializeAs="String">
161161
<value>False</value>
162162
</setting>
163+
<setting name="CursorCaptureHotKey" serializeAs="String">
164+
<value>Alt+Shift+C</value>
165+
</setting>
166+
<setting name="RightClickCast" serializeAs="String">
167+
<value>False</value>
168+
</setting>
169+
<setting name="CastingDelayHigh" serializeAs="String">
170+
<value>1800</value>
171+
</setting>
172+
<setting name="LootingDelayHigh" serializeAs="String">
173+
<value>3000</value>
174+
</setting>
175+
<setting name="FishWaitHigh" serializeAs="String">
176+
<value>22200</value>
177+
</setting>
178+
<setting name="ScanningDelayHigh" serializeAs="String">
179+
<value>32</value>
180+
</setting>
181+
<setting name="ScanningStepsHigh" serializeAs="String">
182+
<value>30</value>
183+
</setting>
163184
</UltimateFishBot.Properties.Settings>
164185
</userSettings>
165186
</configuration>

UltimateFishBot/Classes/BodyParts/Ears.cs

Lines changed: 22 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -13,97 +13,71 @@ class Ears
1313
{
1414
private MMDevice SndDevice;
1515
private Queue<int> m_volumeQueue;
16-
private int tickrate = 100; //ms pause between sound checks
16+
private int tickrate = 50; //ms pause between sound checks
1717

1818
private const int MAX_VOLUME_QUEUE_LENGTH = 5;
1919

2020
public Ears()
2121
{
2222
m_volumeQueue = new Queue<int>();
23+
m_volumeQueue.Enqueue(0);
2324
}
2425

2526
public async Task<bool> Listen(int millisecondsToListen, CancellationToken cancellationToken)
2627
{
2728
Stopwatch stopwatch = new Stopwatch();
2829
stopwatch.Start();
2930
MMDeviceEnumerator SndDevEnum = new MMDeviceEnumerator();
30-
if (Properties.Settings.Default.AudioDevice != "")
31+
if (Properties.Settings.Default.AudioDevice != "") {
3132
SndDevice = SndDevEnum.GetDevice(Properties.Settings.Default.AudioDevice);
32-
else
33+
} else {
3334
SndDevice = SndDevEnum.GetDefaultAudioEndpoint(EDataFlow.eRender, ERole.eMultimedia);
34-
35+
}
3536
Func<bool> heardFish;
3637
if (Properties.Settings.Default.AverageSound)
3738
heardFish = ListenTimerTickAvg;
3839
else
3940
heardFish = ListenTimerTick;
4041

41-
while (stopwatch.ElapsedMilliseconds <= millisecondsToListen)
42-
{
42+
while (stopwatch.ElapsedMilliseconds <= millisecondsToListen) {
4343
await Task.Delay(tickrate, cancellationToken);
44-
if (heardFish())
45-
{
44+
if (heardFish()) {
4645
return true;
4746
}
4847
}
4948
return false;
5049
}
5150

52-
private bool ListenTimerTick()
53-
{
51+
private bool ListenTimerTick() {
5452
// Get the current level
55-
int currentVolumnLevel = (int)(SndDevice.AudioMeterInformation.MasterPeakValue * tickrate);
53+
int currentVolumnLevel = (int)(SndDevice.AudioMeterInformation.MasterPeakValue * 100);
5654

5755
if (currentVolumnLevel >= Properties.Settings.Default.SplashLimit)
5856
return true;
5957

6058
return false;
61-
62-
// Debug code
63-
//if (m_manager.IsStoppedOrPaused() == false)
64-
//{
65-
// Debug.WriteLine("Average volume: " + avgVol);
66-
// Debug.WriteLine("Current volume: " + currentVolumnLevel);
67-
// Debug.WriteLine("Queue values: ");
68-
// foreach (int v in m_volumeQueue)
69-
// {
70-
// Debug.WriteLine("> " + v);
71-
// }
72-
// Debug.WriteLine("Splash limit: " + Properties.Settings.Default.SplashLimit);
73-
// Debug.WriteLine("______________________");
74-
//}
7559
}
7660

7761
private bool ListenTimerTickAvg()
7862
{
7963
// Get the current level
80-
int currentVolumnLevel = (int)(SndDevice.AudioMeterInformation.MasterPeakValue * tickrate);
81-
m_volumeQueue.Enqueue(currentVolumnLevel);
82-
83-
// Keep a running queue of the last X sounds as a reference point
84-
if (m_volumeQueue.Count >= MAX_VOLUME_QUEUE_LENGTH)
85-
m_volumeQueue.Dequeue();
64+
int currentVolumnLevel = (int)(SndDevice.AudioMeterInformation.MasterPeakValue * 100);
65+
int avgVol = GetAverageVolume();
66+
bool hear = false;
8667

8768
// Determine if the current level is high enough to be a fish
88-
int avgVol = GetAverageVolume();
89-
if (currentVolumnLevel - avgVol >= Properties.Settings.Default.SplashLimit)
90-
return true;
69+
if (currentVolumnLevel - avgVol >= Properties.Settings.Default.SplashLimit) {
70+
Serilog.Log.Information("Hear: {av},{cvl},{queue}", avgVol, currentVolumnLevel, m_volumeQueue);
71+
hear = true;
72+
}
9173

92-
return false;
74+
m_volumeQueue.Enqueue(currentVolumnLevel);
75+
// Keep a running queue of the last X sounds as a reference point
76+
if (m_volumeQueue.Count >= MAX_VOLUME_QUEUE_LENGTH) {
77+
m_volumeQueue.Dequeue();
78+
}
79+
return hear;
9380

94-
// Debug code
95-
//if (m_manager.IsStoppedOrPaused() == false)
96-
//{
97-
// Debug.WriteLine("Average volume: " + avgVol);
98-
// Debug.WriteLine("Current volume: " + currentVolumnLevel);
99-
// Debug.WriteLine("Queue values: ");
100-
// foreach (int v in m_volumeQueue)
101-
// {
102-
// Debug.WriteLine("> " + v);
103-
// }
104-
// Debug.WriteLine("Splash limit: " + Properties.Settings.Default.SplashLimit);
105-
// Debug.WriteLine("______________________");
106-
//}
10781
}
10882

10983
private int GetAverageVolume()

0 commit comments

Comments
 (0)