Compare commits

...

4 Commits

  1. 4
      .gitignore
  2. 10
      README.md
  3. 45
      src/xyz/unbewohnte/albionFisher/fisher.java
  4. 12
      src/xyz/unbewohnte/albionFisher/gui.java
  5. 2
      src/xyz/unbewohnte/albionFisher/imgutils.java
  6. 4
      src/xyz/unbewohnte/albionFisher/rgb.java

4
.gitignore vendored

@ -1 +1,3 @@
release/ release/
albionFisher.jar
*.zip

10
README.md

@ -1,7 +1,7 @@
# albionFisher - albion online fisher bot # albionFisher - albion online fishing bot
# Compiling # Compiling
`make jar` if you're on GNU/Linux, else - `javac src/xyz/unbewohnte/albionFisher/*.java`+`jar cvmf MANIFEST.txt albionFisher.jar *.class && rm *.class` `make jar` if you're on GNU/Linux, else - translate the commands in the makefile to compile
# Launch # Launch
`java -jar albionFisher.jar` `java -jar albionFisher.jar`
@ -11,7 +11,7 @@
2. Set your cursor at the exact position where you want to drop the bobber 2. Set your cursor at the exact position where you want to drop the bobber
3. Look at the coordinates on the fisher's window and put them in the xy fields 3. Look at the coordinates on the fisher's window and put them in the xy fields
4. By trial and error specify needed hold time in miliseconds so you could see ingame bobber being in the center of fisher's sight box (by clicking "fish" button) 4. By trial and error specify needed hold time in miliseconds so you could see ingame bobber being in the center of fisher's sight box (by clicking "fish" button)
5. With the same method set difference threshold (in most cases it is somewhere around 3-4 if you fish horizontally, 1-2 if vertically) 5. With the same method set difference threshold (in most cases it is somewhere around 2-3)
6. Start the bot again and leave the computer as is 6. Start the bot again and leave the mouse cursor as is
Moving the mouse automatically (though not very reliably) stops the bot so you can move onto the next spot or entirely stop fishing without manual click on "stop" button Moving the mouse automatically stops the bot so you can move onto the next spot or entirely stop fishing without the manual click on "stop" button

45
src/xyz/unbewohnte/albionFisher/fisher.java

