Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.awt.*;
- import java.awt.event.*;
- import java.awt.image.BufferedImage;
- import java.awt.image.RenderedImage;
- import java.io.BufferedReader;
- import java.io.File;
- import java.io.IOException;
- import java.io.InputStreamReader;
- import java.lang.reflect.InvocationTargetException;
- import java.net.URI;
- import java.net.URL;
- import java.net.URLConnection;
- import java.util.*;
- import java.util.logging.Logger;
- import org.rsbot.Configuration;
- import javax.imageio.ImageIO;
- import javax.swing.*;
- import javax.swing.border.*;
- import com.rarebot.event.events.*;
- import com.rarebot.event.listeners.*;
- import com.rarebot.script.*;
- import com.rarebot.script.methods.*;
- import com.rarebot.script.methods.Game.ChatButton;
- import com.rarebot.script.methods.Game.Tab;
- import com.rarebot.script.wrappers.*;
- @ScriptManifest(authors = { "Fuser" }, keywords = { "Combat", "Giant", "Spider", "Fuser" }, name = "Giant Spider Fuser", version = 2.6, description = "Lets Max out Combat!")
- public class GiantSpiderFuser extends Script implements PaintListener, MessageListener, MouseListener {
- public double getVersion() {
- return getClass().getAnnotation(ScriptManifest.class).version();
- }
- public String scriptName = "Giant Spider Fuser";
- public String author = "Fuser";
- private int foodID;
- private int eatingValue[];
- private int arrow;
- private int potions[] = { 0, 0, 0, 0, 0 };
- private int amounts[] = { 1, 1, 1, 1, 1 };
- private int currentRoom;
- private int tries;
- private int objTries;
- private int bankTab = -1;
- private int stats[][];
- private int trainedSkill = -1;
- private int mouseSpeed1;
- private long startTime;
- long lastTime = System.currentTimeMillis();
- int nextWait = 30000;
- GSFGUI gui = new GSFGUI();
- updateChecker uc = new updateChecker();
- public boolean GuiIsOpen = true;
- boolean guiClosed;
- private boolean enableTeleporting;
- private boolean changeRooms;
- private boolean useTablets;
- private boolean enableRange;
- private boolean noArrowsLeft;
- private boolean atSpiders;
- private boolean needBank;
- String status;
- Rectangle close = new Rectangle(405, 5, 111, 26);
- Point p;
- boolean hide = false;
- private RSTile myTile;
- private RSTile bankTile;
- private final RSTile edgeTile = new RSTile(3094, 3491);
- private final RSTile varrockTile = new RSTile(3189, 3437);
- private final RSTile entranceTile = new RSTile(3081, 3421);
- private final RSTile caveToVarrockTiles[] = { new RSTile(3081, 3421),
- new RSTile(3087, 3420), new RSTile(3095, 3420),
- new RSTile(3103, 3421), new RSTile(3113, 3420),
- new RSTile(3120, 3418), new RSTile(3128, 3417),
- new RSTile(3138, 3417), new RSTile(3148, 3417),
- new RSTile(3157, 3419), new RSTile(3163, 3424),
- new RSTile(3171, 3428), new RSTile(3180, 3429),
- new RSTile(3186, 3433), new RSTile(3189, 3437) };
- private final RSTile varrockToCaveTiles[] = {new RSTile(3189, 3437),
- new RSTile(3186, 3433), new RSTile(3180, 3429),
- new RSTile(3171, 3428), new RSTile(3163, 3424),
- new RSTile(3157, 3419), new RSTile(3148, 3417),
- new RSTile(3138, 3417), new RSTile(3128, 3417),
- new RSTile(3120, 3418), new RSTile(3113, 3420),
- new RSTile(3103, 3421), new RSTile(3095, 3420),
- new RSTile(3087, 3420), new RSTile(3081, 3421)};
- private final RSTile caveToEdgyTiles[] = { new RSTile(3081, 3421),
- new RSTile(3086, 3427), new RSTile(3090, 3431),
- new RSTile(3088, 3441), new RSTile(3087, 3451),
- new RSTile(3087, 3459), new RSTile(3087, 3465),
- new RSTile(3082, 3465), new RSTile(3079, 3468),
- new RSTile(3079, 3475), new RSTile(3079, 3481),
- new RSTile(3083, 3485), new RSTile(3088, 3491),
- new RSTile(3094, 3491) };
- private final RSTile edgyToCaveTiles[] = { new RSTile(3094, 3491),
- new RSTile(3088, 3491), new RSTile(3083, 3485),
- new RSTile(3079, 3481), new RSTile(3079, 3475),
- new RSTile(3079, 3468), new RSTile(3082, 3465),
- new RSTile(3087, 3465), new RSTile(3087, 3459),
- new RSTile(3087, 3451), new RSTile(3088, 3441),
- new RSTile(3090, 3431), new RSTile(3068, 3427),
- new RSTile(3081, 3421) };
- private final RSTile doors[] = { new RSTile(2132, 5257),
- new RSTile(2132, 5260), new RSTile(2132, 5278),
- new RSTile(2132, 5281), new RSTile(2138, 5294),
- new RSTile(2141, 5294), new RSTile(2148, 5299),
- new RSTile(2148, 5302) };
- private final RSArea floor1 = new RSArea(new RSTile(1856, 5236),
- new RSTile(1866, 5245));
- private final RSArea floor1Middle = new RSArea(new RSTile(1900, 5210),
- new RSTile(1917, 5230));
- private final RSArea floor2 = new RSArea(new RSTile(2037, 5239),
- new RSTile(2046, 5246));
- private final RSArea floor2Middle = new RSArea(new RSTile(2009, 5203),
- new RSTile(2034, 5228));
- private final RSArea floor3 = new RSArea(new RSTile(2116, 5250),
- new RSTile(2131, 5259));
- private final RSArea floor3Front = new RSArea(new RSTile(2131, 5253),
- new RSTile(2133, 5256));
- private final RSArea doors1 = new RSArea(new RSTile(2132, 5257),
- new RSTile(2133, 5259));
- private final RSArea doors2 = new RSArea(new RSTile(2132, 5279),
- new RSTile(2133, 5281));
- private final RSArea doors3 = new RSArea(new RSTile(2138, 5294),
- new RSTile(2140, 5295));
- private final RSArea doors4 = new RSArea(new RSTile(2148, 5299),
- new RSTile(2149, 5301));
- private final RSArea room1 = new RSArea(new RSTile(2117, 5267), new RSTile(
- 2134, 5277));
- private final RSArea room2 = new RSArea(new RSTile(2142, 5302), new RSTile(
- 2156, 5311));
- private final int potionConstants[] = { Skills.ATTACK, Skills.STRENGTH,
- Skills.STRENGTH, Skills.ATTACK, Skills.DEFENSE };
- private final int skillConstants[] = { Skills.ATTACK, Skills.STRENGTH,
- Skills.DEFENSE, Skills.RANGE };
- private final int foods[] = { 361, 379, 373, 7946, 385 };
- private final int potionID[][] = { { 9745, 9743, 9741, 9739 },
- { 119, 117, 115, 113 }, { 161, 159, 157, 2440 },
- { 149, 147, 145, 2436 }, { 167, 165, 163, 2442 } };
- private final int rewardID[] = { 11640, 2528, 6199, 14664 };
- private final int bowID[] = { 841, 843, 849, 853, 857, 861, 839, 845, 847,
- 851, 855, 859 };
- private final int arrowID[] = { 882, 884, 886, 888, 890, 892 };
- private final int spiderID = 4400;
- private final int tabletID = 8007;
- private final int lawID = 563;
- private final int fireID = 554;
- private final int airID = 556;
- private final int vialID = 229;
- /*
- * Paint Variables
- */
- private final String skillNames[] = { "Attack", "Strength", "Defense",
- "Range" };
- private long runTime;
- private int currentLevel;
- private int levelsGained;
- private int xpGained;
- private int xpHour;
- private int TNL;
- private int percentTNL;
- private long timeTNL;
- private String skillName;
- private int kills;
- private int killsph;
- private int spiderXP = 200;
- URLConnection url = null;
- BufferedReader in = null;
- private String PBthread = "http://www.powerbot.org/community/topic/538285-giant-spider-fuser-anti-ban-flawless/";
- private String FSthread = "http://fuserscripts.org/community/index.php?/topic/96-giant-spider-fuser-download/";
- Image fsicon;
- Image guilogo;
- Image paint;
- Image showhide;
- Image statusback;
- Rectangle avatarSpotShape = new Rectangle(426, 286, 87, 54);
- Rectangle scriptLogoShape = new Rectangle(184, 283, 235, 54);
- Rectangle FuserScriptsLogoShape = new Rectangle(5, 282, 174, 54);
- private static SystemTray tray = SystemTray.getSystemTray();
- private static TrayIcon icon = new TrayIcon(Toolkit.getDefaultToolkit().getImage(Configuration.Paths.getScriptsDirectory() + File.separator + "fs_icon.png"));
- public GiantSpiderFuser() {
- icon.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- if (Desktop.isDesktopSupported()) {
- try {
- Desktop.getDesktop().browse(new URI("http://fuserscripts.org/"));
- } catch (Exception e1) {
- e1.printStackTrace();
- }
- }
- }
- });
- }
- private static class Images {
- private static Logger log = Logger.getLogger(Images.class.getName());
- public static Image getImage(String fileName) {
- try {
- File f = new File(
- Configuration.Paths.getScriptsDirectory() + File.separator
- + fileName);
- if (f.exists()) {
- log.info("Successfully loaded " + fileName
- + " from scripts folder.");
- return ImageIO.read(f.toURI().toURL());
- }
- BufferedImage img = ImageIO.read(new URL(
- "http://scripters.powerbot.org/files/378722/" + fileName));
- if (img != null) {
- log.info("Downloading images...");
- ImageIO.write((RenderedImage) img, "PNG", f);
- log.info("Saved " + fileName
- + " to Scripts folder successfully.");
- return img;
- }
- } catch (IOException e) {
- log.info("No Internet Connection or Broken Image Link.");
- }
- return null;
- }
- }
- @Override
- public boolean onStart() {
- try {
- if (!game.isLoggedIn()) {
- log.info("Please login before starting");
- return false;
- }
- guilogo = Images.getImage("gsfgui_logov21.png");
- fsicon = Images.getImage("fs_icon.png");
- paint = Images.getImage("gsf_paintv22.png");
- statusback = Images.getImage("statusback.png");
- showhide = Images.getImage("showhide.png");
- /*
- * FS Tray
- */
- if (SystemTray.isSupported()) {
- try {
- tray.add(icon);
- } catch (AWTException e) {
- e.printStackTrace();
- }
- } else {
- log("System Tray is not supported.");
- }
- /*
- * Update Checker
- */
- if (getUpdate() > getVersion()) {
- showMessage(scriptName + ": Script Update found!");
- update();
- return false;
- }
- else {
- showMessage(scriptName + ": Script is Up to Date!");
- /*
- * GUI Init
- */
- try {
- SwingUtilities.invokeAndWait(new Runnable() {
- @Override
- public void run() {
- gui.setVisible(true);
- }
- });
- } catch (InterruptedException ignored) {
- } catch (InvocationTargetException ignored) {
- }
- while (GuiIsOpen) {
- Methods.sleep(25);
- }
- }
- if (guiClosed) {
- return false;
- }
- /*
- * Eating
- */
- if (gui.textField1.getText().length() > 0) {
- try {
- foodID = Integer.parseInt(gui.textField1.getText());
- } catch (NumberFormatException e) {
- log.severe("Invalid food id");
- return false;
- }
- } else {
- if (gui.list1.getSelectedIndex() != -1) {
- foodID = foods[gui.list1.getSelectedIndex()];
- } else {
- log.severe("No food selected");
- return false;
- }
- }
- try {
- final int value = Integer
- .parseInt(gui.textField2.getText());
- final int value1 = Integer.parseInt(gui.textField3
- .getText());
- eatingValue = new int[] { random(value, value1), value,
- value1 };
- } catch (NumberFormatException e) {
- log.severe("Invalid eating value(s)");
- return false;
- }
- /*
- * Potions
- */
- final JCheckBox selections[] = { gui.checkBox1, gui.checkBox2,
- gui.checkBox3, gui.checkBox4, gui.checkBox5 };
- final JTextField fields[] = { gui.textField4, gui.textField5,
- gui.textField6, gui.textField7, gui.textField8 };
- for (int i = 0; i < selections.length; i++) {
- if (selections[i].isSelected()) {
- potions[i] = 1;
- try {
- amounts[i] = Integer.parseInt(fields[i].getText());
- } catch (NumberFormatException e) {
- log.severe("Invalid potion amount(s)");
- return false;
- }
- }
- }
- /*
- * Banking
- */
- if (!gui.radioButton2.isSelected()) {
- bankTile = varrockTile;
- } else {
- bankTile = edgeTile;
- }
- if (!gui.radioButton3.isSelected()) {
- enableTeleporting = true;
- if (!gui.radioButton4.isSelected()) {
- useTablets = true;
- }
- }
- /*
- * Other
- */
- if (gui.mouseSpeed.getValue() == 1) {
- mouseSpeed1 = 10;
- }
- else if (gui.mouseSpeed.getValue() == 2) {
- mouseSpeed1 = 9;
- }
- else if (gui.mouseSpeed.getValue() == 3) {
- mouseSpeed1 = 8;
- }
- else if (gui.mouseSpeed.getValue() == 4) {
- mouseSpeed1 = 7;
- }
- else if (gui.mouseSpeed.getValue() == 5) {
- mouseSpeed1 = 6;
- }
- else if (gui.mouseSpeed.getValue() == 6) {
- mouseSpeed1 = 5;
- }
- else if (gui.mouseSpeed.getValue() == 7) {
- mouseSpeed1 = 4;
- }
- else if (gui.mouseSpeed.getValue() == 8) {
- mouseSpeed1 = 3;
- }
- else if (gui.mouseSpeed.getValue() == 9) {
- mouseSpeed1 = 2;
- }
- else if (gui.mouseSpeed.getValue() == 10) {
- mouseSpeed1 = 1;
- }
- if (gui.radioButton7.isSelected()) {
- changeRooms = true;
- } else {
- if (gui.radioButton8.isSelected()) {
- currentRoom = 1;
- } else {
- currentRoom = 2;
- }
- }
- if (gui.checkBox6.isSelected()) {
- enableRange = true;
- final RSItem knive = equipment.getItem(Equipment.WEAPON);
- if (knive != null && knive.getID() == 863) {
- arrow = 863;
- } else {
- final RSItem weared = equipment.getItem(Equipment.AMMO);
- for (final int id : arrowID) {
- if (weared != null && weared.getID() == id) {
- arrow = id;
- break;
- }
- }
- if (arrow < 1) {
- log.severe("No arrows found");
- return false;
- }
- }
- if (!equipment.containsOneOf(bowID) && arrow != 863) {
- log.severe("No bow found");
- return false;
- }
- }
- stats = new int[][] {
- { skills.getRealLevel(Skills.ATTACK),
- skills.getCurrentExp(Skills.ATTACK) },
- { skills.getRealLevel(Skills.STRENGTH),
- skills.getCurrentExp(Skills.STRENGTH) },
- { skills.getRealLevel(Skills.DEFENSE),
- skills.getCurrentExp(Skills.DEFENSE) },
- { skills.getRealLevel(Skills.RANGE),
- skills.getCurrentExp(Skills.RANGE) } };
- if (!combat.isAutoRetaliateEnabled()) {
- combat.setAutoRetaliate(true);
- }
- setRoom();
- startTime = System.currentTimeMillis();
- /*
- * Disabling Rewards Box Solver
- */
- env.disableRandom("Improved Rewards Box");
- showMessage("Script Started Successfully!");
- return true;
- } catch (Exception e) {
- e.printStackTrace();
- return false;
- }
- }
- public static void showMessage(Object text) {
- icon.displayMessage("Fuser Scripts", text.toString(), TrayIcon.MessageType.INFO);
- }
- private void update() {
- try {
- SwingUtilities.invokeAndWait(new Runnable() {
- @Override
- public void run() {
- uc.setVisible(true);
- }
- });
- } catch (InterruptedException ignored) {
- } catch (InvocationTargetException ignored) {
- }
- while (uc.isVisible()) {
- sleep(100);
- }
- }
- public double getUpdate() {
- try {
- BufferedReader r = new BufferedReader(new InputStreamReader(new URL("http://scripters.powerbot.org/files/378722/gsfversion.txt").openStream()));
- double d = Double.parseDouble(r.readLine());
- r.close();
- return d;
- } catch(Exception e) {
- log("Unable to check for update.");
- }
- return getVersion();
- }
- public void openThread(String thread){
- if (java.awt.Desktop.isDesktopSupported()) {
- java.awt.Desktop desktop = java.awt.Desktop.getDesktop();
- if (!desktop.isSupported(java.awt.Desktop.Action.BROWSE)) {
- log("Unable to Open Script Thread.");
- return;
- }
- try {
- java.net.URI uri = new java.net.URI(thread);
- desktop.browse(uri);
- } catch (Exception e) {
- }
- }
- }
- @Override
- public int loop() {
- if (!game.isLoggedIn()) {
- return random(800, 1200);
- }
- mouse.setSpeed(mouseSpeed1);
- checkRunning();
- if (eat()) {
- return random(100, 250);
- }
- if (teleport()) {
- return random(5000, 6000);
- }
- if (!hasFood() || noArrowsLeft) {
- if (!needBank) {
- setRoom();
- needBank = true;
- atSpiders = false;
- if (tries != 0) {
- tries = 0;
- }
- }
- } else {
- needBank = false;
- }
- if (atSpiders) {
- if (getMyPlayer().getInteracting() == null) {
- if (!pickArrows()) {
- attackSpiders();
- }
- } else {
- status = "Fighting...";
- if (tries != 0) {
- tries = 0;
- }
- if (!drinkPotions() && !equipArrows()) {
- antiban();
- }
- }
- return random(100, 250);
- }
- if ((myTile = getMyPlayer().getLocation()) != null) {
- if (floor1.contains(myTile)) {
- if (!needBank) {
- clickObject(16150, "Enter");
- status = "Entering Portal";
- } else {
- clickObject(16148, "Climb-up");
- status = "Climbing Up";
- }
- } else if (floor1Middle.contains(myTile)) {
- clickObject(16149, "Climb-down");
- status = "Climbing Down";
- } else if (floor2.contains(myTile)) {
- if (!needBank) {
- clickObject(16082, "Enter");
- status = "Entering Portal";
- } else {
- clickObject(16080, "Climb-up");
- status = "Climbing Up";
- }
- } else if (floor2Middle.contains(myTile)) {
- clickObject(16081, "Climb-down");
- status = "Climbing Down";
- } else if (floor3.contains(myTile)) {
- if (!needBank) {
- clickDoor(doors[0]);
- status = "Opening Doors";
- } else {
- clickObject(16114, "Climb-up");
- status = "Climbing Up";
- }
- } else if (floor3Front.contains(myTile)) {
- if (!needBank) {
- clickDoor(doors[0]);
- status = "Opening Doors";
- } else {
- clickObject(16114, "Climb-up");
- status = "Climbing Up";
- }
- } else if (doors1.contains(myTile)) {
- if (!needBank) {
- clickDoor(doors[1]);
- status = "Opening Doors";
- } else {
- clickDoor(doors[0]);
- status = "Opening Doors";
- }
- } else if (myTile.getY() >= 5260 && myTile.getY() <= 5278) {
- if (!needBank) {
- if (currentRoom == 1) {
- if (room1.contains(myTile)) {
- atSpiders = true;
- status = "Reached Spiders";
- } else {
- walkToTile(room1.getCentralTile());
- }
- } else {
- clickDoor(doors[2]);
- status = "Opening Doors";
- }
- } else {
- clickDoor(doors[1]);
- status = "Opening Doors";
- }
- } else if (doors2.contains(myTile)) {
- if (!needBank && currentRoom == 2) {
- clickDoor(doors[3]);
- status = "Opening Doors";
- } else {
- clickDoor(doors[2]);
- status = "Opening Doors";
- }
- } else if (myTile.getY() >= 5282 && myTile.getY() <= 5295
- && myTile.getX() <= 2137) {
- if (!needBank && currentRoom == 2) {
- clickDoor(doors[4]);
- status = "Opening Doors";
- } else {
- clickDoor(doors[3]);
- status = "Opening Doors";
- }
- } else if (doors3.contains(myTile)) {
- if (!needBank && currentRoom == 2) {
- clickDoor(doors[5]);
- status = "Opening Doors";
- } else {
- clickDoor(doors[4]);
- status = "Opening Doors";
- }
- } else if (myTile.getY() >= 5294 && myTile.getY() <= 5298
- && myTile.getX() >= 2141) {
- if (!needBank && currentRoom == 2) {
- clickDoor(doors[6]);
- status = "Opening Doors";
- } else {
- clickDoor(doors[5]);
- status = "Opening Doors";
- }
- } else if (doors4.contains(myTile)) {
- if (!needBank && currentRoom == 2) {
- clickDoor(doors[7]);
- status = "Opening Doors";
- } else {
- clickDoor(doors[6]);
- status = "Opening Doors";
- }
- } else if (room2.contains(myTile)) {
- if (!needBank && currentRoom == 2) {
- walkToTile(room2.getCentralTile());
- atSpiders = true;
- status = "Reached Spiders";
- } else {
- clickDoor(doors[7]);
- status = "Opening Doors";
- }
- } else {
- if (needBank) {
- if (dropVials()) {
- status = "Dropping Vials";
- return random(800, 1200);
- }
- if (dropRewards()) {
- status = "Dropping Reward Box";
- return random(800, 1200);
- }
- if (calc.distanceTo(bankTile) < 5) {
- if (bank.isOpen()) {
- status = "Banking...";
- if (tries != 0) {
- tries = 0;
- }
- if (noArrowsLeft) {
- log.severe("No arrows left");
- showMessage(scriptName + ": No Arrows Left, Stopping Script...");
- stopScript(true);
- }
- if (openBankTab()) {
- return random(800, 1200);
- }
- if (depositCrap()) {
- return random(800, 1200);
- }
- if (enableTeleporting) {
- if (useTablets) {
- if (!inventory.contains(tabletID)
- && bank.getCount(tabletID) > 0) {
- bank.withdraw(tabletID, 1);
- return random(800, 1200);
- }
- } else {
- if (!inventory.contains(lawID)
- && bank.getCount(lawID) > 0) {
- bank.withdraw(lawID, 1);
- return random(800, 1200);
- } else if (inventory.getCount(true, airID) < 3
- && bank.getCount(airID) >= 3) {
- bank.withdraw(airID, 3);
- return random(800, 1200);
- } else if (!inventory.contains(fireID)
- && bank.getCount(fireID) > 0) {
- bank.withdraw(fireID, 1);
- return random(800, 1200);
- }
- }
- }
- for (int i = 0; i < potionID.length; i++) {
- if (potions[i] == 1) {
- if (inventory.getCount(potionID[i]) > amounts[i]) {
- if (depositPotion(potionID[i])) {
- return random(800, 1200);
- }
- } else if (inventory.getCount(potionID[i]) < amounts[i]) {
- if (withdrawPotion(potionID[i])) {
- return random(800, 1200);
- }
- }
- }
- }
- if (!inventory.contains(foodID)) {
- if (bank.getCount(foodID) < 5) {
- log.severe("No food left");
- showMessage(scriptName + ": No Food Left, Stopping Script...");
- stopScript(true);
- } else {
- bank.withdraw(foodID, 0);
- return random(800, 1200);
- }
- } else {
- needBank = false;
- }
- } else {
- if (tries > 3) {
- walkToTile(bankTile);
- tries = 0;
- } else {
- if (clickObject((bankTile.equals(edgeTile)) ? 42217 : 782, "Use-quickly")) {
- tries++;
- status = "Opening Bank ...";
- }
- }
- }
- } else {
- walkPath((bankTile.equals(edgeTile)) ? caveToEdgyTiles : caveToVarrockTiles);
- status = "Walking to Bank";
- }
- } else {
- if (calc.distanceTo(entranceTile) < 5) {
- clickObject(16154, "Climb-down");
- } else {
- walkPath(((bankTile.equals(edgeTile)) ? edgyToCaveTiles : varrockToCaveTiles));
- status = "Walking to Cave";
- }
- }
- }
- }
- return random(100, 250);
- }
- @Override
- public void onFinish() {
- showMessage("Thanks for Using " + scriptName + " - By " + author);
- sleep(5000);
- tray.remove(icon);
- }
- private boolean teleport() {
- if (enableTeleporting && game.getBaseY() > 4000 && needBank
- && canTeleport()) {
- if (useTablets) {
- final RSItem tablet = inventory.getItem(tabletID);
- if (tablet != null) {
- status = "Teleporting, Breaking Tab";
- return tablet.interact("Break");
- }
- } else {
- status = "Teleporting, Casting Spell";
- return magic.castSpell(Magic.SPELL_VARROCK_TELEPORT);
- }
- }
- return false;
- }
- private int getNextTile(final RSTile path[]) {
- for (int i = path.length - 1; i >= 0; i--) {
- if (calc.tileOnMap(path[i])) {
- return i;
- }
- }
- return -1;
- }
- private void walkPath(final RSTile path[]) {
- final int next = getNextTile(path);
- if (next != -1) {
- if (walking.walkTileMM(path[next], 2, 2)) {
- if (path[next].equals(path[path.length - 1])) {
- sleep(700, 900);
- waitToStop();
- } else {
- for (int i = 0; i < 20; i++) {
- if (getMyPlayer().isMoving()) {
- i = 0;
- }
- if (calc.tileOnMap(path[next + 1])) {
- break;
- }
- sleep(100, 200);
- }
- }
- }
- } else {
- walkToTile(path[path.length - 1]);
- }
- }
- private void waitToStop() {
- while (getMyPlayer().isMoving()) {
- sleep(100, 250);
- }
- }
- private boolean canTeleport() {
- return (inventory.contains(tabletID))
- || (inventory.contains(lawID)
- && inventory.getCount(true, airID) >= 3 && inventory
- .contains(fireID));
- }
- private boolean dropVials() {
- if (inventory.contains(vialID)) {
- for (final RSItem item : inventory.getItems()) {
- if (item != null && item.getID() == vialID
- && item.interact("Drop")) {
- sleep(50, 90);
- }
- }
- return true;
- }
- return false;
- }
- private boolean dropRewards() {
- if (inventory.containsOneOf(rewardID)) {
- for (final RSItem item : inventory.getItems()) {
- if (item != null && isReward(item.getID())
- && item.interact("Drop")) {
- sleep(50, 90);
- }
- }
- return true;
- }
- return false;
- }
- private boolean isReward(final int thisID) {
- for (final int id : rewardID) {
- if (thisID == id)
- return true;
- }
- return false;
- }
- private boolean isPotion(final int thisID) {
- for (final int id[] : potionID) {
- for (final int id2 : id) {
- if (thisID == id2)
- return true;
- }
- }
- return false;
- }
- private boolean depositCrap() {
- ArrayList<Integer> items = new ArrayList<Integer>();
- for (final RSItem item : inventory.getItems()) {
- if (item != null) {
- final int id = item.getID();
- if (!items.contains(id) && id > 0 && id != lawID && id != airID
- && id != fireID && id != tabletID && id != foodID
- && id != arrow && !isPotion(id) && !isReward(id)) {
- if (item.interact("Deposit-All")) {
- items.add(id);
- sleep(60, 120);
- }
- item.interact("Deposit");
- }
- }
- }
- return items.size() > 0;
- }
- private boolean equipArrows() {
- if (enableRange && inventory.getCount(true, arrow) >= random(20, 30)) {
- final RSItem arrows = inventory.getItem(arrow);
- if (arrows != null && arrows.interact("Wield")) {
- status = "Weilding Arrows";
- sleep(600, 900);
- return true;
- }
- }
- return false;
- }
- private boolean pickArrows() {
- if (enableRange && !inventory.isFull()) {
- RSGroundItem thisItem = null;
- final RSGroundItem items[] = groundItems.getAll();
- for (final RSGroundItem item : items) {
- if (item != null) {
- if (room1.contains(item.getLocation())
- || room2.contains(item.getLocation())) {
- final RSItem stack = item.getItem();
- if (stack != null && stack.getID() == arrow
- && stack.getStackSize() >= 5) {
- thisItem = item;
- break;
- }
- }
- }
- }
- if (thisItem != null) {
- if (thisItem.isOnScreen()) {
- if (!getMyPlayer().isMoving() && thisItem.interact("Take")) {
- status = "Picking Up Arrows";
- sleep(700, 900);
- waitToStop();
- for (int i = 0; i < 20; i++) {
- if (needToEat()) {
- break;
- }
- sleep(50, 80);
- }
- return true;
- }
- } else {
- walkToTile(thisItem.getLocation());
- }
- }
- }
- return false;
- }
- private boolean containsPotion(final int potion[]) {
- return inventory.containsOneOf(potion);
- }
- private boolean hasFood() {
- for (final RSItem food : (!bank.isOpen()) ? inventory.getItems() : inventory.getItems()) {
- if (food != null && food.getID() == foodID)
- return true;
- }
- return false;
- }
- private boolean drinkPotions() {
- for (int i = 0; i < potionID.length; i++) {
- if (potions[i] == 1
- && containsPotion(potionID[i])
- && skills.getCurrentLevel(potionConstants[i])
- - skills.getRealLevel(potionConstants[i]) <= random(
- 2, 5)) {
- final RSItem potion = inventory.getItem(potionID[i]);
- if (potion != null && potion.interact("Drink")) {
- status = "Drinking Potions *Hic*";
- sleep(1000, 1300);
- return true;
- }
- break;
- }
- }
- return false;
- }
- private boolean openBankTab() {
- if (bankTab != -1) {
- if (bank.getCurrentTab() != bankTab) {
- final RSComponent tab = interfaces.getComponent(
- Bank.INTERFACE_BANK, Bank.INTERFACE_BANK_TAB[bankTab]);
- if (tab.isValid()) {
- return tab.doClick();
- }
- }
- } else {
- bankTab = bank.getCurrentTab();
- }
- return false;
- }
- private boolean withdrawPotion(final int potion[]) {
- for (int i = potion.length - 1; i >= 0; i--) {
- if (bank.getCount(potion[i]) > 0) {
- bank.withdraw(potion[i], 1);
- return true;
- }
- }
- return false;
- }
- private boolean depositPotion(final int potion[]) {
- for (final int id : potion) {
- if (inventory.contains(id)) {
- bank.deposit(id, 0);
- return true;
- }
- }
- return false;
- }
- private boolean eat() {
- if (needToEat()) {
- final RSItem food = inventory.getItem(foodID);
- if (food != null && food.interact("Eat")) {
- status = "Eating, *Om nom nom nom...*";
- sleep(1000, 1300);
- eatingValue[0] = random(eatingValue[1], eatingValue[2]);
- return true;
- }
- }
- return false;
- }
- private boolean needToEat() {
- return combat.getLifePoints() <= eatingValue[0];
- }
- private boolean clickObject(final int id, final String action) {
- final RSObject obj = objects.getNearest(id);
- if (obj != null) {
- if (obj.isOnScreen()) {
- if (!getMyPlayer().isMoving()) {
- if (objTries > 5) {
- camera.setAngle(random(1, 360));
- objTries = 0;
- } else {
- if (obj.interact(action)) {
- objTries = 0;
- sleep(2500, 3000);
- return true;
- } else {
- objTries++;
- }
- }
- }
- } else {
- walkToTile(obj.getLocation());
- }
- }
- return false;
- }
- private void clickDoor(final RSTile doorTile) {
- if (camera.getPitch() != 3072) {
- camera.setPitch(true);
- }
- final RSObject obj = objects.getTopAt(doorTile);
- if (obj != null) {
- if (obj.isOnScreen()) {
- if (!getMyPlayer().isMoving()) {
- if (objTries > 5) {
- camera.setAngle(random(1, 360));
- objTries = 0;
- } else {
- if (obj.interact("Open")) {
- objTries = 0;
- sleep(3500, 4000);
- } else {
- objTries++;
- }
- }
- }
- } else {
- walkToTile(obj.getLocation());
- }
- } else {
- walkToTile(doorTile);
- }
- }
- private void setRoom() {
- if (changeRooms) {
- currentRoom = random(1, 3);
- }
- }
- private void walkToTile(final RSTile destination) {
- if (calc.tileOnMap(destination)) {
- if (walking.walkTileMM(destination, 2, 2)) {
- sleep(700, 900);
- waitToStop();
- }
- } else {
- if (!getMyPlayer().isMoving()
- || walking.getDestination() == null
- || calc.distanceTo(walking.getDestination()) <= random(3, 8)) {
- final RSTile step = walking.getClosestTileOnMap(destination);
- if (step != null && walking.walkTileMM(step, 2, 2)) {
- sleep(700, 900);
- }
- }
- }
- }
- private void checkRunning() {
- if (!walking.isRunEnabled() && walking.getEnergy() >= random(25, 35)) {
- walking.setRun(true);
- sleep(900, 1300);
- }
- }
- private void attackSpiders() {
- final RSNPC agressive = getAgressive();
- if (agressive != null) {
- if (tries < 15) {
- if (!agressive.isMoving()) {
- tries++;
- }
- return;
- }
- }
- final RSNPC free = getFree();
- if (free != null) {
- if (free.isOnScreen()) {
- if (random(1,6) == 3) {
- camera.turnTo(free, random(3,5));
- }
- if (free.interact("Attack")) {
- status = "Attacking Spiders";
- sleep(700, 900);
- waitToStop();
- for (int i = 0; i < 20; i++) {
- if (needToEat()) {
- break;
- }
- sleep(50, 150);
- }
- }
- } else {
- walkToTile(free.getLocation());
- }
- }
- }
- private RSNPC getFree() {
- RSNPC winner = null;
- int distance = 1000;
- for (final RSNPC npc : npcs.getAll()) {
- if (npc != null && npc.getID() == spiderID && !npc.isInCombat()
- && npc.getHPPercent() > 0) {
- if (room1.contains(npc.getLocation())
- || room2.contains(npc.getLocation())) {
- final int thisDistance = calc.distanceTo(npc.getLocation());
- if (thisDistance < distance) {
- winner = npc;
- distance = thisDistance;
- }
- }
- }
- }
- status = "Searching for Free Spiders";
- return winner;
- }
- private RSNPC getAgressive() {
- for (final RSNPC npc : npcs.getAll()) {
- if (npc != null && npc.getID() == spiderID
- && npc.getInteracting() != null
- && npc.getInteracting().equals(getMyPlayer())) {
- return npc;
- }
- }
- return null;
- }
- boolean timeSinceLast(int a) {
- return (System.currentTimeMillis() - lastTime > a);
- }
- void setNext(int a, int b) {
- lastTime = System.currentTimeMillis();
- nextWait = random(a, b);
- }
- public void antiban() {
- if (timeSinceLast(nextWait)) {
- int cC = random(1, 30);
- doAntiban(cC, 100);
- setNext(60000, 120000);
- }
- }
- public void doAntiban(int ws, int randRecur) {
- switch (ws) {
- case 1:
- if (random(0, 100) <= 50) {
- new rotation("", random(1000, 5000));
- } else {
- new rotation("anti", random(1000, 5000));
- }
- mouse.moveRandomly(200, 600);
- mouse.moveSlightly();
- break;
- case 2:
- RSPlayer target = null;
- for (RSPlayer p : players.getAll()) {
- if (p.isOnScreen()) {
- target = p;
- break;
- }
- target = null;
- }
- if (random(0, 100) <= 50) {
- new rotation("", random(1000, 2000));
- } else {
- new rotation("anti", random(1000, 2000));
- }
- if (target != null) {
- Point pt = target.getScreenLocation();
- mouse.click(pt, false);
- sleep(500, 1200);
- mouse.moveRandomly(400, 500);
- }
- break;
- case 3:
- if (random(0, 100) <= 50) {
- new rotation("", random(200, 400));
- } else {
- new rotation("anti", random(200, 400));
- }
- if (random(0, 100) <= 50) {
- game.openTab(Tab.ATTACK);
- sleep(200, 2000);
- game.openTab(Tab.STATS);
- sleep(200, 2000);
- } else {
- game.openTab(Tab.STATS);
- sleep(200, 2000);
- game.openTab(Tab.ATTACK);
- sleep(200, 2000);
- }
- break;
- case 4:
- RSObject objTarg = null;
- for (RSObject p : objects.getAll()) {
- if (p.isOnScreen()) {
- objTarg = p;
- break;
- }
- }
- if (objTarg != null) {
- new rotation("anti", random(200, 1000));
- objTarg.doClick(false);
- sleep(200, 700);
- mouse.moveSlightly();
- mouse.moveRandomly(200, 350);
- }
- break;
- case 5:
- if (random(0, 100) <= 50) {
- new rotation("", random(200, 400));
- } else {
- new rotation("anti", random(200, 400));
- }
- break;
- case 6:
- case 25:
- case 26:
- case 27:
- case 28:
- case 29:
- case 30:
- if (random(0, 100) <= 50) {
- new rotation("", random(200, 400));
- } else {
- new rotation("anti", random(200, 400));
- }
- Point base = new Point(588 + random(0, 17), 175 + random(0, 20));
- Point skillBase = new Point(550 + random(0, 170), 210 + random(0,
- 200));
- mouse.click(base, true);
- sleep(0, 100);
- mouse.move(skillBase);
- sleep(1000, 2000);
- if (random(0, 100) <= 50) {
- new rotation("", random(100, 200));
- } else {
- new rotation("anti", random(100, 200));
- }
- break;
- case 7:
- if (random(0, 100) <= 50) {
- new rotation("", random(200, 400));
- } else {
- new rotation("anti", random(200, 400));
- }
- mouse.moveRandomly(400, 600);
- break;
- case 8:
- Point based = new Point(588 + random(0, 17), 175 + random(0, 20));
- Point skillBased = new Point(550 + random(0, 170), 210 + random(0,
- 200));
- mouse.click(based, true);
- sleep(0, 100);
- mouse.move(skillBased);
- sleep(1000, 2000);
- if (random(0, 100) <= 50) {
- new rotation("", random(100, 200));
- } else {
- new rotation("anti", random(100, 200));
- }
- break;
- case 9:
- game.openTab(Tab.FRIENDS);
- sleep(1300, 1700);
- if (random(0, 100) <= 50) {
- new rotation("", random(100, 200));
- } else {
- new rotation("anti", random(100, 200));
- }
- break;
- case 10:
- game.openTab(Tab.QUESTS);
- sleep(1100, 1700);
- if (random(0, 100) <= 50) {
- new rotation("", random(100, 200));
- } else {
- new rotation("anti", random(100, 200));
- }
- break;
- case 11:
- game.openTab(Tab.ATTACK);
- sleep(1300, 1700);
- if (random(0, 100) <= 50) {
- new rotation("", random(100, 200));
- } else {
- new rotation("anti", random(100, 200));
- }
- break;
- case 12:
- if (random(0, 100) <= 50) {
- new rotation("", random(200, 400));
- } else {
- new rotation("anti", random(200, 400));
- }
- if (random(0, 100) <= 50) {
- new rotation("", random(200, 400));
- } else {
- new rotation("anti", random(200, 400));
- }
- if (random(0, 100) <= 50) {
- new rotation("", random(200, 400));
- } else {
- new rotation("anti", random(200, 400));
- }
- break;
- case 13:
- if (random(0, 100) <= 50) {
- new rotation("", random(200, 400));
- } else {
- new rotation("anti", random(200, 400));
- }
- mouse.moveRandomly(300, 600);
- break;
- case 14:
- if (random(0, 100) <= 50) {
- new rotation("", random(400, 600));
- } else {
- new rotation("anti", random(400, 600));
- }
- break;
- case 15:
- if (random(0, 100) <= 50) {
- new rotation("", random(200, 400));
- } else {
- new rotation("anti", random(200, 400));
- }
- mouse.moveRandomly(400, 600);
- mouse.moveSlightly();
- break;
- case 16:
- Point baseq = new Point(588 + random(0, 17), 175 + random(0, 20));
- Point skillBaseq = new Point(550 + random(0, 170), 210 + random(0,
- 200));
- mouse.click(baseq, true);
- sleep(0, 100);
- mouse.move(skillBaseq);
- sleep(1000, 2000);
- if (random(0, 100) <= 50) {
- new rotation("", random(100, 200));
- } else {
- new rotation("anti", random(100, 200));
- }
- break;
- case 17:
- game.openTab(Tab.FRIENDS);
- sleep(300, 700);
- if (random(0, 100) <= 50) {
- new rotation("", random(100, 200));
- } else {
- new rotation("anti", random(100, 200));
- }
- break;
- case 18:
- Point start = inventory.getItems()[random(0,
- inventory.getItems().length - 1)].getComponent()
- .getLocation();
- Point destination = inventory.getItems()[random(0,
- inventory.getItems().length - 1)].getComponent()
- .getLocation();
- mouse.move(start);
- mouse.drag(destination);
- break;
- case 19:
- inventory.getItems()[random(0, inventory.getItems().length - 1)]
- .interact("Examine");
- mouse.moveRandomly(random(20, 30));
- sleep(323, 700);
- break;
- case 20:
- if (random(0, 100) <= 50) {
- new rotation("", random(200, 2500));
- } else {
- new rotation("anti", random(200, 2500));
- }
- RSObject objTarg3 = null;
- for (RSObject p : objects.getAll()) {
- if (p.isOnScreen()) {
- objTarg3 = p;
- break;
- }
- objTarg3 = null;
- }
- if (objTarg3 != null) {
- new rotation("anti", random(200, 1000));
- objTarg3.interact("Examine");
- mouse.moveRandomly(random(20, 30));
- sleep(200, 700);
- mouse.moveSlightly();
- mouse.moveRandomly(200, 350);
- }
- break;
- case 21:
- if (random(0, 100) <= 50) {
- new rotation("", random(400, 700));
- } else {
- new rotation("anti", random(400, 700));
- }
- RSObject objTarg2 = null;
- for (RSObject p : objects.getAll()) {
- if (p.isOnScreen()) {
- objTarg2 = p;
- break;
- }
- objTarg = null;
- }
- if (objTarg2 != null) {
- objTarg2.interact("Examine");
- mouse.moveRandomly(random(20, 30));
- }
- break;
- case 22:
- RSNPC fc = npcs.getNearest("Giant spider");
- if (fc != null) {
- Point p = fc.getScreenLocation();
- mouse.click(p, false);
- mouse.moveRandomly(random(20, 30));
- sleep(500, 1000);
- mouse.moveSlightly();
- mouse.moveSlightly();
- } else {
- if (random(0, 100) <= 50) {
- new rotation("", random(200, 400));
- } else {
- new rotation("anti", random(200, 400));
- }
- }
- break;
- case 23:
- RSNPC fc2 = npcs.getNearest("Giant spider");
- if (fc2 != null) {
- fc2.interact("Examine");
- mouse.moveRandomly(random(20, 30));
- sleep(500, 1000);
- } else {
- if (random(0, 100) <= 50) {
- new rotation("", random(200, 400));
- } else {
- new rotation("anti", random(200, 400));
- }
- }
- break;
- case 24:
- if (random(0, 100) <= 50) {
- new rotation("", random(200, 400));
- } else {
- new rotation("anti", random(200, 400));
- }
- int b = random(1, 8);
- if (b == 1) {
- game.mouseChatButton(ChatButton.ALL, false);
- sleep(300, 1000);
- }
- if (b == 2) {
- game.mouseChatButton(ChatButton.GAME, false);
- sleep(300, 1000);
- }
- if (b == 3) {
- game.mouseChatButton(ChatButton.PUBLIC, false);
- sleep(300, 1000);
- }
- if (b == 4) {
- game.mouseChatButton(ChatButton.PRIVATE, false);
- sleep(300, 1000);
- }
- if (b == 5) {
- game.mouseChatButton(ChatButton.FRIENDS, false);
- sleep(300, 1000);
- }
- if (b == 6) {
- game.mouseChatButton(ChatButton.CLAN, false);
- sleep(300, 1000);
- }
- if (b == 7) {
- game.mouseChatButton(ChatButton.TRADE, false);
- sleep(300, 1000);
- }
- if (b == 8) {
- game.mouseChatButton(ChatButton.ASSIST, false);
- sleep(300, 1000);
- }
- mouse.moveSlightly();
- break;
- }
- if (random(0, 180) <= randRecur) {
- int cC = ws;
- while (cC == ws) {
- cC = random(1, 30);
- }
- status = "Doing Anti-Ban, Case " + cC;
- doAntiban(cC, randRecur / 2);
- }
- }
- final char anticlockwise = 37;
- final char clockwise = 39;
- private char rotationDirection;
- class rotation extends Thread {
- int maxDuration = 3000, type = 1, angle = 10;
- RSNPC npc = null;
- RSObject object = null;
- String direction = "";
- public rotation(RSNPC npc, int maxDuration) {
- this.npc = npc;
- this.maxDuration = maxDuration;
- type = 1;
- this.setPriority(3);
- this.start();
- }
- public rotation(RSObject object, int maxDuration) {
- this.object = object;
- this.maxDuration = maxDuration;
- type = 1;
- this.setPriority(3);
- this.start();
- }
- public rotation(String direction, int maxDuration) {
- this.direction = direction;
- this.maxDuration = maxDuration;
- type = 2;
- this.setPriority(3);
- this.start();
- }
- public rotation(int angle, int maxDuration) {
- this.angle = angle;
- this.maxDuration = maxDuration;
- type = 3;
- this.setPriority(3);
- this.start();
- }
- public void run() {
- switch (type) {
- case 1:
- doRotate();
- break;
- case 2:
- rotateDuration();
- break;
- case 3:
- rotateToAngle();
- break;
- default:
- break;
- }
- }
- void doRotate() {
- if (npc != null) {
- rotateToNPC();
- } else if (object != null) {
- rotateToObject();
- }
- }
- public void rotateDuration() {
- if (direction.toLowerCase().contains("anti")) {
- rotationDirection = anticlockwise;
- } else {
- rotationDirection = clockwise;
- }
- long sTime = System.currentTimeMillis();
- keyboard.pressKey(rotationDirection);
- while (System.currentTimeMillis() - sTime < maxDuration) {
- try {
- sleep(50);
- } catch (InterruptedException e) {
- }
- }
- keyboard.pressKey(clockwise);
- keyboard.pressKey(anticlockwise);
- keyboard.releaseKey(anticlockwise);
- keyboard.releaseKey(clockwise);
- }
- public void rotateToAngle() {
- long cTime = 0;
- int aT = angle;
- int aC = camera.getAngle();
- int absoluteDifference = Math.abs(aC - aT);
- if (aC < aT && absoluteDifference < 180) {
- rotationDirection = clockwise;
- } else if (aC < aT && absoluteDifference >= 180) {
- rotationDirection = anticlockwise;
- } else if (aC > aT && absoluteDifference > 180) {
- rotationDirection = clockwise;
- } else if (aC > aT && absoluteDifference <= 180) {
- rotationDirection = anticlockwise;
- }
- cTime = System.currentTimeMillis();
- keyboard.pressKey(rotationDirection);
- while (System.currentTimeMillis() - cTime < maxDuration
- && absoluteDifference > 5) {
- aT = angle;
- aC = camera.getAngle();
- absoluteDifference = Math.abs(aC - aT);
- try {
- sleep(50);
- } catch (InterruptedException e) {
- }
- }
- keyboard.pressKey(clockwise);
- keyboard.pressKey(anticlockwise);
- keyboard.releaseKey(anticlockwise);
- keyboard.releaseKey(clockwise);
- }
- public void rotateToObject() {
- long cTime = 0;
- int aT = camera.getTileAngle(object.getLocation());
- int aC = camera.getAngle();
- int absoluteDifference = Math.abs(aC - aT);
- if (aC < aT && absoluteDifference < 180) {
- rotationDirection = clockwise;
- } else if (aC < aT && absoluteDifference >= 180) {
- rotationDirection = anticlockwise;
- } else if (aC > aT && absoluteDifference > 180) {
- rotationDirection = clockwise;
- } else if (aC > aT && absoluteDifference <= 180) {
- rotationDirection = anticlockwise;
- }
- cTime = System.currentTimeMillis();
- keyboard.pressKey(rotationDirection);
- while ((!object.isOnScreen() && System.currentTimeMillis() - cTime < maxDuration)) {
- aT = camera.getTileAngle(object.getLocation());
- aC = camera.getAngle();
- absoluteDifference = Math.abs(aC - aT);
- try {
- sleep(50);
- } catch (InterruptedException e) {
- }
- }
- keyboard.pressKey(clockwise);
- keyboard.pressKey(anticlockwise);
- keyboard.releaseKey(anticlockwise);
- keyboard.releaseKey(clockwise);
- }
- public void rotateToNPC() {
- long cTime = 0;
- int aT = camera.getTileAngle(npc.getLocation());
- int aC = camera.getAngle();
- int absoluteDifference = Math.abs(aC - aT);
- if (aC < aT && absoluteDifference < 180) {
- rotationDirection = clockwise;
- } else if (aC < aT && absoluteDifference >= 180) {
- rotationDirection = anticlockwise;
- } else if (aC > aT && absoluteDifference > 180) {
- rotationDirection = clockwise;
- } else if (aC > aT && absoluteDifference <= 180) {
- rotationDirection = anticlockwise;
- }
- cTime = System.currentTimeMillis();
- keyboard.pressKey(rotationDirection);
- while ((!npc.isOnScreen() && System.currentTimeMillis() - cTime < maxDuration)
- || (!npc.isOnScreen() && absoluteDifference > 3)) {
- aT = camera.getTileAngle(npc.getLocation());
- aC = camera.getAngle();
- absoluteDifference = Math.abs(aC - aT);
- try {
- sleep(50);
- } catch (InterruptedException e) {
- }
- }
- keyboard.pressKey(clockwise);
- keyboard.pressKey(anticlockwise);
- keyboard.releaseKey(anticlockwise);
- keyboard.releaseKey(clockwise);
- }
- }
- public class MousePaint {
- public int waveSize = 0;
- @SuppressWarnings({"serial", "unused"})
- public class MousePathPoint extends Point {
- private long finishTime;
- private double lastingTime;
- public MousePathPoint(int x, int y, int lastingTime) {
- super(x, y);
- this.lastingTime = lastingTime;
- finishTime = System.currentTimeMillis() + lastingTime;
- }
- public boolean isUp() {
- return System.currentTimeMillis() > finishTime;
- }
- }
- public double getRot(int ticks){
- return (System.currentTimeMillis() % (360 * ticks)) / ticks;
- }
- public LinkedList<MousePathPoint> MousePath = new LinkedList<MousePathPoint>();
- public void drawTrail(Graphics g1) {
- Graphics2D g = (Graphics2D) g1;
- g.setStroke(new BasicStroke(1));
- while (!MousePath.isEmpty() && MousePath.peek().isUp()) {
- MousePath.remove();
- }
- Point clientCursor = mouse.getLocation();
- MousePathPoint mpp = new MousePathPoint(clientCursor.x, clientCursor.y, 250);
- if (MousePath.isEmpty() || !MousePath.getLast().equals(mpp)) {
- MousePath.add(mpp);
- }
- MousePathPoint lastPoint = null;
- for (MousePathPoint a : MousePath) {
- if (lastPoint != null) {
- long mpt = System.currentTimeMillis() - mouse.getPressTime();
- if (mouse.getPressTime() == -1 || mpt >= 250) {
- g.setColor(Color.BLACK);
- }
- if (mpt < 250) {
- g.setColor(Color.RED);
- }
- g.drawLine(a.x, a.y, lastPoint.x, lastPoint.y);
- }
- lastPoint = a;
- }
- }
- public void drawMouse(Graphics g1) {
- Graphics2D g = (Graphics2D) g1;
- g.setRenderingHints(new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON));
- g.setStroke(new BasicStroke(3));
- g.setColor(Color.BLACK);
- g.drawOval(mouse.getLocation().x - 13, mouse.getLocation().y - 13, 25, 25);
- g.setStroke(new BasicStroke(1));
- g.setColor(new Color(0, 0, 0, 114));
- g.fillOval(mouse.getLocation().x - 13, mouse.getLocation().y - 13, 25, 25);
- Point MouseLoc = mouse.getLocation();
- long mpt = System.currentTimeMillis() - mouse.getPressTime();
- g.rotate(Math.toRadians(getRot(5)), mouse.getLocation().x, mouse.getLocation().y);
- if (mouse.getPressTime() == -1 || mpt >= 250) {
- g.setColor(Color.GRAY);
- g.drawLine(MouseLoc.x - 5, MouseLoc.y, MouseLoc.x + 5, MouseLoc.y);
- g.drawLine(MouseLoc.x, MouseLoc.y - 5, MouseLoc.x, MouseLoc.y + 5);
- }
- if (mpt < 250) {
- g.setColor(Color.RED);
- g.drawLine(MouseLoc.x - 5, MouseLoc.y, MouseLoc.x + 5, MouseLoc.y);
- g.drawLine(MouseLoc.x, MouseLoc.y - 5, MouseLoc.x, MouseLoc.y + 5);
- }
- }
- public void drawWave(Graphics g1, Color c) {
- Point MouseLoc = mouse.getPressLocation();
- long mpt = System.currentTimeMillis() - mouse.getPressTime();
- Graphics2D g = (Graphics2D) g1;
- g.setRenderingHints(new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON));
- g.setColor(c);
- if (mpt < 1000) {
- waveSize = (int) (mpt / 7.5);
- } else {
- waveSize = 0;
- }
- g.setStroke(new BasicStroke(3));
- g.drawOval(MouseLoc.x - (waveSize / 2), MouseLoc.y - (waveSize / 2), waveSize, waveSize);
- g.drawOval(MouseLoc.x - ((waveSize / 2) / 2), MouseLoc.y - ((waveSize / 2) / 2), waveSize / 2, waveSize / 2);
- }
- public void draw(Graphics g1) {
- Graphics2D g = (Graphics2D) g1;
- g.setRenderingHints(new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON));
- drawWave(g, Color.BLACK);
- drawTrail(g);
- drawMouse(g);
- }
- }
- public MousePaint mousePaint = new MousePaint();
- private int getTrainedSkill() {
- if (enableRange) {
- return 3;
- }
- for (int i = 0; i < skillConstants.length; i++) {
- if (skills.getCurrentExp(skillConstants[i]) - stats[i][1] > 0) {
- return i;
- }
- }
- return -1;
- }
- private String formatTime(final long time) {
- final int sec = (int) (time / 1000), h = sec / 3600, m = sec / 60 % 60, s = sec % 60;
- return (h < 10 ? "0" + h : h) + ":" + (m < 10 ? "0" + m : m) + ":"
- + (s < 10 ? "0" + s : s);
- }
- private final RenderingHints antialiasing = new RenderingHints(
- RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
- private final Font font1 = new Font("Lucida Sans Unicode", Font.PLAIN, 12);
- private final BasicStroke stroke1 = new BasicStroke(2);
- @Override
- public void onRepaint(Graphics g1) {
- Graphics2D g = (Graphics2D) g1;
- g.setRenderingHints(antialiasing);
- g.setFont(font1);
- g.setColor(Color.WHITE);
- if (trainedSkill == -1) {
- trainedSkill = getTrainedSkill();
- g.drawImage(statusback, 5, 5, null);
- g.drawImage(paint, 0, 269, null);
- g.drawString(status, 87, 23);
- mousePaint.draw(g);
- return;
- }
- runTime = System.currentTimeMillis() - startTime;
- currentLevel = skills.getRealLevel(skillConstants[trainedSkill]);
- levelsGained = currentLevel - stats[trainedSkill][0];
- xpGained = skills.getCurrentExp(skillConstants[trainedSkill]) - stats[trainedSkill][1];
- xpHour = (int) ((3600000.0 / (double) runTime) * xpGained);
- TNL = skills.getExpToNextLevel(skillConstants[trainedSkill]);
- percentTNL = skills.getPercentToNextLevel(skillConstants[trainedSkill]);
- timeTNL = (long) ((double) TNL / (double) xpHour * 3600000);
- skillName = skillNames[trainedSkill];
- kills = xpGained / spiderXP;
- killsph = (int) ((3600000.0 / (double) runTime) * kills);
- if (!hide) {
- g.drawImage(statusback, 5, 5, null);
- g.drawImage(paint, 0, 269, null);
- g.drawImage(showhide, 405, 5, null);
- g.setColor(Color.WHITE);
- g.setFont(font1);
- g.drawString("" + formatTime(runTime), 105, 359);
- g.drawString("" + skillName, 105, 386);
- g.drawString("" + currentLevel, 135, 413);
- g.drawString("" + levelsGained, 144, 440);
- g.drawString("" + status, 87, 23);
- g.drawString("" + kills, 90, 467);
- g.drawString("" + (xpGained), 326, 359);
- g.drawString("" + xpHour, 314, 386);
- g.drawString("" + TNL, 364, 413);
- g.drawString("" + formatTime(timeTNL), 381, 439);
- g.drawString("" + killsph, 328, 467);
- g.setColor(Color.RED);
- g.fillRoundRect(493, 373, 10, 100, 10, 10);
- g.setColor(Color.BLACK);
- g.setStroke(stroke1);
- g.drawRoundRect(493, 373, 10, 100, 10, 10);
- g.setColor(Color.GREEN);
- g.fillRoundRect(493, 473 - percentTNL, 10, percentTNL, 10, 10);
- g.setColor(Color.BLACK);
- g.setStroke(stroke1);
- g.drawRoundRect(493, 473 - percentTNL, 10, percentTNL, 10, 10);
- mousePaint.draw(g);
- }
- if (hide) {
- g.drawImage(showhide, 405, 5, null);
- mousePaint.draw(g);
- }
- }
- public void sendToURL(String url) {
- try {
- java.awt.Desktop.getDesktop().browse(
- java.net.URI.create(url));
- } catch (Exception e) {
- log("Error:" + e.getLocalizedMessage());
- log.severe("Please Select 'Allow Untrusted URLs' in Tools > Options");
- }
- }
- public void mouseClicked(MouseEvent e) {
- p = e.getPoint();
- if (close.contains(p) && !hide) {
- hide = true;
- } else if (close.contains(p) && hide) {
- hide = false;
- }
- else if (FuserScriptsLogoShape.contains(p) && !hide) {
- sendToURL("http://fuserscripts.org/community/");
- }
- else if (scriptLogoShape.contains(p) && !hide) {
- sendToURL("http://fuserscripts.org/community/index.php?/topic/96-giant-spider-fuser-download/");
- }
- else if (avatarSpotShape.contains(p) && !hide) {
- sendToURL("http://fuserscripts.org/community/index.php?/user/1-fuser/");
- }
- }
- public void mouseEntered(MouseEvent e) {
- }
- public void mouseExited(MouseEvent e) {
- }
- public void mouseReleased(MouseEvent e) {
- }
- public void mousePressed(MouseEvent e) {
- }
- @Override
- public void messageReceived(MessageEvent e) {
- if (e.getID() == MessageEvent.MESSAGE_SERVER) {
- final String msg = e.getMessage();
- if (msg != null) {
- if (msg.contains("You can't reach that")) {
- atSpiders = false;
- } else if (enableRange && msg.contains("There is no ammo left")) {
- noArrowsLeft = true;
- }
- }
- }
- }
- @SuppressWarnings("serial")
- public class GSFGUI extends JFrame {
- private JPanel contentPane;
- private JTextField textField1;
- private JTextField textField2;
- private JTextField textField3;
- private JTextField textField4;
- private JTextField textField5;
- private JTextField textField7;
- private JTextField textField6;
- private JTextField textField8;
- private JComboBox list1;
- private JCheckBox checkBox1;
- private JCheckBox checkBox2;
- private JCheckBox checkBox3;
- private JCheckBox checkBox4;
- private JCheckBox checkBox5;
- private JCheckBox checkBox6;
- private JRadioButton radioButton1;
- private JRadioButton radioButton2;
- private JRadioButton radioButton3;
- private JRadioButton radioButton4;
- private JRadioButton radioButton5;
- private JRadioButton radioButton7;
- private JRadioButton radioButton8;
- private JRadioButton radioButton9;
- private JButton button1;
- private JSlider mouseSpeed;
- private final ImageIcon gui_logo = new ImageIcon(Configuration.Paths.getScriptsDirectory() + File.separator + "gsfgui_logov21.png");
- private void button1ActionPerformed(ActionEvent e) {
- setVisible(false);
- GuiIsOpen = false;
- }
- /**
- * Create the frame.
- */
- public GSFGUI() {
- addWindowListener(new WindowAdapter() {
- @Override
- public void windowClosed(WindowEvent arg0) {
- guiClosed = true;
- }
- });
- setTitle("Giant Spider Fuser GUI");
- setAlwaysOnTop(true);
- setResizable(false);
- setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
- setCursor(new java.awt.Cursor(java.awt.Cursor.CROSSHAIR_CURSOR));
- setBounds(100, 100, 451, 386);
- contentPane = new JPanel();
- contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
- setContentPane(contentPane);
- contentPane.setLayout(null);
- JLabel label = new JLabel(gui_logo);
- label.setBounds(10, 11, 425, 125);
- contentPane.add(label);
- JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.TOP);
- tabbedPane.setBounds(10, 147, 425, 144);
- contentPane.add(tabbedPane);
- JPanel panel = new JPanel();
- tabbedPane.addTab("Eating", null, panel, null);
- panel.setLayout(null);
- JLabel lblEnterFoodId = new JLabel("Enter Food ID :");
- lblEnterFoodId.setBounds(10, 11, 80, 14);
- panel.add(lblEnterFoodId);
- textField1 = new JTextField();
- textField1.setBounds(102, 8, 86, 20);
- panel.add(textField1);
- textField1.setColumns(10);
- JLabel lblOr = new JLabel("OR");
- lblOr.setFont(new Font("Tahoma", Font.BOLD, 11));
- lblOr.setBounds(196, 12, 16, 14);
- panel.add(lblOr);
- JLabel lblSelectFromList = new JLabel("Select From list :");
- lblSelectFromList.setBounds(224, 11, 86, 14);
- panel.add(lblSelectFromList);
- list1 = new JComboBox();
- list1.setModel(new DefaultComboBoxModel(new String[] {"Tuna", "Lobster", "Swordfish", "Monkfish", "Shark"}));
- list1.setBounds(324, 9, 87, 20);
- panel.add(list1);
- JLabel lblEatWhenLp = new JLabel("Eat when LP is :");
- lblEatWhenLp.setBounds(10, 72, 86, 14);
- panel.add(lblEatWhenLp);
- textField2 = new JTextField();
- textField2.setText("300");
- textField2.setBounds(102, 69, 32, 20);
- panel.add(textField2);
- textField2.setColumns(10);
- textField3 = new JTextField();
- textField3.setText("400");
- textField3.setBounds(168, 69, 32, 20);
- panel.add(textField3);
- textField3.setColumns(10);
- JLabel label_1 = new JLabel("-");
- label_1.setBounds(146, 72, 10, 14);
- panel.add(label_1);
- JPanel panel_1 = new JPanel();
- tabbedPane.addTab("Banking", null, panel_1, null);
- panel_1.setLayout(null);
- JLabel lblWhereWouldYou = new JLabel("Where would you like to bank?");
- lblWhereWouldYou.setBounds(10, 11, 162, 14);
- panel_1.add(lblWhereWouldYou);
- radioButton2 = new JRadioButton("Edgeville Bank");
- radioButton2.setSelected(true);
- radioButton2.setBounds(20, 31, 97, 23);
- panel_1.add(radioButton2);
- radioButton1 = new JRadioButton("Varrock west Bank");
- radioButton1.setBounds(20, 57, 117, 23);
- panel_1.add(radioButton1);
- JLabel lblTeleportingOptions = new JLabel("Teleporting Options :");
- lblTeleportingOptions.setBounds(222, 11, 112, 14);
- panel_1.add(lblTeleportingOptions);
- radioButton3 = new JRadioButton("Don't Teleport! I like to walk!");
- radioButton3.setSelected(true);
- radioButton3.setBounds(232, 31, 171, 23);
- panel_1.add(radioButton3);
- radioButton4 = new JRadioButton("Varrock teleport Runes");
- radioButton4.setBounds(232, 57, 140, 23);
- panel_1.add(radioButton4);
- radioButton5 = new JRadioButton("Varrock teleport TAB");
- radioButton5.setBounds(232, 83, 130, 23);
- panel_1.add(radioButton5);
- JPanel panel_3 = new JPanel();
- tabbedPane.addTab("Potions", null, panel_3, null);
- panel_3.setLayout(null);
- checkBox1 = new JCheckBox("Combat Potion");
- checkBox1.setBounds(6, 32, 110, 23);
- panel_3.add(checkBox1);
- checkBox2 = new JCheckBox("Strength");
- checkBox2.setBounds(6, 58, 74, 23);
- panel_3.add(checkBox2);
- checkBox4 = new JCheckBox("Super Attack");
- checkBox4.setBounds(6, 84, 96, 23);
- panel_3.add(checkBox4);
- JLabel lblWhatPotionsWould = new JLabel("What Potions would you like to use?");
- lblWhatPotionsWould.setBounds(10, 11, 191, 14);
- panel_3.add(lblWhatPotionsWould);
- textField4 = new JTextField();
- textField4.setText("1");
- textField4.setBounds(128, 33, 26, 20);
- panel_3.add(textField4);
- textField4.setColumns(10);
- textField5 = new JTextField();
- textField5.setText("1");
- textField5.setBounds(128, 59, 26, 20);
- panel_3.add(textField5);
- textField5.setColumns(10);
- textField7 = new JTextField();
- textField7.setText("1");
- textField7.setBounds(128, 85, 26, 20);
- panel_3.add(textField7);
- textField7.setColumns(10);
- checkBox3 = new JCheckBox("Super Strength");
- checkBox3.setBounds(210, 32, 107, 23);
- panel_3.add(checkBox3);
- checkBox5 = new JCheckBox("Super Defence");
- checkBox5.setBounds(210, 58, 107, 23);
- panel_3.add(checkBox5);
- textField6 = new JTextField();
- textField6.setText("1");
- textField6.setBounds(329, 33, 26, 20);
- panel_3.add(textField6);
- textField6.setColumns(10);
- textField8 = new JTextField();
- textField8.setText("1");
- textField8.setBounds(329, 59, 26, 20);
- panel_3.add(textField8);
- textField8.setColumns(10);
- JPanel panel_4 = new JPanel();
- tabbedPane.addTab("Other", null, panel_4, null);
- panel_4.setLayout(null);
- JLabel lblRoomOptions = new JLabel("Room Options :");
- lblRoomOptions.setBounds(10, 11, 83, 14);
- panel_4.add(lblRoomOptions);
- radioButton8 = new JRadioButton("Room 1 (Main room)");
- radioButton8.setSelected(true);
- radioButton8.setBounds(20, 32, 132, 23);
- panel_4.add(radioButton8);
- radioButton9 = new JRadioButton("Room 2 (The Small room)");
- radioButton9.setBounds(20, 58, 157, 23);
- panel_4.add(radioButton9);
- radioButton7 = new JRadioButton("Change Randomly Every trip");
- radioButton7.setBounds(20, 84, 171, 23);
- panel_4.add(radioButton7);
- checkBox6 = new JCheckBox("Use Range?");
- checkBox6.setBounds(218, 32, 89, 23);
- panel_4.add(checkBox6);
- JLabel lblRangeOptions = new JLabel("Range Options :");
- lblRangeOptions.setBounds(208, 11, 89, 14);
- panel_4.add(lblRangeOptions);
- JLabel lblthisWillPick = new JLabel("(This will pick up and equip arrows)");
- lblthisWillPick.setBounds(218, 62, 193, 14);
- panel_4.add(lblthisWillPick);
- //---- buttonGroup1 ----
- ButtonGroup buttonGroup1 = new ButtonGroup();
- buttonGroup1.add(radioButton1);
- buttonGroup1.add(radioButton2);
- //---- buttonGroup2 ----
- ButtonGroup buttonGroup2 = new ButtonGroup();
- buttonGroup2.add(radioButton3);
- buttonGroup2.add(radioButton4);
- buttonGroup2.add(radioButton5);
- //---- buttonGroup3 ----
- ButtonGroup buttonGroup3 = new ButtonGroup();
- buttonGroup3.add(radioButton7);
- buttonGroup3.add(radioButton8);
- buttonGroup3.add(radioButton9);
- JPanel panel_5 = new JPanel();
- tabbedPane.addTab("Mouse", null, panel_5, null);
- panel_5.setLayout(null);
- JLabel lblSetMouseSpeed = new JLabel("Set Mouse Speed :");
- lblSetMouseSpeed.setBounds(10, 11, 96, 14);
- panel_5.add(lblSetMouseSpeed);
- mouseSpeed = new JSlider();
- mouseSpeed.setValue(6);
- mouseSpeed.setMaximum(10);
- mouseSpeed.setMinimum(1);
- mouseSpeed.setPaintLabels(true);
- mouseSpeed.setPaintTicks(true);
- mouseSpeed.setSnapToTicks(true);
- mouseSpeed.setBounds(66, 53, 200, 31);
- panel_5.add(mouseSpeed);
- JLabel lblFaster = new JLabel("Faster");
- lblFaster.setBounds(276, 53, 31, 14);
- panel_5.add(lblFaster);
- JLabel lblLower = new JLabel("Slower");
- lblLower.setBounds(19, 53, 37, 14);
- panel_5.add(lblLower);
- button1 = new JButton("Start Fusing!");
- button1.setFont(new Font("Tahoma", Font.PLAIN, 24));
- button1.setBounds(10, 302, 425, 45);
- button1.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- button1ActionPerformed(e);
- }
- });
- contentPane.add(button1);
- }
- }
- @SuppressWarnings("serial")
- public class updateChecker extends JFrame {
- private JPanel contentPane;
- private void pbthreadActionPerformed(ActionEvent e) {
- openThread(PBthread);
- stopScript(false);
- uc.dispose();
- }
- private void fsthreadActionPerformed(ActionEvent e) {
- openThread(FSthread);
- stopScript(false);
- uc.dispose();
- }
- private void cancelActionPerformed(ActionEvent e) {
- stopScript(false);
- uc.dispose();
- }
- /**
- * Create the frame.
- */
- public updateChecker() {
- setTitle("Giant Spider Fuser | Update Checker");
- setResizable(false);
- setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
- setBounds(100, 100, 450, 150);
- contentPane = new JPanel();
- contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
- setContentPane(contentPane);
- contentPane.setLayout(null);
- JLabel lblNewVersionAvailable = new JLabel("New Version Available!");
- lblNewVersionAvailable.setBounds(12, 13, 197, 16);
- lblNewVersionAvailable.setFont(new Font("Lucida Sans Unicode", Font.PLAIN, 18));
- contentPane.add(lblNewVersionAvailable);
- JLabel lblItsRecommendedTo = new JLabel("Its Recommended to Download the Latest Version!");
- lblItsRecommendedTo.setBounds(172, 41, 266, 16);
- contentPane.add(lblItsRecommendedTo);
- JButton btnVisitScriptThread = new JButton("Visit PB Script Thread");
- btnVisitScriptThread.setBounds(6, 82, 130, 34);
- contentPane.add(btnVisitScriptThread);
- JButton btnVisitOfficialFuserscripts = new JButton("Visit Official FuserScripts Thread");
- btnVisitOfficialFuserscripts.setBounds(148, 82, 187, 34);
- contentPane.add(btnVisitOfficialFuserscripts);
- JButton btnCancel = new JButton("Cancel");
- btnCancel.setBounds(347, 82, 81, 34);
- contentPane.add(btnCancel);
- btnCancel.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- cancelActionPerformed(e);
- }
- });
- btnVisitScriptThread.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- pbthreadActionPerformed(e);
- }
- });
- btnVisitOfficialFuserscripts.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- fsthreadActionPerformed(e);
- }
- });
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement