- import java.awt.*;
- import java.awt.event.*;
- import java.awt.image.BufferedImage;
- import java.io.*;
- import java.net.*;
- import javax.imageio.ImageIO;
- import org.powerbot.concurrent.Task;
- import org.powerbot.concurrent.strategy.Condition;
- import org.powerbot.concurrent.strategy.Strategy;
- import org.powerbot.game.api.ActiveScript;
- import org.powerbot.game.api.Manifest;
- import org.powerbot.game.api.methods.Calculations;
- import org.powerbot.game.api.methods.Game;
- import org.powerbot.game.api.methods.Tabs;
- import org.powerbot.game.api.methods.Widgets;
- import org.powerbot.game.api.methods.input.Mouse;
- import org.powerbot.game.api.methods.interactive.NPCs;
- import org.powerbot.game.api.methods.interactive.Players;
- import org.powerbot.game.api.methods.node.GroundItems;
- import org.powerbot.game.api.methods.tab.Inventory;
- import org.powerbot.game.api.methods.tab.Skills;
- import org.powerbot.game.api.methods.widget.Camera;
- import org.powerbot.game.api.util.Filter;
- import org.powerbot.game.api.util.Random;
- import org.powerbot.game.api.util.Time;
- import org.powerbot.game.api.util.Timer;
- import org.powerbot.game.api.wrappers.Area;
- import org.powerbot.game.api.wrappers.Tile;
- import org.powerbot.game.api.wrappers.interactive.NPC;
- import org.powerbot.game.api.wrappers.node.GroundItem;
- import org.powerbot.game.api.wrappers.node.Item;
- import org.powerbot.game.api.wrappers.widget.WidgetChild;
- import org.powerbot.game.bot.event.listener.PaintListener;
- import org.powerbot.game.api.methods.Walking;
- @Manifest(name = "Deadly Red Spider Killer", authors = "Remco Borst", version = 1.0, description = "Kills deadly red spiders for XP in the Varroc dungeon and picks up charms ( start at the spiders )", premium = false)
- public class RDSK extends ActiveScript implements PaintListener {
- //Paint variables
- private final RenderingHints antialiasing = new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
- private final Color color3 = new Color(255, 255, 255);
- private final BasicStroke stroke1 = new BasicStroke(1);
- private final Font font1 = new Font("Arial", 0, 12);
- private final Font font2 = new Font("Arial", 1, 16);
- // XP int's
- private static int startExp;
- private static long startTime;
- public int iAttackXP, iStrengthXP, iDefenceXP, iConstitutionXP, iRangeXP,
- iMagicXP;
- public int iAttack2go, iStrength2go, iDefence2go, iConstitution2go;
- // Levels
- public int iCombatLVL;
- public int iAttackLVL, iStrengthLVL, iDefenceLVL, iConstitutionLVL,
- iRangeLVL, iMagicLVL;
- public boolean cameraChanged = false;
- public boolean botStarted = false;
- public boolean frameOpened = false;
- public boolean pickUpCharms = true;
- @Override
- protected void setup() {
- // Set Starting XP per skill
- iAttackXP = Skills.getExperience(Skills.ATTACK);
- iStrengthXP = Skills.getExperience(Skills.STRENGTH);
- iDefenceXP = Skills.getExperience(Skills.DEFENSE);
- iConstitutionXP = Skills.getExperience(Skills.CONSTITUTION);
- iRangeXP = Skills.getExperience(Skills.RANGE);
- iMagicXP = Skills.getExperience(Skills.MAGIC);
- // Set LVL's
- iAttackLVL = Skills.getLevel(Skills.ATTACK);
- iStrengthLVL = Skills.getLevel(Skills.STRENGTH);
- iDefenceLVL = Skills.getLevel(Skills.DEFENSE);
- iConstitutionLVL = Skills.getLevel(Skills.CONSTITUTION);
- iRangeLVL = Skills.getLevel(Skills.RANGE);
- iMagicLVL = Skills.getLevel(Skills.MAGIC);
- iCombatLVL = Players.getLocal().getLevel();
- startTime = System.currentTimeMillis();
- try {
- openGUI();
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- // Execute Take
- Take Take = new Take();
- provide(new Strategy(Take, Take));
- // AntiBan
- antiBan antiBan = new antiBan();
- provide(new Strategy(antiBan, antiBan));
- // Execute Heal
- Heal Heal = new Heal();
- provide(new Strategy(Heal, Heal));
- // Check and walk to area.
- areaCheck areaCheck = new areaCheck();
- provide(new Strategy(areaCheck, areaCheck));
- // Execute openInvetory
- openInvetory openInvetory = new openInvetory();
- provide(new Strategy(openInvetory, openInvetory));
- // Execute runCheck
- runCheck runCheck = new runCheck();
- provide(new Strategy(runCheck, runCheck));
- // Execute runCheck
- moveCameraUp moveCameraUp = new moveCameraUp();
- provide(new Strategy(moveCameraUp, moveCameraUp));
- // Execute Attack.
- Attack Attack = new Attack();
- provide(new Strategy(Attack, Attack));
- }
- Timer xxx = new Timer(0);
- //Idk whos function this is, post name and credit will be given.
- private String formatTime(final long milliseconds)
- {
- final long t_seconds = milliseconds / 1000;
- final long t_minutes = t_seconds / 60;
- final long t_hours = t_minutes / 60;
- final long seconds = t_seconds % 60;
- final long minutes = t_minutes % 60;
- final long hours = t_hours % 500;
- if( minutes < 10)
- return hours + ": 0" + minutes + ":" + seconds;
- else
- return hours + ":" + minutes + ":" + seconds;
- }
- @Override
- public void onRepaint(Graphics arg0) {
- int ExpGained = (Skills.getExperiences()[Skills.STRENGTH] - iStrengthXP);
- int ExpPerHour = (int)Math.floor((ExpGained * 3600000D) / (System.currentTimeMillis() - startTime) / 1000);
- String exphr = ExpPerHour + "k";
- String timeElapsed = formatTime(System.currentTimeMillis() - startTime);
- Graphics2D g = (Graphics2D)arg0;
- g.setRenderingHints(antialiasing);
- g.setColor(new Color(0,0,0,120));
- g.fillRoundRect(4, 227, 229, 109, 16, 16);
- g.setColor(Color.BLACK);
- g.setStroke(stroke1);
- g.drawRoundRect(4, 227, 229, 109, 16, 16);
- g.setFont(font1);
- g.setColor(color3);
- g.drawString("Time elapsed: " + timeElapsed, 22, 266);
- g.drawString("Experience gained: " + ExpGained, 22, 283);
- g.drawString("Exp/hr: " + exphr, 22, 301);
- // g.drawString("Status: " + Status, 22, 319);
- g.setFont(font2);
- g.setColor(Color.GRAY);
- g.drawString("xScotts Stun Alcher ", 37, 248);
- g.setColor(Color.RED);
- g.fillOval(Mouse.getX() - 4, Mouse.getY() - 4, 7, 7);
- g.setColor(Color.ORANGE);
- g.fillOval(Mouse.getX() -3, Mouse.getY() -3, 5, 5);
- }
- private void Logout() {
- WidgetChild LogoutCross = Widgets.get(746, 194);
- WidgetChild LogoutButton = Widgets.get(182, 7);
- LogoutCross.click(true);
- Time.sleep(1000);
- LogoutButton.click(true);
- Time.sleep(1000);
- stop();
- }
- private class areaCheck implements Task, Condition {
- // Check if player is in the main area.. if not.. go there.
- @Override
- public boolean validate() {
- return true;
- }
- @Override
- public void run() {
- if (botStarted && !anyItems()) {
- Time.sleep(500);
- if (Players.getLocal().getInteracting() == null && !anyItems()) {
- // Main spider area
- Tile topRight = new Tile(3185, 9888, Game.getPlane());
- Tile LeftBottom = new Tile(3175, 9880, Game.getPlane());
- Tile centerTile = new Tile(3179, 9884, Game.getPlane());
- Area centerArea = new Area(topRight, LeftBottom);
- if (!centerArea.contains(Players.getLocal().getLocation())) {
- Walking.walk(centerTile);
- Time.sleep(3000);
- }
- }
- }
- }
- }
- private class runCheck implements Task, Condition {
- @Override
- public boolean validate() {
- return true;
- }
- @Override
- public void run() {
- if (botStarted && !anyItems()) {
- WidgetChild orb = Widgets.get(750, 3);
- try {
- int runPercentage = Walking.getEnergy();
- if (runPercentage == 100) {
- if (!Walking.isRunEnabled()) {
- // log.info("Turning runmode on");
- orb.interact("Turn run mode on");
- }
- } else {
- // log.info("Running percentage = "+runPercentage);
- }
- } catch (NumberFormatException nfe) {
- log.info("Not a number exception");
- }
- }
- }
- }
- private class openInvetory implements Task, Condition {
- @Override
- public boolean validate() {
- return true;
- }
- @Override
- public void run() {
- if (botStarted && !anyItems()) {
- if (!Tabs.INVENTORY.open()) {
- Tabs.INVENTORY.open();
- Time.sleep(1000);
- }
- }
- }
- }
- private class antiBan implements Task, Condition {
- @Override
- public boolean validate() {
- return true;
- }
- @Override
- public void run() {
- if (botStarted && !anyItems()) {
- int rnr = Random.nextInt(1, 600);
- switch (rnr) {
- case 300:
- Camera.setAngle(Random.nextInt(200, 900));
- break;
- case 255:
- WidgetChild stats1 = Widgets.get(746, 60);
- if (!stats1.isVisible()) {
- stats1 = Widgets.get(548, 91);
- }
- WidgetChild constitution = Widgets.get(320, 141);
- if (!constitution.isVisible()) {
- constitution = Widgets.get(320, 4);
- }
- // Open stats
- stats1.click(true);
- Time.sleep(1000);
- // Hover constitution skill
- constitution.hover();
- Time.sleep(3000);
- break;
- case 101:
- WidgetChild stats2 = Widgets.get(746, 60);
- if (!stats2.isVisible()) {
- stats2 = Widgets.get(548, 91);
- }
- WidgetChild attack = Widgets.get(320, 9);
- if (!attack.isVisible()) {
- attack = Widgets.get(320, 2);
- }
- // Open stats
- stats2.click(true);
- Time.sleep(1000);
- // Hover constitution skill
- attack.hover();
- Time.sleep(3000);
- break;
- case 58:
- Camera.setPitch(false);
- Time.sleep(1000);
- Camera.setPitch(false);
- Time.sleep(500);
- Camera.setPitch(false);
- Time.sleep(500);
- Camera.setPitch(true);
- Time.sleep(1000);
- Camera.setPitch(true);
- Time.sleep(500);
- Camera.setPitch(true);
- }
- }
- }
- }
- private class moveCameraUp implements Task, Condition {
- @Override
- public boolean validate() {
- return true;
- }
- @Override
- public void run() {
- if (botStarted) {
- if (cameraChanged == false) {
- Camera.setPitch(true);
- Time.sleep(2000);
- Camera.setPitch(true);
- Time.sleep(500);
- Camera.setPitch(true);
- cameraChanged = true;
- }
- }
- }
- }
- private class Heal implements Task, Condition {
- @Override
- public boolean validate() {
- return true;
- }
- @Override
- public void run() {
- if (botStarted) {
- int[] foodArray = { 13433, 319, 7178, 7180, 315, 2140, 2142,
- 325, 2309, 347, 355, 333, 339, 351, 329, 361, 1891,
- 1893, 1895, 1897, 1899, 1901, 379, 365, 373, 6705,
- 7946, 2293, 2299, 383, 15266, 397, 2301, 2303, 391,
- 7060, 7208, 7210, 7218, 7220, 15272, 385 };
- boolean itemFound = false;
- try {
- // Get current HP
- WidgetChild health = Widgets.get(748).getChild(8);
- int healthTotal = Integer.parseInt(health.getText());
- if (healthTotal < 190) {
- // Read inventory
- for (int inv = 0; inv < Inventory.getItems().length; inv++) {
- // See if item is food
- Item Item = Inventory.getItems()[inv];
- for (int i = 0; i < foodArray.length; i++) {
- if (foodArray[i] == Item.getId()) {
- itemFound = true;
- break;
- }
- }
- if (itemFound == true) {
- // Eat
- // log.info(""+Item.getWidgetChild().getId());
- Item.getWidgetChild().interact("Eat");
- Time.sleep(2500);
- break;
- }
- }
- if (itemFound == false) {
- // Get food from bank.
- log.info("Running away -> then log out! you're outa food!!");
- WidgetChild orb = Widgets.get(750, 3);
- if (!Walking.isRunEnabled()) {
- // log.info("Turning runmode on");
- orb.interact("Turn run mode on");
- }
- if (Walking.isRunEnabled()) {
- Walking.walk(new Tile(3188, 9888, Game
- .getPlane()));
- Time.sleep(4000);
- Walking.walk(new Tile(3203, 9888, Game
- .getPlane()));
- Time.sleep(4000);
- Walking.walk(new Tile(3205, 9880, Game
- .getPlane()));
- Time.sleep(4000);
- } else {
- Walking.walk(new Tile(3188, 9888, Game
- .getPlane()));
- Time.sleep(7000);
- Walking.walk(new Tile(3203, 9888, Game
- .getPlane()));
- Time.sleep(6000);
- Walking.walk(new Tile(3205, 9880, Game
- .getPlane()));
- Time.sleep(5000);
- }
- Logout();
- }
- }
- } catch (NumberFormatException nfe) {
- log.info("Not a number exception");
- }
- }
- }
- }
- public boolean anyItems() {
- GroundItem charm = GroundItems.getNearest(new Filter<GroundItem>() {
- @Override
- public boolean accept(GroundItem arg0) {
- int foundItem = arg0.getGroundItem().getId();
- int iGoldCharm = 12158; // Gold Charm
- int iGreenCharm = 12159; // Green Charm
- int iCrimsonCharm = 12160; // Crimson Charm
- int iBlueCharm = 12163; // Blue Charm
- if (iGoldCharm == foundItem || iGreenCharm == foundItem
- || iCrimsonCharm == foundItem
- || iBlueCharm == foundItem) {
- return true;
- } else {
- return false;
- }
- }
- });
- if (charm != null && pickUpCharms) {
- return true;
- } else {
- return false;
- }
- }
- private class Take implements Task, Condition {
- @Override
- public boolean validate() {
- return true;
- }
- @Override
- public void run() {
- if (botStarted && pickUpCharms) {
- if (Players.getLocal().getInteracting() == null) {
- // If player is free -> look for charms.
- GroundItem charm = GroundItems
- .getNearest(new Filter<GroundItem>() {
- @Override
- public boolean accept(GroundItem arg0) {
- int foundItem = arg0.getGroundItem()
- .getId();
- int iGoldCharm = 12158; // Gold Charm
- int iGreenCharm = 12159; // Green Charm
- int iCrimsonCharm = 12160; // Crimson Charm
- int iBlueCharm = 12163; // Blue Charm
- if (iGoldCharm == foundItem
- || iGreenCharm == foundItem
- || iCrimsonCharm == foundItem
- || iBlueCharm == foundItem) {
- return true;
- } else {
- return false;
- }
- }
- });
- if (charm != null) {
- if (Calculations.distance(Players.getLocal()
- .getLocation(), charm.getLocation()) > 4) {
- Walking.walk(charm.getLocation());
- Time.sleep(2000);
- }
- charm.interact("Take");
- Time.sleep(2500);
- }
- } else {
- // Skip this.
- }
- }
- }
- }
- private class Attack implements Task, Condition {
- @Override
- public boolean validate() {
- return true;
- }
- @Override
- public void run() {
- if (botStarted && !anyItems()) {
- if (Players.getLocal().getInteracting() == null) {
- NPC RDS = NPCs.getNearest(new Filter<NPC>() {
- @Override
- public boolean accept(NPC arg0) {
- int foundNpc = arg0.getId();
- int iRDS = 63; // Red Deadly Spider
- if (foundNpc == iRDS) {
- return true;
- } else {
- return false;
- }
- }
- });
- if (RDS != null) {
- if (RDS.isOnScreen() && RDS.getHpPercent() > 0) {
- // On screen and not in combat, attack
- // log.info("Attacking RDS...");
- RDS.click(true);
- Time.sleep(1500);
- }
- } else {
- //
- }
- }
- }
- }
- }
- private void openGUI() throws InterruptedException {
- Frame gui = new GUI();
- gui.setVisible(true);
- }
- class GUI extends Frame {
- private static final long serialVersionUID = 1L;
- public BufferedImage img;
- public Button bStart, PickOn, PickOff;
- // Frame instellingen
- public GUI() {
- addWindowListener(new VensterHandler());
- setLayout(null);
- // Buttons
- bStart = new Button("Start");
- bStart.setSize(100, 20);
- bStart.setLocation(470, 350);
- bStart.addActionListener(new StartHandler());
- add(bStart);
- PickOn = new Button("On");
- PickOn.setSize(40, 20);
- PickOn.setLocation(310, 155);
- PickOn.addActionListener(new PickOnHandler());
- add(PickOn);
- PickOff = new Button("Off");
- PickOff.setSize(40, 20);
- PickOff.setLocation(360, 155);
- PickOff.addActionListener(new PickOffHandler());
- add(PickOff);
- // Disable On button by default -> it's true already.
- PickOn.setEnabled(false);
- // IMAGES
- try {
- URL url = new URL(getCodeBase(),
- "http://www.myitemsale.co.uk/RDSK.jpg");
- img = ImageIO.read(url);
- } catch (IOException e) {
- // Error loading image
- }
- // SETTINGS
- setBackground(new Color(0, 0, 0));
- setSize(600, 400);
- setResizable(false);
- setTitle("Red deadly Spider Killer - By PHP-Remco");
- setVisible(true);
- }
- // URL fix
- private URL getCodeBase() {
- return null;
- }
- // Graphics
- public void paint(Graphics g) {
- g.drawImage(img, 0, 0, this);
- }
- // START BOT SCRIPT
- private class StartHandler implements ActionListener {
- public void actionPerformed(ActionEvent e) {
- // Start script here.
- botStarted = true;
- dispose();
- }
- }
- private class PickOnHandler implements ActionListener {
- public void actionPerformed(ActionEvent e) {
- // Start script here.
- pickUpCharms = true;
- PickOn.setEnabled(false);
- PickOff.setEnabled(true);
- }
- }
- private class PickOffHandler implements ActionListener {
- public void actionPerformed(ActionEvent e) {
- // Start script here.
- pickUpCharms = false;
- PickOff.setEnabled(false);
- PickOn.setEnabled(true);
- }
- }
- private class VensterHandler extends WindowAdapter {
- public void windowClosing(WindowEvent e) {
- // Start script here.
- botStarted = true;
- dispose();
- }
- }
- }
- }