Computor 177 Share Posted February 3, 2015 (edited) Hey all, my test account just got banned, so now I'm out of membership/levels/accounts to test scripts with. I created this AIO Sawmill script right before I got banned, and am going to release it. I never finished it/perfected it, so don't think it's going to be 100% perfect (that's why it's not going on the SDN). I didn't get widgets working, so right now the script is just clicking on locations that I set. (note for the pricks who try and correct me by using Rectangles). Here's script: Main script: package AIOSawmill; import org.dreambot.api.methods.Calculations; import org.dreambot.api.methods.map.Area; import org.dreambot.api.methods.map.Tile; import org.dreambot.api.script.AbstractScript; import org.dreambot.api.script.Category; import org.dreambot.api.script.ScriptManifest; import org.dreambot.api.wrappers.interactive.GameObject; import org.dreambot.api.wrappers.interactive.NPC; import org.dreambot.api.wrappers.widgets.WidgetChild; import java.awt.*; @ScriptManifest(name = "AIOSawMill2", author = "Computor", description = "AIOSawmill", version = 1, category = Category.MONEYMAKING) public class AIOSawmill extends AbstractScript{ //gui AIOSawmillGUI gui; String plankType; String sWoodType; int iWoodType; //1 plank, 2 oak, 3 teak, 4 mahogany boolean start = false; //gui boolean h; NPC operator; NPC banker; GameObject bankbooth; public static final Area sawMill = new Area(3299, 3486, 3305, 3491, 0); public static final Area eastBank = new Area(3250, 3423, 3257, 3420, 0); public enum State{ BANK, WALKTOBANK, WALKTOSAWMILL, MAKEPLANK; } State state; public State getState(){ if(getBank().isOpen()){ log("Bank is open, returning bank"); return State.BANK; } if((eastBank.contains(getLocalPlayer()) && getInventory().getCount(plankType) == 27) || !getInventory().contains("Coins")){ log("Standing in bank, opening bank. Returning from sawmill with planks. (possibly no coins)"); return State.BANK; } if(eastBank.contains(getLocalPlayer()) && getInventory().getCount(sWoodType) == 27 && getInventory().contains("Coins")){ log("Standing in bank, walking to sawmill. Logs in inventory"); return State.WALKTOSAWMILL; } if(!eastBank.contains(getLocalPlayer()) && getInventory().getCount(plankType) == 27){ log("Did sawmill, walking to bank with planks"); return State.WALKTOBANK; } if(!sawMill.contains(getLocalPlayer()) && getInventory().getCount(sWoodType) == 27 && getInventory().contains("Coins")){ log("Walking to sawmill. Have logs."); return State.WALKTOSAWMILL; } if(sawMill.contains(getLocalPlayer()) && !getInventory().contains(plankType)){ log("Making planks!"); return State.MAKEPLANK; } log("Something went wrong?"); return State.BANK; } @Override public void onStart() { gui = new AIOSawmillGUI(this); gui.setVisible(true);//try } @Override public int onLoop() { if(getClient().isLoggedIn()){ if(start){ banker = getNpcs().getClosest("Banker"); operator = getNpcs().getClosest("Sawmill operator"); bankbooth = getGameObjects().getClosest(6084); if(eastBank.contains(getLocalPlayer())){ h = true; }else { h = false; } state = getState(); switch(state){ case BANK: if(getBank().isOpen()){ if(getInventory().contains(plankType)){ getBank().deposit(plankType); } //check bank for wood bankCheck(sWoodType, 27, "Not enough wood in bank"); //end check for wood //getting coins if(!getInventory().contains("Coins")){ if(!getInventory().isFull()){ getBank().withdraw("Coins"); }else{ getBank().depositAll(); getBank().withdraw("Coins"); } } if(getBank().contains("Coins")){ if(!getInventory().isFull()){ getBank().withdraw("Coins"); }else{ getBank().depositAll(); getBank().withdraw("Coins"); } } //end of getting coins //getting wood out getLogs(); //end of getting wood out //check inventory for enough money if(iWoodType == 1){ itemCheck("Coins", 2700, "Not money in the bank"); }else if(iWoodType == 2){ itemCheck("Coins", 6750, "Not money in the bank"); }else if(iWoodType == 3){ itemCheck("Coins", 13500, "Not money in the bank"); }else{ itemCheck("Coins", 40500, "Not money in the bank"); } //end check for enough money //if money and logs, close if(getInventory().contains("Coins") && getInventory().getCount(sWoodType) == 27){ getBank().close(); sleep(300); } //if money and logs, close }else if(!getBank().isOpen()){ if(bankbooth != null){ if(bankbooth.isOnScreen()){ bankbooth.interact("Bank"); }else{ getCamera().mouseRotateToEntity(bankbooth); sleep(100,200); bankbooth.interact("Bank"); } }else if(banker != null){ if(banker.isOnScreen()){ banker.interact("Bank"); }else{ getCamera().mouseRotateToEntity(banker); sleep(100,200); banker.interact("Bank"); } } } break; case WALKTOBANK: getWalking().walk(eastBank.getRandomTile()); sleep(300); break; case WALKTOSAWMILL: getWalking().walk(sawMill.getRandomTile()); sleep(300); break; case MAKEPLANK: buyPlanks(); break; } } } return Calculations.random(300, 600); } public void bankCheck(String whatToCheck, int howMuch, String message){ if(getBank().getItem(whatToCheck).getAmount() < howMuch){ log(message); getBank().close(); getTabs().logout(); stop(); } } public void itemCheck(String whatToCheck, int howMuch, String message){ if(getInventory().getCount(whatToCheck) < howMuch){ log(message); getBank().close(); getTabs().logout(); stop(); } } public void buyPlanks(){ if(operator.interact("Buy-plank")){ sleep(1000,1200); if(!getLocalPlayer().isMoving()) { sleep(600, 800); if (iWoodType == 1) { //trying(403, 97); trying(139, 150, 85, 24); } else if (iWoodType == 2) { //trying(403, 98); trying(291, 158, 80, 24); } else if (iWoodType == 3) { //trying(403, 99); trying(140, 286, 80, 24); } else { //trying(403, 100); trying(303, 280, 80, 24); } //failsafe if (getWidgets().getChildWidget(403, 122) != null && getWidgets().getChildWidget(403, 122).isVisible()) { getWidgets().getChildWidget(403, 122).interact("Close"); } //failsafe } } } public void trying(int child, int parent, int width, int height){ // if (getWidgets().getChildWidget(child, parent) != null && getWidgets().getChildWidget(child, parent).isVisible()) { // try { // getWidgets().getChildWidget(child, parent).interact("Buy All"); // } catch (Exception e) { // log("Widgets are broken. Tell Computor."); // e.printStackTrace(); // } // } //temp fix Rectangle click = new Rectangle(child,parent,width,height);//xPos,yPos,width,height getMouse().move(click); getMouse().click(); } public void getLogs(){ if(getInventory().getCount(sWoodType) < 27){ if(!getInventory().isFull()){ getBank().withdraw(sWoodType); }else{ getBank().depositAll(); getBank().withdraw("Coins"); getBank().withdraw(sWoodType); } } } public void onPaint(Graphics2D g) { for (Tile t: sawMill.getTiles()) { g.drawPolygon(getMap().getPolygon(t)); } if (h){ g.drawString("TRUE", 200, 200); } } @Override public void onExit() { gui.setVisible(false); } } GUI: package AIOSawmill; import org.dreambot.api.methods.MethodProvider; import java.awt.*; import java.awt.event.*; import java.io.IOException; import java.net.URL; import javax.imageio.ImageIO; import javax.swing.*; /** * @author Jeff Smith */ public class AIOSawmillGUI extends JFrame { private AIOSawmill s; public AIOSawmillGUI(AIOSawmill mainclass) { this.s = mainclass; initComponents(); } private final Image backgroundPicture = getImage("http://designreflect.com/wp-content/uploads/2012/09/wooden-textures/Vintage-Grunge-Wood-Background.jpg"); private Image getImage(String url) {try{ return ImageIO.read(new URL(url)); }catch (IOException e) {} return null; } private void button1ActionPerformed(ActionEvent e) { s.plankType = comboBox1.getSelectedItem().toString(); //gets plank name if(s.plankType.equals("Plank")){ s.iWoodType = 1; s.sWoodType = "Logs"; }else if(s.plankType.equals("Oak plank")){ s.iWoodType = 2; s.sWoodType = "Oak logs"; }else if(s.plankType.equals("Teak plank")){ s.iWoodType = 3; s.sWoodType = "Teak logs"; }else if(s.plankType.equals("Mahogany plank")){ s.iWoodType = 4; s.sWoodType = "Mahogany logs"; }else{ MethodProvider.log("GUI is broken, report this to Computor"); s.stop(); } s.start = true; //start script s.gui.dispose(); //closes gui } private void thisWindowClosing(WindowEvent e) { s.stop(); MethodProvider.log("Stopping the bot...you closed the GUI. Try hitting start instead."); } private void initComponents() { label1 = new JLabel(); label2 = new JLabel(); label3 = new JLabel(); label4 = new JLabel(); button1 = new JButton(); comboBox1 = new JComboBox<>(); //======== this ======== setAlwaysOnTop(true); setResizable(false); setTitle("Computor's AIO SawMill"); addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { thisWindowClosing(e); } }); Container contentPane = getContentPane(); contentPane.setLayout(null); //---- label1 ---- label1.setText("Start bot at Varrock East bank."); label1.setFont(label1.getFont().deriveFont(label1.getFont().getSize() + 8f)); label1.setForeground(Color.BLACK); contentPane.add(label1); label1.setBounds(new Rectangle(new Point(63, 27), label1.getPreferredSize())); //---- label2 ---- label2.setText("Helps to start with gold in inventory."); label2.setFont(label2.getFont().deriveFont(label2.getFont().getSize() + 8f)); label2.setForeground(Color.BLACK); contentPane.add(label2); label2.setBounds(new Rectangle(new Point(40, 75), label2.getPreferredSize())); //---- label3 ---- label3.setText("Select plank type, hit start."); label3.setFont(label3.getFont().deriveFont(label3.getFont().getSize() + 8f)); label3.setForeground(Color.BLACK); contentPane.add(label3); label3.setBounds(new Rectangle(new Point(79, 120), label3.getPreferredSize())); //---- button1 ---- button1.setText("Start"); button1.setFont(button1.getFont().deriveFont(button1.getFont().getSize() + 8f)); button1.addActionListener(e -> button1ActionPerformed(e)); contentPane.add(button1); button1.setBounds(129, 215, 125, 38); //---- comboBox1 ---- comboBox1.setModel(new DefaultComboBoxModel<>(new String[] { "Plank", "Oak plank", "Teak plank", "Mahogany plank" })); contentPane.add(comboBox1); comboBox1.setBounds(113, 167, 157, 35); //---- backgroundPicture ---- label4.setIcon(new ImageIcon(backgroundPicture)); contentPane.add(label4); label4.setBounds(0, -5, 400, 300); contentPane.setPreferredSize(new Dimension(400, 300)); setSize(400, 300); setLocationRelativeTo(getOwner()); } private JLabel label1; private JLabel label2; private JLabel label3; private JLabel label4; private JButton button1; private JComboBox<String> comboBox1; } Edited February 4, 2015 by Computor Link to comment Share on other sites More sharing options...
Nuclear Nezz 1995 Share Posted February 3, 2015 Nice release. :') Link to comment Share on other sites More sharing options...
Takeoff 17 Share Posted February 4, 2015 Any1 wanna compile for us leechers pls ^^ Link to comment Share on other sites More sharing options...
Superman 49 Share Posted February 4, 2015 looks goood Link to comment Share on other sites More sharing options...
Trustmybet 47 Share Posted February 4, 2015 So AIO Sawmill for plank making or construction? im lost.. sorry Link to comment Share on other sites More sharing options...
Computor 177 Author Share Posted February 4, 2015 So AIO Sawmill for plank making or construction? im lost.. sorry Just for plank making....runs from varrock east to sawmill operator and makes planks. Link to comment Share on other sites More sharing options...
Ap0c4lyptyc 0 Share Posted February 4, 2015 Any1 wanna compile for us leechers pls ^^ Yeh! What he said! Please? Though my case is as much a script nub as it is leecher so... Link to comment Share on other sites More sharing options...
Takeoff 17 Share Posted February 5, 2015 Yeh! What he said! Please? Though my case is as much a script nub as it is leecher so... hah I didn't mean it in a bad way my friend without leechers like us sites would die to be honest. Link to comment Share on other sites More sharing options...
Lee5047 0 Share Posted March 3, 2015 How do I use this? Link to comment Share on other sites More sharing options...
Jupeeeeee 0 Share Posted March 22, 2015 Gotta try this Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now