import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.KeyEvent; import java.awt.event.MouseEvent; import java.awt.event.MouseListener; import java.io.IOException; import java.net.URI; import java.net.URISyntaxException; import java.text.DecimalFormat; import java.util.LinkedList; import javax.swing.*; import org.rsbot.event.events.MessageEvent; import org.rsbot.event.listeners.MessageListener; import org.rsbot.event.listeners.PaintListener; import org.rsbot.script.*; import org.rsbot.script.wrappers.*; import org.rsbot.script.methods.*; import org.rsbot.script.util.Filter; import org.rsbot.script.util.Timer; /** * * @author Emeleo * @version 2.3 */ @ScriptManifest(authors = {"Emeleo"}, name = "AutoCookerPro", keywords = {"cooker", "auto", "food", "raw"}, description = "Cooks your food FLAWLESSLY @ Akharid | Rouge Den | Cooking Guild- UPDATED 15 June 2011.", version = 2.3, website = "http://www.powerbot.org/vb/showthread.php?t=618926", requiresVersion = 251) public class AutoCookerPro extends Script implements PaintListener, MessageListener, MouseListener { private static State cState; private static Fish fish; private static Location loc; private Methods m = new Methods(); private AutoCookerProGUI gui; private timer timer; private Paint p = new Paint(); private final static locationIDS con = new locationIDS(); private static boolean logOutOnFinish = true; private static long activityTimer = 2000; private final LinkedList mousePath = new LinkedList(); // private final LinkedList clicks = new LinkedList(); private timer checkEXPTimer = new timer(10); Thread forceCamera = new ForceCamera(); public interface Condition { public long Time(); public boolean isTrue(); } @Override public boolean onStart() { gui = new AutoCookerProGUI(); while (gui.frame1.isVisible()) { sleep(100); } if (gui.cancel) { return false; } else if (gui.start) { fish = gui.getSelectedFish(); loc = gui.getSelectedLocation(); logOutOnFinish = gui.checkBox1.isSelected(); if (fish == null || loc == null) { return false; } logOutOnFinish = gui.checkBox1.isSelected(); log(Color.GREEN, "Latest update 15 June 2011, includes:"); log(Color.ORANGE, "Improved AntiBan!"); log(Color.ORANGE, "Fixed walking bug!"); log(Color.ORANGE, "Fixed missclicks, AGAIN."); m.gatherInfo.start(); p.start_xp = skills.getCurrentExp(Skills.COOKING); p.startTime = System.currentTimeMillis(); return true; } return false; } public void mouseClicked(MouseEvent e) { } public void mousePressed(MouseEvent e) { if (p.showPaint && p.getChatRect().contains(e.getPoint()) && !p.closeRect.contains(e.getPoint())) { p.changeAL = true; p.alph = 50; p.color1 = new Color(102, 0, 0, p.alph); p.color2 = new Color(0, 0, 0, p.alph); p.color3 = new Color(255, 153, 0, p.alph); p.color4 = new Color(51, 102, 0, p.alph); } } public void mouseReleased(MouseEvent e) { if (p.closeRect.contains(e.getPoint())) { p.showPaint = !p.showPaint; } if (p.changeAL) { p.alph = 255; p.color1 = new Color(102, 0, 0, p.alph); p.color2 = new Color(0, 0, 0, p.alph); p.color3 = new Color(255, 153, 0, p.alph); p.color4 = new Color(51, 102, 0, p.alph); p.changeAL = false; } } public void mouseEntered(MouseEvent e) { } public void mouseExited(MouseEvent e) { } public static class locationIDS { private static final RSTile[] cooking_location_tiles = { new RSTile(3043, 4972), new RSTile(3043, 4974), new RSTile(3044, 4973), new RSTile(3042, 4973)}; /** * RangeID */ int CatherbyRangeID = 2728; int RougeDenRangeID = 2732; int AlKharidRangeID = 25730; int CookingGuildRangeID = 24283; /** * RangeTile */ RSTile CatherbyRangeTile = new RSTile(3816, 3442); RSTile RougeDenRangeTile = new RSTile(3043, 4973); RSTile AlkharidRangeTile = new RSTile(3273, 3180); RSTile CookingGuildRangeTile = new RSTile(3146, 3451); /** * BankTile */ RSTile CatherbyBankTile = new RSTile(2809, 3440); RSTile RougeDenBankTile = null; RSTile AlkharidBankTile = new RSTile(3270, 3167); RSTile CookingGuildBankTile = CookingGuildRangeTile; /** * Objects */ int CatherbyClosedDoorID = 1530; RSTile CatherbyClosedDoorTile = new RSTile(2816, 3438); RSTile AlkharidExactRangeTile = new RSTile(3271, 3181); } private enum Location { RougeDen(con.RougeDenRangeID, con.RougeDenBankTile, con.RougeDenRangeTile, "Rouge Den"), ALKHARID(con.AlKharidRangeID, con.AlkharidBankTile, con.AlkharidRangeTile, "Al Kharid"), //CATHERBY(con.CatherbyRangeID, con.CatherbyBankTile, con.CatherbyRangeTile, "Catherby"); COOKINGGUILD(con.CookingGuildRangeID, con.CookingGuildBankTile, con.CookingGuildRangeTile, "Cooking Guild"); int rangeID; RSTile bankTile, rangeTile; String name; Location(final int rangeID, RSTile bankTile, RSTile rangeTile, String name) { this.rangeID = rangeID; this.bankTile = bankTile; this.rangeTile = rangeTile; this.name = name; } boolean isRougeDen() { return this.equals(RougeDen); } boolean specialLocation() { return isRougeDen() || this.equals(COOKINGGUILD); } String getName() { return name; } int getRangeID() { return rangeID; } RSTile getBankTile() { return bankTile; } RSTile getRangeTile() { return rangeTile; } } private enum Fish { CRAYFISH("Raw crayfish", 13435, 1), SHRIMPS("Raw shrimps", 317, 1), SARDINE("Raw sardine", 327, 1), ACHOVIES("Raw anchovies", 321, 1), HERRING("Raw herring", 345, 5), MACHEREL("Raw mackerel", 353, 10), TROUT("Raw trout", 335, 15), COD("Raw cod", 341, 18), PIKE("Raw pike", 349, 20), SALMON("Raw salmon", 331, 25), TUNA("Raw tuna", 359, 30), KARAMBWN("Raw karambwan", 3142, 30), RAINBOW("Raw rainbow fish", 0, 35), CAVEELL("Raw cave eel", 5001, 38), LOBSTER("Raw lobster", 377, 40), BASS("Raw bass", 363, 43), SWORDFISH("Raw swordfish", 371, 45), MONKFISH("Raw monkfish", 7944, 62), SHARK("Raw shark", 383, 80), SEATURTLE("Raw sea turtle", 395, 82), CAVEFISH("Raw cavefish", 15264, 88), MONTARAY("Raw manta ray", 389, 91), ROCKTAIL("Raw rocktail", 15270, 93); String name; int ID; int lvl; private Fish(String name, int ID, int lvl) { this.name = name; this.ID = ID; this.lvl = lvl; } String getName() { return name; } int getID() { return ID; } int getLvl() { return lvl; } } private enum State { cook, bank, clickInterface, sleep, unkown, walkToBank, walkToRange } public class Methods { AntiBan AB = new AntiBan(); int noFood = 0; volatile boolean stop = false; boolean started = false; timer inventoryTimer = new timer(100); volatile boolean inventoryTimerRun = false; private Rectangle DEPOSIT_BANK_CACHE = null; Thread gatherInfo = new Thread(new Runnable() { public void run() { while (DEPOSIT_BANK_CACHE == null) { try { Thread.sleep(1000); if (bank.isOpen()) { RSComponent depoist = interfaces.getComponent(Bank.INTERFACE_BANK, Bank.INTERFACE_BANK_BUTTON_DEPOSIT_CARRIED_ITEMS); if (depoist.isValid()) { DEPOSIT_BANK_CACHE = depoist.getArea(); log("Detected Deposit all component Area!"); } } } catch (InterruptedException e) { } } } }); Thread mouseSpeedChanger = new Thread(new Runnable() { public void run() { while (!stop) { try { Thread.sleep(1000); mouse.setSpeed(random(4, 10)); } catch (InterruptedException ex) { } } } }); Thread inventoryHandler = new Thread(new Runnable() { public void run() { while (!stop) { try { Thread.sleep(1000); } catch (InterruptedException ex) { } if (!isActive()) { continue; } if (game.getTab() == Game.Tab.INVENTORY) { inventoryTimer = new timer(100); inventoryTimerRun = false; } else { if (!inventoryTimerRun) { inventoryTimer = new timer(random(4500, 9500)); inventoryTimerRun = true; } } if (!inventoryTimer.isRunning()) { game.openTab(Game.Tab.INVENTORY, random(0, 10) == 5); try { Thread.sleep(1000); } catch (InterruptedException ex) { } } } } }); Thread bankerWatcher = new Thread(new Runnable() { public void run() { while (!stop) { try { RSNPC banker = npcs.getNearest(Bank.NPC_BANKERS); int count = getCachedCount(fish.getID()); if (count < 3 && count > 0 && banker != null && !bank.isOpen()) { int dist = calc.distanceTo(banker); game.openTab(Game.Tab.INVENTORY, true); sleep(100, 200); if (dist < 5 && banker.isOnScreen()) { mouse.move(banker.getModel().getCentralPoint()); } } Thread.sleep(100); } catch (Throwable e) { } } } }); /** * Interacts with an object, uses model clicking. * @param o The RSObject to interact with. * @param str The action to perform to this object. * @param cond The condition. * @return true if the object was successfully clicked. otherwise false will be returned. */ public boolean interactObject(RSObject o, String str, Condition cond, final boolean hoverComp) { RSModel model = o.getModel(); if (o == null || model == null || str == null || str.isEmpty()) { return false; } Point p = null; for (int i = 0; i < 10; i++) { if ((p = model.getCentralPoint()).x == -1) { continue; } mouse.move(p, random(2, 4), random(2, 4)); sleep(100, 150); if (!menu.contains(str)) { continue; } String[] actions = menu.getItems(); if (actions[0].contains(o.getName()) && actions[0].contains(str)) { mouse.click(true); timer time = new timer((int) cond.Time()); while (time.isRunning() && !cond.isTrue()) { sleep(100); } return cond.isTrue(); } else { mouse.click(false); sleep(100, 200); if (menu.doAction(str + " " + o.getName())) { timer time = new timer((int) cond.Time()); if (hoverComp && DEPOSIT_BANK_CACHE != null) { int x = DEPOSIT_BANK_CACHE.x; int y = DEPOSIT_BANK_CACHE.y; int width = DEPOSIT_BANK_CACHE.width; int hight = DEPOSIT_BANK_CACHE.height; int x1 = random(x, width); int y1 = random(y, hight); mouse.move(x1, y1); } while (time.isRunning() && !cond.isTrue()) { sleep(100); } return cond.isTrue(); } } } return false; } public boolean interactRSNPC(RSNPC npc, String str, Condition cond, final boolean hoverComp) { RSModel model = npc.getModel(); if (npc == null || model == null) { return false; } Point p = null; for (int i = 0; i < 10; i++) { if ((p = model.getCentralPoint()).x == -1) { continue; } mouse.move(p, random(2, 4), random(2, 4)); sleep(100, 150); if (!menu.contains(str)) { continue; } String[] actions = menu.getItems(); if (actions[0].contains(str)) { mouse.click(true); timer time = new timer((int) cond.Time()); while (time.isRunning() && !cond.isTrue()) { sleep(100); } return cond.isTrue(); } else { mouse.click(false); sleep(100, 200); if (menu.doAction(str, npc.getName())) { timer time = new timer((int) cond.Time()); if (hoverComp && DEPOSIT_BANK_CACHE != null) { int x = DEPOSIT_BANK_CACHE.x; int y = DEPOSIT_BANK_CACHE.y; int width = DEPOSIT_BANK_CACHE.width; int hight = DEPOSIT_BANK_CACHE.height; int x1 = random(x, width + x); int y1 = random(y, hight + y); mouse.move(x1, y1); } while (time.isRunning() && !cond.isTrue()) { sleep(100); } return cond.isTrue(); } } } return false; } private boolean isCookingInterface() { return interfaces.get(905).getComponent(14).isValid(); } private boolean clickInterface() { return isCookingInterface() ? interfaces.get(905).getComponent(14).doClick() : false; } private boolean isFull() { return getCachedCount() == 28; } private int getCachedCount(int id) { int amount = 0; for (RSItem one : inventory.getItems(true)) { if (one.getID() != -1 && one.getID() == id) { amount++; } } return amount; } private int getCachedCount() { int amount = 0; for (RSItem one : inventory.getItems(true)) { if (one.getID() != -1) { amount++; } } return amount; } private boolean has(int i) { return getCachedCount(i) > 0; } boolean isCooking() { return has(fish.getID()) && System.currentTimeMillis() - activityTimer < 8500 || getMyPlayer().getAnimation() != -1; } private boolean useOnRange() { RSObject o = loc.equals(Location.ALKHARID) ? objects.getTopAt(con.AlkharidExactRangeTile) : objects.getNearest(loc.getRangeID()); if (o == null) { return false; } String action = "Use " + fish.getName() + " ->"; if (loc.equals(Location.ALKHARID)) { new Thread(new Runnable() { public void run() { camera.setCompass('e'); } }).start(); new Thread(new Runnable() { public void run() { camera.setPitch(true); } }).start(); } return interactObject(o, action, new Condition() { public long Time() { return random(2500, 4500); } public boolean isTrue() { return !getMyPlayer().isMoving() && isCookingInterface(); } }, false); } private State getState() { if (fish == null || loc == null) { return State.unkown; } if (loc.specialLocation()) { if (isCooking()) { return State.sleep; } if (!has(fish.getID())) { return State.bank; } if (isCookingInterface()) { return State.clickInterface; } if (!isCooking() && has(fish.getID())) { return State.cook; } return State.unkown; } if (isCooking()) { return State.sleep; } if (!has(fish.getID())) { if (inBankArea()) { return State.bank; } else { return State.walkToBank; } } else if (isCookingInterface()) { return State.clickInterface; } else { if (inRangeArea()) { return State.cook; } else { return State.walkToRange; } } } private boolean openBank() { if (loc.isRougeDen()) { camera.setPitch(true); return openRougeDenBank(); } else { if (calc.distanceTo(loc.getBankTile()) < 5) { RSObject bankBooth = objects.getNearest(ALLBANKS); if (bankBooth != null) { if (!bankBooth.isReachable()) { return false; } if (!bankBooth.isOnScreen()) { camera.turnTo(bankBooth, 30); sleep(100); return false; } Condition bankCond = new Condition() { public long Time() { return random(2000, 3500); } public boolean isTrue() { return !getMyPlayer().isMoving() && bank.isOpen(); } }; final boolean bankOpen = interactObject(bankBooth, "Use-quickly", bankCond, true); return bankOpen; } } else { if (calc.distanceTo(loc.getBankTile()) < 7) { walking.walkTileOnScreen(loc.bankTile); timer = new timer(2000); while (timer.isRunning() && calc.distanceTo(loc.getBankTile()) > 5) { sleep(10); } } else { web.getWeb(getMyPlayer().getLocation(), loc.getBankTile()).step(); sleep(100); } } } return false; } private void stop(String message) { log(message); stopScript(logOutOnFinish); } private boolean withdrawFish() { if (!bank.isOpen()) { return false; } RSItem item = bank.getItem(fish.getID()); if (item == null || item.getID() == -1) { return false; } RSComponent comp = item.getComponent(); if (comp == null) { return false; } int t = 0; while (comp.getRelativeX() == 0 && bank.getCurrentTab() != 0 && t < 5) { if (interfaces.getComponent(Bank.INTERFACE_BANK, Bank.INTERFACE_BANK_TAB[0]).doClick()) { sleep(random(800, 1300)); } t++; } if (!interfaces.scrollTo(comp, (Bank.INTERFACE_BANK << 16) + Bank.INTERFACE_BANK_SCROLLBAR)) { return false; } final int invCount = inventory.getCount(true); if (comp.interact("Withdraw-All")) { RSComponent close = interfaces.getComponent(Bank.INTERFACE_BANK, Bank.INTERFACE_BANK_BUTTON_CLOSE); if (close != null && close.isValid()) { close.doHover(); } final int newInvCount = inventory.getCount(true); return newInvCount > invCount; } return false; } private void bank() { if (!bank.isOpen()) { openBank(); return; } if (inventory.contains(fish.getID())) { bank.depositAllExcept(fish.getID()); return; } else if (inventory.getCount() > 0) { bank.depositAll(); timer = new timer(2000); while (timer.isRunning() && inventory.getCount() > 0) { sleep(100); } return; } if (bank.getCount(fish.getID()) > 0) { withdrawFish(); timer = new timer(2000); while (!inventory.contains(fish.getID()) && timer.isRunning()) { sleep(100); } if (inventory.contains(fish.getID())) { bank.close(); m.inventoryTimer = new timer(100); } return; } else { log("There's no food in your bank, check #" + noFood); sleep(1000, 2000); if (bank.getCount(fish.getID()) > 0) { log("Opps, we found food! SORRY!"); noFood = 0; return; } else { if (noFood == 2) { bank.close(); sleep(100, 650); } if (noFood > 3) { stop("No food. :/"); } noFood++; } } } String[] getFishesModel() { Fish[] all = Fish.values(); String[] models = new String[all.length]; int a = 0; for (final Fish i : all) { models[a] = i.getName(); a++; } return models; } String[] getLocationsModel() { Location[] all = Location.values(); String[] models = new String[all.length]; int a = 0; for (final Location i : all) { models[a] = i.getName(); a++; } return models; } private boolean cook() { if (!game.getTab().equals(Game.Tab.INVENTORY)) { game.openTab(Game.Tab.INVENTORY, random(0, 10) == 5 ? true : false); sleep(150, 250); // No CPU burning :D return false; } if (!has(fish.getID())) { game.openTab(Game.Tab.INVENTORY, random(0, 10) == 5 ? true : false); sleep(150, 250); // No CPU burning :D return false; } RSObject range = objects.getNearest(loc.getRangeID()); if (range == null || !range.isOnScreen() || calc.distanceTo(range) > 5) { return false; } if (!inventory.isItemSelected()) { inventory.getItem(fish.getID()).interact("Use"); sleep(120, 350); timer = new timer(2000); while (!inventory.isItemSelected() && timer.isRunning()) { sleep(10); } if (!inventory.isItemSelected()) { return false; } } if (inventory.getSelectedItemName().equals(fish.getName())) { return useOnRange(); } else { inventory.clickSelectedItem(); sleep(100, 450); } return false; } private boolean walkTo(RSTile tile) { //RSWeb path = web.getWeb(getMyPlayer().getLocation(), tile.randomize(1, 2)); RSTilePath path = walking.newTilePath(web.generateTilePath(getMyPlayer().getLocation(), tile)); if (path != null && path.isValid()) { p.status = "Walking to Range"; int dist = calc.distanceTo(path.getEnd()); while (isActive() && dist > 6) { path.traverse(); sleep(100); dist = calc.distanceTo(path.getEnd()); } return dist <= 5; } else { p.status = "Walking to Range NULL"; } return false; } private boolean inRangeArea() { RSObject range = objects.getNearest(loc.getRangeID()); return range != null && calc.distanceTo(range) < 5; } private final int[] ALLBANKS = {782, 2213, 4483, 6084, 11402, 11758, 12759, 14367, 19230, 24914, 25808, 26972, 27663, 29085, 34752, 35647, 36786, 9398, 20228, 26969, 36788, 4483, 12308, 21301, 27663, 42192}; private boolean inBankArea() { RSObject banks = objects.getNearest(ALLBANKS); return banks != null && calc.distanceTo(banks) < 5; } public class AntiBan { Thread clickafterInterface = new Thread(new Runnable() { public void run() { while (!stop) { do { try { Thread.sleep(1000); } catch (InterruptedException ex) { } } while (!clickAfterInterface); int r = random(0, 80); if (r < 10 || r > 13 && r < 20 || r > 50 && r < 55 || r > 70 && r < 78) { switch (random(0, 11)) { case 4: mouse.moveSlightly(); break; case 7: mouse.moveRandomly(random(300, 400)); break; case 10: mouse.moveOffScreen(); break; } } } } }); Thread mouseAB = new Thread(new Runnable() { public void run() { while (!stop) { do { try { Thread.sleep(1000); } catch (InterruptedException ex) { } } while (!doAB); if (cState.equals(State.sleep) || cState.equals(State.walkToBank) || cState.equals(State.walkToRange)) { final int r = random(0, 100); if ((r < 17 && r > 10) || (r < 80 && r > random(68, 74)) || r == random(1, 100)) { switch (random(0, 35)) { case 5: RSObject o = getRandomObject(); if (o != null && o.isOnScreen()) { o.interact("Examine", o.getName()); try { Thread.sleep(random(1000, 3500)); } catch (InterruptedException ex) { } } break; case 17: RSPlayer p = getRandomPlayer(); if (p != null && p.isOnScreen()) { RSModel m = p.getModel(); if (m != null) { mouse.click(m.getPoint(), 3, 3, false); try { Thread.sleep(random(900, 1900)); mouse.moveSlightly(); Thread.sleep(random(100, 250)); while (menu.isOpen()) { mouse.moveRandomly(300, 450); Thread.sleep(random(750, 950)); } } catch (InterruptedException e) { } } } break; case 20: mouse.moveOffScreen(); break; case 25: mouse.moveOffScreen(); try { timer aTimer = new timer(random(4500, 10000)); while (AB.doAB && aTimer.isRunning()) { Thread.sleep(100); } mouse.moveSlightly(); } catch (InterruptedException e) { } break; case 16: mouse.move(rX(), rY(), 3, 3); try { Thread.sleep(random(550, 950)); mouse.move(rX(), rY(), 3, 3); Thread.sleep(random(550, 950)); } catch (InterruptedException e) { } break; case 9: mouse.click(false, random(10, 350)); try { Thread.sleep(random(550, 950)); } catch (InterruptedException e) { } break; case 4: mouse.moveOffScreen(); try { Thread.sleep(random(550, 950)); mouse.move(rX(), rY()); Thread.sleep(random(550, 950)); } catch (InterruptedException ex) { } mouse.moveSlightly(); break; case 6: try { mouse.move(rX(), rY()); Thread.sleep(random(550, 950)); if (random(0, 10) == 5) { mouse.move(rX(), rY()); } Thread.sleep(random(550, 950)); mouse.move(rX(), rY()); Thread.sleep(random(550, 950)); if (random(0, 10) == 5) { mouse.move(rX(), rY()); } Thread.sleep(random(550, 950)); mouse.moveOffScreen(); try { Thread.sleep(4000, 9600); } catch (InterruptedException ignored) { } Thread.sleep(random(1550, 3550)); } catch (InterruptedException e) { } break; } } } } } }); Thread cameraAB = new Thread(new Runnable() { public void run() { while (!stop) { do { try { Thread.sleep(1000); } catch (InterruptedException e) { } } while (!doAB); if (cState.equals(State.sleep) || cState.equals(State.walkToBank) || cState.equals(State.walkToRange)) { final int r = random(0, 100); final boolean cooking = (r < 17 && r > 10) || (r < 80 && r > random(68, 74)) || r == random(1, 100); final boolean walkingAB = (r > 10 && r < 30) || (r < 100 && r > 90) || r == random(0, 100) || r == 45 || r == 60; if (cState.equals(State.sleep) ? cooking : walkingAB) { switch (random(0, 40)) { case 0: try { camera.turnTo(getRandomObject(), 20); mouse.moveRandomly(60, 160); break; } catch (NullPointerException ignored) { break; } case 11: try { camera.moveRandomly(random(1000, 2500)); break; } catch (NullPointerException ignored) { break; } case 20: try { if (camera.getPitch() < 2090) { camera.setPitch(random(2600, 3000)); break; } else { camera.setPitch(random(2088, 2500)); } } catch (NullPointerException ignored) { break; } case 32: try { camera.setPitch(random(120, 1200)); break; } catch (NullPointerException ignored) { break; } case 35: try { char[] chars = {'s', 'w', 'n', 'e'}; camera.setCompass(chars[random(0, 4)]); break; } catch (Exception ignored) { break; } case 16: if (camera.getAngle() > random(20, 10) || camera.getAngle() < random(340, 350)) { camera.setNorth(); } break; case 24: try { camera.turnTo(getRandomPlayer(), 20); break; } catch (NullPointerException ignored) { break; } case 2: int camAlt = camera.getZ(); char LR = KeyEvent.VK_LEFT; char UD; if (camAlt > -1600) { UD = KeyEvent.VK_UP; } else if (camAlt < -2215 || random(0, 2) == 0) { UD = KeyEvent.VK_DOWN; } else { UD = KeyEvent.VK_UP; } if (random(0, 2) == 0) { LR = KeyEvent.VK_RIGHT; } keyboard.pressKey(LR); try { Thread.sleep(random(50, 400)); } catch (Exception ignored) { keyboard.releaseKey(LR); } keyboard.pressKey(UD); try { Thread.sleep(random(300, 700)); } catch (Exception ignored) { keyboard.releaseKey(UD); keyboard.releaseKey(LR); } keyboard.releaseKey(UD); try { Thread.sleep(random(100, 400)); } catch (Exception ignored) { keyboard.releaseKey(LR); keyboard.releaseKey(UD); } keyboard.releaseKey(LR); break; } } } } } }); volatile boolean doAB, clickAfterInterface; RSObject getRandomObject() { try { for (RSObject random : objects.getAll(new Filter() { public boolean accept(RSObject t) { return t != null && t.isOnScreen(); } })) { if (random != null && random.isOnScreen()) { return random; } else { break; } } return null; } catch (NullPointerException ignored) { return null; } } RSPlayer getRandomPlayer() { for (RSPlayer random : players.getAll(new Filter() { public boolean accept(RSPlayer t) { return t.isOnScreen() && !t.getName().equals(getMyPlayer().getName()); } })) { if (random != null && random.isOnScreen()) { return random; } } return null; } int rX() { return random(0, random(10, game.getWidth())); } int rY() { return random(0, random(10, game.getHeight())); } private void checkEXP(final long time) { if (checkEXPTimer.isRunning()) { return; } log("AntiBan Debug : Checking cooking exp"); game.openTab(Game.Tab.STATS, false); skills.doHover(Skills.INTERFACE_COOKING); sleep((int) time); if (random(0, 10) != 5) { mouse.moveSlightly(); sleep(100, 350); } game.openTab(Game.Tab.INVENTORY, random(0, 10) != 5); checkEXPTimer = new timer(random(40000, 120000)); } } public boolean catherbyDoor() { return objects.getTopAt(con.CatherbyClosedDoorTile) == null; } public boolean isInRangeAreaCatherBy() { final int x = getMyPlayer().getLocation().getX(); final int y = getMyPlayer().getLocation().getY(); return y > 3438 && y < 3445 && x > 2814 && x < 2819; } public boolean openRougeDenBank() { if (bank.isOpen()) { return true; } RSNPC banker = npcs.getNearest("Emerald Benedict"); RSModel model = null; Point p = null; if (banker != null) { int dist = calc.distanceTo(banker); if (dist > 5) { // NOT ONSCREEN final RSTile tile = banker.getLocation(); if (dist < 8) { // WALK ON SCREEN walking.walkTileOnScreen(tile); timer = new timer(2500); while (timer.isRunning() && dist > 5) { dist = calc.distanceTo(banker); if (banker.isOnScreen() && (model = banker.getModel()) != null && (p = model.getCentralPoint()).x != -1) { mouse.move(p); sleep(random(100, 350)); } } if (dist > 5) { return false; } } else { walking.walkTo(tile); timer = new timer(2500); while (timer.isRunning() && dist > 5) { dist = calc.distanceTo(banker); if (banker.isOnScreen() && (model = banker.getModel()) != null && (p = model.getCentralPoint()).x != -1) { mouse.move(p); sleep(random(100, 350), random(400, 650)); } } if (dist > 5) { return false; } } } if (dist > 5) { return false; } final boolean bankOpen = interactRSNPC(banker, "Bank", new Condition() { public long Time() { return random(2000, 3500); } public boolean isTrue() { return !getMyPlayer().isMoving() && bank.isOpen(); } }, true); return bankOpen; } return false; } public boolean leveledUp() { return interfaces.get(740) != null && interfaces.get(740).getComponent(3).doClick(); } } public class Paint { private int total_cooked = 0, succeeful_cooked = 0, burnt_food = 0; private int total_hour = 0; private int xp_gained = 0, xp_hour; private int start_xp; private long startTime; private String status = "wtf?"; private double version = AutoCookerPro.class.getAnnotation(ScriptManifest.class).version(); Rectangle closeRect = new Rectangle(472, 350, 15, 15); volatile boolean changeAL, showPaint = true; volatile int alph = 255; DecimalFormat dc = new DecimalFormat("###,###,###"); private Color color1 = new Color(102, 0, 0, alph); private Color color2 = new Color(0, 0, 0, alph); private Color color3 = new Color(255, 153, 0, alph); private Color color4 = new Color(51, 102, 0, alph); Rectangle getChatRect() { Rectangle chatRect = interfaces.getComponent(137, 0).getArea(); Rectangle scrollRect = interfaces.getComponent(137, 59).getArea(); Rectangle nameRect = interfaces.getComponent(137, 55).getArea(); int x1 = chatRect.x + 1; int y1 = chatRect.y; int wid = chatRect.width - scrollRect.width; int high = chatRect.height - nameRect.height - 1; return new Rectangle(x1, y1, wid, high); } private Polygon getTilePolygon(RSTile tile) { if (tile == null || tile.getX() < 0 || tile.getY() < 0 || !calc.tileOnScreen(tile)) { return null; } Polygon pol = new Polygon(); Point nW = calc.tileToScreen(tile, 0, 1, 0); Point sW = calc.tileToScreen(tile, 0, 0, 0); Point nE = calc.tileToScreen(tile, 1, 1, 0); Point sE = calc.tileToScreen(tile, 1, 0, 0); pol = new Polygon(new int[]{nW.x, sW.x, sE.x, nE.x}, new int[]{nW.y, sW.y, sE.y, nE.y}, 4); return pol; } private void drawArea(Graphics2D g, RSArea area) { if (area != null) { RSTile[] tiles = area.getTileArray(); for (RSTile i : tiles) { Polygon p; if (i != null && (p = getTilePolygon(i)) != null) { g.fillPolygon(p); } } } } private void drawMouse(Graphics2D g) { Point clientCursor = mouse.getLocation(); while (!mousePath.isEmpty() && mousePath.peek().isUp()) { mousePath.remove(); } MousePathPoint mpp = new MousePathPoint(clientCursor.x, clientCursor.y, 450); if (mousePath.isEmpty() || !mousePath.getLast().equals(mpp)) { mousePath.add(mpp); } MousePathPoint lastPoint = null; for (MousePathPoint p : mousePath) { if (lastPoint != null) { g.setColor(p.getColor()); g.drawLine(p.x, p.y, lastPoint.x, lastPoint.y); } lastPoint = p; } while (!clicks.isEmpty() && clicks.peek().isUp()) { clicks.remove(); } long clickTime = mouse.getPressTime(); Point lastClickPos = mouse.getPressLocation(); if (clicks.isEmpty() || !clicks.getLast().equals(clickTime)) { clicks.add(new Click(lastClickPos.x, lastClickPos.y, clickTime)); } for (Click c : clicks) { c.drawTo(g); } g.setColor(Color.ORANGE); double radians = (System.currentTimeMillis() - startTime) / (2000 / (2 * Math.PI)) % Math.PI; g.drawLine((int) Math.round(clientCursor.x + 7 * Math.cos(radians)), (int) Math.round(clientCursor.y + 7 * Math.sin(radians)), (int) Math.round(clientCursor.x + 7 * Math.cos(radians + Math.PI)), (int) Math.round(clientCursor.y + 7 * Math.sin(radians + Math.PI))); g.drawLine((int) Math.round(clientCursor.x + 7 * Math.cos(radians + HALF_PI)), (int) Math.round(clientCursor.y + 7 * Math.sin(radians + HALF_PI)), (int) Math.round(clientCursor.x + 7 * Math.cos(radians + THREE_HALF_PI)), (int) Math.round(clientCursor.y + 7 * Math.sin(radians + THREE_HALF_PI))); g.setColor(Color.BLACK); g.drawOval(clientCursor.x - 8, clientCursor.y - 8, 16, 16); g.setColor(Color.BLACK); g.fillOval(clientCursor.x - 4, clientCursor.y - 4, 8, 8); g.setColor(new Color(0, 0, 0, 50)); g.fillOval(clientCursor.x - 8, clientCursor.y - 8, 16, 16); } public String[] getFormattedTime(final long timeMillis) { long millis = timeMillis; final long days = millis / (24 * 1000 * 60 * 60); millis -= days * (24 * 1000 * 60 * 60); final long hours = millis / (1000 * 60 * 60); millis -= hours * 1000 * 60 * 60; final long minutes = millis / (1000 * 60); millis -= minutes * 1000 * 60; final long seconds = millis / 1000; String dayString = String.valueOf(days); String hoursString = String.valueOf(hours); String minutesString = String.valueOf(minutes); String secondsString = String.valueOf(seconds); if (hours < 10) { hoursString = 0 + hoursString; } if (minutes < 10) { minutesString = 0 + minutesString; } if (seconds < 10) { secondsString = 0 + secondsString; } return new String[]{dayString, hoursString, minutesString, secondsString}; } public String getTTL() { int TTL = (int) (((double) skills.getExpToNextLevel(Skills.COOKING) / (double) p.xp_hour) * 3600000); String daysToLevel = getFormattedTime(TTL)[0]; String hoursToLevel = getFormattedTime(TTL)[1]; String minutesToLevel = getFormattedTime(TTL)[2]; String secondsToLevel = getFormattedTime(TTL)[3]; return daysToLevel + ":" + hoursToLevel + ":" + minutesToLevel + ":" + secondsToLevel; } public void drawStringWithShadow(final String text, final int x, final int y, final Graphics g) { final Color col = g.getColor(); g.setColor(new Color(0, 0, 0, 255)); g.drawString(text, x + 1, y + 1); g.setColor(col); g.drawString(text, x, y); } } @Override public int loop() { try { if (m.leveledUp()) { return 1000; } if (!m.started) { m.inventoryHandler.start(); m.AB.clickafterInterface.start(); m.AB.mouseAB.start(); m.AB.cameraAB.start(); if (loc.isRougeDen()) { m.bankerWatcher.start(); } m.started = true; return 100; } if (!game.isLoggedIn()) { game.login(); return 100; } if (!game.isFixed()) { m.stop("Run script in fixed mode!"); return -1; } if (loc == null || fish == null) { return -1; } mouse.setSpeed(random(4, 10)); if (getMyPlayer().getLocation().equals(con.RougeDenRangeTile)) { RSTile tile = locationIDS.cooking_location_tiles[random(0, 3)]; walking.walkTileOnScreen(tile); timer = new timer(3000); while (timer.isRunning() && getMyPlayer().getLocation().equals(con.RougeDenRangeTile) || getMyPlayer().isMoving()) { sleep(100); } if (getMyPlayer().getLocation().equals(con.RougeDenRangeTile)) { return 100; } } cState = m.getState(); p.status = cState.toString(); switch (cState) { case clickInterface: if (m.clickInterface()) { m.AB.doAB = false; m.AB.clickAfterInterface = true; mouse.moveSlightly(); timer = new timer(1500); while (timer.isRunning() && m.isCookingInterface()) { sleep(100); } } break; case bank: m.AB.doAB = false; m.AB.clickAfterInterface = false; m.bank(); break; case cook: if (loc.isRougeDen()) { RSObject range = objects.getTopAt(loc.getRangeTile()); if (range == null) { break; } int dist = calc.distanceTo(range); if (!range.isOnScreen() || dist > 5) { if (dist > 7) { walking.walkTo(loc.getRangeTile()); timer = new timer(2500); while (timer.isRunning() && dist > 5) { dist = calc.distanceTo(loc.getRangeTile()); sleep(100); } } else { walking.walkTileOnScreen(loc.getRangeTile()); timer = new timer(2500); while (timer.isRunning() && dist > 5) { dist = calc.distanceTo(loc.getRangeTile()); sleep(100); } } break; } } if (bank.isOpen()) { bank.close(); sleep(100, 350); return 100; } m.cook(); break; case sleep: m.AB.doAB = true; m.AB.clickAfterInterface = false; int i = random(0, 60); if (i > 10 && i < 20) { if (random(0, 10) == 5) { forceCamera.start(); } int count = m.getCachedCount(fish.getID()); if (count <= 4) { m.AB.checkEXP(random(1000, 4500)); } else { m.AB.checkEXP(random(1000, 6500)); } } break; case walkToBank: m.AB.doAB = true; walking.walkTo(loc.getBankTile()); i = random(0, 40); if (i > 10 && i < 20) { if (random(0, 10) == 5) { forceCamera.start(); } int time = 0; int dist = calc.distanceTo(loc.getBankTile()); if (dist > 8) { time = random(1200, 2500); } else { time = random(850, 1500); } m.AB.checkEXP(time); } break; case walkToRange: m.AB.doAB = true; // m.walkTo(loc.getRangeTile()); walking.walkTo(loc.getRangeTile()); i = random(0, 40); if (i > 10 && i < 20) { if (random(0, 10) == 5) { forceCamera.start(); } int time = 0; int dist = calc.distanceTo(loc.getRangeTile()); if (dist > 8) { time = random(1200, 2500); } else { time = random(850, 1500); } m.AB.checkEXP(time); } break; } } catch (Throwable e) { } return 100; } @Override public void onFinish() { m.stop = true; log(Color.ORANGE, "Run Time: " + Timer.format(System.currentTimeMillis() - p.startTime)); log(Color.ORANGE, "Cooked: " + p.dc.format(p.total_cooked)); log(Color.ORANGE, "Gained: " + p.dc.format(p.xp_gained) + " XP" + " /HOUR: " + p.dc.format(p.xp_hour)); env.saveScreenshot(true); log(Color.BLUE, "I JUST TOOK SCREENSHOT, PLEASE POST IT ON MY FEEDBACK THREAD"); } private final BasicStroke stroke1 = new BasicStroke(1); private final Font font1 = new Font("Verdana", 1, 13); private final Font font2 = new Font("Verdana", 1, 11); public void onRepaint(Graphics g1) { p.xp_gained = skills.getCurrentExp(Skills.COOKING) - p.start_xp; p.xp_hour = (int) ((p.xp_gained) * 3600000D / (System.currentTimeMillis() - p.startTime)); p.total_hour = (int) ((p.total_cooked) * 3600000D / (System.currentTimeMillis() - p.startTime)); Graphics2D g = (Graphics2D) g1; Rectangle rect = p.getChatRect(); Rectangle r = p.closeRect; g.setColor(p.color3); g.drawString(p.status, 100, 100); if (p.showPaint) { g.setColor(p.color1); g.fill(p.getChatRect()); g.setColor(p.color2); g.setStroke(stroke1); g.drawRect(rect.x, rect.y, rect.width, rect.height); g.drawLine(6, 367, 496, 367); g.setFont(font1); g.setColor(p.color3); p.drawStringWithShadow(".:. AutoCookerPro .:. V" + p.version + " By Emeleo", 134, 361, g); g.setFont(font2); int x = 15; int y = 380; int dif = 15; p.drawStringWithShadow("Time Running: " + org.rsbot.script.util.Timer.format(System.currentTimeMillis() - p.startTime), x, y, g); g.setColor(p.color3); p.drawStringWithShadow("Total Cooked: " + p.dc.format(p.total_cooked), x, y += dif, g); p.drawStringWithShadow("/hr: " + p.dc.format(p.total_hour), 30, y += dif, g); p.drawStringWithShadow("Burnt: " + p.dc.format(p.burnt_food), x, y += dif, g); p.drawStringWithShadow("Successful: " + p.dc.format(p.succeeful_cooked), x, y += dif, g); x = 200; y = 380; p.drawStringWithShadow("XP Gained: " + p.dc.format(p.xp_gained), x, y, g); p.drawStringWithShadow("/hr: " + p.dc.format(p.xp_hour), 215, y += dif, g); p.drawStringWithShadow("Level: " + skills.getCurrentLevel(Skills.COOKING) + "/" + Skills.getLevelAt(p.start_xp), x, y += dif, g); p.drawStringWithShadow("XP to Level: " + p.dc.format(skills.getExpToNextLevel(Skills.COOKING)), x, y += dif, g); p.drawStringWithShadow("Time till Level: " + (p.xp_gained > 0 ? p.getTTL() : ""), x, y += dif, g); if (fish != null && loc != null) { int x1 = 365; if (loc.equals(Location.COOKINGGUILD)) { x1 = 350; } g.drawString("Fish: " + fish.getName(), x1, 380); g.drawString("Location: " + loc.getName(), x1, 395); } g.setColor(p.color4); g.fillRect(r.x, r.y, r.width, r.height); g.setColor(p.color2); g.drawRect(r.x, r.y, r.width, r.height); g.drawLine(r.x + 2, r.y + 2, r.x + r.height - 2, r.y + r.width - 2); g.drawLine(r.x + 2, r.y + r.height - 2, r.x + r.width - 2, r.y + 2); } else { g.setColor(p.color4); g.fill3DRect(r.x, r.y, r.width, r.height, true); g.setColor(p.color2); g.fillOval(r.x, r.y, r.width, r.height); } p.drawMouse((Graphics2D) g); } public void messageReceived(MessageEvent e) { if (e.getID() == MessageEvent.MESSAGE_ACTION) { final String message = e.getMessage(); if (message.contains("manage to") || message.contains("roast a") || message.contains("successfully") || message.contains("cook some")) { activityTimer = System.currentTimeMillis(); p.total_cooked++; p.succeeful_cooked++; } if (message.contains("eat") || message.contains("interesting happens")) { activityTimer = 0; } if (message.contains("accidentally burn") || message.contains("accidentally burnt")) { activityTimer = System.currentTimeMillis(); p.total_cooked++; p.burnt_food++; } } } public static class timer { long start = 0; int timeOut = 0; public timer(int timeOut) { start = System.currentTimeMillis(); this.timeOut = timeOut; } public boolean isRunning() { return System.currentTimeMillis() - start < timeOut; } } /** * From now on, all credits goes to Enfilde */ private final double HALF_PI = Math.PI * 0.5, THREE_HALF_PI = Math.PI * 1.5; private int toColor(double d) { return Math.min(255, Math.max(0, (int) d)); } private class Click { private long clickTime, finishTime; private double radians; private int x, y; public Click(int x, int y, long clickTime) { this.clickTime = clickTime; finishTime = clickTime + 5000; radians = (clickTime - p.startTime) / (2000 / (2 * Math.PI)) % Math.PI; this.x = x; this.y = y; } public boolean isUp() { return System.currentTimeMillis() > finishTime; } public void drawTo(Graphics2D g) { int alpha = (int) ((finishTime - System.currentTimeMillis()) / 5000.0 * 255); if (alpha < 0) { return; } g.setColor(new Color(0, 0, 0, alpha)); g.drawLine((int) (x + 5 * Math.cos(radians)), (int) (y + 5 * Math.sin(radians)), (int) (x + 5 * Math.cos(radians + Math.PI)), (int) (y + 5 * Math.sin(radians + Math.PI))); g.drawLine((int) (x + 5 * Math.cos(radians + HALF_PI)), (int) (y + 5 * Math.sin(radians + HALF_PI)), (int) (x + 5 * Math.cos(radians + THREE_HALF_PI)), (int) (y + 5 * Math.sin(radians + THREE_HALF_PI))); } public boolean equals(long time) { return clickTime == time; } } private class MousePathPoint extends Point { private static final long serialVersionUID = 1L; private long finishTime; private double lastingTime; public MousePathPoint(int x, int y, int lastingTime) { super(x, y); this.lastingTime = lastingTime; finishTime = System.currentTimeMillis() + lastingTime; } public boolean isUp() { return System.currentTimeMillis() > finishTime; } public Color getColor() { return new Color(0, 0, 0, toColor(256 * ((finishTime - System.currentTimeMillis()) / lastingTime))); } } public class AutoCookerProGUI extends JFrame { public boolean start, cancel; public AutoCookerProGUI() { initComponents(); } private void startButtonActionPerformed(ActionEvent e) { start = true; frame1.setVisible(false); } private void cancelButtonActionPerformed(ActionEvent e) { cancel = true; frame1.setVisible(false); } private void visitThreadActionPerformed(ActionEvent e) throws IOException { try { Desktop.getDesktop().browse(new URI(AutoCookerPro.class.getAnnotation(ScriptManifest.class).website())); } catch (URISyntaxException ex) { } visitThread.setEnabled(false); } private void initComponents() { frame1 = new JFrame(); tabbedPane1 = new JTabbedPane(); panel1 = new JPanel(); label2 = new JLabel(); fishType = new JComboBox(); locationType = new JComboBox(); label3 = new JLabel(); separator2 = new JSeparator(); startButton = new JButton(); cancelButton = new JButton(); checkBox1 = new JCheckBox(); panel2 = new JPanel(); scrollPane1 = new JScrollPane(); textPane1 = new JTextPane(); label1 = new JLabel(); visitThread = new JButton(); panel3 = new JPanel(); scrollPane2 = new JScrollPane(); changeLog = new JTextPane(); //======== frame1 ======== { Container frame1ContentPane = frame1.getContentPane(); frame1ContentPane.setLayout(null); frame1.setResizable(false); frame1.setTitle("AutoCooker GUI"); frame1.setVisible(true); frame1.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); this.setCursor(new Cursor(Cursor.CROSSHAIR_CURSOR)); //======== tabbedPane1 ======== { //======== panel1 ======== { panel1.addPropertyChangeListener(new java.beans.PropertyChangeListener() { public void propertyChange(java.beans.PropertyChangeEvent e) { if ("border".equals(e.getPropertyName())) { throw new RuntimeException(); } } }); panel1.setLayout(null); //---- label2 ---- label2.setText("Select fish type"); panel1.add(label2); label2.setBounds(55, 25, 80, 20); panel1.add(fishType); fishType.setBounds(175, 25, 95, fishType.getPreferredSize().height); fishType.setModel(new DefaultComboBoxModel(m.getFishesModel())); panel1.add(locationType); locationType.setBounds(175, 55, 95, locationType.getPreferredSize().height); locationType.setModel(new DefaultComboBoxModel(m.getLocationsModel())); //---- label3 ---- label3.setText("Location"); panel1.add(label3); label3.setBounds(55, 60, 45, label3.getPreferredSize().height); panel1.add(separator2); separator2.setBounds(0, 110, 360, 7); //---- startButton ---- startButton.setText("Start"); startButton.setFont(new Font("Times New Roman", Font.BOLD, 14)); startButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { startButtonActionPerformed(e); } }); panel1.add(startButton); startButton.setBounds(20, 120, 155, startButton.getPreferredSize().height); //---- cancelButton ---- cancelButton.setText("Cancel"); cancelButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { cancelButtonActionPerformed(e); } }); panel1.add(cancelButton); cancelButton.setBounds(195, 120, 135, 25); //---- checkBox1 ---- checkBox1.setText("Logout on finish?"); checkBox1.setSelected(true); panel1.add(checkBox1); checkBox1.setBounds(50, 85, checkBox1.getPreferredSize().width, 15); { // compute preferred size Dimension preferredSize = new Dimension(); for (int i = 0; i < panel1.getComponentCount(); i++) { Rectangle bounds = panel1.getComponent(i).getBounds(); preferredSize.width = Math.max(bounds.x + bounds.width, preferredSize.width); preferredSize.height = Math.max(bounds.y + bounds.height, preferredSize.height); } Insets insets = panel1.getInsets(); preferredSize.width += insets.right; preferredSize.height += insets.bottom; panel1.setMinimumSize(preferredSize); panel1.setPreferredSize(preferredSize); } } tabbedPane1.addTab("Settings", panel1); //======== panel2 ======== { panel2.setLayout(null); //======== scrollPane1 ======== { //---- textPane1 ---- textPane1.setEditable(false); textPane1.setText("To request a location, you need to send me some IDS, RSTiles.\n1) Click View -> Player postion then go to the middle of the desired bank, get me the X,Y.\n2) Go to the middle location of the range/fire, get me the X,Y\n3) Click View -> Objects then get me the ID of the range/fire.\n\nVisit my thread [Button below] and reply using the following format\n\nBank tile: [step 1]\nRange tile: [step 2]\nRange ID: [step 3]\n\nAnd I WILL add the location.\n\n-------------------------------\n\nTo request a fish, please visit my thread and post the ID of the fish, along with its name and I will add it."); scrollPane1.setViewportView(textPane1); } panel2.add(scrollPane1); scrollPane1.setBounds(15, 25, 325, 105); //---- label1 ---- label1.setText("Read below to make a proper request for location addition."); panel2.add(label1); label1.setBounds(25, 5, 290, label1.getPreferredSize().height); //---- visitThread ---- visitThread.setText("Visit Thread"); visitThread.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try { visitThreadActionPerformed(e); } catch (IOException ex) { } } }); panel2.add(visitThread); visitThread.setBounds(110, 135, 125, visitThread.getPreferredSize().height); { // compute preferred size Dimension preferredSize = new Dimension(); for (int i = 0; i < panel2.getComponentCount(); i++) { Rectangle bounds = panel2.getComponent(i).getBounds(); preferredSize.width = Math.max(bounds.x + bounds.width, preferredSize.width); preferredSize.height = Math.max(bounds.y + bounds.height, preferredSize.height); } Insets insets = panel2.getInsets(); preferredSize.width += insets.right; preferredSize.height += insets.bottom; panel2.setMinimumSize(preferredSize); panel2.setPreferredSize(preferredSize); } } tabbedPane1.addTab("Suggest a location/food", panel2); //======== panel3 ======== { panel3.setLayout(null); //======== scrollPane2 ======== { //---- changeLog ---- changeLog.setText("Last update: 11 June 2011 includes: \n Added Cooking Guild - Thanks to Kaji \n Fixed miss clicks."); changeLog.setEditable(false); scrollPane2.setViewportView(changeLog); } panel3.add(scrollPane2); scrollPane2.setBounds(15, 10, 320, 130); { // compute preferred size Dimension preferredSize = new Dimension(); for (int i = 0; i < panel3.getComponentCount(); i++) { Rectangle bounds = panel3.getComponent(i).getBounds(); preferredSize.width = Math.max(bounds.x + bounds.width, preferredSize.width); preferredSize.height = Math.max(bounds.y + bounds.height, preferredSize.height); } Insets insets = panel3.getInsets(); preferredSize.width += insets.right; preferredSize.height += insets.bottom; panel3.setMinimumSize(preferredSize); panel3.setPreferredSize(preferredSize); } } tabbedPane1.addTab("Change log", panel3); } frame1ContentPane.add(tabbedPane1); tabbedPane1.setBounds(0, 0, 360, 190); { // compute preferred size Dimension preferredSize = new Dimension(); for (int i = 0; i < frame1ContentPane.getComponentCount(); i++) { Rectangle bounds = frame1ContentPane.getComponent(i).getBounds(); preferredSize.width = Math.max(bounds.x + bounds.width, preferredSize.width); preferredSize.height = Math.max(bounds.y + bounds.height, preferredSize.height); } Insets insets = frame1ContentPane.getInsets(); preferredSize.width += insets.right; preferredSize.height += insets.bottom; frame1ContentPane.setMinimumSize(preferredSize); frame1ContentPane.setPreferredSize(preferredSize); } frame1.pack(); frame1.setLocationRelativeTo(frame1.getOwner()); } // JFormDesigner - End of component initialization //GEN-END:initComponents } private Fish getSelectedFish() { String food = gui.fishType.getSelectedItem().toString(); for (Fish i : Fish.values()) { if (i.getName().equalsIgnoreCase(food)) { return i; } } return null; } private Location getSelectedLocation() { String location = gui.locationType.getSelectedItem().toString(); for (Location i : Location.values()) { if (i.getName().equalsIgnoreCase(location)) { return i; } } return null; } private JFrame frame1; private JTabbedPane tabbedPane1; private JPanel panel1; private JLabel label2; private JComboBox fishType; private JComboBox locationType; private JLabel label3; private JSeparator separator2; private JButton startButton; private JButton cancelButton; private JCheckBox checkBox1; private JPanel panel2; private JScrollPane scrollPane1; private JTextPane textPane1; private JLabel label1; private JButton visitThread; private JPanel panel3; private JScrollPane scrollPane2; private JTextPane changeLog; } public class ForceCamera extends Thread { @Override public void run() { try { final int i = random(0, 7); Thread.sleep(2000); switch (i) { case 1: camera.moveRandomly(random(850, 1500)); ForceCamera.sleep(random(650, 1200)); break; case 2: camera.turnTo(m.AB.getRandomPlayer(), random(0, 50)); ForceCamera.sleep(random(650, 1200)); break; case 3: camera.setPitch(random(0, 100)); ForceCamera.sleep(random(650, 1200)); break; case 4: camera.setAngle(random(400, 3000)); ForceCamera.sleep(random(650, 1200)); break; case 5: int camAlt = camera.getZ(); char LR = KeyEvent.VK_LEFT; char UD; if (camAlt > -1600) { UD = KeyEvent.VK_UP; } else if (camAlt < -2215 || random(0, 2) == 0) { UD = KeyEvent.VK_DOWN; } else { UD = KeyEvent.VK_UP; } if (random(0, 2) == 0) { LR = KeyEvent.VK_RIGHT; } keyboard.pressKey(LR); try { Thread.sleep(random(50, 400)); } catch (Exception ignored) { } keyboard.pressKey(UD); try { Thread.sleep(random(300, 700)); } catch (Exception ignored) { } keyboard.releaseKey(UD); try { Thread.sleep(random(100, 400)); } catch (Exception ignored) { } keyboard.releaseKey(LR); break; case 6: camera.turnTo(m.AB.getRandomObject(), random(0, 50)); ForceCamera.sleep(random(650, 1200)); break; } } catch (Throwable ignored) { } } } }