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.

Finished a Cow Killer

Featured Replies

Just finished my first script and was looking for some constructive criticism from people with more experience if thats alright. Simple script that farms cows for xp in Falador, simple antiban, randomised run times, basic GUI.

 

Code:

import org.osbot.rs07.api.filter.Filter;
import org.osbot.rs07.api.map.Area;
import org.osbot.rs07.api.model.NPC;
import org.osbot.rs07.api.ui.Skill;
import org.osbot.rs07.script.Script;
import org.osbot.rs07.script.ScriptManifest;
import org.osbot.rs07.utility.ConditionalSleep;
import java.awt.Graphics2D;

@ScriptManifest(name = "Cow Killer", author = "Tanks", version = 1.0, info = "Farms Cows at Falador Farm", logo = "") 
public class TanksCowKiller extends Script {
	
	private final Area cowField = new Area(3043,3313,3021,3298);
	private long startTime;
	private int startRun;

	@SuppressWarnings("unchecked")
	private NPC getTarget(){
		NPC targetCow = npcs.closest(new Filter<NPC>(){
			public boolean match(NPC theCow){
				return theCow != null && (theCow.getName().equals("Cow") || theCow.getName().equals("Cow calf")) && 
						theCow.isAttackable() && cowField.contains(theCow);
			}
		});
    	return targetCow;
    }
	
	public void AntiBan() throws InterruptedException {
		log("Antiban Triggered ...");
		switch(random(1,7)){
			case 1:
				mouse.moveOutsideScreen();
				sleep(random(5000,12000));
				break;
			case 2:
				mouse.moveSlightly();
				break;
			case 3:
				mouse.moveVerySlightly();
				break;
			case 4:
				skills.open();
				mouse.move(random(554,603),random(211,230)); //check attack xp
				sleep(random(2000,4000));
				mouse.click(random(632,653), random(176,196), false);
				break;
			case 5:
				skills.open();
				mouse.move(random(554,603),random(240,264)); //check strength xp
				sleep(random(2000,4000));
				mouse.click(random(632,653), random(176,196), false);
				break;
			case 6:
				skills.open();
				mouse.move(random(554,603),random(274,294)); //check defence xp
				sleep(random(2000,4000));
				mouse.click(random(632,653), random(176,196), false);
				break;
			case 7:
				skills.open();
				mouse.move(random(616,667),random(212,231)); //check hp xp
				sleep(random(2000,4000));
				mouse.click(random(632,653), random(176,196), false);
				break;
		}
	}
	
	public void startRunning(){
		
		settings.setRunning(true);
		this.startRun = random(60,100);
		
	}
	
    @[member=Override]
    public void onStart() {
    	
    	startTime = System.currentTimeMillis();
    	
    	for(final Skill skill : new Skill[]{Skill.ATTACK, Skill.STRENGTH, Skill.DEFENCE, Skill.HITPOINTS}) {
    	    getExperienceTracker().start(skill);
    	    
    	}
    }

    @[member=Override]
    public int onLoop() throws InterruptedException{
    	
    		NPC cowToKill = getTarget();
    		
    		if(cowToKill != null && !cowToKill.isOnScreen())
    			camera.toEntity(cowToKill);
    		
    		if(cowToKill != null) //another null check in case the cow died before we could attack
    			cowToKill.interact("Attack");
    			sleep(random(2000,3500));
    		
    		int rand = random(1,30);
    		if(rand == 1)
    			AntiBan();
    		
    		int failSafe = random(5,10);
    		int failCount = 0;
    		while(myPlayer().isInteracting(cowToKill) && failCount < failSafe){
    			new ConditionalSleep(4000) {
    				@ Override
    				public boolean condition() throws InterruptedException {
    					return  (myPlayer().isMoving() && !cowToKill.isUnderAttack()) && myPlayer().isUnderAttack() && cowToKill.isInteracting(myPlayer());
    				}
    			}.sleep();
    			
    			failCount++;
    		}
    		
    		if(settings.getRunEnergy() > this.startRun && !settings.isRunning())
    			startRunning();
    			
        return 100;
        
    }
    
    @[member=Override]
    public void onExit() {

    }
    
