Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package scripts;
- import java.awt.*;
- import java.util.*;
- import org.tribot.api.*;
- import org.tribot.api.input.*;
- import org.tribot.api2007.*;
- import org.tribot.api2007.Objects;
- import org.tribot.api2007.types.*;
- import org.tribot.script.interfaces.*;
- import org.tribot.script.*;
- @ScriptManifest(authors = { "Deluxes" }, category = "Runecrafting", name = "DeluxesAIRMaster", description = "Takes essence from slaves and crafts into air runs. Start inside air altar.")
- public class DeluxeAIRMaster extends Script implements Painting
- {
- RSObject altar;
- public String[] slaveNames = new String[] { };
- String state = "";
- @Override
- public void onPaint(Graphics g)
- {
- Graphics2D g1 = (Graphics2D)g;
- g1.drawString("STATE: " + state, 236, 225);
- }
- @Override
- public void run()
- {
- while (true)
- loop();
- }
- void loop()
- {
- if (Login.getLoginState().equals(Login.STATE.INGAME))
- {
- int timeout = 0;
- if (altar == null)
- {
- RSObject[] objs = Objects.findNearest(10, "Altar");
- if (objs.length > 0)
- {
- altar = objs[0];
- }
- else
- General.println("No altar found?");
- }
- if (Player.getRSPlayer().isInCombat())
- {
- RSObject[] portal = Objects.findNearest(25, "Portal");
- if (portal.length > 0)
- {
- portal[0].click("Leave", "Exit", "Use", "Enter");
- do
- {
- General.sleep(100);
- if (!Player.isMoving())
- timeout++;
- } while (timeout < 25 && DeluxesAIRSlave.inAltar());
- timeout = 0;
- }
- }
- if (Inventory.isFull() && altar != null)
- {
- state = "Crafting runes";
- altar.click("Craft-rune");
- while (Inventory.isFull() && timeout < 25)
- {
- General.sleep(100);
- timeout++;
- }
- }
- else
- {
- state = "Waiting for slaves";
- RSPlayer[] players = Players.getAll();
- boolean found = false;
- for (RSPlayer player : players)
- {
- if (!found)
- {
- for (String slave : slaveNames)
- {
- if (slave.equals(player.getName()))
- {
- state = "Slave is here, trading";
- player.hover();
- Mouse.click(3);
- while (!ChooseOption.isOpen() && timeout < 10)
- {
- General.sleep(100);
- timeout++;
- }
- timeout = 0;
- String[] choice = ChooseOption.getOptions();
- if (choice.length > 0)
- {
- for (String trade : choice)
- {
- if (trade.contains("Trade") && trade.contains(slave))
- ChooseOption.select(trade);
- }
- while (ChooseOption.isOpen() && timeout < 10)
- {
- General.sleep(100);
- timeout++;
- }
- timeout = 0;
- while (Interfaces.get(335) == null && Interfaces.get(334) == null && timeout < 50)
- {
- General.sleep(100);
- timeout++;
- }
- timeout = 0;
- if (Interfaces.get(335) != null || Interfaces.get(334) != null)
- {
- state = "Waiting for items";
- while ((Interfaces.get(335) != null || Interfaces.get(334) != null))
- {
- state = "Accepting trades.";
- if(Interfaces.get(335) != null) {
- Interfaces.get(335).getChild(17).click("Accept");
- } else if(Interfaces.get(334) != null) {
- Interfaces.get(334).getChild(20).click("Accept");
- }
- General.sleep(1000);
- }
- }
- }
- }
- }
- }
- }
- General.sleep(500);
- }
- }
- }
- }
- //Start of Master Script
- package scripts;
- import java.awt.*;
- import java.util.*;
- import org.tribot.api.*;
- import org.tribot.api.input.*;
- import org.tribot.api2007.*;
- import org.tribot.api2007.Objects;
- import org.tribot.api2007.types.*;
- import org.tribot.script.interfaces.*;
- import org.tribot.script.*;
- @ScriptManifest(authors = { "Deluxes" }, category = "Runecrafting", name = "DeluxesAIRSlave", description = "Runs essence to its master in the air altar. Start with air tiara in falador bank to begin.")
- public class DeluxesAIRSlave extends Script implements Painting, MessageListening07
- {
- public static RSTile[] path = DeluxeUtil.CreatePath(new RSTile(3012, 3357), new RSTile(3007, 3354), new RSTile(3007, 3343), new RSTile(3007, 3332), new RSTile(3007, 3322), new RSTile(3000, 3314), new RSTile(2997, 3305), new RSTile(2992, 3298), new RSTile(2988, 3292));
- public static int ESS_TYPE = 7936; //7936, 1436
- public static boolean gotTrade = false;
- public static String masterName = "";
- public static boolean endScript = false;
- ArrayList<Node> nodes = new ArrayList<>();
- public static String state = "";
- public DeluxeSlaveGUI gui = new DeluxeSlaveGUI();
- @Override
- public void onPaint(Graphics g)
- {
- Graphics2D g1 = (Graphics2D)g;
- g1.drawString("STATE: " + state, 236, 225);
- }
- @Override
- public void run()
- {
- gui.setVisible(true);
- while (gui.isVisible())
- sleep(500);
- General.println(masterName);
- Collections.addAll(nodes, new DeluxesAIRSlaveBankNode(), new DeluxesAIRSlaveAltarNode());
- Walking.setControlClick(true);
- Walking.setWalkingTimeout(1000);
- Mouse.setSpeed(175);
- loop(40, 50);
- }
- public static boolean inAltar()
- {
- RSObject[] altar = Objects.findNearest(25, "Altar");
- return altar.length > 0;
- }
- public static boolean atEntrance()
- {
- return Player.getPosition().distanceTo(path[path.length - 1].getPosition()) < 5;
- }
- public static boolean inBank()
- {
- //General.println(Player.getPosition().distanceTo(path[0].getPosition()));
- return Player.getPosition().distanceTo(path[0].getPosition()) < 5;
- }
- void loop(int min, int max)
- {
- while (true)
- {
- for (final Node node : nodes)
- {
- if (endScript)
- return;
- if (node.validate())
- {
- node.execute();
- sleep(min, max);
- }
- }
- }
- }
- @Override
- public void clanMessageReceived(String arg0, String arg1) {
- // TODO Auto-generated method stub
- }
- @Override
- public void personalMessageReceived(String arg0, String arg1) {
- // TODO Auto-generated method stub
- }
- @Override
- public void playerMessageReceived(String arg0, String arg1) {
- // TODO Auto-generated method stub
- }
- @Override
- public void serverMessageReceived(String arg0) {
- // TODO Auto-generated method stub
- }
- @Override
- public void tradeRequestReceived(String arg0) {
- // TODO Auto-generated method stub
- if (arg0.equalsIgnoreCase(masterName))
- gotTrade = true;
- }
- class DeluxeSlaveGUI extends javax.swing.JFrame
- {
- private javax.swing.JButton jButton1;
- private javax.swing.JLabel jLabel1;
- public javax.swing.JTextField jTextField1;
- /**
- * Creates new form DeluxeSlaveGUI
- */
- public DeluxeSlaveGUI() {
- initComponents();
- }
- private void startButtonActionPerformed(java.awt.event.ActionEvent evt) {
- DeluxesAIRSlave.masterName = jTextField1.getText();
- super.dispose();
- }
- /**
- * This method is called from within the constructor to initialize the form.
- * WARNING: Do NOT modify this code. The content of this method is always
- * regenerated by the Form Editor.
- */
- @SuppressWarnings("unchecked")
- // <editor-fold defaultstate="collapsed" desc="Generated Code">
- private void initComponents() {
- jLabel1 = new javax.swing.JLabel();
- jTextField1 = new javax.swing.JTextField();
- jButton1 = new javax.swing.JButton();
- setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
- jLabel1.setText("Master Name:");
- jTextField1.setName("masterName"); // NOI18N
- jButton1.setLabel("Start");
- jButton1.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- startButtonActionPerformed(evt);
- }
- });
- javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
- getContentPane().setLayout(layout);
- layout.setHorizontalGroup(
- layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(layout.createSequentialGroup()
- .addGap(120, 120, 120)
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
- .addComponent(jButton1)
- .addGroup(layout.createSequentialGroup()
- .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 73, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
- .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, 143, javax.swing.GroupLayout.PREFERRED_SIZE)))
- .addContainerGap(120, Short.MAX_VALUE))
- );
- layout.setVerticalGroup(
- layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(layout.createSequentialGroup()
- .addGap(30, 30, 30)
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
- .addComponent(jLabel1)
- .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 7, Short.MAX_VALUE)
- .addComponent(jButton1))
- );
- pack();
- }
- }
- }
- class DeluxesAIRSlaveBankNode extends Node
- {
- @Override
- public void execute()
- {
- int timeout = 0;
- if (DeluxesAIRSlave.inAltar())
- {
- DeluxesAIRSlave.state = "Leaving altar.";
- RSObject[] portal = Objects.findNearest(25, "Portal");
- if (portal.length > 0)
- {
- portal[0].click("Leave", "Exit", "Use", "Enter");
- do
- {
- General.sleep(100);
- if (!Player.isMoving())
- timeout++;
- } while (timeout < 25 && DeluxesAIRSlave.inAltar());
- timeout = 0;
- }
- }
- if (!DeluxesAIRSlave.inAltar() && !DeluxesAIRSlave.inBank())
- {
- DeluxesAIRSlave.state = "Left altar, walking to bank.";
- boolean success = false;//DeluxeUtil.TraversePath(Walking.invertPath(DeluxesAIRSlave.path), 200);
- if (!success)
- {
- General.println("Walking path failed. Using webwalk");
- WebWalking.walkToBank();
- }
- }
- if (DeluxesAIRSlave.inBank())
- {
- DeluxesAIRSlave.state = "Inside Bank, opening booth.";
- DeluxesESS.state = "Opening Bank";
- Banking.openBankBooth();
- if (Banking.isPinScreenOpen())
- {
- Banking.inPin();
- }
- while (!Banking.isBankScreenOpen() && timeout < 10)
- {
- General.sleep(100);
- timeout++;
- }
- timeout = 0;
- DeluxesAIRSlave.state = "Withdrawing more ess.";
- Banking.withdraw(0, DeluxesAIRSlave.ESS_TYPE);
- while (!Inventory.isFull() && timeout < 7.5)
- {
- General.sleep(100);
- timeout++;
- }
- timeout = 0;
- }
- }
- @Override
- public boolean validate()
- {
- return (!Inventory.isFull());
- }
- }
- class DeluxesAIRSlaveAltarNode extends Node
- {
- @Override
- public void execute()
- {
- int timeout = 0;
- if (Inventory.isFull() && !DeluxesAIRSlave.inAltar())
- {
- DeluxesAIRSlave.state = "Inventory full, walking to altar.";
- boolean success = false;//DeluxeUtil.TraversePath(DeluxesAIRSlave.path, 200);
- General.println(success);
- if (!DeluxesAIRSlave.atEntrance())
- {
- if (!success)
- {
- WebWalking.walkTo(DeluxesAIRSlave.path[DeluxesAIRSlave.path.length - 1]);
- }
- }
- }
- if (DeluxesAIRSlave.atEntrance() && !Player.isMoving())
- {
- RSObject[] entrance = Objects.getAt(new RSTile(2984, 3291));
- if (entrance.length > 0)
- {
- RSItem[] tally = Inventory.find("Air talisman");
- if (!entrance[0].isOnScreen())
- {
- Camera.turnToTile(entrance[0].getPosition());
- General.sleep(1000);
- }
- if (tally.length > 0)
- {
- tally[0].click("Use");
- entrance[0].click();
- }
- else
- entrance[0].click("Enter");
- while (timeout < 20 && !DeluxesAIRSlave.inAltar())
- {
- General.sleep(100);
- if (!Player.isMoving())
- timeout++;
- }
- timeout = 0;
- }
- }
- if (DeluxesAIRSlave.inAltar())
- {
- if (Inventory.isFull())
- {
- DeluxesAIRSlave.state = "In altar, waiting for trade.";
- while (!DeluxesAIRSlave.gotTrade && timeout < 500)
- {
- General.sleep(100);
- timeout++;
- }
- if (timeout > 499)
- {
- DeluxesAIRSlave.endScript = true;
- return;
- }
- timeout = 0;
- General.sleep(1500);
- RSPlayer[] master = Players.find(DeluxesAIRSlave.masterName);
- if (master.length > 0)
- {
- master[0].hover();
- Mouse.click(3);
- while (!ChooseOption.isOpen() && timeout < 10)
- {
- General.sleep(100);
- timeout++;
- }
- timeout = 0;
- String[] choice = ChooseOption.getOptions();
- if (choice.length > 0)
- {
- while (Interfaces.get(335) == null && Interfaces.get(334) == null)
- {
- for (String trade : choice)
- {
- if (trade.contains("Trade") && trade.contains(DeluxesAIRSlave.masterName))
- ChooseOption.select(trade);
- }
- while (ChooseOption.isOpen() && timeout < 10)
- {
- General.sleep(100);
- timeout++;
- }
- timeout = 0;
- General.sleep(1000);
- }
- }
- DeluxesAIRSlave.gotTrade = false;
- if (Interfaces.get(335) != null || Interfaces.get(334) != null)
- {
- RSItem[] ess = Inventory.find(DeluxesAIRSlave.ESS_TYPE);
- if (ess.length > 0)
- {
- while (Inventory.getCount(DeluxesAIRSlave.ESS_TYPE) > 0 && timeout < 30)
- {
- ess[0].hover();
- Mouse.click(3);
- while (!ChooseOption.isOpen() && timeout < 10)
- {
- General.sleep(100);
- timeout++;
- }
- timeout = 0;
- String[] choices = ChooseOption.getOptions();
- if (choices.length > 0)
- {
- for (String trade : choices)
- {
- if (trade.contains("Offer-All"))
- ChooseOption.select(trade);
- }
- while (ChooseOption.isOpen() && timeout < 10)
- {
- General.sleep(100);
- timeout++;
- }
- timeout = 0;
- }
- General.sleep(2000);
- }
- if (Inventory.getCount(DeluxesAIRSlave.ESS_TYPE) == 0)
- {
- while ((Interfaces.get(335) != null || Interfaces.get(334) != null))
- {
- if(Interfaces.get(335) != null) {
- Interfaces.get(335).getChild(17).click("Accept");
- } else if(Interfaces.get(334) != null) {
- Interfaces.get(334).getChild(20).click("Accept");
- }
- General.sleep(1000);
- }
- }
- }
- }
- }
- }
- }
- }
- @Override
- public boolean validate()
- {
- return true;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement