Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.awt.BasicStroke;
- import java.awt.Color;
- import java.awt.Font;
- import java.awt.Graphics;
- import java.awt.Graphics2D;
- import java.awt.Point;
- import java.text.NumberFormat;
- import org.rsbot.event.events.MessageEvent;
- import org.rsbot.event.listeners.MessageListener;
- import org.rsbot.event.listeners.PaintListener;
- import org.rsbot.script.Script;
- import org.rsbot.script.ScriptManifest;
- import org.rsbot.script.wrappers.RSArea;
- import org.rsbot.script.wrappers.RSItem;
- import org.rsbot.script.wrappers.RSObject;
- import org.rsbot.script.wrappers.RSTile;
- import org.rsbot.script.wrappers.RSTilePath;
- @ScriptManifest(authors = "Robert G", keywords = "Moneymaking", name = "PastryDoughPro", description = "Make's Pastry dough.", version = 1.3)
- /**
- * PastryDoughPro by Robert G
- * v1.1
- * Now fills buckets from fountain in edgeville
- * v1.3
- * Made banking better.
- * Made script run smoother.
- * Added dough's per hour to paint.
- * I can't fix the profit per hour as it fetche's data from
- * the rs ge and for some reason it come's back wrong.
- *
- */
- public class PastryDoughPro extends Script implements PaintListener, MessageListener {
- private int[] theseID = { 1925, 1929 };
- private int bucketID = 1925;
- private int bwaterID = 1929;
- private int pflourID = 1933;
- private int pdoughID = 1953;
- public int bboothID = 11758;
- private int[] doughkit = { 1929, 1933 };
- private int pastry = 0;
- private int pastrydoughPrice;
- public int bucketofwaterPrice;
- private int potofflourPrice;
- private static int profit;
- private static int profitPerHour;
- private static int doughsPerHour;
- boolean makingDough = false;
- boolean fillingBuckets = false;
- private static NumberFormat numberFormatProfit = NumberFormat.getInstance();
- String addZero = "", addZero2 = "";
- public long startTime = System.currentTimeMillis(); // timer
- long runTime, seconds, minutes = 0, hours = 0;
- long runTime2, seconds2, minutes2 = 0, hours2 = 0;
- public static class constants {
- public static final int bucket = 1925;
- public static final int well = 26945;
- }
- // Areas---------------------------------------------------
- RSArea well_area = new RSArea(new RSTile(3083, 3499),
- new RSTile(3086, 3502));
- RSArea bank_area = new RSArea(new RSTile(3090, 3487),
- new RSTile(3099, 3500));
- // Paths---------------------------------------------------
- RSTile[] tilesTobank = { new RSTile(3089, 3501), new RSTile(3093, 3497), new RSTile(3097, 3496) };
- RSTilePath pathTobank;
- RSTile[] tilesTowell = { new RSTile(3089, 3502), new RSTile(3085, 3501) };
- RSTilePath pathTowell;
- public boolean onStart() {
- mouse.setSpeed(random(5, 6));
- startTime = System.currentTimeMillis();
- numberFormatProfit.setParseIntegerOnly(false);
- pastrydoughPrice = grandExchange.lookup(pdoughID).getGuidePrice();
- bucketofwaterPrice = grandExchange.lookup(bwaterID).getGuidePrice();
- potofflourPrice = grandExchange.lookup(pflourID).getGuidePrice();
- pathTobank = walking.newTilePath(tilesTobank);
- pathTowell = walking.newTilePath(tilesTowell);
- log("Welcome to PastryDoughPro!");
- return true;
- }
- private boolean atBank() {
- if (bank_area.contains(getMyPlayer().getLocation())) {
- return true;
- }
- return false;
- }
- private boolean flourCheck() {
- if (inventory.getCount(pflourID) == 0) {
- makingDough = false;
- return true;
- }
- return false;
- }
- private boolean atWell() {
- if (well_area.contains(getMyPlayer().getLocation())) {
- return true;
- }
- return false;
- }
- private void walk2bank() {
- pathTobank.traverse();
- }
- private void walk2well() {
- pathTowell.traverse();
- }
- @Override
- public void onFinish() {
- env.saveScreenshot(true);
- log("Thanks for PastryDoughPro");
- }
- private void fillBuckets() {
- RSItem bucket = inventory.getItem(bucketID);
- if (!inventory.isItemSelected()) {
- bucket.doClick(true);
- sleep(random(800, 1000));
- }
- if (inventory.isItemSelected()) {
- RSObject well = objects.getNearest(constants.well);
- well.doAction("use");
- sleep(random(800, 1000));
- fillingBuckets = true;
- }
- }
- private void makePastry() {
- RSItem flour = inventory.getItem(pflourID);
- RSItem bucket = inventory.getItem(bwaterID);
- if (!inventory.isItemSelected()) {
- flour.doClick(true);
- sleep(random(600, 800));
- }
- bucket.doClick(true);
- if (interfaces.getComponent(905, 15).isValid()){
- interfaces.getComponent(905, 15).doClick();
- sleep(random(800, 1000));
- makingDough = true;
- }
- }
- private void bank() {
- if (!bank.open()) {
- bank.open();
- sleep(1000, 1200);
- }
- if (bank.open()) {
- bank.depositAllExcept(theseID);
- sleep(1000, 1200);
- if (bank.getCount(pflourID) == 0 && inventory.getCount(pflourID) == 8) {
- log.severe("Ran out of flour!");
- stopScript(true);
- log("You made " + pastry + " in " + runTime);
- log("making a total profit of " + profit + ".");
- }
- if (!inventory.contains(pflourID)) {
- bank.withdraw(pflourID, 9);
- sleep(600, 1200);
- }
- if (inventory.contains(pflourID)) {
- bank.close();
- }
- }
- }
- private void setRun() {
- if (!walking.isRunEnabled() && walking.getEnergy() > 50) {
- walking.setRun(true);
- return;
- }
- }
- public void antibanB() {
- int b = random(0, 10);
- switch (b) {
- case 1:
- if (random(0, 10) == 5) {
- log("[Antiban] move mouse");
- mouse.moveSlightly();
- sleep(200, 600);
- mouse.moveRandomly(150, 350);
- }
- break;
- case 2:
- if (random(0, 13) == 2) {
- log("[Antiban] Turn screen");
- camera.setAngle(random(30, 70));
- sleep(400, 1200);
- }
- break;
- case 3:
- if (random(0, 24) == 6) {
- log("[Antiban] mouse off screen");
- mouse.moveOffScreen();
- sleep(random(1200, 2000));
- }
- break;
- case 5:
- if (random(0, 30) == 4) {
- log("[antiban] Setting camera pitch.");
- camera.setPitch(random(10, 99));
- sleep(random(4500, 5400));
- }
- break;
- default:
- break;
- }
- }
- @Override
- public int loop() {
- antibanB();
- setRun();
- flourCheck();
- if (interfaces.getComponent(905, 15).isValid()){
- interfaces.getComponent(905, 15).doClick();
- sleep(random(800, 1000));
- makingDough = true;
- }
- if (fillingBuckets) {
- antibanB();
- }
- if (makingDough) {
- antibanB();
- }
- if (inventory.getCount(bucketID) == 0) {
- fillingBuckets = false;
- }
- if (atBank() && !inventory.contains(pflourID)) {
- bank();
- return random(800, 1000);
- }
- if (atBank() && !makingDough && inventory.containsAll(doughkit)) {
- makePastry();
- return random(1000, 1200);
- }
- if (inventory.contains(pflourID) && !atWell()) {
- if (inventory.getCount(bucketID) == 9)
- walk2well();
- return random(1200, 1400);
- }
- if (atWell() && !makingDough && inventory.getCount(bucketID) == 9) {
- fillBuckets();
- return random(1000, 1200);
- }
- if (atWell() && !fillingBuckets && !makingDough && inventory.containsAll(doughkit)) {
- makePastry();
- return random(1000, 1200);
- }
- if (atWell() && !makingDough && inventory.getCount(bucketID) == 9) {
- fillBuckets();
- return random(1000, 1200);
- }
- if (!atBank() && !inventory.contains(pflourID)) {
- if (inventory.getCount(bwaterID) == 9) {
- walk2bank();
- }
- return random(1000, 1200);
- }
- return 0;
- }
- public void messageReceived(MessageEvent e) {
- String x = e.getMessage().toLowerCase();
- if (x.contains("mix the water and flour"))
- pastry++;
- }
- //START: Code generated using Enfilade's Easel
- private final Color color1 = new Color(51, 0, 51);
- private final Color color2 = new Color(255, 255, 255, 60);
- private final Color color3 = new Color(0, 0, 0);
- private final Color color4 = new Color(51, 0, 51, 222);
- private final BasicStroke stroke1 = new BasicStroke(1);
- private final Font font1 = new Font("Xirod", 1, 30);
- private final Font font2 = new Font("Georgia", 1, 12);
- public void onRepaint(Graphics g1) {
- Graphics2D g = (Graphics2D)g1;
- g.setFont(font1);
- g.setColor(color1);
- g.drawString("PastryDoughPro", 10, 32);
- g.setColor(color2);
- g.fillRect(371, 40, 143, 73);
- g.setColor(color3);
- g.setStroke(stroke1);
- g.drawRect(371, 40, 143, 73);
- g.setFont(font2);
- g.setColor(color4);
- g.drawString("Runtime: " + hours2 + ":" + addZero + minutes2
- + ":" + addZero2 + seconds2, 377, 55);
- g.drawString("Dough's: " + pastry, 377, 67);
- g.drawString("Dough's/h: " + numberFormatProfit.format(doughsPerHour), 377, 79);
- g.drawString("Profit: " + (numberFormatProfit.format(profit)), 377, 91);
- g.drawString("Profit hr: " + numberFormatProfit.format(profitPerHour), 377, 103);
- runTime2 = System.currentTimeMillis() - startTime;
- seconds2 = runTime2 / 1000; // seconds
- if (seconds2 >= 60) { // minutes
- minutes2 = seconds2 / 60;
- seconds2 -= (minutes2 * 60);
- }
- if (minutes2 >= 60) { // hours
- hours2 = minutes2 / 60;
- minutes2 -= (hours2 * 60);
- }
- // adds zero before seconds
- if (seconds2 >= 10) {
- addZero2 = "";
- } else if (seconds2 < 10) {
- addZero2 = "0";
- }
- doughsPerHour = (int) ((pastry) * 3600000.0 / runTime);
- profitPerHour = (int) ((profit) * 3600000.0 / runTime);
- profit = (int) (pastrydoughPrice * pastry) - potofflourPrice;
- runTime = System.currentTimeMillis() - startTime;
- Point m = mouse.getLocation();
- g.setColor(Color.black);
- g.drawRoundRect(m.x - 6, m.y, 15, 3, 5, 5);
- g.drawRoundRect(m.x, m.y - 6, 3, 15, 5, 5);
- g.setColor(color2);
- g.fillRoundRect(m.x - 6, m.y, 15, 3, 5, 5);
- g.fillRoundRect(m.x, m.y - 6, 3, 15, 5, 5);
- }
- //END: Code generated using Enfilade's Easel
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement