FuzzyAutoFighter v1.1
Instructions:
- Save script as "FuzzyAutoFighter.groovy" - Place in: -> %userprofile%/osbot/scripts (Windows) -> /home/osbot/scripts (Mac/Linux) - Launch bot -> Log in -> Position your character wherever you like - Open script selector -> Click "Reload" -> Select "FuzzyAutoFighter" -> Click "Start"
Changelog:
- v1.0 -> Initial release.
Features:
- Selection GUI -> User can select NPCs, loot and food (Food currently not working) // -- No GUI yet -> coming soon (When Java support is added) // - GUI // -> Shows experience and tokkul gained (and average hourly rates)
Planned features:
- GUI -> Exp/loot gains with hourly rates - NPC clicking - Food support -> Food is selectable by the user (Will be fixed in next client update) - Loot support -> Looting not currently working, will fix later on
Known bugs:
- None!
Script:
import org.osbot.script.ScriptManifestimport org.osbot.script.rs2.map.Positionimport org.osbot.script.rs2.model.GroundItemimport org.osbot.script.rs2.model.Itemimport org.osbot.script.rs2.model.NPCimport javax.swing.*import java.awt.*import java.awt.event.ActionEventimport java.awt.event.ActionListener@ScriptManifest(name = "FuzzyAutoFighter", author = "Fuz", version = 1.0D, info = "Superior AIO Autofighter")public class FuzzyAutoFighter extends org.osbot.script.Script { private NPC npc; private Position npcTile; public int foodId; public ArrayList<String> npcNames = new ArrayList<String>(); public ArrayList<Integer> itemIds = new ArrayList<Integer>(); private final Filter<NPC> NPC_FILTER = new Filter<NPC>() { @Override boolean accept(NPC npc) { for (String s : npcNames) if (npc.getName().toLowerCase().contains(s.toLowerCase())) return npc.getFacing() == null; return false; } } private FighterGui gui; @Override void onStart() { gui = new FighterGui(this); } @Override int onLoop() { if (itemIds.size() < 1 || npcNames.size() < 1) return 1000; if (!client.inventory.contains(foodId)) stop(); if (!client.myPlayer.isAnimating() && (client.myPlayer.getFacing() == null || client.myPlayer.getFacing() != npc) && !client.myPlayer.isMoving()) { if ((npc = closestNPC(NPC_FILTER)) != null && !npc.isAnimating() && npc.getFacing() == null) { npcTile = npc.getPosition(); if (!selectEntityOption(npc, "Attack") && distance(npc) < 5) client.moveCameraToEntity(npc); } } return 500; } @Override void onPaint(Graphics g) { } private NPC closestNPC(Filter<NPC> f) { NPC npc = null; for (NPC n : client.localNPCs) if (n != null) if ((npc == null || distance(n) < distance(npc) && f.accept(n))) npc = n; return npc; } interface Filter<T> { public boolean accept(T element); }}class FighterGui extends JFrame { private static final int WIDTH = 180; private static final int HEIGHT = 20; FuzzyAutoFighter script; JPanel panel; JLabel npcNamesLabel; JTextField npcNames; JLabel itemIdsLabel; JTextField itemIds; JLabel foodIdLabel; JComboBox<String> foodIds; JButton startButton; public FighterGui(final FuzzyAutoFighter script) { this.script = script; setTitle("FuzzyAutoFighter"); this.setDefaultCloseOperation(HIDE_ON_CLOSE); panel = new JPanel(); setContentPane(panel); panel.setLayout(new FlowLayout()); npcNamesLabel = new JLabel("NPC names (Separate with ","):"); npcNames = new JTextField("goblin,cow"); npcNames.setPreferredSize(new Dimension(WIDTH, HEIGHT)); itemIdsLabel = new JLabel("Item IDs (Separate with ","):"); itemIds = new JTextField("996,4151"); itemIds.setPreferredSize(new Dimension(WIDTH, HEIGHT)); foodIdLabel = new JLabel("Food:"); Vector food = new Vector(); for (Item i : script.client.inventory.getItems()) { if (i != null) { String s = i.getId() + " (" + script.client.inventory.getAmount(i) + ")"; if (!food.contains(s)) food.add(s); } } final DefaultComboBoxModel model = new DefaultComboBoxModel(food); foodIds = new JComboBox<String>(model); startButton = new JButton("Apply"); startButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { String SEPARATOR = ","; if (npcNames.getText().contains(SEPARATOR)) { script.npcNames.add(npcNames.getText()); } else { for (String s : npcNames.getText().split(",")) { while (s.startsWith(" ")) s = s.substring(s.indexOf(" ")) script.npcNames.add(s); } } if (itemIds.getText().contains(SEPARATOR)) { script.itemIds.add(itemIds.getText()); } else { for (String s : itemIds.getText().split(",")) { while (s.startsWith(" ")) s = s.substring(s.indexOf(" ")) script.itemIds.add(s); } } //script.log(foodIds.getSelectedItem().toString().split(" ")[0]); script.foodId = Integer.parseInt(foodIds.getSelectedItem().toString().split(" ")[0]); setVisible(false); } }); panel.add(npcNamesLabel); panel.add(npcNames); panel.add(itemIdsLabel); panel.add(itemIds); panel.add(foodIdLabel); panel.add(foodIds); panel.add(startButton); pack(); setResizable(false); setVisible(true); }}
Please report any bugs, post proggies (1h+) if possible