Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.awt.*;
- import java.awt.event.*;
- import java.io.IOException;
- import javax.imageio.ImageIO;
- import java.net.URL;
- import java.text.NumberFormat;
- import java.util.LinkedList;
- import java.awt.event.MouseEvent;
- import java.awt.event.MouseListener;
- import org.rsbot.event.events.MessageEvent;
- import org.rsbot.event.listeners.MessageListener;
- import org.rsbot.event.listeners.PaintListener;
- import org.rsbot.script.methods.*;
- import org.rsbot.script.wrappers.*;
- import org.rsbot.script.Script;
- import org.rsbot.script.ScriptManifest;
- @ScriptManifest(authors = "Algol", name = "Fally Soft Clay", version = 0.01, description = "Softclay @ Fally")
- public class FallySoftClay extends Script implements MessageListener, PaintListener, MouseListener, MouseMotionListener{
- /*
- Previous versions:
- v0.1
- */
- //Version of script
- public final double VERSION = getClass().getAnnotation(ScriptManifest.class).version();
- //Number formatter
- public final NumberFormat nf = NumberFormat.getInstance();
- //Variables
- public String serverMsg = "";
- public String status = "";
- public String program = ".:: Falador Soft Clay, by Algol ::.";
- public RSTile atWaterPumpTile = new RSTile(2949, 3382);
- public RSTile waterPumpTile = new RSTile(2947, 3383);
- public RSArea bankArea = new RSArea(new RSTile(2943, 3368), new RSTile(2947, 3373));
- public int totalSCMade = 0;
- public int scInBank = 0;
- public int totalSCInBank = 0;
- public int totalCInBank = 0;
- public int clayID = 434;
- public int softClayID = 1761;
- public int bucketID = 1925;
- public int wBucketID = 1929;
- public int waterPumpID = 11661;
- public int bankBoothID = 11758;
- public int bankerID = 6200;
- //Timer variables
- public long startTime = System.currentTimeMillis();
- public long runTime = 0;
- public long endTime = 0;
- //GUI stuff
- private final RenderingHints rh = new RenderingHints(RenderingHints.KEY_TEXT_ANTIALIASING,
- RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
- Font textFont = new Font("Allerta", Font.PLAIN, 10);
- Font textFontB = new Font("Allerta", Font.BOLD, 10);
- Color BLACK = new Color(0, 0, 0, 255);
- Color TXTBLUE = new Color(50, 161, 226, 255);
- Color TXTCOLOR = new Color(255, 255, 255, 191);
- Color TXTBLUE2 = new Color(50, 112, 226, 255);
- Color WHITE = new Color(255, 250, 255);
- Color TRANSPARRENT = new Color(0, 0, 0, 175);
- Color TRANSPARRENT2 = new Color(0, 0, 0, 145);
- private final LinkedList<MousePathPoint> mousePath = new LinkedList<MousePathPoint>();
- Color myColor = new Color(122, 25, 17, 150);
- Point p;
- //private enum st = { GOBANK, GORANGE, ATBANK, ATRANGE, COOKING };
- /*___________________________________________________________________________*/
- public boolean onStart(){
- nf.setMinimumIntegerDigits(2);
- mouse.setSpeed(random(6,9));
- camera.setPitch(true);
- return true;
- }
- /*___________________________________________________________________________*/
- public void onFinish(){
- log("Thank you for using Fallador Soft Clay, by Algol");
- log("Script ran for " + formatTime(runTime));
- log("You've made " + totalSCMade + " clay into soft clay");
- }
- /*___________________________________________________________________________*/
- public void banking() {
- int fail = 0;
- sleep(300,400);
- int curCountSC = inventory.getCount(softClayID);
- int curCountWBuckets = inventory.getCount(wBucketID);
- int curCountBuckets = inventory.getCount(bucketID);
- int curCountClay = inventory.getCount(clayID);
- int curInventoryCount = inventory.getCount();
- if (curInventoryCount == 0) {
- int bankCountWBucket = bank.getCount(wBucketID);
- int bankCountBucket = bank.getCount(bucketID);
- if (bankCountWBucket >= 14) {
- bank.withdraw(wBucketID, 14);
- } else if (bankCountWBucket < 14 && bankCountWBucket > 0) {
- bank.withdraw(wBucketID, bankCountWBucket);
- } else if (bankCountBucket >= 14) {
- bank.withdraw(bucketID, 14);
- } else if (bankCountBucket < 14 && bankCountBucket > 0) {
- bank.withdraw(bucketID, bankCountBucket);
- } else {
- log("No buckets with or without water found!!!");
- stopScript();
- }
- }
- if (curCountSC > 0) {
- bank.deposit(softClayID, 0);
- sleep(300,500);
- }
- if (curCountClay == 0) {
- if (bank.getCount(clayID) == 0) {
- log("Out of clay!!!");
- stopScript();
- }
- if (random(0,10) == 1) {
- bank.withdraw(clayID, 0);
- } else {
- bank.withdraw(clayID, 28 - inventory.getCount());
- }
- }
- sleep(100,200);
- scInBank = bank.getCount(softClayID);
- totalCInBank = bank.getCount(clayID);
- }
- public boolean atWaterPump() {
- double dist = calc.distanceBetween(players.getMyPlayer().getLocation(), atWaterPumpTile);
- return (dist < 3) ? true : false;
- }
- public boolean atBank() {
- return bankArea.contains(players.getMyPlayer().getLocation()) ? true : false;
- }
- public boolean madeAllSC() {
- if (inventory.getCount() == 0) {
- return true;
- } else if (inventory.getCount(clayID) == 0) {
- return true;
- }
- return ( (inventory.getCount(softClayID) > 0) && (inventory.getCount(clayID) == 0) ) ? true : false;
- }
- public boolean doRest() {
- int energy = walking.getEnergy();
- status = "Resting";
- for (int d = 0; d < 5; d++) {
- interfaces.getComponent(750, 6).doAction("Rest");
- sleep(random(1000, 1400));
- if (getMyPlayer().getAnimation() == 12108 || getMyPlayer().getAnimation() == 2033 || getMyPlayer().getAnimation() == 2716 || getMyPlayer().getAnimation() == 11786 || getMyPlayer().getAnimation() == 5713) {
- break;
- }
- if (d == 4) {
- log("Rest failed!");
- return false;
- }
- }
- energy = walking.getEnergy();
- int maxWait = 0;
- int targetEnergy = random(90,95);
- while (energy < targetEnergy && maxWait++ <= 111) {
- sleep(random(250, 300));
- energy = walking.getEnergy();
- }
- return true;
- }
- private void antiban() {
- int rng = random(1, 10);
- switch (rng) {
- case 1:
- if (random(1, 57) != 1)
- return;
- mouse.move(random(10, 75), random(10, 85));
- status = "Antiban";
- return;
- case 2:
- if (random(1, 30) != 1)
- return;
- int angle = camera.getAngle() + random(-30, 30);
- if (angle < 0) {
- angle = random(0, 10);
- status = "Antiban";
- }
- if (angle > 359) {
- angle = random(0, 10);
- status = "Antiban";
- }
- camera.setAngle(angle);
- status = "Antiban";
- return;
- case 3:
- if (random(1, 15) != 1)
- return;
- try {
- mouse.moveSlightly();
- status = "Antiban";
- } catch (Exception e) {
- }
- return;
- default:
- return;
- }
- }
- @Override
- public int loop() {
- int fail = 0;
- if (!game.isLoggedIn()) {
- status = "not logged in";
- return random(100,200);
- }
- antiban();
- if(walking.getEnergy() < 10) {
- doRest();
- }
- antiban();
- if (!atBank() && madeAllSC()) {
- status = "Walking to Bank";
- walking.walkTileMM(new RSTile(2946, 3369)); // walk to bank
- sleep(800,1100);
- } else if (atBank() && ( madeAllSC() || inventory.getCount() == 0 ) ) {
- status = "Banking";
- RSObject booth = objects.getNearest(bankBoothID);
- if (booth.isOnScreen()) {
- boolean bankClicked = false;
- if (bank.isOpen()) {
- banking();
- } else {
- fail = 0;
- while (fail++<50 && !bankClicked) {
- sleep(25,50);
- if (booth.doAction("use-quickly")) {
- bankClicked = true;
- }
- }
- fail = 0;
- while (fail++<50 &&!bank.isOpen()) {
- sleep(25,50);
- }
- if (bank.isOpen()) {
- banking();
- } else {
- status = "Failed to click the banker. Please wait";
- }
- }
- }
- } else if (!atWaterPump() && !madeAllSC()) {
- status = "Walking to Waterpump";
- walking.walkTileMM(atWaterPumpTile); // walk to waterpump
- sleep(800,1100);
- } else if (atWaterPump() && !madeAllSC() && !players.getMyPlayer().isMoving()) {
- if (inventory.getCount(wBucketID) == 0) { //no buckets with water in inventory
- if (inventory.getCount(bucketID) == 0) {//no buckets in inventory, so stop script
- log("No buckets!!!");
- stopScript();
- }
- inventory.getItem(bucketID).doClick(true);
- mouse.moveRandomly(random(0,40));
- sleep(300,400);
- if (inventory.isItemSelected()) {
- status = "Using Bucket on the Waterpump";
- int countBuckets = inventory.getCount(bucketID);
- fail = 0;
- // if (tiles.doAction(waterPumpTile, "Use Bucket -> Waterpump")) {
- if (objects.getNearest(waterPumpID).doClick(true)) {
- mouse.moveRandomly(random(0,40));
- boolean isFilling = false;
- antiban();
- while (fail++ < 200 && countBuckets > 0) {
- sleep(100,200);
- antiban();
- status = "Filling Buckets. " + countBuckets + " left";
- countBuckets = inventory.getCount(bucketID);
- if (players.getMyPlayer().getAnimation() == 832) {
- isFilling = true;
- }
- if (fail > 8 && !isFilling) {
- break;
- }
- }
- sleep(300,500);
- }
- } else {
- return random(100,200);
- }
- }
- if (inventory.getCount(clayID) > 0 && inventory.getCount(wBucketID) > 0) {
- status = "Making soft clay";
- inventory.getItem(wBucketID).doClick(true);
- sleep(200, 400);
- inventory.getItem(clayID).doClick(true);
- fail = 0;
- while (fail++ < 200 && !interfaces.getComponent(905, 14).isValid()) {
- sleep(100, 300);
- antiban();
- }
- if (interfaces.getComponent(905, 14).isValid()) {
- interfaces.getComponent(905, 14).doClick();
- fail = 0;
- while (fail++ < 200 && inventory.getCount(clayID) != 0) {
- sleep(100,200);
- antiban();
- }
- if (totalCInBank == 0) {
- if (inventory.getCount(bucketID) > 0) {
- int countBuckets = inventory.getCount(bucketID);
- fail = 0;
- if (objects.getNearest(waterPumpID).doClick(true)) {
- mouse.moveRandomly(random(0,40));
- boolean isFilling = false;
- antiban();
- while (fail++ < 200 && countBuckets > 0) {
- sleep(100,200);
- antiban();
- status = "Filling Buckets. " + countBuckets + " left";
- countBuckets = inventory.getCount(bucketID);
- if (players.getMyPlayer().getAnimation() == 832) {
- isFilling = true;
- }
- if (fail > 8 && !isFilling) {
- break;
- }
- }
- sleep(300,500);
- }
- }
- log("Out of clay!!!");
- log("Walking to bank.");
- walking.walkTileMM(new RSTile(2946, 3369)); // walk to bank
- sleep(2500,4100);
- stopScript();
- }
- }
- }
- }
- if (interfaces.canContinue()) {
- sleep(400,600);
- interfaces.clickContinue();
- }
- antiban();
- return random(100,200);
- }
- /*___________________________________________________________________________*/
- public 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 t_days = t_hours / 24;
- final int seconds = (int) (t_seconds % 60);
- final int minutes = (int) (t_minutes % 60);
- final int hours = (int) (t_hours % 60);
- final int days = (int) (t_days % 24);
- return (nf.format(days) + ":" + nf.format(hours) + ":" + nf.format(minutes) + ":" + nf.format(seconds));
- }
- private class MousePathPoint extends Point { // credits to Enfilade
- private int toColor(double d) { // credits to Enfilade
- return Math.min(255, Math.max(0, (int) d));
- }
- 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 Color getColor() {
- return new Color(
- 122,
- 25,
- 17,
- toColor(256 * ((finishTime - System.currentTimeMillis()) / lastingTime)));
- }
- }
- /*___________________________________________________________________________*/
- public void messageReceived(MessageEvent me) {
- if (me.getID() == MessageEvent.MESSAGE_ACTION || me.getID() == MessageEvent.MESSAGE_SERVER) {
- serverMsg = me.getMessage().toLowerCase();
- if ( serverMsg.contains("workable") ){
- totalSCMade += 1;
- }
- }
- }
- public void mouseClicked(MouseEvent e) {
- }
- public void mousePressed(MouseEvent e) {
- }
- public void mouseReleased(MouseEvent e) {
- }
- public void mouseEntered(MouseEvent e) {
- }
- public void mouseExited(MouseEvent e) {
- }
- public void mouseDragged(MouseEvent e)
- {
- }
- public void mouseMoved(MouseEvent e)
- {
- p = e.getPoint();
- }
- /*___________________________________________________________________________*/
- public void onRepaint(Graphics g) {
- ((Graphics2D) g).setRenderingHints(rh);
- runTime = System.currentTimeMillis() - startTime;
- String infoStr;
- g.setColor(BLACK);
- g.drawRect(6, 269, 240, 68);
- g.setColor(TRANSPARRENT2);
- g.fillRect(8, 271, 237, 65);
- g.setColor(WHITE);
- g.setFont(textFontB);
- g.drawString(program, 11, 284);
- g.setFont(textFont);
- g.setColor(TXTBLUE);
- g.drawString("Run Time: " + formatTime(runTime), 11, 296);
- g.drawString("Status: ", 11, 308);
- g.setColor(TXTCOLOR);
- g.drawString(status, 46, 308);
- g.setColor(TXTBLUE);
- g.drawString("Soft clay in Bank: " + scInBank + " Total made so far: " + totalSCMade, 11, 320);
- g.drawString("Clay left in Bank: " + totalCInBank, 11, 332);
- Point p = mouse.getLocation();
- g.setColor(myColor);
- g.fillRect(p.x - 5, p.y, 12, 2);
- g.fillRect(p.x, p.y - 5, 2, 12);
- while (!mousePath.isEmpty() && mousePath.peek().isUp())
- // credits to Enfilade
- mousePath.remove();
- Point clientCursor = mouse.getLocation();
- MousePathPoint mpp = new MousePathPoint(clientCursor.x,
- clientCursor.y, 3000);
- if (mousePath.isEmpty() || !mousePath.getLast().equals(mpp))
- mousePath.add(mpp);
- MousePathPoint lastPoint = null;
- for (MousePathPoint p1 : mousePath) {
- if (lastPoint != null) {
- g.setColor(p1.getColor());
- g.drawLine(p1.x, p1.y, lastPoint.x, lastPoint.y);
- }
- lastPoint = p1;
- }
- }
- }
- /*Algol 2011*/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement