The script is currently not working!
The first Auto Miner with banking support for multiple locations!
GUI:
Locations:
Varrock east
Varrock west
Falador
Yannile
Ores:
Copper
Tin
Clay
Iron
Silver
Coal
Mithril
Bugs
-Varrock east banking is not working correctly
TODO list:
-adding new paint;
-adding more locations;
Script:
Download link: Click Here
Code:
import org.osbot.script.Script;import org.osbot.script.ScriptManifest;import org.osbot.script.rs2.map.Position;import org.osbot.script.rs2.model.GroundItemimport org.osbot.script.rs2.model.Player;import org.osbot.script.rs2.model.RS2Object;import org.osbot.script.rs2.model.RS2Object;import org.osbot.script.rs2.ui.Bank;import org.osbot.script.rs2.ui.Tab;import org.osbot.script.rs2.utility.Area;import javax.swing.GroupLayout;import javax.swing.JComboBox;import javax.swing.JLabel;import javax.swing.JPanel;import javax.swing.GroupLayout.Alignment;import javax.swing.LayoutStyle.ComponentPlacement;import java.awt.Color;import java.awt.Font;import java.awt.Graphics;import java.util.ArrayList;import javax.swing.JFrame;import javax.swing.border.EmptyBorder;import javax.swing.SwingConstants;import javax.swing.JSeparator;import javax.swing.JRadioButton;import javax.swing.JButton;import javax.swing.ButtonGroup;import java.awt.event.ActionEvent;import java.awt.event.ActionListener; @ScriptManifest(name = "AutoMiner", author="Xerion", version = 1.1D, info = "The first AIOMiner!")class AutoMinerGS extends Script { enum State { INPUT, IDLE, MINING, DROP, BANK, BANKING,TOMINE } //Areas private final Area Varrock_east = new Area([new Position(3291, 3361,0), new Position(3291, 3371,0),new Position(3280, 3371,0),new Position(3280, 3361,0)] as Position[]); private final Area Varrock_west = new Area([new Position(3171, 3364,0), new Position(3171, 3377,0),new Position(3183, 3364,0),new Position(3183, 3377,0)] as Position[]); private final Area Falador_west = new Area([new Position(2903, 3352,0), new Position(2903, 3367,0),new Position(2911, 3367,0),new Position(2911, 3352,0)] as Position[]); private final Area Yannile = new Area([new Position(2624, 3139, 0), new Position(2633, 3139, 0),new Position(2624, 3152, 0),new Position(2633, 3152, 0)] as Position[]); //end private final int Mining_emote = 624; private final int[] Banks = [2553] as int[] private final int[] Pickaxes = [1265,1267,1269,1271,1273,1275] as int[] private final int[] pickhandle = [480,482,484,486,488,490]; public Ores[] ores = [new Ores("Copper",[11960,11961,11962,2091] as int[],436), new Ores("Tin",[11957,11958,11959,2095,2094] as int[],438), new Ores("Clay",[15505,15503,15504,2108,2109] as int[],434), new Ores("Iron",[11954,11955,11956,2093,2092] as int[],440), new Ores("Silver",[11950,11949,11948] as int[],442), new Ores("Coal",[11964,11963] as int[],453), new Ores("Mithril",[2102,2103] as int[],447)] as Ores[]; Locations[] locations = [new Locations("Varrock east",[11960,11961,11962,11957,11958,11959,11954,11955,11956] as int[], Varrock_east), new Locations("Varrock west",[11959, 11957, 11955, 11956, 11950, 11949, 11948, 15505, 15503, 11954, 11958] as int[], Varrock_west), new Locations("Falador west",[11956,11954,11957,11958,11959,11960,11692,11963,11694] as int[], Falador_west), new Locations("Yanille",[2108,2091,2095,2094,2092,2093,2102,2103] as int[], Yannile)] as Locations[]; public Ores ore = null; public Locations location = null; public boolean banking; private long startTime; private long Newantiban; private long timeoutTime; private State state = State.INPUT; private RS2Object currentRock = null; private int MinedOre = 0; private boolean ActiveAntibans = true; @Override public void onStart() { startTime = System.currentTimeMillis(); Newantiban = System.currentTimeMillis() + random(40000,120000); Input frame = new Input(locations,ores); frame.setVisible(true); while(location == null || ore == null){ if(frame.selectedlocation != null && frame.ore != null){ location = frame.selectedlocation; ore = frame.ore; banking = frame.banking; frame.dispose(); if(client.getInventory().isFull()){ if (banking == true){ state = State.BANK; } else { state = State.DROP; } } else { if(location.getArea().contains(client.getMyPlayer().getPosition())){ state = State.IDLE; } else { state = State.TOMINE; } } } sleep(1000) } } @Override public int onLoop() throws InterruptedException { if(!randoms() && location != null && ore != null){ switch(state) { case State.IDLE: return mine(); case State.MINING: return check(); case State.DROP: return drop(); case State.BANK: return bank(); case State.BANKING: return banking(); case State.TOMINE: return tomine(); case State.INPUT: return 3000 + gRandom(400, 800); } } return 100 + gRandom(400, 800); } int mine() throws InterruptedException{ currentRock = closestObject(ore.getRockIds()); if(canReach(currentRock) && currentRock != null && location.getArea().contains(currentRock.getPosition())){ if (selectEntityOption(currentRock,false,"Mine")) { timeoutTime = System.currentTimeMillis() + 15000; state = State.MINING; } } else if (!canReach(currentRock) && currentRock != null && location.getArea().contains(currentRock.getPosition())){ if (selectEntityOption(currentRock,"Mine")) { timeoutTime = System.currentTimeMillis() + 15000; state = State.MINING; } } return 100; } int check(){ checkCurrentRock(currentRock); if (!currentRock.exists() || timeoutTime < System.currentTimeMillis()){ if (!client.getInventory().isFull()){ state = State.IDLE; return 500 + random(100, 1000); } else { if (banking == true){ state = State.BANK; setRunning(true); } else { state = State.DROP; } return 500 + random(100, 1000); } } else if (state == State.MINING && Newantiban < System.currentTimeMillis()){ antiban(); } return 100; } int drop() throws InterruptedException{ if (currentTab() != Tab.INVENTORY){ openTab(Tab.INVENTORY); } else { client.getInventory().dropAllExcept(Pickaxes) state = State.IDLE; } return 100; } int bank() throws InterruptedException{ if (!isRunning()){ setRunning(true); } else{ switch(location.getName()) { case "Varrock east": if (myY() <= 3409){ walk(new Position(3289 + random(3),3410 + random(3),0)) } else if(myY() > 3409 && myY() < 3424){ walk(new Position(3279 + random(4),3427 + random(3),0)) }else if(myY() >= 3424){ walk(new Position(3254 + random(3),3422 + random(3),0)) state = State.BANKING; } return 1000 + random(500,2000); case "Falador west": if(myX() < 2935 && !canReach(closestObject(11844))){ walk(new Position(2931 + random(3),3354 + random(3),0)) } else if(myX() < 2935 && canReach(closestObject(11844))){ selectEntityOption(closestObject(11844),"Climb-over") } else if(myX() > 2935 && !client.getMyPlayer().isAnimating()){ walk(new Position(2944 + random(3),3369 + random(3),0)) state = State.BANKING; } return 1000 + random(500,2000) case "Varrock west": if(myY() < 3390){ walk(new Position(3168 + random(4),3395 + random(4),0)) }else if(myY() < 3409 && myY() >= 3390){ walk(new Position(3170 + random(2),3411 + random(2),0)) }else { if(walk(new Position(3181 + random(3),3434 + random(3),0))) state = State.BANKING; } return 1000 + random(500,2000) case "Yanille": if(walk(new Position(2610 + random(3),3093 + random(1),0))) state = State.BANKING; return 1000 + random(500,2000) default: log("Banking is not supported on this location!") state = state.DROP; return 100 } } return 1000 + random(500,2000); } int banking() throws InterruptedException{ Bank bank = client.getBank(); if(bank.isOpen() && client.getInventory().isFull()){ bank.depositAllExcept(Pickaxes) sleep(1500) bank.close() sleep(500) state = State.TOMINE; } else if(client.getInventory().isFull() && !bank.isOpen()) { selectEntityOption(closestObjectForName("Bank booth"), "Bank") } return 1000 + random(500,2000); } int tomine() throws InterruptedException{ switch(location.getName()) { case "Varrock east": if(myY() >= 3417 && myX() <= 3279) walk(new Position(3286 + random(3),3424 + random(3),0)) else if(myY() >= 3417 && myX() >= 3279) walk(new Position(3290 + random(3),3395 + random(3),0)) else if(myY() < 3417 && myY() >= 3384 && myX() >= 3279) walk(new Position(3290 + random(3),3381 + random(3),0)) else { walk(new Position(3283 + random(3),3365 + random(3),0)) state = State.IDLE;} return 1000 + random(500,2000); case "Falador west": if(myX() < 2935 && !client.getMyPlayer().isAnimating()){ walk(new Position(2905 + random(4),3354 + random(4),0)) state = State.IDLE; } else if(myX() > 2935 && canReach(closestObject(11844))){ selectEntityOption(closestObject(11844),"Climb-over") //sleep(random(2000,4000)) } else if(myX() > 2935 && !canReach(closestObject(11844))){ walk(new Position(2938 + random(3),3355 + random(3),0)) } return 1000 + random(500,2000) case "Varrock west": if(myY() > 3424){ walk(new Position(3170 + random(3),3422 + random(3),0)) }else if(myY() <= 3424 && myY() >= 3400){ walk(new Position(3169 + random(4),3394 + random(4),0)) } else { if(walk(new Position(3178 + random(3),3368 + random(3),0))) state = State.IDLE; } return 1000 + random(500,2000) case "Yanille": if(walk(new Position(2626 + random(3),3146 + random(3),0))) state = State.IDLE; return 1000 + random(500,2000) default: if (walk(location.getArea())) state = State.IDLE; return 1000 + random(500,2000); } return 1000 + random(500,2000); } boolean randoms(){ //Losing Pickhandle if (closestGroundItem(pickhandle) != null){ selectEntityOption(closestGroundItem(pickhandle),"Take") return true } else if(client.getMyPlayer().isUnderAttack()){ switch(location.getName()) { case "Varrock east": walk(new Position(3289 + random(3),3410 + random(3),0)) sleep(random(5000,10000)) state = State.TOMINE; return true; } } return false; } @Override public void onPaint(Graphics g) { if (location != null && ore != null){ g.setColor(new Color(0.1f, 0.1f, 0.1f, 0.7f)); g.fillRect(1, 51, 175, 104); g.setFont(new Font("Calisto MT", 0, 16)); g.setColor(new Color(255, 0, 0)); g.drawString("AutoMiner", 7, 76); g.setFont(new Font("Calisto MT", 0, 11)); g.drawString("Time: " + format(System.currentTimeMillis() - startTime), 7, 100); g.drawString("Location: ${location.getName()}", 7, 115); g.drawString("Ore: ${ore.getName()}(${MinedOre})", 7, 130); g.drawString("State: ${state}", 7, 145); } } @Override void onMessage(String message){ if ("You manage to mine some ${ore.getName().toLowerCase()}." == message){ MinedOre++ } else if (message == "This rock contains ${ore.getName().toLowerCase()}." || message == "There is no ore currently available in this rock."){ state = State.IDLE; } } @Override void onExit(){ ActiveAntibans = false } void antiban(){ if (state == State.MINING && Newantiban < System.currentTimeMillis()){ int Anti = random(0 , 3) switch(Anti){ case 0: log("Antiban: Move mouse") moveMouseOutsideScreen() Newantiban = System.currentTimeMillis() + random(40000, 120000) break; case 1: log("Antiban: Move camera") client.moveCameraToEntity(currentRock) Newantiban = System.currentTimeMillis() + random(40000, 120000) break; case 2: log("Antiban: Open Skills tab") if (currentTab() != Tab.SKILLS){ openTab(Tab.SKILLS); } else{openTab(Tab.INVENTORY);} Newantiban = System.currentTimeMillis() + random(40000, 120000) break; case 3: log("Antiban: Open Friends tab") if (currentTab() != Tab.FRIENDS){ openTab(Tab.FRIENDS); sleep(random(500,1000)) } else{openTab(Tab.INVENTORY);} Newantiban = System.currentTimeMillis() + random(40000, 120000) break; } } } void checkCurrentRock(RS2Object currentRock2) { Player p = client.getMyPlayer(); if(p.getAnimation() == Mining_emote){ switch (p.getRotation()){ case 0: //facing south if(currentRock2.getPosition() != new Position(p.getX(),p.getY() - 1, p.getZ())){ for(RS2Object o : client.getCurrentRegion().getObjects()){ if(o.getPosition() == new Position(p.getX(),p.getY() - 1, p.getZ())){ currentRock = (RS2Object) o; log("AutoMiner: Changed currentRock"); } } } break; case 1023: //facing north if(currentRock2.getPosition() != new Position(p.getX(),p.getY() + 1, p.getZ())){ for(RS2Object o : client.getCurrentRegion().getObjects()){ if(o.getPosition() == new Position(p.getX(),p.getY() + 1, p.getZ())){ currentRock = (RS2Object) o; log("AutoMiner: Changed currentRock"); } } } break; case 1537: //facing east if(currentRock2.getPosition() != new Position(p.getX() + 1,p.getY(), p.getZ())){ for(RS2Object o : client.getCurrentRegion().getObjects()){ if(o.getPosition() == new Position(p.getX() + 1,p.getY(), p.getZ())){ currentRock = (RS2Object) o; log("AutoMiner: Changed currentRock"); } } } break; case 511: //facing west if(currentRock2.getPosition() != new Position(p.getX() - 1,p.getY(), p.getZ())){ for(RS2Object o : client.getCurrentRegion().getObjects()){ if(o.getPosition() == new Position(p.getX() - 1,p.getY(), p.getZ())){ currentRock = (RS2Object) o; log("AutoMiner: Changed currentRock"); } } } break; } } } String format(final long time) { final StringBuilder t = new StringBuilder(); final long total_secs = time / 1000; final long total_mins = total_secs / 60; final long total_hrs = total_mins / 60; final int secs = (int) total_secs % 60; final int mins = (int) total_mins % 60; final int hrs = (int) total_hrs % 24; if (hrs < 10) { t.append("0"); } t.append(hrs); t.append(":"); if (mins < 10) { t.append("0"); } t.append(mins); t.append(":"); if (secs < 10) { t.append("0"); } if (secs < 0){ t.append("0"); } else{ t.append(secs); } return t.toString(); }}class Input extends JFrame { private JPanel contentPane; private final ButtonGroup buttonGroup = new ButtonGroup(); public Ores ore = null; public Locations selectedlocation = null; public Ores[] ores; public boolean banking; public Input(final Locations[] locations, final Ores[] ores) { this.ores = ores; String[] loc = new String[locations.length]; for(int i = 0; i < locations.length; i++) { loc[i] = locations[i].getName(); } setResizable(false); setTitle("Setup"); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setBounds(100, 100, 326, 203); contentPane = new JPanel(); contentPane.setBorder(new EmptyBorder(5, 5, 5, 5)); setContentPane(contentPane); JLabel lblNewLabel = new JLabel("AutoMiner"); lblNewLabel.setFont(new Font("Vivaldi", Font.PLAIN, 24)); lblNewLabel.setHorizontalAlignment(SwingConstants.CENTER); JSeparator separator = new JSeparator(); JLabel lblNewLabel_1 = new JLabel("Select Location:"); final JComboBox comboBox = new JComboBox(loc); JLabel lblSelectOre = new JLabel("Select Ore:"); final JComboBox comboBox_1 = new JComboBox(CheckRocks(locations[comboBox.getSelectedIndex()])); comboBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { comboBox_1.removeAllItems(); ArrayList<String> Rocks = new ArrayList<String>(); int[] r = locations[comboBox.getSelectedIndex()].getrocks(); for(Ores y : ores){ for(int i : y.getRockIds()){ if(r.contains(i)){ if (!Rocks.contains(y.getName())) Rocks.add(y.getName()); } } } for (String s : Rocks){ comboBox_1.addItem(s); } }}); JRadioButton rdbtnDrop = new JRadioButton("Drop items"); buttonGroup.add(rdbtnDrop); rdbtnDrop.setSelected(true); JSeparator separator_1 = new JSeparator(); ; final JRadioButton rdbtnBankItems = new JRadioButton("Bank items"); buttonGroup.add(rdbtnBankItems); JButton btnNewButton = new JButton("Start!"); btnNewButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { banking = rdbtnBankItems.isSelected(); selectedlocation = locations[comboBox.getSelectedIndex()]; for(Ores o : ores){ if(o.getName() == comboBox_1.getSelectedItem()) ore = o } }}); GroupLayout gl_contentPane = new GroupLayout(contentPane); gl_contentPane.setHorizontalGroup( gl_contentPane.createParallelGroup(Alignment.LEADING) .addGroup(gl_contentPane.createSequentialGroup() .addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING) .addGroup(gl_contentPane.createSequentialGroup() .addContainerGap() .addComponent(separator, GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)) .addComponent(lblNewLabel, GroupLayout.DEFAULT_SIZE, 279, Short.MAX_VALUE) .addGroup(Alignment.TRAILING, gl_contentPane.createSequentialGroup() .addContainerGap() .addGroup(gl_contentPane.createParallelGroup(Alignment.TRAILING) .addComponent(comboBox_1, GroupLayout.PREFERRED_SIZE, 185, GroupLayout.PREFERRED_SIZE) .addGroup(gl_contentPane.createSequentialGroup() .addComponent(lblNewLabel_1) .addPreferredGap(ComponentPlacement.RELATED, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(comboBox, GroupLayout.PREFERRED_SIZE, 185, GroupLayout.PREFERRED_SIZE))) .addPreferredGap(ComponentPlacement.RELATED))) .addGap(6)) .addGroup(gl_contentPane.createSequentialGroup() .addContainerGap() .addComponent(lblSelectOre, GroupLayout.PREFERRED_SIZE, 76, GroupLayout.PREFERRED_SIZE) .addContainerGap(468, Short.MAX_VALUE)) .addGroup(gl_contentPane.createSequentialGroup() .addContainerGap() .addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING) .addGroup(gl_contentPane.createSequentialGroup() .addComponent(btnNewButton, GroupLayout.DEFAULT_SIZE, 265, Short.MAX_VALUE) .addContainerGap()) .addComponent(separator_1, GroupLayout.DEFAULT_SIZE, 538, Short.MAX_VALUE) .addGroup(gl_contentPane.createSequentialGroup() .addComponent(rdbtnDrop) .addGap(18) .addComponent(rdbtnBankItems, GroupLayout.PREFERRED_SIZE, 118, GroupLayout.PREFERRED_SIZE) .addContainerGap()))) ); gl_contentPane.setVerticalGroup( gl_contentPane.createParallelGroup(Alignment.LEADING) .addGroup(gl_contentPane.createSequentialGroup() .addComponent(lblNewLabel) .addPreferredGap(ComponentPlacement.RELATED) .addComponent(separator, GroupLayout.PREFERRED_SIZE, 4, GroupLayout.PREFERRED_SIZE) .addPreferredGap(ComponentPlacement.RELATED) .addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING) .addComponent(lblNewLabel_1) .addComponent(comboBox, GroupLayout.DEFAULT_SIZE, 20, Short.MAX_VALUE)) .addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING) .addGroup(gl_contentPane.createSequentialGroup() .addGap(8) .addComponent(lblSelectOre)) .addGroup(gl_contentPane.createSequentialGroup() .addPreferredGap(ComponentPlacement.RELATED) .addComponent(comboBox_1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))) .addPreferredGap(ComponentPlacement.RELATED) .addComponent(separator_1, GroupLayout.PREFERRED_SIZE, 4, GroupLayout.PREFERRED_SIZE) .addPreferredGap(ComponentPlacement.RELATED) .addGroup(gl_contentPane.createParallelGroup(Alignment.BASELINE) .addComponent(rdbtnDrop) .addComponent(rdbtnBankItems)) .addPreferredGap(ComponentPlacement.RELATED) .addComponent(btnNewButton, GroupLayout.DEFAULT_SIZE, 322, Short.MAX_VALUE)) ); contentPane.setLayout(gl_contentPane); } public String[] CheckRocks(Locations l){ ArrayList<String> Rocks = new ArrayList<String>(); int[] r = l.getrocks(); for(Ores y : ores){ for(int i : y.getRockIds()){ if(contains(r,i)){ if (!Rocks.contains(y.getName())) Rocks.add(y.getName()); } } } return (String[]) Rocks.toArray(); } public boolean contains(final int[] array, final int key) { for (final int i : array) { if (i == key) { return true; } } return false; } } class Locations { private final String name; private final int[] rocks; private final Area area; public Locations(String name, int[] rocks, Area area) { this.name = name; this.rocks = rocks; this.area = area; } public String getName() { return name; } public int[] getrocks() { return rocks; } public Area getArea() { return area; } } class Ores{ private final String name; private final int[] rockids; private final int oreid; public Ores(String name, int[] rockids, int oreid) { this.name = name; this.rockids = rockids; this.oreid = oreid; } public String getName() { return name; } public int[] getRockIds() { return rockids; } public int getOreId() { return oreid; } }