Compare commits

...

9 Commits

  1. 4
      .gitignore
  2. 4
      MANIFEST.txt
  3. 15
      Makefile
  4. 17
      README.md
  5. 46
      src/xyz/unbewohnte/albionFisher/fisher.java
  6. 20
      src/xyz/unbewohnte/albionFisher/gui.java
  7. 2
      src/xyz/unbewohnte/albionFisher/imgutils.java
  8. 4
      src/xyz/unbewohnte/albionFisher/rgb.java

4
.gitignore vendored

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

4
MANIFEST.txt

@ -0,0 +1,4 @@
Manifest-Version: 1.0
Created-By: 18.0.1.1 (N/A)
Main-Class: fisher

15
Makefile

@ -1,10 +1,15 @@
src_dir:='src/xyz/unbewohnte/albionFisher' src_dir:='src/xyz/unbewohnte/albionFisher'
release_dir:='release' release_dir:='release'
jar_name:='albionFisher.jar'
jar: all
jar cvmf MANIFEST.txt $(jar_name) *.class && rm *.class
all: all:
javac -Werror $(src_dir)/*.java && cp $(src_dir)/*.class . && rm $(src_dir)/*.class javac -Werror $(src_dir)/*.java && mv $(src_dir)/*.class .
mkdir -p $(release_dir)
mv *.class $(release_dir)
# jar: all release: jar
# jar cvfm fisher.jar Manifest.txt gui.class fisher.class bobber.png mkdir -p $(release_dir)
mv $(jar_name) $(release_dir)
cp COPYING $(release_dir)
cp README.md $(release_dir)

17
README.md

@ -0,0 +1,17 @@
# albionFisher - albion online fishing bot
# Compiling
`make jar` if you're on GNU/Linux, else - translate the commands in the makefile to compile
# Launch
`java -jar albionFisher.jar`
# Usage
1. Open the game, make it to the water source
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
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 2-3)
6. Start the bot again and leave the mouse cursor as is
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

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

@ -25,12 +25,12 @@ import java.awt.image.BufferedImage;
import javax.swing.ImageIcon; import javax.swing.ImageIcon;
public class fisher { public class fisher {
static RGB BOBBER_COLOR = new RGB(255, 180, 31); static String VERSION = "v0.1.6";
static rgb BOBBER_COLOR = new rgb(255, 180, 31);
static boolean fishing = false; static boolean fishing = false;
static boolean windowActivated = false;
static Robot bot; static Robot bot;
@ -101,7 +101,7 @@ public class fisher {
bot = new Robot(); bot = new Robot();
// GUI // GUI
gui.launchGUI("fisher"); gui.launchGUI("albionFisher", VERSION);
// update gui in the separate thread // update gui in the separate thread
Thread updateGUIThread = new Thread() { Thread updateGUIThread = new Thread() {
@ -113,7 +113,7 @@ public class fisher {
updateGUIThread.start(); updateGUIThread.start();
// fishing logic // fishing logic
windowActivated = false; boolean windowActivated = false;
while (true) { while (true) {
Thread.sleep(50); Thread.sleep(50);
@ -139,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);
@ -191,7 +190,6 @@ public class fisher {
// check if severe changes has occured in the image // check if severe changes has occured in the image
if (meanDifference > meanDiffThreshold) { if (meanDifference > meanDiffThreshold) {
// catch ! // catch !
System.out.println("catch !");
bot.mousePress(InputEvent.BUTTON1_DOWN_MASK); bot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
bot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); bot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
break; // break out of loop still fishing so the next stage starts break; // break out of loop still fishing so the next stage starts
@ -225,27 +223,41 @@ public class fisher {
Point bobberCoords = imgutils.getPixelCoordinates(screenshot, BOBBER_COLOR); Point bobberCoords = imgutils.getPixelCoordinates(screenshot, BOBBER_COLOR);
if (bobberCoords.x != -1 && bobberCoords.y != -1) { if (bobberCoords.x != -1 && bobberCoords.y != -1) {
// found one ! // found one !
System.out.println(String.format("found bobber: %d %d", bobberCoords.x, bobberCoords.y));
if (initialBobberPosition.x == -1 && initialBobberPosition.y == -1) { if (initialBobberPosition.x == -1 && initialBobberPosition.y == -1) {
// it's the first time // it's the first time
initialBobberPosition = bobberCoords; initialBobberPosition = bobberCoords;
continue; continue;
} }
// play the game
if (bobberCoords.x < initialBobberPosition.x) { if (bobberCoords.x < initialBobberPosition.x) {
// hold
bot.mousePress(InputEvent.BUTTON1_DOWN_MASK); bot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
bot.delay(1400); }
if (bobberCoords.x > initialBobberPosition.x) {
// release
bot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); bot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
} }
} }
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
Thread.sleep(8000); bot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
Thread.sleep(5000);
if (mousePos_x != xpos && mousePos_y != ypos) {
fishing = false;
}
break; break;
} }
Thread.sleep(25); 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) {

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

@ -39,7 +39,7 @@ public class gui {
static JLabel meanDifferenceValueLabel; static JLabel meanDifferenceValueLabel;
static JLabel capturedImageLabel; static JLabel capturedImageLabel;
public static void launchGUI(String windowName) { public static void launchGUI(String windowName, String version) {
SwingUtilities.invokeLater(new Runnable() { SwingUtilities.invokeLater(new Runnable() {
@Override @Override
public void run() { public void run() {
@ -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);
@ -156,9 +155,14 @@ public class gui {
mousePositionLabel.setBounds(190, 230, 100, 30); mousePositionLabel.setBounds(190, 230, 100, 30);
window.add(mousePositionLabel); window.add(mousePositionLabel);
// version label
JLabel versionLabel = new JLabel(version);
versionLabel.setBounds(290, 230, 40, 30);
window.add(versionLabel);
// copyright // copyright
JLabel copyrightLabel = new JLabel("(c) Kasyanov N. A."); JLabel copyrightLabel = new JLabel("(c) Kasyanov N. A.");
copyrightLabel.setBounds(320, 230, 150, 30); copyrightLabel.setBounds(335, 230, 110, 30);
window.add(copyrightLabel); window.add(copyrightLabel);
// show window // show window

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