    //method taken from Explv's paint tutorial -> osbot.org/forum/topic/87697-explvs-dank-paint-tutorial/
    public final String formatTime(final long ms){
    	
        long s = ms / 1000, m = s / 60, h = m / 60;
        s %= 60; m %= 60; h %= 24;
        return String.format("%02d:%02d:%02d", h, m, s);
        
    }

	@[member=Override]
    public void onPaint(Graphics2D g) {
    	
    	double attackXP = getExperienceTracker().getGainedXP(Skill.ATTACK);
    	double strengthXP = getExperienceTracker().getGainedXP(Skill.STRENGTH);
    	double defenceXP = getExperienceTracker().getGainedXP(Skill.DEFENCE);
    	double hitpointsXP = getExperienceTracker().getGainedXP(Skill.HITPOINTS);
    	int attackLvls = getExperienceTracker().getGainedLevels(Skill.ATTACK);
    	int strengthLvls = getExperienceTracker().getGainedLevels(Skill.STRENGTH);
    	int defenceLvls = getExperienceTracker().getGainedLevels(Skill.DEFENCE);
    	int hitpointsLvls = getExperienceTracker().getGainedLevels(Skill.HITPOINTS);
    	
    	g.drawString("Attack XP gained: " + attackXP, 25, 100);
    	g.drawString("Strength XP gained: " + strengthXP, 25, 120);
    	g.drawString("Defence XP gained: " + defenceXP, 25, 140);
    	g.drawString("HP XP gained: " + hitpointsXP, 25, 160);
    	g.drawString("---", 25, 180);
    	g.drawString("Attack Lvls gained: " + attackLvls, 25, 200);
    	g.drawString("Strength Lvls gained: " + strengthLvls, 25, 220);
    	g.drawString("Defence Lvls gained: " + defenceLvls, 25, 240);
    	g.drawString("HP Lvls gained: " + hitpointsLvls, 25, 260);
    	g.drawString("---", 25, 280);
    	g.drawString("Runtime: " + formatTime((System.currentTimeMillis() - startTime)), 25, 300);

    }


}

Thanks

Nice, GZ on your first script :)

1) You should use accessor methods (getter and setter) instead of public fields. 

Eg:
- getMouse().moveOutsideScreen() instead of mouse.moveOutsideScreen()
- getSettings().setRunning(true) instead of settings.setRunning(true)

2) You should use Conditional Sleep instead of static sleep.

mouse.moveOutsideScreen();
sleep(random(5000,12000));

Currently, after moving your mouse off-screen, your script will always sleep from 5 to 12 seconds.

getMouse.moveOutsideScreen();
new ConditionalSleep(5000) {
    @[member=Override]
        public boolean condition() throws InterruptedException {
	    return !getMouse().isOnScreen();
        }
}.sleep();

Using a Conditional Sleep, your script will only sleep until your mouse is off-screen or the timeout is reached. You can check more about this here: https://webcache.googleusercontent.com/search?q=cache:http://osbot.org/api/org/osbot/rs07/utility/ConditionalSleep.html

3) What is anti-ban your opinion? If your user want his account to stay at 1 defence, should your script still check his defence experience?

if(cowToKill != null && !cowToKill.isOnScreen())
    camera.toEntity(cowToKill);

Currently, in your script, your player will always attack the closest cow and if your target isn't visible on screen, it will rotate the camera. Doesn't a non-bot player attacks what is visible for him instead of rotating the camera before attacking a monster? (PS: IIRC @Krulvis already addressed that in the past but I couldn't find his post)
If you want to do this, you need to remove the code above and modify your script to:

@SuppressWarnings("unchecked")
private NPC getTarget(){
    NPC targetCow = getNpcs().closest(new Filter<NPC>(){
        public boolean match(NPC theCow){
            return theCow != null && (theCow.getName().equals("Cow")
                                   || theCow.getName().equals("Cow calf")
         			   && theCow.isAttackable() 
                                   && theCow.isVisible());
	}
    });
    return targetCow;
}

4) Visually speaking, you can reduce your paint to:

