Jump to content
View in the app

A better way to browse. Learn more.

OSBot :: 2007 OSRS Botting

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Computor's Auto-AFKer (for combat)

Featured Replies

Hello all, I have created (using snippets of code from other people) a bot that AFKs and eats. I'm hoping it's less-bannable than normal AIO fighters. All you have to do is input what you want to train (strictly for GUI purposes) and what food you want to eat (case-sensitive, but recognizes ALL food (not drinks)). It will alert you if there is no food in your inventory, and your health is below 50%. The bot eats food at 50% health. It's great for bandits, and red-spiders, and ankous. I will be adding a "drop collection" GUI to it soon, so it will pick up items off the ground.

 

Code:

import org.osbot.rs07.api.ui.Skill;
import org.osbot.rs07.script.Script;
import org.osbot.rs07.script.ScriptManifest;

import java.awt.*;
import java.io.IOException;
import java.net.URL;
import java.util.concurrent.TimeUnit;

import javax.imageio.ImageIO;

import java.awt.event.*;

import javax.swing.*;

@ScriptManifest(name = "AFKer", author = "Computor", version = 1.0, info = "", logo = "") 
public class AFKer extends Script {

	private long timeBegan;	
	private int xpPerHour;
	boolean test = true;


	//GUI
	botGUI g = new botGUI();
	public boolean guiWait = true;
	public String foodToEat;
	public int skillDisplay;


	private int beginningAttack;
	private int currentAttackXp;
	private int currentAttackLevel;
	private int attackXpGained;
	private double nextAttackLevelXp;
	private long timeAttackTNL;
	private double xpTillNextAttackLevel;

	private int beginningHitpoints;
	private int currentHitpointsXp;
	private int hitpointsXpGained;

	private int beginningStrength;
	private int currentStrengthXp;
	private int currentStrengthLevel;
	private int strengthXpGained;
	private double nextStrengthLevelXp;
	private long timeStrengthTNL;
	private double xpTillNextStrengthLevel;

	private int beginningDefense;
	private int currentDefenseXp;
	private int currentDefenseLevel;
	private int defenseXpGained;
	private double nextDefenseLevelXp;
	private long timeDefenseTNL;
	private double xpTillNextDefenseLevel;


	final int[] XP_TABLE =
		{
			0, 0, 83, 174, 276, 388, 512, 650, 801, 969, 1154,
			1358, 1584, 1833, 2107, 2411, 2746, 3115, 3523, 3973, 4470, 5018,
			5624, 6291, 7028, 7842, 8740, 9730, 10824, 12031, 13363, 14833,
			16456, 18247, 20224, 22406, 24815, 27473, 30408, 33648, 37224,
			41171, 45529, 50339, 55649, 61512, 67983, 75127, 83014, 91721,
			101333, 111945, 123660, 136594, 150872, 166636, 184040, 203254,
			224466, 247886, 273742, 302288, 333804, 368599, 407015, 449428,
			496254, 547953, 605032, 668051, 737627, 814445, 899257, 992895,
			1096278, 1210421, 1336443, 1475581, 1629200, 1798808, 1986068,
			2192818, 2421087, 2673114, 2951373, 3258594, 3597792, 3972294,
			4385776, 4842295, 5346332, 5902831, 6517253, 7195629, 7944614,
			8771558, 9684577, 10692629, 11805606, 13034431, 200000000
		};

	//paint background
	private final Image bg = getImage("http://s12.postimg.org/wty7h6sb1/AFKer.png");
	private final Image bg1 = getImage("http://s1.postimg.org/hoow91tdb/Untitled_1.png");

	private Image getImage(String url)
	{
		try
		{
			return ImageIO.read(new URL(url));
		}
		catch (IOException e) {}
		return null;
	}
	//end paint background

	@Override
	public void onStart() {
		//Code here will execute before the loop is started
		timeBegan = System.currentTimeMillis();
		beginningAttack = skills.getExperience(Skill.ATTACK);
		beginningHitpoints = skills.getExperience(Skill.HITPOINTS);
		beginningStrength = skills.getExperience(Skill.STRENGTH);
		beginningDefense = skills.getExperience(Skill.DEFENCE);
		timeAttackTNL = 0;
		timeStrengthTNL = 0;
		timeDefenseTNL = 0;

		g.setVisible(true);	
	}

	@Override
	public void onExit() {
		//Code here will execute after the script ends


	}

	@Override
	public int onLoop() throws InterruptedException
	{
		int currentHP = skills.getDynamic(Skill.HITPOINTS);
		final int timeToEat = skills.getStatic(Skill.HITPOINTS) / 2;

		if (currentHP <= timeToEat)
			if(foodToEat != null){
				inventory.interact("Eat", foodToEat);
				if(!inventory.contains(foodToEat)){
					Toolkit.getDefaultToolkit().beep();
				}
			}

		return random(0, 123);
	}


	@Override
	public void onPaint(Graphics2D g) {
		//This is where you will put your code for paint(s)
		//background paint
		Graphics2D gr = g;
		g.drawImage(bg, 4, 341, null);

		if (test == false){
			if(!inventory.contains(foodToEat)){
				g.drawImage(bg1, 1, 1, null);
			}
		}
		//attack
		currentAttackXp = skills.getExperience(Skill.ATTACK);
		currentAttackLevel = skills.getStatic(Skill.ATTACK);
		attackXpGained = currentAttackXp - beginningAttack;
		xpPerHour = (int)( attackXpGained / ((System.currentTimeMillis() - this.timeBegan) / 3600000.0D));
		nextAttackLevelXp = XP_TABLE[currentAttackLevel + 1];
		xpTillNextAttackLevel = nextAttackLevelXp - currentAttackXp;
		if (attackXpGained >= 1)
		{
			timeAttackTNL = (long) ((xpTillNextAttackLevel / xpPerHour) * 3600000);
		}

		if (skillDisplay == 1){
			g.drawString("" + ft(timeAttackTNL), 377, 427);
		}
		g.drawString("" + attackXpGained, 203, 427);

		//strength
		currentStrengthXp = skills.getExperience(Skill.STRENGTH);
		currentStrengthLevel = skills.getStatic(Skill.STRENGTH);
		strengthXpGained = currentStrengthXp - beginningStrength;
		xpPerHour = (int)( strengthXpGained / ((System.currentTimeMillis() - this.timeBegan) / 3600000.0D));
		nextStrengthLevelXp = XP_TABLE[currentStrengthLevel + 1];
		xpTillNextStrengthLevel = nextStrengthLevelXp - currentStrengthXp;
		if (strengthXpGained >= 1)
		{
			timeStrengthTNL = (long) ((xpTillNextStrengthLevel / xpPerHour) * 3600000);
		}

		if (skillDisplay == 2){
			g.drawString("" + ft(timeStrengthTNL), 377, 427);
		}
		g.drawString("" + strengthXpGained,220, 458);

		//Defence
		currentDefenseXp = skills.getExperience(Skill.DEFENCE);
		currentDefenseLevel = skills.getStatic(Skill.DEFENCE);
		defenseXpGained = currentDefenseXp - beginningDefense;
		xpPerHour = (int)( defenseXpGained / ((System.currentTimeMillis() - this.timeBegan) / 3600000.0D));
		nextDefenseLevelXp = XP_TABLE[currentDefenseLevel + 1];
		xpTillNextDefenseLevel = nextDefenseLevelXp - currentDefenseXp;
		if (defenseXpGained >= 1)
		{
			timeDefenseTNL = (long) ((xpTillNextDefenseLevel / xpPerHour) * 3600000);
		}

		if (skillDisplay == 3){
			g.drawString("" + ft(timeDefenseTNL), 377, 427);
		}
		g.drawString("" + defenseXpGained, 432, 401);

		//hitpoints
		currentHitpointsXp = skills.getExperience(Skill.HITPOINTS);
		hitpointsXpGained = currentHitpointsXp - beginningHitpoints;	
		g.drawString("" + hitpointsXpGained, 439, 458);

		int totalxp = attackXpGained + strengthXpGained + hitpointsXpGained + defenseXpGained;
		g.drawString("" + totalxp, 249, 401);
	}

	private String ft(long duration)
	{
		String res = "";
		long days = TimeUnit.MILLISECONDS.toDays(duration);
		long hours = TimeUnit.MILLISECONDS.toHours(duration)
				- TimeUnit.DAYS.toHours(TimeUnit.MILLISECONDS.toDays(duration));
		long minutes = TimeUnit.MILLISECONDS.toMinutes(duration)
				- TimeUnit.HOURS.toMinutes(TimeUnit.MILLISECONDS
						.toHours(duration));
		long seconds = TimeUnit.MILLISECONDS.toSeconds(duration)
				- TimeUnit.MINUTES.toSeconds(TimeUnit.MILLISECONDS
						.toMinutes(duration));
		if (days == 0)
		{
			if (minutes < 10 && seconds < 10){
				res = (hours + ":0" + minutes + ":0" + seconds);		
			}
			if (minutes < 10 && seconds >= 10){
				res = (hours + ":0" + minutes + ":" + seconds);	
			}
			if (minutes >= 10 && seconds < 10){
				res = (hours + ":" + minutes + ":0" + seconds);	
			}

			if (minutes >= 10 && seconds >= 10){
				res = (hours + ":" + minutes + ":" + seconds);
			}
		}
		if (days > 0)
		{
			if (minutes < 10 && seconds < 10){
				res = (days + ":" + hours + ":0" + minutes + ":0" + seconds);		
			}
			if (minutes < 10 && seconds >= 10){
				res = (days + ":" + hours + ":0" + minutes + ":" + seconds);	
			}
			if (minutes >= 10 && seconds < 10){
				res = (days + ":" + hours + ":" + minutes + ":0" + seconds);	
			}

			if (minutes >= 10 && seconds >= 10){
				res = (days + ":" + hours + ":" + minutes + ":" + seconds);
			}
		}
		return res;
	}





	class botGUI extends JFrame {
		public botGUI() {
			initComponents();
		}

		private void startButtonActionPerformed(ActionEvent e) {

			foodToEat = whatToEat.getText().toString();

			if (whatToAttack.getText().equalsIgnoreCase("Attack")){
				skillDisplay = 1;
			}
			if (whatToAttack.getText().equalsIgnoreCase("Strength")){
				skillDisplay = 2;
			}
			if (whatToAttack.getText().equalsIgnoreCase("Defence")){
				skillDisplay = 3;
			}

			g.dispose();
			test = false;
		}
		private void initComponents() {
			startButton = new JButton();
			label1 = new JLabel();
			whatToEat = new JTextField();
			label2 = new JLabel();
			whatToAttack = new JTextField();

			//======== this ========
			setAlwaysOnTop(true);
			setResizable(false);
			setTitle("Computor's AFKer");
			Container contentPane = getContentPane();
			contentPane.setLayout(null);

			//---- startButton ----
			startButton.setText("Start");
			startButton.addActionListener(new ActionListener() {
				@Override
				public void actionPerformed(ActionEvent e) {
					startButtonActionPerformed(e);
				}
			});
			contentPane.add(startButton);
			startButton.setBounds(87, 175, 210, 65);

			//---- label1 ----
			label1.setText("What are you going to train? (Attack, Strength, Defence)");
			contentPane.add(label1);
			label1.setBounds(new Rectangle(new Point(35, 40), label1.getPreferredSize()));
			contentPane.add(whatToEat);
			whatToEat.setBounds(35, 120, 130, whatToEat.getPreferredSize().height);

			//---- label2 ----
			label2.setText("Enter any food name here:");
			contentPane.add(label2);
			label2.setBounds(new Rectangle(new Point(35, 100), label2.getPreferredSize()));
			contentPane.add(whatToAttack);
			whatToAttack.setBounds(35, 60, 140, 20);

			contentPane.setPreferredSize(new Dimension(400, 300));
			pack();
			setLocationRelativeTo(getOwner());
		}


		private JButton startButton;
		private JLabel label1;
		private JTextField whatToEat;
		private JLabel label2;
		private JTextField whatToAttack;
	}


}

Screen shots (submit your own proggies):

 

AFKer.png

gui.png

 

File download:

https://mega.co.nz/#!B1cghSyL!zhStG_InfUFR5TrPmTs89b4xrbtUF2e5z7mP2xh_MgI

File Scan:

https://www.virustotal.com/en/file/13cdc3d912b7a50371a0ad2744b8f36067da817b9404f595e9ed0cbd0d0c66a6/analysis/1418607684/

Instead of: 

        nextAttackLevelXp = XP_TABLE[currentAttackLevel + 1];
        xpTillNextAttackLevel = nextAttackLevelXp - currentAttackXp;

You could do:

 

       xpTillNextAttackLevel = skills.experienceToLevel(Skill.ATTACK);

Edited by Molly

  • Author

You just go out of bounds and come back in again. It's a very simple bot, eats + displays a paint. It's not going to fight things, move, walk. It keeps you logged in, warns you if you're out of food, makes noises if you're out of food and at low health, and has a paint. No more, no less.


Thank you Molly, you just saved me a lot of space :P

  • 2 weeks later...

Thankyou so much for creating this. I lost a fire cape at giant spiders while playing xbox :'(
 

  • 4 weeks later...
  • 3 weeks later...

If you had one like this but for prayer pots it would be so useful for 1 def pures at bandits and such... Also Because it keeps you 'logged in' can you use while splashing so you never get the auto log after 6 hours? :s

  • 2 weeks later...
  • Author

If you had one like this but for prayer pots it would be so useful for 1 def pures at bandits and such... Also Because it keeps you 'logged in' can you use while splashing so you never get the auto log after 6 hours? :s

Change this:

if (currentHP <= timeToEat)
			if(foodToEat != null){
				inventory.interact("Eat", foodToEat);
				if(!inventory.contains(foodToEat)){
					Toolkit.getDefaultToolkit().beep();
				}
			}

 

To this:
if (currentHP <= timeToEat)
			if(foodToEat != null){
				inventory.interact("Drink", foodToEat);
				if(!inventory.contains(foodToEat)){
					Toolkit.getDefaultToolkit().beep();
				}
			}

 
And put "Prayer potion(4)" in the GUI.

10/10 would use if IP wasn't flagged lol :doge: 


  • 3 weeks later...

looks good will use in futere

no u won't.......... get it cos u banned. roflcopters420

  • 1 month later...
Item food = inventory.getItem(new Filter<Item>() {
    public boolean match(Item item) {
        return item != null && Arrays.asList(item.getActions()).contains("Eat");
    }
});

Easier way to eat any food, because wont have to enter food name. It will eat anything that contains the action "Eat", which in almost all cases is food.

Create an account or sign in to comment

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.