Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import org.osbot.rs07.api.map.Area;
- import org.osbot.rs07.api.map.constants.Banks;
- import org.osbot.rs07.api.model.RS2Object;
- import org.osbot.rs07.api.ui.RS2Widget;
- import org.osbot.rs07.api.ui.Skill;
- import org.osbot.rs07.event.WebWalkEvent;
- import org.osbot.rs07.script.Script;
- import org.osbot.rs07.script.ScriptManifest;
- import org.osbot.rs07.utility.ConditionalSleep;
- import java.awt.*;
- import java.awt.event.KeyEvent;
- import java.util.concurrent.TimeUnit;
- @ScriptManifest(name = "Jueixs baked potatos", author = "Jueix", version = 1.0, info = "Makes baked potatos", logo = "")
- public class main extends Script {
- public String ScriptType;
- //Variables
- private int Stage = 1;
- private int randomclicks = 0;
- private String ScriptStatus = "None";
- //Dialog GUI
- private Potatogui gui;
- private boolean ScriptStarted;
- //GUI
- public long timeBegan;
- private long timeRan;
- private int beginningXP;
- private int currentXp;
- private int xpGained;
- //Areas Butter Creator
- Area YanileChurn = new Area(2570, 3101, 2572, 3097);
- //Areas Potato cooker
- Area CookPlace = new Area(2816, 3443, 2818, 3439);
- public void onStart() {
- ScriptStatus = "Starting script.";
- beginningXP = skills.getExperience(Skill.COOKING);
- gui = new Potatogui(this);
- gui.setVisible(true);
- }
- public int onLoop() throws InterruptedException {
- if(ScriptStarted) {
- if(ScriptType == "Butter creator") {
- log("Butter Creating: Current state: " + Stage);
- switch (Stage) {
- case 1: {
- if (inventory.contains("Pat of butter")) {
- ScriptStatus = "Banking butter.";
- Stage = 3;
- break;
- }
- else if(YanileChurn.contains(myPlayer())) {
- Stage = 2;
- break;
- }
- else if (!Banks.YANILLE.contains(myPlayer())) {
- log("you are not currently in yanille bank");
- stop();
- }
- else if (!getBank().isOpen()) {
- if (inventory.contains("Bucket of milk")) {
- log("You already have the ingredients in inventory");
- ScriptStatus = "Heading to churn.";
- bank.close();
- Stage = 2;
- break;
- }
- getBank().open();
- ScriptStatus = "Opening bank.";
- new ConditionalSleep(2500, 3000) {
- @Override
- public boolean condition() {
- return getBank().isOpen();
- }
- }.sleep();
- } else {
- if (!bank.contains("Bucket of milk")) {
- log("you don't have any buckets of milk in the bank");
- stop();
- }
- sleep(random(200, 1300));
- bank.withdraw("Bucket of milk", 28);
- sleep(random(250, 500));
- bank.close();
- ScriptStatus = "Heading to churn.";
- Stage = 2;
- break;
- }
- }
- case 2: {
- if(!YanileChurn.contains(myPlayer())) {
- log("We are now starting our journey to the churn");
- getWalking().webWalk(YanileChurn);
- }
- else if(inventory.contains("Pat of butter") && myPlayer().isAnimating()) {
- ScriptStatus = "Interacting with churn.";
- }
- else if(YanileChurn.contains(myPlayer()) && !myPlayer().isAnimating()) {
- if(inventory.contains("Bucket of milk") && !myPlayer().isAnimating()) {
- log("We are attempting to interact with the churn");
- ScriptStatus = "Interacting with churn.";
- sleep(random(100, 500));
- RS2Object Churn = objects.closest("Dairy churn");
- Churn.interact("Churn");
- sleep(random(500, 3500));
- getKeyboard().typeKey((char) 50);
- sleep(random(100, 500));
- ScriptStatus = "Should be making butter.";
- new ConditionalSleep(151000, 151000) {
- @Override
- public boolean condition() {
- return !myPlayer().isAnimating() | !inventory.contains("Bucket of milk");
- }
- }.sleep();
- }
- else if(!inventory.contains("Bucket of milk")) {
- ScriptStatus = "Heading to bank.";
- getWalking().webWalk(Banks.YANILLE);
- Stage = 3;
- sleep(random(100, 500));
- break;
- }
- }
- }
- case 3: {
- if (!getBank().isOpen()) {
- if (inventory.contains("Bucket of milk")) {
- log("You already have the ingredients in inventory");
- ScriptStatus = "Heading to churn.";
- bank.close();
- Stage = 2;
- break;
- }
- else {
- getBank().open();
- ScriptStatus = "Opening bank.";
- new ConditionalSleep(2500, 3000) {
- @Override
- public boolean condition() {
- return getBank().isOpen();
- }
- }.sleep();
- }
- } else {
- if (inventory.contains("Pat of butter")) {
- bank.depositAll();
- ScriptStatus = "Withdrawing buckets of milk.";
- sleep(random(100, 750));
- Stage = 1;
- }
- }
- }
- }
- }
- if(ScriptType == "Baked potato") {
- log("Cooking potato's: Current state: " + Stage);
- switch (Stage) {
- case 1 : {
- if (inventory.contains("Baked potato")) {
- ScriptStatus = "Banking baked potato's.";
- Stage = 3;
- break;
- }
- else if(YanileChurn.contains(myPlayer())) {
- Stage = 2;
- break;
- }
- else if (!Banks.CATHERBY.contains(myPlayer())) {
- log("you are not currently in catherby bank");
- stop();
- }
- else if (!getBank().isOpen()) {
- if (inventory.contains("Potato")) {
- log("You already have the ingredients in inventory");
- ScriptStatus = "Closing bank, starting potatos.";
- bank.close();
- Stage = 2;
- break;
- }
- getBank().open();
- ScriptStatus = "Opening bank.";
- new ConditionalSleep(2500, 3000) {
- @Override
- public boolean condition() {
- return getBank().isOpen();
- }
- }.sleep();
- } else {
- if (!bank.contains("Potato")) {
- log("You don't have any Potato's in the bank.");
- stop();
- }
- ScriptStatus = "Withdrawing potato's.";
- sleep(random(200, 1300));
- bank.withdraw("Potato", 28);
- sleep(random(250, 850));
- bank.close();
- ScriptStatus = "Heading to range.";
- Stage = 2;
- break;
- }
- }
- case 2: {
- if(!CookPlace.contains(myPlayer())) {
- log("We are now starting our journey to the range");
- getWalking().webWalk(CookPlace);
- }
- else if(CookPlace.contains(myPlayer()) && !myPlayer().isAnimating()) {
- log("We are attempting to interact with the churn");
- ScriptStatus = "Interacting with range.";
- sleep(random(100, 500));
- RS2Object Range = objects.closest("Range");
- Range.interact("Cook");
- sleep(random(500, 3500));
- getKeyboard().typeKey((char) 32);
- sleep(random(500, 1500));
- ScriptStatus = "Should be making baked potato's.";
- new ConditionalSleep(18000, 22000) {
- @Override
- public boolean condition() {
- return !myPlayer().isAnimating() | !inventory.contains("Potato");
- }
- }.sleep();
- }
- else if(!inventory.contains("Potato")) {
- ScriptStatus = "Heading to bank.";
- getWalking().webWalk(Banks.CATHERBY);
- Stage = 3;
- sleep(random(100, 500));
- break;
- }
- }
- case 3: {
- if (!getBank().isOpen()) {
- if (inventory.contains("Potato")) {
- log("You already have the ingredients in inventory");
- ScriptStatus = "Heading to range.";
- bank.close();
- Stage = 2;
- break;
- }
- else {
- getBank().open();
- ScriptStatus = "Opening bank.";
- new ConditionalSleep(2500, 3000) {
- @Override
- public boolean condition() {
- return getBank().isOpen();
- }
- }.sleep();
- }
- } else {
- if (inventory.contains("Baked potato")) {
- bank.depositAll();
- ScriptStatus = "Withdrawing Potato's.";
- sleep(random(100, 750));
- Stage = 1;
- }
- }
- }
- }
- }
- if(ScriptType == "Potato with butter") {
- log("Potato with butter: Current state: " + Stage);
- switch (Stage) {
- case 1: {
- log("attempting to bank");
- if (!getBank().isOpen()) {
- if (inventory.contains("Baked potato") && inventory.contains("Pat of butter")) {
- log("You already have the ingredients in inventory");
- ScriptStatus = "Closing bank, starting potatos.";
- bank.close();
- Stage = 2;
- break;
- }
- getBank().open();
- ScriptStatus = "Opening bank.";
- new ConditionalSleep(2500, 3000) {
- @Override
- public boolean condition() {
- return getBank().isOpen();
- }
- }.sleep();
- } else {
- if (!bank.contains("Baked potato") | !bank.contains("Pat of butter")) {
- log("You don't have a baked potato or pat of butter in teh bank");
- stop();
- }
- randomclicks = random(1, 5);
- log("Random clicks = " + randomclicks);
- if (randomclicks < 3) {
- ScriptStatus = "Withdrawing baked potato and butter.";
- sleep(random(200, 1250));
- bank.withdraw("Baked potato", 14);
- sleep(random(200, 1300));
- bank.withdraw("Pat of butter", 14);
- sleep(random(250, 500));
- bank.close();
- log("Bank Closed");
- Stage = 2;
- sleep(random(100, 1000));
- } else if (randomclicks >= 3) {
- ScriptStatus = "Withdrawing butter and potato.";
- sleep(random(200, 1250));
- bank.withdraw("Pat of butter", 14);
- sleep(random(200, 1300));
- bank.withdraw("Baked potato", 14);
- sleep(random(200,600));
- bank.close();
- log("Bank Closed");
- Stage = 2;
- sleep(random(100, 1000));
- }
- }
- break;
- }
- case 2: {
- log("Attempting to make the items");
- if (inventory.contains("Baked potato") && inventory.contains("Pat of butter")) {
- randomclicks = random(1, 5);
- log("Random clicks = " + randomclicks);
- if (randomclicks < 3) {
- ScriptStatus = "Using butter on potato.";
- log("uses butter before the baked.");
- getInventory().interact("Use", "Pat of butter");
- sleep(random(100, 1500));
- getInventory().interact("Use", "Baked Potato");
- sleep(random(100, 1200));
- log("Dialog after it's shown");
- sleep(random(100, 1700));
- getKeyboard().typeKey((char) 32);
- log("Dialog after space");
- sleep(random(18500, 20000));
- Stage = 3;
- } else if (randomclicks >= 3) {
- ScriptStatus = "Using potato on butter.";
- log("Uses baked before the butter.");
- getInventory().interact("Use", "Baked Potato");
- sleep(random(100, 1000));
- getInventory().interact("Use", "Pat of butter");
- sleep(random(100, 2000));
- log("Dialog after it's shown");
- sleep(random(500, 1500));
- getKeyboard().typeKey((char) 32);
- log("Dialog after space");
- sleep(random(18500, 20000));
- Stage = 3;
- }
- }
- break;
- }
- case 3: {
- log("Banking the items");
- ScriptStatus = "Banking items.";
- if (!getBank().isOpen()) {
- getBank().open();
- new ConditionalSleep(2500, 3000) {
- @Override
- public boolean condition() {
- return getBank().isOpen();
- }
- }.sleep();
- } else if (getBank().isOpen()) {
- bank.depositAll();
- sleep(random(500, 1200));
- Stage = 1;
- }
- break;
- }
- case 4: {
- break;
- }
- }
- }
- }
- return 100; //The amount of time in milliseconds before the loop starts over
- }
- public void onPaint(Graphics2D g) {
- if(ScriptStarted) {
- timeRan = System.currentTimeMillis() - this.timeBegan;
- currentXp = skills.getExperience(Skill.COOKING);
- xpGained = currentXp - beginningXP;
- g.setColor(Color.WHITE);
- g.drawString("Time ran: " + ft(timeRan), 14, 286);
- g.drawString("Status: " + ScriptStatus, 14, 306);
- g.drawString("Experience: " + xpGained, 14, 326);
- }
- }
- private String ft(long duration)
- {
- String res = "";
- long days = TimeUnit.MILLISECONDS.toDays(duration);
- long hours = TimeUnit.MILLISECONDS.toHours(duration)
- - TimeUnit.DAYS.toHours(TimeUnit.MILLISECONDS.toDays(duration));
- long minutes = TimeUnit.MILLISECONDS.toMinutes(duration)
- - TimeUnit.HOURS.toMinutes(TimeUnit.MILLISECONDS
- .toHours(duration));
- long seconds = TimeUnit.MILLISECONDS.toSeconds(duration)
- - TimeUnit.MINUTES.toSeconds(TimeUnit.MILLISECONDS
- .toMinutes(duration));
- if (days == 0) {
- res = (hours + ":" + minutes + ":" + seconds);
- } else {
- res = (days + ":" + hours + ":" + minutes + ":" + seconds);
- }
- return res;
- }
- public void onExit() {
- stop();
- //Code here will execute after the script ends
- }
- public void setScriptStarted(boolean ScriptStarted) {
- this.ScriptStarted = ScriptStarted;
- }
- }
Add Comment
Please, Sign In to add comment