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.

How to have bot pick up birdsnare after a bird has been caught/it fell over

Featured Replies

Reading through the api right now trying to understand it, but I'm still learning it. How would I make my bot fix a broken bird snare, or take a bird from one if it gets caught. Also, how would I keep my bot in a certain area so it doesn't wander off? Like I said i'm still trying to read the api but theres a bunch there to learn. Is there a getState for ground items? or something like that?

Edited by twin 763

Well seeming that the above poster didnt seem to help ya much ill do my best to walk you through it without code cause I havent coded for Osbot in while so here is how itd work. First you should make a new class, I designed this one for you if you dont like it trash it do whatever thats your choice.

import java.util.ArrayList;

class Trap {
	private static ArrayList<Trap> traps = new ArrayList<Trap>();
	private int x;
	private int y;
	private int id;
	private Entity trap;
	
	public Trap(int x, int y, int id, Entity trap){
		this.x = x;
		this.y = y;
		this.id = id;
		this.trap = trap;
                traps.add(trap);
	}
	
	public boolean trapFell(){
		return trap.getId() != id;
	}
}

This may work it may not. You may have to change it. But aslong as when the trap falls, its id changes than it will return that it fell. If the ID doesnt change when it falls, replace the id information in the trap class to information about the model, than check againist the model and see. For added failsafe, make sure the trap you are checking is corresponding to the trap with the x, y your working with. The trap class is not complete, you would have to add a setter nd getter for the cord aswell. Good luck man

Edited by boyyo11

If you haven't already, feel free to check out my scripting tutorial which outlines the very basics.

http://osbot.org/forum/topic/58775-a-beginners-guide-to-writing-osbot-scripts-where-to-get-started-by-apaec/

 

Firstly, to stop your bot leaving an area, we first have to define the area in question:

 

at the top of your script where you define all your variables, 

Area HUNTING_AREA = new Area(0,0,0,0);
// instead of 0,0,0,0, write the top right and bottom left coords in the format
// (Top right X, Top right Y, Bottom left X, Bottom left y);

Then, after defining your area, you need to check if the players in it. In this scenario, we want to make sure the player is not out of the area. We can do this by dropping a check at the top of the onLoop:

if (!HUNTING_AREA.contains(myPlayer())) { //if you're not standing in the hunting area
    log("Returning to Hunting Area");
    localWalker.walk(HUNTING_AREA.getRandomPosition(0)); //Walks into hunting area
}

In light to your other question about the bird traps, you first need to find out what changes when you catch a bird. I.e, does the name change? do the actions change? does a single action change? Does the id change  (this is a last resort) ?

 

Once you figure out what changes, let me know and we can figure things out from there.

 

As for a fallen over trap, at the top of your onloop, just put:

GroundItem fallenSnare = groundItems.closest("Snare"); //whatever the name is, and may have called this wrong
if (fallenSnare != null && fallenSnare.exists()) {
    fallenSnare.interact("Take");
    sleep(500);
}

Any other problems, just let me know. Oh yea and i wrote the code all in the reply box so forgive me if I made any typos / mistakes

 

Apaec

  • Author

If you haven't already, feel free to check out my scripting tutorial which outlines the very basics.

http://osbot.org/forum/topic/58775-a-beginners-guide-to-writing-osbot-scripts-where-to-get-started-by-apaec/

 

Firstly, to stop your bot leaving an area, we first have to define the area in question:

 

at the top of your script where you define all your variables, 

Area HUNTING_AREA = new Area(0,0,0,0);
// instead of 0,0,0,0, write the top right and bottom left coords in the format
// (Top right X, Top right Y, Bottom left X, Bottom left y);

Then, after defining your area, you need to check if the players in it. In this scenario, we want to make sure the player is not out of the area. We can do this by dropping a check at the top of the onLoop:

if (!HUNTING_AREA.contains(myPlayer())) { //if you're not standing in the hunting area
    log("Returning to Hunting Area");
    localWalker.walk(HUNTING_AREA.getRandomPosition(0)); //Walks into hunting area
}