@ -26,9 +26,9 @@ import javax.swing.ImageIcon;
public class fisher { public class fisher {
static String VERSION = "v0.1.3"; static String VERSION = "v0.1.6";
static RGB BOBBER_COLOR = new RGB(255, 180, 31); static rgb BOBBER_COLOR = new rgb(255, 180, 31);
static boolean fishing = false; static boolean fishing = false;
@ -101,7 +101,7 @@ public class fisher {
bot = new Robot(); bot = new Robot();
// GUI // GUI
gui.launchGUI("fisher", VERSION); gui.launchGUI("albionFisher", VERSION);
// update gui in the separate thread // update gui in the separate thread
Thread updateGUIThread = new Thread() { Thread updateGUIThread = new Thread() {
@ -114,9 +114,6 @@ public class fisher {
// fishing logic // fishing logic
boolean windowActivated = false; boolean windowActivated = false;
boolean needToRecast = false;
int idleCountMsMax = 20000; // 20 seconds
int idleCountMs = 0;
while (true) { while (true) {
Thread.sleep(50); Thread.sleep(50);
@ -142,22 +139,21 @@ public class fisher {
holdms = gui.holdMsSlider.getValue(); holdms = gui.holdMsSlider.getValue();
meanDiffThreshold = gui.meanDiffThresholdSlider.getValue(); meanDiffThreshold = gui.meanDiffThresholdSlider.getValue();
Thread.sleep(500);
// activate window if needed // activate window if needed
if (!windowActivated) { if (!windowActivated) {
windowActivated = true; bot.delay(100);
bot.mouseMove(xpos, ypos); bot.mouseMove(xpos, ypos);
bot.mousePress(InputEvent.BUTTON1_DOWN_MASK); bot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
bot.delay(50); bot.delay(25);
bot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); bot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
windowActivated = true;
} }
// move the mouse to the position // move the mouse to the position
// give the game window needed vector // give the game window needed vector
bot.delay(300); bot.delay(250);
bot.mouseMove(xpos-5, ypos-5); bot.mouseMove(xpos-5, ypos-5);
bot.mouseMove(xpos, ypos); bot.mouseMove(xpos, ypos);
@ -170,15 +166,7 @@ public class fisher {
Thread.sleep(3500); Thread.sleep(3500);
// wait for fish as long as the user does not move the mouse // wait for fish as long as the user does not move the mouse
idleCountMs = 0;
needToRecast = false;
while (true) { while (true) {
if (idleCountMs >= idleCountMsMax) {
// something must be wrong
needToRecast = true;
break;
}
if (mousePos_x != xpos && mousePos_y != ypos) { if (mousePos_x != xpos && mousePos_y != ypos) {
fishing = false; fishing = false;
break; // break out of loop with fishing flag set to FALSE break; // break out of loop with fishing flag set to FALSE
@ -208,13 +196,12 @@ public class fisher {
} }
Thread.sleep(50); Thread.sleep(50);
idleCountMs += 50;
} }
// play minigame if still fishing // play minigame if still fishing
lastMean = 0.0f; lastMean = 0.0f;
currentMean = 0.0f; currentMean = 0.0f;
if (!fishing || needToRecast) { if (!fishing) {
continue; continue;
}; };
@ -256,11 +243,21 @@ public class fisher {
if (bobberCoords.x == -1 && bobberCoords.y == -1 && initialBobberPosition.x != -1 && initialBobberPosition.y != -1) { if (bobberCoords.x == -1 && bobberCoords.y == -1 && initialBobberPosition.x != -1 && initialBobberPosition.y != -1) {
// the game has been finished // the game has been finished
bot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); bot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
Thread.sleep(6000); Thread.sleep(5000);
if (mousePos_x != xpos && mousePos_y != ypos) {
fishing = false;
}
break; break;
} }
Thread.sleep(5); if (bobberCoords.x == -1 && bobberCoords.y == -1 && initialBobberPosition.x == -1 && initialBobberPosition.y == -1) {
// false-positive !
// recast
Thread.sleep(5000);
break;
}
} }
} }
} catch (Exception e) { } catch (Exception e) {

12
src/xyz/unbewohnte/albionFisher/gui.java

@ -102,7 +102,7 @@ public class gui {
holdSliderLabel.setBounds(20, 90, 70, 20); holdSliderLabel.setBounds(20, 90, 70, 20);
window.add(holdSliderLabel); window.add(holdSliderLabel);
holdMsSlider = new JSlider(JSlider.HORIZONTAL, 0, 1500, 250); holdMsSlider = new JSlider(JSlider.HORIZONTAL, 0, 1100, 250);
holdMsSlider.setValue(250); holdMsSlider.setValue(250);
holdMsSlider.setMajorTickSpacing(500); holdMsSlider.setMajorTickSpacing(500);
holdMsSlider.setMinorTickSpacing(250); holdMsSlider.setMinorTickSpacing(250);
@ -116,11 +116,10 @@ public class gui {
thresholdSliderLabel.setBounds(20, 135, 130, 20); thresholdSliderLabel.setBounds(20, 135, 130, 20);
window.add(thresholdSliderLabel); window.add(thresholdSliderLabel);
meanDiffThresholdSlider = new JSlider(JSlider.HORIZONTAL, 0, 10, 5);
meanDiffThresholdSlider = new JSlider(JSlider.HORIZONTAL, 0, 30, 10); meanDiffThresholdSlider.setValue(3);
meanDiffThresholdSlider.setValue(10); meanDiffThresholdSlider.setMajorTickSpacing(5);
meanDiffThresholdSlider.setMajorTickSpacing(10); meanDiffThresholdSlider.setMinorTickSpacing(1);
meanDiffThresholdSlider.setMinorTickSpacing(5);
meanDiffThresholdSlider.setPaintTicks(true); meanDiffThresholdSlider.setPaintTicks(true);
meanDiffThresholdSlider.setPaintLabels(true); meanDiffThresholdSlider.setPaintLabels(true);
meanDiffThresholdSlider.setBounds(150, 135, 170, 45); meanDiffThresholdSlider.setBounds(150, 135, 170, 45);
@ -163,7 +162,6 @@ public class gui {
// copyright // copyright
JLabel copyrightLabel = new JLabel("(c) Kasyanov N. A."); JLabel copyrightLabel = new JLabel("(c) Kasyanov N. A.");
// copyrightLabel.setBounds(290, 230, 110, 30);
copyrightLabel.setBounds(335, 230, 110, 30); copyrightLabel.setBounds(335, 230, 110, 30);
window.add(copyrightLabel); window.add(copyrightLabel);

2
src/xyz/unbewohnte/albionFisher/imgutils.java

@ -33,7 +33,7 @@ public class imgutils {
return sum / (img.getWidth() * img.getHeight()); return sum / (img.getWidth() * img.getHeight());
} }
public static Point getPixelCoordinates(BufferedImage img, RGB color) { public static Point getPixelCoordinates(BufferedImage img, rgb color) {
for (int y = 0; y < img.getHeight(); y++) { for (int y = 0; y < img.getHeight(); y++) {
for (int x = 0; x < img.getWidth(); x++) { for (int x = 0; x < img.getWidth(); x++) {
int imgColor = img.getRGB(x, y); int imgColor = img.getRGB(x, y);

4
src/xyz/unbewohnte/albionFisher/RGB.java → src/xyz/unbewohnte/albionFisher/rgb.java

@ -16,12 +16,12 @@ You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
public class RGB { public class rgb {
public int r; public int r;
public int g; public int g;
public int b; public int b;
public RGB(int r, int g, int b) { public rgb(int r, int g, int b) {
this.r = r; this.r = r;
this.g = g; this.g = g;
this.b = b; this.b = b;
Loading…
Cancel
Save