rendered paste bodyimport org.rsbot.script.Script;
import org.rsbot.script.ScriptManifest;
import org.rsbot.script.wrappers.RSTile;
import org.rsbot.script.wrappers.RSNPC;
import org.rsbot.script.wrappers.RSItem;
import org.rsbot.script.wrappers.RSItemDef;
import org.rsbot.script.wrappers.RSObject;
import org.rsbot.script.wrappers.RSGroundItem;
import org.rsbot.script.wrappers.RSArea;
import org.rsbot.script.wrappers.RSTilePath;
import org.rsbot.script.methods.Walking;
import org.rsbot.client.HardReference;
import org.rsbot.client.SoftReference;
import org.rsbot.event.listeners.PaintListener;
import org.rsbot.util.GlobalConfiguration;
import java.util.ArrayList;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.imageio.ImageIO;
import java.io.IOException;
import java.io.File;
import java.io.FileWriter;
import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.URL;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.MouseMotionListener;
import java.awt.Point;
import java.awt.Image;
import java.awt.Graphics;
import java.awt.Color;
import java.awt.Font;
import java.awt.Rectangle;
import java.awt.FontMetrics;
import java.awt.image.RenderedImage;
/**
*
*@Author Connor132 (Credits to Foulwerp for attacking, and looting)
*///<a src=http://www.thepinoytattoo.co.cc/wp-content/uploads/2009/08/black-demon.jpg>
@ScriptManifest(authors = {"<html><body bgcolor=0><font color=ffffff>Connor132"}, name = "<html><body bgcolor=0><font color=ffffff>Black Demon Murder", version = 1.4, description = "<html><body bgcolor=0><font color=ffffff>Must use monkfish")
public class BlackDemonMurder extends Script implements PaintListener, MouseMotionListener, MouseListener {
public boolean onStart() {
try {
action = "Starting up...";
location = "Undefined";
gui g = new gui(this);
g.setVisible(true);
while(g.isVisible()) sleep(20);
Object o[] = g.getData();
lootArray = getLootArray(o);
foodID = (Integer)o[3];
lootCount = new int[lootArray.length];
bankCount = new int[lootArray.length];
for (int i = 0; i < lootCount.length; i++) {
lootCount[i] = 0;
bankCount[i] = 0;
}
button = getImage("button.png");
createSettingsFile(o);
cursor = new Point(-1, -1);
startExp = new int[25];
startLevel = new int[25];
for (int i = 0; i < 25; i++) {
startExp[i] = skills.getCurrentExp(i);
startLevel[i] = skills.getCurrentLevel(i);
}
buttonHover = new boolean[3];
for(int i = 0; i < buttonHover.length; i++)
buttonHover[i] = false;
buttonClick = new boolean[3];
for(int i = 0; i < buttonClick.length; i++)
buttonClick[i] = false;
stillTime = 0L;
startTime = System.currentTimeMillis();
mouseClick = new Point(-1, -1);
paintOn = true;
BANK_WALL = walking.newTilePath(BANK_WALL_PATH);
WALL_LADDER = walking.newTilePath(WALL_LADDER_PATH);
LADDER_GATE = walking.newTilePath(LADDER_GATE_PATH);
GATE_DEMON = walking.newTilePath(GATE_DEMON_PATH);
TAB_BANK = walking.newTilePath(TAB_BANK_PATH);
lastTileIndex = -1;
} catch(Exception e) {e.printStackTrace();log("Failed to start up");return false;}
return game.isLoggedIn();
}
private Object[] getData(File f) {
int index = 0;
Object[] o = new Object[4];
String line = "";
try {
BufferedReader br = new BufferedReader(new FileReader(f));
while((line = br.readLine()) != null) {
index = Character.getNumericValue(line.charAt(0));
o[index] = (Object)((line.substring(2).equalsIgnoreCase("false") || line.substring(2).equalsIgnoreCase("true")) ? Boolean.parseBoolean(line.substring(2)) : Integer.parseInt(line.substring(2)));
}
br.close();
} catch(Exception e) {}
return o;
}
private void createSettingsFile(Object[] settings) {
try {
File file = new File(GlobalConfiguration.Paths.getScriptsDirectory() + "/DMdata/settings.data");
if (file.exists())
file.delete();
file.createNewFile();
BufferedWriter bw = new BufferedWriter(new FileWriter(file));
for (int i = 0; i < settings.length; i++) {
if (settings[i] instanceof Boolean) {
bw.write(i+" "+((Boolean)settings[i]));
} else {
bw.write(i+" "+((Integer)settings[i]));
}
bw.newLine();
}
bw.close();
} catch(Exception e) {}
}
private int[] getLootArray(Object[] settings) {
ArrayList LOOT = new ArrayList<Integer>();
LOOT.add(1147);
LOOT.add(1113);
LOOT.add(18778);
if ((Boolean)settings[0]) {
LOOT.add(12160);
LOOT.add(12163);
LOOT.add(12158);
LOOT.add(12159);
}
if ((Boolean)settings[1]) {
LOOT.add(217);
LOOT.add(207);
}
if ((Boolean)settings[2]) {
LOOT.add(20268); //Ashes
}
int index = 0;
Integer[] integer = new Integer[LOOT.toArray().length];
for (Object o2 : LOOT.toArray()) {
integer[index++] = (Integer)o2;
}
int[] array = new int[integer.length];
index = 0;
for (Integer temp : integer)
array[index++] = temp;
return array;
}
public void onRepaint(Graphics g) {
try {
if (!game.isLoggedIn())
return;
if (paintOn) {
boolean drawn = false;
g.drawImage(button, 422, 308, null);
g.drawImage(button, 328, 308, null);
g.drawImage(button, 234, 308, null);
for (int i = 0; i < buttonClick.length; i++) {
if (buttonClick[i]) {
drawInfo(i, g);
drawOutline(i, g);
drawn = true;
}
}
if (!drawn)
for (int i = 0; i < buttonHover.length; i++)
if (buttonHover[i])
drawInfo(i, g);
/**Drawing Mouse**/
Point p = mouse.getLocation();
int s = (int)(System.currentTimeMillis() - startTime) / 100;
int xs = (int) (Math.cos(s * Math.PI / 30 - Math.PI / 2) * 10 + p.getX());
int ys = (int) (Math.sin(s * Math.PI / 30 - Math.PI / 2) * 10 + p.getY());
g.drawLine((int)p.getX(), (int)p.getY(), xs, ys);
g.drawOval((int)p.getX()-10, (int)p.getY()-10, 20, 20);
g.setColor(Color.RED);
g.fillOval((int)p.getX()-2, (int)p.getY()-2, 4, 4);
if (System.currentTimeMillis() - mouse.getPressTime() < 1000) {
p = mouse.getPressLocation();
g.fillOval((int)p.getX()-5, (int)p.getY()-5, 10, 10);
g.setColor(Color.GREEN);
g.fillOval((int)p.getX()-2, (int)p.getY()-2, 4, 4);
}
/****/
}
} catch (Exception e) {}
}
private void drawOutline(int i, Graphics g) {
g.setColor(Color.WHITE);
g.drawRect(516-94*(i+1), 308, 94, 30);
}
private void drawInfo(int i, Graphics g) {
g.setColor(backGround);
int[] d = getInfoDimension(i, g);
if ((516-(94*(i+1)))+d[0] > 516)
g.fillRect((516-(94*i))-d[0], 308-d[1], d[0], d[1]);
else
g.fillRect(516-(94*(1+i)), 308-d[1], d[0], d[1]);
switch(i) {
case 0:
g.setColor(Color.WHITE);
long millis = System.currentTimeMillis() - startTime;
if ((516-(94*(i+1)))+d[0] > 516) {
g.drawString("RunTime: "+formatTime(millis/3600000)+":"+formatTime(millis/60000-(millis/3600000*60))+":"+formatTime(millis/1000-(millis/3600000*60*60)-(millis/60000*60)), 516-d[0]+3, 306-d[1]+15);
g.drawString("Action: "+action, 516-d[0]+3, 306-d[1]+30);
g.drawString("Location: "+location, 516-d[0]+3, 306-d[1]+45);
} else {
g.drawString("RunTime: "+formatTime(millis/3600000)+":"+formatTime(millis/60000-(millis/3600000*60))+":"+formatTime(millis/1000-(millis/3600000*60)-(millis/60000)), 516-94*(i+1)+3, 306-d[1]+15);
g.drawString("Action: "+action, 516-94*(i+1)+3, 306-d[1]+30);
g.drawString("Location: "+location, 516-94*(i+1)+3, 306-d[1]+45);
}
break;
case 1:
g.setColor(Color.WHITE);
int y = 306-d[1]+15;
for (int i2 = 0; i2 < lootCount.length; i2++) {
if ((516-(94*(i+1)))+d[0] > 516)
g.drawString(getItemName(lootArray[i2])+": "+(bankCount[i2]+lootCount[i2]), 516-94-d[0]+3, y);
else
g.drawString(getItemName(lootArray[i2])+": "+(bankCount[i2]+lootCount[i2]), 516-94*(i+1)+3, y);
y += 15;
}
break;
case 2:
g.setColor(Color.WHITE);
int y2 = 306-d[1]+15;
boolean flag = false;
for (int i3 = 0; i3 < startExp.length; i3++) {
int xpGained = skills.getCurrentExp(i3) - startExp[i3];
int lvlsGained = skills.getCurrentLevel(i3) - startLevel[i3];
if (xpGained > 0) {
if ((516-(94*(i+1)))+d[0] > 516)
g.drawString(skills.SKILL_NAMES[i3]+": XP - "+xpGained+" LVLS - "+lvlsGained, 516-94-d[0]+3, y2);
else
g.drawString(skills.SKILL_NAMES[i3]+": XP - "+xpGained+" LVLS - "+lvlsGained, 516-94*(i+1)+3, y2);
y2 += 15;
flag = true;
}
}
if (!flag) {
if ((516-(94*(i+1)))+d[0] > 516)
g.drawString("No XP Gained", 516-94-d[0]+3, y2);
else
g.drawString("No XP Gained", 516-94*(i+1)+3, y2);
}
break;
}
}
private int[] getInfoDimension(int i, Graphics g) {
FontMetrics m = g.getFontMetrics();
int h = 5;
int w = 0;
int i2 = 0;
switch(i) {
case 0:
long millis = System.currentTimeMillis() - startTime;
i2 = m.stringWidth("Action: "+action);
if (i2 > w)
w = i2;
i2 = m.stringWidth("RunTime: "+formatTime(millis/3600000)+":"+formatTime(millis/60000-(millis/3600000*60))+":"+formatTime(millis/1000-(millis/3600000*60*60)-(millis/60000*60)));
if (i2 > w)
w = i2;
i2 = m.stringWidth("Location: "+location);
if (i2 > w)
w = i2;
h += m.getHeight() + m.getHeight() + m.getHeight() + 2;
break;
case 1:
for (int i3 = 0; i3 < lootCount.length; i3++) {
i2 = m.stringWidth(getItemName(lootArray[i3])+": "+(bankCount[i3]+lootCount[i3]));
if (i2 > w)
w = i2;
h += m.getHeight();
}
break;
case 2:
boolean flag = false;
for (int i4 = 0; i4 < startExp.length; i4++) {
int xpGained = skills.getCurrentExp(i4) - startExp[i4];
int lvlsGained = skills.getCurrentLevel(i4) - startLevel[i4];
if (xpGained > 0) {
i2 = m.stringWidth(skills.SKILL_NAMES[i4]+": (XP - "+xpGained+") (LVLS - "+lvlsGained+")");
if (i2 > w)
w = i2;
h += m.getHeight();
flag = true;
}
}
if (!flag) {
i2 = m.stringWidth("No XP Gained");
if (i2 > w)
w = i2;
h += m.getHeight();
}
break;
}
int[] i5 = {w+10, h};
return i5;
}
private void drawPaintToggle(Graphics g) {
g.setColor(paintOn ? Color.GREEN : Color.RED);
g.fillOval(689, 215, 20, 20);
g.setColor(paintHover ? Color.WHITE : Color.GRAY);
g.drawOval(689, 215, 20, 20);
}
private String formatTime(long l) {
String s = ""+((int)l);
if (s.length() == 1) {
s = "0"+s;
}
return s;
}
public int loop() {
try {
if (random(0, 5) > 2) {
mouse.setSpeed(random(1, 10));
antiBan();
}
if (pickUpKey()) {
return random(500, 750);
}
if (interfaces.canContinue()) {
interfaces.clickContinue();
}
for (int i = 0; i < lootCount.length; i++)
lootCount[i] = inventory.getCount(true, lootArray[i]);
if (combat.getLifePoints() < (skills.getRealLevel(3) * 10) / 2) {
action = "Eating";
RSItem food = edible();
if (food != null) {
food.doAction("Eat ");
return random(500, 750);
} else if (inventory.getItem(8009) != null) {
action = "Teleporting";
useTab();
lastTileIndex = -1;
return random(3500, 4000);
}
}
if (!getMyPlayer().isMoving()) {
if (stillTime == 0L) {
stillTime = System.currentTimeMillis();
return 0;
}
if (System.currentTimeMillis() - stillTime >= 5000) {
lastTileIndex = -1;
}
} else {
stillTime = 0L;
}
if (BANK.contains(getMyPlayer().getLocation())) {
location = "Bank";
if (!inventory.contains(foodID) || !inventory.contains(8009)) {
action = "Banking";
if (!bank.isOpen()) {
bank.open();
return 0;
}
int[] i = {1590, 8009};
bank.depositAllExcept(i);
for (int i2 = 0; i2 < lootCount.length; i2++) {
bankCount[i2] += lootCount[i2];
lootCount[i2] = 0;
}
sleep(random(1000, 1500));
if (!inventory.contains(8009)) {
if (bank.getCount(8009) < 5 && bank.isOpen()) {
log("No more tabs...");
stopScript(true);
return 0;
}
bank.withdraw(8009, 5);
}
sleep(random(1000, 1500));
if (bank.getCount(foodID) < 5 && bank.isOpen()) {
log("No more food...");
stopScript(true);
return 0;
}
bank.withdraw(foodID, 0);
sleep(random(250, 500));
lastTileIndex = -1;
return 0;
} else {
action = "Walking";
walkPath(BANK_WALL);
return random(250, 500);
}
}
if (WALL.contains(getMyPlayer().getLocation()) || (calc.distanceTo(new RSTile(2936, 3355)) < 5 && getMyPlayer().getLocation().getX() >= 2936)) {
action = "Jumping Wall";
location = "Wall";
handleWall();
lastTileIndex = -1;
return random(1500, 2000);
}
if (BANK_TO_WALL.contains(getMyPlayer().getLocation())) {
action = "Walking";
location = "Path to wall";
if (!inventory.contains(foodID) || !inventory.contains(8009)) {
walkPath(TAB_BANK);
return random(250, 500);
}
walkPath(BANK_WALL);
return random(250, 500);
}
if(WALL_TO_LADDER.contains(getMyPlayer().getLocation())) {
location = "Wall to ladder";
if (calc.distanceTo(new RSTile(2884, 3398)) < 5) {
action = "Climbing Ladder";
handleLadder();
lastTileIndex = -1;
return random(1500, 2000);
}
action = "Walking";
walkPath(WALL_LADDER);
return random(250, 500);
}
if (GATE.contains(getMyPlayer().getLocation())) {
location = "Gate";
action = "Opening Gate";
handleGate();
lastTileIndex = -1;
return random(1500, 2000);
}
if (PIPE.contains(getMyPlayer().getLocation())) {
if (skills.getCurrentLevel(16) >= 70) {
walking.walkTileMM(new RSTile(2886, 9799));
handlePipe();
} else {
location = "Path to gate";
action = "Walking";
walkPath(LADDER_GATE);
return random(250, 500);
}
}
if (isInDragonArea()) {
location = "Dragons";
action = "Walking";
walkPath(GATE_DEMON);
return 0;
}
if (getMyPlayer().getLocation().getX() >= 2881 && getMyPlayer().getLocation().getY() >= 8500) {
location = "Path to gate";
action = "Walking";
walkPath(LADDER_GATE);
return random(250, 500);
}
if (FALADOR.contains(getMyPlayer().getLocation())) {
location = "Falador";
if (walkPath(TAB_BANK)) {
action = "Walking";
return random(750, 1000);
}
return random(750, 1000);
}
if (!inventory.contains(foodID)) {
action = "Teleporting";
useTab();
lastTileIndex = -1;
return random(3500, 4000);
}
if (DEMONS.contains(getMyPlayer().getLocation())) {
location = "Demons";
RSGroundItem loot = groundItems.getNearest(lootArray);
if (loot != null) {
action = "Looting";
if (players.getMyPlayer().isMoving()) {
return random(400, 600);
}
if (inventory.isFull() && ((itemIsStackable(loot.getItem().getID()) && !inventory.contains(loot.getItem().getID())) || !itemIsStackable(loot.getItem().getID())) ) {
if (edible() != null) {
edible().doAction("Eat");
return random(800, 1000);
}
} else {
if (!loot.isOnScreen()) {
camera.turnToTile(loot.getLocation(), 15);
if (!loot.isOnScreen()) {
walking.walkTileMM(walking.getClosestTileOnMap(loot.getLocation()));
return random(900, 1200);
}
}
loot.doAction("Take " + loot.getItem().getName());
return random(900, 1100);
}
}
if (!getMyPlayer().isInCombat() && getMyPlayer().getInteracting() == null) {
action = "Attacking";
RSNPC npc = getNearestNPC(BLACK_DEMON);
if (npc == null)
return random(250, 750);
if (players.getMyPlayer().isMoving() && !npc.isOnScreen()) {
return random(400, 600);
}
if (!npc.isOnScreen()) {
turnTo(camera.getCharacterAngle(npc), npc);
if (!npc.isOnScreen()) {
walking.walkTileMM(walking.getClosestTileOnMap(npc.getLocation()));
return random(800, 1000);
}
}
npc.doAction("Attack " + npc.getName());
return random(750, 1000);
} else {
action = "Fighting";
}
} else {
location = "Undefined";
walkPath(LADDER_GATE);
}
} catch(Exception e) {}
return 100;
}
private Image getImage(String fileName) {
File[] files = {
new File(GlobalConfiguration.Paths.getScriptsDirectory() + "/DMdata"),
new File(GlobalConfiguration.Paths.getScriptsDirectory() + "/DMdata/images"),
};
for (File file : files)
if (!file.exists())
file.mkdir();
try {
File f = new File(GlobalConfiguration.Paths.getScriptsDirectory() + "/DMdata/images/" + fileName);
if(f.exists())
return ImageIO.read(f.toURI().toURL());
Image img = ImageIO.read(new URL("http://outstream.webs.com/RSBot/DemonMurder/" + fileName));
if(img != null) {
ImageIO.write((RenderedImage)img, "PNG", f);
return img;
}
} catch(IOException e) {
}
return null;
}
private void antiBan() {
int random = random(1, 5);
switch (random) {
case 1:
if (random(1, 25) != 1)
return;
mouse.move(random(10, 750), random(10, 495));
return;
case 2:
if (random(1, 6) != 1)
return;
int angle = camera.getAngle() + random(-45, 45);
if (angle < 0) {
angle = random(0, 10);
}
if (angle > 359) {
angle = random(0, 10);
}
char whichDir = 37; //left
if (random(0,100) < 50)
whichDir = 39; //right
keyboard.pressKey(whichDir);
sleep(random(100,500));
keyboard.releaseKey(whichDir);
return;
case 3:
if (random(1, 15) != 1)
return;
mouse.moveSlightly();
return;
default:
return;
}
}
private RSNPC getNearestNPC(int[] NPCs) {
RSNPC finalNPC = npcs.getNearest(NPCs);
int distance = 99;
for (int i = 0; i < NPCs.length; i++) {
RSNPC npc = npcs.getNearest(NPCs[i]);
if (npc == null)
continue;
if (calc.distanceTo(npc) < distance) {
if (!npc.isInCombat()) {
distance = calc.distanceTo(npc);
finalNPC = npc;
}
}
}
return finalNPC;
}
private boolean itemIsStackable(int i) {
switch(i) {
case 12160:
case 12158:
case 12159:
case 12163:
return true;
default:
return false;
}
}
private RSItem edible() {
RSItem[] is = inventory.getItems();
for (RSItem i : is) {
if (i.getComponent().getActions() == null || i.getComponent().getActions()[0] == null) {
continue;
}
if (i.getComponent().getActions()[0].contains("Eat")) {
return i;
}
}
return null;
}
public void turnTo(int degrees, RSNPC n) {
char left = 37;
char right = 39;
char whichDir = left;
int start = camera.getAngle();
if (start < 180) {
start += 360;
}
if (degrees < 180) {
degrees += 360;
}
if (degrees > start) {
if (degrees - 180 < start) {
whichDir = right;
}
} else if (start > degrees) {
if (start - 180 >= degrees) {
whichDir = right;
}
}
degrees %= 360;
keyboard.pressKey(whichDir);
int timeWaited = 0;
while (!n.isOnScreen() && camera.getAngle() > degrees + 10 || !n.isOnScreen() && camera.getAngle() < degrees - 10) {
sleep(10);
timeWaited += 10;
if (timeWaited > 500) {
int time = timeWaited - 500;
if (time == 0) {
keyboard.pressKey(whichDir);
} else if (time % 40 == 0) {
keyboard.pressKey(whichDir);
}
}
}
keyboard.releaseKey(whichDir);
}
private boolean isInDragonArea() {
int x = getMyPlayer().getLocation().getX();
int y = getMyPlayer().getLocation().getY();
return (x < 2924 && x > 2890 && y > 9793 && y < 9813) || (y < 9795 && y > 9763 && x > 2878 && x < 2903);
}
private boolean walkPath(RSTilePath path) {
if (!walking.isRunEnabled() && walking.getEnergy() > 50) {
walking.setRun(true);
while(!walking.isRunEnabled());
sleep(300);
}
RSTile[] t = path.toArray();
try {
RSTile tile = getNextTile(t);
if (calc.tileOnMap(tile)) {
walking.walkTileMM(tile);
return false;
}
} catch(Exception e) {}
return walking.getDestination() != null;
}
private RSTile getNextTile(RSTile[] t) {
RSTile tile = null;
int index = -1;
for (int i = t.length - 1; i >= 0; --i) {
if (calc.tileOnMap(t[i]) && i > lastTileIndex) {
tile = t[i];
index = i;
}
}
if (index != -1)
lastTileIndex = index;
return tile;
}
private boolean useTab() {
if (FALADOR.contains(getMyPlayer().getLocation()))
return true;
try {
return inventory.getItem(8009).doAction("Break");
} catch(Exception e) {}
return false;
}
public void onFinish() {
try {
inventory.getItem(8009).doAction("Break");
} catch(Exception e) {}
}
private boolean pickUpKey() {
try {
RSGroundItem key = groundItems.getNearest(1590);
return key.doAction("Take Dusty Key");
} catch(Exception e) {}
return false;
}
private boolean handleWall() {
try {
RSObject wall = objects.getNearest(11844);
return wall.doAction("Climb-over");
} catch(Exception e) {}
return false;
}
private boolean handlePipe() {
try {
RSObject ladder = objects.getNearest(9293);
return ladder.doAction("Squeeze");
} catch(Exception e) {}
return false;
}
private boolean handleLadder() {
try {
RSObject ladder = objects.getNearest(55404);
return ladder.doAction("Climb");
} catch(Exception e) {}
return false;
}
private boolean handleGate() {
try {
RSItem key = inventory.getItem(1590);
RSObject gate = objects.getNearest(2623);
return inventory.useItem(key, gate);
} catch(Exception e) {}
return false;
}
public void mouseMoved(MouseEvent e) {
cursor = e.getPoint();
int x = (int)e.getPoint().getX();
int y = (int)e.getPoint().getY();
for (int i = 0; i < buttonHover.length; i++) {
buttonHover[i] = (x > 516-(i+1)*94 && y > 307 && x < 516-(i*94) && y < 339);
}
}
public void mouseDragged(MouseEvent e) {
cursor = e.getPoint();
int x = (int)e.getPoint().getX();
int y = (int)e.getPoint().getY();
buttonHover[0] = (x > 422 && y > 307 && x < 516 && y < 339);
buttonHover[1] = (x > 328 && y > 307 && x < 422 && y < 339);
paintHover = (x > 689 && y > 215 && x < 709 && y < 245);
}
public void mousePressed(MouseEvent e) {
int x = (int)e.getPoint().getX();
int y = (int)e.getPoint().getY();
int index = -1;
for (int i = 0; i < buttonClick.length; i++) {
if (x > 516-(i+1)*94 && y > 307 && x < 516-(i*94) && y < 339) {
buttonClick[i] = !buttonClick[i];
if (buttonClick[i] == true)
index = i;
}
}
if (index != -1)
for (int i = 0; i < buttonClick.length; i++)
if (i != index)
buttonClick[i] = false;
}
public void mouseClicked(MouseEvent e) {}
public void mouseReleased(MouseEvent e) {}
public void mouseEntered(MouseEvent e) {}
public void mouseExited(MouseEvent e) {}
public boolean checkForUpdates() {
try {
/* Get the current version from the Script Manifest annotation defined at the top of your script's class */
double currentVer = BlackDemonMurder.class.getAnnotation(ScriptManifest.class).version();
double newVer = -1;
URL url = new URL(UPDATER_URL);
/* Open a stream to the newest script file hosted on your server */
BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream()));
String line, lines = "";
Matcher m;
/* Look for the "version = x.x" string in the newer file to figure out the newest version number */
while((line = in.readLine()) != null) {
lines += line + "\n";
if((m = UPDATER_VERSION_PATTERN.matcher(line)).find()) {
newVer = Double.parseDouble(m.group(1));
break;
}
}
/* Check if the updater was unable to read the newest version number */
if(newVer < 0) {
in.close();
log("Unable to find the new version number. Update failed");
return false;
}
/* Compare the current version to the newest. */
if(currentVer == newVer) {
in.close();
log("You already have the latest version of the script.");
return false;
}
/* The current version is less than the newest version, so we need to download it */
log("Update found! Downloading version " + newVer);
/* Figure out where to save the file */
String scriptFilePath = GlobalConfiguration.Paths.getScriptsSourcesDirectory()+"\\" + UPDATER_FILE_NAME;
PrintWriter out = new PrintWriter(scriptFilePath);
/* Print the cached lines from the version checking */
out.print(lines);
/* Print the rest of the file */
while((line = in.readLine()) != null)
out.println(line);
/* Close the streams */
out.close();
in.close();
log("Successfully saved " + UPDATER_FILE_NAME + " to " + GlobalConfiguration.Paths.getScriptsSourcesDirectory());log("Compiling...");
try {
/* Attempt to compile the downloaded version */
Runtime.getRuntime().exec(new String[] {
"javac",
"-classpath",
"RSBot.jar",
scriptFilePath
});
} catch (Exception ex) {
log("Could not compile the script. Please manually compile to finish the update.");
return false;
}
log("Update successful!");
log("The new version will appear near the bottom of the script selector.");
log("Stop and restart the script to run the newer version.");
return true;
} catch(IOException e) {
log(e.toString());
log("Update failed.");
}
return false;
}
private static final String UPDATER_FILE_NAME = "BlackDemonMurder.java";
private static final String UPDATER_URL = "http://outstream.webs.com/RSBot/DemonMurder/BlackDemonMurder.java";
private static final Pattern UPDATER_VERSION_PATTERN = Pattern.compile("version\\s*=\\s*([0-9.]+)");
private class gui extends javax.swing.JFrame {
public gui(BlackDemonMurder script) {
bdm = script;
initComponents();
}
@SuppressWarnings("unchecked")
private void initComponents() {
jToggleButton1 = new javax.swing.JToggleButton();
jTextField1 = new javax.swing.JTextField();
jLabel1 = new javax.swing.JLabel();
jButton1 = new javax.swing.JButton();
jCheckBox2 = new javax.swing.JCheckBox();
jCheckBox1 = new javax.swing.JCheckBox();
jLabel2 = new javax.swing.JLabel();
jCheckBox3 = new javax.swing.JCheckBox();
jScrollPane1 = new javax.swing.JScrollPane();
jTextArea1 = new javax.swing.JTextArea();
jButton3 = new javax.swing.JButton();
jToggleButton1.setText("Start");
jToggleButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jToggleButton1ActionPerformed(evt);
}
});
jLabel1.setText("FoodID:");
jButton1.setText("Check for Updates");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
jCheckBox2.setText("Herbs");
jCheckBox1.setText("Charms");
jLabel2.setText("Loot:");
jCheckBox3.setText("Ashes");
jTextArea1.setEditable(false);
jTextArea1.setText(getChangeLog("http://outstream.webs.com/RSBot/DemonMurder/changelog.txt"));
jScrollPane1.setViewportView(jTextArea1);
jButton3.setText("Use Last Settings");
jButton3.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton3ActionPerformed(evt);
}
});
jButton3.setEnabled(new File(GlobalConfiguration.Paths.getScriptsDirectory() + "/DMdata/settings.data").exists());
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel2)
.addGap(18, 18, 18)
.addComponent(jCheckBox1)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jCheckBox2)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jCheckBox3)
.addContainerGap(97, Short.MAX_VALUE))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 303, Short.MAX_VALUE)
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
.addComponent(jLabel1)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(17, 17, 17)
.addComponent(jButton1, javax.swing.GroupLayout.DEFAULT_SIZE, 137, Short.MAX_VALUE))
.addGroup(layout.createSequentialGroup()
.addComponent(jToggleButton1, javax.swing.GroupLayout.DEFAULT_SIZE, 150, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jButton3, javax.swing.GroupLayout.PREFERRED_SIZE, 147, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addContainerGap())))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel1)
.addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jButton1))
.addGap(11, 11, 11)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel2)
.addComponent(jCheckBox1)
.addComponent(jCheckBox2)
.addComponent(jCheckBox3))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 140, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jToggleButton1)
.addComponent(jButton3))
.addContainerGap())
);
pack();
}
public Object[] getData() {
if (!loadFromFile) {
int i = 0;
try {
i = Integer.parseInt(jTextField1.getText());
} catch(Exception e) {
log("Something wrong with the foodID");
stopScript(true);
return null;
}
return new Object[] {
jCheckBox1.isSelected(),
jCheckBox2.isSelected(),
jCheckBox3.isSelected(),
i
};
}
return bdm.getData(new File(GlobalConfiguration.Paths.getScriptsDirectory() + "/DMdata/settings.data"));
}
private String getChangeLog(String s) {
try {
/*BufferedReader in = new BufferedReader(new InputStreamReader((new URL(s)).openStream()));
String line = in.readLine();
in.close();
return line.replaceAll("\n", System.getProperty("line.separator"));*/
} catch(Exception e) {log("Unable to get Changelog");}
return "Unable to get Changelog";
}
private void jToggleButton1ActionPerformed(java.awt.event.ActionEvent evt) {
setVisible(false);
}
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
if (bdm.checkForUpdates()) {
log("Update complete, please rerun the script.");
bdm.stopScript(false);
}
}
private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {
loadFromFile = true;
setVisible(false);
}
private BlackDemonMurder bdm;
private boolean loadFromFile = false;
private javax.swing.JButton jButton1;
private javax.swing.JButton jButton3;
private javax.swing.JCheckBox jCheckBox1;
private javax.swing.JCheckBox jCheckBox2;
private javax.swing.JCheckBox jCheckBox3;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JTextArea jTextArea1;
private javax.swing.JTextField jTextField1;
private javax.swing.JToggleButton jToggleButton1;
}
public String getItemName(int id) {
switch(id) {
case 1113:
return "Rune Chainbody";
case 1147:
return "Rune Med Helm";
case 12158:
return "Gold Charm";
case 12160:
return "Chrimson Charm";
case 12163:
return "Blue Charm";
case 12159:
return "Green Charm";
case 207:
return "Grimy Ranarr";
case 20268:
return "Infernal Ashes";
case 217:
return "Grimy Dwarf Weed";
case 18778:
return "Starved Effigy";
default:
return "Unknown item";
}
}
private final static RSTile[] TAB_BANK_PATH = {
new RSTile(2961, 3381), new RSTile(2951, 3377),
new RSTile(2945, 3371),
};
private final static RSTile[] GATE_DEMON_PATH = {
new RSTile(2911, 9797), new RSTile(2901, 9797),
new RSTile(2892, 9790), new RSTile(2892, 9778),
new RSTile(2885, 9770), new RSTile(2876, 9775),
};
private final static RSTile[] LADDER_GATE_PATH = {
new RSTile(2884, 9807), new RSTile(2884, 9819),
new RSTile(2884, 9833), new RSTile(2888, 9846),
new RSTile(2895, 9849), new RSTile(2903, 9848),
new RSTile(2916, 9849), new RSTile(2927, 9842),
new RSTile(2937, 9833), new RSTile(2937, 9820),
new RSTile(2940, 9807), new RSTile(2950, 9795),
new RSTile(2952, 9779), new RSTile(2941, 9777),
new RSTile(2933, 9765), new RSTile(2922, 9756),
new RSTile(2926, 9770), new RSTile(2930, 9778),
new RSTile(2933, 9785), new RSTile(2930, 9798),
new RSTile(2924, 9803),
};
private final static RSTile[] WALL_LADDER_PATH = {
new RSTile(2923, 3362), new RSTile(2913, 3373),
new RSTile(2903, 3381), new RSTile(2898, 3383),
new RSTile(2890, 3392), new RSTile(2884, 3398),
};
private final static RSTile[] BANK_WALL_PATH = {
new RSTile(2945, 3370), new RSTile(2940, 3372),
new RSTile(2940, 3366), new RSTile(2940, 3357),
new RSTile(2936, 3355),
};
private final static RSArea FALADOR = new RSArea(new RSTile(3066, 3308), new RSTile(2935, 3395));
private final static RSTile[] DRAGON_AREA = {
new RSTile(2890, 9813), new RSTile(2924, 9794),
new RSTile(2924, 9813), new RSTile(2892, 9813),
};
private final static RSArea DRAGON = new RSArea(DRAGON_AREA);
private final static RSTile[] GATE_AREA = {
new RSTile(2924, 9805), new RSTile(2924, 9800),
new RSTile(2932, 9805), new RSTile(2932, 9800),
};
private final static RSArea GATE = new RSArea(GATE_AREA);
private final static RSTile[] WALL_TO_LADDER_AREA = {
new RSTile(2935, 3353), new RSTile(2882, 3353),
new RSTile(2882, 3401), new RSTile(2935, 3401),
};
private final static RSArea WALL_TO_LADDER = new RSArea(WALL_TO_LADDER_AREA);
private final static RSTile[] BANK_AREA = {
new RSTile(2949, 3368), new RSTile(2949, 3373),
new RSTile(2943, 3373), new RSTile(2943, 3368),
};
private final static RSArea BANK = new RSArea(BANK_AREA);
private final static RSArea BANK_TO_WALL = new RSArea(new RSTile(2936, 3354), new RSTile(2942, 3376));
private final static RSTile[] WALL_AREA = {
new RSTile(2936, 3355), new RSTile(2940, 3353),
new RSTile(2940, 3357), new RSTile(2936, 3357),
};
private final static RSArea HILLS = new RSArea(new RSTile(2898, 9713), new RSTile(2937, 9763));
private final static RSArea PIPE = new RSArea(new RSTile(2881, 9794), new RSTile(2886, 9801));
private final static RSArea DEMONS = new RSArea(new RSTile(2849, 9761), new RSTile(2877, 9787));
private String location;
private int foodID;
private static boolean[] buttonHover;
private static boolean[] buttonClick;
private static int[] startExp, startLevel;
private static Image button;
private static Point cursor;
private long startTime;
private final double HALF_PI = Math.PI*0.5, THREE_HALF_PI = Math.PI*1.5;
private static int clockPoint;
private static Point mouseClick;
private static String action;
private static boolean paintOn;
private static boolean paintHover;
private final static Color backGround = new Color(0, 0, 0, 180);
private static RSArea WALL = new RSArea(WALL_AREA);
private static RSTilePath BANK_WALL;
private static RSTilePath WALL_LADDER;
private static RSTilePath LADDER_GATE;
private static RSTilePath GATE_DEMON;
private static RSTilePath TAB_BANK;
private long stillTime;
private static int[] lootArray;
private static int[] lootCount;
private static int[] bankCount;
private final static int[] BLACK_DEMON = {84, 4703, 4702, 4704, 4705};
private int lastTileIndex;
}