@ -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 ( 2 5) ;
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 ( 30 0) ;
bot . delay ( 25 0) ;
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 ) {