Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.awt.Color;
- import java.awt.Font;
- import java.awt.Graphics;
- import java.awt.Graphics2D;
- import java.awt.Image;
- import java.awt.RenderingHints;
- import java.io.IOException;
- import java.net.URL;
- import java.text.DecimalFormat;
- import java.text.DecimalFormatSymbols;
- import javax.imageio.ImageIO;
- import org.rsbot.event.events.ServerMessageEvent;
- import org.rsbot.event.listeners.PaintListener;
- import org.rsbot.event.listeners.ServerMessageListener;
- import org.rsbot.script.Script;
- import org.rsbot.script.ScriptManifest;
- import org.rsbot.script.util.Timer;
- import org.rsbot.script.wrappers.RSArea;
- import org.rsbot.script.wrappers.RSComponent;
- import org.rsbot.script.wrappers.RSNPC;
- import org.rsbot.script.wrappers.RSObject;
- import org.rsbot.script.wrappers.RSTile;
- @ScriptManifest( authors = {"ShadowMoose"}, keywords = "Money", version = 0.2, name = "CrossBow Buyer", description =
- "This script is amazing at getting you Crossbows!")
- public class CrossbowBuyer extends Script implements PaintListener, ServerMessageListener
- {
- //OBJECTS
- int door = 1533;// -- door("Open" if On screen);
- //ITEMS
- int Bow = 10156;// -- Crossbows!
- int gp = 995;// -- GP!
- int bought = 0;
- Boolean ANTIBAN = true;
- int price = 1;
- //NPCs
- int LeonID = 5111;// -- Leon("Talk-to L");
- //Tiles
- RSArea Shop = new RSArea(new RSTile(2564, 3079), new RSTile(2570, 3085));
- RSTile Bank = new RSTile(2612, 3092);
- RSTile[] toBank = {new RSTile(2563, 3082), new RSTile(2574, 3089), new RSTile(2584, 3097), new RSTile(2598, 3098), new RSTile(2603, 3094), new RSTile(2611, 3093)};
- //Paint:
- private final Color color1 = new Color(255, 51, 51);
- private final Font font1 = new Font("Arial", 0, 15);
- private final Font font2 = new Font("Arial", 0, 12);
- private final Font font3 = new Font("Arial", 0, 10);
- private final Image img1 = getImage("http://www.zybez.net/img/idbimg/crossbow_hunter.png");
- private final Image img2 = getImage("http://www.runescape.com/img/main/kbase/items/misc/coins.gif");
- Timer time = new Timer(0);
- public boolean onStart(){
- mouse.setSpeed(random(1, 3));
- price = grandExchange.lookup(Bow).getGuidePrice();
- new Thread() {
- public void run() {
- log("AntiBan started!");
- while(ANTIBAN) {
- // Do thread functions here.
- //log.severe("AntiBan: Rotating camera.");
- if(game.isLoggedIn()){camera.setAngle(random(10, 360));}
- mouse.setSpeed(random(1, 3));
- // Wait for 10/100 of a second
- try {Thread.sleep((random(100, 23*1000)));} catch (Exception e) {log.severe("Error Waiting!");}
- }
- }
- }.start();
- return true;
- }
- public void shutDown(){//logs you out & stops the script.
- ANTIBAN = false;
- bought++;
- while(bank.isOpen()){bank.close(); sleep(random(1000, 2000));}
- while (!game.isOnLogoutTab() && !getMyPlayer().isInCombat()) {
- interfaces.get(548).getComponent(178).doClick();
- sleep(random(1000, 2000));
- }
- while(game.isLoggedIn() && game.isOnLogoutTab() && !getMyPlayer().isInCombat()){
- interfaces.get(182).getComponent(15).doClick();
- sleep(random(1000, 2000));
- }
- log.severe("Total bought:"+bought);
- stopScript();
- }
- private Image getImage(String url) {
- try {
- return ImageIO.read(new URL(url));
- } catch(IOException e) {
- return null;
- }
- }
- @Override
- public int loop() {
- RSObject openMe = objects.getNearest(door);
- if(inventory.getCount(true, gp) < 1300){shutDown();}
- if(Shop.contains(getMyPlayer().getLocation()) && inventory.getCount(true, gp) >= 1300 && !inventory.isFull()){
- //time to buy crossbows.
- RSNPC leon = npcs.getNearest(LeonID);
- if(leon != null && leon.isOnScreen()){
- if(doChat()){return 100;}//return if we're already chatting.
- leon.doAction("Talk-to L");
- int i=0;
- while(interfaces.getComponent(232, 3) == null || interfaces.getComponent(232, 3) != null && !interfaces.getComponent(232, 3).getText().contains("ross")){
- i++;
- if(i>50){return 10;}
- sleep(random(100, 150));
- if(interfaces.getComponent(230, 3) != null && interfaces.getComponent(230, 3).getText().contains("Can I")){return 10;}
- }
- return 100;
- }
- }
- if(inventory.isFull()){
- if(openMe != null && openMe.isOnScreen()){//Open the door if it's closed.
- openMe.doAction("Open");
- return random(1000, 3000);
- }
- if(calc.distanceTo(Bank) > 4){walking.walkPathMM(walking.randomizePath(toBank,2,2)); return random(2700, 3500);}
- try{
- bank.open();
- if(bank.isOpen()){
- bought++;
- bank.depositAllExcept(gp);
- bank.close();
- }
- }catch(Exception e){log.severe("Error opening bank!");}
- }
- if(!Shop.contains(getMyPlayer().getLocation()) && !inventory.isFull() && inventory.getCount(true, gp) >= 1300){
- if(openMe != null && openMe.isOnScreen()){//Open the door if it's closed.
- openMe.doAction("Open");
- return random(1000, 3000);
- }
- walking.walkPathMM(walking.randomizePath(walking.reversePath(toBank),2,2));
- if(calc.tileOnMap(Shop.getCentralTile())){walking.walkTileMM(walking.randomizeTile(Shop.getCentralTile(), 2, 2));}
- return random(2500, 3500);
- }
- return random(2500, 3700);
- }
- public boolean doChat(){
- RSComponent cont = interfaces.getComponent(64, 5);
- RSComponent Lcont = interfaces.getComponent(242, 6);
- RSComponent start = interfaces.getComponent(232, 3);
- RSComponent start2 = interfaces.getComponent(230, 3);
- RSComponent offer = interfaces.getComponent(241, 5);
- RSComponent accept = interfaces.getComponent(230, 2);
- RSComponent done = interfaces.getComponent(211,3);
- if(cont != null && cont.getText().contains("ontinue")){click(cont); pause(cont,"ontinue"); return true;}
- if(Lcont != null && Lcont.getText().contains("ontinue")){click(Lcont); pause(Lcont,"ontinue"); return true;}
- if(start != null && start.getText().contains("ross")){click(start); pause(start,"ross"); return true;}
- if(start2 != null && start2.getText().contains("ross")){click(start2); pause(start2,"ross"); return true;}
- if(offer != null && offer.getText().contains("ontinue")){click(offer); pause(offer,"ontinue"); return true;}
- if(accept != null && accept.getText().contains("Ok,")){click(accept); pause(accept,"Ok,"); return true;}
- if(done != null && done.getText().contains("ontinue")){bought++; return false;}
- return false;
- }
- public void pause(RSComponent component, String stringToCheck){//waits for an interface to be gone.
- String s = stringToCheck;
- RSComponent c = component;
- for(int i=0; i<=40 && c.getText().contains(s); i++){
- sleep(random(100, 150));
- RSComponent cc = interfaces.getComponent(242, 4);
- if(cc != null && cc.getText().contains("Of course,")){i = 41; break;}
- }
- }
- public void click(RSComponent c){//clicks the interface... Guaranteed.
- if(c.isValid() && !c.doClick()){
- mouse.click(true);
- }
- }
- public String insertCommas(long num) {
- DecimalFormat df = new DecimalFormat();
- DecimalFormatSymbols dfs = new DecimalFormatSymbols();
- dfs.setGroupingSeparator(',');
- df.setDecimalFormatSymbols(dfs);
- return((String)df.format((int)num));
- }
- @Override
- public void onRepaint(Graphics g) {
- ((Graphics2D) g).setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
- long seconds, minutes, hours, millis;
- millis = time.getElapsed();
- hours = millis / (1000 * 60 * 60);
- millis -= hours * (1000 * 60 * 60);
- minutes = millis / (1000 * 60);
- millis -= minutes * (1000 * 60);
- seconds = millis / 1000;
- g.drawImage(img1, 550, 208, null);
- g.drawImage(img1, 686, 205, null);
- g.drawImage(img1, 548, 304, null);
- g.drawImage(img1, 688, 305, null);
- g.drawImage(img1, 686, 413, null);
- g.drawImage(img1, 550, 414, null);
- g.drawImage(img2, 627, 433, null);
- g.drawImage(img2, 700, 371, null);
- g.drawImage(img2, 561, 374, null);
- g.drawImage(img2, 556, 268, null);
- g.drawImage(img2, 701, 268, null);
- g.drawImage(img2, 628, 216, null);
- g.setFont(font1);
- g.setColor(color1);
- g.drawString("CrossbowBuyer", 590, 264);
- g.setFont(font2);
- g.drawString("By: ShadowMoose", 590, 288);
- g.setFont(font3);
- g.drawString("Crossbows Bought: "+insertCommas(bought), 597, 326);
- //if(millis > 0){g.drawString("Crossbows p/h: "+(((bought)/millis)*60*60), 596, 343);}
- g.drawString("Profit: "+insertCommas((bought*price)-(bought*1300)), 598, 382);
- //g.drawString("Profit Per Hour: ", 597, 402);
- g.drawString("Run Time: "+time.toElapsedString(), 598, 430);
- }
- @Override
- public void serverMessageRecieved(ServerMessageEvent e) {
- // TODO Auto-generated method stub
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement