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

Untitled

By: a guest on Jul 15th, 2012  |  syntax: None  |  size: 10.19 KB  |  hits: 12  |  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 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.Image;
  7. import java.io.IOException;
  8. import java.net.URL;
  9. import javax.imageio.ImageIO;
  10. import org.rsbot.event.listeners.PaintListener;
  11. import org.rsbot.script.Script;
  12. import org.rsbot.script.ScriptManifest;
  13. import org.rsbot.script.methods.Skills;
  14. import org.rsbot.script.util.Filter;
  15. import org.rsbot.script.wrappers.RSItem;
  16. import org.rsbot.script.wrappers.RSNPC;
  17. import org.rsbot.script.wrappers.RSObject;
  18. import org.rsbot.script.wrappers.RSTile;
  19.  
  20.  
  21. @ScriptManifest(authors={"Arbeer"}, keywords={"Barb", "killer", "Barbkiller"}, name="ArbeersBarbKiller", description="Kills Barb anywhere", version=1.0)
  22. public class ArbeersBarbKiller extends Script implements PaintListener {
  23.  
  24.         private static final String bankBooth = null;
  25.                 public final int ITEM_ID = 1229;
  26.         public final int[] foodID = { 1895, 1893, 1891, 4293, 2142, 291, 2140, 3228, 9980,
  27.                         7223, 6297, 6293, 6295, 6299, 7521, 9988, 7228, 2878, 7568, 2343,
  28.                         1861, 13433, 315, 325, 319, 3144, 347, 355, 333, 339, 351, 329,
  29.                         3381, 361, 10136, 5003, 379, 365, 373, 7946, 385, 397, 391, 3369,
  30.                         3371, 3373, 2309, 2325, 2333, 2327, 2331, 2323, 2335, 7178, 7180,
  31.                         7188, 7190, 7198, 7200, 7208, 7210, 7218, 7220, 2003, 2011, 2289,
  32.                         2291, 2293, 2295, 2297, 2299, 2301, 2303, 1891, 1893, 1895, 1897,
  33.                         1899, 1901, 7072, 7062, 7078, 7064, 7084, 7082, 7066, 7068, 1942,
  34.                         6701, 6703, 7054, 6705, 7056, 7060, 2130, 1985, 1993, 1989, 1978,
  35.                         5763, 5765, 1913, 5747, 1905, 5739, 1909, 5743, 1907, 1911, 5745,
  36.                         2955, 5749, 5751, 5753, 5755, 5757, 5759, 5761, 2084, 2034, 2048,
  37.                         2036, 2217, 2213, 2205, 2209, 2054, 2040, 2080, 2277, 2225, 2255,
  38.                         2221, 2253, 2219, 2281, 2227, 2223, 2191, 2233, 2092, 2032, 2074,
  39.                         2030, 2281, 2235, 2064, 2028, 2187, 2185, 2229, 6883, 1971, 4608,
  40.                         1883, 1885, 15272 };
  41.  
  42.         RSTile[] pathToBank = { new RSTile(3078, 3078), new RSTile(3084, 3084),
  43.                                 new RSTile(3090, 3090), new RSTile(3090, 3090),
  44.                                 new RSTile(3087, 3087), new RSTile(3098, 3098),
  45.                                 new RSTile(3099, 3099), new RSTile(3091, 3091) };
  46.        
  47.             public int startExp;
  48.             public int startLevel;
  49.             public int gainedExp;
  50.             public int gainedLevels;
  51.             public int kills;
  52.         public long startTime = 0;
  53.         public long last = 0;
  54.                 private Object pathTomonster;
  55.  
  56.         public boolean onStart() {
  57.                 setPathTomonster(walking.newTilePath(pathToBank));
  58.                 if(!game.isLoggedIn())
  59.                 {
  60.                         log("Please login before starting script.");
  61.                         return false;
  62.                 }
  63.                 startTime = System.currentTimeMillis();
  64.                 startExp = skills.getCurrentExp(Skills.STRENGTH);
  65.                 startLevel = skills.getCurrentLevel(Skills.STRENGTH);
  66.                 log("Welcome To ArbeersBarbKiller");
  67.                 return true;
  68.         }
  69.            
  70.         public void attack(){
  71.                 RSNPC npc = npcs.getNearest(new Filter<RSNPC>() {
  72.                         public boolean accept(RSNPC t) {
  73.                                 return (t.getName().equals("Barbarian") || t.getName().equals("Haakon the Champion")) && !t.isInCombat() && t.getHPPercent() > 0 && t.getInteracting() == null;                        
  74.                                 }
  75.                 });
  76.  
  77.                 if (getMyPlayer().getInteracting() == null){//om vi inte fightas..
  78.                         if (npc != null){
  79.                                 if (npc.isOnScreen()){
  80.                                         npc.doAction("Attack");
  81.                                         sleep(500,900);
  82.                                         if(random(1, 15) == 4) antiban();
  83.                                 }else if (!getMyPlayer().isMoving()){
  84.                                         walking.walkTileMM(npc.getLocation());
  85.                                         sleep(500,900);
  86.                                 }
  87.                         }
  88.                 }else if (getMyPlayer().getInteracting() instanceof RSNPC){
  89.  
  90.                         while (getMyPlayer().getInteracting() instanceof RSNPC) {
  91.                                
  92.                         }
  93.                         kills++;
  94.  
  95.  
  96.  
  97.                 }
  98.         }
  99.  
  100.     @SuppressWarnings("unused")
  101.         private boolean walkPath1(final RSTile[] path) {
  102.         if (calc.distanceTo(path[path.length - 1]) > 4) {
  103.             RSTile n = getNext1(path);
  104.             if(n!=null){
  105.                 walking.walkTileMM(n.randomize(2, 2));
  106.                 if(random(1,6) != 2){
  107.                     mouse.moveRandomly(20);
  108.                 }
  109.             }
  110.         }
  111.         return false;
  112.     }
  113.  
  114.     private RSTile getNext1(RSTile[] path) {
  115.         boolean found = false;
  116.         for (int a = 0; a < path.length&&!found; a++) {
  117.             if(calc.tileOnMap(path[path.length-1-a])){
  118.                 found = true;
  119.                 return path[path.length-1-a];
  120.             }
  121.         }
  122.         return null;
  123.     }
  124.    
  125.     private boolean walkPath(RSTile[] path, boolean reverse) {
  126.         if (reverse) {
  127.             for (int i = 0; i < path.length; i++) {
  128.                 path[i] = path[path.length - i - 1];
  129.             }
  130.         }
  131.         if (calc.distanceTo(path[path.length - 1]) > 4) {
  132.             RSTile n = getNext1(path);
  133.             if (n != null) {
  134.                 walking.walkTileMM(n.randomize(2, 2));
  135.                 if (random(1, 6) != 2) {
  136.                     mouse.moveRandomly(20);
  137.                 }
  138.             }
  139.         }
  140.         return false;
  141.     }
  142.    
  143.    
  144.    
  145.     private boolean walkPath(RSTile path[]){
  146.         return walkPath(path,false);
  147.     }
  148.  
  149.     private RSTile getNext(RSTile[] path) {
  150.         boolean found = false;
  151.         for (int a = 0; a < path.length && !found; a++) {
  152.             if (calc.tileOnMap(path[path.length - 1 - a])) {
  153.                 found = true;
  154.                 return path[path.length - 1 - a];
  155.             }
  156.         }
  157.         return null;
  158.     }
  159.        
  160.         public int loop() {
  161.                 if(inventory.isFull()){
  162.             if(bankBooth == null){
  163.                 walkPath(pathToBank);
  164.             }
  165.        
  166.                
  167.         } else {
  168.         if (combat.getLifePoints() <= 300 & inventory.containsOneOf(foodID)) {
  169.             inventory.getItem(foodID).doAction("Eat");
  170.         }
  171.                 RSItem item = inventory.getItem(1329);
  172.              if (inventory.getItem(1329) != null){
  173.                 item.doAction("Wield");
  174.              sleep(900, 1500);
  175.         }
  176.                 attack();
  177.         }
  178.        
  179.     }
  180.         return random(100,300);
  181.     }
  182.  
  183.         private String Time(final long time) {
  184.                 final int sec = (int) (time / 1000), h = sec / 3600, m = sec / 60 % 60, s = sec % 60;
  185.                 return (h < 10 ? "0" + h : h) + ":" + (m < 10 ? "0" + m : m) + ":"
  186.                 + (s < 10 ? "0" + s : s);
  187.         }
  188.         //START: Code geneBarbed using Enfilade's Easel
  189.         private Image getImage(String url) {
  190.         try {
  191.             return ImageIO.read(new URL(url));
  192.         } catch(IOException e) {
  193.             return null;
  194.         }
  195.     }
  196.  
  197.        
  198.         private final Color color1 = new Color(102, 0, 0, 158);
  199.         private final Color color2 = new Color(0, 0, 0);
  200.  
  201.         private final BasicStroke stroke1 = new BasicStroke(1);
  202.  
  203.         private final Font font1 = new Font("Arial", 0, 20);
  204.         private final Font font2 = new Font("Arial", 0, 15);
  205.         private final Image img1 = getImage("http://images2.wikia.nocookie.net/__cb20101004040634/runescape/images/5/58/Raw_meat.png");
  206.        
  207.         public void onRepaint(Graphics g1) {
  208.                 long runningmillis = System.currentTimeMillis() - startTime;
  209.                 long millis = runningmillis;
  210.                 //Här räknar vi ut exp/timme
  211.                
  212.                 long hours = millis / (1000 * 60 * 60);
  213.                 millis -= hours * (1000 * 60 * 60);
  214.                 long minutes = millis / (1000 * 60);
  215.                 millis -= minutes * (1000 * 60);
  216.                 long seconds = millis / 1000;
  217.                 float xpsec = 0;
  218.                 if ((minutes > 0 || hours > 0 || seconds > 0) && gainedExp > 0) {
  219.                         xpsec = ((float) gainedExp)/ (float) (seconds + (minutes * 60) + (hours * 60 * 60));
  220.                 }
  221.                 final float xpmin = xpsec * 60;
  222.                 final float xphour = xpmin * 60;
  223.  
  224.                 gainedExp = skills.getCurrentExp(Skills.STRENGTH) - startExp;
  225.                 gainedLevels = skills.getCurrentLevel(Skills.STRENGTH) - startLevel;
  226.  
  227.         Graphics2D g = (Graphics2D)g1;
  228.         g.setColor(color1);
  229.         g.fillRect(12, 348, 484, 108);
  230.         g.setFont(font1);
  231.         g.setColor(color2);
  232.         g.drawString("ArbeersBarbKiller", 15, 366);
  233.         g.setFont(font2);
  234.         g.drawString("Time running: "+Time(runningmillis), 20, 383);
  235.         g.drawString("XP/H: "+(int) xphour, 23, 404);
  236.         g.drawString("Levels gained: "+gainedLevels, 23, 423);
  237.         g.drawString("Barbs killed:" + kills, 22, 443);
  238.         g.drawString("Xp gained: "+gainedExp, 193, 382);
  239.        
  240.     }
  241.     //END: Code geneBarbed using Enfilade's Easel
  242.  
  243.         public void setWalkingPath(RSTile[] walkingPath) {
  244.                 this.pathToBank = walkingPath;
  245.         }
  246.  
  247.         public RSTile[] getWalkingPath() {
  248.                 return pathToBank;
  249.         }
  250.  
  251.         public void setPathTomonster(Object pathTomonster) {
  252.                 this.pathTomonster = pathTomonster;
  253.         }
  254.  
  255.         public Object getPathTomonster() {
  256.                 return pathTomonster;
  257.         }
  258.        
  259.          public void antiban() {
  260.              
  261.                         int b = random(0, 10);
  262.                              switch (b) {
  263.                              case 1:
  264.                                  if (random(0, 10) == 5) {
  265.                                      log("[Antiban] move mouse");
  266.                                      mouse.moveSlightly();
  267.                                      sleep(200, 600);
  268.                                      mouse.moveRandomly(150, 350);
  269.                                  }
  270.                                  break;
  271.                              case 2:
  272.                                  if (random(0, 13) == 2) {
  273.                                      log("[Antiban] Turning screen");
  274.                                      camera.setAngle(random(30, 70));
  275.                                      sleep(400, 1200);                
  276.                                    
  277.                                  }            
  278.                                  break;
  279.                              case 3:
  280.                                  if (random(0, 24) == 6) {
  281.                                      log("[Antiban] mouse off screen");
  282.                                      mouse.moveOffScreen();
  283.                                      sleep(random(600, random(1200, 2000)));
  284.                                  }
  285.                                  break;
  286.                              case 4:
  287.                                  if (random(0, 18) == 3) {
  288.                                      log("[antiban] Checking Exp.");
  289.                                      game.openTab(1);
  290.                                      skills.doHover(skills.INTERFACE_STRENGTH);                
  291.                                      sleep(random(2100, 3400));
  292.                                  }
  293.                                  break;
  294.                            default:
  295.                                  break;
  296.                              }
  297.                          }
  298.                          
  299.                          private void doBank() {
  300.         if (bank.isOpen()) {
  301.             bank.depositAllExcept(ITEM_ID);
  302.             sleep(800, 1200);
  303.         } else {
  304.             bank.open();
  305.             sleep(1800, 2200);
  306.         }
  307.     }
  308.  
  309.     private boolean atBank() {
  310.         Filter<RSObject> boothID = null;
  311.                 RSObject bank = objects.getNearest(boothID);
  312.         if (bank != null) {
  313.             if (bank.isOnScreen()) {
  314.                 return true;
  315.             }
  316.         }
  317.         return false;
  318.     }
  319.                          
  320. }