Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Imports
- import org.rsbot.event.listeners.PaintListener;
- import org.rsbot.script.Script;
- import org.rsbot.script.ScriptManifest;
- import org.rsbot.script.methods.GrandExchange.GEItem;
- import org.rsbot.script.wrappers.RSGroundItem;
- import org.rsbot.script.wrappers.RSPath;
- import org.rsbot.script.wrappers.RSTile;
- import java.awt.*;
- import java.awt.event.ActionEvent;
- import java.awt.event.ActionListener;
- import java.awt.event.MouseEvent;
- import java.awt.event.MouseListener;
- import javax.swing.ButtonGroup;
- import javax.swing.JButton;
- import javax.swing.JCheckBox;
- import javax.swing.JFrame;
- import javax.swing.JLabel;
- import javax.swing.JRadioButton;
- import javax.swing.SwingConstants;
- import javax.swing.SwingUtilities;
- @ScriptManifest(
- authors = { "Thondar" },
- name = "Asher", version = 0.01, keywords = {"Ash", "money", "low", "GE"}, description = "Picks Ashes at GE")
- public class Asher extends Script {
- //Variables
- // - Integers
- int Ashes = 592;
- int ashes_gained = 0;
- int ashes_price = 0;
- int money_gained = 0;
- int ashes_in_bank = 0;
- int cache = 0;
- int ashes_hr = 0;
- int money_hr = 0;
- int x = 0;
- int y = 0;
- // - Strings, GEItems, RSTiles, Booleans, GUIs, RSPaths
- String antiban_status;
- String location;
- GEItem ashes_ge;
- RSTile GETile = new RSTile (3168, 3487);
- RSTile DVTile = new RSTile (3092, 3247);
- boolean transparent = false;
- boolean rest_enabled = true;
- boolean guistart = false;
- boolean started_w = false;
- AshesToGold_GUI gui = new AshesToGold_GUI();
- RSPath path;
- // - Anti-Ban
- int ar_1 = 1;
- int ar_2 = 1;
- boolean antiban_t = true;
- // - Time
- public long startTime = 0;
- public long millis = 0;
- public long hours = 0;
- public long minutes = 0;
- public long seconds = 0;
- public long last = 0;
- //Startup program
- public boolean onStart() {
- //Timer
- startTime = System.currentTimeMillis();
- //Prices
- log("Loading script");
- ashes_ge = grandExchange.lookup(Ashes);
- ashes_price = ashes_ge.getGuidePrice();
- log("Ash price: " + ashes_price);
- mouse.setSpeed(random(4, 7));
- camera.setPitch(true);
- log("AshesToGold Started");
- return true;
- }
- //Finishing Program
- public void onFinish(){
- log("Ashes Gained: " + ashes_gained);
- log("Money Gained: " + money_gained);
- log("Thanks for using AshesToGold!");
- }
- //The all mighty loop
- @Override
- public int loop() {
- //Start walking program
- if (started_w == false) {
- if (location == "Grand Exchange") {
- walktoge();
- } else if (location == "Draynor Village") {
- walktodv();
- }
- }
- //Start the Anti-Ban
- if (antiban_t == true) {
- antiban();
- } else {
- antiban_status = "Off";
- }
- //Sets camera pitch
- if (camera.getPitch() < 1851) {
- camera.setPitch(true);
- }
- //If rest is enabled
- if (rest_enabled == true && walking.getEnergy() < random(20, 30) || walking.getEnergy() < 20) {
- while (walking.getEnergy() < random(70, 90)) {
- if (walking.rest() == false) {
- walking.rest();
- sleep(random(2000, 3000));
- }
- }
- } else {
- //Main looping sequence
- //Check if player is running
- if (!walking.isRunEnabled() && walking.getEnergy() > random(50, 90)) {
- walking.setRun(true);
- }
- //Get ashes or go to bank
- if (!inventory.isFull()) {
- takeashes();
- } else {
- inventory.dropAllExcept(Ashes);
- if (inventory.isFull()) {
- if (location == "Grand Exchange") {
- walktoge();
- } else if (location == "Draynor Village") {
- walktodv();
- }
- sleep(random(1000, 2000));
- bankashes();
- }
- }
- }
- //Final commands
- started_w = true;
- ash_count();
- return random(300, 500);
- }
- //Anti-Ban Program
- public void antiban() {
- // 1/40 chance of running an anti-ban
- ar_1 = random(1, 40);
- if (ar_1 == 27) {
- ar_2 = random(1, 8);
- if (ar_2 == 1){
- antiban_status = "Mouse";
- mouse.moveOffScreen();
- sleep(random(200, 1000));
- }
- else if (ar_2 == 2) {
- antiban_status = "Mouse";
- mouse.moveSlightly();
- mouse.moveSlightly();
- mouse.moveSlightly();
- }
- else if (ar_2 == 3) {
- antiban_status = "Mouse";
- mouse.setSpeed(random(4, 8));
- }
- else if (ar_2 == 4) {
- antiban_status = "Mouse";
- mouse.moveSlightly();
- mouse.moveSlightly();
- }
- else if (ar_2 == 5) {
- antiban_status = "Mouse";
- mouse.moveOffScreen();
- sleep(random(3000, 6000));
- }
- else if (ar_2 == 6) {
- antiban_status = "Camera";
- if(random(1, 3) == 2) {
- int r = random(1,2);
- camera.setAngle(random(1,359));
- if(r!=1)
- camera.setPitch(random(1,99));
- }
- }
- else if (ar_2 == 7) {
- antiban_status = "Camera";
- if(random(1, 3) == 2) {
- int r = random(1,2);
- camera.setAngle(random(1,359));
- if(r!=1)
- camera.setPitch(random(1,99));
- }
- }
- else if (ar_2 == 8) {
- antiban_status = "Camera";
- if(random(1, 3) == 2) {
- int r = random(1,2);
- camera.setAngle(random(1,359));
- if(r!=1)
- camera.setPitch(random(1,99));
- }
- }
- else {
- antiban_status = "Running";
- }
- sleep(2000);
- }
- antiban_status = "Running";
- }
- //Take ashes action
- public void takeashes() {
- RSGroundItem ashes = groundItems.getNearest(Ashes);
- if (!getMyPlayer().isMoving()) {
- if ((groundItems.getNearest(Ashes) != null) && (calc.tileOnScreen(ashes.getLocation())) && getMyPlayer().isIdle()) {
- ashes.doAction("Take");
- }
- else if ((groundItems.getNearest(Ashes) != null) && (!calc.tileOnScreen(ashes.getLocation()))) {
- walking.walkTileMM(groundItems.getNearest(Ashes).getLocation());
- cursor_move();
- sleep(random(1000, 1500));
- if (!calc.tileOnScreen(ashes.getLocation()) && getMyPlayer().isIdle() && !getMyPlayer().isMoving()) {
- if (location == "Grand Exchange") {
- walktoge();
- } else if (location == "Draynor Village") {
- walktodv();
- }
- }
- } else {
- if (getMyPlayer().getLocation() == GETile) {
- cursor_move();
- sleep(random(2000, 5000));
- } else {
- if (location == "Grand Exchange") {
- walktoge();
- } else if (location == "Draynor Village") {
- walktodv();
- }
- }
- }
- }
- }
- //Check ashes
- public void ash_count() {
- ashes_gained = inventory.getCount(Ashes) + ashes_in_bank;
- money_gained = ashes_gained * ashes_price;
- }
- //Cursor move
- public void cursor_move() {
- if (random(1, 8) == 2) {
- mouse.moveSlightly();
- mouse.moveSlightly();
- }
- }
- //Walk to GE program
- public void walktoge() {
- walkto(GETile);
- }
- //Walk to DV program
- public void walktodv() {
- walkto(DVTile);
- }
- //Walking program
- public void walkto(RSTile tile) {
- path = walking.getPath(tile);
- path.traverse();
- }
- //Bank ashes program
- public void bankashes() {
- if (!getMyPlayer().isMoving()) {
- bank.open();
- mouse.setSpeed(8);
- sleep(random(1500, 2000));
- cache = inventory.getCount(Ashes);
- sleep(random(200, 300));
- bank.depositAll();
- sleep(random(2000, 2500));
- bank.close();
- if (inventory.getCount(Ashes) == 0) {
- ashes_in_bank += cache;
- }
- cache = 0;
- sleep(random(200, 500));
- mouse.setSpeed(random(4, 8));
- }
- }
- //Toggles for paint
- public void toggles() {
- //Mouse check
- //(x >= *most left* && x < *most left* + *plus most right* && y >= *most up* && y < *most up* + *plus most down*)
- //Rest toggle
- if (x >= 583 && x < 583 + 44 && y >= 409 && y < 409 + 18) {
- rest_enabled = !rest_enabled;
- x = 0;
- y = 0;
- }
- //Transparent toggle
- if (x >= 643 && x < 643 + 100 && y >= 409 && y < 409 + 18) {
- transparent = !transparent;
- x = 0;
- y = 0;
- }
- //Anti-Ban toggle
- if (x >= 619 && x < 619 + 50 && y >= 430 && y < 430 + 18) {
- antiban_t = !antiban_t;
- x = 0;
- y = 0;
- }
- }
- //Mouse location for toggles
- public void mouseClicked(MouseEvent e) {
- x = e.getX();
- y = e.getY();
- }
- //Variables for paint
- // - Colors
- private Color color1 = new Color(0, 0, 0);
- private Color color2 = new Color(255, 255, 255);
- private Color color3 = new Color(51, 255, 0);
- private Color color4 = new Color(255, 0, 0);
- private Color mouse1 = new Color(51, 255, 0);
- // - Fonts
- private final Font font1 = new Font("Arial", 1, 24);
- private final Font font2 = new Font("Arial", 1, 12);
- private final Font font3 = new Font("Arial", 1, 10);
- private final Font font4 = new Font("Arial", 1, 14);
- // - Other
- private final BasicStroke stroke1 = new BasicStroke(1);
- //Java graphics
- public void onRepaint(Graphics g1) {
- Graphics2D g = (Graphics2D)g1;
- if (transparent == true) {
- color1 = new Color(0, 0, 0, 50);
- color2 = new Color(255, 255, 255, 50);
- color3 = new Color(51, 255, 0, 50);
- color4 = new Color(255, 0, 0, 50);
- } else {
- color1 = new Color(0, 0, 0);
- color2 = new Color(255, 255, 255);
- color3 = new Color(51, 255, 0);
- color4 = new Color(255, 0, 0);
- }
- //Check toggles
- toggles();
- //Cursor paint
- final int mouse_x = mouse.getLocation().x;
- final int mouse_y = mouse.getLocation().y;
- g.setColor(mouse1);
- g.fillOval(mouse_x - 10, mouse_y - 1, 22, 3);
- g.fillOval(mouse_x - 1, mouse_y - 10, 3, 22);
- // Time calculations
- ashes_hr = (int) ((ashes_gained) * 3600000D / (System.currentTimeMillis() - startTime));
- money_hr = ashes_hr * ashes_price;
- millis = System.currentTimeMillis() - startTime;
- hours = millis / (1000 * 60 * 60);
- millis -= hours * (1000 * 60 * 60);
- minutes = millis / (1000 * 60);
- millis -= minutes * (1000 * 60);
- seconds = millis / 1000;
- // Background
- g.setColor(color1);
- g.fillRect(549, 209, 187, 254);
- g.setColor(color2);
- g.setStroke(stroke1);
- g.drawRect(549, 209, 187, 254);
- // Text
- g.setFont(font1);
- g.drawString("AshesToGold", 562, 238);
- g.setFont(font2);
- g.drawString("By Nunnsy", 609, 256);
- g.setFont(font3);
- g.drawString("Ashes: " + ashes_gained, 557, 286);
- g.drawString("Money: " + money_gained, 557, 300);
- g.drawString("Ashes/Hr: " + ashes_hr, 643, 286);
- g.drawString("Money/Hr: " + money_hr, 643, 300);
- g.drawString("Running: " + hours +":"+ minutes + ":" + seconds, 557, 272);
- g.drawString("Ash Price: " + ashes_price, 557, 314);
- g.drawString("Location: " + location, 557, 342);
- g.drawString("Anti-Ban: " + antiban_status, 557, 328);
- // Settings
- g.setFont(font4);
- g.drawString("---------- Settings ----------", 559, 364);
- g.setFont(font3);
- if (rest_enabled == true) {
- g.setColor(color3);
- } else {
- g.setColor(color4);
- }
- g.drawString("Resting", 588, 420);
- if (transparent == true) {
- g.setColor(color3);
- } else {
- g.setColor(color4);
- }
- g.drawString("Transparent", 647, 420);
- if (antiban_t == true) {
- g.setColor(color3);
- } else {
- g.setColor(color4);
- }
- g.drawString("Anti-Ban", 620, 442);
- }
- //AshesToGold GUI class
- public class AshesToGold_GUI extends JFrame {
- private static final long serialVersionUID = 1L;
- //Main control
- public AshesToGold_GUI() {
- initGUI();
- }
- //GUI code
- private void initGUI() {
- getContentPane().setLayout(null);
- //AshesToGold label
- JLabel lblAshestogold = new JLabel("AshesToGold");
- lblAshestogold.setHorizontalAlignment(SwingConstants.CENTER);
- lblAshestogold.setFont(new Font("Arial", Font.PLAIN, 24));
- lblAshestogold.setBounds(6, 6, 242, 43);
- getContentPane().add(lblAshestogold);
- //Location label
- JLabel lblLocation = new JLabel("Location:");
- lblLocation.setBounds(16, 49, 61, 16);
- getContentPane().add(lblLocation);
- setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- setBounds(100, 100, 254, 261);
- //Font for Java objects
- lblAshestogold.setFont(new Font("Arial", Font.PLAIN, 24));
- lblAshestogold.setHorizontalAlignment(SwingConstants.CENTER);
- //Location - Grand Exchange
- final JRadioButton rdbtnGrandExchange = new JRadioButton("Grand Exchange");
- rdbtnGrandExchange.setSelected(true);
- rdbtnGrandExchange.setBounds(76, 45, 141, 23);
- getContentPane().add(rdbtnGrandExchange);
- //Location - Draynor Village
- final JRadioButton rdbtnDraynorVillage = new JRadioButton("Draynor Village");
- rdbtnDraynorVillage.setBounds(76, 69, 141, 23);
- getContentPane().add(rdbtnDraynorVillage);
- //Anti-Ban check box
- final JCheckBox chckbxAntiban = new JCheckBox("Anti-Ban");
- chckbxAntiban.setSelected(true);
- chckbxAntiban.setBounds(6, 104, 94, 23);
- getContentPane().add(chckbxAntiban);
- //Resting check box
- final JCheckBox chckbxResting = new JCheckBox("Resting");
- chckbxResting.setSelected(true);
- chckbxResting.setBounds(6, 127, 79, 23);
- getContentPane().add(chckbxResting);
- //Transparent check box
- final JCheckBox chckbxTransparent = new JCheckBox("Transparent");
- chckbxTransparent.setBounds(6, 150, 107, 23);
- getContentPane().add(chckbxTransparent);
- //Start button
- JButton btnStart = new JButton("Start!");
- btnStart.setFont(new Font("Arial", Font.PLAIN, 20));
- btnStart.setBounds(6, 190, 242, 43);
- getContentPane().add(btnStart);
- //Group location buttons
- final ButtonGroup place = new ButtonGroup();
- place.add(rdbtnGrandExchange);
- place.add(rdbtnDraynorVillage);
- //Functions
- btnStart.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent arg0) {
- //Location
- if (rdbtnGrandExchange.isSelected()) {
- location = "Grand Exchange";
- }
- else if (rdbtnDraynorVillage.isSelected()) {
- location = "Draynor Village";
- }
- //Check box settings
- transparent = chckbxTransparent.getModel().isSelected();
- rest_enabled = chckbxResting.getModel().isSelected();
- antiban_t = chckbxAntiban.getModel().isSelected();
- //GUI helpers
- guistart = true;
- gui.setVisible(false);
- }
- });
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement