dogetrix Posted July 15, 2018 Share Posted July 15, 2018 (edited) Powerfish anywhere. Even at barbarian village, which the top 2 aio fishers can't do for some reason. Incredibly stable. Just put the action name in and you're good to go. I gladly accept any criticism of the code. (I did use a couple lambdas so decompilers might make it look messy.) osb.jar Sources: GUI: Spoiler package com.dogetrix.bots; import java.awt.Component; import java.awt.Container; import java.awt.Dialog; import java.awt.FlowLayout; import java.awt.LayoutManager; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.BoxLayout; import javax.swing.JButton; import javax.swing.JCheckBox; import javax.swing.JComboBox; import javax.swing.JDialog; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JTextField; import javax.swing.border.Border; import javax.swing.border.EmptyBorder; public class DogeFishingGUI { private JDialog mainDialog = new JDialog(); private JTextField action; private JCheckBox barbVillageToggle; private JCheckBox bankToggle; private boolean started; public DogeFishingGUI() { mainDialog.setTitle("Doge Powerfishing"); mainDialog.setModal(true); mainDialog.setModalityType(Dialog.ModalityType.APPLICATION_MODAL); JPanel mainPanel = new JPanel(); mainPanel.setLayout(new BoxLayout(mainPanel, 3)); mainPanel.setBorder(new EmptyBorder(20, 20, 20, 20)); mainDialog.getContentPane().add(mainPanel); JPanel actionPanel = new JPanel(); actionPanel.setLayout(new FlowLayout(0)); JLabel targetLevelLabel = new JLabel("Action name: "); actionPanel.add(targetLevelLabel); action = new JTextField("", 8); actionPanel.add(action); mainPanel.add(actionPanel); JPanel barbVillagePanel = new JPanel(); barbVillagePanel.setLayout(new FlowLayout(1)); barbVillageToggle = new JCheckBox("Barbarian village fishing"); barbVillagePanel.add(barbVillageToggle); mainPanel.add(barbVillagePanel); JPanel bankPanel = new JPanel(); bankPanel.setLayout(new FlowLayout(1)); bankToggle = new JCheckBox("Bank (currently does nothing)"); bankPanel.add(bankToggle); mainPanel.add(bankPanel); JPanel startButtonPanel = new JPanel(); startButtonPanel.setLayout(new FlowLayout(1)); JButton startButton = new JButton("Start"); startButton.addActionListener(listener -> {started = true; close();}); startButtonPanel.add(startButton); mainPanel.add(startButtonPanel); mainDialog.pack(); } public boolean isStarted() { return started; } public String getAction() { return action.getText(); } public boolean getBarbVillageChoice() { return barbVillageToggle.isSelected(); } public boolean getBankChoice() { return bankToggle.isSelected(); } public void open() { mainDialog.setLocationRelativeTo(null); mainDialog.setVisible(true); } public void close() { mainDialog.setVisible(false); mainDialog.dispose(); } } Script: Spoiler package com.dogetrix.bots; import org.osbot.rs07.api.Tabs; import org.osbot.rs07.api.map.Position; import org.osbot.rs07.api.model.NPC; import org.osbot.rs07.api.model.Player; import org.osbot.rs07.api.model.RS2Object; import org.osbot.rs07.api.ui.RS2Widget; import org.osbot.rs07.api.ui.Skill; import org.osbot.rs07.api.ui.Tab; import org.osbot.rs07.event.WebWalkEvent; import org.osbot.rs07.script.Script; import org.osbot.rs07.script.ScriptManifest; import org.osbot.rs07.utility.Condition; import org.osbot.rs07.utility.ConditionalSleep; import javax.swing.*; import java.awt.*; @ScriptManifest(name = "Doge Fishing", author = "dogetrix", version = 1.0, info = "", logo = "") public class DogeFishing extends Script { String status; long start = 0; String actionType; boolean barbarianVillage, banking; DogeFishingGUI gui; public void onStart() { //Code here will execute before the loop is started status = "GUI"; logger.debug("Bot started, waiting for gui"); try { SwingUtilities.invokeAndWait(() -> {gui = new DogeFishingGUI(); gui.open();}); } catch (Exception e) { e.printStackTrace(); logger.debug("GUI failed to load"); stop(); return; } if (!gui.isStarted()) { logger.debug("GUI not started"); stop(); return; } logger.debug("GUI started successfully"); barbarianVillage = gui.getBarbVillageChoice(); actionType = gui.getAction(); banking = gui.getBankChoice(); logger.debug("Got values for (barbarianVillage, actionType, banking) as (" + barbarianVillage + ", " + actionType + ", " + banking + ")"); status = "Starting bot"; start = System.currentTimeMillis(); getExperienceTracker().start(Skill.FISHING); } //I didn't create auxiliary methods for most of the stuff in the main loop because it's simple enough that it can //all be read in one go, and auxiliary methods would basically be obfuscation public int onLoop() throws InterruptedException { if (inventory.isFull()) { status = "Dropping"; logger.debug("Begin dropping"); if (inventory.isItemSelected()) { inventory.deselectItem(); //occasionally osbot's shift dropping will select an item on accident. logger.debug("Attempted to deselect item while dropping"); } inventory.dropAll(f -> f.getName().substring(0, 3).equals("Raw")); //this below one doesn't work idk why //inventory.dropAll(f -> f.nameContains("Raw")); logger.debug("Dropped all"); } else if (!myPlayer().isAnimating()) { NPC spot = npcs.closest(f -> (barbarianVillage ? "Rod Fishing spot" : "Fishing spot").equals(f.getName()) && f.hasAction(actionType)); logger.debug("Queried spot " + spot); status = "Fishing"; if (inventory.isItemSelected()) { inventory.deselectItem(); logger.debug("Attempted to deselect item while fishing"); } if (spot.interact(actionType)) { logger.debug("Interacted!"); mouse.moveOutsideScreen(); status = "Idling"; sleep(3000); //allow for a small lag between when the click is done and when movement begins //the idling CS is meant to prevent against multiclicking the fishing spot after each loop logger.debug("entering idling CS"); new ConditionalSleep(15000, 1000) { public boolean condition() {return !myPlayer().isAnimating() && !myPlayer().isMoving();} }.sleep(); logger.debug("CS finished"); } } //I know that this kind of "antiban" is worthless, but people like to see it. //I aim to add antipattern (sleep times + multiclick + more?), but only after the script demonstrates stability //later these methods will also be antipattern'd, they still need to be there so n00bs can see it //and put more trust in it if (random(1, 100) == 50) { status = "Rotating camera randomly"; logger.debug("Rotating camera randomly"); camera.movePitch(random(35, 67)); camera.moveYaw(random(0, 359)); } if (random(1, 100) == 2) { status = "Checking experience"; logger.debug("Checking experience randomly"); tabs.open(Tab.SKILLS); RS2Widget w = widgets.get(320, Skill.FISHING.getChildId()); if (w != null) { w.hover(); } sleep(random(1000, 3000)); tabs.open(Tab.INVENTORY); } return random(1000, 2000); } public void onPaint(Graphics2D g) { Font font = new Font("Arial", Font.PLAIN, 14); g.setFont(font); g.setColor(Color.white); g.drawString(formatTime(System.currentTimeMillis() - start), 10, 30); g.drawString("Levels: " + getExperienceTracker().getGainedLevels(Skill.FISHING), 10, 50); g.drawString("Experience (hourly): " + getExperienceTracker().getGainedXP(Skill.FISHING) + " (" + (int) ((3600000.0 * getExperienceTracker().getGainedXP(Skill.FISHING)) / (System.currentTimeMillis() - start)) + ")", 10, 70); g.drawString("Status: " + status, 10, 110); Point cursorLocation = getMouse().getPosition(); int x = (int) cursorLocation.getX(); int y = (int) cursorLocation.getY(); g.drawLine(x - 6, y - 6, x + 6, y + 6); g.drawLine(x - 6, y + 6, x + 6, y - 6); } private String formatTime(long ms) { long s = ms / 1000, m = s / 60, h = m / 60; s %= 60; m %= 60; h %= 24; return h + ":" + (m < 10 ? "0" + m : m) + ":" + (s < 10 ? "0" + s : s); //return String.format("%02d:%02d:%02d", h, m, s); } } Edited July 15, 2018 by dogetrix add source Quote Link to comment Share on other sites More sharing options...
dogetrix Posted July 15, 2018 Author Share Posted July 15, 2018 forgot to say that banking support will be added in the near future. Quote Link to comment Share on other sites More sharing options...
Rays Posted July 15, 2018 Share Posted July 15, 2018 Looks fine overall. Though, antipattern != antiban. Also, this makes no sense to me: they still need to be there so n00bs can see it and put more trust in it Quote Link to comment Share on other sites More sharing options...
dogetrix Posted July 15, 2018 Author Share Posted July 15, 2018 13 minutes ago, Rays said: Looks fine overall. Though, antipattern != antiban. Also, this makes no sense to me: they still need to be there so n00bs can see it and put more trust in it Thanks for taking the time to look over it! What I meant in the comment was that "antiban" as in moving camera, check skills, etc. is basically worthless, but people like to see it (including me), and there's no harm done from doing it. I know the difference between antipattern and antiban, and there's no antipattern right now, but there will be in the future. Quote Link to comment Share on other sites More sharing options...
Rays Posted July 15, 2018 Share Posted July 15, 2018 10 minutes ago, dogetrix said: Thanks for taking the time to look over it! What I meant in the comment was that "antiban" as in moving camera, check skills, etc. is basically worthless, but people like to see it (including me), and there's no harm done from doing it. I know the difference between antipattern and antiban, and there's no antipattern right now, but there will be in the future. Actually, I think people are also debating if it's actually making it worse doing random 'antiban' like that. Good luck with further scripting though! 1 Quote Link to comment Share on other sites More sharing options...