Jump to content

Get loaded/nearest/second/furthest/random


Recommended Posts

getLoaded, getNearest, getSecondNearest, getFurthest and getRandom for RS2Objects, NPCs, Players and GroundItems. Enjoy:


Download the class and source files here.

Files hosted on Copy.com


Open the Jar with any Zip/Rar program, and extract. There's pre-compiled classes (.class) and the source codes (.java). Enjoy.


[edit] Forgot to mention: The available parameters are int, String and Filter Var-Args for every method! You don't have to have any parameter at all if you don't want. [/edit]


Example of use:

		MethodAdapter methodAdapter = new MethodAdapter(this);

		final GroundItem bones = methodAdapter.getGroundItemHandler().getRandom(

		methodAdapter.interactWithEntity(bones, "Take", 1000, 200, 400,
				new XDynamicSleep() {

					public boolean canAwake() {

						return !bones.exists();

Or if you want to create an EntityXProfile:

		//Declare a new <code>MethodAdapter</code> instance
		final MethodAdapter m = new MethodAdapter(this);
		//Declare a new <code>EntityProfile<generic extends Entity>
		EntityXProfile<NPC> whiteKnight = new EntityXProfile<>();
		//Provide the profile defining attributes:
		whiteKnight.setNames("White Knight");
		whiteKnight.setFilters(new Filter<NPC>() {
			public boolean accept(NPC o) {
				return o.getFacing() == null || o.getFacing().equals(m.getLocalPlayer());
		}); //Check to make sure that the NPC isn't in combat or is in combat with me
		//Find the nearest and second nearest Rock Crab and declare new <code>NPC</code> instances
		NPC first = m.getNPCHandler().getNearest(whiteKnight);
		NPC second = m.getNPCHandler().getSecondNearest(whiteKnight);

		//Do what you want, just make sure you null-check them first.
		if (first != null && !first.isMoving())
		else if (second != null && !first.isMoving())
			//No NPC found


I've finished creating a generic-orientated getter class for Entities. This ensures that objects, NPC, players and ground items all use the same methods to their specific needs. Because I'm a bit of a perfectionist, I prefer "getting" and evaluating object instances before interacting. I want to be the one who handles those processed. This helps ensure that each interaction is concluded flawlessly.



How to install:

Copy the src/co/ folder to your source folder.


Edited by liverare
Link to comment
Share on other sites

This topic is now closed to further replies.
  • Recently Browsing   0 members

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