g.drawString("Attack XP gained: " + attackXP + " - Attack Lvls gained: " + attackLvls, 25, 200);
case 4:
				skills.open();
				mouse.move(random(554,603),random(211,230)); //check attack xp
				sleep(random(2000,4000));
				mouse.click(random(632,653), random(176,196), false); 

I'll offer some constructive criticism. With the code you have here, you aren't checking if the skills tab is open so if it fails, it'll just proceed to hovering over the wrong tab. Also you could use the API settings to hover over a skill.

 

But overall antiban is pretty useless to add to a script. It is just slowing it down.

 

Also, you said you have a GUI but I don't see one lol

 

Try to make your return value random for your loop so its not always clicking at the same value. 

If you have any questions, don't be afraid to ask smile.png

Edited by Juggles

  • Author

 

1) You should use accessor methods (getter and setter) instead of public fields. 

Eg:
- getMouse().moveOutsideScreen() instead of mouse.moveOutsideScreen()
- getSettings().setRunning(true) instead of settings.setRunning(true)

2) You should use Conditional Sleep instead of static sleep.

mouse.moveOutsideScreen();
sleep(random(5000,12000));

Currently, after moving your mouse off-screen, your script will always sleep from 5 to 12 seconds.

getMouse.moveOutsideScreen();
new ConditionalSleep(5000) {
    @[member='Override']
        public boolean condition() throws InterruptedException {
	    return !getMouse().isOnScreen();
        }
}.sleep();

Using a Conditional Sleep, your script will only sleep until your mouse is off-screen or the timeout is reached. You can check more about this here: https://webcache.googleusercontent.com/search?q=cache:http://osbot.org/api/org/osbot/rs07/utility/ConditionalSleep.html

3) What is anti-ban your opinion? If your user want his account to stay at 1 defence, should your script still check his defence experience?

if(cowToKill != null && !cowToKill.isOnScreen())
    camera.toEntity(cowToKill);

Currently, in your script, your player will always attack the closest cow and if your target isn't visible on screen, it will rotate the camera. Doesn't a non-bot player attacks what is visible for him instead of rotating the camera before attacking a monster? (PS: IIRC @Krulvis already addressed that in the past but I couldn't find his post)

If you want to do this, you need to remove the code above and modify your script to:

@SuppressWarnings("unchecked")
private NPC getTarget(){
    NPC targetCow = getNpcs().closest(new Filter<NPC>(){
        public boolean match(NPC theCow){
            return theCow != null && (theCow.getName().equals("Cow")
                                   || theCow.getName().equals("Cow calf")
         			   && theCow.isAttackable() 
                                   && theCow.isVisible());
	}
    });
    return targetCow;
}

4) Visually speaking, you can reduce your paint to:

g.drawString("Attack XP gained: " + attackXP + " - Attack Lvls gained: " + attackLvls, 25, 200);

great feedback. Ill modify it now to what you've said. thanks man :)

case 4:
				skills.open();
				mouse.move(random(554,603),random(211,230)); //check attack xp
				sleep(random(2000,4000));
				mouse.click(random(632,653), random(176,196), false); 

I'll offer some constructive criticism. With the code you have here, you aren't checking if the skills tab is open so if it fails, it'll just proceed to hovering over the wrong tab. Also you could use the API settings to hover over a skill.

 

But overall antiban is pretty useless to add to a script. It is just slowing it down.

 

Also, you said you have a GUI but I don't see one lol

 

Try to make your return value random for your loop so its not always clicking at the same value. 

If you have any questions, don't be afraid to ask smile.png

 

Hadn't thought of that thanks a lot I'll change it now. For the antiban part however how come its useless to add? I know its really basic and not a wide variety of different operations to perform, but could it not possibly help reduce the bot detection if it has these added features? thanks for the feedback man :) 

great feedback. Ill modify it now to what you've said. thanks man smile.png

Hadn't thought of that thanks a lot I'll change it now. For the antiban part however how come its useless to add? I know its really basic and not a wide variety of different operations to perform, but could it not possibly help reduce the bot detection if it has these added features? thanks for the feedback man smile.png

Read #4 on here made by @@Alek

http://osbot.org/forum/topic/45618-preventing-rs-botting-bans/page-1

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.