Ministry

Bananas 1.4

Jun 25th, 2011
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 17.86 KB | None | 0 0
  1. import java.awt.BasicStroke;
  2. import java.awt.Color;
  3. import java.awt.Font;
  4. import java.awt.Graphics;
  5. import java.awt.Graphics2D;
  6. import java.awt.Point;
  7. import java.awt.event.MouseEvent;
  8. import java.awt.event.MouseListener;
  9. import java.awt.image.BufferedImage;
  10. import java.io.IOException;
  11. import java.net.MalformedURLException;
  12. import java.net.URL;
  13.  
  14. import javax.imageio.ImageIO;
  15.  
  16. import org.rsbot.event.events.MessageEvent;
  17. import org.rsbot.event.listeners.MessageListener;
  18. import org.rsbot.event.listeners.PaintListener;
  19. import org.rsbot.script.ScriptManifest;
  20. import org.rsbot.script.Script;
  21. import org.rsbot.script.wrappers.RSArea;
  22. import org.rsbot.script.wrappers.RSNPC;
  23. import org.rsbot.script.wrappers.RSObject;
  24. import org.rsbot.script.wrappers.RSTile;
  25.  
  26. @ScriptManifest(authors={"Bollejef1"}, keywords={"banana", "gold", "money"}, name="Banana picker", description="Have gold in invo", version=1.4)
  27. public class Bananas extends Script implements PaintListener, MessageListener, MouseListener {
  28.  
  29.         //===========mouse variabele=============
  30.          BufferedImage normal = null;
  31.          BufferedImage clicked = null;
  32.          
  33.          RSArea depositbox = new RSArea(new RSTile(3042,3234), new RSTile(3050,3237));
  34.          RSArea bananas = new RSArea(new RSTile(2905,3155), new RSTile(2930,3170));
  35.          RSArea dockKaramja = new RSArea(new RSTile(2948,3145), new RSTile(2960,3151));
  36.          RSArea dockSarim = new RSArea(new RSTile(3022,3213), new RSTile(3030,3222));
  37.          /*RSArea boatSarim = new RSArea(new RSTile(3032,3213,1), new RSTile(3036,3224,1));
  38.          RSArea boatKaramja = new RSArea(new RSTile(2952,3139,1), new RSTile(2963,3143,1));*/
  39.          
  40.         // RSTile[] pathFromBoatToBananas={new RSTile(2949,3147),new RSTile(2942,3147),
  41.                 //                         new RSTile(2933,3149),new RSTile(2922,3152),
  42.                    //                      new RSTile(2917,3159)};
  43.         // RSTile[] pathFromBananasToBoat={new RSTile(2917,3161),new RSTile(2916,3154),
  44.             //                             new RSTile(2926,3150),new RSTile(2936,3148),
  45.              //                            new RSTile(2941,3146),new RSTile(2952,3146)};
  46.         RSTile[] pathFromBoxToBoat={new RSTile(3036,3237),new RSTile(3028,3234),
  47.                                     new RSTile(3027,3223),new RSTile(3027,3216)};
  48.         RSTile[] pathFromBoatToBox={new RSTile(3027,3228),new RSTile(3029,3235),
  49.                                     new RSTile(3038,3236),new RSTile(3046,3235)};
  50.  
  51.          RSTile toBox = new RSTile(3045, 3236);
  52.          RSTile toBananas = new RSTile(2917,3159);
  53.          RSTile boxToBoat = new RSTile(3027,3218);
  54.          RSTile bananasToBoat = new RSTile(2952,3146);
  55.  
  56.          private int captainID=380, plankToBananas=2082, plankToBox=2084, boxID=36788,
  57.                      lastPlace, bananasGained, bananaPrice, costBoat, profit;
  58.          private int[] verschillendeBomen={2073,2074,2075,2076,2077}, captainIDs={378,376,377};
  59.          /*private int boomMet5Banane=2073;
  60.          private int boomMet4Banane=2074;
  61.          private int boomMet3Banane=2075;
  62.          private int boomMet2Banane=2076;
  63.          private int boomMet1Banaan=2077;
  64.          private int boomZonderBanana=2078;*/
  65.          private boolean banked=true;
  66.  
  67.          final ScriptManifest update = getClass().getAnnotation(ScriptManifest.class);
  68.          
  69.          public long startTime, millis, hours, minutes, seconds, last;
  70.  
  71.          public double secs=0;
  72.          public double uren=0;
  73.          
  74.          
  75.          
  76.          
  77.         public boolean onStart() {
  78.          //voor de muis... erges gepikt op powerbot
  79.          try {
  80.                         final URL cursorURL = new URL("http://i48.tinypic.com/313623n.png");
  81.                         final URL cursor80URL = new URL("http://i46.tinypic.com/9prjnt.png");
  82.                         normal = ImageIO.read(cursorURL);
  83.                         clicked = ImageIO.read(cursor80URL);
  84.                 } catch (MalformedURLException e) {
  85.                         log("Unable to buffer cursor.");
  86.                 } catch (IOException e) {
  87.                         log("Unable to open cursor image.");
  88.                 }
  89.                 if(inventory.isFull())
  90.                 {banked=false;}
  91.                 // tot ier vo de muis
  92.                 bananaPrice=grandExchange.lookup(1963).getGuidePrice();
  93.                 log(Color.green,"Welkom! Banana price is: "+bananaPrice+" Sell above mid!");
  94.                 startTime = System.currentTimeMillis();
  95.                 return true;
  96.     }
  97.  
  98.        
  99.         public void mouseClicked(MouseEvent e){
  100.          
  101.          }
  102.  
  103.          public void mouseEntered(MouseEvent e){
  104.          }
  105.  
  106.          public void mouseExited(MouseEvent e){
  107.          }
  108.  
  109.          public void mouseReleased(MouseEvent e){
  110.          }
  111.  
  112.          public void mousePressed(MouseEvent e){
  113.          }
  114.          
  115.         public void messageReceived(MessageEvent e) {
  116.                     String x = e.getMessage().toLowerCase();
  117.      if (x.contains("not have enough")) {
  118.          log(Color.red,"Out of coins... We only have " + inventory.getCount(995) + " while we need atleast 60 coins");
  119.          stopScript();
  120.             }
  121.           }
  122.        
  123.         //=====================================Walking methode, erges gepikt op powerbot==================
  124.     private boolean walkPath(RSTile[] path, boolean reverse) {
  125.         if (reverse) {
  126.             for (int i = 0; i < path.length; i++) {
  127.                 path[i] = path[path.length - i - 1];
  128.             }
  129.         }
  130.         if (calc.distanceTo(path[path.length - 1]) > 4) {
  131.             RSTile n = getNext(path);
  132.             if (n != null) {
  133.                 walking.walkTileMM(n.randomize(2, 2));
  134.                 sleep(600,900);
  135.                 if (random(1, 6) != 2) {
  136.                     mouse.moveRandomly(20);
  137.                 }
  138.             }
  139.         }
  140.         return false;
  141.     }
  142.     private RSTile getNext(RSTile[] path) {
  143.         boolean found = false;
  144.         for (int a = 0; a < path.length && !found; a++) {
  145.             if (calc.tileOnMap(path[path.length - 1 - a])) {
  146.                 found = true;
  147.                 return path[path.length - 1 - a];
  148.             }
  149.         }
  150.         return null;
  151.     }
  152.     private boolean walkPath(RSTile path[]){
  153.         return walkPath(path,false);
  154.     }
  155.     //==========================Einde walking methode===============================
  156.     private void WalkPath()
  157.     {
  158.         if(lastPlace==1 && banked==true && !inventory.contains(1963))
  159.         {
  160.                 walkPath(pathFromBoxToBoat);
  161.                 //walking.getPath(boxToBoat);
  162.                //walking.walkTo(boxToBoat);
  163.         }
  164.         else if(lastPlace==1&&banked==false)
  165.         {
  166.                 Deposit();
  167.         }
  168.         if(lastPlace==2&&banked==true)
  169.         {
  170.                 RSNPC schipper=npcs.getNearest(captainIDs);
  171.                 if(schipper!=null&&!schipper.isOnScreen())
  172.                 {walking.walkTileMM(schipper.getLocation());}
  173.                 if(schipper!=null)
  174.                 {
  175.                 camera.turnTo(schipper);
  176.                 }
  177.                 if(schipper!=null&&schipper.isOnScreen()&&!interfaces.get(241).getComponent(1).isValid())
  178.                 {
  179.                 schipper.doAction("fare");
  180.                 }
  181.                 sleep(700,1100);
  182.                 //log("interface valid:"+interfaces.get(241).getComponent(1).isValid());
  183.                 if(interfaces.get(241).getComponent(1).isValid())
  184.                 {
  185.                 ChatToBananas();
  186.                 sleep(8000,9000);
  187.                 }
  188.                
  189.                 //log("z:"+getMyPlayer().getLocation().getZ());
  190.                 while(getMyPlayer().getLocation().getZ()>0&&game.isLoggedIn())
  191.                 {
  192.                 //log("entered while to click plank");
  193.                 RSObject plank=objects.getNearest(plankToBananas);
  194.                 if(plank!=null)
  195.                 {
  196.                 plank.interact("Cross");
  197.                 sleep(2500,3200);
  198.                 }
  199.                 costBoat+=30;
  200.                 }
  201.                
  202.         }
  203.         else if(lastPlace==2&&banked==false)
  204.         {
  205.                 walkPath(pathFromBoatToBox);
  206.                 //walking.getPath(toBox);
  207.                 //walking.walkTo(toBox);
  208.                
  209.         }
  210.         if(lastPlace==3&&banked==true && !players.getMyPlayer().isMoving())
  211.         {
  212.                // walkPath(pathFromBoatToBananas);
  213.                 walking.getPath(toBananas);
  214.                 walking.walkTo(toBananas);
  215.                
  216.         }
  217.         else if(lastPlace==3&&banked==false)
  218.         {
  219.                 RSNPC schipper=npcs.getNearest(captainID);
  220.                 if(schipper!=null&&!schipper.isOnScreen())
  221.                 {walking.walkTileMM(schipper.getLocation());}
  222.                 if(schipper!=null)
  223.                 {
  224.                 camera.turnTo(schipper);
  225.                 }
  226.                 if(schipper!=null&&schipper.isOnScreen()&&!interfaces.get(241).getComponent(1).isValid())
  227.                 {
  228.                 schipper.doAction("fare");
  229.                 }
  230.                 sleep(1100,1400);
  231.                
  232.                 //log("interface valid:"+interfaces.get(241).getComponent(1).isValid());
  233.                 if(interfaces.get(241).getComponent(1).isValid())
  234.                 {
  235.                 ChatToBox();
  236.                 sleep(8000,9000);
  237.                 }
  238.                
  239.                 while(getMyPlayer().getLocation().getZ()>0&&game.isLoggedIn())
  240.                 {
  241.                 //log("entered while to click plank");
  242.                 RSObject plank=objects.getNearest(plankToBox);
  243.                 if(plank!=null)
  244.                 {
  245.                 plank.interact("Cross");
  246.                 sleep(2500,3200);
  247.                 }
  248.                 costBoat+=30;
  249.                 }
  250.                
  251.         }
  252.         if(lastPlace==4&&inventory.isFull() && !players.getMyPlayer().isMoving())
  253.         {
  254.                 banked=false;
  255.                // walkPath(pathFromBananasToBoat);
  256.                 walking.getPath(bananasToBoat);
  257.                 walking.walkTo(bananasToBoat);
  258.  
  259.         }
  260.     }
  261.     private boolean AtBox() {
  262.          if(depositbox.contains(getMyPlayer().getLocation()))
  263.          {lastPlace=1;}
  264.                 return depositbox.contains(getMyPlayer().getLocation());
  265.         }
  266.     private boolean AtSarimBoat() {
  267.          if(dockSarim.contains(getMyPlayer().getLocation()))
  268.          {lastPlace=2;}
  269.                 return dockSarim.contains(getMyPlayer().getLocation());
  270.                
  271.         }
  272.     private boolean AtKaramBoat() {
  273.          if(dockKaramja.contains(getMyPlayer().getLocation()))
  274.          {lastPlace=3;}
  275.                 return dockKaramja.contains(getMyPlayer().getLocation());
  276.         }
  277.     private boolean AtBananas() {
  278.          if(bananas.contains(getMyPlayer().getLocation()))
  279.          {lastPlace=4;}
  280.                 return bananas.contains(getMyPlayer().getLocation());
  281.         }
  282.     /*private boolean AtBoatSarim() {
  283.          
  284.                 return boatSarim.contains(getMyPlayer().getLocation());
  285.         }
  286.     private boolean AtBoatKaramja() {
  287.          
  288.                 return boatKaramja.contains(getMyPlayer().getLocation());getMyPlayer().
  289.         }*/
  290.    
  291.    
  292.     private void CheckPosition()
  293.         {
  294.                 AtBox();
  295.                 AtSarimBoat();
  296.                 AtKaramBoat();
  297.                 AtBananas();
  298.                
  299.         }
  300.    
  301.     private void CheckRun() {        
  302.                         if(walking.getEnergy() < random(20,40)) {
  303.                                 //status = "Resting...";
  304.                                 walking.rest(random(45,72));
  305.                         } else
  306.                                 walking.setRun(true);
  307.                                 sleep(1000);
  308.         }
  309.    
  310.     private void ChatToBox() {
  311.         if (interfaces.getComponent(228, 2).isValid()) {
  312.             interfaces.getComponent(228, 2).doClick(); }
  313.                 mouse.click(random(137,466), random(448,460), true);
  314.                 sleep(700,990);
  315.                 mouse.click(random(150,375), random(397,409), true);
  316.                 sleep(700,990);
  317.                 mouse.click(random(114,301), random(447,457), true);
  318.                 sleep(700,990);
  319.                 mouse.click(random(214,394), random(447,459), true);
  320.                 sleep(700,990);
  321.                 mouse.click(random(123,395), random(410,426), true);
  322.                 sleep(700,990);
  323.                 mouse.click(random(120,310), random(445,460), true);
  324.                 sleep(700,990);
  325.                 mouse.click(random(210,410), random(445,460), true);
  326.                 sleep(700,990);
  327.                 mouse.click(random(235,300), random(395,410), true);
  328.                 sleep(700,990);
  329.                 mouse.click(random(125,300), random(450,460), true);
  330.         }
  331.         private void ChatToBananas()
  332.         {
  333.                 mouse.click(random(210,400), random(450,460), true);
  334.                 sleep(700,990);
  335.                 mouse.click(random(210,310), random(395,410), true);
  336.                 sleep(700,990);
  337.                 mouse.click(random(125,310), random(445,460), true);
  338.         }
  339.        
  340.        
  341.         private void Deposit() {
  342.                 RSObject box=objects.getNearest(boxID);
  343.                 if( box.isOnScreen() && !bank.isOpen() ) {
  344.                         box.interact("Deposit");
  345.                         sleep(1500);
  346.                 }
  347.                 if(bank.isDepositOpen()){
  348.                          bank.depositAllExcept(995);
  349.                          banked=true;
  350.                          bananasGained+=27;
  351.                          sleep(700,900);
  352.                 }
  353.                 bank.close();
  354.                 sleep(1000);
  355.             }
  356.        
  357.         private void PickBananas() {
  358.                 if(!inventory.isFull()&&(players.getMyPlayer().isIdle()||players.getMyPlayer().getAnimation()==11786||players.getMyPlayer().getAnimation()==5713)) {
  359.                                 //log("banaantjes plukke :)");
  360.                                 RSObject boom=objects.getNearest(verschillendeBomen);
  361.                                 if(boom!=null&&boom.isOnScreen()) {
  362.                                 boom.interact("Pick");
  363.                                 sleep(random(400,600));
  364.                                 }
  365.                                 else if( !boom.isOnScreen())
  366.                                 {walking.walkTileMM(boom.getLocation());}
  367.                                 sleep(300,500);    
  368.                 }
  369.         }
  370.        
  371.        
  372.        
  373.        
  374.        
  375.        
  376.        
  377.          public int loop() {
  378.         CheckPosition();
  379.    if (interfaces.canContinue()) {
  380.       interfaces.clickContinue();
  381.       }
  382.       mouse.setSpeed(random(5,7));
  383.  
  384.    if (!game.isLoggedIn()) { return 3000; }
  385.  
  386.    if(!walking.isRunEnabled()) { CheckRun(); }
  387.                  WalkPath();
  388.    RSObject box=objects.getNearest(boxID);
  389.    if(inventory.isFull() && depositbox.contains(getMyPlayer().getLocation())) {
  390.        Deposit(); }
  391.    if(lastPlace==4 && banked==true) { PickBananas(); }
  392.  
  393.          
  394.          return random(100,300);
  395.          }
  396.          @Override
  397.          public void onFinish(){
  398.          log(Color.red,"Ist al gedaan? :p");
  399.          log("Time ran: "+ hours +" h "+ minutes + " m " + seconds+" s");
  400.          log("Profit made: "+profit);
  401.      }
  402.          
  403.          //START: Code generated using Enfilade's Easel
  404.             private final Color color1 = new Color(102, 204, 255, 135);
  405.             private final Color color2 = new Color(0, 0, 0);
  406.  
  407.             private final BasicStroke stroke1 = new BasicStroke(1);
  408.  
  409.             private final Font font1 = new Font("Arial", 0, 13);
  410.  
  411.          public void onRepaint(Graphics g1) {
  412.                
  413.                 Graphics2D g = (Graphics2D)g1;
  414.                  /*drawMouseLines(g);*/
  415.                  final Point p = mouse.getLocation();
  416.                                 final Point c = mouse.getPressLocation();
  417.                                 final long mpt = System.currentTimeMillis()- mouse.getPressTime();
  418.                                 if (mouse.getPressTime() == -1 || mpt >= 1000) {
  419.                                         g.drawImage(normal, p.x - 8, p.y - 8, null); // this
  420.                                        
  421.                                 }
  422.  
  423.                                 if (mpt < 1000) {
  424.                                         g.drawImage(clicked, c.x - 8, c.y - 8, null);          
  425.                                
  426.                                 }
  427.                         millis = System.currentTimeMillis() - startTime;
  428.                         secs=millis/1000;
  429.                         uren=secs/3600;
  430.                         hours = millis / (1000 * 60 * 60);
  431.                         millis -= hours * (1000 * 60 * 60);
  432.                         minutes = millis / (1000 * 60);
  433.                         millis -= minutes * (1000 * 60);
  434.                         seconds = millis / 1000;
  435.                         profit=(bananaPrice*bananasGained)-costBoat;
  436.                         g.setColor(color1);
  437.                         g.fillRoundRect(11, 14, 160, 100, 16, 16);
  438.                         g.setColor(color2);
  439.                         g.setStroke(stroke1);
  440.                         g.drawRoundRect(11, 14, 160, 100, 16, 16);
  441.                         g.setFont(font1);
  442.                         g.drawString("BananaPicker " + update.version(), 25, 35);
  443.                         g.drawString("By Bollejef1", 25, 50);
  444.                         g.drawString("Bananas Picked: " +bananasGained, 25, 65);
  445.                         g.drawString("Profit: "+profit, 25, 80);
  446.                         g.drawString("Profit/h: "+Math.round(((profit)/1000)/uren)+" k", 25, 95);
  447.                         g.drawString("RunTime: "+ hours +" h "+ minutes + " m " + seconds+" s", 25, 110);
  448.          }
  449.        
  450. }
Advertisement
Add Comment
Please, Sign In to add comment