import impsoft.nexus.bots.color.constants.Areas; import impsoft.nexus.bots.color.constants.BitMapInfo; import impsoft.nexus.bots.color.listeners.ChatListener; import impsoft.nexus.bots.color.methods.ColorScript; import impsoft.nexus.bots.color.methods.GameScreenMethods; import impsoft.nexus.bots.color.scriptobjects.DTM; import impsoft.nexus.bots.color.scriptobjects.RGB; import impsoft.nexus.bots.color.scriptobjects.RGBCluster; import impsoft.nexus.bots.color.scriptobjects.Timer; import impsoft.nexus.bots.color.scriptobjects.XY; import impsoft.nexus.bots.paint.SimplePaintJob; import java.awt.Graphics; import java.awt.Rectangle; import java.awt.image.BufferedImage; import java.io.OutputStream; public class pestControll extends ColorScript implements ChatListener { XY foundLoc = null; static short[][][] onBoat; boolean onLander = false; @Override public boolean doStart(String arg0, String[] arg1) throws InterruptedException { setRun(true); a = new animal(this); return true; } animal a; XY plank = new XY(301, 184); RGB gagplankColor=new RGB(74,33,57); @Override public void script() throws InterruptedException { boolean skipper = false; while (true) { if (!leftIsland()) { skipper = true; } onLander = false; spiralSearch("Gangplank", 20, plank); sleep(5000); } if (onLander || skipper) { log("We are on the lander"); while (!arrivedAtIsland() && !skipper) { sleep(500); } if (!skipper) { log("At the island"); walkOnIsland(); walkToNpc(); } while (!leftIsland()) { skipper = false; if (dead) { walkOnIsland(); dead = false; } if (inFight() || isMoving()) { sleep(1000); continue; } a.gatherNewPoints(10); a.removeRedundantPoints(20); if (!a.doTopTextAndMenuOnMoving("Attack", "Attack")) { if (leftIsland() || dead) continue; walkToNpc(); } sleep(1000); } } } } private void walkToNpc() throws InterruptedException { Rectangle[] npcs = getNpcsOnMinimap(); mouseClickLeft(npcs[0]); sleep(500); while (isMoving()) { sleep(500); } } public void walkOnIsland() throws InterruptedException { walk(-6, -75); switch (Random(4)) { case 0: walk(1, -74); break; case 1: walk(67, 0); break; case 2: walk(-71, -5); break; } } public boolean inFight() throws InterruptedException { RGB fightColor = new RGB(65280, RGB.COLOR_TYPE_SCAR); Rectangle searchZone = new Rectangle(217, 129, 80, 80); return (findRGBXY(getColorArray2d(), fightColor, searchZone) != null); } public boolean spiralSearch(String name, int width, XY start) throws InterruptedException { foundLoc = null; topTextMonitor t = new topTextMonitor(name, 5000, this); new Thread(t).start(); XY nextXY = new XY(start.x, start.y); double angle = 0; double totalAngle = width * 2 * Math.PI / 10; double angleInc = Math.PI / 8; while (foundLoc == null && angle < totalAngle) { mouseMove(nextXY); angle = angle + angleInc; nextXY.x = (int) (nextXY.x + Math.cos(angle) * angle * 10 / (2 * Math.PI)); nextXY.y = (int) (nextXY.y + Math.sin(angle) * angle * 10 / (2 * Math.PI)); } if (foundLoc == null) return false; mouseMove(foundLoc); if (getTopText().contains(name)) { mouseClickLeft(foundLoc); return true; } return false; } class topTextMonitor implements Runnable { Timer t; String text; pestControll p; public topTextMonitor(String text, int timeoutms, pestControll p) { t = new Timer(timeoutms); this.text = text; this.p = p; } public void run() { try { while (!t.isUp()) { if (getTopText().contains(text)) { p.foundLoc = p.currentMouseXY(); break; } try { Thread.sleep(5); } catch (InterruptedException e) { e.printStackTrace(); } } p.log("Ending topText monitoring"); } catch (InterruptedException e) { } } } boolean arrivedAtIsland() throws InterruptedException { return getTextAt(getColorArray2d(), 8, 25, 91, 5, "StatChars", false, new RGB(204, 204, 204), 3, 0).equals("20"); } public void chat(String s) { if (s.contains("You board the lander")) this.onLander = true; if (s.contains("Oh dear :: are dead!")) this.dead = true; } boolean dead = false; class animal extends RGBCluster { public animal(GameScreenMethods methods) { super(new RGB[] { new RGB(199, 169, 198), new RGB(62, 133, 87), new RGB(195, 25, 42), new RGB(224, 31, 214), new RGB(119, 123, 114), new RGB(182, 144, 182), new RGB(103, 13, 115), new RGB(140, 84, 149), new RGB(164, 92, 112), new RGB(194, 118, 132), new RGB(62, 57, 57), new RGB(134, 75, 91) }, methods); } } boolean leftIsland() throws InterruptedException { if (findXY(getColorArray2d(), new RGB(0, 0, 248), new Rectangle(31, 62, 15, 13), 5, 5, 5) != null || findXY(getColorArray2d(), new RGB(248, 0, 0), new Rectangle( 31, 62, 15, 13), 5, 5, 5) != null) { return false; } return true; } public void paintColorMap(final short[][][] colorMap, final int xOff, final int yOff, final int time) { final BufferedImage bf = new BufferedImage(colorMap.length, colorMap[0].length, BufferedImage.TYPE_INT_RGB); for (int x = 0; x < colorMap.length; x++) { for (int y = 0; y < colorMap[0].length; y++) { if (colorMap[x][y][0] > -1) { bf.setRGB(x, y, new RGB(colorMap[x][y]) .toColor(RGB.COLOR_TYPE_AWT)); } } } addPaintJob(new SimplePaintJob(time) { @Override public void paint(Graphics g) { g.drawImage(bf, xOff, yOff, null); } }); } }