Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.awt.BasicStroke;
- import java.awt.Color;
- import java.awt.Font;
- import java.awt.Graphics;
- import java.awt.Graphics2D;
- import java.awt.Point;
- import java.awt.event.MouseEvent;
- import java.awt.event.MouseListener;
- import java.awt.image.BufferedImage;
- import java.io.IOException;
- import java.net.MalformedURLException;
- import java.net.URL;
- import javax.imageio.ImageIO;
- import org.rsbot.event.events.MessageEvent;
- import org.rsbot.event.listeners.MessageListener;
- import org.rsbot.event.listeners.PaintListener;
- import org.rsbot.script.ScriptManifest;
- import org.rsbot.script.Script;
- import org.rsbot.script.wrappers.RSArea;
- import org.rsbot.script.wrappers.RSNPC;
- import org.rsbot.script.wrappers.RSObject;
- import org.rsbot.script.wrappers.RSTile;
- @ScriptManifest(authors={"Bollejef1"}, keywords={"banana", "gold", "money"}, name="Banana picker", description="Have gold in invo", version=1.4)
- public class Bananas extends Script implements PaintListener, MessageListener, MouseListener {
- //===========mouse variabele=============
- BufferedImage normal = null;
- BufferedImage clicked = null;
- RSArea depositbox = new RSArea(new RSTile(3042,3234), new RSTile(3050,3237));
- RSArea bananas = new RSArea(new RSTile(2905,3155), new RSTile(2930,3170));
- RSArea dockKaramja = new RSArea(new RSTile(2948,3145), new RSTile(2960,3151));
- RSArea dockSarim = new RSArea(new RSTile(3022,3213), new RSTile(3030,3222));
- /*RSArea boatSarim = new RSArea(new RSTile(3032,3213,1), new RSTile(3036,3224,1));
- RSArea boatKaramja = new RSArea(new RSTile(2952,3139,1), new RSTile(2963,3143,1));*/
- // RSTile[] pathFromBoatToBananas={new RSTile(2949,3147),new RSTile(2942,3147),
- // new RSTile(2933,3149),new RSTile(2922,3152),
- // new RSTile(2917,3159)};
- // RSTile[] pathFromBananasToBoat={new RSTile(2917,3161),new RSTile(2916,3154),
- // new RSTile(2926,3150),new RSTile(2936,3148),
- // new RSTile(2941,3146),new RSTile(2952,3146)};
- RSTile[] pathFromBoxToBoat={new RSTile(3036,3237),new RSTile(3028,3234),
- new RSTile(3027,3223),new RSTile(3027,3216)};
- RSTile[] pathFromBoatToBox={new RSTile(3027,3228),new RSTile(3029,3235),
- new RSTile(3038,3236),new RSTile(3046,3235)};
- RSTile toBox = new RSTile(3045, 3236);
- RSTile toBananas = new RSTile(2917,3159);
- RSTile boxToBoat = new RSTile(3027,3218);
- RSTile bananasToBoat = new RSTile(2952,3146);
- private int captainID=380, plankToBananas=2082, plankToBox=2084, boxID=36788,
- lastPlace, bananasGained, bananaPrice, costBoat, profit;
- private int[] verschillendeBomen={2073,2074,2075,2076,2077}, captainIDs={378,376,377};
- /*private int boomMet5Banane=2073;
- private int boomMet4Banane=2074;
- private int boomMet3Banane=2075;
- private int boomMet2Banane=2076;
- private int boomMet1Banaan=2077;
- private int boomZonderBanana=2078;*/
- private boolean banked=true;
- final ScriptManifest update = getClass().getAnnotation(ScriptManifest.class);
- public long startTime, millis, hours, minutes, seconds, last;
- public double secs=0;
- public double uren=0;
- public boolean onStart() {
- //voor de muis... erges gepikt op powerbot
- try {
- final URL cursorURL = new URL("http://i48.tinypic.com/313623n.png");
- final URL cursor80URL = new URL("http://i46.tinypic.com/9prjnt.png");
- 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.");
- }
- if(inventory.isFull())
- {banked=false;}
- // tot ier vo de muis
- bananaPrice=grandExchange.lookup(1963).getGuidePrice();
- log(Color.green,"Welkom! Banana price is: "+bananaPrice+" Sell above mid!");
- startTime = System.currentTimeMillis();
- return true;
- }
- public void mouseClicked(MouseEvent e){
- }
- public void mouseEntered(MouseEvent e){
- }
- public void mouseExited(MouseEvent e){
- }
- public void mouseReleased(MouseEvent e){
- }
- public void mousePressed(MouseEvent e){
- }
- public void messageReceived(MessageEvent e) {
- String x = e.getMessage().toLowerCase();
- if (x.contains("not have enough")) {
- log(Color.red,"Out of coins... We only have " + inventory.getCount(995) + " while we need atleast 60 coins");
- stopScript();
- }
- }
- //=====================================Walking methode, erges gepikt op powerbot==================
- private boolean walkPath(RSTile[] path, boolean reverse) {
- if (reverse) {
- for (int i = 0; i < path.length; i++) {
- path[i] = path[path.length - i - 1];
- }
- }
- if (calc.distanceTo(path[path.length - 1]) > 4) {
- RSTile n = getNext(path);
- if (n != null) {
- walking.walkTileMM(n.randomize(2, 2));
- sleep(600,900);
- 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;
- }
- private boolean walkPath(RSTile path[]){
- return walkPath(path,false);
- }
- //==========================Einde walking methode===============================
- private void WalkPath()
- {
- if(lastPlace==1 && banked==true && !inventory.contains(1963))
- {
- walkPath(pathFromBoxToBoat);
- //walking.getPath(boxToBoat);
- //walking.walkTo(boxToBoat);
- }
- else if(lastPlace==1&&banked==false)
- {
- Deposit();
- }
- if(lastPlace==2&&banked==true)
- {
- RSNPC schipper=npcs.getNearest(captainIDs);
- if(schipper!=null&&!schipper.isOnScreen())
- {walking.walkTileMM(schipper.getLocation());}
- if(schipper!=null)
- {
- camera.turnTo(schipper);
- }
- if(schipper!=null&&schipper.isOnScreen()&&!interfaces.get(241).getComponent(1).isValid())
- {
- schipper.doAction("fare");
- }
- sleep(700,1100);
- //log("interface valid:"+interfaces.get(241).getComponent(1).isValid());
- if(interfaces.get(241).getComponent(1).isValid())
- {
- ChatToBananas();
- sleep(8000,9000);
- }
- //log("z:"+getMyPlayer().getLocation().getZ());
- while(getMyPlayer().getLocation().getZ()>0&&game.isLoggedIn())
- {
- //log("entered while to click plank");
- RSObject plank=objects.getNearest(plankToBananas);
- if(plank!=null)
- {
- plank.interact("Cross");
- sleep(2500,3200);
- }
- costBoat+=30;
- }
- }
- else if(lastPlace==2&&banked==false)
- {
- walkPath(pathFromBoatToBox);
- //walking.getPath(toBox);
- //walking.walkTo(toBox);
- }
- if(lastPlace==3&&banked==true && !players.getMyPlayer().isMoving())
- {
- // walkPath(pathFromBoatToBananas);
- walking.getPath(toBananas);
- walking.walkTo(toBananas);
- }
- else if(lastPlace==3&&banked==false)
- {
- RSNPC schipper=npcs.getNearest(captainID);
- if(schipper!=null&&!schipper.isOnScreen())
- {walking.walkTileMM(schipper.getLocation());}
- if(schipper!=null)
- {
- camera.turnTo(schipper);
- }
- if(schipper!=null&&schipper.isOnScreen()&&!interfaces.get(241).getComponent(1).isValid())
- {
- schipper.doAction("fare");
- }
- sleep(1100,1400);
- //log("interface valid:"+interfaces.get(241).getComponent(1).isValid());
- if(interfaces.get(241).getComponent(1).isValid())
- {
- ChatToBox();
- sleep(8000,9000);
- }
- while(getMyPlayer().getLocation().getZ()>0&&game.isLoggedIn())
- {
- //log("entered while to click plank");
- RSObject plank=objects.getNearest(plankToBox);
- if(plank!=null)
- {
- plank.interact("Cross");
- sleep(2500,3200);
- }
- costBoat+=30;
- }
- }
- if(lastPlace==4&&inventory.isFull() && !players.getMyPlayer().isMoving())
- {
- banked=false;
- // walkPath(pathFromBananasToBoat);
- walking.getPath(bananasToBoat);
- walking.walkTo(bananasToBoat);
- }
- }
- private boolean AtBox() {
- if(depositbox.contains(getMyPlayer().getLocation()))
- {lastPlace=1;}
- return depositbox.contains(getMyPlayer().getLocation());
- }
- private boolean AtSarimBoat() {
- if(dockSarim.contains(getMyPlayer().getLocation()))
- {lastPlace=2;}
- return dockSarim.contains(getMyPlayer().getLocation());
- }
- private boolean AtKaramBoat() {
- if(dockKaramja.contains(getMyPlayer().getLocation()))
- {lastPlace=3;}
- return dockKaramja.contains(getMyPlayer().getLocation());
- }
- private boolean AtBananas() {
- if(bananas.contains(getMyPlayer().getLocation()))
- {lastPlace=4;}
- return bananas.contains(getMyPlayer().getLocation());
- }
- /*private boolean AtBoatSarim() {
- return boatSarim.contains(getMyPlayer().getLocation());
- }
- private boolean AtBoatKaramja() {
- return boatKaramja.contains(getMyPlayer().getLocation());getMyPlayer().
- }*/
- private void CheckPosition()
- {
- AtBox();
- AtSarimBoat();
- AtKaramBoat();
- AtBananas();
- }
- private void CheckRun() {
- if(walking.getEnergy() < random(20,40)) {
- //status = "Resting...";
- walking.rest(random(45,72));
- } else
- walking.setRun(true);
- sleep(1000);
- }
- private void ChatToBox() {
- if (interfaces.getComponent(228, 2).isValid()) {
- interfaces.getComponent(228, 2).doClick(); }
- mouse.click(random(137,466), random(448,460), true);
- sleep(700,990);
- mouse.click(random(150,375), random(397,409), true);
- sleep(700,990);
- mouse.click(random(114,301), random(447,457), true);
- sleep(700,990);
- mouse.click(random(214,394), random(447,459), true);
- sleep(700,990);
- mouse.click(random(123,395), random(410,426), true);
- sleep(700,990);
- mouse.click(random(120,310), random(445,460), true);
- sleep(700,990);
- mouse.click(random(210,410), random(445,460), true);
- sleep(700,990);
- mouse.click(random(235,300), random(395,410), true);
- sleep(700,990);
- mouse.click(random(125,300), random(450,460), true);
- }
- private void ChatToBananas()
- {
- mouse.click(random(210,400), random(450,460), true);
- sleep(700,990);
- mouse.click(random(210,310), random(395,410), true);
- sleep(700,990);
- mouse.click(random(125,310), random(445,460), true);
- }
- private void Deposit() {
- RSObject box=objects.getNearest(boxID);
- if( box.isOnScreen() && !bank.isOpen() ) {
- box.interact("Deposit");
- sleep(1500);
- }
- if(bank.isDepositOpen()){
- bank.depositAllExcept(995);
- banked=true;
- bananasGained+=27;
- sleep(700,900);
- }
- bank.close();
- sleep(1000);
- }
- private void PickBananas() {
- if(!inventory.isFull()&&(players.getMyPlayer().isIdle()||players.getMyPlayer().getAnimation()==11786||players.getMyPlayer().getAnimation()==5713)) {
- //log("banaantjes plukke :)");
- RSObject boom=objects.getNearest(verschillendeBomen);
- if(boom!=null&&boom.isOnScreen()) {
- boom.interact("Pick");
- sleep(random(400,600));
- }
- else if( !boom.isOnScreen())
- {walking.walkTileMM(boom.getLocation());}
- sleep(300,500);
- }
- }
- public int loop() {
- CheckPosition();
- if (interfaces.canContinue()) {
- interfaces.clickContinue();
- }
- mouse.setSpeed(random(5,7));
- if (!game.isLoggedIn()) { return 3000; }
- if(!walking.isRunEnabled()) { CheckRun(); }
- WalkPath();
- RSObject box=objects.getNearest(boxID);
- if(inventory.isFull() && depositbox.contains(getMyPlayer().getLocation())) {
- Deposit(); }
- if(lastPlace==4 && banked==true) { PickBananas(); }
- return random(100,300);
- }
- @Override
- public void onFinish(){
- log(Color.red,"Ist al gedaan? :p");
- log("Time ran: "+ hours +" h "+ minutes + " m " + seconds+" s");
- log("Profit made: "+profit);
- }
- //START: Code generated using Enfilade's Easel
- private final Color color1 = new Color(102, 204, 255, 135);
- private final Color color2 = new Color(0, 0, 0);
- private final BasicStroke stroke1 = new BasicStroke(1);
- private final Font font1 = new Font("Arial", 0, 13);
- public void onRepaint(Graphics g1) {
- Graphics2D g = (Graphics2D)g1;
- /*drawMouseLines(g);*/
- final Point p = mouse.getLocation();
- final Point c = mouse.getPressLocation();
- final long mpt = System.currentTimeMillis()- mouse.getPressTime();
- if (mouse.getPressTime() == -1 || mpt >= 1000) {
- g.drawImage(normal, p.x - 8, p.y - 8, null); // this
- }
- if (mpt < 1000) {
- g.drawImage(clicked, c.x - 8, c.y - 8, null);
- }
- millis = System.currentTimeMillis() - startTime;
- secs=millis/1000;
- uren=secs/3600;
- hours = millis / (1000 * 60 * 60);
- millis -= hours * (1000 * 60 * 60);
- minutes = millis / (1000 * 60);
- millis -= minutes * (1000 * 60);
- seconds = millis / 1000;
- profit=(bananaPrice*bananasGained)-costBoat;
- g.setColor(color1);
- g.fillRoundRect(11, 14, 160, 100, 16, 16);
- g.setColor(color2);
- g.setStroke(stroke1);
- g.drawRoundRect(11, 14, 160, 100, 16, 16);
- g.setFont(font1);
- g.drawString("BananaPicker " + update.version(), 25, 35);
- g.drawString("By Bollejef1", 25, 50);
- g.drawString("Bananas Picked: " +bananasGained, 25, 65);
- g.drawString("Profit: "+profit, 25, 80);
- g.drawString("Profit/h: "+Math.round(((profit)/1000)/uren)+" k", 25, 95);
- g.drawString("RunTime: "+ hours +" h "+ minutes + " m " + seconds+" s", 25, 110);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment