Rare scripts Posted August 19, 2018 Share Posted August 19, 2018 Simple but does the trick! Did not see one around and had to make one real quick, so why not share it? -Start @ Canifis bank or ghouls, Pick food from the GUI. Enjoy! -Rare. GhoulKiller.jar 1 Quote Link to comment Share on other sites More sharing options...
Alek Posted August 19, 2018 Share Posted August 19, 2018 Because you can use any generic combat script to kill them. In the future, use Widgets closeOpenInterface() instead of the method you wrote; it handles more interfaces. Seems like a good start though. 1 Quote Link to comment Share on other sites More sharing options...
Rare scripts Posted August 19, 2018 Author Share Posted August 19, 2018 Just now, Alek said: Because you can use any generic combat script to kill them. In the future, use Widgets closeOpenInterface() instead of the method you wrote; it handles more interfaces. Seems like a good start though. Thanks! I will update this first thing in the morning -Rare. 1 Quote Link to comment Share on other sites More sharing options...
D Bolter Posted August 19, 2018 Share Posted August 19, 2018 1 hour ago, Rare scripts said: Simple but does the trick! Did not see one around and had to make one real quick, so why not share it? -Start @ Canifis bank or ghouls, Pick food from the GUI. Enjoy! -Rare. GhoulKiller.jar Thanks for sharing! Would you mind pasting the source code so I can learn from it? 1 Quote Link to comment Share on other sites More sharing options...
Rare scripts Posted August 19, 2018 Author Share Posted August 19, 2018 9 hours ago, D Bolter said: Thanks for sharing! Would you mind pasting the source code so I can learn from it? import java.awt.Color; import java.awt.Graphics2D; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.util.function.BooleanSupplier; import javax.swing.DefaultComboBoxModel; import javax.swing.JButton; import javax.swing.JComboBox; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JTextField; import org.osbot.rs07.api.map.Area; import org.osbot.rs07.api.map.Position; import org.osbot.rs07.api.model.NPC; import org.osbot.rs07.api.ui.Message; import org.osbot.rs07.script.Script; import org.osbot.rs07.script.ScriptManifest; import org.osbot.rs07.utility.ConditionalSleep; @ScriptManifest(author = "Rare Scripts", name = "Ghoul killer", info = "Start in bank or @ Ghouls", version = 1, logo = "") public final class GhoulKiller extends Script { public final Area GhoulArea = new Area(3425, 3467, 3438, 3457); public final Area BankArea = new Area(3509, 3483, 3513, 3476); String CurrentState, FoodName; private long startTime; private MouseTrail trail = new MouseTrail(0, 255, 255, 2000, this); private MouseCursor cursor = new MouseCursor(52, 4, Color.red, this); public Boolean finishedGUI = false; private JPanel ScriptName; private JTextField textField; int eatOn; public void JFrame() { JFrame ScriptName; ScriptName = new JFrame(); ScriptName.setTitle("Rare Ghoul killer"); ScriptName.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); ScriptName.setBounds(100, 100, 406, 155); ScriptName.getContentPane(); ScriptName.setLayout(null); JComboBox comboBox = new JComboBox(); comboBox.setModel(new DefaultComboBoxModel(new String[] {"- Food -", "Trout", "Salmon", "Lobster"})); comboBox.setBounds(10, 11, 100, 20); ScriptName.add(comboBox); JLabel lblEatOn = new JLabel("Eat on:"); lblEatOn.setBounds(10, 42, 35, 14); ScriptName.add(lblEatOn); textField = new JTextField(); textField.setText("56"); textField.setBounds(55, 39, 22, 20); ScriptName.add(textField); textField.setColumns(10); JLabel label = new JLabel("%"); label.setBounds(83, 42, 11, 14); ScriptName.add(label); JButton btnNewButton = new JButton("Start"); btnNewButton.setBounds(10, 114, 100, 23); ScriptName.add(btnNewButton); ScriptName.getContentPane().add(btnNewButton); ScriptName.setVisible(true); btnNewButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { // TODO Auto-generated method stub ScriptName.setVisible(false); ScriptName.dispose(); FoodName = comboBox.getSelectedItem().toString(); eatOn = Integer.parseInt(textField.getText()); finishedGUI = true; } }); } @Override public final void onStart() { CurrentState = "Starting script..."; startTime = System.currentTimeMillis(); JFrame(); } public void TerminateScript(String reason) { log("[Terminate - Reason]: "+reason); widgets.closeOpenInterface(); stop(); } public boolean needEating() { return myPlayer().getHealthPercent() < eatOn; } public void EatFood() { if (getInventory().contains(FoodName)) { int oldHealth = myPlayer().getHealthPercent(); if (getInventory().getItem(FoodName).interact("Eat")) { Sleep.sleepUntil(() -> myPlayer().getHealthPercent() > oldHealth, 5000); } } } public void FightMonster(String name) { if (needEating()) { return; } if (myPlayer().isUnderAttack()) { Sleep.sleepUntil(() -> !myPlayer().isUnderAttack() || needEating(), 85000); return; } NPC theNpc = getNpcs().closest(name); if (theNpc != null && map.canReach(theNpc) && theNpc.isAttackable()) { if (theNpc.isVisible()) { if (!myPlayer().isUnderAttack() && !theNpc.isUnderAttack() && theNpc.hasAction("Attack")) { if (theNpc.interact("Attack")) { Sleep.sleepUntil(() -> myPlayer().isUnderAttack() || !theNpc.exists(), 9000); Sleep.sleepUntil(() -> !theNpc.exists() || !myPlayer().isUnderAttack() || needEating(), 85000); } } } else { if (map.isWithinRange(theNpc, 8)) { getCamera().toPosition(theNpc.getPosition()); } else { getWalking().webWalk(theNpc.getPosition()); } } } } public void WithdrawItem(String name, int amount, boolean StopNotFound) { if (getBank().contains(name)) { getBank().withdraw(name, amount); } else { if (StopNotFound == true) { getBank().close(); Sleep.sleepUntil(() -> !getBank().isOpen(), 9000); TerminateScript("No "+name+" found in bank"); } } } public void HandleBank() throws InterruptedException { if (getBank().isOpen()) { getBank().depositAll(); WithdrawItem(FoodName, -1, true); getBank().close(); Sleep.sleepUntil(() -> !getBank().isOpen() && getInventory().contains(FoodName), 9000); } else { getBank().open(); } } @Override public final int onLoop() throws InterruptedException { if (finishedGUI == true) { if (getInventory().contains(FoodName)) { if (GhoulArea.contains(myPlayer())) { if (needEating()) { CurrentState = "Eating "+FoodName+"..."; EatFood(); } else { CurrentState = "Fighting..."; FightMonster("Ghoul"); } } else { CurrentState = "Running to Ghouls..."; getWalking().webWalk(GhoulArea); } } else { if (BankArea.contains(myPlayer())) { CurrentState = "Banking..."; HandleBank(); } else { CurrentState = "Running to Bank..."; getWalking().webWalk(BankArea); } } } return random(50, 500); } @Override public final void onExit() { log("Script terminated! :)"); ScriptName.setVisible(false); } @Override public final void onMessage(final Message message) { //log("New msg: " + message.getMessage()); } @Override public void onPaint(final Graphics2D g) { trail.paint(g); cursor.paint(g); g.drawString("Rare Ghoul killer", 12, 130); g.drawString("Time running: "+formatTime(System.currentTimeMillis() - startTime), 12, 150); g.drawString("State: "+CurrentState, 12, 170); } public final String formatTime(final long ms) { long s = ms / 1000, m = s / 60, h = m / 60, d = h / 24; s %= 60; m %= 60; h %= 24; return d > 0 ? String.format("%02d:%02d:%02d:%02d", d, h, m, s) : h > 0 ? String.format("%02d:%02d:%02d", h, m, s) : String.format("%02d:%02d", m, s); } } If u have any questions feel free to shoot me a PM 1 Quote Link to comment Share on other sites More sharing options...
Holysmokess Posted August 23, 2018 Share Posted August 23, 2018 it doesnt work for me, i start it and the gui pops up i pick lobsters as food but theres no "okay" or "submit" button. it just says "state: starting script" and nothing happens and if i close the gui it closes osbot Quote Link to comment Share on other sites More sharing options...