rendered paste bodyimport java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Insets;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.MouseEvent;
import java.awt.event.MouseMotionListener;
import javax.swing.*;
import org.rsbot.event.events.MessageEvent;
import org.rsbot.event.listeners.MessageListener;
import org.rsbot.event.listeners.PaintListener;
import org.rsbot.gui.AccountManager;
import org.rsbot.script.Script;
import org.rsbot.script.ScriptManifest;
import org.rsbot.script.methods.Environment;
import org.rsbot.script.methods.Equipment;
import org.rsbot.script.methods.Game;
import org.rsbot.script.methods.Skills;
import org.rsbot.script.wrappers.RSArea;
import org.rsbot.script.wrappers.RSGroundItem;
import org.rsbot.script.wrappers.RSItem;
import org.rsbot.script.wrappers.RSNPC;
import org.rsbot.script.wrappers.RSObject;
import org.rsbot.script.wrappers.RSPath;
import org.rsbot.script.wrappers.RSTile;
/**
* @author jtryba
* @version 1.29 (c)2010-2011 jtryba, No one except jtryba has the right to
* modify and/or spread this script without the permission of jtryba.
* I'm not held responsible for any damage that may occur to your
* property.
*/
@ScriptManifest(authors = { "jtryba" }, keywords = "cooking", name = "autoCook", version = 1.29, description = ("cooks anything in al-karid"))
public class autoCook extends Script implements PaintListener, MessageListener,
MouseMotionListener {
// script constants
public static final RSArea[] area = {
new RSArea(new RSTile(3250, 3150), new RSTile(3281, 3200)), // al-karid
new RSArea(new RSTile(3035, 4960), new RSTile(3060, 4992)), // rouges-den
new RSArea(new RSTile(2790, 3420), new RSTile(2840, 3465)) // catherby
};
public static final RSTile[] ntr = { new RSTile(3273, 3180),
new RSTile(3043, 4972), new RSTile(2817, 3443) };
public static final RSTile[] ntb = { new RSTile(3269, 3166),
new RSTile(3269, 3167), new RSTile(3269, 3168),
new RSTile(3269, 3169), new RSTile(3043, 4972),
new RSTile(2809, 3441), new RSTile(2810, 3441),
new RSTile(2811, 3441) };
/*-Al-Karid-----------------------------------------------------------*/
public static final RSTile alKaridRangeTiles[] = { new RSTile(3271, 3180),
new RSTile(3271, 3181) };
public static final RSTile alKaridBankTiles[] = { new RSTile(3268, 3166),
new RSTile(3268, 3167), new RSTile(3268, 3168),
new RSTile(3268, 3169) };
/*--------------------------------------------------------------------*/
/*-Rouges-Den---------------------------------------------------------*/
public static final RSTile rougesDenRangeTiles[] = { new RSTile(3043, 4973) };
public static final int bankerNpcID = 2271;
/*--------------------------------------------------------------------*/
/*-Catherby-----------------------------------------------------------*/
public static final RSTile catherbyRangeTiles[] = { new RSTile(2817, 3444),
new RSTile(2818, 3444) };
public static final RSTile catherbyBankTiles[] = { new RSTile(2809, 3442),
new RSTile(2810, 3442), new RSTile(2811, 3442) };
public static final RSTile doorTile = new RSTile(2816, 3438);
/*--------------------------------------------------------------------*/
public static final int COOKING_GAUNTLENTS_ID = 775;
public static final int ids[] = { 3132, 2138, 13435, 317, 327, 345, 321,
353, 335, 341, 349, 331, 359, 377, 363, 371, 7944, 383, 395, 15270,
2287 };
public static final String names[] = { "Raw beef", "Raw chicken",
"Raw crayfish", "Raw shrimps", "Raw sardine", "Raw herring",
"Raw anchovies", "Raw mackerel", "Raw trout", "Raw cod",
"Raw pike", "Raw salmon", "Raw tuna", "Raw lobster", "Raw bass",
"Raw swordfish", "Raw monkfish", "Raw shark", "Raw sea turtle",
"Raw rocktail", "Uncooked pizza" };
public final static String doorAction = "Open Door";
final private cameraHeight camHeight = new cameraHeight();
final private cameraRotate camRotate = new cameraRotate();
private enum State {
ATRANGE, TORANGE, BANKING, TOBANK, LOGOUT, TOLOCATION, WAIT
};
/*-rewards box-*/
public static final int boxID = 14664;
public static final int coinID = 995;
public boolean doRewardPickUp = false;
public boolean hadToDrop = false;
public int droppedID = 0;
public String droppedName = "";
// script variables
GUI gui;
public int startExp = 0;
public int startExp2 = 0;
public int lastExp = 0;
public int rawExp = 0;
public int rawExp2 = 0;
public int rawID = 0;
public int rawID2 = 0;
public int levelsGained = 0;
public int burnt = 0;
public int cooked = 0;
public int mouseSpeed = 0;
public int currentMouseSpeed = 0;
public long lastCookedTime = 0;
public long lastCheck = 0;
public long startTime = 0;
public long afkTime = 0;
public boolean bankNpc = false;
public boolean cook2ids = false;
public boolean showMouse = true;
public boolean hoverMouse = false;
public boolean clickContinue = false;
public boolean firstRun = true;
public boolean startScript = false;
public boolean outOfRaw = false;
public boolean customID = false;
public boolean customID2 = false;
public boolean dropCoins = false;
public boolean afk = false;
public boolean useafk = false;
public Point mousePoint;
public RSTile nextToBank = null;
public RSTile bankTile = null;
public RSTile nextToRange = null;
public RSTile rangeTile = null;
public RSArea location = null;
public String status = "";
public String rawName = "";
public String rawName2 = "";
public String t = "";
private State getState() {
if (game.isLoggedIn()) {
if (outOfRaw) {
return State.LOGOUT;
}
if (atLocation()) {
if (hasRaw()) {
if (atRange()) {
return State.ATRANGE;
} else {
return State.TORANGE;
}
} else {
if (atBank()) {
return State.BANKING;
} else {
return State.TOBANK;
}
}
} else {
if (nearLocation()) {
return State.TOLOCATION;
} else {
return State.LOGOUT;
}
}
}
return State.WAIT;
}
@Override
public int loop() {
if (game.isLoggedIn()
&& skills.getCurrentLevel(Skills.CONSTITUTION) > 1) {
currentMouseSpeed = mouseSpeed + random(-2, 3);
if (currentMouseSpeed < 0) {
currentMouseSpeed = 0;
} else if (currentMouseSpeed > 10) {
currentMouseSpeed = 10;
}
mouse.setSpeed(currentMouseSpeed);
if (firstRun) {
firstRun();
firstRun = false;
return 50;
}
if (rawExp == 0 && skills.getCurrentExp(Skills.COOKING) > startExp
&& startExp2 == 0) {
rawExp = totalExp();
}
if (rawExp == 0 && skills.getCurrentExp(Skills.COOKING) > startExp2
&& startExp2 > 0) {
rawExp = skills.getCurrentExp(Skills.COOKING) - startExp2;
}
if (outOfRaw && cook2ids) {
if (rawID != rawID2) {
rawID = rawID2;
rawName = rawName2;
rawExp = 0;
startExp2 = skills.getCurrentExp(Skills.COOKING);
outOfRaw = false;
return 100;
}
}
if (System.currentTimeMillis() < afkTime) {
status = "[AB] - AFK for: "
+ formatTime((int) (afkTime - System
.currentTimeMillis()));
return 100;
} else {
if (afk) {
camHeight.pause = false;
camRotate.pause = false;
status = t;
afk = false;
env.setUserInput(Environment.INPUT_KEYBOARD);
return 100;
}
}
checkRun();
if (camera.getPitch() < 75) {
camera.setPitch(true);
return 50;
}
if (clickContinue && interfaces.canContinue()) {
env.saveScreenshot(true);
interfaces.clickContinue();
mouse.moveSlightly();
clickContinue = false;
return random(500, 1000);
}
if (doRewardPickUp && itemPresent(boxID, 5)) {
status = "RewardBox";
if (inventory.isFull()) {
hadToDrop = true;
final int randomSpot = random(15, 28);
final RSItem dropped = inventory.getItemAt(randomSpot);
if (dropped != null) {
droppedID = dropped.getID();
droppedName = dropped.getName().substring(12);
log("Dropped ID: " + droppedID);
log("Dropped Name: " + droppedName);
dropped.doAction("Drop " + droppedName);
return random(1750, 2100);
}
return random(10, 50);
} else {
RSGroundItem rewardBox = groundItems.getNearest(boxID);
if (rewardBox != null) {
rewardBox.doAction("Take " + "Random event gift");
log("Picked up reward box");
return random(1750, 2200);
}
return random(10, 50);
}
}
if (doRewardPickUp && hadToDrop && dropCoins
&& inventory.contains(coinID) && inventory.isFull()) {
RSItem coins = inventory.getItem(coinID);
if (coins != null) {
coins.doAction("Drop");
return random(1000, 1500);
}
}
if (doRewardPickUp && hadToDrop && itemPresent(droppedID, 5)
&& !inventory.isFull()) {
status = "RewardBox";
final RSGroundItem dropped = groundItems.getNearest(droppedID);
if (dropped != null) {
dropped.doAction("Take " + droppedName);
sleep(random(2500, 3000));
}
if (!itemPresent(droppedID, 5)) {
droppedID = 0;
droppedName = "";
hadToDrop = false;
}
return random(10, 50);
}
switch (getState()) {
case ATRANGE:
status = "Cooking";
if (getMyPlayer().getAnimation() != -1) {
if (random(1, 100) < 5) {
switch (random(1, 10)) {
case 1:
mouse.moveSlightly();
sleep(random(250, 500));
break;
case 2:
mouse.moveSlightly();
sleep(random(1250, 1500));
mouse.moveSlightly();
sleep(random(250, 500));
break;
case 3:
if (random(1, 25) < 5) {
t = status;
status = "[AB] - Checking Cooking skill";
if (game.getCurrentTab() != Game.TAB_STATS) {
game.openTab(Game.TAB_STATS);
sleep(1000, 1500);
}
skills.doHover(Skills.INTERFACE_COOKING);
sleep(random(4000, 9000));
status = t;
}
break;
case 4:
mouse.moveSlightly();
sleep(random(250, 500));
break;
case 5:
mouse.moveSlightly();
mouse.moveSlightly();
sleep(random(100, 1100));
mouse.moveSlightly();
sleep(random(250, 500));
break;
case 6:
if (random(1, 100) < 5
&& inventory.getCount(rawID) > 7 && useafk) {
camHeight.pause = true;
camRotate.pause = true;
t = status;
afkTime = System.currentTimeMillis()
+ random(random(5000, 10000), random(
60000, 120000));
status = "[AB] - AFK for: "
+ formatTime((int) afkTime);
mouse.moveOffScreen();
afk = true;
env.setUserInput(0);
return 100;
}
break;
}
}
lastCookedTime = System.currentTimeMillis();
}
if (interfaces.get(916).isValid()
&& interfaces.getComponent(905, 14).isValid()) {
interfaces.getComponent(905, 14).doClick();
mouse.moveSlightly();
lastCookedTime = System.currentTimeMillis();
return random(1000, 2000);
} else {
if ((System.currentTimeMillis() - lastCookedTime) > 4000) {
if (bank.isOpen()) {
bank.close();
return random(100, 500);
}
if (inventory.isItemSelected()) {
RSObject range = objects.getTopAt(rangeTile);
if (range != null) {
if (bankNpc) {
if (range.doAction("Use " + rawName
+ " -> Fire")) {
mouse.move(201, 368, 66, 38);
return random(1000, 2000);
}
} else {
if (range.doAction("Use " + rawName
+ " -> Range")) {
mouse.move(201, 368, 66, 38);
return random(1000, 2000);
}
}
return random(100, 500);
}
} else {
RSItem raw = inventory.getItem(rawID);
if (raw != null) {
if (raw.doAction("Use " + rawName)) {
return random(500, 1000);
}
return random(100, 500);
}
}
}
return 100;
}
case TORANGE:
camRotate.pause = true;
if (!getMyPlayer().isMoving() && !cameraIsMoving()) {
if (location.contains(ntb[5])) { // catherby
if (doorOpen()) {
status = "Walking to range";
walking.walkTo(nextToRange);
} else {
if (atDoor()) {
camera.setCompass('s');
if (camera.getPitch() > 50) {
camera.setPitch(25);
}
Point p = calc.tileToScreen(doorTile);
if (p != null) {
status = "Opening door";
mouse.move(p, 5, 5);
sleep(random(250, 500));
if (menu.contains(doorAction)) {
if (menu.getIndex(doorAction) > 0) {
mouse.click(false);
sleep(random(250, 500));
if (menu.contains(doorAction)) {
menu.doAction(doorAction);
} else {
mouse.moveSlightly();
}
} else {
mouse.click(true);
}
}
}
} else {
status = "Walking to door";
walking.walkTo(new RSTile(doorTile.getX(),
doorTile.getY() - 1));
}
}
} else {
status = "Walking to range";
walking.walkTo(nextToRange);
}
}
camRotate.pause = false;
return random(500, 1000);
case TOBANK:
camRotate.pause = true;
if (!getMyPlayer().isMoving() && !cameraIsMoving()) {
if (location.contains(ntb[5])) { // catherby
if (doorOpen()) {
status = "Walking to bank";
walking.walkTo(nextToBank);
} else {
camera.setCompass('s');
if (camera.getPitch() > 50) {
camera.setPitch(25);
}
Point p = calc.tileToScreen(doorTile);
if (p != null) {
status = "Opening door";
mouse.move(p, 5, 5);
sleep(random(250, 500));
if (menu.contains(doorAction)) {
if (menu.getIndex(doorAction) > 0) {
mouse.click(false);
sleep(random(250, 500));
if (menu.contains(doorAction)) {
menu.doAction(doorAction);
} else {
mouse.moveSlightly();
}
} else {
mouse.click(true);
}
}
}
}
} else {
status = "Walking to bank";
walking.walkTo(nextToBank);
}
}
camRotate.pause = false;
return random(500, 1000);
case BANKING:
if (bank.isOpen()) {
if (inventory.getCount() >= 1) {
status = "Depositing all";
bank.depositAll();
return random(1000, 1500);
} else {
status = "Withdrawing raw";
if (bank.getCount(rawID) > 0) {
if (bank.withdraw(rawID, 0)) {
mouse.moveSlightly();
return random(500, 1000);
}
return 100;
} else {
outOfRaw = true;
return 100;
}
}
} else {
status = "Opening bank";
if (bankNpc) {
RSNPC banker = npcs.getNearest(bankerNpcID);
if (banker != null) {
if (calc.pointOnScreen(banker.getScreenLocation())) {
if (banker.doAction("Bank Emerald Benedict")) {
mouse.moveSlightly();
return random(2000, 2500);
}
return 100;
} else {
RSTile tile = banker.getLocation();
if (tile != null) {
int a1 = camera.getAngle();
int at1 = camera.getTileAngle(tile);
if (a1 < (at1 - 25) || a1 > (at1 + 25)) {
camera.turnTo(bankTile, 10);
}
}
return 100;
}
}
return 100;
} else {
if (calc.tileOnScreen(bankTile)) {
RSObject bankBooth = objects.getTopAt(bankTile);
if (bankBooth != null) {
if (bankBooth.doAction("Use-quickly")) {
mouse.moveSlightly();
return random(2000, 2500);
}
return 100;
}
return 100;
} else {
int a1 = camera.getAngle();
int at1 = camera.getTileAngle(bankTile);
if (a1 < (at1 - 25) || a1 > (at1 + 25)) {
camera.turnTo(bankTile, 10);
return 100;
}
return 100;
}
}
}
case LOGOUT:
status = "Stoping script";
game.logout(true);
return -1;
case TOLOCATION:
camRotate.pause = true;
status = "Walking to cooking area.";
if (!cameraIsMoving()) {
RSPath gPath = walking.getPath(location.getCentralTile());
if (gPath.isValid()) {
if (gPath.traverse()) {
camRotate.pause = false;
return random(1500, 2000);
}
}
}
camRotate.pause = false;
return random(250, 500);
case WAIT:
return 100;
}
}
return 100;
}
private boolean atDoor() {
return calc.tileOnScreen(doorTile) && calc.distanceTo(doorTile) < 3;
}
private boolean doorOpen() {
return objects.getTopAt(doorTile) == null;
}
private boolean cameraIsMoving() {
int ca1 = 0, ca2 = 0;
ca1 = camera.getAngle();
sleep(50);
ca2 = camera.getAngle();
if (ca1 != ca2) {
return true;
}
return false;
}
private void checkRun() {
if (!walking.isRunEnabled() && walking.getEnergy() > random(15, 30)) {
status = "Setting run";
walking.setRun(true);
sleep(random(500, 750));
}
}
private boolean atLocation() {
return location.contains(getMyPlayer().getLocation());
}
private boolean nearLocation() {
return calc.distanceTo(location.getCentralTile()) < 35;
}
private boolean atBank() {
if (location.contains(ntr[0])) {
return calc.tileOnScreen(bankTile) && calc.distanceTo(bankTile) < 5
&& getMyPlayer().getLocation().getX() >= bankTile.getX();
} else if (location.contains(ntr[1])) {
RSNPC banker = npcs.getNearest(bankerNpcID);
if (banker != null) {
RSTile t = banker.getLocation();
if (t != null)
return calc.tileOnScreen(t) && calc.distanceTo(t) < 3;
}
return false;
} else {
return calc.tileOnScreen(bankTile) && calc.distanceTo(bankTile) < 5
&& getMyPlayer().getLocation().getY() <= bankTile.getY();
}
}
private boolean atRange() {
if (location.contains(ntr[0])) {
return calc.tileOnScreen(rangeTile)
&& calc.distanceTo(rangeTile) < 5
&& getMyPlayer().getLocation().getX() >= rangeTile.getX();
} else if (location.contains(ntr[1])) {
return calc.tileOnScreen(rangeTile)
&& calc.distanceTo(rangeTile) < 5;
} else {
return calc.tileOnScreen(rangeTile)
&& calc.distanceTo(rangeTile) < 3
&& getMyPlayer().getLocation().getY() <= rangeTile.getY();
}
}
private boolean hasRaw() {
return inventory.contains(rawID);
}
private double getVersion() {
return getClass().getAnnotation(ScriptManifest.class).version();
}
private int totalExp() {
return skills.getCurrentExp(Skills.COOKING) - startExp;
}
private int expPerHour() {
if (runTime() / 1000 > 0) {
return (int) (3600000.0 / runTime() * totalExp());
}
return 0;
}
private int cookedPerHour() {
if (runTime() / 1000 > 0) {
return (int) (3600000.0 / runTime() * cooked);
}
return 0;
}
private int burntPerHour() {
if (runTime() / 1000 > 0) {
return (int) (3600000.0 / runTime() * burnt);
}
return 0;
}
private int rawTNL() {
if (rawExp == 0) {
return 0;
}
return (int) skills.getExpToNextLevel(Skills.COOKING) / rawExp;
}
private int rawTNN() {
if (rawExp == 0) {
return 0;
}
int currentExp = skills.getCurrentExp(Skills.COOKING);
if (currentExp < 13034431) {
return (int) (13034431 - currentExp) / rawExp;
}
return 0;
}
private long runTime() {
return System.currentTimeMillis() - startTime;
}
private String runTimeString() {
return formatTime((int) runTime());
}
private String formatTime(int time) { // credits to Ahmedbasil1
final StringBuilder stringAppend = new StringBuilder();
final long TSec = time / 1000;
final long TMin = TSec / 60;
final long THour = TMin / 60;
final int s = (int) TSec % 60;
final int m = (int) TMin % 60;
final int h = (int) THour;
if (time <= 0) {
return "00:00:00";
}
if (h < 10) {
stringAppend.append("0");
}
stringAppend.append(h);
stringAppend.append(":");
if (m < 10) {
stringAppend.append("0");
}
stringAppend.append(m);
stringAppend.append(":");
if (s < 10) {
stringAppend.append("0");
}
stringAppend.append(s);
return stringAppend.toString();
}
private void firstRun() {
while (skills.getCurrentExp(Skills.COOKING) == 0) {
sleep(100);
}
status = "setup";
startExp = skills.getCurrentExp(Skills.COOKING);
if (isMember()) {
status = "Checking for gauntlents";
if (equipment.getItem(Equipment.HANDS).getID() != COOKING_GAUNTLENTS_ID) {
if (!inventory.contains(COOKING_GAUNTLENTS_ID)) {
log("You could be burning a lot less food if you had 'Cooking gauntlets'");
log("You can get these by completing the 'Family Crest' quest.");
} else {
RSItem gloves = inventory.getItem(COOKING_GAUNTLENTS_ID);
if (gloves != null) {
String n = gloves.getName();
if (n != null) {
gloves.doAction("Wield " + n);
}
}
}
}
}
camRotate.isAlive = true;
camRotate.start();
camHeight.isAlive = true;
camHeight.start();
}
public boolean isMember() {
return AccountManager.isMember(account.getName());
}
@Override
public boolean onStart() {
gui = new GUI();
while (gui.isVisible()) {
sleep(100);
}
status = "loading";
if (customID) {
log("Loading name from ge");
rawName = grandExchange.getItemName(rawID);
}
if (cook2ids) {
if (customID2) {
log("Loading second name from ge");
rawName2 = grandExchange.getItemName(rawID2);
}
log("We will cook " + rawName + " ID: " + rawID + " and "
+ rawName2 + " ID: " + rawID2);
} else {
log("We will cook " + rawName + " ID: " + rawID);
}
startTime = System.currentTimeMillis();
return startScript;
}
@Override
public void onFinish() {
camHeight.isAlive = false;
camRotate.isAlive = false;
log("Cooked " + cooked + " " + rawName + " in " + runTimeString()
+ " (" + cookedPerHour() + " p/hr)");
log("Burnt " + burnt + " " + rawName);
log("Exp gained: " + totalExp() + " (" + expPerHour() + " p/hr)");
log("Levels gained: " + levelsGained);
log("autoCook v" + getVersion());
}
@Override
public void onRepaint(Graphics render) {
Graphics2D g = (Graphics2D) render;
if (showMouse) {
g.setStroke(new BasicStroke(2));
drawMouse(g);
}
if (afk) {
g.setColor(new Color(0, 0, 0, 150));
g.fillRect(0, 0, 768, 510);
}
if (game.isLoggedIn()
&& skills.getCurrentLevel(Skills.CONSTITUTION) > 1
&& !isHover(528, 203, 756, 466)) {
g.setColor(new Color(0, 0, 0, 150));
g.fillRoundRect(528, 203, 228, 263, 16, 16);
g.setFont(new Font("Arial", 1, 16));
g.setColor(Color.GREEN);
g.drawString("autoCook v" + getVersion(), 584, 221);
g.setFont(new Font("Arial", 1, 12));
g.drawString("Runtime: " + runTimeString(), 533, 240);
g.drawString("Status: " + status, 533, 256);
g.drawString("Total raw: " + (cooked + burnt), 533, 272);
g.drawString("Cooked: " + cooked + " (" + cookedPerHour()
+ " p/hr)", 533, 288);
g.drawString("Burnt: " + burnt + " (" + burntPerHour() + " p/hr)",
533, 304);
g.drawString("Total exp: " + totalExp(), 533, 320);
g.drawString("Exp p/hr: " + expPerHour(), 533, 336);
if (skills.getCurrentLevel(Skills.COOKING) < 99) {
g.drawString("Exp TNL: "
+ skills.getExpToNextLevel(Skills.COOKING) + " ("
+ skills.getPercentToNextLevel(Skills.COOKING) + "%)",
533, 352);
try {
if (expPerHour() > 0) {
long sTNL = skills.getExpToNextLevel(Skills.COOKING)
/ (expPerHour() / 3600);
long hTNL = sTNL / (60 * 60);
sTNL -= hTNL * (60 * 60);
long mTNL = sTNL / 60;
sTNL -= mTNL * 60;
g.drawString("Level in: " + hTNL + ":" + mTNL + ":"
+ sTNL, 533, 368);
} else {
g.drawString("Level in: 0:0:0 ", 533, 368);
}
} catch (Exception e) {
g.drawString("Level in: -1:-1:-1", 533, 368);
}
g.drawString("Cooked TNL: " + rawTNL(), 533, 416);
} else {
g.drawString("Exp TNL: 0 (0%)", 533, 352);
g.drawString("Level in: 0:0:0 ", 533, 368);
g.drawString("Cooked TNL: 0", 533, 416);
}
g.drawString("Total levels: " + levelsGained, 533, 384);
g.drawString("Exp per raw: " + rawExp, 533, 400);
g.drawString("Cooked till 99: " + rawTNN(), 533, 432);
if (skills.getCurrentLevel(Skills.COOKING) < 99) {
try {
if (expPerHour() > 0) {
long sTNN = (13034431 - skills
.getCurrentExp(Skills.COOKING))
/ (expPerHour() / 3600);
long hTNN = sTNN / (60 * 60);
sTNN -= hTNN * (60 * 60);
long mTNN = sTNN / 60;
sTNN -= mTNN * 60;
g.drawString(
"99 in: " + hTNN + ":" + mTNN + ":" + sTNN,
533, 448);
} else {
g.drawString("99 in: 0:0:0 ", 533, 448);
}
} catch (Exception e) {
g.drawString("99 in: -1:-1:-1", 533, 448);
}
} else {
g.drawString("99 in: 0:0:0 ", 533, 448);
}
}
}
public void drawMouse(final Graphics g) {
final Point loc = mouse.getLocation();
g.setColor(Color.RED);
g.drawLine(0, loc.y, 766, loc.y);
g.drawLine(loc.x, 0, loc.x, 505);
}
@Override
public void messageReceived(MessageEvent e) {
String s = e.getMessage().toLowerCase();
if (s.contains("accidentally burn") || s.contains("accidentally burnt")) {
burnt++;
}
if (s.contains("successfully cook") || s.contains("manage to cook")
|| s.contains("roast") || s.contains("bake")) {
cooked++;
}
if (s.contains("you've just advanced")) {
if (s.contains("cooking level")) {
levelsGained++;
}
log("Gratz you just gained a level !");
clickContinue = true;
}
}
@Override
public void mouseDragged(MouseEvent arg0) {
// Auto-generated method stub
// Not used
}
@Override
public void mouseMoved(MouseEvent e) {
mousePoint = e.getPoint();
}
public boolean isHover(int x1, int y1, int x2, int y2) { // credits to
// Ahmedbasil1
if (mousePoint != null) {
if (mousePoint.getX() >= x1 && mousePoint.getY() >= y1
&& mousePoint.getX() <= x2 && mousePoint.getY() <= y2) {
return true;
} else {
return false;
}
} else {
return false;
}
}
public boolean itemPresent(int itemID, int dist) {
RSGroundItem item = groundItems.getNearest(itemID);
RSTile playerTile = getMyPlayer().getLocation();
if (item != null) {
RSTile itemTile = item.getLocation();
return (playerTile.getX() - dist) <= itemTile.getX()
&& itemTile.getX() <= (playerTile.getX() + dist)
&& (playerTile.getY() + dist) >= itemTile.getY()
&& itemTile.getY() >= (playerTile.getY() - dist);
}
return false;
}
public class cameraHeight extends Thread {
// credits to Aion
private boolean isAlive = false;
private boolean pause = false;
@Override
public void run() {
while (this.isAlive) {
if (random(1, 15000) == 342) {
try {
if (this.pause) {
while (this.pause) {
Thread.sleep(3000, 7000);
}
}
char key = KeyEvent.VK_UP;
if (camera.getPitch() >= random(50, 100)) {
key = KeyEvent.VK_DOWN;
}
keyboard.pressKey(key);
Thread.sleep(random(75, 300));
keyboard.releaseKey(key);
} catch (Exception e) {
}
try {
Thread.sleep(random(random(1000, 5000), random(11000,
17000)));
} catch (Exception e) {
camera.setPitch(random(0, 100));
}
}
}
}
}
public class cameraRotate extends Thread {
// credits to Aion
private boolean isAlive = false;
private boolean pause = false;
@Override
public void run() {
while (this.isAlive) {
if (random(1, 15000) == 342) {
try {
if (this.pause) {
while (this.pause) {
Thread.sleep(3000, 7000);
}
}
char key = KeyEvent.VK_RIGHT;
if (random(1, 5) == 2) {
key = KeyEvent.VK_LEFT;
}
keyboard.pressKey(key);
Thread.sleep(random(350, 1200));
keyboard.releaseKey(key);
} catch (Exception e) {
camera.setAngle(random(0, 360));
}
try {
Thread.sleep(random(random(1000, 5000), random(11000,
17000)));
} catch (Exception e) {
}
}
}
}
}
public class GUI extends JFrame {
private static final long serialVersionUID = -7758110133437943043L;
public GUI() {
initComponents();
}
private void buttonStartActionPerformed(ActionEvent e) {
if (checkBoxCustomID.isSelected()) {
customID = true;
try {
rawID = Integer.parseInt(textFieldCustomID.getText());
} catch (NumberFormatException nfe) {
log
.severe("You MUST enter a valid nuber in the custom ID text field");
setVisible(false);
dispose();
}
} else {
rawID = ids[comboBoxPreSetID.getSelectedIndex()];
rawName = names[comboBoxPreSetID.getSelectedIndex()];
}
if (checkBoxCookSecondItem.isSelected()) {
cook2ids = true;
if (checkBoxCustomID2.isSelected()) {
customID2 = true;
try {
rawID2 = Integer.parseInt(textFieldCustomID2.getText());
} catch (NumberFormatException nfe) {
log
.severe("You MUST enter a valid nuber in the 2nd custom ID text field");
setVisible(false);
dispose();
}
} else {
rawID2 = ids[comboBoxPreSetID2.getSelectedIndex()];
rawName2 = names[comboBoxPreSetID2.getSelectedIndex()];
}
}
if (checkBoxRewards.isSelected()) {
doRewardPickUp = true;
}
if (checkBoxAFK.isSelected()) {
useafk = true;
}
int l = comboBoxLocation.getSelectedIndex();
location = area[l];
nextToRange = ntr[l];
switch (l) {
case 0:
rangeTile = alKaridRangeTiles[random(0,
alKaridRangeTiles.length)];
nextToBank = ntb[random(0, alKaridBankTiles.length)];
bankTile = alKaridBankTiles[random(0, alKaridBankTiles.length)];
break;
case 1:
rangeTile = rougesDenRangeTiles[random(0,
rougesDenRangeTiles.length)];
nextToBank = ntb[4];
bankTile = null;
bankNpc = true;
break;
case 2:
rangeTile = catherbyRangeTiles[random(0,
catherbyRangeTiles.length)];
nextToBank = ntb[random(5, ntb.length)];
bankTile = catherbyBankTiles[random(0, catherbyBankTiles.length)];
break;
}
mouseSpeed = sliderMouseSpeed.getValue();
/* Write settings
try {
final BufferedWriter out = new BufferedWriter(new FileWriter(
settingsFile));
out.write((checkBoxCustomID.isSelected() ? "true" : "false")
+ ":" // 0
+ rawID
+ ":" // 1
+ comboBoxPreSetID.getSelectedIndex()
+ ":" // 2
+ (checkBoxRewards.isSelected() ? "true" : "false")
+ ":" // 3
+ (checkBoxDropCoins.isSelected() ? "true" : "false")
+ ":" // 4
+ (checkBoxCookSecondItem.isSelected() ? "true"
: "false")
+ ":" // 5
+ rawID2
+ ":" // 6
+ comboBoxPreSetID2.getSelectedIndex()
+ ":" // 7
+ (checkBoxCustomID2.isSelected() ? "true" : "false")
+ ":" // 8
+ (checkBoxAFK.isSelected() ? "true" : "false") + ":" // 9
+ comboBoxLocation.getSelectedIndex() + ":" // 10
+ sliderMouseSpeed.getValue()); // 11
out.close();
} catch (final Exception e1) {
log.warning("Error saving setting.");
}
// End write settings */
startScript = true;
setVisible(false);
dispose();
}
private void buttonExitActionPerformed(ActionEvent e) {
final int exit = JOptionPane.showConfirmDialog(null,
"Are you sure you want to exit the script?", "Exiting",
JOptionPane.YES_NO_OPTION);
if (exit == 0) {
setVisible(false);
dispose();
}
}
private void checkBoxCustomIDActionPerformed(ActionEvent e) {
if (checkBoxCustomID.isSelected()) {
comboBoxPreSetID.setEnabled(false);
textFieldCustomID.setEnabled(true);
} else {
textFieldCustomID.setEnabled(false);
comboBoxPreSetID.setEnabled(true);
}
}
private void buttonVisitThreadActionPerformed(ActionEvent e) {
JOptionPane.showConfirmDialog(null,
"RSBot no longer allows this option..",
"Sorry", JOptionPane.OK_OPTION);
}
private void checkBoxRewardsActionPerformed(ActionEvent e) {
if (checkBoxRewards.isSelected()) {
checkBoxDropCoins.setEnabled(true);
} else {
checkBoxDropCoins.setEnabled(false);
checkBoxDropCoins.setSelected(false);
}
}
private void checkBoxCustomID2ActionPerformed(ActionEvent e) {
if (checkBoxCustomID2.isSelected()) {
comboBoxPreSetID2.setEnabled(false);
textFieldCustomID2.setEnabled(true);
} else {
comboBoxPreSetID2.setEnabled(true);
textFieldCustomID2.setEnabled(false);
}
}
private void checkBoxCookSecondItemActionPerformed(ActionEvent e) {
if (checkBoxCookSecondItem.isSelected()) {
comboBoxPreSetID2.setEnabled(true);
checkBoxCustomID2.setEnabled(true);
} else {
comboBoxPreSetID2.setEnabled(false);
checkBoxCustomID2.setEnabled(false);
textFieldCustomID2.setEnabled(false);
}
}
private void initComponents() {
// GEN-BEGIN:initComponents
panelMain = new JPanel();
comboBoxPreSetID = new JComboBox();
label1 = new JLabel();
buttonStart = new JButton();
buttonExit = new JButton();
checkBoxCustomID = new JCheckBox();
textFieldCustomID = new JTextField();
label2 = new JLabel();
buttonVisitThread = new JButton();
checkBoxRewards = new JCheckBox();
checkBoxDropCoins = new JCheckBox();
comboBoxPreSetID2 = new JComboBox();
checkBoxCustomID2 = new JCheckBox();
textFieldCustomID2 = new JTextField();
checkBoxCookSecondItem = new JCheckBox();
checkBoxAFK = new JCheckBox();
sliderMouseSpeed = new JSlider();
label3 = new JLabel();
label4 = new JLabel();
label5 = new JLabel();
label6 = new JLabel();
comboBoxLocation = new JComboBox();
// ======== this ========
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
setTitle("autoCook v" + getVersion());
setVisible(true);
setResizable(false);
Container contentPane = getContentPane();
contentPane.setLayout(null);
// ======== panelMain ========
{
panelMain.setLayout(null);
// ---- comboBoxPreSetID ----
comboBoxPreSetID.setModel(new DefaultComboBoxModel(
new String[] { "Raw beef", "Raw chicken",
"Raw crayfish", "Raw shrimps", "Raw sardine",
"Raw herring", "Raw anchovies", "Raw mackerel",
"Raw trout", "Raw cod", "Raw pike",
"Raw salmon", "Raw tuna", "Raw lobster",
"Raw bass", "Raw swordfish", "Raw monkfish",
"Raw shark", "Raw sea turtle", "Raw rocktail",
"Uncooked pizza" }));
comboBoxPreSetID.setSelectedIndex(12);
panelMain.add(comboBoxPreSetID);
comboBoxPreSetID.setBounds(110, 35, 100, comboBoxPreSetID
.getPreferredSize().height);
// ---- label1 ----
label1.setText("autoCook v" + getVersion() + " Settings");
label1.setHorizontalAlignment(SwingConstants.CENTER);
label1.setFont(new Font("Tahoma", Font.BOLD, 16));
panelMain.add(label1);
label1.setBounds(0, 0, 435, 30);
// ---- buttonStart ----
buttonStart.setText("START");
buttonStart.setFont(buttonStart.getFont().deriveFont(
buttonStart.getFont().getStyle() | Font.BOLD));
buttonStart.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
buttonStartActionPerformed(e);
}
});
panelMain.add(buttonStart);
buttonStart.setBounds(5, 155, 135, 30);
// ---- buttonExit ----
buttonExit.setText("EXIT");
buttonExit.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
buttonExitActionPerformed(e);
}
});
panelMain.add(buttonExit);
buttonExit.setBounds(290, 155, 135, 30);
// ---- checkBoxCustomID ----
checkBoxCustomID.setText("Custom ID?");
checkBoxCustomID.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
checkBoxCustomIDActionPerformed(e);
}
});
panelMain.add(checkBoxCustomID);
checkBoxCustomID.setBounds(5, 65, 100, 20);
// ---- textFieldCustomID ----
textFieldCustomID.setEnabled(false);
panelMain.add(textFieldCustomID);
textFieldCustomID.setBounds(110, 65, 100, 20);
// ---- label2 ----
label2.setText("Pre-set ID:");
panelMain.add(label2);
label2.setBounds(10, 35, 95, 20);
// ---- buttonVisitThread ----
buttonVisitThread.setText("Visit Thread");
buttonVisitThread.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
buttonVisitThreadActionPerformed(e);
}
});
panelMain.add(buttonVisitThread);
buttonVisitThread.setBounds(145, 155, 140, 30);
// ---- checkBoxRewards ----
checkBoxRewards.setText("Pick up rewards?");
checkBoxRewards.setSelected(true);
checkBoxRewards.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
checkBoxRewardsActionPerformed(e);
}
});
panelMain.add(checkBoxRewards);
checkBoxRewards.setBounds(new Rectangle(new Point(5, 95),
checkBoxRewards.getPreferredSize()));
// ---- checkBoxDropCoins ----
checkBoxDropCoins.setText("Drop coins?");
checkBoxDropCoins.setSelected(true);
panelMain.add(checkBoxDropCoins);
checkBoxDropCoins.setBounds(new Rectangle(new Point(110, 95),
checkBoxDropCoins.getPreferredSize()));
// ---- comboBoxPreSetID2 ----
comboBoxPreSetID2.setModel(new DefaultComboBoxModel(
new String[] { "Raw beef", "Raw chicken",
"Raw crayfish", "Raw shrimps", "Raw sardine",
"Raw herring", "Raw anchovies", "Raw mackerel",
"Raw trout", "Raw cod", "Raw pike",
"Raw salmon", "Raw tuna", "Raw lobster",
"Raw bass", "Raw swordfish", "Raw monkfish",
"Raw shark", "Raw sea turtle", "Raw rocktail",
"Uncooked pizza" }));
comboBoxPreSetID2.setEnabled(false);
comboBoxPreSetID2.setSelectedIndex(15);
panelMain.add(comboBoxPreSetID2);
comboBoxPreSetID2.setBounds(325, 35, 100, 22);
// ---- checkBoxCustomID2 ----
checkBoxCustomID2.setText("Custom ID?");
checkBoxCustomID2.setEnabled(false);
checkBoxCustomID2.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
checkBoxCustomID2ActionPerformed(e);
}
});
panelMain.add(checkBoxCustomID2);
checkBoxCustomID2.setBounds(220, 65, 100, 20);
// ---- textFieldCustomID2 ----
textFieldCustomID2.setEnabled(false);
panelMain.add(textFieldCustomID2);
textFieldCustomID2.setBounds(325, 65, 100, 20);
// ---- checkBoxCookSecondItem ----
checkBoxCookSecondItem.setText("Second ID? ID:");
checkBoxCookSecondItem.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
checkBoxCookSecondItemActionPerformed(e);
}
});
panelMain.add(checkBoxCookSecondItem);
checkBoxCookSecondItem.setBounds(new Rectangle(new Point(220,
35), checkBoxCookSecondItem.getPreferredSize()));
// ---- checkBoxAFK ----
checkBoxAFK.setText("AFK?");
checkBoxAFK.setSelected(true);
panelMain.add(checkBoxAFK);
checkBoxAFK.setBounds(new Rectangle(new Point(190, 95),
checkBoxAFK.getPreferredSize()));
// ---- sliderMouseSpeed ----
sliderMouseSpeed.setMaximum(10);
sliderMouseSpeed.setMinimum(1);
sliderMouseSpeed.setPaintLabels(true);
sliderMouseSpeed.setPaintTicks(true);
sliderMouseSpeed.setSnapToTicks(true);
sliderMouseSpeed.setValue(7);
sliderMouseSpeed.setMinorTickSpacing(1);
panelMain.add(sliderMouseSpeed);
sliderMouseSpeed.setBounds(325, 105, 100, 17);
// ---- label3 ----
label3.setText("Mouse speed:");
panelMain.add(label3);
label3.setBounds(255, 95, label3.getPreferredSize().width, 20);
// ---- label4 ----
label4.setText("fast");
panelMain.add(label4);
label4.setBounds(new Rectangle(new Point(330, 90), label4
.getPreferredSize()));
// ---- label5 ----
label5.setText("slow");
panelMain.add(label5);
label5.setBounds(new Rectangle(new Point(405, 90), label5
.getPreferredSize()));
// ---- label6 ----
label6.setText("Location:");
panelMain.add(label6);
label6.setBounds(10, 125, label6.getPreferredSize().width, 20);
// ---- comboBoxLocation ----
comboBoxLocation
.setModel(new DefaultComboBoxModel(new String[] {
"Al-karid", "Rouge's den", "Catherby" }));
panelMain.add(comboBoxLocation);
comboBoxLocation.setBounds(110, 125, 100, comboBoxLocation
.getPreferredSize().height);
{ // compute preferred size
Dimension preferredSize = new Dimension();
for (int i = 0; i < panelMain.getComponentCount(); i++) {
Rectangle bounds = panelMain.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 = panelMain.getInsets();
preferredSize.width += insets.right;
preferredSize.height += insets.bottom;
panelMain.setMinimumSize(preferredSize);
panelMain.setPreferredSize(preferredSize);
}
}
contentPane.add(panelMain);
panelMain.setBounds(0, 0, 435, 195);
{ // compute preferred size
Dimension preferredSize = new Dimension();
for (int i = 0; i < contentPane.getComponentCount(); i++) {
Rectangle bounds = contentPane.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 = contentPane.getInsets();
preferredSize.width += insets.right;
preferredSize.height += insets.bottom;
contentPane.setMinimumSize(preferredSize);
contentPane.setPreferredSize(preferredSize);
}
pack();
setLocationRelativeTo(getOwner());
// GEN-END:initComponents
/* LOAD SAVED SELECTION INFO
try {
final BufferedReader in = new BufferedReader(new FileReader(
settingsFile));
String line;
String[] opts = {};
while ((line = in.readLine()) != null) {
if (line.contains(":")) {
opts = line.split(":");
}
}
in.close();
if (opts.length > 10) {
if (opts[0].equals("true")) {
checkBoxCustomID.setSelected(true);
textFieldCustomID.setEnabled(true);
textFieldCustomID.setText(opts[1]);
}
comboBoxPreSetID
.setSelectedIndex(Integer.parseInt(opts[2]));
if (opts[3].equals("true")) {
checkBoxRewards.setSelected(true);
checkBoxDropCoins.setEnabled(true);
if (opts[4].equals("true")) {
checkBoxDropCoins.setSelected(true);
}
}
if (opts[5].equals("true")) {
checkBoxCookSecondItem.setSelected(true);
comboBoxPreSetID2.setEnabled(true);
checkBoxCustomID2.setEnabled(true);
if (opts[8].equals("true")) {
checkBoxCustomID2.setSelected(true);
textFieldCustomID2.setEnabled(true);
textFieldCustomID2.setText(opts[6]);
}
}
comboBoxPreSetID2.setSelectedIndex(Integer
.parseInt(opts[7]));
if (opts[9].equals("false")) {
checkBoxAFK.setSelected(false);
}
comboBoxLocation.setSelectedIndex(Integer
.parseInt(opts[10]));
sliderMouseSpeed.setValue(Integer.parseInt(opts[11]));
}
} catch (final Exception e2) {
log.warning("Error loading settings.");
}
// END LOAD SAVED SELECTION INFO */
}
// GEN-BEGIN:variables
private JPanel panelMain;
private JComboBox comboBoxPreSetID;
private JLabel label1;
private JButton buttonStart;
private JButton buttonExit;
private JCheckBox checkBoxCustomID;
private JTextField textFieldCustomID;
private JLabel label2;
private JButton buttonVisitThread;
private JCheckBox checkBoxRewards;
private JCheckBox checkBoxDropCoins;
private JComboBox comboBoxPreSetID2;
private JCheckBox checkBoxCustomID2;
private JTextField textFieldCustomID2;
private JCheckBox checkBoxCookSecondItem;
private JCheckBox checkBoxAFK;
private JSlider sliderMouseSpeed;
private JLabel label3;
private JLabel label4;
private JLabel label5;
private JLabel label6;
private JComboBox comboBoxLocation;
// GEN-END:variables
}
}