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.

Bot only uses these tiles to fish?

Featured Replies

So I've tried a few methods and getting the bot to fish from all spots in aerial fishing but it only goes for the ones that shows up in the black line closest to the character doesn't fish any of the ones located in the red line or any off the ones further out than the red line but the bird can reach, think it may be a problem with the closest function.

bot-only-uses-these-tiles.jpg

the code I have that runs in the best at the moment is

if(!inventory.isFull()) {

NPC Fishspot = npcs.closest("Fishing spot");

Fishspot.interact("Catch");

sleep(random(1000,4000));

}

but would rather allow it to fish from all of the fishing spots.

(Also the paint doesn't always seem to load each time I start the script, sometimes it does sometimes it doesn't, working on getting a better paint made but that's it for now.)

Edited by Jueix

Well, your Fishspot is grabbing the closest fishing spot (npcs.closest), which means it will keep targetting the nearest npc to your player's tile, so it won't be targetting the far away ones when there are fishing spots more closer.

Try: 

	NPC Fishspot = getNpcs().getAll().stream().filter(a -> a.getName().equalsIgnoreCase("Fishing spot")).findAny().orElseGet(() -> getNpcs().closest("Fishing spot"));
	

What is different?

This is grabbing all fishing spots in the area, and choosing any (findAny), instead of choosing closest. If it fails and none are found, it will resort to finding the closest one. This makes use of streams, otherwise the code would be much longer.

You're absolutely right about what the problem is. You've got two solutions:

  1. Write your own function that finds the farthest NPCs you're after, or...
  2. Write your own function that filters out NPCs within a defined Area.

@Czar idea would work, however I think a better solution would be to simply order the list by distance in descending order and return the first result:

	public NPC getFarthestNPC(String name) {
		return npcs.getAll().stream()
				.filter(npc -> name.equals(npc.getName()))
				.sorted((npc1, npc2) -> {
					double distToNpc1 = map.distance(npc1);
					double distToNpc2 = map.distance(npc2);
					return Double.compare(distToNpc2, distToNpc1);
				})
				.findFirst()
				.orElse(null);
	}

Then you can do:

NPC cow = getFarthestNPC("Cow");

However, just always remember this will return the farthest NPC irrespective of whether or not you can reach it. It'll work fine if you don't need to physically reach a tile, but should you need to then you can tweak around with the code to include filtering for distance/real distance, by areas, etc.

:edit:

I have just realised that you WILL need to cache the farthest NPC and re-use and re-check it until it stops existing. Why? Because if you keep trying to find the farthest fishing spot, then your in-game player will be running about like a mong. :)

 

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.