Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import org.rsbot.script.*;
- import org.rsbot.script.Script;
- import org.rsbot.script.wrappers.*;
- import java.awt.*;
- import org.rsbot.event.events.MessageEvent;
- import org.rsbot.event.listeners.MessageListener;
- import org.rsbot.event.listeners.PaintListener;
- import javax.imageio.ImageIO;
- import java.io.IOException;
- import java.net.URL;
- import java.awt.image.BufferedImage;
- import java.io.IOException;
- import java.net.MalformedURLException;
- @ScriptManifest(authors = "Havefunpeeps, Deww1 ", keywords = "", name = "Beer Buyer", version = 1.02, description = "Buys Asgarnian Ales at West Falador")
- public class AleBuyer extends Script implements MessageListener, PaintListener {
- int CoinsID = 995;
- int AleID = 1905;
- int NPCID = 736;
- int AlePrice;
- int BANK = 11758;
- antiban antiban = new antiban();
- BufferedImage normal = null;
- BufferedImage clicked = null;
- public String cursorU;//Cursor unclicked
- public String cursorC;//Cursor clicked
- private String status = "Setting up";
- private String MouseSpeed = "Unknown";
- public long startTime = 0;
- public long millis = 0;
- public long hours = 0;
- public long minutes = 0;
- public long seconds = 0;
- private int aleCollected = 0;
- private int AleCollected = 0;
- public int OreCollected = 0;
- private int banked;
- private int aleHr = 0;
- public void messageReceived(MessageEvent e) {
- String x = e.getMessage().toLowerCase();
- if (x.contains("buy an")){
- aleCollected++;
- AleCollected++;
- }
- }
- private void loadsBanked() {
- if (AleCollected == 27) {
- AleCollected = 0;
- banked++;
- }
- }
- public final RSArea BarArea = new RSArea(new RSTile[] {
- new RSTile(2953, 3365), new RSTile(2961, 3364),
- new RSTile(2962, 3375), new RSTile(2953, 3376)
- });
- public final RSArea BankArea = new RSArea(new RSTile[] {
- new RSTile(2940, 3362), new RSTile(2940, 3374),
- new RSTile(2949, 3374), new RSTile(2949, 3361)
- });
- public final RSTile[] ToBar = {
- new RSTile(2946, 3369), new RSTile(2946, 3371),
- new RSTile(2946, 3372), new RSTile(2946, 3373),
- new RSTile(2946, 3373), new RSTile(2947, 3373),
- new RSTile(2948, 3374), new RSTile(2948, 3374),
- new RSTile(2949, 3375), new RSTile(2949, 3376),
- new RSTile(2949, 3377), new RSTile(2950, 3377),
- new RSTile(2950, 3378), new RSTile(2951, 3378),
- new RSTile(2952, 3379), new RSTile(2953, 3380),
- new RSTile(2954, 3380), new RSTile(2955, 3380),
- new RSTile(2956, 3380), new RSTile(2956, 3379),
- new RSTile(2956, 3377), new RSTile(2957, 3375),
- new RSTile(2957, 3373), new RSTile(2957, 3373),
- new RSTile(2957, 3371), new RSTile(2957, 3371)
- };
- public final RSTile[] ToBank = {
- new RSTile(2957, 3371), new RSTile(2956, 3372),
- new RSTile(2956, 3374), new RSTile(2956, 3375),
- new RSTile(2956, 3377), new RSTile(2957, 3378),
- new RSTile(2956, 3380), new RSTile(2953, 3379),
- new RSTile(2953, 3379), new RSTile(2953, 3378),
- new RSTile(2951, 3376), new RSTile(2950, 3375),
- new RSTile(2949, 3374), new RSTile(2948, 3373),
- new RSTile(2945, 3369)
- };
- @Override
- public boolean onStart(){
- startTime = System.currentTimeMillis();
- AlePrice = grandExchange.lookup(AleID).getGuidePrice();
- if(!inventory.contains(CoinsID)){
- log("Please have coins");
- onFinish();
- }
- cursorU = "http://rkdewbots.site50.net/images/ironpickup/mouseReg.png";
- cursorC = "http://rkdewbots.site50.net/images/ironpickup/mouseClicked.png";
- try {
- final URL cursorURL = new URL(cursorU);
- final URL cursor80URL = new URL(cursorC);
- normal = ImageIO.read(cursorURL);
- clicked = ImageIO.read(cursor80URL);
- } catch (MalformedURLException e) {
- log("Unable to buffer cursor.");
- } catch (IOException e) {
- log("Unable to open cursor image.");
- }
- return true;
- }
- private boolean walkPath(RSTile[] path) {
- if (calc.distanceTo(path[path.length - 1]) > 4) {
- RSTile n = getNext(path);
- if (n != null) {
- antiban.antiBanCamera();
- walking.walkTileMM(n.randomize(2, 2));
- if (random(1, 6) != 2) {
- mouse.moveRandomly(20);
- }
- }
- }
- return false;
- }
- private RSTile getNext(RSTile[] path) {
- boolean found = false;
- for (int a = 0; a < path.length && !found; a++) {
- if (calc.tileOnMap(path[path.length - 1 - a])) {
- found = true;
- return path[path.length - 1 - a];
- }
- }
- return null;
- }
- public int loop() { //Not sure where you want to add antiban. Add it with antiBan() wherever you want.
- mouseSpeed();
- loadsBanked();
- if(BankArea.contains(getMyPlayer().getLocation())) {
- if(inventory.isFull()){
- bank();
- }else{
- status = "walking to the bar";
- walkPath(ToBar);
- }
- }
- if(BarArea.contains(getMyPlayer().getLocation())) {
- if(inventory.isFull()) {
- status = "walking to the bank";
- walkPath(ToBank);
- }else{
- BuyBeer();
- }
- }
- if(inventory.getItem(CoinsID).getStackSize() < 3) {
- log("Ran out of coins");
- onFinish();
- }
- return random(300, 900);
- }
- @Override
- public void onFinish() {
- log("You have made "+(AlePrice-3)*aleCollected+" GP in total with "+aleCollected+" Ale collected!");
- log("Thank you for using Beer Buyer!");
- }
- public int bankOpen() {
- if (BankArea.contains(getMyPlayer().getLocation()) && players.getMyPlayer().isIdle()) {
- status = "Opening Bank.";
- RSObject bankBooth = objects.getNearest(BANK);
- if (random(1, 4) > 1) {
- bankBooth.doAction("Use-quickly");
- } else {
- antiban.antiBan();
- }
- }
- return random(800, 1300);
- }
- public int depositBank() {
- status = "Depositing ores";
- bank.depositAllExcept(coinsID);
- return random(300, 1100);
- }
- public void bank() {
- if (!bank.isOpen()) {
- bankOpen();
- antiban.antiBanMouse();
- }
- if (bank.isOpen()) {
- depositBank();
- antiban.antiBanMouse();
- sleep(random(100, 500));
- }
- }
- public void BuyBeer() {
- RSNPC BeerPerson = npcs.getNearest(NPCID);
- if(!interfaces.getComponent(241, 5).isValid() && !interfaces.getComponent(64, 5).isValid() && !interfaces.getComponent(242, 6).isValid() && !interfaces.getComponent(232, 2).isValid()) {
- BeerPerson.doAction("Talk-to");
- status = "Buyin beers!";
- sleep(500, 1000);
- }else{
- if(interfaces.getComponent(241, 5).isValid()) {
- interfaces.getComponent(241, 5).doClick();
- sleep(random(1300, 1500));
- }
- if(interfaces.getComponent(64, 5).isValid()) {
- interfaces.getComponent(64, 5).doClick();
- sleep(random(1300, 1500));
- }
- if(interfaces.getComponent(242, 6).isValid()) {
- interfaces.getComponent(242, 6).doClick();
- sleep(random(1300, 1500));
- }
- if(interfaces.getComponent(232, 2).isValid()) {
- interfaces.getComponent(232, 2).doClick();
- sleep(random(1300, 1500));
- }
- }
- }
- //START: Code generated using Enfilade's Easel
- private final RenderingHints antialiasing = new RenderingHints(
- RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
- private Image getImage(String url) {
- try {
- return ImageIO.read(new URL(url));
- } catch(IOException e) {
- return null;
- }
- }
- private void mouseSpeed() {
- int rand = random(1, 5);
- if (rand == 1) {
- mouse.setSpeed(random(4, 7));
- }
- if (rand == 2) {
- mouse.setSpeed(random(5, 10));
- }
- if (rand == 3) {
- mouse.setSpeed(random(2, 5));
- }
- if (rand == 4) {
- mouse.setSpeed(random(2, 10));
- }
- mouseSet();
- }
- private void mouseSet() {
- if (mouse.getSpeed() >= 1 && mouse.getSpeed() <= 3) {
- MouseSpeed = "Extremely fast";
- }
- if (mouse.getSpeed() >= 4 && mouse.getSpeed() <= 6) {
- MouseSpeed = "Regular";
- }
- if (mouse.getSpeed() >= 7 && mouse.getSpeed() <= 10) {
- MouseSpeed = "Slow";
- }
- }
- private final Color color1 = new Color(0, 0, 0);
- private final Color color2 = new Color(255, 255, 255);
- private final Color color3 = new Color(0, 0, 0, 133);
- private final Font font1 = new Font("Times New Roman", 0, 11);
- private final Font font2 = new Font("Times New Roman", 0, 13);
- private final Image img1 = getImage("http://rkdewbots.site50.net/scripts/alebuyer/AleBuyerPaint.png");
- public void onRepaint(Graphics g1) {
- Graphics2D g = (Graphics2D)g1;
- if (normal != null) {
- final int mouse_x = mouse.getLocation().x;
- final int mouse_y = mouse.getLocation().y;
- final int mouse_x2 = mouse.getPressLocation().x;
- final int mouse_y2 = mouse.getPressLocation().y;
- final long mpt = System.currentTimeMillis()
- - mouse.getPressTime();
- if (mouse.getPressTime() == -1 || mpt >= 1000) {
- g.drawImage(normal, mouse_x - 8, mouse_y - 8, null); //this show the mouse when its not clicked
- }
- if (mpt < 1000) {
- g.drawImage(clicked, mouse_x2 - 8, mouse_y2 - 8, null); //this show the four squares where you clicked.
- g.drawImage(normal, mouse_x - 8, mouse_y - 8, null); //this show the mouse as normal when its/just clicked
- }
- }
- g.setRenderingHints(antialiasing);
- aleHr = (int) ((aleCollected) * 3600000D / (System.currentTimeMillis() - startTime));
- 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;
- g.drawImage(img1, -1, 308, null);
- g.setFont(font1);
- g.setColor(color1);
- g.drawString(""+AleBuyer.class.getAnnotation(ScriptManifest.class).version(), 119, 453);
- g.setColor(color2);
- g.drawString("Run Time: " + hours + ":" + minutes + ":" + seconds, 360, 464);
- g.setFont(font2);
- g.setColor(color1);
- g.drawString("Ale's Bought: "+aleCollected, 21, 390);
- g.setColor(color2);
- g.drawString("Ale Price: "+AlePrice, 354, 343);
- g.setColor(color1);
- g.drawString("Ale's Bought/hr: "+aleHr, 21, 423);
- g.drawString("Mouse Speed: "+MouseSpeed, 348, 443);
- g.drawString("Status: "+status, 186, 384);
- g.drawString("Bank Trips: "+banked, 348, 420);
- g.setColor(color3);
- g.drawString("Paint by: Deww1", 247, 471);
- }
- //END: Code generated using Enfilade's Easel
- public class antiban {
- public void antiBanMouse() {
- int randomNum1 = random(1, 50);
- if (randomNum1 == 1 || randomNum1 == 2 || randomNum1 == 3) {
- mouse.moveSlightly();
- mouse.moveSlightly();
- }
- if (randomNum1 == 4 || randomNum1 == 5 || randomNum1 == 6) {
- mouse.move(random(175, 325), random(75, 225));
- }
- if (randomNum1 == 7) {
- mouse.moveRandomly(10, 150);
- }
- if (randomNum1 == 10 || randomNum1 == 11 || randomNum1 == 12
- || randomNum1 == 13) {
- mouse.moveSlightly();
- mouse.moveRandomly(random(30, 39), random(40, 60));
- }
- if (randomNum1 == 14) {
- mouse.moveOffScreen();
- }
- if (randomNum1 == 15) {
- mouse.moveSlightly();
- mouse.move(random(350, 700), random(50, 300));
- }
- if (randomNum1 == 16) {
- mouse.moveSlightly();
- mouse.moveSlightly();
- mouse.moveSlightly();
- mouse.moveSlightly();
- }
- if (randomNum1 > 16) {
- int randomNum2 = random(1, 3);
- if (randomNum2 == 1) {
- mouse.moveSlightly();
- }
- if (randomNum2 == 2) {
- mouse.moveRandomly(30, 50);
- }
- if (randomNum2 == 3) {
- mouse.moveSlightly();
- mouse.moveRandomly(30, 50);
- }
- }
- sleep(random(100, 400));
- }
- public void antiBanCamera() {
- int randomNumber3 = random(1, 40);
- if (randomNumber3 == 1 || randomNumber3 == 2 || randomNumber3 == 3) {
- camera.setPitch(random(40, 68));
- }
- if (randomNumber3 == 4 || randomNumber3 == 5 || randomNumber3 == 6) {
- camera.moveRandomly(random(800, 1200));
- }
- if (randomNumber3 == 7 || randomNumber3 == 8 || randomNumber3 == 9) {
- camera.setAngle(random(10, 50));
- }
- if (randomNumber3 == 10 || randomNumber3 == 11) {
- camera.setPitch(true);
- }
- if (randomNumber3 == 12 || randomNumber3 == 13) {
- camera.setPitch(false);
- }
- if (randomNumber3 == 14) {
- camera.moveRandomly(random(400, 800));
- }
- if (randomNumber3 == 15) {
- camera.setAngle(random(5, 40));
- sleep(random(200, 300));
- }
- if (randomNumber3 > 15 && randomNumber3 < 30) {
- camera.setPitch(true);
- }
- if (randomNumber3 > 29) {
- camera.moveRandomly(random(200, 800));
- }
- }
- public void antiBan(){
- int randomNumber123 = random(1, 3);
- if(randomNumber123 == 1) {
- antiBanMouse();
- }
- if(randomNumber123 == 2) {
- antiBanCamera();
- }
- }
- }
- }//Paint :D
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement