Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.awt.*;
- import javax.imageio.ImageIO;
- import java.io.IOException;
- import java.net.URL;
- import org.rsbot.event.events.MessageEvent;
- import org.rsbot.event.listeners.MessageListener;
- import org.rsbot.event.listeners.PaintListener;
- import org.rsbot.script.Script;
- import org.rsbot.script.ScriptManifest;
- import org.rsbot.script.wrappers.RSObject;
- import org.rsbot.script.wrappers.RSTile;
- import org.rsbot.script.wrappers.RSTilePath;
- @ScriptManifest(
- authors = {"Rudie"},
- version = 1.00,
- keywords = ("miner"),
- description = "Mines and banks coal at the mining guild.",
- name = "GuildMinerR"
- )
- public class GuildMinerR extends Script implements PaintListener, MessageListener {
- int[] boothID = {11758};
- int[] oreID = {5770, 5771, 5772};
- int miningAnimation = 625;
- int[] pickID = {1265, 1267, 1269, 1271, 1273, 1275};
- int dstairID = 2113;
- int ustairID = 6226;
- RSTile[] fromBankToStairs = {new RSTile(3015, 3355)};
- RSTilePath bankToStairs;
- RSTile[] fromStairsToBank = {new RSTile(3019, 3342)};
- RSTilePath stairsToBank;
- RSTile[] MiningAreaE = {new RSTile(3027, 9739), new RSTile(3034, 9738),
- new RSTile(3044, 9738)};
- RSTilePath MiningArea;
- long startTime;
- int expGained = 0;
- int startExp = 0;
- int oresMined = 0;
- int lvlsGained = 0;
- int gemsFound = 0;
- private String Status = "Loading...";
- public boolean onStart() {
- bankToStairs = walking.newTilePath(fromBankToStairs);
- stairsToBank = walking.newTilePath(fromStairsToBank);
- MiningArea = walking.newTilePath(MiningAreaE);
- startTime = System.currentTimeMillis();
- mouse.setSpeed(random(3, 5));
- startExp = skills.getCurrentExp(skills.MINING);
- return true;
- }
- @Override
- public int loop() {
- if(inventory.isFull()) {
- if(atBank()) {
- doBank();
- } else if(atUp()) {
- goUp();
- } else {
- BtS();
- StB();
- MiningPlace();
- }
- } else {
- if(atMine()) {
- mineOres();
- } else if(atDown()) {
- goDown();
- } else {
- BtSS();
- StBB();
- MiningPlacee();
- }
- }
- return random(600, 800);
- }
- private void mineOres() {
- RSObject rock = objects.getNearest(oreID);
- if(getMyPlayer().getAnimation() != miningAnimation) {
- rock.doAction("Mine");
- Status = "Mining.";
- AntiBan();
- AntiBanCamera();
- }
- sleep(2500, 4000);
- }
- private void goDown() {
- RSObject ladder = objects.getNearest(dstairID);
- if(getMyPlayer().getAnimation() != miningAnimation) {
- ladder.doAction("Climb-down");
- Status = "Going down.";
- AntiBan();
- AntiBanCamera();
- }
- sleep(3000, 4500);
- }
- private void goUp() {
- RSObject ladder = objects.getNearest(ustairID);
- if(getMyPlayer().getAnimation() != miningAnimation) {
- ladder.doAction("Climb-up");
- Status = "Going up.";
- AntiBan();
- AntiBanCamera();
- }
- sleep(5000, 6500);
- }
- private void BtS() {
- bankToStairs.reverse();
- bankToStairs.traverse();
- bankToStairs.reverse();
- AntiBanCamera();
- Status = "Walk to mine.";
- }
- private void BtSS() {
- bankToStairs.traverse();
- AntiBanCamera();
- Status = "Walk to mine.";
- }
- private void StB() {
- stairsToBank.reverse();
- stairsToBank.traverse();
- stairsToBank.reverse();
- AntiBanCamera();
- Status = "Walk to bank.";
- }
- private void StBB() {
- stairsToBank.traverse();
- AntiBanCamera();
- Status = "Walk to bank.";
- }
- private void MiningPlace() {
- MiningArea.reverse();
- MiningArea.traverse();
- MiningArea.reverse();
- AntiBanCamera();
- Status = "Walk to bank.";
- }
- private void MiningPlacee() {
- MiningArea.traverse();
- AntiBanCamera();
- Status = "Walk to mine.";
- }
- public void onFinish() {
- log("Ty for using GuildMinerR.");
- env.saveScreenshot(true);
- }
- private boolean atBank() {
- RSObject bank = objects.getNearest(boothID);
- if(bank != null) {
- if(bank.isOnScreen()) {
- return true;
- }
- }
- return false;
- }
- private void doBank() {
- if(bank.isOpen()) {
- bank.depositAllExcept(pickID);
- sleep(800, 1200);
- Status = "Banking.";
- } else {
- bank.open();
- Status = "Banking.";
- sleep(1800, 2200);
- }
- }
- private boolean atMine() {
- RSObject ore = objects.getNearest(oreID);
- AntiBan();
- AntiBanCamera();
- if(ore != null) {
- if(ore.isOnScreen()) {
- return true;
- }
- }
- return false;
- }
- private boolean atDown() {
- RSObject ladder = objects.getNearest(dstairID);
- AntiBan();
- AntiBanCamera();
- if(ladder != null) {
- if(ladder.isOnScreen()) {
- return true;
- }
- }
- return false;
- }
- private boolean atUp() {
- RSObject ladder = objects.getNearest(ustairID);
- AntiBan();
- AntiBanCamera();
- if(ladder != null) {
- if(ladder.isOnScreen()) {
- return true;
- }
- }
- return false;
- }
- //START: Code generated using Enfilade's Easel
- private Image getImage(String url) {
- try {
- return ImageIO.read(new URL(url));
- } catch(IOException e) {
- return null;
- }
- }
- private final Color color1 = new Color(204, 0, 0, 136);
- private final Color color2 = new Color(0, 0, 0);
- private final Color color3 = new Color(255, 255, 255);
- private final BasicStroke stroke1 = new BasicStroke(1);
- private final Font font1 = new Font("Verdana", 0, 20);
- private final Font font2 = new Font("Verdana", 0, 17);
- private final Font font3 = new Font("Arial", 2, 10);
- private final Image img1 = getImage("http://images3.wikia.nocookie.net/__cb20100407061734/runescape/images/thumb/f/fd/Coal_detail.png/120px-Coal_detail.png");
- //END: Code generated using Enfilade's Easel
- /*
- * ----- PAINT -----
- */
- @Override
- public void onRepaint(Graphics g) {
- drawModel(g, objects.getNearest(oreID), Color.RED, "", Color.GREEN);
- drawModel(g, objects.getNearest(boothID), Color.WHITE, "", Color.GREEN);
- expGained = skills.getCurrentExp(skills.MINING) - startExp;
- 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;
- float xpsec = 0;
- if((minutes > 0 || hours > 0 || seconds > 0)&& expGained > 0) {
- xpsec = ((float) expGained)/(float)(seconds + (minutes*60) + (hours*60*60));
- }
- float xpmin = xpsec * 60;
- float xphour = xpmin * 60;
- float oresec = 0;
- if((minutes > 0 || hours > 0 || seconds > 0)&& oresMined > 0) {
- oresec = ((float) oresMined)/(float)(seconds + (minutes*60) + (hours*60*60));
- }
- float oremin = oresec * 60;
- float orehour = oremin * 60;
- Graphics2D g1 = (Graphics2D)g;
- g1.setColor(color1);
- g.setColor(Color.RED);
- g.drawLine(0, (int)(mouse.getLocation().getY()), 800, (int)(mouse.getLocation().getY()));
- g.setColor(Color.RED);
- g.drawLine((int)(mouse.getLocation().getX()), 0, (int)(mouse.getLocation().getX()), 800);
- g.setColor(Color.BLACK);
- g.fillRect(4, 318, 512, 20);
- g.setColor(Color.BLACK);
- g.fillRect(6, 320, 508, 16);
- g.setColor(Color.RED);
- g.fillRect(6, 320, 508, 16);
- g.setColor(Color.GREEN);
- g.fillRect(6, 320, skills.getPercentToNextLevel(14) * (508/100), 16);
- g.setColor(Color.BLACK);
- g.drawString("" + skills.getPercentToNextLevel(14) + "% to lvl " + (skills.getCurrentLevel(14) + 1) + " Mining", 194, 332);
- g1.setColor(color1);
- g1.fillRoundRect(545, 203, 195, 262, 16, 16);
- g1.setColor(color2);
- g1.setStroke(stroke1);
- g1.drawRoundRect(545, 203, 195, 262, 16, 16);
- g1.setFont(font1);
- g1.setColor(color3);
- g1.drawString("GuildMinerR", 574, 228);
- g1.setFont(font2);
- g1.drawString("Status: " + Status, 550, 257);
- g1.drawString("Exp Gained: " + expGained, 550, 273);
- g1.drawString("Exp/H: " + (int)xphour, 550, 288);
- g1.drawString("Coal Mined: " + oresMined, 550, 303);
- g1.drawString("Coal/H: " + (int)orehour, 550, 318);
- g1.drawString("RunTime: " + hours + ":" + minutes + ":" + seconds, 550, 333);
- g1.drawString("Gems Found: " + gemsFound, 550, 348);
- g1.drawString("Current Lvl: " + skills.getCurrentLevel(skills.MINING), 550, 363);
- g1.drawString("Lvl's Gained: " + lvlsGained, 550, 378);
- g1.drawImage(img1, 576, 380, null);
- g1.setFont(font3);
- g1.drawString("GuildMinerR ®", 548, 462);
- g1.drawString("© 2011", 699, 462);
- }
- public void drawModel(Graphics g, RSObject o, Color c, String s, Color tc) {
- if(o != null) {
- Polygon[] model = o.getModel().getTriangles();
- Point point = calc.tileToScreen(o.getLocation());
- for(Polygon p : model) {
- g.setColor(c);
- g.fillPolygon(p);
- g.setColor(c.darker());
- g.drawPolygon(p);
- }
- g.setColor(tc);
- g.drawString(s, point.x - 75, point.y - 35);
- }
- }
- public RSTile[] reversePath(RSTile[] other) {
- RSTile[] t = new RSTile[other.length];
- for (int i = 0; i < t.length; i++) {
- t[i] = other[other.length - i - 1];
- }
- return t;
- }
- public void messageReceived(MessageEvent e) {
- String svrmsg = e.getMessage();
- if (svrmsg.contains("You've")) {
- lvlsGained++;
- }
- if (svrmsg.contains("coal")) {
- oresMined++;
- }
- if (svrmsg.contains("just found")) {
- gemsFound++;
- }
- }
- private void AntiBan() {
- int randomProd = random(1, 60);
- if (randomProd == 1) {
- int randomMore = random(1, 5);
- if (randomMore == 1) {
- if (game.getCurrentTab() != 2) {
- game.openTab(2);
- sleep(350, 500);
- mouse.move(random(678, 728), random(213, 232));
- sleep(2000, 3500);
- } else {
- mouse.move(random(678, 728), random(213, 232));
- sleep(2000, 3500);
- }
- } else {
- sleep(1200, 2500);
- }
- }
- if (randomProd == 2 || randomProd == 3 || randomProd == 4) {
- sleep(1000, 2500);
- }
- if (randomProd >= 52) {
- mouse.moveRandomly(65, 350);
- } else
- sleep(10, 30);
- }
- private void AntiBanCamera() {
- int randomNum = random(1, 50);
- if (randomNum == 1 || randomNum == 2 || randomNum == 3) {
- camera.moveRandomly(random(2000, 5500));
- }
- if (randomNum == 4 || randomNum == 5) {
- camera.setAngle(random(10, 40));
- }
- if (randomNum == 6) {
- camera.setPitch(random(40, 68));
- }
- if (randomNum == 7) {
- camera.setPitch(random(20, 45));
- }
- if (randomNum == 8) {
- camera.setPitch(random(68, 90));
- } else
- sleep(50, 70);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement