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.

take far away item

Featured Replies

im using this wilderness looting script that takes items from the ground. it works pretty well except when it finds an item that is so far away or behind a hill so that the take menu is not available and it just gets stuck. how would i fix this to walk towards the item if it is too far away? or at least ignore if it cant actually be picked up.

for(int i = 0;i<P2PLoot.length;i++){
    for(GroundItem g: groundItems.getAll()){
        if(g.getName().equals(P2PLoot[i])&&g !=null){
            if(inventory.isFull()||skills.getDynamic(Skill.HITPOINTS)<=6||myPlayer().isUnderAttack()){
                break;
            }
            log("found item!"+ P2PLoot[i]);
            GroundItem a=  groundItems.closest(P2PLoot[i]);
            a.interact("Take");
            sleep(300);
            do{
                sleep(200);
            }while(myPlayer().isAnimating());

            breaker = true;
            break;
        }
    }

 

if item distance < x

loot

else

walk to item

WalkCondition should break on distance threshold being met

this snippet may be helpful:

public GroundItem getTokkul() {
    Filter<GroundItem> b = item -> (item.getName().contains("Tokkul") && item.getAmount() > tokkulloot && getMap().realDistance(item) < 7 );
    GroundItem tokkul = getGroundItems().closest(b);
    return tokkul;
}

I.e this only returns the tokkul is there if you could also add a getMap().canReach(item), this means if you can't reach it it won't return as true

getMap().realDistance(item) < 7

 

 if(g.getName().equals(P2PLoot[i])&&g !=null){

change to:

 if(g.getName().equals(P2PLoot[i])&&g !=null && getMap().canReach(g) && getMap().realDistance(g) < ARBITRARY NUMBER say 7){

Then if you wanted you can do if your g = null (so you prioritise looting stuff nearer to your character) walk to items further away and loot them

When sleeping - your using static sleeps: Below is a way of randomising that sleep time - just makes it a tad less botlike

try{
    sleep(random(300,600));
}
catch(Exception e){

}

You can test whether the tile is reachable, which can found here.

You should definitely separate out your logic, because you're looking for items and, whilst in the midst of doing that, are re-checking whether you're in danger. You don't/shouldn't do that. You should check whether you're in danger first then find those items:

IF IN DANGER
    GO AND RECOVER
ELSE IF FOUND ITEMS
    LOOT ITEMS
ELSE
    WAIT FOR ITEMS

I'm not going to write your entire script, but I will help you find items:

private boolean isGroundItemSomethingWeWant(GroundItem item) {
	boolean yes = false;
	String itemName = item.getName();
	for (String name : P2PLoot) {
		if (itemName.equals(name)) {
			yes = true;
			break;
		}
	}
	return yes;
}

Then you can do this:

List<GroundItem> items = groundItems.getAll().stream()
			.filter(this::isGroundItemSomethingWeWant)
			.filter(map::canReach)
			.collect(Collectors.toList());

 

Edited by liverare

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.