import java.awt.*;
import java.util.*;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.URL;
import java.net.URLConnection;
import com.speljohan.rsbot.bot.*;
import com.speljohan.rsbot.script.*;
import com.speljohan.rsbot.script.wrappers.*;
import com.speljohan.rsbot.event.listeners.*;
public class TenacGuildMiner extends Script implements PaintListener {
int[] bankerID = { 6200 };
int[] bankBoothID = { 11758 };
RSTile topLadderTile = new RSTile(3019, 3339);
int[] ladderID = { 30941 };
int[] coalRockID = { 31068, 31069, 31070 };
int[] mithRockID = { 31086, 31087, 31088, };
int coalID = 453;
int mithrilID = 447;
int[] gemID = { 1617, 1619, 1621, 1623 };
int[] pickaxeHandleID = { 466 };
int[] pickaxeID = { 1265, 1267, 1269, 1273, 1271, 1275 };
int[] pickaxeHeadID = { 480, 482, 484, 486, 488, 490 };
int[] brokenPickaxeID = { 468, 470, 472, 474, 476, 478 };
int[] junkItems = { 1917, 1971 }; //beer, kebab,
int goldPiecesID = 995;
RSTile lumbridgeTile = new RSTile(3221, 3218);
RSTile bankTile = new RSTile(3014, 3356);
RSTile[] betweenBankAndLadderTiles = { new RSTile(3019, 3351), new RSTile(3022, 3351), new RSTile(3024, 3352) };
RSTile ladderTile = new RSTile(3022, 3340);
//RSTile[] topLadderTiles = { new RSTile(3022, 3341), new RSTile(3022, 3337) };
//RSTile[] bottomLadderTiles = { new RSTile(3021, 9741), new RSTile(3022, 9740) };
RSTile[] coalToLadderPath = { new RSTile(3046, 9747), new RSTile(3041, 9744), new RSTile(3036, 9737),
new RSTile(3030, 9736), new RSTile(3020, 9740) };
RSTile[] ladderToCoalPath = reversePath(coalToLadderPath);
RSTile[] lumbridgeToFalidorPath = { new RSTile(3226, 3218), new RSTile(3233, 3220), new RSTile(3233, 3225),
new RSTile(3231, 3230), new RSTile(3228, 3233), new RSTile(3223, 3238),
new RSTile(3221, 3242), new RSTile(3219, 3247), new RSTile(3218, 3251),
new RSTile(3217, 3256), new RSTile(3217, 3257), new RSTile(3217, 3261),
new RSTile(3217, 3266), new RSTile(3216, 3272), new RSTile(3216, 3277),
new RSTile(3210, 3280), new RSTile(3205, 3280), new RSTile(3204, 3279),
new RSTile(3197, 3279), new RSTile(3190, 3282), new RSTile(3184, 3286),
new RSTile(3178, 3287), new RSTile(3172, 3286), new RSTile(3165, 3285),
new RSTile(3158, 3291), new RSTile(3149, 3296), new RSTile(3143, 3294),
new RSTile(3137, 3295), new RSTile(3136, 3295), new RSTile(3130, 3295),
new RSTile(3123, 3299), new RSTile(3118, 3296), new RSTile(3112, 3295),
new RSTile(3106, 3295), new RSTile(3099, 3295), new RSTile(3094, 3292),
new RSTile(3088, 3290), new RSTile(3082, 3289), new RSTile(3076, 3288),
new RSTile(3074, 3284), new RSTile(3074, 3280), new RSTile(3069, 3277),
new RSTile(3063, 3277), new RSTile(3057, 3276), new RSTile(3050, 3276),
new RSTile(3047, 3276), new RSTile(3044, 3274), new RSTile(3037, 3277),
new RSTile(3030, 3278), new RSTile(3024, 3276), new RSTile(3018, 3275),
new RSTile(3013, 3276), new RSTile(3011, 3278), new RSTile(3007, 3284),
new RSTile(3004, 3289), new RSTile(3007, 3294), new RSTile(3006, 3299),
new RSTile(3004, 3304), new RSTile(3006, 3310), new RSTile(3007, 3316),
new RSTile(3007, 3321), new RSTile(3005, 3326), new RSTile(3007, 3331),
new RSTile(3007, 3332), new RSTile(3007, 3337), new RSTile(3007, 3343),
new RSTile(3007, 3349), new RSTile(3005, 3355), new RSTile(3007, 3361),
new RSTile(3012, 3361), new RSTile(3015, 3355) };
long startTime = System.currentTimeMillis();
int startingLevel = skills.getCurrentSkillLevel(STAT_MINING);
int startingExperience = skills.getCurrentSkillExp(STAT_MINING);
int ranAwayFromCombat = 0;
int gemsBanked = 0;
int coalBanked = 0;
int mithBanked = 0;
int xpPerCoal = 50;
int energyToRunAt = random(50, 90);
boolean walkBack = false;
boolean miningMith = false;
int priceOfCoal = getMarketPriceOfItem(coalID);
int priceOfMithril = getMarketPriceOfItem(mithrilID);
public double getVersion() {
return 1.1;
}
public String getName() {
return "Guild Miner";
}
public String getAuthor() {
return "Tenac";
}
public String getScriptCategory() {
return "Mining";
}
public String getScriptDescription( ) {
String html = "";
html += "<html>\n";
html += "<body>\n";
html += "<font size=\"6\">";
html += "<center><h2>" + getName() + "</h2></center>\n";
html += "</font>";
html += "<b>Author:</b>" + getAuthor() + "<br/>";
html += "<b>Version:</b>" + getVersion() + "<br/><br>";
html += "Start anywhere with a pickaxe and at least 60 mining, preferably inside Falidor East bank or Mining Guild.<br>\n<br>";
html += "<input type=\"checkbox\" name=\"mineMith\" value=\"yes\" checked>Mine mithril rocks also?\n<br>";
html += "</body>\n";
html += "</html\n";
return html;
}
public boolean onStart(Map<String, String> args) {
startTime = System.currentTimeMillis();
if(isLoggedIn()) {
startingLevel = skills.getCurrentSkillLevel(STAT_MINING);
startingExperience = skills.getCurrentSkillExp(STAT_MINING);
setCameraAltitude(true);
setCameraRotation(random(1, 359));
}
if(args.get("mineMith") != null)
miningMith = true;
Bot.getEventManager().addListener(PaintListener.class, this);
return true;
}
public void onFinish() {
Bot.getEventManager().removeListener(PaintListener.class, this);
}
public void onRepaint(Graphics g) {
if(isLoggedIn()) {
if(startTime == 0)
startTime = System.currentTimeMillis();
if(startingLevel == 0 || startingExperience == 0) {
startingLevel = skills.getCurrentSkillLevel(STAT_MINING);
startingExperience = skills.getCurrentSkillExp(STAT_MINING);
}
long millis = System.currentTimeMillis() - startTime;
long hours = millis / (1000 * 60 * 60);
millis -= hours * (1000 * 60 * 60);
long minutes = millis / (1000 * 60);
millis -= minutes * (1000 * 60);
long seconds = millis / 1000;
g.setColor(new Color(33, 46, 207, 100));
//window is (0, 0) (337, 515)
//my box is (515 - 260, 0) (337, 200)
int x = 515 - 230;
int y = 4;
g.fillRoundRect(x, y, 230, 170, 20, 20);
g.setColor(new Color(26, 36, 162, 255));
g.drawRoundRect(x, y, 230, 170, 20, 20);
g.setColor(new Color(255, 255, 255, 255));
g.drawString(getAuthor() + "'s " + getName() + " v" + getVersion(), x + 10, y += 15);
g.drawString("Running for " + hours + ":" + minutes + ":" + seconds, x + 10, y += 15);
g.drawString("Banked " + coalBanked + " coal", x + 10, y += 15);
g.drawString("Banked " + mithBanked + " mithril", x + 10, y += 15);
g.drawString("Banked " + gemsBanked + " gems", x + 10, y += 15);
g.drawString("Gained " + ((coalBanked * priceOfCoal) + (mithBanked * priceOfMithril)) + "gp", x + 10, y += 15);
g.drawString("Currently level " + skills.getCurrentSkillLevel(STAT_MINING) + " and " + skills.getPercentToNextLevel(STAT_MINING) + "% to next level", x + 10, y += 15);
g.drawString("Gained " + (skills.getCurrentSkillLevel(STAT_MINING) - startingLevel) + " levels", x + 10, y += 15);
g.drawString("Gained " + (skills.getCurrentSkillExp(STAT_MINING) - startingExperience) + " experience", x + 10, y += 15);
//g.drawString("Earning about " + (skills.getCurrentSkillExp(14) / (hours + (60 / minutes)) + (60 / seconds) + .0001) + "xp per hour", x + 10, y += 15);
g.drawString("Ran from combat " + ranAwayFromCombat + " times", x + 10, y += 15);
g.drawString("" + (int)(skills.getXPToNextLevel(STAT_MINING) / xpPerCoal + 1) + " more coal until next level", x + 10, y += 15);
//g.drawString("Earning about " + (((priceOfCoal * coalBanked) + (mithBanked * priceOfMithril)) / (hours + (60 / minutes)) + (60 / seconds) + .0001) + "gp per hour", x + 10, y += 15);
}
}
public void printProgressReport() {
long millis = System.currentTimeMillis() - startTime;
long hours = millis / (1000 * 60 * 60);
millis -= hours * (1000 * 60 * 60);
long minutes = millis / (1000 * 60);
millis -= minutes * (1000 * 60);
long seconds = millis / 1000;
log(getAuthor() + "'s " + getName() + " v" + getVersion());
log("Running for " + hours + ":" + minutes + ":" + seconds);
log("Banked " + coalBanked + " coal");
log("Banked " + mithBanked + " mithril");
log("Banked " + gemsBanked + " gems");
log("Gained " + ((coalBanked * priceOfCoal) + (mithBanked * priceOfMithril)) + "gp");
log("Currently level " + skills.getCurrentSkillLevel(STAT_MINING) + " and " + skills.getPercentToNextLevel(STAT_MINING) + "% to next level");
log("Gained " + (skills.getCurrentSkillLevel(STAT_MINING) - startingLevel) + " levels");
log("Gained " + (skills.getCurrentSkillExp(STAT_MINING) - startingExperience) + " experience");
//log("Earning about " + (skills.getCurrentSkillExp(14) / (hours + (60 / minutes)) + (60 / seconds) + .0001) + "xp per hour");
log("Ran from combat " + ranAwayFromCombat + " times");
log("" + (int)(skills.getXPToNextLevel(STAT_MINING) / xpPerCoal + 1) + " more coal until next level");
//log("Earning about " + ((priceOfCoal * coalBanked) / (hours + (60 / minutes)) + (60 / seconds) + .0001) + "gp per hour");
}
public String getWebPage(String url) throws Exception {
URL theUrl = new URL(url);
URLConnection theUrlConnection = theUrl.openConnection();
BufferedReader in = new BufferedReader(new InputStreamReader(theUrlConnection.getInputStream()));
String inputLine = "";
String result = "";
while ((inputLine = in.readLine()) != null) {
result += inputLine;
}
in.close();
return result;
}
public int getMarketPriceOfItem(int id) {
String pageSource = "";
int begin = 0;
int end = 0;
try {
URL theUrl = new URL("http://itemdb-rs.runescape.com/viewitem.ws?obj=" + id);
URLConnection theUrlConnection = theUrl.openConnection();
BufferedReader in = new BufferedReader(new InputStreamReader(theUrlConnection.getInputStream()));
String inputLine = "";
while ((inputLine = in.readLine()) != null)
pageSource += inputLine;
in.close();
pageSource = pageSource.replaceAll("\n", "");
pageSource = pageSource.replaceAll("\t", "");
begin = pageSource.indexOf("<b>Market price:</b> ") + ("<b>Market price:</b> ").length();
end = pageSource.indexOf("</span><span><b>Maximum price:</b>");
} catch (Exception e) {
System.out.println("Error obtaining price of http://itemdb-rs.runescape.com/viewitem.ws?obj=" + id);
}
return (int)new Integer(pageSource.substring(begin, end)).intValue();
}
public int loop() {
if(!isLoggedIn())
return random(200, 600);
if(getEnergy() >= energyToRunAt) {
energyToRunAt = random(50, 90);
setRun(true);
}
if(getMyPlayer().isInCombat())
return runAway();
if(distanceTo(lumbridgeTile) <= 17)
walkBack = true;
if(isLost()) {
if(myGetNextTile(lumbridgeToFalidorPath, 17) == null)
return teleportToLumbridge();
walkBack = true;
}
if(walkBack) {
if(myWalkPath(lumbridgeToFalidorPath, 17, 1)) {
walkBack = false;
depositInventory();
}
return random(50, 200);
}
if(getGroundItemByID(17, pickaxeHeadID) != null && (isCarryingItem(pickaxeHandleID)))
return fixPickaxe();
if(isCarryingItem(brokenPickaxeID) || isCarryingItem(pickaxeHandleID))
return getNewPick();
if(isCarryingJunk())
return dropJunk();
if(canEquipPickaxe())
return wieldPickaxe();
if(isInventoryFull())
return depositInventory();
return mineCoal();
}
public boolean isLost() {
if(distanceTo(lumbridgeTile) <= 17)
return false;
if(distanceTo(bankTile) <= 17)
return false;
if(distanceTo(ladderTile) <= 17)
return false;
for(int i = 0; i < betweenBankAndLadderTiles.length - 1; i++)
if(distanceTo(betweenBankAndLadderTiles[i]) <= 17)
return false;
for(int i = 0; i < coalToLadderPath.length - 1; i++)
if(distanceTo(coalToLadderPath[i]) <= 17)
return false;
return true;
}
public boolean isCarryingJunk() {
for(int i = 0; i < junkItems.length; i++) {
if(inventoryContainsOneOf(junkItems[i])) {
return true;
}
}
RSItem item = getInventoryItemByID(goldPiecesID);
if(item != null) {
if(item.getStackSize() <= 5000) {
return true;
}
}
return false;
}
public int dropJunk() {
for(int i = 0; i < junkItems.length; i++) {
if(inventoryContainsOneOf(junkItems[i])) {
if(atInventoryItem(junkItems[i], "Drop"))
return random(550, 700);
}
}
RSItem item = getInventoryItemByID(goldPiecesID);
if(item != null) {
if(item.getStackSize() <= 5000) {
if(atInventoryItem(goldPiecesID, "Drop"))
return random(550, 700);
}
}
return random(40, 200);
}
public void unequipWeapon() {
openTab(TAB_EQUIPMENT);
RSInterface equip = RSInterface.getInterface(INTERFACE_TAB_EQUIPMENT);
RSInterfaceChild weapon = equip.getChild(16);
atInterface(weapon);
wait(random(400, 800));
openTab(TAB_INVENTORY);
}
public int runAway() {
setRun(true);
if(getMyPlayer().getLocation().getY() > 6000) {
myWalkPathAllTheWay(coalToLadderPath, 2);
waitUntilNotMoving();
climbUpLadder();
wait(random(1500, 2000));
climbDownLadder();
return random(200, 600);
} else {
RSTile curentTile = getMyPlayer().getLocation();
int xRand = random(-16, 17);
int yRand;
if(random(0, 2) == 0)
yRand = -(int)(Math.sqrt((16 * 16) - (xRand * xRand)));
else
yRand = -(int)(Math.sqrt((16 * 16)- (xRand * xRand)));
RSTile runawayTile = new RSTile(curentTile.getX() + xRand, curentTile.getY() + yRand);
myWalkTile(runawayTile, 0);
waitUntilNearTile(runawayTile, 0);
wait(random(2200, 3800));
myWalkTile(curentTile, 1);
wait(random(50, 600));
if(random(0, 4) < 3)
moveMouse(random(0, 515), random(0, 337));
waitUntilNotMoving();
}
ranAwayFromCombat++;
return random(50, 100);
}
int attemptsClimbingUp;
public boolean climbUpLadder() {
attemptsClimbingDown = 0;
while(attemptsClimbingDown < 5) {
RSObject object = getNearestObjectById(16, ladderID);
if(object != null) {
if(!Calculations.onScreen(Calculations.tileToScreen(object.getLocation()))) {
myWalkTile(object.getLocation(), 1);
wait(random(50, 600));
if(random(0, 4) < 3)
moveMouse(random(0, 515), random(0, 337));
waitUntilNotMoving();
}
if(atObject(object, "up")) {
wait(random(200, 600));
while(getMyPlayer().getLocation().getY() > 6000)
wait(random(200, 400));
return true;
} else {
if(distanceTo(coalToLadderPath[coalToLadderPath.length - 1]) > 4)
myWalkTile(coalToLadderPath[coalToLadderPath.length - 1], 2);
setCameraRotation(random(1, 359));
setCameraAltitude(true);
attemptsClimbingUp++;
}
}
}
return false;
}
public boolean atTileModified(RSTile tile, String action, int randomness) {
try {
Point location = Calculations.tileToScreen(tile);
if (location.x == -1 || location.y == -1) return false;
moveMouse(location, randomness, randomness);
if (getMenuItems().get(0).toLowerCase().contains(action.toLowerCase())) {
clickMouse(true);
} else {
clickMouse(false);
if (!atMenu(action)) return false;
}
wait(random(500, 1000));
while (true) {
if (!getMyPlayer().isMoving()) break;
wait(random(500, 1000));
}
return true;
} catch (Exception e) {
return false;
}
}
int attemptsClimbingDown;
public boolean climbDownLadder() {
if(!Calculations.onScreen(Calculations.tileToScreen(topLadderTile)))
return false;
attemptsClimbingDown = 0;
while(attemptsClimbingDown < 5) {
if(atTileModified(topLadderTile, "down", 16)) {
wait(random(400, 600));
while(getMyPlayer().getLocation().getY() < 6000)
wait(random(200, 400));
return true;
} else {
if(distanceTo(ladderTile) > 4)
myWalkTile(ladderTile, 2);
setCameraRotation(random(1, 359));
setCameraAltitude(true);
attemptsClimbingDown++;
}
}
return false;
}
public int getNewPick() {
if(getMyPlayer().getLocation().getY() > 6000) {
if(myWalkPath(coalToLadderPath, 15, 3)) {
waitUntilNotMoving();
climbUpLadder();
}
return random(100, 200);
}
if(distanceTo(bankTile) > 4) {
if(myWalkTile(betweenBankAndLadderTiles[random(0, betweenBankAndLadderTiles.length)], 1)) {
waitUntilNearTile(betweenBankAndLadderTiles[random(0, betweenBankAndLadderTiles.length)], 2);
}
myWalkTile(bankTile, 2);
wait(random(200, 600));
if(equipmentContains(pickaxeHandleID) || equipmentContains(brokenPickaxeID))
unequipWeapon();
wait(random(50, 600));
if(random(0, 4) < 3)
moveMouse(random(0, 515), random(0, 337));
waitUntilNotMoving();
return random(200, 300);
}
if(!RSInterface.getInterface(INTERFACE_BANK).isValid()) {
switch(random(0, 2)) {
case 0: atObject(getNearestObjectById(15, bankBoothID), "uickl"); break;
case 1: atNPC(getNearestNPCByID(bankerID), "ank Ba"); break;
//case 2: atObject(getNearestObjectById(15, depositBoxID), "sit Ban"); break;
default: atObject(getNearestObjectById(15, bankBoothID), "uickl"); break;
}
waitUntilNotMoving();
return random(400, 700);
}
if(RSInterface.getInterface(INTERFACE_BANK).isValid()) {
coalBanked += getInventoryCount(coalID);
mithBanked += getInventoryCount(mithrilID);
gemsBanked += getInventoryCount(gemID);
bank.depositAll();
//broken since the bank methods are broken
/*
bank.setWithdrawModeToItem();
int skillMining = skills.getCurrentSkillLevel(STAT_MINING);
for(int i = pickaxeID.length - 1; i >= 0; i--) {
if((skillMining >= 61 && i == 6) ||
(skillMining >= 41 && i == 5) ||
(skillMining >= 31 && i == 4) ||
(skillMining >= 21 && i == 3) ||
(skillMining >= 6 && i == 2) ||
(skillMining >= 1 && i == 1) ||
(skillMining >= 1 && i == 0)) {
bank.atItem(pickaxeID[i], "hdraw 1");
break;
}
}
wait(random(400, 900));
if(skills.getCurrentSkillLevel(STAT_ATTACK) >= 40 && inventoryContainsOneOf(pickaxeID[5]))
atInventoryItem(pickaxeID[5], "ield");
else if(skills.getCurrentSkillLevel(STAT_ATTACK) >= 30 && inventoryContainsOneOf(pickaxeID[4]))
atInventoryItem(pickaxeID[4], "ield");
else if(skills.getCurrentSkillLevel(STAT_ATTACK) >= 20 && inventoryContainsOneOf(pickaxeID[3]))
atInventoryItem(pickaxeID[3], "ield");
else if(skills.getCurrentSkillLevel(STAT_ATTACK) >= 5 && inventoryContainsOneOf(pickaxeID[2]))
atInventoryItem(pickaxeID[2], "ield");
else if(skills.getCurrentSkillLevel(STAT_ATTACK) >= 1 && inventoryContainsOneOf(pickaxeID[1]))
atInventoryItem(pickaxeID[1], "ield");
else if(skills.getCurrentSkillLevel(STAT_ATTACK) >= 1 && inventoryContainsOneOf(pickaxeID[0]))
atInventoryItem(pickaxeID[0], "ield");
*/
bank.close();
}
log("No useable pickaxe, ending script =(");
printProgressReport();
stopAllScripts();
return random(200, 400);
}
public int fixPickaxe() {
RSItemTile head = getGroundItemByID(17, pickaxeHeadID);
if(head != null) {
log("Getting Head..");
myWalkTile(head, 1);
waitUntilNearTile(head, 0);
if(!atTile(head, "ake")) {
setCameraRotation(random(1, 359));
setCameraAltitude(true);
}
return random(10, 50);
}
if(equipmentContains(pickaxeHandleID) || equipmentContains(brokenPickaxeID))
unequipWeapon();
openTab(TAB_INVENTORY);
wait(random(200, 300));
useItem(getInventoryItemByID(pickaxeHeadID), getInventoryItemByID(pickaxeHandleID));
if(skills.getCurrentSkillLevel(STAT_ATTACK) >= 40 && inventoryContainsOneOf(pickaxeID[5]))
atInventoryItem(pickaxeID[5], "ield");
else if(skills.getCurrentSkillLevel(STAT_ATTACK) >= 30 && inventoryContainsOneOf(pickaxeID[4]))
atInventoryItem(pickaxeID[4], "ield");
else if(skills.getCurrentSkillLevel(STAT_ATTACK) >= 20 && inventoryContainsOneOf(pickaxeID[3]))
atInventoryItem(pickaxeID[3], "ield");
else if(skills.getCurrentSkillLevel(STAT_ATTACK) >= 5 && inventoryContainsOneOf(pickaxeID[2]))
atInventoryItem(pickaxeID[2], "ield");
else if(skills.getCurrentSkillLevel(STAT_ATTACK) >= 1 && inventoryContainsOneOf(pickaxeID[1]))
atInventoryItem(pickaxeID[1], "ield");
else if(skills.getCurrentSkillLevel(STAT_ATTACK) >= 1 && inventoryContainsOneOf(pickaxeID[0]))
atInventoryItem(pickaxeID[0], "ield");
return random(200, 400);
}
public boolean canEquipPickaxe() {
if((skills.getCurrentSkillLevel(STAT_ATTACK) >= 40 && inventoryContainsOneOf(pickaxeID[5])) ||
(skills.getCurrentSkillLevel(STAT_ATTACK) >= 30 && inventoryContainsOneOf(pickaxeID[4])) ||
(skills.getCurrentSkillLevel(STAT_ATTACK) >= 20 && inventoryContainsOneOf(pickaxeID[3])) ||
(skills.getCurrentSkillLevel(STAT_ATTACK) >= 5 && inventoryContainsOneOf(pickaxeID[2])) ||
(skills.getCurrentSkillLevel(STAT_ATTACK) >= 1 && inventoryContainsOneOf(pickaxeID[1])) ||
(skills.getCurrentSkillLevel(STAT_ATTACK) >= 1 && inventoryContainsOneOf(pickaxeID[0])))
return true;
return false;
}
public int wieldPickaxe() {
if(skills.getCurrentSkillLevel(STAT_ATTACK) >= 40 && inventoryContainsOneOf(pickaxeID[5]))
atInventoryItem(pickaxeID[5], "ield");
else if(skills.getCurrentSkillLevel(STAT_ATTACK) >= 30 && inventoryContainsOneOf(pickaxeID[4]))
atInventoryItem(pickaxeID[4], "ield");
else if(skills.getCurrentSkillLevel(STAT_ATTACK) >= 20 && inventoryContainsOneOf(pickaxeID[3]))
atInventoryItem(pickaxeID[3], "ield");
else if(skills.getCurrentSkillLevel(STAT_ATTACK) >= 5 && inventoryContainsOneOf(pickaxeID[2]))
atInventoryItem(pickaxeID[2], "ield");
else if(skills.getCurrentSkillLevel(STAT_ATTACK) >= 1 && inventoryContainsOneOf(pickaxeID[1]))
atInventoryItem(pickaxeID[1], "ield");
else if(skills.getCurrentSkillLevel(STAT_ATTACK) >= 1 && inventoryContainsOneOf(pickaxeID[0]))
atInventoryItem(pickaxeID[0], "ield");
return random(200, 400);
}
public int depositInventory() {
if(getMyPlayer().getLocation().getY() > 6000) {
if(myWalkPath(coalToLadderPath, 15, 2)) {
waitUntilNotMoving();
climbUpLadder();
}
return random(100, 200);
}
if(distanceTo(bankTile) > 4) {
if(myWalkTile(betweenBankAndLadderTiles[random(0, betweenBankAndLadderTiles.length)], 1)) {
waitUntilNearTile(betweenBankAndLadderTiles[random(0, betweenBankAndLadderTiles.length)], 2);
}
myWalkTile(bankTile, 2);
wait(random(200, 600));
if(random(0, 4) < 3)
moveMouse(random(0, 515), random(0, 337));
waitUntilNotMoving();
return random(200, 300);
}
if(!RSInterface.getInterface(INTERFACE_BANK).isValid()) {
switch(random(0, 2)) {
case 0: atObject(getNearestObjectById(15, bankBoothID), "uickl"); break;
case 1: atNPC(getNearestNPCByID(bankerID), "ank Ba"); break;
//case 2: atObject(getNearestObjectById(15, depositBoxID), "sit Ban"); break;
default: atObject(getNearestObjectById(15, bankBoothID), "uickl"); break;
}
waitUntilNotMoving();
return random(400, 700);
}
if(RSInterface.getInterface(INTERFACE_BANK).isValid()) {
coalBanked += getInventoryCount(coalID);
mithBanked += getInventoryCount(mithrilID);
gemsBanked += getInventoryCount(gemID);
bank.depositAllExcept(pickaxeID);
if(random(0, 4) == 0)
bank.close();
}
return random(200, 400);
}
public void mouseOverMiningSkill() {
openTab(TAB_STATS);
wait(random(100, 200));
//2 interfaces, one for the pickaxe image, other for the skill text
RSInterfaceChild one = RSInterface.getInterface(320).getChild(9);
RSInterfaceChild two = RSInterface.getInterface(320).getChild(10);
if(random(0, 2) == 0)
moveMouse(new Point(one.getAbsoluteX() + random(2, one.getWidth() - 1), one.getAbsoluteY() + random(2, one.getHeight() - 1)));
else
moveMouse(new Point(two.getAbsoluteX() + random(2, two.getWidth() - 1), two.getAbsoluteY() + random(2, two.getHeight() - 1)));
wait(random(800, 1200));
}
//10% chance of doing antiban: 24/300, every 4.5-18 seconds doing antiban
public int antiBan() {
switch(random(0, 240)) {
case 0: setCameraRotation(random(1, 359)); break;
case 1: setCameraRotation(random(1, 359)); break;
case 2: setCameraRotation(random(1, 359)); break;
case 3: setCameraRotation(random(1, 359)); break;
case 4: setCameraRotation(random(1, 359)); break;
case 5: setCameraRotation(random(1, 359)); break;
case 6: setCameraRotation(random(1, 359)); break;
case 7: setCameraRotation(random(1, 359)); break;
case 8: setCameraAltitude(true); break;
case 9: setRun(true); break;
case 10: moveMouse(random(0, 515), random(0, 337)); break;
case 11: moveMouse(random(0, 515), random(0, 337)); break;
case 12: moveMouse(random(0, 515), random(0, 337)); break;
case 13: moveMouse(random(0, 515), random(0, 337)); break;
case 14: moveMouse(random(0, 764), random(0, 502)); break;
case 15: moveMouse(random(0, 764), random(0, 502)); break;
case 16: moveMouse(random(0, 764), random(0, 502)); break;
case 17: moveMouse(random(0, 764), random(0, 502)); break;
case 18: mouseOverMiningSkill(); break;
case 19: mouseOverMiningSkill(); break;
case 20: openTab(TAB_INVENTORY); break;
case 21: openTab(TAB_STATS); break;
case 22: openTab(random(0, 13)); break;
case 23: openTab(random(0, 13)); break;
default: break;
}
return random(50, 300);
}
RSTile lastRockLocation = new RSTile(0000, 0000);
boolean mineNewRock = false;
RSObject rock;
long timeIdle = System.currentTimeMillis();
public int mineCoal() {
if(getMyPlayer().getLocation().getY() < 6000) {
if(!climbDownLadder()) {
if(myWalkTile(betweenBankAndLadderTiles[random(0, betweenBankAndLadderTiles.length)], 1)) {
waitUntilNearTile(betweenBankAndLadderTiles[random(0, betweenBankAndLadderTiles.length)], 2);
myWalkTile(ladderTile, 2);
waitUntilNearTile(ladderTile, 1);
} else {
myWalkTile(bankTile, 2);
waitUntilNearTile(bankTile, 0);
}
}
return random(200, 400);
}
mineNewRock = true;
if(getObjectAt(lastRockLocation) != null) {
for(int i = 0; i < coalRockID.length; i++) {
if(getObjectAt(lastRockLocation).getID() == coalRockID[i])
mineNewRock = false;
}
for(int i = 0; i < mithRockID.length; i++) {
if(getObjectAt(lastRockLocation).getID() == mithRockID[i])
mineNewRock = false;
}
}
if(getMyPlayer().getAnimation() != -1)
timeIdle = System.currentTimeMillis();
if(mineNewRock || ((getMyPlayer().getAnimation() == -1) && (System.currentTimeMillis() - timeIdle >= 4000) && !getMyPlayer().isMoving())) {
if(miningMith && getNearestObjectById(16, mithRockID) != null)
rock = getNearestObjectById(16, mithRockID);
else
rock = getNearestObjectById(16, coalRockID);
if(rock == null) {
if(distanceTo(ladderToCoalPath[ladderToCoalPath.length - 1]) < 6) {
myWalkPath(coalToLadderPath, 15, 3);
wait(random(50, 600));
if(random(0, 4) < 3)
moveMouse(random(0, 515), random(0, 337));
waitUntilNotMoving();
return random(50, 200);
}
if(distanceTo(coalToLadderPath[ladderToCoalPath.length - 1]) < 6) {
myWalkPath(ladderToCoalPath, 15, 3);
wait(random(50, 600));
if(random(0, 4) < 3)
moveMouse(random(0, 515), random(0, 337));
waitUntilNotMoving();
return random(50, 200);
}
if(random(0, 2) == 0)
myWalkPath(ladderToCoalPath, 15, 3);
else
myWalkPath(coalToLadderPath, 15, 3);
wait(random(50, 600));
if(random(0, 4) < 3)
moveMouse(random(0, 515), random(0, 337));
waitUntilNotMoving();
return random(50, 200);
}
//if(!tileOnScreen(rock.getLocation())) {
if(!Calculations.onScreen(Calculations.tileToScreen(rock.getLocation()))) {
myWalkTile(rock.getLocation(), 2);
wait(random(50, 600));
if(random(0, 4) < 3)
moveMouse(random(0, 515), random(0, 337));
waitUntilNotMoving();
return random(50, 200);
}
lastRockLocation = rock.getLocation();
atObject(rock, "ine");
return random(100, 300);
}
return antiBan();
}
int tries = 0;
public int teleportToLumbridge() {
if(distanceTo(lumbridgeTile) > 17) {
castSpell(1);
wait(random(1500, 2400));
if(getMyPlayer().getAnimation() != -1) {
wait(random(12500,14000));
} else {
tries++;
if(tries >= 4) {
log("Unable to teleport to lumbridge, stopping script");
printProgressReport();
stopAllScripts();
}
int r = random(120000, 400000);
log("Unable to teleport to lumbridge, will attempt again in " + (r / 1000));
wait(r);
}
}
myWalkTile(lumbridgeTile, 1);
setRun(true);
waitUntilNearTile(lumbridgeTile, 2);
return random(100, 600);
}
public void waitUntilNotMoving() {
wait(random(700, 800));
while(getMyPlayer().isMoving())
wait(random(25, 100));
}
public void waitUntilNearTile(RSTile tile, int dist) {
wait(random(700, 800));
while(distanceTo(tile) > dist && getMyPlayer().isMoving())
wait(random(25, 100));
}
public boolean myWalkTile(RSTile theTile, int randomness) {
if((distanceTo(theTile)) <= 17) {
RSTile newTile;
if(randomness == 0)
newTile = new RSTile(theTile.getX(), theTile.getY());
else
newTile = new RSTile(theTile.getX() + random(-randomness, randomness), theTile.getY() + random(-randomness, randomness));
if(random(0, 30) == 0)
turnToTile(newTile, 15);
if(tileOnScreen(newTile) && random(0, 8) == 0) {
if(!atTile(newTile, "Walk")) {
if(!walkTileMM(newTile)) {
log("Failed walking to tile: (" + theTile.getX() + ", " + theTile.getY() + ")");
return false;
} else {
return true;
}
} else {
return true;
}
} else {
if(!walkTileMM(newTile)) {
log("Failed walking to tile: (" + theTile.getX() + ", " + theTile.getY() + ")");
return false;
} else {
return true;
}
}
} else {
log("Tile out of reach: (" + theTile.getX() + ", " + theTile.getY() + ")");
return false;
}
}
public RSTile myGetNextTile(RSTile[] path, int maxDist) {
for(int i = path.length - 1; i >= 0; i--) {
if(distanceTo(path[i]) <= maxDist) {
return path[i];
}
}
return null;
}
public boolean myWalkPath(RSTile[] path, int maxDist, int randomness) {
if(distanceTo(path[path.length - 1]) <= 4) {
return true;
} else {
RSTile theTile = myGetNextTile(path, maxDist);
if(theTile != null) {
myWalkTile(theTile, randomness);
waitUntilNearTile(theTile, 2);
}
return false;
}
}
public void myWalkPathAllTheWay(RSTile[] path, int randomness) {
while(distanceTo(path[path.length - 1]) >= 4) {
RSTile theTile = myGetNextTile(path, 17);
if(theTile != null) {
myWalkTile(theTile, randomness);
waitUntilNearTile(theTile, 2);
}
}
}
public RSObject getNearestObjectById(int range, int... ids) {
for(int i = 0; i <= range; i++) {
RSObject temp = findObject(i, ids);
if(temp != null) {
return temp;
}
}
return null;
}
}