In light to your other question about the bird traps, you first need to find out what changes when you catch a bird. I.e, does the name change? do the actions change? does a single action change? Does the id change  (this is a last resort) ?

 

Once you figure out what changes, let me know and we can figure things out from there.

 

As for a fallen over trap, at the top of your onloop, just put:

GroundItem fallenSnare = groundItems.closest("Snare"); //whatever the name is, and may have called this wrong
if (fallenSnare != null && fallenSnare.exists()) {
    fallenSnare.interact("Take");
    sleep(500);
}

Any other problems, just let me know. Oh yea and i wrote the code all in the reply box so forgive me if I made any typos / mistakes

 

Apaec

 

Thank you for this! Defiantly helped a lot since i'm still new with java, only about 6 months experience. I didn't even have any idea where to look in the api to find some of this since there's a lot there. Let me see if I can use this to get something basic out(just functionally, really) and I'll get back to you! thanks again =)

Well seeming that the above poster didnt seem to help ya much ill do my best to walk you through it without code cause I havent coded for Osbot in while so here is how itd work. First you should make a new class, I designed this one for you if you dont like it trash it do whatever thats your choice.

import java.util.ArrayList;

class Trap {
	private static ArrayList<Trap> traps = new ArrayList<Trap>();
	private int x;
	private int y;
	private int id;
	private Entity trap;
	
	public Trap(int x, int y, int id, Entity trap){
		this.x = x;
		this.y = y;
		this.id = id;
		this.trap = trap;
                traps.add(trap);
	}
	
	public boolean trapFell(){
		return trap.getId() != id;
	}
}

This may work it may not. You may have to change it. But aslong as when the trap falls, its id changes than it will return that it fell. If the ID doesnt change when it falls, replace the id information in the trap class to information about the model, than check againist the model and see. For added failsafe, make sure the trap you are checking is corresponding to the trap with the x, y your working with. The trap class is not complete, you would have to add a setter nd getter for the cord aswell. Good luck man

 

I'm confused with this. Would I have to make another class with my project then make the snare object?Also, I never really thought arrays were useful so thanks for proving me wrong lol

  • 3 weeks later...
  • Author

did not mean to post here.

Edited by twin 763

  • 1 month later...

Yes you would, that would be the trap class, just holds information about your traps you have placed so you can continously work with all of them in ease.

  • Author

Yes you would, that would be the trap class, just holds information about your traps you have placed so you can continously work with all of them in ease.

 

I get the class now tongue.png I knew like nothing a month ago lol

  • Author

If you haven't already, feel free to check out my scripting tutorial which outlines the very basics.

http://osbot.org/forum/topic/58775-a-beginners-guide-to-writing-osbot-scripts-where-to-get-started-by-apaec/

 

Firstly, to stop your bot leaving an area, we first have to define the area in question:

 

at the top of your script where you define all your variables, 

Area HUNTING_AREA = new Area(0,0,0,0);
// instead of 0,0,0,0, write the top right and bottom left coords in the format
// (Top right X, Top right Y, Bottom left X, Bottom left y);

Then, after defining your area, you need to check if the players in it. In this scenario, we want to make sure the player is not out of the area. We can do this by dropping a check at the top of the onLoop:

if (!HUNTING_AREA.contains(myPlayer())) { //if you're not standing in the hunting area
    log("Returning to Hunting Area");
    localWalker.walk(HUNTING_AREA.getRandomPosition(0)); //Walks into hunting area
}

In light to your other question about the bird traps, you first need to find out what changes when you catch a bird. I.e, does the name change? do the actions change? does a single action change? Does the id change  (this is a last resort) ?

 

Once you figure out what changes, let me know and we can figure things out from there.

 

As for a fallen over trap, at the top of your onloop, just put:

GroundItem fallenSnare = groundItems.closest("Snare"); //whatever the name is, and may have called this wrong
if (fallenSnare != null && fallenSnare.exists()) {
    fallenSnare.interact("Take");
    sleep(500);
}

Any other problems, just let me know. Oh yea and i wrote the code all in the reply box so forgive me if I made any typos / mistakes

 

Apaec

 

Thanks buddy tongue.png

 

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.