Code:
import java.awt.*;
import java.util.Map;
import javax.swing.JOptionPane;
import java.lang.reflect.Method;
import org.rsbot.event.listeners.PaintListener;
import org.rsbot.event.listeners.ServerMessageListener;
import org.rsbot.event.events.ServerMessageEvent;
import org.rsbot.script.*;
import org.rsbot.script.wrappers.*;
import org.rsbot.bot.input.Mouse;
@ScriptManifest(authors = { "Harack" }, category = "Mining", name = "Resource Dungeon Iron Miner", version = 1.02, description =
"<html><body> <p><b>Resource Dungeon Iron Miner</b></p>" +
"Mines iron ore in the dwarf dungeon and desposits in resource dungeon deposit box! <br/>" +
"You have the option to mine adamantite ore, however this is still a work in progress and may slow xp per hour<br/>" +
"<br><b>Bank as a skiller?</b></br>" +
"<select name='skiller'>" +
"<option>No</option>"
+ "<option>Yes</option>" +
"<br><b>Mine Adamantite?</b></br>" +
"<select name='mineAddy'>" +
"<option>No</option>"
+ "<option>Yes</option>" +
"<br/>If you want something to do while botting, play some of my online flash games!<br/>" +
"V1.0 by Harack<br/>" +
"</body></html>"
)
public class RDIM extends Script implements PaintListener, ServerMessageListener{
public int pickaxes[] = { 1275, 1265, 1273, 1267, 1271 };
public int iron[] = { 31071, 31072, 31073};
public int addy[] = { 31083, 31085};
public int entrance = 52855;
public int exit = 52864;
public int depositBox = 25937;
public int bankInterface = 11;
public RSTile exitTile = new RSTile(1041, 4576);
public RSTile bankTile = new RSTile(1042, 4577);
public RSTile entranceTile = new RSTile(3032, 9772);
public RSObject rock;
public int gemsMined = 0;
public int ironMined = 0;
public int addyMined = 0;
public boolean skiller = false;
public boolean mineAddy = false;
public int fixedmouse = 5;
private String status = "Online";
public int startexp = 0;
public int exp;
public int expGained;
public float expsec;
public float expmin;
public float exphour;
public long timeRunning = 0, seconds = 0 ,minutes = 0, hours = 0;
public long startTime = System.currentTimeMillis();
protected int getMouseSpeed() {
return fixedmouse;
}
public boolean onStart( Map<String,String> args ) {
/* Credits to ZombieKnight for Panel */
final int welcome = JOptionPane.showConfirmDialog(null,"Would you like to play some of my online flash games while botting??","Welcome", JOptionPane.YES_NO_OPTION);
if (welcome == 0) {
final String message = "<html><h1>Thanks for playing!</h1><br/>"
+ "<p>I hope you enjoy my games!!! <br/>"
+ "-Harack.</p>"
+ "</html>";
JOptionPane.showMessageDialog(null, message);
openURL("http://www.harack.co.nz");
}
log("--------------------------------------------------------------");
startTime = System.currentTimeMillis();
startexp = skills.getCurrentSkillExp(Constants.STAT_MINING);
if (args.get("skiller").equals("No")) {
skiller = false;
log("Normal bank-all method!");
} else {
skiller = true;
log("Banking as a skiller!");
}
if (args.get("mineAddy").equals("No")) {
mineAddy = false;
} else {
mineAddy = true;
log("Script will mine adamantite ore!");
}
log("--------------------------------------------------------------");
getMouseSpeed();
return true;
}
public void antiBan(){
if (random(1, 100) == 1) {
status = "Antiban - Screen Rotate";
setCameraRotation(random(1,360));
}
if (getEnergy() > 40 + random(-10, 10)) {
status = "Antiban - Set to run!";
setRun(true);
}
if (random(1, 50) == 1) {
status = "Antiban - Move Mouse";
int x = (int) getMouseLocation().getX();
int y = (int) getMouseLocation().getY();
moveMouse(x + random(-145, 145), y + random(-105, 105));
}
if(random(1, 300) == 1) {
status = "AntiBan - Check XP";
openTab(TAB_STATS);
moveMouse(random(661, 712), random(220, 251));
wait(random(700, 950));
openTab(TAB_INVENTORY);
}
}
public int loop() {
antiBan();
if(getMyPlayer().isMoving()){
return random(500, 850);
} else if((getMyPlayer().getAnimation() != -1) && (!changeRock())) {
status = "Mining";
return random(500, 750);
}
if(isDownstairs()) {
if(bankIsOpen()) {
deposit();
} else if(isInventoryFull()) {
openBank();
} else {
exit();
}
} else {
if(!isInventoryFull()) {
mine();
} else {
enter();
}
}
return random(200, 300);
}
public boolean changeRock() {
return (rock == null) ? true : false;
}
public boolean isDownstairs() {
RSObject bankBox = getNearestObjectByID(depositBox);
if (bankBox != null) {
return true;
} else {
return false;
}
}
public void enter() {
status = "Entering Dungeon";
walkIfNeeded(entranceTile);
if(tileOnScreen(entranceTile)) {
RSObject entranceDoor = getNearestObjectByID(entrance);
atObject(entranceDoor, "Enter");
wait(random(3000,5000));
}
wait(random(500,750));
}
public void walkIfNeeded(RSTile inTile) {
if (distanceTo(inTile) > 3) {
walkTileMM(inTile);
}
wait(random(500,750));
}
public void exit() {
status = "Exiting Dungeon";
walkIfNeeded(exitTile);
if(tileOnScreen(exitTile)) {
RSObject exitDoor = getNearestObjectByID(exit);
atObject(exitDoor, "Exit");
wait(random(3000,5000));
}
wait(random(500,750));
}
public void openBank() {
status = "Opening Bank";
walkIfNeeded(bankTile);
if(tileOnScreen(bankTile) && (!RSInterface.getInterface(bankInterface).isValid())) {
RSObject box = getNearestObjectByID(depositBox);
atObject(box, "Deposit");
wait(random(1500,2500));
}
wait(random(500,750));
}
public boolean bankIsOpen() {
return getInterface(bankInterface).isValid();
}
public void deposit() {
status = "Banking";
if(skiller) {
RSInterfaceComponent[] components = RSInterface.getInterface(11).getChild(17).getComponents();
for (int i = 0; i < components.length; i++) {
if (components[i].getComponentID() != -1) {
boolean canDeposit = true;
for (int y = 0; y < pickaxes.length; y++) {
if(components[i].getComponentID() == pickaxes[y]) {
canDeposit = false;
break;
}
}
if(canDeposit) {
atComponent(components[i],"Deposit-All");
wait(random(550, 700));
}
}
}
} else {
wait(random(550, 700));
atInterface(RSInterface.getInterface(11).getChild(18));//Deposit all buttonz
wait(random(550, 700));
}
wait(random(550, 700));
atInterface(RSInterface.getInterface(11).getChild(15));//The 'X'
wait(500);
}
public void mine() {
status = "Searching For Rocks";
if(mineAddy) {
if(!mineRock(addy)) {
mineRock(iron);
wait(random(300,500));
}
} else {
mineRock(iron);
wait(random(300,500));
}
wait(random(500,750));
}
public boolean mineRock(int[] toMine) {
rock = getNearestObjectByID(toMine);
wait(random(300,500));
if(rock != null) {
if(mineAddy) {
RSTile mineLoc = rock.getLocation();
if(distanceTo(mineLoc) > 5) {
walkTileMM(mineLoc);
wait(random(400,500));
while(getMyPlayer().isMoving()) {
wait(random(100,400));
}
}
}
atObject(rock, "Mine");
return true;
} else {
return false;
}
}
public int getEnergy() {
int a;
try {
a = Integer.parseInt(RSInterface.getChildInterface(750, 5).getText());
} catch (final Exception e) {
a = 0;
}
return a;
}
public void onFinish() {
log("--------------------------------------------------------------");
log("Thank you for using Resource Dungeon Iron Miner By Harack");
log("You Gained " + expGained + " xp and mined " + ironMined + " iron and " + addyMined + " adamantite.");
log("The Script ran for: " + hours + ":" + minutes + ":" + seconds);
log("--------------------------------------------------------------");
}
/* Credits to ZombieKnight who gave credits to Dave who gave credits to some guy who made this.*/
public void openURL(final String url) {
final String osName = System.getProperty("os.name");
try {
if (osName.startsWith("Mac OS")) {
final Class<?> fileMgr = Class.forName("com.apple.eio.FileManager");
final Method openURL = fileMgr.getDeclaredMethod("openURL",new Class[]{String.class});
openURL.invoke(null, new Object[]{url});
} else if (osName.startsWith("Windows")) {
Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler " + url);
} else { // assume Unix or Linux
final String[] browsers = {"firefox", "opera", "konqueror","epiphany", "mozilla", "netscape"};
String browser = null;
for (int count = 0; count < browsers.length && browser == null; count++) {
if (Runtime.getRuntime().exec(new String[]{"which", browsers[count]}).waitFor() == 0) {
browser = browsers[count];
}
}
if (browser == null) {
throw new Exception("Could not find web browser");
} else {
Runtime.getRuntime().exec(new String[]{browser, url});
}
}
} catch (final Exception e) {
}
}
public void onRepaint(Graphics g) {
if (isLoggedIn()) {
expGained = skills.getCurrentSkillExp(Constants.STAT_MINING) - startexp;
timeRunning = System.currentTimeMillis() - startTime;
seconds = timeRunning / 1000;
if (seconds >= 60) {
minutes = seconds / 60;
seconds -= minutes * 60;
}
if (minutes >= 60) {
hours = minutes / 60;
minutes -= hours * 60;
}
if ((minutes > 0 || hours > 0 || seconds > 0) && expGained > 0) {
expsec = ((float) expGained)/(float)(seconds + (minutes*60) + (hours*60*60));
}
exphour = expmin * 60;
expmin = expsec * 60;
}
g.setColor(Color.blue);
g.drawRect(5, 5, 180, 160);
g.setColor(new Color(0, 0, 255, 130));
g.fillRect(5, 5, 180, 160);
g.setFont(new Font("Rockwell", 0, 12));
g.setColor(new Color(255, 255, 255));
g.drawString("Resource Dungeon Iron Miner", 10, 20);
g.setFont(new Font("Rockwell", 0, 11));
g.drawString("Status: " + status, 10, 40);
g.drawString("Runtime: " + hours + ":" + minutes + ":" + seconds, 10, 55);
g.drawString("Iron Mined: " + ironMined, 10, 70);
g.drawString("Gems Mined: " + gemsMined, 10, 85);
g.drawString("Mining XP gained: " + expGained, 10, 100);
g.drawString("XP Per hour: " + (int)exphour, 10, 115);
g.drawString("Exp until level up: " + skills.getXPToNextLevel(STAT_MINING), 10, 130);
g.drawString("Percent till next level: " + skills.getPercentToNextLevel(Constants.STAT_MINING), 10, 145); //360
if (mineAddy) {
g.drawString("Adamantite Mined: " + addyMined, 10, 160);
}
//Mouse Paint.
Point m = getMouseLocation();
g.setColor(Color.blue);
g.drawRoundRect(m.x - 6, m.y, 15, 3, 5, 5);
g.drawRoundRect(m.x, m.y - 6, 3, 15, 5, 5);
g.fillRoundRect(m.x - 6, m.y, 15, 3, 5, 5);
g.fillRoundRect(m.x, m.y - 6, 3, 15, 5, 5);
}
public void serverMessageRecieved(final ServerMessageEvent e) {
String message = e.getMessage();
if (message.contains("manage to mine some iron")) {
ironMined +=1;
}
if (message.contains("manage to mine some adamantite")) {
addyMined +=1;
}
if (message.contains("just found")) {
gemsMined +=1;
}