Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.awt.event.*;
- import java.awt.*;
- import java.util.*;
- import java.io.*;
- import java.net.*;
- import java.lang.reflect.Method;
- import javax.swing.*;
- import org.rsbot.script.*;
- import org.rsbot.script.methods.Game;
- import org.rsbot.script.methods.Skills;
- import org.rsbot.script.wrappers.*;
- import org.rsbot.event.events.MessageEvent;
- import org.rsbot.event.listeners.*;
- import javax.imageio.ImageIO;
- @ScriptManifest(authors = { "Rawr & Conderoga" }, keywords = "Money Making", name = "White Berry Grabber Pro", version = 1.00,description = "Collects White Berries.")
- /*UpdateLog:
- v1.00 - initial release
- */
- public class WhiteBerries extends Script implements PaintListener, MessageListener{
- //Paint Stuff
- private String status = "";
- private boolean full = false;
- private long startTime;
- private double startTimeDbl;
- private int startExp;
- private int expGained;
- private int startLevel;
- private int levelsGained;
- //Money Stuff
- private int doOnce =0;
- private int whiteBerriesVal;
- private int lawRuneVal;
- private int profit = 0;
- private int numBerries = 0;
- //IDS
- private int berryID = 239;
- private int lawID = 563;
- //Walking stuff
- boolean inWild = false;
- RSTile [] bankToCanoe = {new RSTile(3097,3496),new RSTile(3104,3503),new RSTile(3113,3508),
- new RSTile(3121,3515),new RSTile(3133,3513),new RSTile(3132,3508)};
- RSTile [] pondToTele = {new RSTile(3141,3796),new RSTile(3151,3795),new RSTile(3166,3793),
- new RSTile(3181,3793),new RSTile(3195,3795),new RSTile(3206,3796),
- new RSTile(3215,3802),new RSTile(3219,3806)};
- RSTile [] teleToEscape = {new RSTile(3219,3806),new RSTile(3221,3792),new RSTile(3221,3777),
- new RSTile(3221,3766),new RSTile(3224,3754)};
- RSTile [] escapeToBank = {new RSTile(3087,3496),new RSTile(3097,3495)};
- public boolean onStart() {
- startTime = System.currentTimeMillis();
- startTimeDbl = System.currentTimeMillis();
- return true;
- }
- public boolean makeCanoe(){
- RSObject station;
- RSObject [] check = objects.getAllAt(new RSTile(3131,3510));
- for(RSOBject o : check)
- if(o.getID()==12166)
- station=o;
- if(station!=null){
- Point p = o.getModel().getPoint();
- mouse.move(p);
- menu.doAction("Chop-down Canoe station");
- sleep(random(2000,3000));
- mouse.move(p);
- menu.doAction("Shape-canoe Canoe station");
- sleep(random(2000,3000)); //==================================================ALL OF THESE TIMES NEED ADJUSTMENT
- if(interfaces.get(52)!=null)
- if(handleInterface(52,33,"Select")){
- sleep(random(2000,3000));
- Point p2 = o.getModel().getPoint();
- mouse.move(p2);
- menu.doAction("Float Canoe Canoe station");
- sleep(random(2000,3000));
- mouse.move(p2);
- menu.doAction("Paddle Canoe Canoe station");
- sleep(random(2000,3000));
- if(interfaces.get(53)!=null)
- if(handleInterface(53,45,"Select")){
- sleep(random(2000,3000));
- if(interfaces.get(382)!=null)
- return handleInterface(382,19,"Proceed");
- }
- }
- }
- return false;
- }
- public boolean handleInterface(int i, int c, String a){
- return interfaces.getComponent(i,c).doAction(a);
- }
- public void walkTo(RSTile [] path, int time){
- long startTime = System.currentTimeMillis();
- mouse.setSpeed(random(5,8));
- if(random(1,3)==2)
- camera.setPitch(true);
- int lastTileToWalkTo = -1;
- int tempTileToWalkTo = 0;
- path = fixPath(path);
- if(path.length!=0)
- while(!playerIsNear(path[path.length-1],4)&&System.currentTimeMillis()-startTime<time)
- {
- if(!walking.isRunEnabled()&&walking.getEnergy()>20){
- walking.setRun(true);
- sleep(random(600,800));
- }
- if(!getMyPlayer().isMoving()){
- sleep(random(600,800));
- if(!getMyPlayer().isMoving())
- lastTileToWalkTo=-1;
- }
- boolean clicked = false;
- tempTileToWalkTo = walkPath(path);
- if(tempTileToWalkTo>lastTileToWalkTo){
- if(walking.walkTileMM(path[tempTileToWalkTo],1,1))
- clicked = true;
- sleep(random(400,500));
- if(getMyPlayer().isMoving())
- clicked = true;
- }
- if(clicked){
- lastTileToWalkTo = tempTileToWalkTo;
- }
- sleep(random(200, 300));
- }
- }
- public boolean compareTiles(RSTile t1, RSTile t2){
- if(t1==null||t2==null)
- return false;
- return t1.getX()==t2.getX()&&t1.getY()==t2.getY();
- }
- public int walkPath(RSTile [] path){
- int temp = 0;
- boolean nearSomething = false;
- for(int i = 0; i<path.length;i++)
- {
- if(playerIsNear(path[i],5))
- {
- nearSomething = true;
- temp = i+1;
- antiBan(random(1,200));
- for(int j = i; j<path.length; j++)
- {
- if(calc.tileToMinimap(path[j]).x<0)
- {
- temp=j-1;
- break;
- }
- if(j==path.length-1&&calc.tileToMinimap(path[j]).x>0)
- {
- temp=j;
- break;
- }
- }
- return temp;
- }
- }
- if(!nearSomething){
- RSTile tempTileToCompare = walking.newTilePath(path).getNext();
- for(int i = 0; i<path.length;i++)
- {
- if(compareTiles(path[i],tempTileToCompare))
- return i;
- }
- }
- return 0;
- }
- public void messageReceived(final MessageEvent e) {
- final String serverString = e.getMessage();
- if (serverString.toLowerCase().contains("wilderness"))
- inWild = true;
- }
- public boolean playerIsNear(RSTile tile, int d)
- {
- return (Math.abs(getMyPlayer().getLocation().getX()-tile.getX())<d&&Math.abs(getMyPlayer().getLocation().getY()-tile.getY())<d);
- }
- public int distanceTo(RSTile test){
- RSTile myLoc = players.getMyPlayer().getLocation();
- return (int)Math.pow(Math.pow(test.getY()-myLoc.getY(),2)+Math.pow(test.getX()-myLoc.getX(),2),.5);
- }
- public int distanceBetween(RSTile t1, RSTile t2){
- return (int)Math.pow(Math.pow(t1.getY()-t2.getY(),2)+Math.pow(t1.getX()-t2.getX(),2),.5);
- }
- public RSTile[] fixPath(RSTile [] path){
- ArrayList<RSTile> newPath = new ArrayList<RSTile>();
- for(RSTile t : path)
- newPath.add(t);
- newPath = fixPath(newPath);
- path = new RSTile[newPath.size()];
- for(int i=0; i<path.length;i++){
- path[i]=newPath.get(i);
- }
- return path;
- }
- public ArrayList<RSTile> fixPath(ArrayList<RSTile> path){
- boolean madeSwap = false;
- do{
- madeSwap = false;
- for(int i = 0; i<path.size()-1;i++)
- if(distanceBetween(path.get(i),path.get(i+1))>7){
- path.add(i+1,getMidTile(path.get(i),path.get(i+1)));
- madeSwap = true;
- }
- }while(madeSwap);
- return path;
- }
- public RSTile getMidTile(RSTile tile1, RSTile tile2)
- {
- int x1 = tile1.getX();
- int y1 = tile1.getY();
- int x2 = tile2.getX();
- int y2 = tile2.getY();
- return new RSTile((int)(x1+x2)/2,(int)(y1+y2)/2);
- }
- public int getGEValue(String name, int id){
- try{
- String [] temp = name.split(" ");
- String newName = "";
- for(int i = 0; i<temp.length; i++)
- if(i==temp.length-1)
- newName+=temp[i];
- else
- newName+="_"+temp[i];
- URL url = new URL("http://services.runescape.com/m=itemdb_rs/"+newName+"/viewitem.ws?obj="+id);
- InputStream is = url.openStream();
- InputStreamReader isr = new InputStreamReader(is);
- BufferedReader br = new BufferedReader(isr);
- String line;
- String num = "";
- while((line=br.readLine())!=null){
- if(line.contains("Current guide price:"))
- num = line;
- }
- System.out.println(num);
- if(num.length()<29)
- return -1;
- else{
- num = num.substring(28);
- num = num.replaceAll(",", "");
- return Integer.parseInt(num);
- }
- }catch(Exception e){
- return -1;
- }
- }
- //LOOP====================================================================================================================
- public int loop() {
- try{
- if(doOnce==0){
- doOnce=1;
- whiteBerriesVal = getGEValue("White berries",berryID);
- lawRuneVal = getGEValue("Law rune",lawID);
- profit = whiteBerriesVal-lawRuneVal;
- }
- //Walk To canoe
- walkTo(bankToCanoe,20000);
- //Make canoe/Go To wilderness
- makeCanoe();
- //Walk to telegrab area
- walkTo(pondToTele,25000);
- //Walk away from telegrab
- walkTo(teleToEscape,20000);
- //Walk to bank
- walkTo(escapeToBank,8000);
- }catch (Exception e){};
- return random(300,500);
- }
- //LOOP====================================================================================================================
- public void antiBan(int rand){
- status += "(AB)";
- mouse.setSpeed(random(7,8));
- if(rand==1)
- if(random(1, 8) == 2)
- mouse.moveRandomly(900,1200);
- if(rand==2)
- if(random(1, 8) == 2)
- mouse.moveRandomly(400,800);
- if(rand==3)
- if(random(1, 8) == 2)
- mouse.moveRandomly(200,700);
- if(rand==5) //THIS CLICKS THE XP BUTTON UNDER THE COMPASS (Update thanks to Rawr =D)
- if(random(1, 24) == 2)
- {
- if (interfaces.get(548).getComponent(38).isValid()) {
- return;
- } else {
- if (interfaces.get(548).getComponent(0).doClick()) {
- sleep(1500);
- }
- }
- }
- if(rand==7) //RANDOM SPIN
- if(random(1, 3) == 2)
- {int r = random(1,2);
- camera.setAngle(random(1,359));
- if(r!=1)
- camera.setPitch(random(1,99));}
- if(rand==8) //THIS CHECKS A RANDOM TAB
- if(random(1, 4) == 2)
- {
- int[] tabs = {0,1,2,3,5,6,7,9,10,11,12,13,14,15};
- game.openTab(tabs[random(0,tabs.length-1)]);
- mouse.moveRandomly(175,200);
- sleep(random(1600,1800));
- sleep(random(900,1000));
- }
- if(rand==9)
- if(random(1,10)==2)
- mouse.moveOffScreen();
- status=status.substring(0,status.indexOf('('));
- }
- public void onRepaint(Graphics g)
- {
- if(game.isLoggedIn())
- {
- if(startExp==0)
- {
- startExp = skills.getCurrentExp(skills.getIndex("magic"));
- startLevel = skills.getCurrentLevel(skills.getIndex("magic"));
- }
- lvlsGained = skills.getCurrentLevel(skills.getIndex("magic")) - startLevel;
- expGained = skills.getCurrentExp(skills.getIndex("magic")) - startExp;
- //setting up the time
- long ms = System.currentTimeMillis() - startTime;
- double ms2 = System.currentTimeMillis() - startTimeDbl;
- long hours = ms/3600000;
- ms = ms-(hours*3600000);
- long minutes = ms/60000;
- ms = ms-(minutes*60000);
- long seconds = ms/1000;
- g.setColor(Color.RED);
- numBerries = expGained/43;
- g.drawString("Status: "+status,15,25);
- g.drawString("Time Running: "+hours+" : "+minutes+" : "+seconds,15,50);
- g.drawString("Profit: "+(numBerries*profit)+" ("+numBerries+" berries)",15,75);
- g.drawString("Profit/Hr: "+(numBerries*profit)/(ms2/3600000),15,100);
- }
- }
- public void onFinish() {
- log("Money gained: "+numBerries*profit);
- log("Levels gained: "+lvlsGained);
- log("Thanks for using our White Berry Grabber!");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement