rendered paste bodyimport org.rsbot.event.listeners.PaintListener;
import org.rsbot.script.Script;
import org.rsbot.script.ScriptManifest;
import org.rsbot.script.methods.Equipment;
import org.rsbot.script.methods.Game;
import org.rsbot.script.util.Filter;
import org.rsbot.script.wrappers.*;
import javax.swing.*;
import javax.swing.border.EmptyBorder;
import javax.swing.border.LineBorder;
import javax.swing.border.TitledBorder;
import javax.swing.table.DefaultTableModel;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import java.util.LinkedList;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.lang.reflect.Method;
import java.net.URL;
import java.net.URLConnection;
import org.rsbot.script.wrappers.RSNPC;
import org.rsbot.script.wrappers.RSObject;
import org.rsbot.script.wrappers.RSTile;
@ScriptManifest(authors = {"Fixed by Louisc999"}, keywords = {"Minigames", "Combat"}, name = "BPestControl", version = 1.65, description = "Select options in the GUI.")
public class BPestControl extends Script implements PaintListener {
ScriptManifest sm = getClass().getAnnotation(ScriptManifest.class);
double version = sm.version();
class AnimationChecker implements Runnable {
public void run() {
while (isActive()) {
if (getMyPlayer().getAnimation() != -1) {
lastAniChange = System.currentTimeMillis();
}
try {
Thread.sleep(500);
} catch (Exception ignored) {
}
}
}
}
private class Job {
private final String n;
private boolean done = false;
public int points;
public Job(final String name, int points) {
n = name;
this.points = points;
}
public final String getName() {
return n;
}
public boolean isFinished() {
return done;
}
public String toString() {
return "Name " + getName();
}
}
private class Portal {
private final RSTile Location;
private final String Name;
private final RSTile gateLoc;
public Portal(final RSTile t, final String name, final RSTile g) {
Location = t;
Name = name;
gateLoc = g;
}
public boolean equals(final Portal p) {
return p.getLocation().getX() == getLocation().getX()
&& p.getLocation().getY() == getLocation().getY();
}
public RSArea getArea() {
RSArea a = null;
if (getName().equals("E")) {
a = new RSArea(voidLoc.getX() + 24, voidLoc.getY() - 20, voidLoc.getX() + 27, voidLoc.getY() - 15);
} else if (getName().equals("W")) {
a = new RSArea(voidLoc.getX() - 25, voidLoc.getY() - 15, voidLoc.getX() - 21, voidLoc.getY() - 12);
} else if (getName().contains("SE")) {
a = new RSArea(voidLoc.getX() + 16, voidLoc.getY() - 34, voidLoc.getX() + 20, voidLoc.getY() - 31);
} else if (getName().contains("SW")) {
a = new RSArea(voidLoc.getX() - 8, voidLoc.getY() - 35, voidLoc.getX() - 3, voidLoc.getY() - 32);
}
return a;
}
public RSObject getGate() {
return objects.getTopAt(getGateLocation());
}
public RSTile getGateLocation() {
return gateLoc;
}
public RSTile getLocation() {
return Location;
}
public String getName() {
return Name;
}
public RSNPC getNPC() {
if (!attackPortals) {
return null;
}
final RSNPC portal = npcs.getNearest("Portal");
if (portal != null) {
if (portal.isInCombat()) {
return portal;
} else {
return null;
}
}
return null;
}
public RSTile getRandom() {
final RSTile[][] tiles = getArea().getTiles();
final int y = random(0, tiles.length - 1);
final int x = random(0, tiles[y].length - 1);
try {
return tiles[x][y];
} catch (final Exception e) {
return getRandom();
}
}
public RSArea getRealArea() {
RSArea a = null;
if (getName().equals("E")) {
a = new RSArea(voidLoc.getX() + 16, voidLoc.getY() - 23, voidLoc.getX() + 30, voidLoc.getY() - 9);
} else if (getName().equals("W")) {
a = new RSArea(voidLoc.getX() - 30, voidLoc.getY() - 24, voidLoc.getX() - 14, voidLoc.getY() - 5);
} else if (getName().contains("SE")) {
a = new RSArea(voidLoc.getX(), voidLoc.getY() - 45, voidLoc.getX() + 28, voidLoc.getY() - 24);
} else if (getName().contains("SW")) {
a = new RSArea(voidLoc.getX() - 17, voidLoc.getY() - 44, voidLoc.getX(), voidLoc.getY() - 24);
}
return a;
}
public boolean isGateOpen() {
return getGate() == null || getGate().getID() > 14240;
}
public boolean isOpen() {
try {
if (getName().equals("W")) {
if (Integer.parseInt(interfaces.getComponent(408, 13).getText()) < 10) {
return false;
}
}
if (getName().equals("E")) {
if (Integer.parseInt(interfaces.getComponent(408, 14).getText()) < 10) {
return false;
}
}
if (getName().equals("SE")) {
if (Integer.parseInt(interfaces.getComponent(408, 15).getText()) < 10) {
return false;
}
}
if (getName().equals("SW")) {
if (Integer.parseInt(interfaces.getComponent(408, 16).getText()) < 10) {
return false;
}
}
} catch (final Exception e) {
return false;
}
return true;
}
private void openGate() {
while (inPest() && !isGateOpen()) {
if (getMyPlayer().isMoving()) {
sleep(random(500, 600));
continue;
}
final Point p = calc.tileToScreen(getGateLocation());
if (!calc.pointOnScreen(p)) {
walking.walkTileMM(getGateLocation());
try {
Thread.sleep(random(500, 700));
} catch (InterruptedException ignored) {
}
continue;
}
moveMouse (p, 375, 165);
mouse.clickSlightly();
sleep (random (2500,3000));
doAction(p, "Open");
}
}
public void walkTo() {
final Portal p = getNearestPortal();
boolean died = false;
final RSNPC npc = npcs.getNearest(squire);
if (npc != null) {
if (calc.distanceTo(npc) < 10) {
died = true;
}
}
boolean atDoor = false;
while (inPest() && calc.distanceTo(getLocation()) > 10 && isOpen()) {
if (getMyPlayer().isInCombat()
&& getMyPlayer().getHPPercent() < 2
&& calc.distanceTo(npcs.getNearest(squire)) > 15) {
return;
}
if (died) {
try {
enablePrayer();
Thread.sleep(random(300, 800));
walking.setRun(true);
Thread.sleep(random(300, 800));
doDragonBattleAxe();
Thread.sleep(random(300, 800));
} catch (Exception ignored) {
}
if (!atDoor) {
walkPath(genPath(getGateLocation()));
if (!isGateOpen() && calc.tileOnScreen(getGateLocation())) {
openGate();
if (isGateOpen()) {
atDoor = true;
}
}
if (calc.distanceTo(getGateLocation()) < 10 && isGateOpen()) {
atDoor = true;
}
}
if (atDoor) {
walkPath(genPath(getRandom()));
}
} else if (p.getName().equals("E") && getName().equals("W")) {
while (inPest() && getNearestPortal().getName().equals("E")) {
final Portal se = getPortalByName("SE");
if (!walkPath(genPath(se.getRandom()))) {
wait(400, 700);
}
}
while (inPest()
&& getNearestPortal().getName().equals("SE")) {
final Portal sw = getPortalByName("SW");
if (!walkPath(genPath(sw.getRandom()))) {
wait(400, 700);
}
}
} else if (p.getName().equals("W") && getName().equals("E")) {
while (inPest() && getNearestPortal().getName().equals("W")) {
final Portal sw = getPortalByName("SW");
if (!walkPath(genPath(sw.getRandom()))) {
wait(400, 700);
}
}
while (inPest()
&& getNearestPortal().getName().equals("SW")) {
final Portal se = getPortalByName("SE");
if (!walkPath(genPath(se.getRandom()))) {
wait(400, 700);
}
}
while (!walkPath(genPath(getRandom()))) {
wait(400, 700);
}
} else if (p.getName().equals("E") && getName().equals("SE")) {
if (!walkPath(genPath(getLocation()))) {
wait(400, 700);
}
} else if (p.getName().equals("SE") && getName().equals("E")) {
while (!walkPath(genPath(getLocation()))) {
wait(400, 700);
}
} else if (p.getName().equals("E") && getName().equals("SW")) {
while (inPest() && getNearestPortal().getName().equals("E")) {
final Portal se = getPortalByName("SE");
if (!walkPath(genPath(se.getRandom()))) {
wait(400, 700);
}
}
while (!walkPath(genPath(getRandom()))) {
wait(400, 700);
}
} else if (p.getName().equals("SW") && getName().equals("E")) {
while (inPest()
&& getNearestPortal().getName().equals("SW")) {
final Portal se = getPortalByName("SE");
if (!walkPath(genPath(se.getRandom()))) {
wait(400, 700);
}
}
while (!walkPath(genPath(getRandom()))) {
wait(400, 700);
}
} else if (p.getName().equals("W") && getName().equals("SW")) {
if (!walkPath(genPath(getLocation()))) {
wait(400, 700);
}
} else if (p.getName().equals("SW") && getName().equals("W")) {
if (!walkPath(genPath(getLocation()))) {
wait(400, 700);
}
} else if (p.getName().equals("SE") && getName().equals("W")) {
while (inPest()
&& getNearestPortal().getName().equals("SE")) {
final Portal se = getPortalByName("SW");
if (!walkPath(genPath(se.getRandom()))) {
wait(400, 700);
}
}
while (!walkPath(genPath(getRandom()))) {
wait(400, 700);
}
} else if (p.getName().equals("W") && getName().equals("SE")) {
while (inPest() && getNearestPortal().getName().equals("W")) {
final Portal se = getPortalByName("SW");
if (!walkPath(genPath(se.getRandom()))) {
wait(400, 700);
}
}
while (!walkPath(genPath(getRandom()))) {
wait(400, 700);
}
} else if (p.getName().equals("SW") && getName().equals("SE")) {
if (!walkPath(genPath(getLocation()))) {
wait(400, 700);
}
} else if (p.getName().equals("SE") && getName().equals("SW")) {
if (!walkPath(genPath(getLocation()))) {
wait(400, 700);
}
}
}
}
public void wait(int min, int max) {
try {
Thread.sleep(random(min, max));
} catch (Exception ignored) {
}
}
}
//private static final int INTERFACE_250_PTS = 213;
private final LinkedList<Job> jobQ = new LinkedList<Job>();
private final LinkedList<Portal> portalQ = new LinkedList<Portal>();
private final LinkedList<Break> breakQ = new LinkedList<Break>();
private final ArrayList<String> antibanQ = new ArrayList<String>();
private Portal current;
private boolean start = false;
private boolean attackPortals = false;
private boolean usePray = false;
private boolean played = false;
private boolean got250 = false;
private boolean attackSpinner = false;
private boolean DBaxe = false;
private boolean pickupArrows = false;
private RSTile[] path;
private int plankID = 14315;
private final int squire = 3781;
private int Squire;
private int failsafe = 0;
private int points = 0;
//private int points = 0;
private int specialPercent = 0;
private int spendwhenpoints = 0;
private int arrowID = 0;
private int oldPoints = 0;
private int gainedPoints = 0;
private int AttState = 0;
private int VarAttState = 0;
private int lost = 0;
private int won = 0;
private RSArea boatArea = null;
private RSArea BuyArea = null;
private RSTile voidLoc = null;
private RSTile standingTile = null;
private RSTile standingTile2 = null;
private long lastAniChange = 0;
private long startTime = 0;
private long gc = 0;
public final int ROTATE_COMPASS = 0;
public final int MOVE_MOUSE = 1;
public final int MOVE_MOUSE_AND_ROTATE_COMPASS = 2;
public final int RIGHT_CLICK_OBJECT = 3;
public final int RIGHT_CLICK_NPC = 4;
public final int RIGHT_CLICK_PLAYER = 5;
private final String[] jobsStrings = new String[]{"Attack", "Defence",
"Magic", "Prayer", "Strength", "Ranged", "Hitpoints",
"melee helm", "ranger helm", "mage helm", "top", "robes",
"gloves", "mace", "deflector", //"seal"
};
//"Robe", "Range Helm", "Melee Helm", "Mage Helm", "Glove"};
private final int[] jobsPoints = new int[]{100, 100, 100, 100, 100, 100,
100, 250, 250, 200, 200, 200, 150};
private int width = 0;
private int height = 0;
private Break curBreak;
Pathfinder pf;
Runnable antiban = new Runnable() {
public void run() {
while (isActive()) {
try {
if (!game.isLoggedIn()) {
Thread.sleep(300, 400);
continue;
}
int i = random(0, 150);
if (i == 4 || i == 9)
performAntiban(antibanQ.get(random(0, antibanQ.size())));
Thread.sleep(random(100, 2000));
} catch (InterruptedException ignored) {
}
}
}
};
public void performAntiban(String antiban) throws InterruptedException {
log("Doing : " + antiban.toLowerCase().replace('_', ' '));
int ab = AntibanStringToInteger(antiban);
switch (ab) {
case ROTATE_COMPASS:
char dir = 37;
if (random(0, 3) == 2)
dir = 39;
keyboard.pressKey(dir);
Thread.sleep(random(500, 2000));
keyboard.releaseKey(dir);
break;
case MOVE_MOUSE:
mouse.move(random(0, game.getWidth()), random(0,
game.getHeight()));
break;
case MOVE_MOUSE_AND_ROTATE_COMPASS:
Thread camera = new Thread() {
@Override
public void run() {
char dir = 37;
if (random(0, 3) == 2)
dir = 39;
keyboard.pressKey(dir);
try {
Thread.sleep(random(500, 2000));
} catch (InterruptedException e) {
e.printStackTrace();
}
keyboard.releaseKey(dir);
}
};
Thread mouseThread = new Thread() {
@Override
public void run() {
mouse.move(random(0, game.getWidth()), random(
0, game.getHeight()));
}
};
camera.start();
mouseThread.start();
while (camera.isAlive() || mouseThread.isAlive())
Thread.sleep(random(100, 300));
break;
case RIGHT_CLICK_OBJECT:
RSObject obj = getObjOnScreen();
if (obj != null) {
mouse.click(calc.tileToScreen(obj.getLocation()), false);
Thread.sleep(random(500, 2000));
while (menu.isOpen()) {
mouse.moveRandomly(20);
}
}
break;
case RIGHT_CLICK_NPC:
RSNPC npc = getNPCOnScreen();
if (npc != null) {
mouse.click(npc.getScreenLocation(), false);
Thread.sleep(random(500, 2000));
while (menu.isOpen()) {
mouse.moveRandomly(20);
}
}
break;
case RIGHT_CLICK_PLAYER:
RSPlayer player = getPlayerOnScreen();
if (player != null) {
mouse.click(player.getScreenLocation(), false);
Thread.sleep(random(500, 2000));
while (menu.isOpen()) {
mouse.moveRandomly(20);
}
}
break;
default:
break;
}
}
public RSObject getObjOnScreen() {
ArrayList<RSObject> result = new ArrayList<RSObject>();
for (int x = 0; x < 104; x++) {
for (int y = 0; y < 104; y++) {
RSObject obj = objects.getTopAt(
new RSTile(x + game.getBaseX(), y + game.getBaseY()));
if (obj != null) {
Point p = calc.tileToScreen(obj.getLocation());
if (p.x != -1)
result.add(obj);
}
}
}
if (result.size() == 0)
return null;
return result.get(random(0, result.size()));
}
public RSNPC getNPCOnScreen() {
RSNPC[] screen = npcs.getAll(new Filter<RSNPC>() {
public boolean accept(RSNPC npc) {
return npc.isOnScreen();
}
});
if (screen.length > 0) {
return screen[random(0, screen.length)];
}
return null;
}
public int AntibanStringToInteger(String a) {
if (a.contains("rotate compass"))
return ROTATE_COMPASS;
else if (a.contains("move mouse"))
return MOVE_MOUSE;
else if (a.contains("MOVE_MOUSE_AND_ROTATE_COMPASS"
.replaceAll("_", " ").toLowerCase()))
return MOVE_MOUSE_AND_ROTATE_COMPASS;
else if (a.contains("RIGHT_CLICK_OBJECT".replaceAll("_", " ")
.toLowerCase()))
return RIGHT_CLICK_OBJECT;
else if (a.contains("RIGHT_CLICK_NPC".replaceAll("_", " ")
.toLowerCase()))
return RIGHT_CLICK_NPC;
else if (a.contains("RIGHT_CLICK_PLAYER".replaceAll("_", " ")
.toLowerCase()))
return RIGHT_CLICK_PLAYER;
return -1;
}
boolean atPortal() {
for (final Portal p : portalQ) {
if (p.getRealArea().contains(getMyPlayer().getLocation())) {
return true;
}
}
return false;
}
public Break getCurrentBreak() {
if ((curBreak == null || curBreak.isDone) && breakQ.size() == 0)
return null;
if (curBreak == null || curBreak.isDone)
curBreak = breakQ.remove();
if (curBreak.Time == null)
curBreak.init();
return curBreak;
}
boolean clickNPC(final RSNPC n, final String action) {
if (!calc.tileOnScreen(n.getLocation())) {
while (inPest() && atPortal()
&& !walkPath(genPath(n.getLocation()))) {
sleep(random(200, 500));
}
}
try {
Point p;
while ((p = n.getScreenLocation()) != null && p.x != -1
&& mouse.getLocation().distance(n.getScreenLocation()) > 8) {
moveMouse ( p , 1 , 1);
}
if (!calc.pointOnScreen(mouse.getLocation())) {
return false;
}
if (getTopText().contains(action)) {
mouse.click(true);
} else if (menu.contains(action)) {
mouse.click(false);
return menu.doAction(action);
} else {
return false;
}
} catch (final Exception ignored) {
}
return true;
}
boolean doAction(final Point p, final String action) {
if (p.x == -1 || p.y == -1) {
return false;
}
while (p.x != -1 && mouse.getLocation().distance(p) > 8) {
mouse.move(p);
}
if (!calc.pointOnScreen(mouse.getLocation())) {
return false;
}
if (getTopText().contains(action)) {
mouse.click(true);
} else if (menu.contains(action)) {
mouse.click(false);
return menu.doAction(action);
} else {
return false;
}
return true;
}
public boolean tileOnMap(RSTile tile) {
Point center = calc.tileToMinimap(getMyPlayer().getLocation());
return calc.tileToMinimap(tile).distance(center) <= 70;
}
void enablePrayer() {
if (!PrayerEnabled() && usePray) {
mouse.click(random(715, 752), random(60, 80), true);
}
}
int enterBoat() {
portalQ.clear();
final RSObject o = objects.getNearest(plankID);
if (o != null && !onBoat()) {
//camera.setAngle(random(1, 360));
camera.turnTo(o);
if (interfaces.get(242).isValid() ) {
lost++;
interfaces.get(242).getComponent(6).doClick();
}
if (interfaces.get(243).isValid() ) {
won++;
interfaces.get(243).getComponent(7).doClick();
}
o.doAction("Cross");
sleep(random(1500,2000));
}
return random(600, 800);
}
void fillPortalList() {
if (portalQ.size() < 1) {
portalQ.add(new Portal(new RSTile(voidLoc.getX() - 26, voidLoc
.getY() - 15), "W", new RSTile(voidLoc.getX() - 12, voidLoc
.getY() - 15)));
portalQ.add(new Portal(new RSTile(voidLoc.getX() + 26, voidLoc
.getY() - 18), "E", new RSTile(voidLoc.getX() + 15, voidLoc
.getY() - 15)));
portalQ.add(new Portal(new RSTile(voidLoc.getX() + 15, voidLoc
.getY() - 36), "SE", new RSTile(voidLoc.getX() + 1, voidLoc
.getY() - 22)));
portalQ.add(new Portal(new RSTile(voidLoc.getX() - 9, voidLoc
.getY() - 37), "SW", new RSTile(voidLoc.getX() + 1, voidLoc
.getY() - 22)));
} else {
portalQ.clear();
fillPortalList();
}
}
RSTile[] genPath(final RSTile t) {
RSTile[] temp = pf.findPath(t);
if (temp != null)
return temp;
RSTile current = getMyPlayer().getLocation();
final ArrayList<RSTile> tiles = new ArrayList<RSTile>();
final ArrayList<RSTile> path = new ArrayList<RSTile>();
while (calc.distanceBetween(t, current) > 2) {
final int x = current.getX();
final int y = current.getY();
tiles.add(new RSTile(x, y - 1));
tiles.add(new RSTile(x - 1, y));
tiles.add(new RSTile(x + 1, y));
tiles.add(new RSTile(x, y + 1));
tiles.add(new RSTile(x - 1, y - 1));
tiles.add(new RSTile(x + 1, y - 1));
tiles.add(new RSTile(x + 1, y + 1));
tiles.add(new RSTile(x - 1, y + 1));
final RSTile tile = getNearest(tiles, t);
path.add(tile);
this.path = path.toArray(new RSTile[path.size()]);
current = tile;
tiles.clear();
}
this.path = path.toArray(new RSTile[path.size()]);
return this.path;
}
Portal getCurrentPortal() {
return current;
}
Job getJob() {
if (jobQ.size() == 0)
return null;
return jobQ.getFirst();
}
RSTile getNearest(final ArrayList<RSTile> tiles, final RSTile t) {
RSTile nearest = tiles.get(0);
for (RSTile tile : tiles) {
if (calc.distanceBetween(tile, t) < calc.distanceBetween(
nearest, t)) {
nearest = tile;
}
}
return nearest;
}
Portal getNearestOpenPortal() {
if (portalQ.size() < 1) {
return null;
}
Portal winner = null;
for (final Portal p : portalQ) {
if (p.isOpen()) {
winner = p;
}
}
if (winner == null) {
return null;
}
for (final Portal p : portalQ) {
if (!p.isOpen()) {
continue;
}
if (calc.distanceTo(p.getLocation()) < calc.distanceTo(winner.getLocation())) {
winner = p;
}
}
current = winner;
return winner;
}
Portal getNearestPortal() {
if (portalQ.size() < 1) {
return null;
}
Portal winner = portalQ.get(0);
for (final Portal p : portalQ) {
if (calc.distanceTo(p.getLocation()) < calc.distanceTo(winner.getLocation())) {
winner = p;
}
}
return winner;
}
RSTile getNext(final RSTile[] path) {
RSTile nearest = path[0];
for (final RSTile element : path) {
if (calc.distanceBetween(element, path[path.length - 1]) < calc
.distanceBetween(nearest, path[path.length - 1])) {
if (tileOnMap(element)) {
nearest = element;
}
}
}
return nearest;
}
RSPlayer getPlayerOnScreen() {
RSPlayer[] screen = players.getAll(new Filter<RSPlayer>() {
public boolean accept(RSPlayer p) {
return p.isOnScreen();
}
});
if (screen.length > 0) {
return screen[random(0, screen.length)];
}
return null;
}
Portal getPortalByName(final String name) {
if (portalQ.size() < 1) {
return null;
}
for (final Portal p : portalQ) {
if (p.getName().equalsIgnoreCase(name)) {
return p;
}
}
return null;
}
Portal getRandomOpenPortal() {
if (portalQ.size() < 1) {
return null;
}
final ArrayList<Portal> po = new ArrayList<Portal>();
for (final Portal p : portalQ) {
if (p.isOpen()) {
po.add(p);
}
}
current = po.get(random(0, po.size()));
return current;
}
String getTopText() {
try {
final long start = System.currentTimeMillis();
String[] menuItems = menu.getItems();
if (menuItems.length == 0) {
return "Cancel";
}
while (menuItems[0].contains("Cancel")
&& calc.pointOnScreen(mouse.getLocation())
&& System.currentTimeMillis() - start < 700) {
menuItems = menu.getItems();
}
return menuItems[0];
} catch (Exception e) {
return getTopText();
}
}
boolean inPest() {
return npcs.getNearest(Squire) == null;
}
public void exchange() {
if (getJob().getName().equals("Attack")) {
sleep (random(6000,8000));
sleep(random(5000, 6500));
log ("we're gonna click on 100x");
interfaces.get(1011).getComponent(87).doClick();
sleep(random(4000, 5000));
log ("we clicked 100x, now confirm");
sleep(random(5000, 6500));
interfaces.get(1011).getComponent(382).doClick();
log ("we confirmed");
oldPoints = 0;
played = false;
points = 0;
got250 = false;
interfaces.get(1011).getComponent(51).doClick();
sleep (2000, 3500);
walkPath(genPath(new RSTile (2657, 2639)), 2);
}
if (getJob().getName().equals("Defence")) {
sleep (random(6000,8000));
sleep(random(5000, 6500));
log ("we're gonna click on 100x");
interfaces.get(1011).getComponent(119).doClick();
sleep(random(4000, 5000));
log ("we clicked 100x, now confirm");
sleep(random(5000, 6500));
interfaces.get(1011).getComponent(382).doClick();
log ("we confirmed");
oldPoints = 0;
played = false;
points = 0;
got250 = false;
interfaces.get(1011).getComponent(51).doClick();
sleep (2000, 3500);
walkPath(genPath(new RSTile (2657, 2639)), 2);
}
if (getJob().getName().equals("Magic")) {
sleep (random(6000,8000));
sleep(random(5000, 6500));
log ("we're gonna click on 100x");
interfaces.get(1011).getComponent(167).doClick();
sleep(random(4000, 5000));
log ("we clicked 100x, now confirm");
sleep(random(5000, 6500));
interfaces.get(1011).getComponent(382).doClick();
log ("we confirmed");
oldPoints = 0;
played = false;
points = 0;
got250 = false;
interfaces.get(1011).getComponent(51).doClick();
sleep (2000, 3500);
walkPath(genPath(new RSTile (2657, 2639)), 2);
}
if (getJob().getName().equals("Prayer")) {
sleep (random(6000,8000));
sleep(random(5000, 6500));
log ("we're gonna click on 100x");
interfaces.get(1011).getComponent(183).doClick();
sleep(random(4000, 5000));
log ("we clicked 100x, now confirm");
sleep(random(5000, 6500));
interfaces.get(1011).getComponent(382).doClick();
log ("we confirmed");
oldPoints = 0;
played = false;
points = 0;
got250 = false;
interfaces.get(1011).getComponent(51).doClick();
sleep (2000, 3500);
walkPath(genPath(new RSTile (2657, 2639)), 2);
}
if (getJob().getName().equals("Strength")) {
sleep (random(6000,8000));
sleep(random(5000, 6500));
log ("we're gonna click on 100x");
interfaces.get(1011).getComponent(103).doClick();
sleep(random(4000, 5000));
log ("we clicked 100x, now confirm");
sleep(random(5000, 6500));
interfaces.get(1011).getComponent(382).doClick();
log ("we confirmed");
oldPoints = 0;
played = false;
points = 0;
got250 = false;
interfaces.get(1011).getComponent(51).doClick();
sleep (2000, 3500);
walkPath(genPath(new RSTile (2657, 2639)), 2);
}
if (getJob().getName().equals("Ranged")) {
sleep (random(6000,8000));
sleep(random(5000, 6500));
log ("we're gonna click on 100x");
interfaces.get(1011).getComponent(151).doClick();
sleep(random(4000, 5000));
log ("we clicked 100x, now confirm");
sleep(random(5000, 6500));
interfaces.get(1011).getComponent(382).doClick();
log ("we confirmed");
oldPoints = 0;
played = false;
points = 0;
got250 = false;
interfaces.get(1011).getComponent(51).doClick();
sleep (2000, 3500);
walkPath(genPath(new RSTile (2657, 2639)), 2);
}
if (getJob().getName().equals("Hitpoints")) {
sleep (random(6000,8000));
sleep(random(5000, 6500));
log ("we're gonna click on 100x");
interfaces.get(1011).getComponent(135).doClick();
sleep(random(4000, 5000));
log ("we clicked 100x, now confirm");
sleep(random(5000, 6500));
interfaces.get(1011).getComponent(382).doClick();
log ("we confirmed");
oldPoints = 0;
played = false;
points = 0;
got250 = false;
interfaces.get(1011).getComponent(51).doClick();
sleep (2000, 3500);
walkPath(genPath(new RSTile (2657, 2639)), 2);
}
//the void armor
//if (getJob().getName().equals("seal")) {
//sleep (random(6000,8000));
//sleep(random(5000, 6500));
// log ("we're gonna the tab");
///interfaces.get(1011).getComponent(28).doClick();
// sleep(random(4000, 5000));
// log ("we clicked the tab, now click exchange..");
// sleep(random(3500,4600));
// interfaces.get(1011).getComponent(279).doClick();
// log ("we clicked exchange, now confirm");
// sleep(random(5000, 6500));
// interfaces.get(1011).getComponent(382).doClick();
// log ("we confirmed");
// walkPath(genPath(new RSTile (2657, 2639)), 2);
//}
if (getJob().getName().equals("deflector")) {
sleep (random(6000,8000));
sleep(random(5000, 6500));
log ("we're gonna the tab");
interfaces.get(1011).getComponent(28).doClick();
sleep(random(4000, 5000));
log ("we clicked the tab, now click exchange..");
sleep(random(3500,4600));
interfaces.get(1011).getComponent(266).doClick();
log ("we clicked exchange, now confirm");
sleep(random(5000, 6500));
interfaces.get(1011).getComponent(382).doClick();
log ("we confirmed");
oldPoints = 0;
played = false;
points = 0;
got250 = false;
interfaces.get(1011).getComponent(51).doClick();
sleep (2000, 3500);
walkPath(genPath(new RSTile (2657, 2639)), 2);
jobQ.remove();
}
if (getJob().getName().equals("mace")) {
sleep (random(6000,8000));
sleep(random(5000, 6500));
log ("we're gonna the tab");
interfaces.get(1011).getComponent(28).doClick();
sleep(random(4000, 5000));
log ("we clicked the tab, now click exchange..");
sleep(random(3500,4600));
interfaces.get(1011).getComponent(254).doClick();
log ("we clicked exchange, now confirm");
sleep(random(5000, 6500));
interfaces.get(1011).getComponent(382).doClick();
log ("we confirmed");
oldPoints = 0;
played = false;
points = 0;
got250 = false;
interfaces.get(1011).getComponent(51).doClick();
sleep (2000, 3500);
walkPath(genPath(new RSTile (2657, 2639)), 2);
jobQ.remove();
}
if (getJob().getName().equals("gloves")) {
sleep (random(6000,8000));
sleep(random(5000, 6500));
log ("we're gonna the tab");
interfaces.get(1011).getComponent(28).doClick();
sleep(random(4000, 5000));
log ("we clicked the tab, now click exchange..");
sleep(random(3500,4600));
interfaces.get(1011).getComponent(243).doClick();
log ("we clicked exchange, now confirm");
sleep(random(5000, 6500));
interfaces.get(1011).getComponent(382).doClick();
log ("we confirmed");
oldPoints = 0;
played = false;
points = 0;
got250 = false;
interfaces.get(1011).getComponent(51).doClick();
sleep (2000, 3500);
walkPath(genPath(new RSTile (2657, 2639)), 2);
jobQ.remove();
}
if (getJob().getName().equals("robes")) {
sleep (random(6000,8000));
sleep(random(5000, 6500));
log ("we're gonna the tab");
interfaces.get(1011).getComponent(28).doClick();
sleep(random(4000, 5000));
log ("we clicked the tab, now click exchange..");
sleep(random(3500,4600));
interfaces.get(1011).getComponent(231).doClick();
log ("we clicked exchange, now confirm");
sleep(random(5000, 6500));
interfaces.get(1011).getComponent(382).doClick();
log ("we confirmed");
oldPoints = 0;
played = false;
points = 0;
got250 = false;
interfaces.get(1011).getComponent(51).doClick();
sleep (2000, 3500);
walkPath(genPath(new RSTile (2657, 2639)), 2);
jobQ.remove();
}
if (getJob().getName().equals("top")) {
sleep (random(6000,8000));
sleep(random(5000, 6500));
log ("we're gonna the tab");
interfaces.get(1011).getComponent(28).doClick();
sleep(random(4000, 5000));
log ("we clicked the tab, now click exchange..");
sleep(random(3500,4600));
interfaces.get(1011).getComponent(219).doClick();
log ("we clicked exchange, now confirm");
sleep(random(5000, 6500));
interfaces.get(1011).getComponent(382).doClick();
log ("we confirmed");
oldPoints = 0;
played = false;
points = 0;
got250 = false;
interfaces.get(1011).getComponent(51).doClick();
sleep (2000, 3500);
walkPath(genPath(new RSTile (2657, 2639)), 2);
jobQ.remove();
}
if (getJob().getName().equals("mage helm")) {
sleep (random(6000,8000));
sleep(random(5000, 6500));
log ("we're gonna the tab");
interfaces.get(1011).getComponent(28).doClick();
sleep(random(4000, 5000));
log ("we clicked the tab, now click exchange..");
sleep(random(3500,4600));
interfaces.get(1011).getComponent(207).doClick();
log ("we clicked exchange, now confirm");
sleep(random(5000, 6500));
interfaces.get(1011).getComponent(382).doClick();
log ("we confirmed");
oldPoints = 0;
played = false;
points = 0;
got250 = false;
interfaces.get(1011).getComponent(51).doClick();
sleep (2000, 3500);
walkPath(genPath(new RSTile (2657, 2639)), 2);
jobQ.remove();
}
if (getJob().getName().equals("ranger helm")) {
sleep (random(6000,8000));
sleep(random(5000, 6500));
log ("we're gonna the tab");
interfaces.get(1011).getComponent(28).doClick();
sleep(random(4000, 5000));
log ("we clicked the tab, now click exchange..");
sleep(random(3500,4600));
interfaces.get(1011).getComponent(195).doClick();
log ("we clicked exchange, now confirm");
sleep(random(5000, 6500));
interfaces.get(1011).getComponent(382).doClick();
log ("we confirmed");
oldPoints = 0;
played = false;
points = 0;
got250 = false;
interfaces.get(1011).getComponent(51).doClick();
sleep (2000, 3500);
walkPath(genPath(new RSTile (2657, 2639)), 2);
jobQ.remove();
}
if (getJob().getName().equals("melee helm")) {
sleep (random(6000,8000));
sleep(random(5000, 6500));
log ("we're gonna the tab");
interfaces.get(1011).getComponent(28).doClick();
sleep(random(4000, 5000));
log ("we clicked the tab, now click exchange..");
sleep(random(3500,4600));
interfaces.get(1011).getComponent(290).doClick();
log ("we clicked exchange, now confirm");
sleep(random(5000, 6500));
interfaces.get(1011).getComponent(382).doClick();
log ("we confirmed");
oldPoints = 0;
played = false;
points = 0;
got250 = false;
interfaces.get(1011).getComponent(51).doClick();
sleep (2000, 3500);
walkPath(genPath(new RSTile (2657, 2639)), 2);
jobQ.remove();
}
//equipment: 21 & 28
//melee helm: 66 290
//ranger helm: 98 195
//mage helm: 114 207
//top: 130 219
//robes: 146 231
//gloves: 162 243
//mace: 254
//deflector: 178 266
//seal: 279
// "Attack", "Defence",
// "Magic", "Prayer", "Strength", "Ranged", "Hitpoints", "Top",
// "Robe", "Range Helm", "Melee Helm", "Mage Helm", "Glove"
//jobQ.remove(j);
}
@Override
public int loop() {
VarAttState = GetAttState();
if (!(VarAttState == AttState))
{
RSComponent set1 = interfaces.getComponent(884, 11);
RSComponent set2 = interfaces.getComponent(884, 12);
RSComponent set3 = interfaces.getComponent(884, 13);
RSComponent set4 = interfaces.getComponent(884, 14);
if (game.getCurrentTab() != Game.TAB_ATTACK)
game.openTab(Game.TAB_ATTACK);
if (AttState == 0)
{
set1.doClick();
}
if (AttState == 1)
{
set2.doClick();
}
if (AttState == 2)
{
set3.doClick();
}
if (AttState == 3)
{
set4.doClick();
}
}
try {
mouse.setSpeed(random(5, 8));
if (gc == 0)
gc = System.currentTimeMillis();
if (!onBoat() && !inPest()) {
Break b = getCurrentBreak();
if (b != null && b.needsBreak())
b.takeBreak();
}
//if (interfaces.get(INTERFACE_250_PTS).isValid()) {
// got250 = true;
//}
if (points >= spendwhenpoints && !inPest()) {
log ("We have (more than) the required number of points!");
got250 = true;
}
if (getMyPlayer().isInCombat() && getMyPlayer().getHPPercent() < 2
&& calc.distanceTo(npcs.getNearest(squire)) > 15) {
return random(600, 800);
}
// if (!(getMyPlayer().isInCombat()) && inPest() && standStill() == true) {
// log ("fixing standing still");
// } adding later
RSNPC changer = npcs.getNearest(3788);
RSNPC changer2 = npcs.getNearest(3789);
if (!onBoat() && !inPest() && getJob() != null && got250 == true && !interfaces.get(1011).isValid()) {
log ("we're gonna buy (dojob)");
//doJob();
final Job j = getJob();
if (j == null) {
log ("we returned");
//return;
}
if (j.points == 100 && !got250)
{
log ("we returned 2");
//return;
}
//if (npcs.getNearest(3788) == null && !inBuyArea()) {
// log ("the void is null");
// walkPath(genPath(new RSTile(9545, 10657)), 2);
// walkPath(genPath(npcs.getNearest(3788).getLocation()), 2);
// sleep(random(5000, 6500));
// clickNPC(npcs.getNearest(3788), "Exchange");
// } else if (calc.distanceTo(npcs.getNearest(3788)) > 3) {
//} else if (npcs.getNearest(3788) != null && !inBuyArea()){
// log ("the void is not null");
// walkPath(genPath(new RSTile(2662, 2650)), 2);
// walkPath(genPath(npcs.getNearest(3788).getLocation()), 2);
// clickNPC(npcs.getNearest(3788), "Exchange");
// }
//RSNPC changer = npcs.getNearest(3788);
//RSNPC changer2 = npcs.getNearest(3789);
//if (changer.isOnScreen()) {
// clickNPC(npcs.getNearest(3788), "Exchange");
//log ("we clicked the void");
// exchange();
///} else {
// walkPath(genPath(npcs.getNearest(3788).getLocation()), 2);
//}
//if (changer2.isOnScreen()) {
// clickNPC(npcs.getNearest(3789), "Exchange");
// log ("we clicked the void");
// exchange();
//} else {
// walkPath(genPath(npcs.getNearest(3788).getLocation()), 2);
//}
if (changer.isOnScreen()&& !(interfaces.get(1011).isValid())) {
log ("the changer is on screen");
clickNPC(npcs.getNearest(3788), "Exchange");
sleep (random(3000,4000));
} else {
walkPath(genPath(npcs.getNearest(3788).getLocation()), 2);
camera.turnTo(changer);
sleep (random(1000,2000));
if (changer.isOnScreen()&& !(interfaces.get(1011).isValid())) {
clickNPC(npcs.getNearest(3788), "Exchange");
sleep (random(3000,4000));
}
else
{
if (changer2.isOnScreen() && !(interfaces.get(1011).isValid())) {
log ("the changer is on screen");
clickNPC(npcs.getNearest(3789), "Exchange");
sleep (random(3000,4000));
} else {
walkPath(genPath(npcs.getNearest(3789).getLocation()), 2);
sleep (random(3000,4000));
clickNPC(npcs.getNearest(3789), "Exchange");
sleep (random(3000,4000));
} return 3000;
}
}
}
if (interfaces.get(1011).isValid()) {
exchange();
}
//if (inBuyArea()) {
// log ("we're in the buy area");
// camera.turnToCharacter(changer);
// } else {
// log ("the changer is NOT on screen");
// walkPath(genPath(npcs.getNearest(3789).getLocation()), 2);
// camera.turnToCharacter(changer);
// clickNPC(npcs.getNearest(3789), "Exchange");
// sleep (random(3000,4000));
// if (interfaces.get(1011).isValid()) {
// log ("interface is valid");
// exchange();
// } else {
// walkPath(genPath(npcs.getNearest(3789).getLocation()), 2);
// sleep (random(3000,4000));
// clickNPC(npcs.getNearest(3788), "Exchange");
// sleep (random(3000,4000));
// }
// }
// } return 4000;
//}
if (getJob() == null && got250) {
game.logout(false);
log("Thanks for using BPestControl");
log("Reached 250 points and out of jobs");
}
if (menu.isOpen()) {
mouse.move(random(5, 760), random(5, 500));
}
if (!inPest() && !onBoat() && !inBuyArea() && !got250) {
return enterBoat();
}
if (onBoat()) {
String s = "";
if (interfaces.getComponent(407, 16) != null) {
s = interfaces.getComponent(407, 16).getText();
}
points = Integer.parseInt(s.replace("Commendations: ", ""));
if (played) {
if (points > oldPoints) {
gainedPoints += points - oldPoints;
}
//if (points - oldPoints == 0) {
// lost++;
//} else {
// won++;
//}
}
oldPoints = points;
played = false;
return random(400, 700);
}
if (npcs.getNearest(squire) != null) {
voidLoc = npcs.getNearest(squire).getLocation();
fillPortalList();
}
if (inPest()) {
return pestLoop();
}
} catch (Exception ignored) {
}
return random(100, 800);
}
public void moveMouse(final Point p, final int rX, final int rY) {
final int X = p.x + random(-(rX / 1), (rX / 1));
final int Y = p.y + random(-(rY / 1), (rY / 1));
mouse.move(X, Y);
}
boolean onBoat() {
return boatArea != null && boatArea.contains(getMyPlayer().getLocation());
}
boolean inBuyArea() {
//int[] BuyArea = {2658, 2646, 2671, 2658};
BuyArea = new RSArea (2658, 2647, 2667, 2659);
return BuyArea != null && BuyArea.contains(getMyPlayer().getLocation());
}
int GetAttState() {
return settings.getSetting(43);
}
@Override
public boolean onStart() {
if (game.isLoggedIn()) {
start = false;
URLConnection url = null;
BufferedReader in = null;
JOptionPane.showMessageDialog(null, "Checking for updates... Click OK to continue!");
try {
JOptionPane.showMessageDialog(null,
"You have the latest version.");
if (in != null)
in.close();
} catch (IOException e) {
return false;
}
final BGUI gui = new BGUI();
gui.setVisible(true);
while (gui.isVisible()) {
sleep(random(500, 600));
}
if (!start) {
return false;
}
new Thread(new AnimationChecker()).start();
new Thread(antiban).start();
log("starting script");
pf = new Pathfinder();
} else {
log("Login before starting this script.");
stopScript(false);
return false;
}
return true;Gravemindx; remake by Louisc999.");
log("Gained " + gainedPoints + " points.");
}
public void onRepaint(final Graphics g) {
Point mLoc = mouse.getLocation();
g.setColor(Color.blue);
g.drawLine(mLoc.x, 0, mLoc.x, 502);
g.drawLine(0, mLoc.y, 764, mLoc.y);
if (getCurrentBreak() != null) {
g.drawString(getCurrentBreak().getTimeTillBreak(), 10, 400);
g.drawString("" + getCurrentBreak().needsBreak(), 10, 415);
}
int y = 120;
final int x = 20;
g.setColor(new Color(51, 153, 255, 170));
g.fillRoundRect(15, 120, width, height, 5, 5);
g.setColor(Color.WHITE);
g.drawRoundRect(15, 120, width, height, 5, 5);
width = 0;
height = 0;
if (startTime == 0) {
startTime = System.currentTimeMillis();
}
long millis = System.currentTimeMillis() - startTime;
try {
g.setColor(Color.WHITE);
g.setFont(new Font("Arial", Font.BOLD, 14));
g.drawString("BPestControl by Louisc999 v1.66", x, y += g
.getFontMetrics().getHeight());
height += g.getFontMetrics().getHeight();
width = (int) g.getFontMetrics().getStringBounds(
"BPestControl by Louisc999 v1.66", g).getWidth();
g.setFont(new Font("Arial", Font.PLAIN, 12));
g.drawString("Lost " + lost + " Games", x, y += g.getFontMetrics()
.getHeight());
height += g.getFontMetrics().getHeight();
g.drawString("won " + won + " Games", x, y += g.getFontMetrics()
.getHeight());
height += g.getFontMetrics().getHeight();
g.drawString("Gained " + gainedPoints + " points", x, y += g
.getFontMetrics().getHeight());
height += g.getFontMetrics().getHeight();
g.drawString("Time running : " + timeToString(millis), x, y += g
.getFontMetrics().getHeight());
height += g.getFontMetrics().getHeight();
if (getJob() != null) {
if (g.getFontMetrics().getStringBounds(
"Spending points on " + getJob().getName(), g)
.getWidth() > width) {
width = (int) g.getFontMetrics().getStringBounds(
"Spending points on " + getJob().getName(), g)
.getWidth();
}
g.drawString("Spending points on " + getJob().getName() + " "
+ points, x, y += g.getFontMetrics().getHeight());
height += g.getFontMetrics().getHeight();
}
height += 5;
width += 10;
} catch (final Exception ignored) {
}
}
int pestLoop() {
if (!played) {
played = true;
}
try {
if (!atPortal()) {
final Portal p = getRandomOpenPortal();
p.walkTo();
return random(100, 600);
}
if (!getCurrentPortal().equals(getNearestPortal())) {
if (getNearestOpenPortal() != null) {
getNearestOpenPortal().walkTo();
}
return random(100, 600);
}
if (!getCurrentPortal().isOpen()) {
if (getNearestOpenPortal() != null) {
getNearestOpenPortal().walkTo();
}
return random(100, 600);
}
checkSpecial();
if (getMyPlayer().getInteracting() == null) {
RSGroundItem t = groundItems.getNearest(arrowID);
if (t != null && t.isOnScreen()) {
t.doAction("Take");
return random(600, 800);
}
path = null;
if (!inPest()) {
return random(100, 500);
}
failsafe = 0;
RSNPC c;
if (getCurrentPortal().getNPC() != null) {
c = getCurrentPortal().getNPC();
} else {
c = getNPC(attackSpinner);
}
//if (c != null) {
// if (clickNPC(c, "Attack")) {
// return random(600, 1200);
// }
//}
if (c != null) {
clickNPC(c, "Attack");
//return random(10000, 13000);
}
//return random(400, 700);
} else {
RSNPC n = getNPC(true);
if (n != null && n.getName().contains("Spinner")) {
RSNPC inter = (RSNPC) getMyPlayer().getInteracting();
if ((inter != null && !inter.getName().equals(n.getName()))
|| inter == null)
if (clickNPC(n, "Attack Spinner")) {
//return random(600, 1200);
}
}
path = null;
if (failsafe > 4) {
walking.walkTileMM(getNearestOpenPortal().getRandom());
}
final RSNPC npc = (RSNPC) getMyPlayer().getInteracting();
if (getMyPlayer().isMoving()
|| getMyPlayer().getInteracting() != null
|| System.currentTimeMillis() - lastAniChange < 2000
|| npc != null && npc.getName().contains("ortal")) {
failsafe = 0;
} else {
failsafe++;
sleep(random(600, 800));
}
return random(400, 700);
}
} catch (final Exception ignored) {
}
return random(400, 700);
}
boolean PrayerEnabled() {
return settings.getSetting(1395) > 0;
}
private int i = 0;
boolean walkPath(final RSTile[] path) {
final char left = 37;
final char right = 39;
RSTile tile = getNext(path);
mouse.move(calc.worldToMinimap(tile.getX(), tile.getY()));
if (!inPest()) {
return true;
}
if (i == 7) {
char dir = random(0, 3) == 2 ? left : right;
keyboard.pressKey(dir);
sleep(random(800, 1200));
keyboard.releaseKey(dir);
i = 0;
return false;
}
if (getTopText().contains("Cancel")) {
i++;
return false;
}
try {
walking.walkTileMM(getNext(path));
sleep(random(200, 500));
while (getMyPlayer().isMoving() && calc.distanceTo(walking.getDestination()) > 7) {
sleep(random(600, 800));
}
} catch (final Exception ignored) {
}
return calc.distanceTo(path[path.length - 1]) < 10 || !inPest();
}
void checkSpecial() {
if (specialPercent == 0 ) {
return;
}
int percent = (settings.getSetting(300) / 10);
if (percent >= specialPercent && settings.getSetting(301) == 0) {
RSComponent child = interfaces.getComponent(884, 4);
if (game.getCurrentTab() != Game.TAB_ATTACK)
game.openTab(Game.TAB_ATTACK);
child.doClick();
sleep(random(2000, 3000));
}
}
void walkPath(final RSTile[] path, final int i) {
try {
walking.walkTileMM(getNext(path));
sleep(random(200, 500));
while (getMyPlayer().isMoving() && calc.distanceTo(walking.getDestination()) > 7) {
sleep(random(600, 800));
}
} catch (final Exception ignored) {
}
}
int daxeID = 0;
int oldID = 0;
public void doDragonBattleAxe() {
if (!DBaxe)
return;
if (game.getCurrentTab() != Game.TAB_INVENTORY)
game.openTab(Game.TAB_INVENTORY);
inventory.getItem(daxeID).doClick(true);
game.openTab(Game.TAB_ATTACK);
RSComponent child = interfaces.getComponent(884, 4);
child.doClick();
sleep(random(1200, 1500));
if (game.getCurrentTab() != Game.TAB_INVENTORY)
game.openTab(Game.TAB_INVENTORY);
inventory.getItem(oldID).doClick(true);
}
RSNPC getNPC(boolean spinner) {
final String[] names = {"Shifter", "Defiler", "Torcher", "Brawler", "Ravager", "Spinner"};
RSNPC closest = null;
RSNPC[] result = npcs.getAll(new Filter<RSNPC>() {
public boolean accept(RSNPC monster) {
for (String name : names) {
if (!name.equals(monster.getName())
|| calc.distanceBetween(getCurrentPortal().getLocation(), monster.getLocation()) > 10
|| monster.isInCombat() && monster.getHPPercent() < 10) {
continue;
}
return true;
}
return false;
}
});
if (result.length == 0)
return null;
RSNPC s = null;
for (RSNPC npc : result) {
if (spinner) {
if (npc.getName().equalsIgnoreCase("Spinner")) {
if (s == null || calc.distanceTo(s) > calc.distanceTo(npc))
s = npc;
}
}
if (closest == null || calc.distanceTo(closest) > calc.distanceTo(npc))
closest = npc;
}
if (spinner && s != null) {
return s;
}
return closest;
}
public String timeToString(long time) {
final long hours = time / (1000 * 60 * 60);
time -= hours * 1000 * 60 * 60;
final long minutes = time / (1000 * 60);
time -= minutes * 1000 * 60;
final long seconds = time / 1000;
String str = "";
if (hours < 10)
str += "0";
str += hours + ":";
if (minutes < 10)
str += "0";
str += minutes + ":";
if (seconds < 10)
str += "0";
str += seconds;
return str;
}
class Break {
public boolean isDone = false;
int time, after;
public Timer Time;
long end;
public Break(int time, int after) {
this.time = time;
this.after = after;
end = System.currentTimeMillis() + after;
}
public void init() {
Time = new Timer(time);
end = System.currentTimeMillis() + after;
}
public void takeBreak() {
while (game.isLoggedIn())
game.logout(false);
Time.reset();
log("Taking break for " + Time.toString());
while (!Time.isDone()) {
try {
Thread.sleep(random(500, 800));
} catch (InterruptedException ignored) {
}
}
isDone = true;
}
public String getTimeTillBreak() {
return timeToString(end - System.currentTimeMillis());
}
public boolean needsBreak() {
return System.currentTimeMillis() > end;
}
}
// ----------
class Timer {
private long start;
private int time;
public Timer(int time) {
start = System.currentTimeMillis();
this.time = time;
}
public Timer() {
this(0);
}
public boolean isDone() {
return (System.currentTimeMillis() - start) > time;
}
public void reset() {
start = System.currentTimeMillis();
}
@Override
public String toString() {
return timeToString((System.currentTimeMillis() - start));
}
}
// ----------
class Pathfinder {
public int basex, basey;
public int[][] blocks;
public Pathfinder() {
reload();
}
public void reload() {
basex = game.getBaseX();
basey = game.getBaseY();
blocks = walking.getCollisionFlags(game.getPlane());
}
public RSTile[] findPath(RSTile dest) {
if (!isValid())
reload();
return findPath(getMyPlayer().getLocation(), dest);
}
public RSTile[] findPath(RSTile start, RSTile dest) {
if (!isValid())
reload();
return findPath(
new Node(start.getX() - basex, start.getY() - basey),
new Node(dest.getX() - basex, dest.getY() - basey));
}
public RSTile[] findPath(Node start, Node dest) {
if (!isValid())
reload();
if (!calc.canReach(new RSTile(dest.x + basex, dest.y + basey), false)) {
return null;
}
ArrayList<Node> closed = new ArrayList<Node>();
ArrayList<Node> open = new ArrayList<Node>();
Node current = start;
open.add(current);
while (open.size() != 0) {
current = getBestNode(open);
closed.add(current);
open.remove(current);
for (Node node : getNodesAround(current)) {
if (!closed.contains(node)) {
if (!open.contains(node)) {
node.parent = current;
node.cost = current.cost
+ getMovementCost(node, current);
node.heuristic = node.cost
+ getHeuristicCost(node, dest);
open.add(node);
} else {
if (current.cost + getMovementCost(node, current) < node.cost) {
node.parent = current;
node.cost = current.cost
+ getMovementCost(node, current);
node.heuristic = node.cost
+ getHeuristicCost(node, dest);
}
}
}
}
if (closed.contains(dest)) {
final ArrayList<RSTile> result = new ArrayList<RSTile>();
Node node = closed.get(closed.size() - 1);
while (node.parent != null) {
result.add(new RSTile(node.x + basex, node.y + basey));
node = node.parent;
}
path = reversePath(result
.toArray(new RSTile[result.size()]));
return path;
}
}
return null;
}
/**
* Reverses an array of tiles.
*
* @param other The <tt>RSTile</tt> path array to reverse.
* @return The reverse <tt>RSTile</tt> path for the given <tt>RSTile</tt>
* path.
*/
@Deprecated
public RSTile[] reversePath(RSTile[] other) {
RSTile[] t = new RSTile[other.length];
for (int i = 0; i < t.length; i++) {
t[i] = other[other.length - i - 1];
}
return t;
}
public Node getBestNode(ArrayList<Node> nodes) {
Node winner = null;
for (Node node : nodes) {
if (winner == null || node.cost < winner.cost) {
winner = node;
}
}
return winner;
}
public double getHeuristicCost(Node current, Node dest) {
float dx = dest.x - current.x;
float dy = dest.y - current.y;
return Math.sqrt((dx * dx) + (dy * dy));
}
public double getMovementCost(Node current, Node dest) {
return Math.hypot(dest.x - current.x, dest.y - current.y);
}
/* (non-Javadoc)
* credits to Jacmob
*/
public ArrayList<Node> getNodesAround(Node node) {
final ArrayList<Node> tiles = new ArrayList<Node>();
final int curX = node.x, curY = node.y;
if (curX > 0 && curY < 103
&& (blocks[curX - 1][curY + 1] & 0x1280138) == 0
&& (blocks[curX - 1][curY] & 0x1280108) == 0
&& (blocks[curX][curY + 1] & 0x1280120) == 0) {
tiles.add(new Node(curX - 1, curY + 1));
}
if (curY < 103 && (blocks[curX][curY + 1] & 0x1280120) == 0) {
tiles.add(new Node(curX, curY + 1));
}
if (curX > 0 && curY < 103
&& (blocks[curX - 1][curY + 1] & 0x1280138) == 0
&& (blocks[curX - 1][curY] & 0x1280108) == 0
&& (blocks[curX][curY + 1] & 0x1280120) == 0) {
tiles.add(new Node(curX + 1, curY + 1));
}
if (curX > 0 && (blocks[curX - 1][curY] & 0x1280108) == 0) {
tiles.add(new Node(curX - 1, curY));
}
if (curX < 103 && (blocks[curX + 1][curY] & 0x1280180) == 0) {
tiles.add(new Node(curX + 1, curY));
}
if (curX > 0 && curY > 0
&& (blocks[curX - 1][curY - 1] & 0x128010e) == 0
&& (blocks[curX - 1][curY] & 0x1280108) == 0
&& (blocks[curX][curY - 1] & 0x1280102) == 0) {
tiles.add(new Node(curX - 1, curY - 1));
}
if (curY > 0 && (blocks[curX][curY - 1] & 0x1280102) == 0) {
tiles.add(new Node(curX, curY - 1));
}
if (curX < 103 && curY > 0
&& (blocks[curX + 1][curY - 1] & 0x1280183) == 0
&& (blocks[curX + 1][curY] & 0x1280180) == 0
&& (blocks[curX][curY - 1] & 0x1280102) == 0) {
tiles.add(new Node(curX + 1, curY - 1));
}
return tiles;
}
public boolean isValid() {
return basex == game.getBaseX()
&& basey == game.getBaseY();
}
class Node {
public final int x, y;
public double cost = 0, heuristic = 0;
public Node parent;
public Node(int x, int y) {
this.x = x;
this.y = y;
}
public boolean equals(Object other) {
if (other instanceof Node) {
Node o = (Node) other;
return x == o.x && y == o.y;
}
return false;
}
}
}
// ----------
class BGUI extends JFrame implements ActionListener {
private static final long serialVersionUID = 1L;
private JPanel contentPane;
private JTabbedPane tabbedPane;
private JTable table;
private JTextField textField;
private JTextField textField_1;
private JButton btnAddBreak;
private DefaultTableModel model;
private DefaultListModel jobmodel;
private JButton btnAddAntiban;
private JComboBox comboBox_1;
private JList list_1;
private JButton btnAddJob;
private JButton btnDelJob;
private JList list;
private JComboBox comboBox;
public BGUI() {
super("BPestControl");
initGUI();
}
private void initGUI() {
setAlwaysOnTop(true);
setResizable(false);
try {
UIManager.setLookAndFeel(UIManager
.getSystemLookAndFeelClassName());
} catch (Exception ignored) {
}
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
setBounds(100, 100, 450, 300);
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
contentPane.setLayout(null);
tabbedPane = new JTabbedPane(SwingConstants.LEFT);
tabbedPane.setBounds(10, 10, 414, 218);
contentPane.add(tabbedPane);
final JPanel panel = new JPanel();
tabbedPane.addTab("Main", null, panel, null);
final JLabel lblnote = new JLabel("note: fill in how much precent special it needs to be");
lblnote.setBounds(10, 232, 300, 16);
contentPane.add(lblnote);
final JLabel lblnote2 = new JLabel("to do a special attack (example: 80) no % symbol");
lblnote2.setBounds(43, 243, 300, 16);
contentPane.add(lblnote2);
btnStartScript = new JButton("Start script");
btnStartScript.addActionListener(this);
btnStartScript.setBounds(327, 234, 97, 23);
contentPane.add(btnStartScript);
panel.setLayout(null);
final JPanel panel_2 = new JPanel();
tabbedPane.addTab("Antiban", null, panel_2, null);
chckbxUseSpecialAttack = new JCheckBox("Use special attack when at (fill in how much precent)");
chckbxUseSpecialAttack.setBounds(10, 10, 126, 17);
panel.add(chckbxUseSpecialAttack);
chckbxUseQuickPrayer = new JCheckBox("Use quick prayer");
chckbxUseQuickPrayer.setBounds(10, 27, 126, 17);
panel.add(chckbxUseQuickPrayer);
final JLabel spendnote = new JLabel("spend if we have");
spendnote.setBounds(28, 44, 126, 17);
panel.add(spendnote);
spendwhen = new JTextField();
spendwhen.setText("250");
spendwhen.setBounds(137, 43, 31, 19);
panel.add(spendwhen);
comboBox = new JComboBox();
comboBox.setModel(new DefaultComboBoxModel(jobsStrings));
comboBox.setBounds(10, 70, 126, 24);
panel.add(comboBox);
btnAddJob = new JButton("Add Job");
btnAddJob.setBounds(20, 95, 103, 23);
btnAddJob.addActionListener(this);
panel.add(btnAddJob);
btnDelJob = new JButton("Delete Job");
btnDelJob.setBounds(20, 120, 103, 23);
btnDelJob.addActionListener(this);
panel.add(btnDelJob);
final JScrollPane scrollPane = new JScrollPane();
scrollPane.setBounds(180, 10, 126, 193);
panel.add(scrollPane);
jobmodel = new DefaultListModel();
list = new JList(jobmodel);
scrollPane.setViewportView(list);
list.setBorder(new TitledBorder(null, "", TitledBorder.LEADING,
TitledBorder.TOP, null, null));
final JPanel panel_7 = new JPanel();
tabbedPane.addTab("Break handler", null, panel_7, null);
panel_2.setLayout(null);
m = new DefaultListModel();
list_1 = new JList(m);
list_1.setBorder(new LineBorder(new Color(0, 0, 0)));
list_1.setBounds(10, 10, 307, 164);
panel_2.add(list_1);
btnAddAntiban = new JButton("Add antiban");
btnAddAntiban.addActionListener(this);
btnAddAntiban.setBounds(10, 180, 97, 23);
panel_2.add(btnAddAntiban);
comboBox_1 = new JComboBox();
comboBox_1.setModel(new DefaultComboBoxModel(new String[]{
"rotate compass", "move mouse",
"move mouse and rotate compass", "rest",
"right click object", "right click npc",
"right click player"}));
comboBox_1.setBounds(113, 180, 204, 23);
panel_2.add(comboBox_1);
panel_7.setLayout(null);
table = new JTable();
table.setBorder(new LineBorder(new Color(0, 0, 0)));
table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
table.setBounds(10, 10, 301, 164);
model = new DefaultTableModel();
table.setModel(model);
model.addColumn("");
model.addColumn("");
panel_7.add(table);
btnAddBreak = new JButton("Add break");
btnAddBreak.addActionListener(this);
btnAddBreak.setBounds(10, 180, 89, 23);
panel_7.add(btnAddBreak);
final JLabel lblBreakFor = new JLabel("Break for");
lblBreakFor.setBounds(105, 183, 52, 16);
panel_7.add(lblBreakFor);
textField = new JTextField();
textField.setBounds(158, 181, 27, 21);
panel_7.add(textField);
textField.setColumns(10);
final JLabel lblAfter = new JLabel("after ");
lblAfter.setBounds(190, 183, 27, 16);
panel_7.add(lblAfter);
textField_1 = new JTextField();
textField_1.setBounds(218, 181, 26, 21);
panel_7.add(textField_1);
textField_1.setColumns(10);
btnRemove = new JButton("Delete");
btnRemove.addActionListener(this);
btnRemove.setBounds(248, 181, 65, 23);
panel_7.add(btnRemove);
comboBox_2 = new JComboBox();
comboBox_2.setModel(new DefaultComboBoxModel(new String[]{
"Novice", "Intermediate", "Veteran"}));
comboBox_2.setBounds(10, 181, 141, 22);
panel.add(comboBox_2);
chckbxAttackPortals = new JCheckBox("Attack portals");
chckbxAttackPortals.setBounds(10, 145, 105, 17);
panel.add(chckbxAttackPortals);
specialtxt = new JTextField();
specialtxt.setText("");
specialtxt.setBounds(137, 10, 31, 19);
panel.add(specialtxt);
specialtxt.setColumns(10);
chckbxattackspinners = new JCheckBox("Attack spinners");
chckbxattackspinners.setBounds(10, 160, 113, 17);
panel.add(chckbxattackspinners);
}
DefaultListModel m;
private JButton btnRemove;
public void actionPerformed(final ActionEvent e) {
if (e.getSource() == btnStartScript) {
AttState = GetAttState();
start = true;
attackPortals = chckbxAttackPortals.isSelected();
attackSpinner = chckbxattackspinners.isSelected();
spendwhenpoints = Integer.parseInt(spendwhen.getText());
if (pickupArrows) {
if (game.getCurrentTab() != Game.TAB_EQUIPMENT)
game.openTab(Game.TAB_EQUIPMENT);
arrowID = equipment.getItem(Equipment.AMMO).getID();
}
if (DBaxe) {
if (game.getCurrentTab() != Game.TAB_EQUIPMENT)
game.openTab(Game.TAB_EQUIPMENT);
oldID = equipment.getItem(Equipment.WEAPON).getID();
}
usePray = chckbxUseQuickPrayer.isSelected();
if (chckbxUseSpecialAttack.isSelected()) {
try {
specialPercent = Integer.parseInt(specialtxt.getText());
} catch (Exception check) {
specialPercent = 0;
}
} else {
specialPercent = 0;
}
for (int i = 0; i < jobmodel.getSize(); i++) {
int index = 0;
for (int j = 0; j < jobsStrings.length; j++)
if (jobsStrings[j].equals(jobmodel.get(i).toString()))
index = j;
jobQ.add(new Job(jobmodel.get(i).toString(),
jobsPoints[index]));
}
for (int i = 0; i < m.getSize(); i++) {
antibanQ.add(m.get(i).toString());
}
int i = comboBox_2.getSelectedIndex();
log("" + i);
if (i == 0) {
plankID = 14315;
boatArea = new RSArea(2660, 2638, 2663, 2643);
Squire = 3802;
} else if (i == 1) {
plankID = 25631;
boatArea = new RSArea(2638, 2642, 2641, 2647);
Squire = 6140;
} else {
plankID = 25632;
boatArea = new RSArea(2632, 2649, 2635, 2654);
Squire = 6141;
}
dispose();
}
if (e.getSource() == btnAddJob) {
jobmodel.addElement(comboBox.getSelectedItem());
}
if (e.getSource() == btnDelJob) {
jobmodel.removeElement(comboBox.getSelectedItem());
}
if (e.getSource() == btnRemove) {
if (table.getSelectedRow() != -1)
model.removeRow(table.getSelectedRow());
}
if (e.getSource() == btnAddAntiban) {
m.addElement(comboBox_1.getSelectedItem());
}
if (e.getSource() == btnAddBreak) {
model.addRow(new Object[]{textField.getText(),
textField_1.getText()});
}
}
double version = 1.0;
private JTextField specialtxt;
private JTextField spendwhen;
private JButton btnStartScript;
private JCheckBox chckbxUseSpecialAttack;
private JCheckBox chckbxUseQuickPrayer;
private JCheckBox chckbxAttackPortals;
private JComboBox comboBox_2;
private JCheckBox chckbxattackspinners;
}
}