Ministry

GraveDigger v1.2 by Ministry

Apr 22nd, 2011
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 16.57 KB | None | 0 0
  1. import java.awt.*;
  2. import java.awt.event.*;
  3. import java.awt.event.MouseListener;
  4. import javax.swing.*;
  5. import java.awt.image.BufferedImage;
  6. import javax.imageio.ImageIO;
  7. import java.io.IOException;
  8. import java.net.URL;
  9.  
  10. import org.rsbot.event.events.MessageEvent;
  11. import org.rsbot.event.listeners.MessageListener;
  12. import org.rsbot.event.listeners.PaintListener;
  13.  
  14. import org.rsbot.script.*;
  15. import org.rsbot.script.wrappers.*;
  16. import org.rsbot.script.methods.Skills;
  17. import org.rsbot.script.wrappers.RSGroundItem;
  18. import org.rsbot.script.util.Filter;
  19.  
  20. @ScriptManifest( authors = { "Ministry" },
  21.                  keywords = { "Prayer" },
  22.                  name = "<html><b>GraveDigger</b></html>",
  23.                  description = "Picks up any bones from the ground & burys them.",
  24.                  version = 1.3 )
  25. public class GraveDigger extends Script implements PaintListener, MessageListener, MouseListener {
  26.  
  27.             private int startLevel, currLevel, startExp, currXP, lvlsGained, bonesburied = 0,
  28.                    expGained, expHour, expToLevel, percentTNL, boneID;
  29.  
  30.             private final static int bonesID = 526, bigBonesID = 532, babyDragonID = 534, dragonBonesID= 536;
  31.  
  32.             private final static int keep[] = { 526, 532, 534, 536 };
  33.  
  34.             private boolean Bury, showPaint = true, lootBones = true;
  35.             private boolean guiWait = true;
  36.  
  37.             private long startTime = 0, millis = 0, hours = 0, minutes = 0, seconds = 0,
  38.                     STL = 0, MTL = 0, HTL = 0, last = 0;
  39.  
  40.             private float sXP = 0, mXP = 0, hXP = 0;
  41.  
  42.             private BufferedImage normal = null, clicked = null;
  43.  
  44.             private RSArea chickens = new RSArea(3226, 3288, 3236, 3301);
  45.             private RSArea goblins = new RSArea(new RSTile (3262, 3252), new RSTile (3245, 3225));
  46.  
  47.             final ScriptManifest update = getClass().getAnnotation(ScriptManifest.class);
  48.             gui g = new gui();
  49.  
  50. @Override
  51.     public boolean onStart() {
  52.         startTime = System.currentTimeMillis();
  53.         startExp = skills.getCurrentExp(Skills.PRAYER);
  54.                 currXP = startExp;
  55.         expGained = skills.getCurrentExp(Skills.PRAYER) - startExp;
  56.         startLevel = skills.getCurrentLevel(Skills.PRAYER);
  57.         log("Welcome to GraveDigger v" + update.version() + " by Ministry");
  58.        
  59.         g.setVisible(true);
  60.         while(guiWait) sleep(500);
  61.  
  62.                 try {
  63.                 final URL cursorURL = new URL("http://sc2upload.sytes.net/rsbot/cursor2.png");
  64.                 final URL clickedURL = new URL("http://sc2upload.sytes.net/rsbot/cursor1.png");
  65.                 normal = ImageIO.read(cursorURL);
  66.                 clicked = ImageIO.read(clickedURL);
  67.             } catch (Exception e) {
  68.                 log("Error obtaining custom cursor.");
  69.             }
  70.  
  71.         return true;
  72.        
  73.     }
  74.  
  75.  
  76.  
  77.     public void messageReceived(MessageEvent e) {
  78.         String x = e.getMessage().toLowerCase();
  79.         if (x.contains("bury the bones")) {
  80.             bonesburied++;  
  81.                 }
  82.             }
  83.    
  84.     public void messageReceived2(MessageEvent e) {
  85.         String x = e.getMessage().toLowerCase();
  86.         if (x.contains("can't reach that")) {
  87.                     RSTile Current = getMyPlayer().getLocation();
  88.                         walking.walkTileMM(Current, 6, 6);
  89.         }
  90.             }
  91.  
  92.         public final void antiban() {
  93.         int b = random(0, 25);
  94.         switch (b) {
  95.         case 1:
  96.             if (random(0, 10) == 5) {
  97.                 mouse.moveSlightly();
  98.                 sleep(200, 600);
  99.                 mouse.moveRandomly(150, 350);
  100.             }
  101.             break;
  102.         case 2:
  103.             if (random(0, 13) == 2) {
  104.                 camera.setAngle(random(30, 70));
  105.                 sleep(400, 1200);
  106.             }
  107.             break;
  108.         case 3:
  109.             if (random(0, 24) == 6) {
  110.                 mouse.moveOffScreen();
  111.                 sleep(1200, 2000);
  112.             }
  113.             break;
  114.         case 4:
  115.             if (random(0, 18) == 3) {
  116.                 game.openTab(1);
  117.                 skills.doHover(Skills.INTERFACE_PRAYER);
  118.                 sleep(2100, 3400);
  119.             }
  120.             break;
  121.         case 5:
  122.             if (random(0, 15) == 4) {
  123.                 mouse.moveRandomly(8);
  124.                 sleep(1400, 2400);
  125.             }
  126.             break;
  127.         case 6:
  128.             if (random(0, 19) == 5) {
  129.                 game.openTab(random(2, 7));
  130.                 mouse.sleep(1500);
  131.                 sleep(400, 500);
  132.             }
  133.          case 7:
  134.          if(random(0,6) == 5){
  135.             mouse.move(535, 60);
  136.             mouse.click(true);
  137.             sleep(1000, 2500);
  138.         }
  139.             break;
  140.         default:
  141.             break;
  142.         }
  143.     }
  144.  
  145.        
  146.     private void FindBones() {
  147.         RSGroundItem bone = groundItems.getNearest(boneID);
  148.             if(bone !=null && players.getMyPlayer().isIdle()) {
  149.                 RSGroundItem bones = pickup();
  150.                     if  (!inventory.isFull()) {
  151.                             if (bones.isOnScreen() && (bones != null)) {
  152.                                     bones.interact("Take bones");
  153.                             }else
  154.                             if (!bones.isOnScreen()) {
  155.                                     camera.turnTo(bones.getLocation(), 15);
  156.                                     if (!bones.isOnScreen()) {
  157.                                             walking.walkTileMM(walking.getClosestTileOnMap(bones.getLocation()));
  158.             } else {
  159.                 if(bone == null) {
  160.                 sleep(random(400,450));
  161.                                  }}
  162.                             }
  163.                     }}
  164.             }
  165.  
  166.     private void BuryBones() {
  167.         game.openTab(4);
  168.              if (inventory.contains(boneID) && game.getCurrentTab() == 4) {
  169.                 while (inventory.getCount(boneID) > 0) {
  170.                    for(RSItem bone: inventory.getItems(boneID)) {
  171.                      if (bone != null) {
  172.                         bone.doClick(true);
  173.                         sleep(random(195, 210));
  174.                         }
  175.                        }
  176.                     }
  177.         }
  178.         sleep(500);
  179.                 }
  180.        
  181.     private void runEnable () {
  182.         if(walking.isRunEnabled() == false && walking.getEnergy() >= random(55, 68)) {
  183.             walking.setRun(true);
  184.             }
  185.     }
  186.    
  187.     private RSGroundItem pickup() {
  188.         return groundItems.getNearest(new Filter<RSGroundItem>() {
  189.             public boolean accept(RSGroundItem g) {
  190.                 return g.getItem().getID() == boneID;
  191.             }
  192.         });
  193.     }
  194.  
  195.         public void dropAll() {
  196.             sleep(random(150, 300));
  197.             if (players.getMyPlayer().isIdle()) {
  198.                 inventory.dropAllExcept(keep);
  199.             }
  200.         }
  201.        
  202. @Override
  203.     public void onFinish() {
  204.         env.saveScreenshot(false);
  205.         log("GraveDigger v" + update.version() + " stopped.");
  206.         log("Ran for: " +hours + ":" + minutes + ":" + seconds);
  207.         log("Burried: " + bonesburied + " bones");
  208.         log("Gained : " + expGained + " experience and " + lvlsGained + " levels");
  209.     }
  210.    
  211.     public int loop() {
  212.         sleep(random(400,650));
  213.                 mouse.setSpeed(random(7, 9));
  214.                 dropAll();
  215.         runEnable();
  216.                 antiban();
  217.                 if (!inventory.isFull()) {
  218.                         FindBones();
  219.                 }
  220.         if (inventory.isFull()) {
  221.             BuryBones();
  222.         }
  223.         return random(350, 700);
  224.        
  225.     }
  226.    
  227.  
  228.     private final RenderingHints antialiasing = new RenderingHints(
  229.             RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
  230.  
  231.     private Image getImage(String url) {
  232.         try {
  233.             return ImageIO.read(new URL(url));
  234.         } catch(IOException e) {
  235.             return null;
  236.         }
  237.     }
  238.  
  239.     private final Color color1 = new Color(0, 0, 0, 135);
  240.     private final Color color2 = new Color(35, 36, 135, 180);
  241.     private final Color color4 = new Color(51, 153, 0);
  242.     private final Color color5 = new Color(255, 255, 255);
  243.     private final Color color7 = new Color(0, 0, 0);
  244.  
  245.     private final BasicStroke stroke1 = new BasicStroke(1);
  246.  
  247.     private final Font font1 = new Font("Rockwell", 1, 16);
  248.     private final Font font2 = new Font("Rockwell", 0, 14);
  249.     private final Font font3 = new Font("Rockwell", 0, 12);
  250.     private final Font font4 = new Font("Rockwell", 1, 8);
  251.  
  252.     private final Image Zomzom = getImage("http://sc2upload.sytes.net/images//1303413346-zw.PNG");
  253.     private final Image pBar = getImage("http://sc2upload.dyndns.org/images/re.png");
  254.     private final Image Simg = getImage("http://sc2upload.dyndns.org/images/S.png");
  255.     private final Image Himg = getImage("http://sc2upload.dyndns.org/images/H.png");
  256.  
  257.         Rectangle tab1 = new Rectangle(496, 345, 30, 30);
  258.         //format is rectangle(xCORD, yCORD, WIDTH, HEIGHT)//
  259.  
  260.  
  261.     public void mouseClicked(MouseEvent e){
  262.      if(tab1.contains(e.getPoint())){
  263.       showPaint = !showPaint;
  264.           }
  265.     }
  266.         public void mouseEntered(MouseEvent e){
  267.         }
  268.         public void mouseExited(MouseEvent e){
  269.         }
  270.         public void mouseReleased(MouseEvent e){
  271.         }
  272.         public void mousePressed(MouseEvent e){
  273.         }
  274.  
  275.  
  276.  
  277.     public void onRepaint(Graphics g1) {
  278.            Graphics2D g = (Graphics2D)g1;
  279.                 if (game.isLoggedIn() && !game.isWelcomeScreen())
  280.             {
  281.         millis = System.currentTimeMillis() - startTime;
  282.         hours = millis / (1000 * 60 * 60);
  283.         millis -= hours * (1000 * 60 * 60);
  284.         minutes = millis / (1000 * 60);
  285.         millis -= minutes * (1000 * 60);
  286.         seconds = millis / 1000;
  287.         currLevel = skills.getCurrentLevel(Skills.PRAYER);
  288.                 currXP = skills.getCurrentExp(Skills.PRAYER);
  289.         lvlsGained = currLevel - startLevel;
  290.                 expGained = currXP - startExp;
  291.                 expToLevel = skills.getExpToNextLevel(Skills.PRAYER);
  292.                 percentTNL = skills.getPercentToNextLevel(skills.PRAYER);
  293.                 expHour = (int) ((expGained) * 3600000D / (System.currentTimeMillis() - startTime));
  294.  
  295.                   final int percentBar = (int) (skills.getPercentToNextLevel(Skills.PRAYER)*0.52);
  296.  
  297.                   if ((minutes > 0 || hours > 0 || seconds > 0) && expGained > 0) {
  298.             sXP = (float) expGained
  299.                                 / (float) (seconds + minutes * 60 + hours * 60 * 60);
  300.                 }
  301.                 mXP = sXP * 60;
  302.                 hXP = mXP * 60;
  303.  
  304.                   if (sXP > 0) {
  305.                 STL = (int) (expToLevel / sXP);
  306.                 }
  307.                 if (STL >= 60) {
  308.                     MTL = STL / 60;
  309.                     STL -= MTL * 60;
  310.                 } else {
  311.                     MTL = 0;
  312.                 }
  313.                 if (MTL >= 60) {
  314.                     HTL = MTL / 60;
  315.                     MTL -= HTL * 60;
  316.                 } else {
  317.                     HTL = 0;
  318.                 }
  319.           if (clicked != null) {
  320.                         final int mx = (int)mouse.getLocation().getX();
  321.                         final int my = (int)mouse.getLocation().getY();
  322.  
  323.                         final long mpt = System.currentTimeMillis() - mouse.getPressTime();
  324.                         if (mouse.getPressTime() == -1 || mpt >= 300)
  325.                                 g.drawImage(normal, mx - 10, my - 6, null);
  326.                         if (mpt < 300)
  327.                                 g.drawImage(clicked, mx - 10, my - 6, null);
  328.                 }
  329.         if (showPaint == true) {
  330.         //this is so you can see where the location is at, you can delete these once you get the correct size and cords//
  331.         g.setRenderingHints(antialiasing);
  332.         g.setColor(color1);
  333.         g.fillRect(279, 351, 214, 104);
  334.         g.setStroke(stroke1);
  335.         g.drawRect(279, 351, 214, 104);
  336.         g.setColor(color2);
  337.         g.fillRect(276, 348, 214, 104);
  338.         g.setColor(color7);
  339.         g.drawRect(276, 348, 214, 104);
  340.         g.setFont(font1);
  341.         g.drawString("Grave Digger", 312, 364);
  342.         g.setFont(font2);
  343.         g.drawString("v"+ update.version(), 424, 366);
  344.         g.setFont(font3);
  345.         g.drawString("Bones Burried  : " + bonesburied , 282, 382);
  346.         g.drawString("Exp Gained      : " + expGained, 282, 394);
  347.         g.drawString("Current Level   : " + currLevel, 280, 408);
  348.         g.drawString("Runtime        : " +hours + ":" + minutes + ":" + seconds, 282, 436);
  349.         g.drawString("Time TNL       : " + HTL + ":" + MTL + ":" + STL, 282, 422);
  350.         g.drawImage(Zomzom, 444, 392, null);
  351.         g.setFont(font4);
  352.         g.setColor(color1);
  353.         g.drawString("� Ministry", 446, 448);
  354.         g.drawImage(pBar, 461, 480, null);
  355.         g.setColor(color4);
  356.         g.fillRoundRect(462, 480, percentBar, 22, 10, 10);
  357.  
  358.         g.setFont(font3);
  359.         g.setColor(color5);
  360.         g.drawString( percentTNL + " %", 468, 497);
  361.         g.drawImage(Himg, 496, 345, null);
  362.                 }
  363.                                
  364.         if (showPaint == false) {
  365.         g.drawImage(Simg, 496, 345, null);
  366.               }
  367.               }
  368.         }
  369.  
  370.  
  371. class gui extends JFrame {
  372.     public gui() {
  373.         initComponents();
  374.     }
  375.  
  376.     private void startbuttonActionPerformed(ActionEvent e) {
  377.         String chosen = boneSelected.getSelectedItem().toString();
  378.         if (chosen.equals("Bones")) {
  379.             boneID = bonesID;
  380.         }else
  381.             if (chosen.equals("Big Bones")) {
  382.                 boneID = bigBonesID;
  383.             }else
  384.                 if (chosen.equals("Babydragon Bones")) {
  385.                     boneID = babyDragonID;
  386.                 } else
  387.                     if (chosen.equals("Dragon Bones")) {
  388.                         boneID = dragonBonesID;
  389.                     }
  390.         guiWait = false;
  391.         g.dispose();
  392.     }
  393.  
  394.     private void initComponents() {
  395.         // JFormDesigner - Component initialization - DO NOT MODIFY  //GEN-BEGIN:initComponents
  396.         startbutton = new JButton();
  397.                 boneSelected = new JComboBox();
  398.         label1 = new JLabel();
  399.         label2 = new JLabel();
  400.         comboBox1 = new JComboBox();
  401.  
  402.         //======== this ========
  403.         setResizable(false);
  404.         setTitle("GraveDigger");
  405.         setIconImage(new ImageIcon("C:\\Users\\Ministry\\Desktop\\dragonb.gif").getImage());
  406.         Container contentPane = getContentPane();
  407.  
  408.         //---- boneSelected ----
  409.         boneSelected.setModel(new DefaultComboBoxModel(new String[] {
  410.             "Bones",
  411.             "Big Bones",
  412.             "Babydragon Bones",
  413.             "Dragon Bones"
  414.         }));
  415.  
  416.         //---- label1 ----
  417.         label1.setText("Type of Bones :");
  418.  
  419.         //---- startbutton ----
  420.         startbutton.setText("Start");
  421.         startbutton.addActionListener(new ActionListener() {
  422.             public void actionPerformed(ActionEvent e) {
  423.                 startbuttonActionPerformed(e);
  424.             }
  425.         });
  426.  
  427.                 //---- label2 ----
  428.         label2.setText("Location :");
  429.  
  430.         //---- comboBox1 ----
  431.         comboBox1.setModel(new DefaultComboBoxModel(new String[] {
  432.             "Anywhere",
  433.             "Lumbridge Chickens",
  434.             "Goblin Village"
  435.         }));
  436.         comboBox1.setSelectedIndex(0);
  437.         comboBox1.setToolTipText("Sets an area where your player will remain.");
  438.  
  439.         GroupLayout contentPaneLayout = new GroupLayout(contentPane);
  440.         contentPane.setLayout(contentPaneLayout);
  441.         contentPaneLayout.setHorizontalGroup(
  442.             contentPaneLayout.createParallelGroup()
  443.                 .addGroup(contentPaneLayout.createSequentialGroup()
  444.                     .addContainerGap()
  445.                     .addGroup(contentPaneLayout.createParallelGroup()
  446.                         .addGroup(contentPaneLayout.createSequentialGroup()
  447.                             .addComponent(label1)
  448.                             .addGap(10, 10, 10)
  449.                             .addComponent(boneSelected, 0, 136, Short.MAX_VALUE))
  450.                         .addComponent(startbutton, GroupLayout.DEFAULT_SIZE, 222, Short.MAX_VALUE)
  451.                         .addGroup(contentPaneLayout.createSequentialGroup()
  452.                             .addComponent(label2)
  453.                             .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
  454.                             .addComponent(comboBox1, 0, 182, Short.MAX_VALUE)))
  455.                     .addContainerGap())
  456.         );
  457.         contentPaneLayout.setVerticalGroup(
  458.             contentPaneLayout.createParallelGroup()
  459.                 .addGroup(contentPaneLayout.createSequentialGroup()
  460.                     .addContainerGap()
  461.                     .addGroup(contentPaneLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
  462.                         .addComponent(boneSelected, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
  463.                         .addComponent(label1))
  464.                     .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
  465.                     .addGroup(contentPaneLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
  466.                         .addComponent(label2)
  467.                         .addComponent(comboBox1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
  468.                     .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, 7, Short.MAX_VALUE)
  469.                     .addComponent(startbutton)
  470.                     .addContainerGap())
  471.         );
  472.         setSize(250, 125);
  473.         setLocationRelativeTo(null);
  474.         // JFormDesigner - End of component initialization  //GEN-END:initComponents
  475.     }
  476.  
  477.     // JFormDesigner - Variables declaration - DO NOT MODIFY  //GEN-BEGIN:variables
  478.     private JButton startbutton;
  479.         private JComboBox boneSelected;
  480.     private JLabel label1;
  481.     private JLabel label2;
  482.     private JComboBox comboBox1;
  483.     // JFormDesigner - End of variables declaration  //GEN-END:variables
  484.     }
  485. }
Advertisement
Add Comment
Please, Sign In to add comment