Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.awt.*;
- import javax.swing.JOptionPane;
- 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.Walking;
- import org.powerbot.game.api.methods.Widgets;
- import org.powerbot.game.api.methods.input.Keyboard;
- import org.powerbot.game.api.methods.input.Mouse;
- import org.powerbot.game.api.methods.interactive.NPCs;
- 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.Item;
- 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;
- /**
- * @author BrownBirdScripts
- * @version 0.25
- * Copyright 2011 - 2012
- * All Rights Reserved
- * ONLY BrownBird may edit this script, no exception.
- *
- */
- @Manifest(authors = { "BrownBirdScripts" }, name = "BBOakLarder", description = "Builds & Destorys Oak Larders for EXP.", version = 0.25, website = "", premium = false)
- public class BBoakLarder extends ActiveScript implements MessageListener, PaintListener{
- final static private int oakPlank = 8778;
- final static private int notedOakPlank = 8779;
- static private int servantId;
- final static private int removedLarder = 15403;
- final static private int Larder = 13566;
- private int startExp = 0;
- private int expGained;
- public int banked;
- 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;
- @Override
- protected void setup() {
- ServantID sid = new ServantID();
- submit(sid);
- log.info("Script is now running.");
- startTime = System.currentTimeMillis();
- startExp = Skills.getExperience(Skills.CONSTRUCTION);
- Build build = new Build();
- Strategy buildStrategy = new Strategy(build, build);
- provide(buildStrategy);
- Remove remove = new Remove();
- Strategy removeStrategy = new Strategy(remove, remove);
- provide(removeStrategy);
- useServant servant = new useServant();
- Strategy servantStrategy = new Strategy(servant, servant);
- provide(servantStrategy);
- Pay pay = new Pay();
- Strategy payStrategy = new Strategy(pay, pay);
- provide(payStrategy);
- Antiban ab = new Antiban();
- Strategy abStrategy = new Strategy(ab, ab);
- provide(abStrategy);
- }
- private class ServantID implements Task, Condition {
- @Override
- public void run() {
- try {
- servantId = Integer.parseInt(JOptionPane.showInputDialog("Enter your servant ID here:"));
- } catch (Exception e) {
- stop();
- }
- }
- @Override
- public boolean validate() {
- return true;
- }
- }
- private class Build implements Task, Condition {
- @Override
- public void run() {
- if(Inventory.getCount(oakPlank) >= 8) {
- status = "Building Oak Larder";
- }
- final SceneObject LS = SceneEntities.getNearest(15403);
- 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, "Build");
- Time.sleep(Random.nextInt(400, 800));
- if (Widgets.get(394, 11).isOnScreen()) {
- Widgets.get(394, 11).getChildren()[1].click(true);
- Time.sleep(Random.nextInt(400, 800));
- Widgets.get(93, 121).click(true);
- Time.sleep(Random.nextInt(500, 800));
- }
- }
- }
- }
- @Override
- public boolean validate() {
- for (SceneObject loc : SceneEntities.getLoaded()) {
- if (loc.getId() == removedLarder)
- return (Inventory.getCount(oakPlank) >= 8);
- }
- return false;
- }
- }
- private class Remove implements Task, Condition {
- @Override
- public void run() {
- status = "Removing Oak Larder";
- final SceneObject LS = SceneEntities.getNearest(13566);
- 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 {
- Time.sleep(Random.nextInt(300, 500));
- interact(LS, "Remove");
- Time.sleep(Random.nextInt(800, 1000));
- Keyboard.sendKey('1');
- Time.sleep(Random.nextInt(1000, 1200));
- }
- }
- }
- @Override
- public boolean validate() {
- for (SceneObject loc : SceneEntities.getLoaded()) {
- if (loc.getId() == Larder);
- }
- return true;
- }
- }
- private class useServant implements Task, Condition {
- @Override
- public void run() {
- status = "Talking to Servant";
- Time.sleep(Random.nextInt(1000, 3000));
- for (Item i : Inventory.getItems()) {
- if (i.getId() == notedOakPlank) {
- i.getWidgetChild().interact("Use");
- Time.sleep(Random.nextInt(1000, 1500));
- NPCs.getNearest(servantId).interact("Use");
- Time.sleep(Random.nextInt(1000, 1500));
- if(Widgets.get(1188, 31).isOnScreen()) {
- status = "Sending servant...";
- Keyboard.sendKey('1');
- Time.sleep(Random.nextInt(1500, 2000));
- }
- if (Widgets.get(1188, 3).isOnScreen()) {
- status = "Entering amount";
- Keyboard.sendKey('1');
- Time.sleep(Random.nextInt(1200, 1500));
- Keyboard.sendText("27", true);
- Time.sleep(Random.nextInt(1000, 1200));
- Widgets.getContinue().click(true);
- Time.sleep(Random.nextInt(800, 1500));
- }
- /*if(Inventory.getCount(notedOakPlank) >= 0) {
- status = "Stopping Script, out of Planks";
- log.info("Stopping script, out of Planks");
- stop();
- }*/
- }
- }
- }
- @Override
- public boolean validate() {
- for (SceneObject loc : SceneEntities.getLoaded()) {
- if (loc.getId() == removedLarder)
- return (Inventory.getCount(oakPlank) < 8 && !Widgets.get(1184, 19).isOnScreen());// && Integer.parseInt(Widgets.get(748, 8).getText()) <= 25 + (Random.nextInt(-3, 3));
- }
- return false;
- }
- }
- private class Pay implements Task, Condition {
- @Override
- public void run() {
- status = "Paying Servant";
- if (Widgets.get(1184, 18).isOnScreen()) {
- Widgets.get(1184, 18).click(true);
- Time.sleep(Random.nextInt(500, 1000));
- Keyboard.sendKey('1');
- Time.sleep(Random.nextInt(800, 1500));
- }
- }
- @Override
- public boolean validate() {
- if (Widgets.get(1184, 18).isOnScreen() && Inventory.getCount(oakPlank) < 8) {
- return true;
- }
- return false;
- }
- }
- private class Antiban implements Task, Condition {
- @Override
- public void run() {
- switch(Random.nextInt(1, 569)){
- case 0:
- Camera.setAngle(Random.nextInt(-180, 180));
- log.info("Antiban: Rotating Camera");
- case 119:
- Camera.setAngle(Random.nextInt(1, 150));
- log.info("Antiban: Rotating Camera");
- case 289:
- Camera.setAngle(Random.nextInt(1, 360));
- log.info("Antiban: Rotating Camera");
- case 500:
- 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 onRepaint(Graphics graphics) {
- Graphics2D g = (Graphics2D) graphics;
- 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.CONSTRUCTION) - startExp;
- g.setRenderingHints(new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF));
- g.setColor(new Color(246, 194, 65, 163));
- g.fillRect(15, 21, 193, 105);
- g.setStroke(new BasicStroke(1));
- g.setColor(new Color(0, 0, 0));
- g.drawRect(15, 21, 193, 105);
- g.setColor(new Color(8, 7, 5));
- g.setFont(new Font("Arial", 0, 15));
- g.drawString("BBoakLarder", 67, 39);
- g.setColor(new Color(8, 7, 5));
- g.setFont(new Font("Arial", 0, 10));
- g.drawString("Run Time: "+ hours + ":" + minutes + ":" + seconds, 24, 60);
- g.setColor(new Color(8, 7, 5));
- g.setFont(new Font("Arial", 0, 10));
- g.drawString("Sent Servant to Bank: "+banked, 24, 75);
- g.setColor(new Color(9, 7, 3));
- g.setFont(new Font("Arial", 0, 10));
- g.drawString("EXP Gained: "+expGained, 24, 90);
- g.setColor(new Color(9, 7, 3));
- g.setFont(new Font("Arial", 0, 10));
- g.drawString("Status: "+status, 24, 105);
- }
- public void messageReceived(MessageEvent e) {
- String svrmsg = e.getMessage();
- if (svrmsg.contains("The servant")) {
- banked++;
- }
- }
- 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;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment