- import java.awt.BasicStroke;
- import java.awt.Color;
- import java.awt.Font;
- import java.awt.Graphics;
- import java.awt.Graphics2D;
- import java.awt.Image;
- import java.io.IOException;
- import java.net.URL;
- import javax.imageio.ImageIO;
- import org.rsbot.event.listeners.PaintListener;
- import org.rsbot.script.Script;
- import org.rsbot.script.ScriptManifest;
- import org.rsbot.script.methods.Skills;
- import org.rsbot.script.util.Filter;
- import org.rsbot.script.wrappers.RSItem;
- import org.rsbot.script.wrappers.RSNPC;
- import org.rsbot.script.wrappers.RSObject;
- import org.rsbot.script.wrappers.RSTile;
- @ScriptManifest(authors={"Arbeer"}, keywords={"Barb", "killer", "Barbkiller"}, name="ArbeersBarbKiller", description="Kills Barb anywhere", version=1.0)
- public class ArbeersBarbKiller extends Script implements PaintListener {
- private static final String bankBooth = null;
- public final int ITEM_ID = 1229;
- public final int[] foodID = { 1895, 1893, 1891, 4293, 2142, 291, 2140, 3228, 9980,
- 7223, 6297, 6293, 6295, 6299, 7521, 9988, 7228, 2878, 7568, 2343,
- 1861, 13433, 315, 325, 319, 3144, 347, 355, 333, 339, 351, 329,
- 3381, 361, 10136, 5003, 379, 365, 373, 7946, 385, 397, 391, 3369,
- 3371, 3373, 2309, 2325, 2333, 2327, 2331, 2323, 2335, 7178, 7180,
- 7188, 7190, 7198, 7200, 7208, 7210, 7218, 7220, 2003, 2011, 2289,
- 2291, 2293, 2295, 2297, 2299, 2301, 2303, 1891, 1893, 1895, 1897,
- 1899, 1901, 7072, 7062, 7078, 7064, 7084, 7082, 7066, 7068, 1942,
- 6701, 6703, 7054, 6705, 7056, 7060, 2130, 1985, 1993, 1989, 1978,
- 5763, 5765, 1913, 5747, 1905, 5739, 1909, 5743, 1907, 1911, 5745,
- 2955, 5749, 5751, 5753, 5755, 5757, 5759, 5761, 2084, 2034, 2048,
- 2036, 2217, 2213, 2205, 2209, 2054, 2040, 2080, 2277, 2225, 2255,
- 2221, 2253, 2219, 2281, 2227, 2223, 2191, 2233, 2092, 2032, 2074,
- 2030, 2281, 2235, 2064, 2028, 2187, 2185, 2229, 6883, 1971, 4608,
- 1883, 1885, 15272 };
- RSTile[] pathToBank = { new RSTile(3078, 3078), new RSTile(3084, 3084),
- new RSTile(3090, 3090), new RSTile(3090, 3090),
- new RSTile(3087, 3087), new RSTile(3098, 3098),
- new RSTile(3099, 3099), new RSTile(3091, 3091) };
- public int startExp;
- public int startLevel;
- public int gainedExp;
- public int gainedLevels;
- public int kills;
- public long startTime = 0;
- public long last = 0;
- private Object pathTomonster;
- public boolean onStart() {
- setPathTomonster(walking.newTilePath(pathToBank));
- if(!game.isLoggedIn())
- {
- log("Please login before starting script.");
- return false;
- }
- startTime = System.currentTimeMillis();
- startExp = skills.getCurrentExp(Skills.STRENGTH);
- startLevel = skills.getCurrentLevel(Skills.STRENGTH);
- log("Welcome To ArbeersBarbKiller");
- return true;
- }
- public void attack(){
- RSNPC npc = npcs.getNearest(new Filter<RSNPC>() {
- public boolean accept(RSNPC t) {
- return (t.getName().equals("Barbarian") || t.getName().equals("Haakon the Champion")) && !t.isInCombat() && t.getHPPercent() > 0 && t.getInteracting() == null;
- }
- });
- if (getMyPlayer().getInteracting() == null){//om vi inte fightas..
- if (npc != null){
- if (npc.isOnScreen()){
- npc.doAction("Attack");
- sleep(500,900);
- if(random(1, 15) == 4) antiban();
- }else if (!getMyPlayer().isMoving()){
- walking.walkTileMM(npc.getLocation());
- sleep(500,900);
- }
- }
- }else if (getMyPlayer().getInteracting() instanceof RSNPC){
- while (getMyPlayer().getInteracting() instanceof RSNPC) {
- }
- kills++;
- }
- }
- @SuppressWarnings("unused")
- private boolean walkPath1(final RSTile[] path) {
- if (calc.distanceTo(path[path.length - 1]) > 4) {
- RSTile n = getNext1(path);
- if(n!=null){
- walking.walkTileMM(n.randomize(2, 2));
- if(random(1,6) != 2){
- mouse.moveRandomly(20);
- }
- }
- }
- return false;
- }
- private RSTile getNext1(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, 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 = getNext1(path);
- if (n != null) {
- walking.walkTileMM(n.randomize(2, 2));
- if (random(1, 6) != 2) {
- mouse.moveRandomly(20);
- }
- }
- }
- return false;
- }
- private boolean walkPath(RSTile path[]){
- return walkPath(path,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;
- }
- public int loop() {
- if(inventory.isFull()){
- if(bankBooth == null){
- walkPath(pathToBank);
- }
- } else {
- if (combat.getLifePoints() <= 300 & inventory.containsOneOf(foodID)) {
- inventory.getItem(foodID).doAction("Eat");
- }
- RSItem item = inventory.getItem(1329);
- if (inventory.getItem(1329) != null){
- item.doAction("Wield");
- sleep(900, 1500);
- }
- attack();
- }
- }
- return random(100,300);
- }
- private String Time(final long time) {
- final int sec = (int) (time / 1000), h = sec / 3600, m = sec / 60 % 60, s = sec % 60;
- return (h < 10 ? "0" + h : h) + ":" + (m < 10 ? "0" + m : m) + ":"
- + (s < 10 ? "0" + s : s);
- }
- //START: Code geneBarbed using Enfilade's Easel
- private Image getImage(String url) {
- try {
- return ImageIO.read(new URL(url));
- } catch(IOException e) {
- return null;
- }
- }
- private final Color color1 = new Color(102, 0, 0, 158);
- private final Color color2 = new Color(0, 0, 0);
- private final BasicStroke stroke1 = new BasicStroke(1);
- private final Font font1 = new Font("Arial", 0, 20);
- private final Font font2 = new Font("Arial", 0, 15);
- private final Image img1 = getImage("http://images2.wikia.nocookie.net/__cb20101004040634/runescape/images/5/58/Raw_meat.png");
- public void onRepaint(Graphics g1) {
- long runningmillis = System.currentTimeMillis() - startTime;
- long millis = runningmillis;
- //Här räknar vi ut exp/timme
- long hours = millis / (1000 * 60 * 60);
- millis -= hours * (1000 * 60 * 60);
- long minutes = millis / (1000 * 60);
- millis -= minutes * (1000 * 60);
- long seconds = millis / 1000;
- float xpsec = 0;
- if ((minutes > 0 || hours > 0 || seconds > 0) && gainedExp > 0) {
- xpsec = ((float) gainedExp)/ (float) (seconds + (minutes * 60) + (hours * 60 * 60));
- }
- final float xpmin = xpsec * 60;
- final float xphour = xpmin * 60;
- gainedExp = skills.getCurrentExp(Skills.STRENGTH) - startExp;
- gainedLevels = skills.getCurrentLevel(Skills.STRENGTH) - startLevel;
- Graphics2D g = (Graphics2D)g1;
- g.setColor(color1);
- g.fillRect(12, 348, 484, 108);
- g.setFont(font1);
- g.setColor(color2);
- g.drawString("ArbeersBarbKiller", 15, 366);
- g.setFont(font2);
- g.drawString("Time running: "+Time(runningmillis), 20, 383);
- g.drawString("XP/H: "+(int) xphour, 23, 404);
- g.drawString("Levels gained: "+gainedLevels, 23, 423);
- g.drawString("Barbs killed:" + kills, 22, 443);
- g.drawString("Xp gained: "+gainedExp, 193, 382);
- }
- //END: Code geneBarbed using Enfilade's Easel
- public void setWalkingPath(RSTile[] walkingPath) {
- this.pathToBank = walkingPath;
- }
- public RSTile[] getWalkingPath() {
- return pathToBank;
- }
- public void setPathTomonster(Object pathTomonster) {
- this.pathTomonster = pathTomonster;
- }
- public Object getPathTomonster() {
- return pathTomonster;
- }
- public void antiban() {
- int b = random(0, 10);
- switch (b) {
- case 1:
- if (random(0, 10) == 5) {
- log("[Antiban] move mouse");
- mouse.moveSlightly();
- sleep(200, 600);
- mouse.moveRandomly(150, 350);
- }
- break;
- case 2:
- if (random(0, 13) == 2) {
- log("[Antiban] Turning screen");
- camera.setAngle(random(30, 70));
- sleep(400, 1200);
- }
- break;
- case 3:
- if (random(0, 24) == 6) {
- log("[Antiban] mouse off screen");
- mouse.moveOffScreen();
- sleep(random(600, random(1200, 2000)));
- }
- break;
- case 4:
- if (random(0, 18) == 3) {
- log("[antiban] Checking Exp.");
- game.openTab(1);
- skills.doHover(skills.INTERFACE_STRENGTH);
- sleep(random(2100, 3400));
- }
- break;
- default:
- break;
- }
- }
- private void doBank() {
- if (bank.isOpen()) {
- bank.depositAllExcept(ITEM_ID);
- sleep(800, 1200);
- } else {
- bank.open();
- sleep(1800, 2200);
- }
- }
- private boolean atBank() {
- Filter<RSObject> boothID = null;
- RSObject bank = objects.getNearest(boothID);
- if (bank != null) {
- if (bank.isOnScreen()) {
- return true;
- }
- }
- return false;
- }
- }