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 org.rsbot.event.events.ServerMessageEvent;
- import org.rsbot.event.listeners.PaintListener;
- import org.rsbot.event.listeners.ServerMessageListener;
- import org.rsbot.script.Script;
- import org.rsbot.script.ScriptManifest;
- import org.rsbot.script.util.Timer;
- import org.rsbot.script.wrappers.RSObject;
- @ScriptManifest(authors = {"Rapid"}, name = "AutoTunaPotatoer")
- public class AutoTunaPotatoer extends Script implements PaintListener, ServerMessageListener{
- private enum State{
- SLEEP, BANK, HANDLEINTERFACE, MAKE_BUTTER_POTATO, MAKE_SWEETCORN_BOWL, MAKE_TUNASWEETCORN_BOWL, MAKE_TUNA_POTATO
- }
- private int[] BankBoothID = { 11758, 11402, 34752, 35647, 2213, 25808, 2213, 26972, 27663, 4483, 14367, 19230, 29085, 12759, 6084, 24914 };
- private int PotatoID = 6701;
- private int PotatoButterID = 6703;
- private int ButterID = 6697;
- private int BowlID = 1923;
- private int TunaID = 361;
- private int SweetcornID = 5988;
- private int SweetcornBowlID = 7088;
- private int TunaSweetCornID = 7068;
- private int TunaPotatoID = 7060;
- private int KnifeID = 946;
- private int PotatoButterMade;
- private int BowlSweetcornMade;
- private int BowlTunaSweetcornMade;
- private int TunaPotatoMade;
- private int ButterPrice;
- private int PotatoPrice;
- private int SweetcornPrice;
- private int SweetcornBowlPrice;
- private int TunaPrice;
- private int TunaSweetcornPrice;
- private int PotatoButterPrice;
- private int TunaPotatoPrice;
- private long StartTime;
- private boolean MakeButter = true;
- private boolean MakeSweetcorn;
- private boolean MakeTunaSweetcorn;
- private boolean MakeTunaPotato;
- private String LastMessage;
- private int InterfaceID = 905;
- private int CompID = 14;
- private int timeout;
- public boolean onStart(){
- StartTime = System.currentTimeMillis();
- return true;
- }
- @Override
- public int loop() {
- if (!game.isLoggedIn()){
- return random(800, 1250);
- }else{
- switch(getState()){
- case BANK:
- if (bank.isOpen()){
- handleBank();
- }else{
- openBank();
- }
- break;
- case HANDLEINTERFACE:
- handleInterface();
- break;
- case SLEEP:
- return random(850, 1250);
- }
- }
- return random(850, 1250);
- }
- private void handleInterface(){
- if (interfaces.get(916).isValid()){
- if (interfaces.get(InterfaceID).getComponent(CompID).doAction("Make All")){
- sleep(random(14000, 16000));
- }
- }else{
- if (MakeButter == true){
- if (inventory.isItemSelected()){
- inventory.getItem(PotatoID).doClick(true);
- }else{
- inventory.getItem(ButterID).doClick(true);
- }
- }else if (MakeSweetcorn == true){
- if (inventory.isItemSelected()){
- inventory.getItem(SweetcornID).doClick(true);
- }else{
- inventory.getItem(BowlID).doClick(true);
- }
- }else if (MakeTunaSweetcorn == true){
- if (inventory.isItemSelected()){
- inventory.getItem(TunaID).doClick(true);
- }else{
- inventory.getItem(SweetcornBowlID).doAction("Use");
- }
- }else if (MakeTunaPotato == true){
- if (inventory.isItemSelected()){
- inventory.getItem(PotatoButterID).doAction("Use");
- }else{
- inventory.getItem(TunaSweetCornID).doAction("Use");
- }
- }
- }
- }
- private void openBank(){
- RSObject Bank = objects.getNearest(BankBoothID);
- if (Bank != null){
- Bank.doAction("Use-quickly");
- }else{
- return;
- }
- }
- private void handleBank(){
- sleep(random(1000, 1500));
- if (bank.getCount(PotatoID) > 13 && bank.getCount(ButterID) > 13){
- bank.depositAllExcept(KnifeID);
- sleep(random(1000, 1500));
- if (bank.withdraw(PotatoID, 13)){
- sleep(random(850, 1250));
- if (bank.withdraw(ButterID, 13)){
- sleep(random(850, 1250));
- bank.close();
- }else{
- bank.withdraw(ButterID, 13);
- sleep(random(850, 1250));
- bank.close();
- }
- }
- MakeButter = true;
- }else if (bank.getCount(SweetcornID) > 13 && bank.getCount(BowlID) > 13){
- bank.depositAllExcept(KnifeID);
- sleep(random(1000, 1500));
- if (bank.withdraw(SweetcornID, 13)){
- sleep(random(850, 1250));
- if (bank.withdraw(BowlID, 13)){
- sleep(random(850, 1250));
- bank.close();
- }else{
- bank.withdraw(BowlID, 13);
- sleep(random(850, 1250));
- bank.close();
- }
- }
- MakeButter = false;
- MakeSweetcorn = true;
- }else if (bank.getCount(SweetcornBowlID) > 13 && bank.getCount(TunaID) > 13){
- bank.depositAllExcept(KnifeID);
- if (!inventory.contains(SweetcornBowlID)){
- if(bank.withdraw(SweetcornBowlID, 13)){
- if (bank.withdraw(TunaID, 13)){
- bank.close();
- }
- }
- }else{
- if (bank.withdraw(TunaID, 13)){
- bank.close();
- }
- }
- MakeButter = false;
- MakeSweetcorn = false;
- MakeTunaSweetcorn = true;
- }else if (bank.getCount(PotatoButterID) > 13 && bank.getCount(TunaSweetCornID) > 13){
- bank.depositAllExcept(KnifeID);
- if (!inventory.contains(TunaSweetCornID)){
- if (bank.withdraw(TunaSweetCornID, 13)){
- if (bank.withdraw(PotatoButterID, 13)){
- bank.close();
- }
- }
- }else{
- if (bank.withdraw(PotatoButterID, 13)){
- bank.close();
- }
- }
- MakeButter = false;
- MakeSweetcorn = false;
- MakeTunaSweetcorn = false;
- MakeTunaPotato = true;
- }else{
- stopScript();
- }
- }
- private State getState(){
- if (MakeButter == true){
- if (inventory.getCount(PotatoButterID) == 13){
- return State.BANK;
- }else{
- int Potato[] = {ButterID, PotatoID};
- if (inventory.containsAll(Potato)){
- return State.HANDLEINTERFACE;
- }else{
- return State.BANK;
- }
- }
- }else if (MakeSweetcorn == true){
- if (inventory.getCount(SweetcornBowlID) == 13){
- return State.BANK;
- }else{
- int Sweetcorn[] = {BowlID, SweetcornID};
- if (inventory.containsAll(Sweetcorn)){
- return State.HANDLEINTERFACE;
- }else{
- return State.BANK;
- }
- }
- }else if (MakeTunaSweetcorn == true){
- if (inventory.getCount(TunaSweetCornID) == 13){
- return State.BANK;
- }else{
- int TunaSweetcorn[] = {TunaID, SweetcornBowlID};
- if (inventory.containsAll(TunaSweetcorn)){
- return State.HANDLEINTERFACE;
- }else{
- return State.BANK;
- }
- }
- }else if (MakeTunaPotato == true){
- if (inventory.getCount(TunaPotatoID) == 13){
- return State.BANK;
- }else{
- int TunaPotato[] = {TunaSweetCornID, PotatoButterID};
- if (inventory.containsAll(TunaPotato)){
- return State.HANDLEINTERFACE;
- }else{
- return State.BANK;
- }
- }
- }else{
- return State.SLEEP;
- }
- }
- @Override
- public void onRepaint(Graphics g1) {
- final Color color1 = new Color(0, 51, 255, 125);
- final Color color2 = new Color(0, 0, 0);
- final BasicStroke stroke1 = new BasicStroke(1);
- final Font font1 = new Font("Arial", 1, 16);
- final Font font2 = new Font("Arial", 1, 12);
- Timer FormatTimer = new Timer(0);
- Graphics2D g = (Graphics2D)g1;
- g.setColor(color1);
- g.fillRoundRect(19, 355, 463, 94, 16, 16);
- g.setColor(color2);
- g.setStroke(stroke1);
- g.drawRoundRect(19, 355, 463, 94, 16, 16);
- g.setFont(font1);
- g.drawString("AutoTunaPotato", 30, 376);
- g.setFont(font2);
- g.drawString("Potato's buttered: " + PotatoButterMade, 50, 400);
- g.drawString("Sweetcorn bowl's made: " + BowlSweetcornMade, 50, 425);
- g.drawString("Tuna and sweetcorn made: " + BowlTunaSweetcornMade, 250, 400);
- g.drawString("Tuna potato's made: " + TunaPotatoMade, 250, 425);
- g.drawString("Run-time: " + FormatTimer.format(System.currentTimeMillis() - StartTime), 250, 375);
- }
- @Override
- public void serverMessageRecieved(ServerMessageEvent e) {
- LastMessage = e.getMessage().toLowerCase();
- if (LastMessage.contains("butter to the potato")){
- PotatoButterMade++;
- }
- if (LastMessage.contains("sweetcorn into the bowl")){
- BowlSweetcornMade++;
- }
- if (LastMessage.contains("mix ingredients")){
- BowlTunaSweetcornMade++;
- }
- if (LastMessage.contains("add the topping")){
- TunaPotatoMade++;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement