Don't like ads? PRO users don't see any ads ;-)
Guest

sdgsdg

By: a guest on Jul 11th, 2012  |  syntax: None  |  size: 7.65 KB  |  hits: 23  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. import interfaces.Painter;
  2.  
  3. import java.awt.Color;
  4. import java.awt.Font;
  5. import java.awt.FontMetrics;
  6. import java.awt.Graphics;
  7. import java.awt.Graphics2D;
  8. import java.awt.Paint;
  9. import java.awt.Point;
  10. import java.awt.RadialGradientPaint;
  11. import java.awt.Rectangle;
  12.  
  13. import com.parabot.methods.GroundItems;
  14. import com.parabot.methods.Inventory;
  15. import com.parabot.methods.NPCs;
  16. import com.parabot.methods.Players;
  17. import com.parabot.methods.Walking;
  18. import com.parabot.scripts.BasicLoop;
  19. import com.parabot.scripts.Script;
  20. import com.parabot.scripts.ScriptFormat;
  21. import com.parabot.utils.Timer;
  22. import com.parabot.utils.Utils;
  23. import com.parabot.wrappers.GroundItem;
  24. import com.parabot.wrappers.NPC;
  25. import com.parabot.wrappers.RSItem;
  26.  
  27.  
  28. @ScriptFormat(author = "D R O", category = "Combat", description = "Cow killer and buries bones.", name = "CowKillerNR", version = 0.01)
  29. public class CowKillerNR extends Script implements BasicLoop, Painter {
  30. /**
  31.  * Variables
  32.  */
  33.         private static final int COW = 5852;
  34.          public int[] bones = { 526 };
  35.         /**
  36.          * Time
  37.          */
  38.          long millis2;
  39.             long seconds2;
  40.             long startTime2;
  41.             long startTime;
  42.          // Paint
  43.         final Font comicPlain10 = new Font("Comic Sans MS", Font.PLAIN, 22);
  44.         final Color black = new Color(0, 0, 0);
  45.         private final Timer RUNTIME = new Timer();
  46.         private FontMetrics FONTMETRICS = null;
  47.         private String STATE = "";
  48. @Override
  49. public boolean onExecute() {
  50. return true;
  51. }
  52.  
  53. @Override
  54. public void paint(Graphics g) {
  55.         if (FONTMETRICS == null) {
  56.                 FONTMETRICS = g.getFontMetrics();
  57.                 RUNTIME.start();
  58.         }
  59.         drawGradientText(g, "Runtime: " + RUNTIME.getElapsedTime(), 15, 200, Color.red);
  60.         drawGradientText(g, "Cow Killer V1", 15, 218, Color.red);
  61.         drawGradientText(g, "State: " + STATE, 15, 218, Color.red);                
  62. }
  63. public void drawGradientText(Graphics g, String text, int x, int y, Color c) {
  64.     Graphics2D g2 = (Graphics2D) g;
  65.     Color color3 = new Color(51, 51, 51, 205);
  66.     Font font1 = new Font("Arial", 0, 12);
  67.     g.setFont(font1);
  68.     FONTMETRICS = g.getFontMetrics();
  69.     Rectangle textBox = new Rectangle(x, y - g.getFont().getSize(),
  70.                     (int) FONTMETRICS.getStringBounds(text, g).getWidth() + 8,
  71.                     (int) FONTMETRICS.getStringBounds(text, g).getHeight() + 5);
  72.     Paint defaultPaint = g2.getPaint();
  73.     g2.setPaint(new RadialGradientPaint(new Point.Double(textBox.x
  74.                     + textBox.width / 2.0D, textBox.y + textBox.height / 2.0D),
  75.                     (float) (textBox.getWidth() / 2.0D),
  76.                     new float[] { 0.5F, 1.0F }, new Color[] {
  77.                                     new Color(color3.getRed(), color3.getGreen(), color3
  78.                                                     .getBlue(), 175),
  79.                                     new Color(0.0F, 0.0F, 0.0F, 0.8F) }));
  80.     g.fillRect(textBox.x, textBox.y + 12, textBox.width, textBox.height);
  81.     g2.setPaint(defaultPaint);
  82.     g.setColor(Color.BLACK);
  83.     g.drawRect(textBox.x, textBox.y + 12, textBox.width, textBox.height);
  84.     g.setColor(c);
  85.     g.drawString(text, x + 4, y + 15);
  86.     for (int i = 0; i < text.length(); i++) {
  87.             if (Character.isDigit(text.charAt(i))) {
  88.                     g.setColor(new Color(255, 255, 255));
  89.                     g.drawString("" + text.charAt(i),
  90.                                     x + FONTMETRICS.stringWidth(text.substring(0, i)) + 4,
  91.                                     y + 15);
  92.             }
  93.     }
  94. }
  95. /**
  96.  * Voids and Ints
  97.  */
  98.  
  99.  
  100.                 private int attackCow() {  //attacks the cow
  101.                                 NPC cow = getNear(COW);
  102.                                         if(cow != null) {
  103.                                                 if(!Players.getMyPlayer().isInCombat()) {
  104.                                                         if(cow.isOnScreen()) {
  105.                                                                 cow.interact("Attack");
  106.                                                                 Utils.sleep(2000);
  107.                                                         } else {
  108.                                                                 Walking.walkMM(cow.getLocation());
  109.                                                         }
  110.                                                 }
  111.         }
  112.         return 0;
  113. }
  114.                
  115.                
  116.                  /*
  117.                   * Finds the ground item to pickup
  118.                   */
  119.                  public GroundItem check(int[] ID, int Dist) {
  120.                          
  121.              GroundItem[] g = GroundItems.getGroundItems(Dist);
  122.  
  123.              if (g != null) {
  124.                      for (GroundItem item : g) {
  125.                              for (int ID2 : ID) {
  126.                                      if (item.getID() == ID2) {
  127.                                              if (item.isOnScreen()) {
  128.                                                      return item;
  129.                                              }
  130.                                      }
  131.                              }
  132.                      }
  133.              }
  134.  
  135.              return null;
  136.      }
  137.  
  138.      
  139.                  public void lootStuff(int[] ID, int Dist) {
  140.              GroundItem i = check(ID, Dist);
  141.              if (i != null) {
  142.                      i.interact("Take " + i.getDef().getName(), Dist);
  143.                      Utils.sleep(2000);
  144.              }
  145.      }
  146.       /*
  147.        * End of picking up/ looting items
  148.        */
  149.      
  150.      
  151.       /**
  152.        * This will drop the unwanted items
  153.        */
  154.         private int dropMeat() {
  155.                         RSItem j = contains(2133);
  156.                                 if(j != null) {
  157.                                 j.interact("Drop");
  158.                                 STATE = "Dropping meat";
  159.                         }
  160.         return 1000;
  161. }
  162.         private int dropHide() {
  163.                         RSItem j = contains(1740);
  164.                                 if(j != null) {
  165.                             j.interact("Drop");
  166.                           STATE = "Dropping hides";
  167.                    }
  168.         return 1000;
  169. }
  170.         /**
  171.          * Bury bones
  172.          */
  173.         private int buryBones() {
  174.             for (RSItem item : Inventory.getItems()) {
  175.                     if (item != null)
  176.                             if (item.getId() == 527) {
  177.                                     item.interact("Bury");
  178.                                     STATE = "Burying bones";
  179.                                     break;
  180.                             }
  181.             }
  182.             return 3000;
  183.  
  184.     }
  185.      
  186.        
  187. /**
  188.  * Other useful methods
  189.  */
  190.         public RSItem contains(int ID) {
  191.                         RSItem[] i = Inventory.getItems();
  192.                         for(RSItem item : i) {
  193.                                 if(item.getId() == ID) {
  194.                             return item;
  195.             }
  196.     }
  197.     return null;
  198. }
  199.                 public static NPC getNear(int... ids) { // checks if npc is in combat or not.
  200.                                         NPC[] npcs = NPCs.getNPCs();
  201.                                         NPC curr = null;
  202.                                         for (NPC npc : npcs) {
  203.                                                 for (int id : ids) {
  204.                                                         if(npc != null) {
  205.                             if (npc.getDef().getID() == id & !npc.isInCombat()) {
  206.                                     curr = npc;
  207.                             }
  208.                     }
  209.             }
  210.     }
  211.  
  212. return curr;
  213. }
  214.                
  215.                
  216.                
  217.                 /**
  218.                  *
  219.                  * Loop
  220.                  */
  221.                 @Override
  222.                  public int loop() {
  223.                 GroundItem i = check(bones, 10);
  224.                  if (i != null) {
  225.                 Utils.sleep(1000);
  226.                 buryBones();
  227.                  }
  228.                  if (i != null) {
  229.                 dropHide();
  230.                 Utils.sleep(1500);
  231.                 dropMeat();
  232.                 Utils.sleep(1500);
  233.              }
  234.                  
  235.                 if (i != null) {
  236.                         lootStuff(bones, 10);
  237.                         Utils.sleep(1000);
  238.                         STATE = "Looting";
  239.                        
  240.                 } else {
  241.                         if (Players.getMyPlayer().isInCombat()) {
  242.                                 Utils.sleep(200);
  243.                         } else {
  244.                                 attackCow();
  245.                                 Utils.sleep(2000);
  246.                                 STATE = "Attacking";
  247.                         }
  248.                        
  249.                 }
  250.                 return 1000;
  251.         }
  252.                        
  253. }