import java.awt.*;
import java.util.*;
import java.awt.event.*;
import com.speljohan.rsbot.script.*;
import com.speljohan.rsbot.bot.*;
import com.speljohan.rsbot.script.wrappers.*;
import com.speljohan.rsbot.event.listeners.*;
import com.speljohan.rsbot.event.events.*;
import com.speljohan.rsbot.accessors.*;
public class barbarianAgility extends Script implements ServerMessageListener, PaintListener {
public int currentStep = 1;
public int currentHeight = 0;
public int fallCount = 0;
public int whichWall = 1;
public int lapCount = 0;
public int randomInt = 0;
public int isIdle = 0;
public int hasNoFood = 0;
public int currentHealth = 0;
public int dangerousHP = 0;
public int whenToRun = random(40, 75);
public int[] foodID = { 1895,1893,1891, 4293, 2142, 4291, 2140, 3228, 9980, 7223, 6297, 6293, 6295, 6299, 7521, 9988, 7228, 2878, 7568, 2343, 1861, 13433, 315, 325, 319, 3144, 347, 355, 333, 339, 351, 329, 3381, 361, 10136, 5003, 379, 365, 373, 7946, 385, 397, 391, 3369, 3371, 3373, 2309, 2325, 2333, 2327, 2331, 2323, 2335, 7178, 7180, 7188, 7190, 7198, 7200, 7208, 7210, 7218, 7220, 2003, 2011, 2289, 2291, 2293, 2295, 2297, 2299, 2301, 2303, 1891, 1893, 1895, 1897, 1899, 1901, 7072, 7062, 7078, 7064, 7084, 7082, 7066, 7068, 1942, 6701, 6703, 7054, 6705, 7056, 7060, 2130, 1985, 1993, 1989, 1978, 5763, 5765, 1913, 5747, 1905, 5739, 1909, 5743, 1907, 1911, 5745, 2955, 5749, 5751, 5753, 5755, 5757, 5759, 5761, 2084, 2034, 2048, 2036, 2217, 2213, 2205, 2209, 2054, 2040, 2080, 2277, 2225, 2255, 2221, 2253, 2219, 2281, 2227, 2223, 2191, 2233, 2092, 2032, 2074, 2030, 2281, 2235, 2064, 2028, 2187, 2185, 2229 }; //Has almost every food cookable in runescape, members and non!
//credits to Bug5532 for the foodID's
public String getName() {
return "barbarianAgility";
}
public String getScriptCategory() {
return "Agility";
}
public double getVersion() {
return 1.1;
}
public String getAuthor() {
return "Silentone";
}
public boolean onStart(String[] args) {
currentStep = 1;
Bot.getEventManager().removeListener(ServerMessageListener.class, this);
Bot.getEventManager().removeListener(PaintListener.class, this);
Bot.getEventManager().addListener(ServerMessageListener.class, this);
Bot.getEventManager().addListener(PaintListener.class, this);
return true;
}
public RSTile[] toWalls = new RSTile[] { new RSTile(2532,3549),
new RSTile(2534,3553)};
public RSTile[] toLog = new RSTile[] { new RSTile(2543,3553),
new RSTile(2546,3552),
new RSTile(2549,3550)};
public RSTile[] logFail = new RSTile[] {
new RSTile(2537,3547),
new RSTile(2549,3543),
new RSTile(2551,3545)};
public RSTile[] netFail = new RSTile[] {
new RSTile(2543,3553),
new RSTile(2540,3546)};
public int killBot() {
return -1;
}
public int loop() {
RSObject tempObject;
try {
if (skills.getCurrentSkillLevel(3) < dangerousHP ) {
if (getInventoryCount(foodID) == 0) {
log("..uhoh.. we have no food and hp is at a dangerous level");
return killBot();
}
for(int i = 0; i<foodID.length; i++) {
if(getInventoryCount(foodID[i]) >= 1) {
atInventoryItem(foodID[i], "Eat");
return random(800, 1400);
}
}
}
if (getEnergy() >= whenToRun && !isRunning( ) ) {
setRun(true);
whenToRun = random(30, 70);
return random(500, 750);
}
doSomething();
if (getMyPlayer().isMoving()){
isIdle=0;
}
dangerousHP = random(7,15);
currentHealth = skills.getCurrentSkillLevel(3);
if (!getMyPlayer().isMoving()) {
isIdle++;
if(isIdle > 20){
log("We've been idle too long.");
log("Stopping script to minimize bot suspicion");
stopAllScripts();
}
}
if(getMyPlayer().isMoving())
return random(1000,1500);
if (currentStep == 1) {
tempObject = findObjectInRange(15,2294);
atObject(tempObject, "Walk-across");
}
if (currentStep == 2) {
tempObject = findObjectInRange(15,20211);
atObject(tempObject, "Climb-over");
}
if (currentStep == 3) {
tempObject = findObjectInRange(15,2302);
atObject(tempObject, "Walk-across");
}
if (currentStep == 4) {
tempObject = findObjectInRange(15,3205);
currentHeight = getPlane();
if(tempObject != null){
atObject(tempObject, "Climb-down");
currentHeight = getPlane();
}
if (currentHeight == 0){
currentStep = 5;
}
}
if (currentStep == 5) {
walkPathMM( randomizePath(toWalls, 2, 2), 20 );
if((distanceTo(new RSTile(2535, 3553)) >= 5)) {
currentStep = 6;
}
}
if (currentStep == 6) {
whichWall = 1;
atTile(new RSTile(2536,3553), "Climb-over");
}
if(currentStep == 7){
whichWall = 2;
atTile(new RSTile(2539,3553), "Climb-over");
}
if(currentStep == 8){
whichWall = 3;
atTile(new RSTile(2542,3553), "Climb-over");
}
if (currentStep == 9){
walkPathMM( randomizePath(toLog, 2, 2), 20 );
if((distanceTo(new RSTile(2551, 3546)) >= 3)) {
currentStep = 1;
}
}
if (currentStep == 01){
walkPathMM( randomizePath(logFail, 2, 2), 20 );
if((distanceTo(new RSTile(2551, 3546)) >= 3)) {
currentStep = 1;
}
}
if (currentStep == 02){
walkPathMM( randomizePath(netFail, 2, 2), 20 );
if((distanceTo(new RSTile(2541, 3546)) >= 2)) {
currentStep = 2;
}
}
} catch(Exception e) {}
return random(500,1200);
}
public void onFinish() {
try {
Bot.getEventManager().removeListener(ServerMessageListener.class, this);
Bot.getEventManager().removeListener(PaintListener.class, this);
} catch(Exception e) {}
}
public void onRepaint(Graphics g) {
if(isLoggedIn()){
int x = 358;
int y = 358;
g.drawString("currentStep := " +currentStep, x, y += 15);
g.drawString("fallCount := " +fallCount, x, y += 15);
g.drawString("lapCount := " +lapCount, x, y += 15);
g.drawString("", x, y += 15);
if(isIdle >= 1){
g.drawString("idleCounter := " +isIdle, x, y += 15);
} else {
g.drawString("", x, y += 15);
}
}
}
public void serverMessageRecieved(ServerMessageEvent e) {
String message = e.getMessage().toLowerCase();
if(message.contains("safely to") && currentStep == 1) {
currentStep=2;
}
if(message.contains("climb the") && currentStep == 2) {
currentStep=3;
}
if(message.contains("skillfully") && currentStep == 3) {
currentStep=4;
}
if(message.contains("low wall") && currentStep == 6 && whichWall == 1) {
currentStep=7;
}
if(message.contains("low wall") && currentStep == 7 && whichWall == 2) {
currentStep=8;
}
if(message.contains("low wall") && currentStep == 8 && whichWall == 3) {
currentStep=9;
whichWall=1;
lapCount=+1;
}
if(message.contains("water bites") && currentStep == 1) {
currentStep=01;
fallCount=+1;
}
if(message.contains("slip and fall") && currentStep == 3) {
currentStep=02;
fallCount=+1;
}
}
public RSObject findObjectInRange(int distanceTo, int id) {
for(int i=0;i<=distanceTo;i++) {
RSObject tempObject = findObject(i, id);
if(tempObject != null)
return tempObject;
}
return null;
}
public void moveCamera() {
char[] LR = new char[] { KeyEvent.VK_LEFT, KeyEvent.VK_RIGHT };
char[] UD = new char[] { KeyEvent.VK_UP, KeyEvent.VK_DOWN };
char[] LRUD = new char[] { KeyEvent.VK_LEFT, KeyEvent.VK_RIGHT,
KeyEvent.VK_UP, KeyEvent.VK_DOWN };
int random2 = random(0,2);
int random1 = random(0,2);
int random4 = random(0,4);
if(random(0,3) == 0) {
if(random(0,2) == 0) {
Bot.getInputManager().pressKey(LR[random1]);
try { Thread.sleep(random(100, 400)); } catch (Exception e) {}
Bot.getInputManager().pressKey(UD[random2]);
try { Thread.sleep(random(300, 600)); } catch (Exception e) {}
Bot.getInputManager().releaseKey(UD[random2]);
try { Thread.sleep(random(100, 400)); } catch (Exception e) {}
Bot.getInputManager().releaseKey(LR[random1]);
} else {
Bot.getInputManager().pressKey(UD[random2]);
try { Thread.sleep(random(100, 400)); } catch (Exception e) {}
Bot.getInputManager().pressKey(LR[random1]);
try { Thread.sleep(random(300, 600)); } catch (Exception e) {}
Bot.getInputManager().releaseKey(LR[random1]);
try { Thread.sleep(random(100, 400)); } catch (Exception e) {}
Bot.getInputManager().releaseKey(UD[random2]);
}
} else {
Bot.getInputManager().pressKey(LRUD[random4]);
if(random4>1) {
try { Thread.sleep(random(300, 600)); } catch (Exception e) {}
} else {
try { Thread.sleep(random(500, 900)); } catch (Exception e) {}
}
Bot.getInputManager().releaseKey(LRUD[random4]);
}
}
public void myOpenTab(int tab) {
if (tab == getCurrentTab()) {
return;}
switch(tab) {
case TAB_ATTACK: input.holdKey((char) KeyEvent.VK_F1, random(300, 700)); break;
case TAB_STATS: input.holdKey((char) KeyEvent.VK_F2, random(300, 700)); break;
case TAB_QUESTS: input.holdKey((char) KeyEvent.VK_F3, random(300, 700)); break;
case TAB_INVENTORY: input.holdKey((char) KeyEvent.VK_F4, random(300, 700)); break;
case TAB_EQUIPMENT: input.holdKey((char) KeyEvent.VK_F5, random(300, 700)); break;
case TAB_PRAYER: input.holdKey((char) KeyEvent.VK_F6, random(300, 700)); break;
case TAB_MAGIC: input.holdKey((char) KeyEvent.VK_F7, random(300, 700)); break;
case TAB_FRIENDS: input.holdKey((char) KeyEvent.VK_F8, random(300, 700)); break;
default: openTab(tab); break;
}
}
public void doSomething() {
wait (random(1000, 2000));
randomInt = random(1, 12);
if ((randomInt == 1) || (randomInt == 2) || (randomInt == 3)) {
wait(random(2000, 2000));
}
if (randomInt == 4) {
openTab(random(0,12));
}
if (randomInt == 5) {
myOpenTab(TAB_STATS);
openTab(TAB_STATS);
wait( random(350,800));
moveMouse(random(556,648),random(230,281));
wait( random(550,1300));
}
if (randomInt == 6) {
myOpenTab(random(0,12));
}
if ((randomInt == 7) || (randomInt == 8) || (randomInt == 9)) {
int x = random(0, 750);
int y = random(0, 500);
moveMouse(0, 0, x, y);
}
if ((randomInt == 10) || (randomInt == 11) || (randomInt == 12)) {
moveCamera();
}
}
}