ScummyBotter Posted April 5, 2018 Share Posted April 5, 2018 (edited) Scummy F2P Bank Walker I was a little bored of walking everywhere manually since this site didn't have a basic public free walker so I made this walker, please let me know of any ways I can improve my code quality. Bugs: Idk, it seems to work, let me know and I'll fix it Features: Walks to banks using Osbot webwalker Usage: Simply select the destination, arrival action then press go, check the status too since the webwalker can't always reach every location. Future Features: None planned, want CLI + Custom locations? Explv's got you covered Script Class: Spoiler import java.awt.Color; import java.awt.Graphics2D; import java.util.HashMap; import java.util.Map; import java.util.concurrent.TimeUnit; import org.osbot.rs07.api.map.Area; import org.osbot.rs07.api.map.constants.Banks; import org.osbot.rs07.event.WebWalkEvent; import org.osbot.rs07.script.Script; import org.osbot.rs07.script.ScriptManifest; import gui.GUI; @ScriptManifest(author = "ScummyBotter", info = "Uses Osbot webwalker to try and walk you to the F2P bank of your choice.", logo = "", name = "Scummy F2P Bank Walker", version = 1.0) public class ScummyF2PBankWalker extends Script { private GUI frame; private String status = ""; private Map<String, Area> bankMap = new HashMap<String, Area>(); private long startTime = System.currentTimeMillis(); private long timeElapsed = 0; @Override public void onStart() throws InterruptedException { log("Welcome to Scummy F2P Bank Walker"); status = "Awaiting Input From GUI..."; populateBanks(); makeGUI(); } private void populateBanks() { bankMap.put("Al Kharid", Banks.AL_KHARID); bankMap.put("Draynor", Banks.DRAYNOR); bankMap.put("Duel Arena", Banks.DUEL_ARENA); bankMap.put("Edgeville", Banks.EDGEVILLE); bankMap.put("Falador East", Banks.FALADOR_EAST); bankMap.put("Falador West", Banks.FALADOR_WEST); bankMap.put("Grand Exchange", Banks.GRAND_EXCHANGE); bankMap.put("Lumbridge Upper", Banks.LUMBRIDGE_UPPER); bankMap.put("Lumbridge Lower", Banks.LUMBRIDGE_LOWER); bankMap.put("Varrock East", Banks.VARROCK_EAST); bankMap.put("Varrock West", Banks.VARROCK_WEST); } private void makeGUI() { try { frame = new GUI(); frame.setVisible(true); } catch (Exception e) { e.printStackTrace(); } } @Override public int onLoop() throws InterruptedException { if(frame.getGoButtonState()){ frame.setVisible(false); if(notAtDestination()){ gotoDestination(); }else if(!notAtDestination() && wantsToAfk()){ afk(); }else{ status = "Exiting..."; stop(); } } return 0; } private void afk() throws InterruptedException { status = "Afking, will log out automatically."; sleep(random(180000)); } private boolean wantsToAfk() { return frame.getafkButtonState(); } private void gotoDestination() throws InterruptedException { WebWalkEvent event = new WebWalkEvent(bankMap.get(frame.getSelectedBank())); if(event.prefetchRequirements(this)){ log("Walking to " + frame.getSelectedBank()); status = "Walking to " + frame.getSelectedBank(); getWalking().webWalk(bankMap.get(frame.getSelectedBank())); log("Arrived at " + frame.getSelectedBank()); status = "Arrived at " + frame.getSelectedBank(); }else{ log("Webwalker couldn't find a path to destination, please move manually closer to the destination and try again."); status = "Couldn't find location. Read Osbot logger. Logging out in 30 seconds"; log("Logging out in 30 seconds..."); sleep(30000); stop(); } } private boolean notAtDestination() { return !bankMap.get(frame.getSelectedBank()).contains(myPlayer().getPosition()); } @Override public void onExit() throws InterruptedException { log("Thanks for using my walker :)"); } @Override public void onPaint(Graphics2D paint) { long currentTime = System.currentTimeMillis(); timeElapsed = currentTime - startTime; long hours = TimeUnit.MILLISECONDS.toHours(timeElapsed); timeElapsed -= TimeUnit.HOURS.toMillis(hours); long minutes = TimeUnit.MILLISECONDS.toMinutes(timeElapsed); timeElapsed -= TimeUnit.MINUTES.toMillis(minutes); long seconds = TimeUnit.MILLISECONDS.toSeconds(timeElapsed); paint.setColor(Color.WHITE); paint.drawString("Run Time: " + hours + ":" + minutes + ":" + seconds, 10, 314); paint.drawString("Status: " + status, 10, 328); } } Gui Class: Spoiler package gui; import java.awt.BorderLayout; import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.JLabel; import javax.swing.JComboBox; import javax.swing.JRadioButton; import javax.swing.JButton; import java.awt.Color; import javax.swing.DefaultComboBoxModel; import javax.swing.SwingConstants; import javax.swing.ButtonGroup; import java.awt.Dimension; import javax.swing.border.LineBorder; import javax.swing.UIManager; import javax.swing.border.TitledBorder; import javax.swing.border.BevelBorder; import java.awt.Font; import java.awt.Point; import java.awt.event.ActionListener; import java.awt.event.ActionEvent; public class GUI extends JFrame { private JPanel contentPane; private final ButtonGroup buttonGroup = new ButtonGroup(); private boolean goButton; private boolean afkButton; private boolean logButton; private String bankBox; /** * Create the frame. */ public GUI() { setType(Type.UTILITY); setLocation(new Point(768, 768)); setFont(new Font("GROBOLD", Font.PLAIN, 12)); setForeground(Color.BLACK); setTitle("ScummyBotter's F2P Bank Walker"); setBackground(Color.BLACK); setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); setBounds(100, 100, 270, 131); contentPane = new JPanel(); contentPane.setBackground(Color.DARK_GRAY); contentPane.setBorder(new BevelBorder(BevelBorder.LOWERED, null, null, null, null)); setContentPane(contentPane); contentPane.setLayout(new BorderLayout(0, 0)); JComboBox comboBox = new JComboBox(); comboBox.setBorder(new LineBorder(Color.DARK_GRAY, 2)); comboBox.setModel(new DefaultComboBoxModel(new String[] {"Al Kharid", "Draynor", "Duel Arena", "Edgeville", "Falador East", "Falador West", "Grand Exchange", "Lumbridge Upper", "Lumbridge Lower", "Varrock East", "Varrock West"})); comboBox.setSelectedIndex(6); contentPane.add(comboBox, BorderLayout.NORTH); JRadioButton rdbtnNewRadioButton = new JRadioButton("Afk"); rdbtnNewRadioButton.setMaximumSize(new Dimension(20, 20)); rdbtnNewRadioButton.setBorderPainted(true); rdbtnNewRadioButton.setBorder(new TitledBorder(UIManager.getBorder("TitledBorder.border"), "", TitledBorder.LEADING, TitledBorder.TOP, null, new Color(0, 0, 0))); rdbtnNewRadioButton.setHorizontalAlignment(SwingConstants.LEFT); rdbtnNewRadioButton.setMinimumSize(new Dimension(20, 20)); buttonGroup.add(rdbtnNewRadioButton); rdbtnNewRadioButton.setBackground(Color.GRAY); contentPane.add(rdbtnNewRadioButton, BorderLayout.CENTER); JRadioButton rdbtnNewRadioButton_1 = new JRadioButton("Log Out"); rdbtnNewRadioButton_1.setSelected(true); rdbtnNewRadioButton_1.setBorder(new TitledBorder(null, "", TitledBorder.LEADING, TitledBorder.TOP, null, null)); rdbtnNewRadioButton_1.setBorderPainted(true); buttonGroup.add(rdbtnNewRadioButton_1); rdbtnNewRadioButton_1.setBackground(Color.GRAY); contentPane.add(rdbtnNewRadioButton_1, BorderLayout.EAST); JButton btnNewButton = new JButton("Go"); btnNewButton.setPreferredSize(new Dimension(45, 40)); btnNewButton.setMinimumSize(new Dimension(45, 40)); btnNewButton.setMaximumSize(new Dimension(100, 100)); btnNewButton.setBorder(new LineBorder(Color.DARK_GRAY)); btnNewButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { goButton = true; bankBox = comboBox.getSelectedItem().toString(); if(rdbtnNewRadioButton.isSelected()){ afkButton = true; logButton = false; }else if(rdbtnNewRadioButton_1.isSelected()){ logButton = true; afkButton = false; } } }); contentPane.add(btnNewButton, BorderLayout.SOUTH); JLabel lblNewLabel = new JLabel("Select Action On Arrival: "); lblNewLabel.setBorder(new LineBorder(Color.DARK_GRAY, 2)); lblNewLabel.setForeground(Color.WHITE); contentPane.add(lblNewLabel, BorderLayout.WEST); } public boolean getGoButtonState(){ return goButton; } public boolean getafkButtonState(){ return afkButton; } public boolean getLogButtonState(){ return logButton; } public String getSelectedBank(){ return bankBox; } } Download: ScummyF2PWalker.jar Edited June 8, 2019 by ScummyBotter 2 Quote Link to comment Share on other sites More sharing options...
Billyrex1999 Posted April 5, 2018 Share Posted April 5, 2018 Thanks for sharing your source code! Quote Link to comment Share on other sites More sharing options...
jb4 Posted April 5, 2018 Share Posted April 5, 2018 Thanks a lot for this! Quote Link to comment Share on other sites More sharing options...
ScummyBotter Posted April 5, 2018 Author Share Posted April 5, 2018 7 hours ago, Billyrex1999 said: Thanks for sharing your source code! 3 hours ago, jb4 said: Thanks a lot for this! No worries guys! Enjoy Quote Link to comment Share on other sites More sharing options...
Erradicated Posted October 16, 2018 Share Posted October 16, 2018 nice release, script needed for quality of life Quote Link to comment Share on other sites More sharing options...
Johnnybgd Posted October 27, 2018 Share Posted October 27, 2018 Gonna test this out today many thanks Quote Link to comment Share on other sites More sharing options...
ScummyBotter Posted October 27, 2018 Author Share Posted October 27, 2018 (edited) 7 minutes ago, Johnnybgd said: Gonna test this out today many thanks No worries, let me know if anything is broken and I'll fix it Edited October 27, 2018 by ScummyBotter Quote Link to comment Share on other sites More sharing options...
TutIslander Posted November 7, 2018 Share Posted November 7, 2018 Nice release this will help a few people Quote Link to comment Share on other sites More sharing options...