- /*
- This script has a requirement of crossing the log (like 37ish agility or something, i forget exactly) along with a requirement to picklock the door (47ish thieving).
- I've used this script on my main, seems to work well... It sometimes got stuck in a door, though I've added some stuff so he should open it if he's stuck in it. If it still gives problems let me know.
- Just a heads up, this place has objects that seem to change/getupdated frequently. I've done my best to get the script working reguardless of how the changes will be made.
- The script sometimes does funny things, that aren't superhuman. Since I'm leaving for two years, i don't really have the time or motivation to fix right now.
- Edit the pickup ids in pickupids array for it to pickup different items. Currently picks most herbs and runes n stuff.
- */
- /*
- ArdyDruids.java
- Author: CamHart
- Fixers/Updaters/Improvers: Wolf
- Date Created: 5/03/09
- Date Modified: 22/03/09
- Version: 0.2
- Credits - Look throughout script
- Instructions:
- *33 Agility and 46 Thieving required. Doesn't eat.
- Notes
- *add special attack support
- Updates
- 0.1 - Added auto update check feature.
- */
- import java.awt.Color;
- import java.awt.Graphics;
- import java.awt.Point;
- import java.util.List;
- import java.util.ArrayList;
- import java.util.Map;
- import java.net.URL;
- import java.io.*;
- import org.rsbot.script.Script;
- import org.rsbot.script.wrappers.RSNPC;
- import org.rsbot.script.Calculations;
- import org.rsbot.script.wrappers.RSObject;
- import org.rsbot.script.wrappers.RSTile;
- import org.rsbot.script.wrappers.RSItem;
- import org.rsbot.bot.Bot;
- import org.rsbot.event.listeners.PaintListener;
- import org.rsbot.event.listeners.ServerMessageListener;
- import org.rsbot.event.events.ServerMessageEvent;
- import org.rsbot.script.wrappers.RSItemTile;
- import org.rsbot.script.ScriptManifest;
- @ScriptManifest(authors = {"CamHart"},
- category = "Combat",
- name = "Ardy Druids",
- version = 1.2,
- description = "<html><body><head><style type=\"text/css\"> hr {color: white} p {margin-left: 15px}</style></head>" +
- "<center><b>Ardy Druids</b> Fixed by waterwolf <b>1.2</b></center<br>" +
- "Kills druids n stuff.<br>" +
- "Must have 33 agility and 46 thieving.<br>" +
- "Picks up Herbs and anything else if value, if you want to change ids do so yourself." +
- "If pickup style 1 picks up bad items (bones, coins, etc), then change it to 2." +
- "<b>Instructions</b><br>" +
- "Start anywhere from Ardy North bank to druid tower. <br>" +
- "PickUp Style:<select name=\"pickup\"><option selected value=\"1\">Pickup Style 1</option>" +
- "<option value=\"2\">Pickup Style 2</option></select> [Change to style 2 if 1 picks bad items]<br>" +
- "<input type=\"checkbox\" name=\"antiban\" value=\"true\" checked=\"checked\">Use Script AntiBan<br>" +
- "<input type=\"checkbox\" name=\"update\" value=\"true\" checked=\"checked\">Check for Update<br>" +
- "Loop Delay:<input type=\"text\" name=\"slowCPU\" size=6>  [optional - increase if the script lags your computer (default 10)]" +
- "</body></html>")
- public class ArdyDruids extends Script implements PaintListener, ServerMessageListener { // Names the script
- long startTime = -1;
- int slowCPU = 10;
- int mouseSpeed = 10; //lower = faster
- int errorsFound = 0;
- long lastError = 0;
- double newestVersion = -0.1;
- boolean useAntiBan = true;
- String status = "Starting up...";
- String debug = "";
- int valueOfBankedItems = 0;
- boolean pickUpOption = true;
- boolean canUpdate = false;
- public class GELoader extends Thread {
- public GELoader() {
- }
- @Override
- public void run() {
- debug = "Loading GE item values";
- int loaddots = 0;
- for(int c = 0; c < GEVALUES.length; c++) {
- GEVALUES[c] = grandExchange.loadItemInfo(PICKUPIDS[c]).getMarketPrice() ;
- debug += ".";
- loaddots++;
- if(loaddots > 3) {
- debug = "Loading GE item values (" + c + ")";
- loaddots = 0;
- }
- }
- doneLoading = true;
- }
- }
- boolean doneLoading = false;
- @Override
- public boolean onStart(Map<String, String> args) {
- //newestVersion = ; this doesnt work
- GELoader theGE = new GELoader();
- theGE.start();
- startTime = System.currentTimeMillis();
- String temp = args.get("slowCPU").replaceAll(" ", "");
- if(!temp.equals(null) && !temp.equals("")) {
- if(isNumeric(temp)) {
- slowCPU = Integer.parseInt(temp);
- log("CPU slower set to " + slowCPU + ".");
- }
- else {
- log("cpuSlow:" + temp.replaceAll(" ", "."));
- log("Loop delay must be an integer value!");
- return false;
- }
- }
- temp = args.get("pickup");
- if(temp.contains("1"))
- pickUpOption = true;
- else pickUpOption = false;
- if(args.get("antiban") != null) {
- useAntiBan = true;
- log("Antiban enabled");
- } else {
- useAntiBan = false;
- log("Antiban disabled");
- }
- if(args.get("update") != null) {
- canUpdate = true;
- } else {
- canUpdate = false;
- //log("Picking Priority disabled");
- }
- log("Ardy Druids has started...");
- return true;
- }
- @Override
- public void onFinish() {
- //theAniWatch().stop();
- Bot.getEventManager().removeListener(PaintListener.class, this);
- Bot.getEventManager().removeListener(ServerMessageListener.class, this);
- }
- public void serverMessageRecieved(ServerMessageEvent e) {
- }
- public void onRepaint(Graphics g) {
- if (isLoggedIn()) {
- long millis = System.currentTimeMillis() - startTime;
- long oMillis = millis;
- long hours = millis / (1000 * 60 * 60);
- millis -= hours * (1000 * 60 * 60);
- long minutes = millis / (1000 * 60);
- millis -= minutes * (1000 * 60);
- long seconds = millis / 1000;
- int theYspot = 332;
- g.setColor(new Color(0, 0, 0));
- //replace 4 w/ number of strings being printed
- //g.fill3DRect(6, theYspot - (4 * 15) , 190, (4 * 15) + 6, true);
- g.setColor(new Color(255, 255, 255));
- g.drawString("Ardy Druids v1.2", 9, theYspot);
- /*if(newestVersion > getVersion()) {
- g.drawString("Please visit the link in the script description to update.", 9, theYspot-=15);
- g.drawString(getName() + " has been updated to version " + newestVersion + ", your " + (int)((newestVersion - getVersion()) * 10) + " updates behind!", 9, theYspot-=15);
- } Theres no site to update this crap */
- g.drawString("RunTime: " + (hours < 10 ? "0" + hours : hours) + ":" + (minutes < 10 ? "0" + minutes : minutes) + ":" + (seconds < 10 ? "0" + seconds : seconds), 9, theYspot-=15);
- if(doneLoading) {
- g.drawString("Estimated Profit:" + (valueOfBankedItems + getInventoryValue()), 9, theYspot-=15);
- g.drawString("Profit / hour:" + (int)((valueOfBankedItems + getInventoryValue()) * 3600000D / (double)oMillis), 9, theYspot-=15);
- }
- g.drawString("Status: " + status, 9, theYspot-=15);
- //g.drawString(((getMyPlayer().isInCombat() == true) ? "in combat" : " ---- ") + " : " + ((inCombat() == true) ? "in combat" : " ---- "), 9, theYspot-=15);
- g.drawString("Debug(" + getMouseSpeed() + "): " + debug, 9, theYspot-=15);
- }
- }
- /* Credits to Ruski on these Ids */
- //If you add to the foodids add to the depositallexcept command also
- // UNCOMMENT BELOW to get foodids
- /*private final int[] FOODID = { 1895, 1893, 1891, 4293, 2142, 291, 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, 6883,
- 1971, 4608, 1883, 1885 };
- */
- private int[] NPCDEATHANIMATION = {836};
- //laws, vials = 227
- private int[] PICKUPIDS = {563, 556, 558, 561, 227, 2485, 2486, 3049, 3050,
- 3051, 3052, 12174, 12175, 199, 200, 201, 202, 203, 204, 205, 206, 207,
- 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220,
- 830, 5647, 836, 5653, 5714, 5715, 5728, 5729, 1247, 1248, 1261, 1262,
- 3175, 5730, 5731, 1249, 1250, 1263, 1264, 3176, 5716, 5717, 5730, 5731,
- 554, 557, 562, 560, 985, 986, 987, 988, 1623, 1621, 1619, 1617, 1618,
- 2366, 2367, 2368, 2369, 231, 232, 1462, 1463, 1452, 1453};
- private int[] GEVALUES = new int[PICKUPIDS.length];
- private final int[] BANKIDS = {34752};
- private final RSTile[] TOLOG = {
- new RSTile(2614, 3333), new RSTile(2609, 3337), new RSTile(2603, 3336)
- };
- private final RSTile[] TOTOWER = {
- new RSTile(2598, 3336), new RSTile(2594, 3340), new RSTile(2587, 3343),
- new RSTile(2582, 3345), new RSTile(2579, 3348), new RSTile(2575, 3351),
- new RSTile(2571, 3355), new RSTile(2565, 3356)
- };
- private final RSTile[] TOTOWERCHKPTS = {
- new RSTile(2598, 3336), new RSTile(2595, 3339), new RSTile(2585, 3344),
- new RSTile(2576, 3350), new RSTile(2565, 3356)
- };
- int doorError = 0;
- long lastDoor = 0;
- int logError = 0;
- long lastLog = 0;
- int bankError = 0;
- long lastBank = 0;
- //See if upstairs
- int missClicks = 0;
- long lastMiss = 0;
- long badLadder = 0;
- //long Ladder = 0;
- @Override
- public int loop() {
- if(skills.getCurrSkillLevel(3) <= 10) {
- log("Your hitpoints are at, or below, 10. Stopping script.");
- stopScript();
- }
- /*if(System.currentTimeMillis() - badLadder > rand(60000, 60000 * 30) && ) {
- setCameraAltitude(true);
- }*/
- if(getMyPlayer().getLocation().getY() > 8000) {
- if(!getMyPlayer().isIdle())
- return antiBan(rand(1250, 1500));
- if(System.currentTimeMillis() - badLadder > rand(3000, 8000))
- setCameraAltitude(true);
- badLadder = System.currentTimeMillis();
- RSObject theLadder = getNearestObjectByID(32015);
- if(theLadder == null) {
- log("Couldn't find ladder to climb up, logging out...");
- stopScript();
- }
- else {
- if(random(0, 2) == 0)
- turnToObject(theLadder);
- else if(random(0, 3) == 3)
- setCameraRotation(getCameraAngle() + (random(0, 1) == 0 ? random(-4, -20) : random(4, 20)));
- wait(rand(150, 350));
- if(!atObject(theLadder, "Climb-up")) {
- myWalk(new RSTile(2562, 9757), 0, false);
- wait(rand(2000, 3000));
- turnToTile(new RSTile(2562, 9757));
- }
- }
- }
- if(getPlane() == 1) { //getMyPlayer().getHeight() == 1) {
- if(System.currentTimeMillis() - badLadder > rand(3000, 8000))
- setCameraAltitude(true);
- badLadder = System.currentTimeMillis();
- RSObject theLadder = getObjectAt(2560, 3356); //.findObject(1750);
- if(theLadder == null) {
- log("You're lost, logging out...");
- stopScript();
- }
- else {
- if(random(0, 1) == 1)
- turnToObject(theLadder);
- if(random(0, 5) == 3)
- setCameraRotation(getCameraAngle() + (random(0, 1) == 0 ? random(-4, -20) : random(4, 20)));
- wait(rand(150, 350));
- atObject(theLadder, "Climb-down");
- }
- }
- else if(getInventoryCount() < 28 && !atDruids()) {
- log("a");
- if(getMyPlayer().getLocation().getX() > 2600) { //2600 divides the river
- status = "Walking to log...";
- //bank to log
- //add door enterance
- int posHold = walkToNextTile(TOLOG, -1);
- if(posHold == 1 || distanceTo(TOLOG[TOLOG.length - 1]) < 15) {
- if(getMyPlayer().isMoving())
- return antiBan(rand(150, 550));
- RSObject theLog = getNearestObjectByID(35999); //LOGID - bank to otherside
- if(theLog == null) {
- logError++;
- if(System.currentTimeMillis() - lastLog > 120000) {
- logError = 1;
- }
- lastLog = System.currentTimeMillis();
- if(logError > 60) {
- log("Log cannot be found... Stopping script.");
- stopScript();
- }
- }
- else {
- status = "Crossing log...";
- if(getMyPlayer().isMoving()) {
- wait(antiBan(rand(450, 750)));
- }
- if(distanceTo(TOLOG[TOLOG.length - 1]) > random(1, 4) && distanceTo(TOLOG[TOLOG.length - 1]) < 16)
- myWalk(TOLOG[TOLOG.length - 1]);
- if(atObject(theLog, "Walk-across")) {
- logError = 0;
- return antiBan(rand(1500, 3000));
- }
- else {
- logError++;
- if(System.currentTimeMillis() - lastLog > 120000) {
- logError = 1;
- }
- lastLog = System.currentTimeMillis();
- if(logError > 1)
- turnToObject(theLog);
- if(logError > 60) {
- log("Log cannot be found... Stopping script.");
- log("If character got stuck please PM CamHart with a screen shot.");
- stopScript();
- }
- }
- }
- }
- } else if(getMyPlayer().getLocation().getX() < 2600) {
- status = "Walking to tower...";
- if(!canReach(new RSTile(2592, 3339),false) && canReach(new RSTile(2592, 3338), false)) {
- RSObject theDoor = getNearestObjectByID(2054);
- if(theDoor == null || !atObject(theDoor, "Open")) {
- doorError++;
- if(System.currentTimeMillis() - lastDoor > 120000) {
- doorError = 1;
- }
- lastDoor = System.currentTimeMillis();
- if(doorError > 5)
- //turnToTile(new RSTile(getMyPlayer().getLocation().getX() + 1, getMyPlayer().getLocation().getY()));
- turnToObject(theDoor);
- if(doorError > 10)
- //setCameraAltitude(false);
- setCameraAltitude(random(20, 40));//setCamerAltitude(false)
- if(doorError > 60) {
- log("Door cannot be found... Stopping script.");
- stopScript();
- }
- }
- }
- int posHold = walkToNextTile(TOTOWER, TOTOWERCHKPTS, -1);//editout
- if(posHold == 1) {
- status = "Picking door...";
- if(getMyPlayer().isMoving()) {
- wait(antiBan(rand(450, 750)));
- }
- RSObject theDoor = null;
- try {
- theDoor = getObjectAt(2564, 3356); //findObject(1623);
- } catch (Exception e) {}
- if(theDoor == null) {
- log("null door...");
- try {
- //if(atObject(getObjectAt(2564, 3356), "Pick-lock")) {
- if(openDoor(new RSTile(2565, 3356), "Pick-lock")) {
- doorError = 0;
- return antiBan(rand(1250, 1750));
- }
- else {
- doorError++;
- if(System.currentTimeMillis() - lastDoor > 120000) {
- doorError = 1;
- }
- lastDoor = System.currentTimeMillis();
- if(doorError > 5)
- turnToTile(new RSTile(getMyPlayer().getLocation().getX() + 1, getMyPlayer().getLocation().getY()));
- if(doorError > 10)
- //setCameraAltitude(false);
- setCameraAltitude(random(20, 40));//setCamerAltitude(false)
- if(doorError > 60) {
- log("Door cannot be found... Stopping script.");
- stopScript();
- }
- return antiBan(rand(350, 450));
- }
- } catch (Exception e) {}
- doorError++;
- if(System.currentTimeMillis() - lastDoor > 120000) {
- doorError = 1;
- }
- lastDoor = System.currentTimeMillis();
- if(doorError > 5)
- turnToTile(new RSTile(getMyPlayer().getLocation().getX() + 1, getMyPlayer().getLocation().getY()));
- if(doorError > 2)
- //setCameraAltitude(false);
- setCameraAltitude(random(20, 40));//setCamerAltitude(false)
- if(doorError > 60) {
- log("Door cannot be found... Stopping script.");
- stopScript();
- }
- }
- else {
- if(openDoor(theDoor.getLocation(), "Pick-lock")) {
- doorError = 0;
- return antiBan(rand(1250, 1750));
- }
- else {
- doorError++;
- if(System.currentTimeMillis() - lastDoor > 120000) {
- doorError = 1;
- }
- lastDoor = System.currentTimeMillis();
- /*if(doorError > 1)
- turnToObject(theDoor, random(-5, 5)); */
- if(doorError > 5)
- turnToTile(new RSTile(getMyPlayer().getLocation().getX() + 1, getMyPlayer().getLocation().getY()));
- if(doorError > 3)
- //setCameraAltitude(false);
- setCameraAltitude(random(20, 40));//setCamerAltitude(false)
- if(doorError > 60) {
- log("Door cannot be found... Stopping script.");
- log("If character got stuck please PM CamHart with a screen shot.");
- stopScript();
- }
- }
- }
- }
- //log to tower
- }
- }
- else if(getInventoryCount() == 28) {
- if(atDruids()) {
- status = "Exiting door...";
- if(getMyPlayer().isMoving()) {
- wait(antiBan(rand(450, 750)));
- }
- RSObject theDoor = null;
- try {
- theDoor = getObjectAt(2564, 3356); //findObject(1623);
- } catch (Exception e) {}
- if(theDoor == null) {
- try {
- //if(atObject(getObjectAt(2564, 3356), "Open")) {
- if(openDoor(new RSTile(2564, 3356), "Open")) {//maybe 2563?
- return antiBan(rand(1250, 1750));
- }
- else {
- missClicks++;
- lastMiss = System.currentTimeMillis();
- doorError++;
- if(System.currentTimeMillis() - lastDoor > 120000) {
- doorError = 1;
- }
- lastDoor = System.currentTimeMillis();
- if(doorError > 2)
- setCameraAltitude(random(20, 40));//setCamerAltitude(false)
- if(doorError > 5)
- turnToTile(new RSTile(getMyPlayer().getLocation().getX() - 1, getMyPlayer().getLocation().getY()));
- if(doorError > 60) {
- log("Door cannot be found... Stopping script.");
- log("If character got stuck please PM CamHart with a screen shot.");
- stopScript();
- }
- }
- } catch (Exception e) {}
- doorError++;
- if(System.currentTimeMillis() - lastDoor > 120000) {
- doorError = 1;
- }
- lastDoor = System.currentTimeMillis();
- if(doorError > 60) {
- log("Door cannot be found... Stopping script.");
- log("If character got stuck please PM CamHart with a screen shot.");
- stopScript();
- }
- }
- else {
- if(openDoor(theDoor.getLocation(), "Open")) {
- return antiBan(rand(1250, 1750));
- }
- else {
- missClicks++;
- lastMiss = System.currentTimeMillis();
- doorError++;
- if(System.currentTimeMillis() - lastDoor > 120000) {
- doorError = 1;
- }
- lastDoor = System.currentTimeMillis();
- if(doorError > 2)
- setCameraAltitude(random(20, 40));//setCamerAltitude(false)
- if(doorError > 5)
- turnToTile(new RSTile(getMyPlayer().getLocation().getX() - 1, getMyPlayer().getLocation().getY()));
- if(doorError > 60) {
- log("Door cannot be found... Stopping script.");
- log("If character got stuck please PM CamHart with a screen shot.");
- stopScript();
- }
- }
- }
- }
- else if(getMyPlayer().getLocation().getX() < 2600) {
- status = "Walking to log...";
- if(getMyPlayer().isMoving()) {
- wait(antiBan(rand(450, 750)));
- }
- if(!canReach(new RSTile(2592, 3339), false) && canReach(new RSTile(2592, 3338), false)) {
- RSObject theDoor = getNearestObjectByID(2054);
- if(theDoor == null || !atObject(theDoor, "Open")) {
- doorError++;
- if(System.currentTimeMillis() - lastDoor > 120000) {
- doorError = 1;
- }
- lastDoor = System.currentTimeMillis();
- if(doorError > 5)
- //turnToTile(new RSTile(getMyPlayer().getLocation().getX() + 1, getMyPlayer().getLocation().getY()));
- turnToObject(theDoor);
- if(doorError > 10)
- //setCameraAltitude(false);
- setCameraAltitude(random(20, 40));//setCamerAltitude(false)
- if(doorError > 60) {
- log("Door cannot be found... Stopping script.");
- log("If character got stuck please PM CamHart with a screen shot.");
- stopScript();
- }
- }
- }
- int posHold = walkToNextTile(reversePath(TOTOWER), reversePath(TOTOWERCHKPTS), -1);
- if(posHold == 1 || distanceTo(reversePath(TOTOWER)[TOTOWER.length - 1]) < 15) {
- if(getMyPlayer().isMoving())
- return antiBan(rand(150, 550));
- RSObject theLog = getNearestObjectByID(35997); //LOGID - tower to otherside
- if(theLog == null) {
- logError++;
- if(System.currentTimeMillis() - lastLog > 120000) {
- logError = 1;
- }
- lastLog = System.currentTimeMillis();
- if(logError > 60) {
- log("Log cannot be found... Stopping script.");
- log("If character got stuck please PM CamHart with a screen shot.");
- stopScript();
- }
- }
- else {
- status = "Crossing log...";
- if(getMyPlayer().isMoving()) {
- wait(antiBan(rand(450, 750)));
- }
- if(distanceTo(reversePath(TOLOG)[TOLOG.length - 1]) > random(1, 4) && distanceTo(reversePath(TOLOG)[TOLOG.length - 1]) < 16)
- myWalk(reversePath(TOLOG)[TOLOG.length - 1]);
- if(atObject(theLog, "Walk-across")) {
- logError = 0;
- return antiBan(rand(1500, 3000));
- }
- else {
- logError++;
- if(System.currentTimeMillis() - lastLog > 120000) {
- logError = 1;
- }
- lastLog = System.currentTimeMillis();
- if(logError > 1)
- turnToObject(theLog);
- if(logError > 60) {
- log("Log cannot be found... Stopping script.");
- log("If character got stuck please PM CamHart with a screen shot.");
- stopScript();
- }
- }
- }
- return 1000;
- }
- }
- else if(!atBank()) {
- walkToNextTile(reversePath(TOLOG), -1);
- }
- else if(atBank()) {
- status = "Banking...";
- RSObject theBank = getNearestObjectByID(BANKIDS);
- if(myDistanceBetween(2614, 3333) > 5) {
- myWalk(2614, 3333, 1);
- return antiBan(rand(750, 1250));
- }
- if(bank.isOpen()) {
- int tempValue = getInventoryValue();
- if(bank.depositAll()) {
- valueOfBankedItems += tempValue;
- wait(rand(150, 1250));
- if(random(5, 15) > random(7, 8))
- bank.close();
- }
- }
- else if(theBank != null) {
- if(atObject(theBank, "Use-quickly"))
- return rand(550, 750);
- else {
- bankError++;
- if(System.currentTimeMillis() - lastBank > 120000) {
- bankError = 1;
- }
- if(bankError > random(0, 3))
- turnToObject(theBank);
- if(bankError > 60) {
- log("Problems clicking bank... stopping script.");
- stopScript();
- }
- lastBank = System.currentTimeMillis();
- }
- }
- else {
- bankError++;
- if(System.currentTimeMillis() - lastBank > 120000) {
- bankError = 1;
- }
- lastBank = System.currentTimeMillis();
- }
- }
- }
- else if(atDruids()) {
- //status = "At druids...";
- if(getMyPlayer().isMoving())
- return antiBan(rand(450, 750));
- RSItemTile theItem = getGroundItemByID(10, PICKUPIDS); //getNearestGroundItemByID
- RSNPC theNpc = getNearestFreeNPCByID(181); //chaos druid id
- if(theItem != null) {
- debug = "Picking!";
- if(isMenuOpen() && !inArray("Take", getMenuItems())) {
- debug = " [trashing bad menu]";
- moveMouse(random(0, 764), random(0, 502));
- }
- if(!atGroundItem(theItem)) {
- missClicks++;
- if(missClicks > 10) {
- setCameraRotation(getCameraAngle() + (random(0, 1) == 1 ? random(-10, -30) : random(10, 30)));
- missClicks = 0;
- }
- lastMiss = System.currentTimeMillis();
- }
- return antiBan(rand(150, 350));
- } else if(theNpc != null && !inArray(theNpc.getAnimation(), NPCDEATHANIMATION) && !inCombat()) {
- status = "Killing druids...";
- if(clickNPC(theNpc, "Attack")) {
- debug = "Attacking!";
- }
- else {
- missClicks++;
- lastMiss = System.currentTimeMillis();
- }
- }
- }
- return antiBan(rand(350, 550));
- }
- public boolean openDoor(RSTile theDoor, String command) {
- log("blah");
- if(!pointOnScreen(Calculations.tileToScreen(theDoor))) {
- log("asdf");
- if(!tileOnMap(theDoor))
- log("Door not on map...");
- else {
- log("wth");
- myWalk(theDoor, 1, true);
- return false;
- }
- } else {
- log("moving...");
- Point newPoint = Calculations.tileToScreen(theDoor);
- newPoint.setLocation(newPoint.getX(), newPoint.getY() - random(35, 55));
- moveMouse(newPoint);
- if(inMenuOptions(command)) {
- log("donit");
- clickMouse(false);
- return atMenu(command);
- }
- }
- return false;
- }
- public int getInventoryValue() {
- int value = 0;
- RSItem[] rsInvyItems = getInventoryItems();
- int[] invyItems = getInventoryArray();
- for(int c = 0; c < invyItems.length; c++) {
- if(inArray(invyItems[c], PICKUPIDS)) {
- try {
- int index = getIndexInArray(invyItems[c], PICKUPIDS);
- if(index != -1)
- value += (GEVALUES[index] * rsInvyItems[c].getStackSize());
- else if(debug.indexOf(" [bad item]") < 0)
- debug += " [bad item]";
- } catch (NullPointerException e) {
- log("Something screwed up in getting item value...");
- }
- }
- }
- return value;
- }
- /* returns -1 if not found*/
- public int getIndexInArray(int value, int[] stuff) {
- int retval = -1;
- for(int c = 0; c < stuff.length; c++) {
- if(stuff[c] == value) {
- retval = c;
- return retval;
- }
- }
- return retval;
- }
- public boolean atDruids() {
- return canReach(new RSTile(2564, 3356), false);
- }
- public boolean needToBank() {
- return false;
- }
- public boolean atBank() {
- int value = myDistanceBetween(2614, 3333);
- return value != -1 && value <= 5;
- }
- /* Credits to Ruski - Stolen from RuskisFighterV2.java */
- public RSItemTile getNearestGroundItemByID(int range, int[] ids) {
- int pX = getMyPlayer().getLocation().getX();
- int pY = getMyPlayer().getLocation().getY();
- int minX = pX - range;
- int minY = pY - range;
- int maxX = pX + range;
- int maxY = pY + range;
- int dist = 100;
- RSItemTile nItem = null;
- for (int x = minX; x <= maxX; x++) {
- for (int y = minY; y <= maxY; y++) {
- if (Calculations.canReach(new RSTile(x, y), false)) {
- RSItemTile[] items = getGroundItemsAt(x, y);
- for (RSItemTile item : items) {
- int iId = item.getItem().getID();
- for (int id : ids) {
- if (iId == id) {
- if (distanceTo(new RSTile(x, y)) < dist) {
- dist = distanceTo(new RSTile(x, y));
- nItem = item;
- }
- }
- }
- }
- }
- }
- }
- return nItem;
- }
- /* Also stolen from Ruski*/
- private RSNPC[] getInteractingNPCs() {
- ArrayList<RSNPC> npcList = new ArrayList<RSNPC>();
- org.rsbot.accessors.RSNPC[] npcs = Bot.getClient().getRSNPCArray();
- for (int a = 0; a < npcs.length; a++) {
- RSNPC npc = new RSNPC(npcs[a]);
- if (!npc.isValid()) {
- continue;
- }
- if (npc.isInteractingWithLocalPlayer()) {
- npcList.add(npc);
- }
- }
- return npcList.toArray(new RSNPC[npcList.size()]);
- }
- public boolean inCombat() {
- if(getMyPlayer().isInCombat())
- return true;
- else if(getMyPlayer().getInteracting() != null) {
- RSNPC[] interactingNpcs = getInteractingNPCs();
- if(interactingNpcs.length > 0) {
- if(interactingNpcs[0].getHPPercent() != 0)
- return true;
- }
- }
- return false;
- }
- /* Updated May 08, 2009 */
- public boolean atGroundItem(RSItemTile theItemTile) {
- RSItemTile[] itemsOnGround = getGroundItemsAt(new RSTile(theItemTile.getX(), theItemTile.getY()));
- int itemIndex = -1;
- //boolean foundBones = false;
- for(int q = 0; q < itemsOnGround.length; q++) {
- if(itemsOnGround[q].getItem().getID() == theItemTile.getItem().getID()) {
- if(pickUpOption) {
- log("a");
- itemIndex = (itemsOnGround.length - 1) - q; //itemsOnGround.length - 1 - q; q;
- }
- else {
- log("b");
- itemIndex = q;
- }
- break;
- }
- }
- if(itemIndex == -1)
- return false;
- moveMouse(Calculations.tileToScreen(new RSTile(theItemTile.getX(), theItemTile.getY())), random(-5, 5), random(-5, 5));
- ArrayList<String> menuOptions = getMenuItems();
- for(int q = 0; q < menuOptions.size(); q++) {
- if(menuOptions.get(q).startsWith("Take")) {
- clickMouse(false);
- return atMenuItem(q + itemIndex);
- }
- }
- return false;
- }
- public int findFood(int[] foods) {
- int[] invy = getInventoryArray();
- for(int q = 0; q < invy.length; q++) {
- if(inArray(invy[q], foods))
- return invy[q];
- }
- return -1;
- }
- /*
- if TrickFood = true, then that means your
- TrickFood = 0 after banking
- TrickFood = 1 once fighting
- */
- public boolean inArray(int a, int[] lots) {
- for(int c = 0; c < lots.length; c++) {
- if(lots[c] == a)
- return true;
- }
- return false;
- }
- public boolean inArray(String a, ArrayList<String> lots) {
- for(int c = 0; c < lots.size(); c++) {
- if(lots.get(c).contains(a))
- return true;
- }
- return false;
- }
- public boolean atMenuCheck(String command) {
- ArrayList<String> options = getMenuItems();
- for(int c = 0; c < options.size(); c++) {
- if(options.get(c).contains(command)) {
- if(atMenuItem(c))
- return true;
- }
- }
- return false;
- }
- public boolean inMenuOptions(String command) {
- ArrayList<String> options = getMenuItems();
- for(int c = 0; c < options.size(); c++) {
- if(options.get(c).contains(command)) {
- return true;
- }
- }
- return false;
- }
- /*
- This doesn't support doors, if a door is closed or somehow
- a spot becomes unreachable it screws up. Only use when
- walking places that will not be blocked.
- *checkPts need to be points in an almost straight line from start to destination, no turns.
- (if you need turns just do several of these walks ending/starting at the turn points)
- return values
- 1 = at destination
- 750+ = still have walking to do
- -1 = unreachable / error
- */
- int chkptIndex = 0;
- int pathIndex = 0;
- public int walkToNextTile(RSTile[] thePath, int randomValue) {
- RSTile[] checkPts = new RSTile[] {thePath[0], thePath[thePath.length - 1]};
- return walkToNextTile(thePath, checkPts, randomValue);
- }
- /* If randomValue is negative then it uses 3 for all points except the last where it'll use 1. */
- /* public int walkToNextTile(RSTile[] thePath, RSTile[] checkPts, int randomValue) {
- if(getMyPlayer().isMoving() && distanceTo(getDestination()) > random(2, 8))
- return rand(400, 1250);
- /* Checks if players not moving but has destination
- RSTile tempCheck = null;
- try {
- tempCheck = getDestination();
- } catch (NullPointerException e) {}
- if(!getMyPlayer().isMoving() && tempCheck != null) {
- wait(antiBan(rand(750, 1250)));
- if(!getMyPlayer().isMoving()) {
- log("no dist at player walk");
- if(random(0, 9) < random(0, 2))
- myWalk(getMyPlayer().getLocation(), 2);
- else {
- moveMouse(Calculations.tileToScreen(getMyPlayer().getLocation()), random(-3, 3), random(-3, 3));
- wait(rand(0, 10));
- clickMouse(true);
- }
- }
- return rand(150, 350);
- }
- RSTile nextTile = null;
- int leastDist = 9999;
- RSTile curCheckPt = null;
- //if player is within rand of end
- if(!isLoggedIn())
- return -1;
- int tempDist1 = myDistanceBetween(getMyPlayer().getLocation(), thePath[thePath.length - 1]);
- log("dist:" + tempDist1);
- if(tempDist1 < random(2, 4) && tempDist1 != -1)
- return 1;
- if(tempDist1 == -1 || tempDist1 > 15) {
- for(int c = 0; c < checkPts.length; c++) {
- if(myDistanceBetween(getMyPlayer().getLocation(), checkPts[c]) != -1 && (distanceBetween(checkPts[c], checkPts[checkPts.length - 1]) < distanceBetween(getMyPlayer().getLocation(), checkPts[checkPts.length - 1])) && (distanceBetween(checkPts[c], checkPts[checkPts.length - 1]) < leastDist)) {
- leastDist = distanceBetween(checkPts[c], checkPts[checkPts.length - 1]);
- curCheckPt = checkPts[c];
- chkptIndex = c;
- wait(slowCPU);;
- }
- }
- } else {
- curCheckPt = thePath[thePath.length - 1];
- }
- tempDist1 = myDistanceBetween(getMyPlayer().getLocation(), curCheckPt);
- leastDist = 9999;
- for(int c = 0; c < thePath.length; c++) {
- boolean tempBool = false;
- try {
- tempBool = canReach(thePath[c], false);
- }
- catch(Exception e) {
- log("printstacktrace");
- e.printStackTrace();
- }
- RSTile tempTile = getDestination();
- int tempDist = 0;
- if(tempTile == null) {
- tempTile = getMyPlayer().getLocation();
- tempDist = 99;
- }
- else
- tempDist = distanceBetween(thePath[c], tempTile);
- if(tempBool && tempDist > 4) {
- int tempDist2 = myDistanceBetween(getMyPlayer().getLocation(), thePath[c]);
- if(tempDist2 < leastDist && distanceTo(thePath[c]) < 15) {
- int tempDist3 = myDistanceBetween(thePath[c], curCheckPt);
- if(tempDist1 >= tempDist3) {
- pathIndex = c;
- leastDist = tempDist3;
- nextTile = thePath[c];
- }
- }
- }
- wait(slowCPU);;
- }
- if(nextTile != null) {
- if(canReach(nextTile, false)) {
- int randVal = randomValue;
- if(randomValue < 0)
- randVal = (distanceTo(thePath[thePath.length - 1]) < 10) ? 1 : 3;
- myWalk(nextTile, randVal);
- return rand(750, 1500);
- } else {
- errorsFound++;
- if((System.currentTimeMillis() - lastError) > 10000) {
- errorsFound = 0;
- lastError = 0;
- }
- }
- } else {
- errorsFound++;
- log("walking error: " + errorsFound);
- if((System.currentTimeMillis() - lastError) > 30000) {
- errorsFound = 1;
- }
- lastError = System.currentTimeMillis();
- }
- if(errorsFound > 100) {
- log("100+ errors have been found. Script killing.");
- log("Please supply the following information to CamHart:");
- log(gatherInfo());
- log("Sorry for any inconvience. I'll get on a fix asap.");
- stopScript();
- }
- return rand(250, 500);
- }*/
- public int walkToNextTile(RSTile[] thePath, RSTile[] checkPts, int randomValue) {
- if(getMyPlayer().isMoving() && distanceTo(getDestination()) > random(2, 8))
- return rand(400, 1250);
- /* Checks if players not moving but has destination */
- RSTile tempCheck = null;
- try {
- tempCheck = getDestination();
- } catch (NullPointerException e) {}
- if(!getMyPlayer().isMoving() && tempCheck != null) {
- wait(antiBan(rand(750, 1250)));
- if(!getMyPlayer().isMoving()) {
- if(random(0, 9) < random(0, 2) || !pointOnScreen(Calculations.tileToScreen(getMyPlayer().getLocation())))
- myWalk(getMyPlayer().getLocation(), 2);
- else {
- moveMouse(Calculations.tileToScreen(getMyPlayer().getLocation()), random(-3, 3), random(-3, 3));
- wait(rand(0, 10));
- clickMouse(true);
- }
- }
- return rand(150, 350);
- }
- RSTile nextTile = null;
- int leastDist = 9999;
- RSTile curCheckPt = null;
- //if player is within rand of end
- if(!isLoggedIn())
- return -1;
- int tempDist1 = myDistanceBetween(getMyPlayer().getLocation(), thePath[thePath.length - 1]);
- if(tempDist1 < random(2, 4) && tempDist1 != -1)
- return 1;
- if(tempDist1 == -1 || tempDist1 > 15) {
- for(int c = 0; c < checkPts.length; c++) {
- if(myDistanceBetween(getMyPlayer().getLocation(), checkPts[c]) != -1 && (distanceBetween(checkPts[c], checkPts[checkPts.length - 1]) < distanceBetween(getMyPlayer().getLocation(), checkPts[checkPts.length - 1])) && (distanceBetween(checkPts[c], checkPts[checkPts.length - 1]) < leastDist)) {
- leastDist = distanceBetween(checkPts[c], checkPts[checkPts.length - 1]);
- curCheckPt = checkPts[c];
- log("dist:" + myDistanceBetween(getMyPlayer().getLocation(), curCheckPt));
- wait(slowCPU);;
- }
- }
- } else {
- curCheckPt = thePath[thePath.length - 1];
- }
- tempDist1 = myDistanceBetween(getMyPlayer().getLocation(), curCheckPt);
- leastDist = 9999;
- for(int c = 0; c < thePath.length; c++) {
- boolean tempBool = false;
- try {
- tempBool = canReach(thePath[c], false);
- }
- catch(Exception e) {
- log("printstacktrace");
- e.printStackTrace();
- }
- RSTile tempTile = getDestination();
- int tempDist = 0;
- if(tempTile == null) {
- tempTile = getMyPlayer().getLocation();
- tempDist = 99;
- }
- else
- tempDist = distanceBetween(thePath[c], tempTile);
- if(tempBool && tempDist > 4) {
- int tempDist2 = myDistanceBetween(getMyPlayer().getLocation(), thePath[c]);
- if(tempDist2 < leastDist && distanceTo(thePath[c]) < 15) {
- int tempDist3 = myDistanceBetween(thePath[c], curCheckPt);
- if(tempDist1 >= tempDist3) {
- leastDist = tempDist3;
- nextTile = thePath[c];
- }
- }
- }
- wait(slowCPU);;
- }
- if(nextTile != null) {
- if(canReach(nextTile, false)) {
- int randVal = randomValue;
- if(randomValue < 0)
- randVal = (distanceTo(thePath[thePath.length - 1]) < 10) ? 1 : 3;
- myWalk(nextTile, randVal);
- return rand(750, 1500);
- } else {
- errorsFound++;
- if((System.currentTimeMillis() - lastError) > 10000) {
- errorsFound = 0;
- lastError = 0;
- }
- }
- } else {
- errorsFound++;
- log("walking error: " + errorsFound);
- if((System.currentTimeMillis() - lastError) > 180000) {
- errorsFound = 1;
- }
- lastError = System.currentTimeMillis();
- }
- if(errorsFound > 50) {
- log("Trying to get back on path...");
- if(!getMyPlayer().isMoving()) {
- if(myWalkTo(thePath[thePath.length - 1]))
- wait(rand(1250, 1500));
- }
- }
- if(errorsFound > 100) {
- log("100+ errors have been found. Script killing.");
- log("Please supply the following information to CamHart:");
- log(gatherInfo());
- log("Sorry for any inconvience. I'll get on a fix asap.");
- stopScript();
- }
- return rand(250, 500);
- }
- public boolean myWalkTo(RSTile blah) {
- return myWalkTo(blah.getX(), blah.getY());
- }
- public boolean myWalkTo(final int x, final int y) {
- final RSTile[] path = generateProperPath(x, y);
- if (path == null) {
- return false;
- }
- //while (true) {
- if (!getMyPlayer().isMoving() || distanceTo(getDestination()) > 4) {
- if (myWalkPathMM(randomizePath(path, 2, 2), 17)) {
- errorsFound++;
- wait(random(750, 1250));
- return true;
- }
- }
- //}
- return false;
- }
- int tooShort = 0;
- private static RSTile myCurrent = new RSTile(0, 0);
- public boolean myWalkPathMM(final RSTile[] path, final int maxDist) {
- try {
- final RSTile next = nextTile(path, maxDist);
- if(distanceTo(next) < 4) {
- errorsFound++;
- tooShort++;
- if(tooShort > 10)
- return false;
- }
- if (next != null && !next.equals(myCurrent)) {
- walkTileMM(next);
- wait(random(750, 1250));
- myCurrent = next;
- return false;
- } else if (next != null && next.equals(myCurrent)) {
- return false;
- }
- } catch (final Exception e) {
- return false;
- }
- return true;
- }
- /*
- Stole this from PowerChopper by Megaalgos. Touched it up to work how I wanted it to.
- */
- public int antiBan(int retval) {
- int gamble = random(1, random(75, 100));
- int x = random(0, 750);
- int y = random(0, 500);
- int xx = random(554, 710);
- int yy = random(230, 444);
- int screenx = random(1, 510);
- int screeny = random(1, 450);
- debug += "#";
- if(!useAntiBan)
- return retval;
- switch (gamble) {
- case 1:
- return retval;
- case 2:
- moveMouse(x, y);
- return retval;
- case 3:
- openTab(TAB_INVENTORY);
- return retval;
- case 4:
- if (getMyPlayer().isMoving()) {
- return retval;
- }
- case 5:
- openTab(TAB_STATS);
- moveMouse(random(663, 711), random(325, 348)); //663, 325 711, 348
- return retval;
- case 6:
- if (getCurrentTab() != TAB_STATS) {
- openTab(TAB_STATS);
- moveMouse(xx, yy);
- return retval;
- }
- case 7:
- if (random(1, 8) == 2) {
- int angle = getCameraAngle() + random(-90, 90);
- if (angle < 0) {
- angle = 0;
- }
- if (angle > 359) {
- angle = 0;
- }
- setCameraRotation(angle);
- }
- return retval;
- case 8:
- moveMouse(screenx, screeny);
- return retval;
- case 9:
- moveMouse(screenx, screeny);
- return retval;
- case 10:
- randomTab();
- wait(rand(0, 250));
- return retval;
- case 11:
- wait(rand(0, 250));
- moveMouse(screenx, screeny);
- return retval;
- case 12:
- wait(rand(0, 250));
- moveMouse(screenx, screeny);
- return retval;
- case 13:
- wait(rand(0, 250));
- moveMouse(screenx, screeny);
- return retval;
- case 14:
- //log("moving mouse off screen...");
- wait(rand(100, 1000));
- moveMouse(random(-800, 800), random(-800, 800));
- return retval;
- case 15:
- //log("moving mouse off screen...");
- wait(rand(100, 1000));
- moveMouse(random(-200, 800), random(-100, 800));
- return retval;
- }
- return retval;
- }
- /* Also taken from PowerChopper.java*/
- public int randomTab() {
- int random1 = random(1, random(23, 28));
- switch (random1) {
- case 1:
- openTab(TAB_STATS);
- return random(100, 500);
- case 2:
- openTab(TAB_ATTACK);
- return random(100, 500);
- case 3:
- openTab(TAB_QUESTS);
- return random(100, 500);
- case 4:
- openTab(TAB_EQUIPMENT);
- return random(100, 500);
- case 5:
- openTab(TAB_INVENTORY);
- return random(100, 500);
- case 6:
- openTab(TAB_PRAYER);
- return random(100, 500);
- case 7:
- openTab(TAB_MAGIC);
- return random(100, 500);
- case 8:
- openTab(TAB_SUMMONING);
- return random(100, 500);
- case 9:
- openTab(TAB_FRIENDS);
- return random(100, 500);
- case 10:
- openTab(TAB_IGNORE);
- return random(100, 500);
- case 11:
- openTab(TAB_CLAN);
- return random(100, 500);
- case 12:
- openTab(TAB_CONTROLS);
- return random(100, 500);
- case 13:
- openTab(TAB_MUSIC);
- return random(100, 500);
- case 14:
- openTab(TAB_OPTIONS);
- return random(100, 500);
- case 15:
- openTab(TAB_STATS);
- return random(100, 500);
- case 16:
- openTab(TAB_STATS);
- return random(100, 500);
- case 17:
- openTab(TAB_INVENTORY);
- return random(100, 500);
- case 18:
- openTab(TAB_INVENTORY);
- return random(100, 500);
- case 19:
- openTab(TAB_INVENTORY);
- return random(100, 500);
- }
- return random(100, 300);
- }
- public String gatherInfo() {
- String ret = "Location:" + getMyPlayer().getLocation().getX() + ", " + getMyPlayer().getLocation().getY() + "\n";
- ret += "Along with a screenshot of your character and a description of what was occuring (if you can).";
- return ret;
- }
- public boolean myWalk(int x, int y) {
- return myWalk(new RSTile(x, y), 3);
- }
- public boolean myWalk(int x, int y, int randVal) {
- return myWalk(new RSTile(x, y), randVal);
- }
- public boolean myWalk(RSTile walkTo) {
- return myWalk(walkTo, 3);
- }
- public boolean myWalk(RSTile walkTo, int val) {
- return myWalk(walkTo, val, false);
- }
- public boolean myWalk(RSTile walkTo, int randVal, boolean isObject) {
- if(getEnergy() >= random(random(30, 60), random(61, 100)))
- setRun(true);
- int randX = random(-randVal, randVal);
- int randY = random(-randVal, randVal);
- for(int c = 0; c < 5; c++) {
- RSTile tempTile = new RSTile(walkTo.getX() + randX, walkTo.getY() + randY);
- if(canReach(tempTile, isObject)) {
- if(Math.abs(myDistanceBetween(getMyPlayer().getLocation(), tempTile) - myDistanceBetween(getMyPlayer().getLocation(), walkTo)) <= 4) {
- //log(" walking to " + tempTile.getX() + "," + tempTile.getY());
- Point thePoint = Calculations.tileToScreen(tempTile);
- thePoint.setLocation(thePoint.getX() + random(-(randVal * 10), (randVal * 10)), thePoint.getY() + random(-(randVal * 10), (randVal * 10)));
- if(pointOnScreen(thePoint) && random(0, 10) > 3){
- moveMouse(thePoint);
- log("fancy walk :" + tempTile);
- return atMenu("Walk here");
- }
- else if(tileOnMap(tempTile)){
- boolean retVal = false;
- try{
- retVal = walkTileMM(tempTile);
- } catch(Exception e) {
- e.printStackTrace();
- }
- return retVal;
- } else {
- log("Error with coord: " + tempTile);
- }
- }
- }
- randX = random(-randVal, randVal);
- randY = random(-randVal, randVal);
- }
- if(canReach(walkTo, isObject)) {
- return walkTileMM(walkTo);
- }
- return false;
- }
- /*public boolean myWalk(RSTile walkTo, int randVal) {
- if(getEnergy() >= random(random(30, 60), random(61, 100)))
- setRun(true);
- int randX = random(-randVal, randVal);
- int randY = random(-randVal, randVal);
- for(int c = 0; c < 5; c++) {
- RSTile tempTile = new RSTile(walkTo.getX() + randX, walkTo.getY() + randY);
- if(canReach(tempTile, false)) {
- if(Math.abs(myDistanceBetween(getMyPlayer().getLocation(), tempTile) - myDistanceBetween(getMyPlayer().getLocation(), walkTo)) <= 4) {
- //log(" walking to " + tempTile.getX() + "," + tempTile.getY());
- Point thePoint = Calculations.tileToScreen(tempTile);
- thePoint.setLocation(thePoint.getX() + random(-(randVal * 10), (randVal * 10)), thePoint.getY() + random(-(randVal * 10), (randVal * 10)));
- if(pointOnScreen(thePoint) && distanceTo(tempTile) < random(3, 5)){
- moveMouse(thePoint);
- log("fancy walk :" + tempTile);
- return atMenu("Walk here");
- }
- else {
- boolean retVal = false;
- try{
- retVal = walkTileMM(tempTile);
- } catch(Exception e) {
- e.printStackTrace();
- }
- return retVal;
- }
- }
- }
- randX = random(-randVal, randVal);
- randY = random(-randVal, randVal);
- }
- if(canReach(walkTo, false)) {
- return walkTileMM(walkTo);
- }
- return false;
- } */
- public int myDistanceBetween(int sx, int sy, int ex, int ey) {
- return myDistanceBetween(new RSTile(sx, sy), new RSTile(ex, ey));
- }
- public int myDistanceBetween(RSTile end) {
- return myDistanceBetween(getMyPlayer().getLocation(), end);
- }
- public int myDistanceBetween(int s, int e) {
- return myDistanceBetween(new RSTile(s, e));
- }
- public int myDistanceBetween(RSTile start, RSTile end) {
- int ret;
- if(start == null || end == null)
- return -1;
- try {
- ret = Calculations.getRealDistanceTo(start.getX() - Bot.getClient().getBaseX(), start.getY() - Bot.getClient().getBaseY(), end.getX() - Bot.getClient().getBaseX(), end.getY() - Bot.getClient().getBaseY(), false);
- } catch (ArrayIndexOutOfBoundsException e) {
- log(" ERROR:" + e);
- ret = -1;
- }
- return ret;
- }
- public int distanceTo(int s, int e) {
- return distanceTo(new RSTile(s, e));
- }
- public int rand(int a, int b) {
- int ret = 0;
- int temp = random(0, random(10, 20));
- if(temp == 4)
- ret = random(a, b) * random(1, random(1, 5));
- else
- ret = random(a, b);
- //log("RandWait: " + ret);
- return ret;
- }
- public boolean isNumeric(String str) {
- try {
- Integer.parseInt(str);
- return true;
- }
- catch (Exception e) {
- return false;
- }
- }
- @Override
- public int getMouseSpeed() {
- return mouseSpeed;
- }
- public double getCorrectVersion(String scriptName) {
- if(!canUpdate)
- return 0.0;
- try {
- URL link = new URL("http://camhart.com/Scripts/ScriptVersions.txt");
- BufferedReader br = new BufferedReader(new InputStreamReader(new BufferedInputStream(link.openConnection().getInputStream())));
- int charRead = 0;
- double version = -0.1;
- String data = "";
- while(charRead != -1) {
- charRead = br.read();
- data += (char)charRead;
- //log("Character Read Was: " + charRead);
- }
- //log("String: " + data);
- ArrayList<String> lineByLine = split(data, 10);//13 = carriage return, 10 = line feed
- for(int c = 0; c < lineByLine.size(); c++) {
- //log("LineByLine: " + lineByLine.get(c));
- if(lineByLine.get(c).startsWith(scriptName)) {
- version = Double.parseDouble(lineByLine.get(c).substring(lineByLine.get(c).indexOf(':') + 1, lineByLine.get(c).lastIndexOf(';')));
- }
- }
- br.close();
- //log(scriptName + " version is " + version);
- return version;
- } catch (IOException e) {
- log("Problems checking for updates.");
- throw new RuntimeException(e);
- }
- }
- public ArrayList<String> split(String list, int splitChar) {
- return split(list, (char)splitChar);
- }
- public ArrayList<String> split(String list, char splitChar) {
- ArrayList<String> ret = new ArrayList<String>();
- int prevCut = 0;
- for(int c = 0; c < list.length(); c++) {
- if(list.charAt(c) == splitChar) {
- ret.add(list.substring(prevCut, c).trim());
- prevCut = c;
- }
- }
- return ret;
- }
- /* Ruskis */
- private boolean clickNPC(final RSNPC npc, final String action) {
- try {
- int a;
- final StringBuffer npcCommandBuf = new StringBuffer();
- npcCommandBuf.append(action);
- npcCommandBuf.append(" ");
- npcCommandBuf.append(npc.getName());
- final String npcCommand = npcCommandBuf.toString();
- for (a = 10; a-- >= 0;) {
- if (npc.getInteracting() != null
- && !npc.isInteractingWithLocalPlayer()) {
- return false;
- }
- final List<String> menuItems = getMenuItems();
- if (menuItems.size() > 1) {
- if (listContainsString(menuItems, npcCommand)) {
- if (menuItems.get(0).contains(npcCommand)) {
- clickMouse(true);
- return true;
- } else {
- // clickMouse(false);
- wait(random(230, 520));
- return atMenu(npcCommand);
- }
- }
- }
- final Point screenLoc = npc.getScreenLocation();
- if (!pointOnScreen(screenLoc)) {
- return false;
- }
- final Point randomP = new Point(random(screenLoc.x - 15,
- screenLoc.x + 15), random(screenLoc.y - 15,
- screenLoc.y + 15));
- if (randomP.x >= 0 && randomP.y >= 0) {
- moveMouse(randomP);
- }
- }
- return false;
- } catch (final Exception e) {
- //log.log(Level.SEVERE, "clickNPC(RSNPC, String) error: ", e);
- return false;
- }
- }
- // Optimized version of array contains string
- private boolean listContainsString(final List<String> list,
- final String string) {
- try {
- int a;
- for (a = list.size() - 1; a-- >= 0;) {
- if (list.get(a).contains(string)) {
- return true;
- }
- }
- } catch (final Exception e) {
- }
- return false;
- }
- }
