Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.awt.Color;
- import java.awt.Graphics;
- import java.awt.Point;
- import java.awt.Polygon;
- import java.awt.Rectangle;
- import org.powerbot.concurrent.Task;
- import org.powerbot.concurrent.strategy.Condition;
- import org.powerbot.concurrent.strategy.Strategy;
- import org.powerbot.game.api.ActiveScript;
- import org.powerbot.game.api.Manifest;
- import org.powerbot.game.api.methods.Calculations;
- import org.powerbot.game.api.methods.Tabs;
- import org.powerbot.game.api.methods.Walking;
- import org.powerbot.game.api.methods.Widgets;
- import org.powerbot.game.api.methods.input.Mouse;
- import org.powerbot.game.api.methods.interactive.Players;
- import org.powerbot.game.api.methods.node.Menu;
- import org.powerbot.game.api.methods.node.SceneEntities;
- import org.powerbot.game.api.methods.tab.Inventory;
- import org.powerbot.game.api.methods.tab.Skills;
- import org.powerbot.game.api.methods.widget.Camera;
- import org.powerbot.game.api.util.Random;
- import org.powerbot.game.api.util.Time;
- import org.powerbot.game.api.wrappers.Tile;
- import org.powerbot.game.api.wrappers.node.SceneObject;
- import org.powerbot.game.bot.event.MessageEvent;
- import org.powerbot.game.bot.event.listener.MessageListener;
- import org.powerbot.game.bot.event.listener.PaintListener;
- import java.awt.*;
- import javax.imageio.ImageIO;
- import java.io.IOException;
- import java.net.URL;
- /**
- * @author BrownBirdScripts
- * @version 0.00
- * Copyright 2011 - 2012 All Rights Reserved
- * ONLY BrownBird may edit this script, no exception.
- * Website: www.brownbirdscripts.net78.net
- */
- @Manifest(authors = { "BrownBirdScripts" }, name = "BBgoldMiner", description = "Mines gold ore for money.", version = 0.00, website = "http://www.brownbirdscripts.net78.net", premium = false)
- public class BBgoldMiner extends ActiveScript implements PaintListener, MessageListener{
- //IDS
- final static private int[] goldOreRock = {9720, 9722};
- final static private int[] goldOreRockUsed = {9725, 9723};
- final static private int bank = 11758;
- final static private int goldOre = 444;
- //PAINT
- private int startExp = 0;
- private int expGained;
- public int mined;
- public int gems;
- String status = "";
- public long startTime = 0;
- public long millis = 0;
- public long hours = 0;
- public long minutes = 0;
- public long seconds = 0;
- public long last = 0;
- public int expHour = 0;
- //TILES
- private Tile[] pathToBank = new Tile[] { new Tile(2977, 3238, 0),
- new Tile(2978, 3245, 0), new Tile(2978, 3251, 0),
- new Tile(2981, 3258, 0), new Tile(2989, 3267, 0),
- new Tile(2996, 3275, 0), new Tile(3001, 3279, 0),
- new Tile(3005, 3284, 0), new Tile(3006, 3294, 0),
- new Tile(3006, 3306, 0), new Tile(3006, 3314, 0),
- new Tile(3006, 3321, 0), new Tile(3006, 3327, 0),
- new Tile(3007, 3332, 0), new Tile(3007, 3338, 0),
- new Tile(3007, 3345, 0), new Tile(3007, 3352, 0),
- new Tile(3007, 3359, 0), new Tile(3011, 3356, 0)};
- private Tile[] pathToMine = new Tile[] {new Tile(3011, 3356, 0),
- new Tile(3007, 3359, 0), new Tile(3007, 3352, 0),
- new Tile(3007, 3345, 0), new Tile(3007, 3338, 0),
- new Tile(3007, 3332, 0), new Tile(3006, 3327, 0),
- new Tile(3006, 3321, 0), new Tile(3006, 3314, 0),
- new Tile(3006, 3306, 0), new Tile(3006, 3294, 0),
- new Tile(3005, 3284, 0), new Tile(3001, 3279, 0),
- new Tile(2996, 3275, 0), new Tile(2989, 3267, 0),
- new Tile(2981, 3258, 0), new Tile(2978, 3251, 0),
- new Tile(2978, 3245, 0), new Tile(2977, 3238, 0),
- new Tile(2976, 3234, 0),};
- @Override
- protected void setup() {
- startTime = System.currentTimeMillis();
- startExp = Skills.getExperience(Skills.MINING);
- mineGold mG = new mineGold();
- Strategy mGStrategy = new Strategy(mG, mG);
- provide(mGStrategy);
- walkToBank wB = new walkToBank();
- Strategy wBStrategy = new Strategy(wB, wB);
- provide(wBStrategy);
- useBank uB = new useBank();
- Strategy uBStrategy = new Strategy(uB, uB);
- provide(uBStrategy);
- walkToMine wM = new walkToMine();
- Strategy wMStrategy = new Strategy(wM, wM);
- provide(wMStrategy);
- Antiban ab = new Antiban();
- Strategy abStrategy = new Strategy(ab, ab);
- provide(abStrategy);
- }
- private class mineGold implements Task, Condition {
- @Override
- public void run() {
- if(SceneEntities.getNearest(goldOreRock).isOnScreen()){
- status = "Mining Gold Ore...";
- if(SceneEntities.getNearest(goldOreRock).validate()){
- final SceneObject LS = SceneEntities.getNearest(goldOreRock);
- if (LS != null) {
- if (Calculations.distance(Players.getLocal().getLocation(),
- LS.getLocation()) > 4) {
- Walking.walk(getNextPathTile(LS.getLocation().derive(
- Random.nextInt(-3, 3), Random.nextInt(-3, 3))));
- } else {
- interact(LS, "Mine");
- Time.sleep(Random.nextInt(1000, 3000));
- }
- }
- }
- }
- }
- @Override
- public boolean validate() {
- return (Tabs.INVENTORY.open() && Inventory.getCount() < 28 && Players.getLocal().getAnimation() == -1);
- }
- }
- private class walkToBank implements Task, Condition {
- @Override
- public void run() {
- status = "Walking to bank";
- walkPath(pathToBank);
- }
- @Override
- public boolean validate() {
- return (Inventory.getCount() >=28 && Players.getLocal().getAnimation() == -1);
- }
- }
- private class useBank implements Task, Condition {
- @Override
- public void run() {
- if(SceneEntities.getNearest(bank).isOnScreen()) {
- status = "Opening bank";
- final SceneObject LS = SceneEntities.getNearest(bank);
- if (LS != null) {
- if (Calculations.distance(Players.getLocal().getLocation(),
- LS.getLocation()) > 4) {
- Walking.walk(getNextPathTile(LS.getLocation().derive(
- Random.nextInt(-3, 3), Random.nextInt(-3, 3))));
- } else {
- interact(LS, "Bank");
- Time.sleep(Random.nextInt(2002, 3000));
- if(Widgets.get(762, 1).validate() && Inventory.getCount() >= 28) {
- Widgets.get(762, 34).click(true);
- Time.sleep(Random.nextInt(1200, 2000));
- Widgets.get(762, 45).click(true);
- Time.sleep(Random.nextInt(1200, 2000));
- }
- }
- }
- }
- }
- @Override
- public boolean validate() {
- return (Inventory.getCount() >= 28 );
- }
- }
- private class walkToMine implements Task, Condition {
- @Override
- public void run() {
- if(Inventory.getCount(goldOre) == 0 && Players.getLocal().getAnimation() == -1) {
- status = "Walking to back to Mine";
- walkPath(pathToMine);
- }
- }
- @Override
- public boolean validate() {
- return (Inventory.getCount(goldOre) == 0 && Players.getLocal().getAnimation() == -1);
- }
- }
- private class Antiban implements Task, Condition {
- @Override
- public void run() {
- switch (Random.nextInt(1, 588)) {
- case 0:
- status = "Antiban";
- Camera.setAngle(Random.nextInt(-180, 180));
- log.info("Antiban: Rotating Camera");
- case 119:
- status = "Antiban";
- Camera.setAngle(Random.nextInt(1, 150));
- log.info("Antiban: Rotating Camera");
- case 289:
- status = "Antiban";
- Mouse.move(Random.nextInt(1, 500), Random.nextInt(1, 500));
- log.info("Antiban: Moving Mouse");
- case 500:
- status = "Antiban";
- Mouse.move(Random.nextInt(1, 500), Random.nextInt(1, 500));
- log.info("Antiban: Moving Mouse");
- case 3:
- status = "Antiban";
- Camera.setAngle(Random.nextInt(-180, 180));
- log.info("Antiban: Rotating Camera");
- case 530:
- status = "Antiban";
- Mouse.move(Random.nextInt(1, 500), Random.nextInt(1, 500));
- log.info("Antiban: Moving Mouse");
- }
- Time.sleep(Random.nextInt(100, 500));
- }
- @Override
- public boolean validate() {
- return true;
- }
- }
- public void walkPath(final Tile... path) {
- if (Walking.getEnergy() > Random.nextInt(30, 50)) {
- Walking.setRun(true);
- }
- for (int i = path.length - 1; i >= 0; i--) {
- if (Calculations.distanceTo(path[i]) >= 15) {
- continue;
- }
- if (Walking.walk(path[i])) {
- break;
- }
- }
- }
- private Tile getNextPathTile(final Tile tile) {
- final Tile pos = Players.getLocal().getLocation();
- return new Tile((int) (pos.getX() + (tile.getX() - pos.getX())
- * Random.nextDouble(.75D, .9D)),
- (int) (pos.getY() + (tile.getY() - pos.getY())
- * Random.nextDouble(.75D, .9D)), tile.getPlane());
- }
- private boolean interact(final SceneObject l, final String action) {
- final java.awt.geom.Area a = new java.awt.geom.Area();
- for (final Polygon p : l.getBounds())
- a.add(new java.awt.geom.Area(p));
- final Rectangle bounds = a.getBounds();
- Point p;
- do {
- p = new Point(Random.nextGaussian(bounds.x,
- bounds.x + bounds.width, 20), Random.nextGaussian(bounds.y,
- bounds.y + bounds.height, 20));
- } while (!a.contains(p));
- Mouse.move(p.x, p.y);
- final String[] actions = Menu.getActions();
- if (actions.length > 0 && actions[0].contains(action)) {
- Mouse.click(true);
- return true;
- } else {
- for (final String item : actions) {
- if (item.contains(action)) {
- Mouse.click(false);
- Time.sleep(Random.nextInt(200, 400));
- return Menu.select(item);
- }
- }
- }
- return false;
- }
- private Image getImage(String url) {
- try {
- return ImageIO.read(new URL(url));
- } catch(IOException e) {
- return null;
- }
- }
- private final Color color1 = new Color(255, 255, 255);
- private final Font font1 = new Font("Gnuolane Free", 0, 20);
- private final Image img1 = getImage("http://i46.tinypic.com/311rng3.png");
- public void onRepaint(Graphics g1) {
- Graphics2D g = (Graphics2D)g1;
- millis = System.currentTimeMillis() - startTime;
- hours = millis / (1000 * 60 * 60);
- millis -= hours * (1000 * 60 * 60);
- minutes = millis / (1000 * 60);
- millis -= minutes * (1000 * 60);
- seconds = millis / 1000;
- Point mLoc = Mouse.getLocation();
- g.setColor(Color.black);
- g.drawLine(mLoc.x, 0, mLoc.x, 502);
- g.drawLine(0, mLoc.y, 764, mLoc.y);
- expGained = Skills.getExperience(Skills.MINING) - startExp;
- expHour = (int) ((expGained) * 3600000D / (System.currentTimeMillis() - startTime));
- g.drawImage(img1, 1, 339, null);
- g.setFont(font1);
- g.setColor(color1);
- g.drawString(" "+ hours + ":" + minutes + ":" + seconds, 119, 430);
- g.drawString(" "+ expGained, 132, 448);
- g.drawString(" "+ expHour, 107, 469);
- g.drawString(" "+ mined, 324, 430);
- g.drawString(" "+ gems, 327, 450);
- g.drawString(" "+status, 282, 469);
- }
- public void messageReceived(MessageEvent e) {
- String svrmsg = e.getMessage();
- if (svrmsg.contains("You just found") ) {
- gems++;
- }
- if(svrmsg.contains("You ma")) {
- mined++;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment