Jump to content

Getting all objects in a wide area


Recommended Posts

Posted (edited)

I''m failing to find a way how to get a bunch of objects in a given slightly bigger area.

It isn't really that big :

x cord span: 38

y cord span: 45.

When using methods like

List<RS2Object> openableDoors = s.objects.getAll().stream().filter(f -> f.getName().equals("Door") && f.hasAction("Open")).collect(Collectors.toList());

or 

List<RS2Object> objList = s.objects.filter(f -> f.getName().equals(objectName) && f.hasAction(objectAction));
		if (!objList.isEmpty()) {
			RS2Object lever = objList.get(0);
            // Do stuff
        } else {
          s.log("Couldn't find object: " + objectName); 
        }

I was hoping that this gives me all the objects that are loaded in region. (The objects exists and actually are visible)

When I manually walk a lil closer to the object I want to interact, the script finds the object. 

I have a hunch that these methods have a "max search distance" or something.

Anyway to get a full list of objects loaded or in a given (a lil bigger) area? 

Edited by nosepicker
Posted
31 minutes ago, WhoKnew said:

You could just define a huge area? From what it looks like you are doing, it'll work with what you are trying to do. Looks like you are just trying to find a door

What difference should it bring in just "finding an object that I can see". Atm I don't care if the object I want in the area I want, could be X other objects outside my desired area :) The problem I'm facing is that the script doesn't find the object even when I see it (from far away - maybe like 15-20 or so tiles).

After playing around noticed that if I rotate the camera a lil towards the object, the script finds the object.

Apart from adding failsafes like rotate camera or walk around, any bulletproof ways to do this?

Posted
7 hours ago, El_Maestro said:

Trying running your current snippet from the same game position twice. Print how many objects you find. If something is wrong it should print a different number every run.

Running this every loop iteration. Will try to see the size of the returned list, thanks!

6 hours ago, d0zza said:

The game only loads objects up to 15 tiles away from your player so you won't be able to get all the objects in an area that big.

Thanks for the info. But isn't there something like a "loaded region"? Should be bigger than 15 tiles

Also when I see the object in the distance I can right click on it and interact with it, so it's loaded in game, but the script has trouble finding it

Posted
21 minutes ago, El_Maestro said:

The game is loading, I think the api method may just have a preset distance cap because you don't usually need anything bigger. I've always noticed that it only gets npcs that are on your minimap.

This minimap thing might be the case. Will test to confirm. Though if it's true, any methods to load beyond minimap?

Posted
55 minutes ago, dreameo said:

Try to stand further away from your object until it's not visible in minimap and tell me how it goes :boge:

What I noticed though:

1) Object must be on minimap to be found (after login). If it was on minimap earlier, then it can be found later without problems.

2) Methods closest(Area, objectName), getAll() adhere to the 1st rule.

Posted
41 minutes ago, nosepicker said:

Try to stand further away from your object until it's not visible in minimap and tell me how it goes :boge:

What I noticed though:

1) Object must be on minimap to be found (after login). If it was on minimap earlier, then it can be found later without problems.

2) Methods closest(Area, objectName), getAll() adhere to the 1st rule.

I've had issues before with getObjects() in general. It picked up things that aren't actually there. Hence when I tested out the max tile distance, I got 73 (Logged in and testing where I stood - didn't move). 

If objects aren't being loaded because they are too far, not sure if there's anything that you could even do about it lol. 

Play around and do some tests :troll:

Posted
11 minutes ago, dreameo said:

I've had issues before with getObjects() in general. It picked up things that aren't actually there. Hence when I tested out the max tile distance, I got 73 (Logged in and testing where I stood - didn't move). 

If objects aren't being loaded because they are too far, not sure if there's anything that you could even do about it lol. 

Play around and do some tests :troll:

73 Tiles? Quite a lot. I test by completely relaunching the client, so should be fresh cache.

Anyway, "solved" the issue by first traveling around the area for all objects to load properly. All works as expected after this.

Posted
2 minutes ago, nosepicker said:

73 Tiles? Quite a lot. I test by completely relaunching the client, so should be fresh cache.

Anyway, "solved" the issue by first traveling around the area for all objects to load properly. All works as expected after this.

Hmmm wouldn't it just save a cache of the objects? If they are dynamic objects, then it wouldn't be that much of a solution. 

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...