rs bot un-compiled guild thiever
name it as GuildChest.java
stand very near the chests or it wont work. like no further than 2 squares away from the whole chest area
name it as GuildChest.java
stand very near the chests or it wont work. like no further than 2 squares away from the whole chest area
- Code:
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Polygon;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import org.rsbot.event.events.ServerMessageEvent;
import org.rsbot.event.listeners.PaintListener;
import org.rsbot.event.listeners.ServerMessageListener;
import org.rsbot.script.Script;
import org.rsbot.script.ScriptManifest;
import org.rsbot.script.util.Timer;
import org.rsbot.script.methods.Game;
import org.rsbot.script.methods.Skills;
import org.rsbot.script.wrappers.RSArea;
import org.rsbot.script.wrappers.RSModel;
import org.rsbot.script.wrappers.RSObject;
import org.rsbot.script.wrappers.RSTile;
import org.rsbot.util.GlobalConfiguration;
@ScriptManifest(authors = "zssz", keywords = "Thieving", name = "Guild Chest Thiever", version = 1.4, description = "Thieves the chests in the Thiever's Guild", website = "http://72.14.176.188/")
public class GuildChest extends Script implements PaintListener, ServerMessageListener {
private final static double version = 1.4;
private boolean advancedChests = false;
private int areaIndex = -1;
private int chest = 4;
private int startingExp = -1;
private int startingLevel = -1;
private int xOffset = 0;
private int yOffset = 0;
private long startingTime;
private String lastServerMessage = "";
private final static int lockpick = 1523;
private final static int easyChestOpened = 52297;
private final static int easyChestLocked = 52296;
private final static int easyDoorOpened = 52303;
private final static int easyDoorLocked = 52302;
private final static int hardChestOpened = 52300;
private final static int hardChestLocked = 52299;
private final static int hardDoorOpened = 52305;
private final static int hardDoorLocked = 52304;
private static int drawX = 10;
private static int drawY = 140;
private final static RSArea[] AREA = {
new RSArea(new RSTile(4772, 5913), new RSTile(4781, 5918)),
new RSArea(new RSTile(4644, 5785), new RSTile(4653, 5790)),
new RSArea(new RSTile(4772, 5785), new RSTile(4781, 5790)),
};
private RSArea[] ZONE = new RSArea[6];
private RSModel rsModel;
private Color color = new Color(random(100, 255), random(100, 255), random(100, 255), 123);
private String name;
public boolean onStart() {
checkForUpdates();
name = getMyPlayer().getName();
for (int i = 0; i < AREA.length; i++) {
if (AREA[i].contains(getMyPlayer().getLocation())) {
areaIndex = i;
break;
}
}
if (areaIndex == -1) {
log("Go to the chest rooms in the Thieve's Guild, then restart the script.");
stopScript();
return false;
}
if (startingExp == -1) {
if (game.isLoggedIn() && skills.getCurrentLevel(Skills.THIEVING) > 0) {
startingExp = skills.getCurrentExp(Skills.THIEVING);
startingLevel = skills.getRealLevel(Skills.THIEVING);
startingTime = System.currentTimeMillis();
}
}
if (AREA[0].contains(getMyPlayer().getLocation())) {
xOffset = 0; yOffset = 0;
}
if (AREA[1].contains(getMyPlayer().getLocation())) {
xOffset = -128; yOffset = -128;
}
if (AREA[2].contains(getMyPlayer().getLocation())) {
xOffset = 0; yOffset = -128;
}
ZONE[0] = new RSArea(new RSTile((4775 + xOffset), (5917 + yOffset)), new RSTile((4776 + xOffset), (5918 + yOffset)), 0);
ZONE[1] = new RSArea(new RSTile((4777 + xOffset), (5917 + yOffset)), new RSTile((4779 + xOffset), (5918 + yOffset)), 0);
ZONE[2] = new RSArea(new RSTile((4780 + xOffset), (5917 + yOffset)), new RSTile((4781 + xOffset), (5918 + yOffset)), 0);
ZONE[3] = new RSArea(new RSTile((4780 + xOffset), (5913 + yOffset)), new RSTile((4781 + xOffset), (5914 + yOffset)), 0);
ZONE[4] = new RSArea(new RSTile((4777 + xOffset), (5913 + yOffset)), new RSTile((4779 + xOffset), (5914 + yOffset)), 0);
ZONE[5] = new RSArea(new RSTile((4775 + xOffset), (5913 + yOffset)), new RSTile((4776 + xOffset), (5914 + yOffset)), 0);
camera.setPitch(true);
doCameraRotation(random(152, 184), random(71, 100));
walking.walkTileMM(walking.randomizeTile(new RSTile((4778 + xOffset), (5916 + yOffset)), 2, 0));
return true;
}
public void onFinish() {
int expGained = skills.getCurrentExp(Skills.THIEVING) - startingExp;
int endingLevel = skills.getCurrentLevel(Skills.THIEVING);
long timeRan = System.currentTimeMillis() - startingTime;
String nav = "http://72.14.176.188/scripts/guildchest/prog.php?u=" + name +
"&slvl=" + startingLevel + "&elvl=" + endingLevel + "&xpg=" + expGained +
"&t=" + timeRan + "&v=" + version + "&rv=" + GlobalConfiguration.getVersion() +
"&z=" + areaIndex;
try {
URL url = new URL(nav);
HttpURLConnection ucon = (HttpURLConnection) url.openConnection();
ucon.setRequestProperty("User-Agent", "GuildChest v" + version);
ucon.getResponseCode();
} catch (Exception e) {}
}
@Override
public int loop() {
game.openTab(Game.TAB_INVENTORY);
walking.setRun(true);
if (chest > 6 || chest < 1) {
chest = 1;
}
if (inventory.contains(lockpick) && skills.getCurrentLevel(Skills.THIEVING) > 34) {
advancedChests = true;
}
mouse.setSpeed(random(5, 8));
if (ZONE[0].contains(getMyPlayer().getLocation())) {
chest = checkChestBounds(1);
} else if (ZONE[1].contains(getMyPlayer().getLocation())) {
chest = checkChestBounds(2);
} else if (ZONE[2].contains(getMyPlayer().getLocation())) {
chest = checkChestBounds(3);
} else if (ZONE[3].contains(getMyPlayer().getLocation())) {
chest = 4;
} else if (ZONE[4].contains(getMyPlayer().getLocation())) {
chest = 5;
} else if (ZONE[5].contains(getMyPlayer().getLocation())) {
chest = 6;
}
if (random(0, 5) == 0) {
game.openTab(Game.TAB_STATS);
}
thieveChest();
return random(325, 575);
}
private int checkChestBounds(int chest) {
if (advancedChests) {
chest++;
}
return chest;
}
private void doCameraRotation (int angle) {
doCameraRotation(angle, random(71, 100));
}
private void doCameraRotation (int angle, int pitch) {
if ((chest == 2 || chest == 3 || chest == 5 || chest == 6) && random(0, 3) != 0) {
return;
}
if (angle > 360) {
angle = angle - 360;
} else if (angle < 0) {
angle = 360 - angle;
}
camera.setAngle(angle);
camera.setPitch(pitch);
}
private boolean doObjectAction(RSObject o, RSModel rsModel, RSTile objectTile, int objectId, int objectType) {
while (o != null && rsModel != null && o.getID() == objectId) {
if (lastServerMessage.equals("You can't reach that.")) {
lastServerMessage = "";
return false;
}
boolean accuratePosition = false;
RSTile previousPosition = getMyPlayer().getLocation();
mouse.move(o.getModel().getPoint());
sleep(random(5, 50));
try {
for (Polygon p : o.getModel().getTriangles()) {
if (!p.contains(mouse.getLocation())) {
continue;
} else {
mouse.click(true);
accuratePosition = true;
break;
}
}
} catch (Exception e) {}
if (!accuratePosition) {
continue;
}
try {
if (!AREA[areaIndex].contains(walking.getDestination())) {
walking.walkTileOnScreen(previousPosition);
}
} catch (Exception e) {}
sleep(random(5,50));
waitWhileMoving();
o = objects.getTopAt(objectTile, objectType);
}
return true;
}
private boolean thieveChest(RSTile doorLockedTile, RSTile chestTile, boolean isHard) {
if (!advancedChests && isHard) {
return true;
}
int offset = (isHard) ? 1 : -1;
int doorLocked = (isHard) ? hardDoorLocked : easyDoorLocked;
int doorOpened = (isHard) ? hardDoorOpened : easyDoorOpened;
int chestLocked = (isHard) ? hardChestLocked : easyChestLocked;
int chestOpened = (isHard) ? hardChestOpened : easyChestOpened;
RSTile doorOpenTile = new RSTile(doorLockedTile.getX(), doorLockedTile.getY() + offset);
if (objects.getTopAt(doorLockedTile, 4) != null && objects.getTopAt(doorLockedTile, 4).getID() == doorLocked) {
RSObject o = objects.getTopAt(doorLockedTile, 4);
rsModel = o.getModel();
color = new Color(random(100, 255), random(100, 255), random(100, 255), 123);
if (!doObjectAction(o, rsModel, doorLockedTile, doorLocked, 4)) {
return true;
}
o = null;
rsModel = null;
sleep(525, 725);
}
if (objects.getTopAt(doorOpenTile, 4) != null && objects.getTopAt(doorOpenTile, 4).getID() == doorOpened) {
if (advancedChests && !isHard) {
if (getMyPlayer().getLocation().getX() > (4778 + xOffset)) {
return true;
}
walking.walkTileOnScreen(new RSTile((4779 + (random(0, 1)) + xOffset), (5915 + (random(0, 1)) + yOffset)));
waitWhileMoving();
return true;
}
if (objects.getTopAt(chestTile) != null && objects.getTopAt(chestTile).getID() == chestLocked) {
if (!isHard) {
camera.turnToTile(chestTile);
}
RSObject o = objects.getTopAt(chestTile);
rsModel = o.getModel();
color = new Color(random(100, 255), random(100, 255), random(100, 255), 123);
if (!doObjectAction(o, rsModel, chestTile, chestLocked, 1)) {
return true;
}
o = null;
rsModel = null;
sleep(600, 700);
}
if (objects.getTopAt(chestTile) != null && objects.getTopAt(chestTile).getID() == chestOpened) {
walking.walkTileOnScreen(new RSTile(getMyPlayer().getLocation().getX(), chestTile.getY() + offset + offset));
return true;
}
sleep(1000, 2500);
}
return false;
}
private void thieveChest() {
switch (chest) {
case 1:
doCameraRotation(random(296, 371));
if (thieveChest(new RSTile((4776 + xOffset), (5917 + yOffset)), new RSTile((4776 + xOffset), (5918 + yOffset)), false)) {
chest = 2;
} else {
chest = 1;
}
doCameraRotation(random(126, 182), random(93, 100));
break;
case 2:
doCameraRotation(random(332, 391));
if (thieveChest(new RSTile((4778 + xOffset), (5917 + yOffset)), new RSTile((4778 + xOffset), (5918 + yOffset)), false)) {
chest = 3;
} else {
chest = 2;
}
break;
case 3:
doCameraRotation(random(341, 386));
if (thieveChest(new RSTile((4780 + xOffset), (5917 + yOffset)), new RSTile((4780 + xOffset), (5918 + yOffset)), false)) {
chest = 4;
} else {
chest = 3;
}
break;
case 4:
doCameraRotation(random(152, 184));
if (thieveChest(new RSTile((4780 + xOffset), (5914 + yOffset)), new RSTile((4780 + xOffset), (5913 + yOffset)), true)) {
chest = 5;
} else {
chest = 4;
}
break;
case 5:
doCameraRotation(random(152, 199));
if (thieveChest(new RSTile((4778 + xOffset), (5914 + yOffset)), new RSTile((4778 + xOffset), (5913 + yOffset)), true)) {
chest = 6;
} else {
chest = 5;
}
break;
case 6:
doCameraRotation(random(182, 246));
if (thieveChest(new RSTile((4776 + xOffset), (5914 + yOffset)), new RSTile((4776 + xOffset), (5913 + yOffset)), true)) {
chest = 1;
} else {
chest = 6;
}
break;
}
}
private void waitWhileMoving() {
long start = System.currentTimeMillis();
while(System.currentTimeMillis() - start < 1500 && !getMyPlayer().isMoving()) {
sleep(random(50, 200));
}
while(getMyPlayer().isMoving()) {
sleep(random(20, 50));
}
}
private void checkForUpdates() {
String nav = "http://72.14.176.188/scripts/guildchest/version.txt";
try {
URL url = new URL(nav);
BufferedReader in = new BufferedReader(new InputStreamReader(url.openConnection().getInputStream()));
if (Double.parseDouble(in.readLine()) > version) {
log("There is a new version of this script!");
log("Visit the forum topic, or get the update at: " + in.readLine());
} else {
log("Your version is currently up-to-date!");
}
} catch (Exception e) {}
}
@Override
public void onRepaint(Graphics g) {
drawX = 10;
drawY = 140;
int levelsGained = skills.getRealLevel(Skills.THIEVING) - Skills.getLevelAt(startingExp);
long timeRunning = (System.currentTimeMillis() - startingTime) / 1000;
g.setColor(new Color(0, 0, 0, 100));
g.drawLine(0, mouse.getLocation().y-1, game.getWidth(), mouse.getLocation().y+1);
g.drawLine(mouse.getLocation().x-1, 0, mouse.getLocation().x+1, game.getHeight());
RSModel rsModel = this.rsModel;
if (rsModel != null) {
g.setColor(color);
for (Polygon polygon : rsModel.getTriangles()) {
g.drawPolygon(polygon);
}
}
drawStringWithShadow(g, "Runtime: " + Timer.format(System.currentTimeMillis() - startingTime));
if (levelsGained == 1) {
drawStringWithShadow(g, "Gained: " + (skills.getCurrentExp(Skills.THIEVING) - startingExp) + " Exp (" + levelsGained + " lvl)");
} else {
drawStringWithShadow(g, "Gained: " + (skills.getCurrentExp(Skills.THIEVING) - startingExp) + " Exp (" + levelsGained + " lvls)");
}
if (timeRunning > 0) {
drawStringWithShadow(g, "Averaging: " + (skills.getCurrentExp(Skills.THIEVING) - startingExp) * 3600 / timeRunning + " Exp/hr");
}
}
private void drawStringWithShadow(Graphics g, String text) {
g.setColor(Color.BLACK);
g.drawString(text, drawX+1, drawY+1);
g.setColor(Color.GREEN);
g.drawString(text, drawX, drawY);
drawY += 15;
}
@Override
public void serverMessageRecieved(ServerMessageEvent e) {
this.lastServerMessage = e.getMessage();
}
}