Jump to content

Rare scripts

Scripter I
  • Posts

    246
  • Joined

  • Last visited

  • Feedback

    98.1%

Posts posted by Rare scripts

  1. 7b1c227d0198a9614ae33d44c24d784b.png

    Thanks for visiting my thread! :)

    You can contact me over OSBot PM or Skype :)

    Skype: rare-scripts

    Discord: rare scripts#8548 (If it doesn't work, try without space)

    if you add me to Skype: please make sure you ask to verrify by sending a PM on OSBot before giving out any info/payment!

    Note: Let me know you are from OSBot when adding me, thanks :)

    Payment method:

    • 07GP/BTC/ETH

    TOS:

    • You are NOT allowed to re-sell my scripts.
    • If i'm unable to finish the request, a 100% refund will be given to the customer.
    • I'm not responsible for any bans and/or account loss.
    • I will send you the .jar file, please backup the file - If you lose it, i can't recover the script for you.
       
    • Like 1
  2. 9 hours ago, D Bolter said:

    Thanks for sharing! Would you mind pasting the source code so I can learn from it? :D

     

    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 :)

    • Like 1
  3. 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.

    • Like 1
  4. Hello! ?

    New here &  bad at introductions :)

    I wanted to learn some more about java and GUI's so why not give Osbot a try?

    Hoping to release some scripts & getting to know the community :)

    - Rare
     

×
×
  • Create New...