Made bot detect plots available and unavailable. Yay

main
Joshua Sigona 3 years ago
parent b994789979
commit d03063286b
  1. BIN
      bin/sig/HousingTracker.class
  2. BIN
      screenshot.png
  3. 78
      src/sig/HousingTracker.java

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.0 MiB

After

Width:  |  Height:  |  Size: 3.3 MiB

@ -11,6 +11,7 @@ import java.awt.Robot;
import java.awt.event.KeyEvent; import java.awt.event.KeyEvent;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -25,7 +26,7 @@ public class HousingTracker{
public static final int SCANSTART_X = 601; public static final int SCANSTART_X = 601;
public static final int SCANSTART_Y = 415; public static final int SCANSTART_Y = 415;
public static final Rectangle SCANSTART_REGION = new Rectangle(601,415,330,24); public static final Rectangle SCANSTART_REGION = new Rectangle(601,415,330,24);
public static final Rectangle NAMESTART_REGION = new Rectangle(119,0,16,11); public static final Rectangle NAMESTART_REGION = new Rectangle(119,0,4,11);
public static Map<String,List<Boolean>> PLOTSTATE = new HashMap<String,List<Boolean>>(); public static Map<String,List<Boolean>> PLOTSTATE = new HashMap<String,List<Boolean>>();
public static final String[] REGIONS = new String[] {"Kugane","Gridania","Uldah","Limsa"}; public static final String[] REGIONS = new String[] {"Kugane","Gridania","Uldah","Limsa"};
@ -35,6 +36,14 @@ public class HousingTracker{
try { try {
r = new Robot(); r = new Robot();
for (String REGION : REGIONS) {
List<Boolean> house_list = new ArrayList<Boolean>();
PLOTSTATE.put(REGION,house_list);
for (int i=0;i<1440;i++) {
house_list.add(true);
}
}
r.delay(3000); r.delay(3000);
//Starts at 601,415 //Starts at 601,415
/*BufferedImage i = CaptureScreen(env, r); /*BufferedImage i = CaptureScreen(env, r);
@ -45,7 +54,9 @@ public class HousingTracker{
}*/ }*/
//CompleteALoadingPhase(); //CompleteALoadingPhase();
//Walk(Direction.RIGHT,1000); //Walk(Direction.RIGHT,1000);
//OpenResidentialMenu(); if (OpenResidentialMenu()) {
CaptureResidentialData();
}
} catch (AWTException e) { } catch (AWTException e) {
e.printStackTrace(); e.printStackTrace();
} }
@ -54,19 +65,62 @@ public class HousingTracker{
private static void CaptureResidentialData() { private static void CaptureResidentialData() {
GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment();
BufferedImage i = null; BufferedImage i = null;
try { for (int ward=0;ward<24;ward++) {
i = CaptureScreen(env); for (int tab=0;tab<2;tab++) {
} catch (IOException e1) { try {
e1.printStackTrace(); i = CaptureScreen(env);
} } catch (IOException e1) {
for (int x=0;x<2;x++) { e1.printStackTrace();
for (int y=0;y<15;y++) { }
Image plot_img = i.getSubimage(SCANSTART_REGION.x+SCANSTART_REGION.width*x,SCANSTART_REGION.y+SCANSTART_REGION.height*y,SCANSTART_REGION.width,NAMESTART_REGION.height); for (int x=0;x<2;x++) {
for (int y=0;y<15;y++) {
BufferedImage plot_img = i.getSubimage(SCANSTART_REGION.x+SCANSTART_REGION.width*x,SCANSTART_REGION.y+SCANSTART_REGION.height*y,SCANSTART_REGION.width,NAMESTART_REGION.height);
boolean found=false;
for (int xx=0;xx<NAMESTART_REGION.width;xx++) {
for (int yy=0;yy<NAMESTART_REGION.height;yy++) {
Color col = new Color(plot_img.getRGB(NAMESTART_REGION.x+xx, NAMESTART_REGION.y+yy));
if (col.getRed()>150||col.getGreen()>150) {
found=true;
break;
}
}
if (found) {
break;
}
}
if (found) {
//Ignore this plot, it is taken.
PLOTSTATE.get(REGIONS[CURRENT_REGION]).set(x*15+y+ward*60+tab*30,found);
System.out.println("Plot "+((x*15+y+tab*30)+1)+" in Ward "+(ward+1)+" is taken.");
} else {
//Ignore this plot, it is taken.
if (PLOTSTATE.get(REGIONS[CURRENT_REGION]).get(x*15+y+ward*60+tab*30)) {
AnnounceNewOpenPlot(REGIONS[CURRENT_REGION],ward+1,(x*15+y+tab*30)+1,"Small");
}
PLOTSTATE.get(REGIONS[CURRENT_REGION]).set(x*15+y+ward*60+tab*30,found);
}
}
}
PressKey(KeyEvent.VK_F10);r.delay(500);
} }
PressKey(KeyEvent.VK_F9);r.delay(200);
PressKeyWithModifier(KeyEvent.VK_SHIFT,KeyEvent.VK_F10);r.delay(200);
PressKey(KeyEvent.VK_NUMPAD0);r.delay(1000);
} }
} }
private static void OpenResidentialMenu() { private static void AnnounceNewOpenPlot(String region,int ward,int plot,String size) {
System.out.println("A new "+size+" plot has become available in "+region+", Ward "+ward+", Plot "+plot+"!");
}
private static void PressKeyWithModifier(int modifier,int keycode) {
r.keyPress(modifier);
r.keyPress(keycode);
r.keyRelease(keycode);r.delay(100);
r.keyRelease(modifier);
}
private static boolean OpenResidentialMenu() {
PressKey(KeyEvent.VK_ESCAPE);r.delay(500); PressKey(KeyEvent.VK_ESCAPE);r.delay(500);
PressKey(KeyEvent.VK_ESCAPE);r.delay(500); PressKey(KeyEvent.VK_ESCAPE);r.delay(500);
PressKey(KeyEvent.VK_NUMPAD0); PressKey(KeyEvent.VK_NUMPAD0);
@ -79,8 +133,10 @@ public class HousingTracker{
PressKey(KeyEvent.VK_NUMPAD0);r.delay(2000); PressKey(KeyEvent.VK_NUMPAD0);r.delay(2000);
PressKey(KeyEvent.VK_NUMPAD7);r.delay(200); PressKey(KeyEvent.VK_NUMPAD7);r.delay(200);
PressKey(KeyEvent.VK_NUMPAD0);r.delay(2000); PressKey(KeyEvent.VK_NUMPAD0);r.delay(2000);
return true;
} else { } else {
System.out.println("Could not select Aetheryte!! Moving on..."); System.out.println("Could not select Aetheryte!! Moving on...");
return false;
} }
} }

Loading…
Cancel
Save