Jump to content

Ent Detection [Answered]


thelegacy0

Recommended Posts

Hey guys, I need some help with this. I don't babysit my bot, but it'll go for an hour or two easily (ran it up to 4 hours at once already). I don't know if it's coincidental, but it'll have no problems for those hours, then sometimes it'll eat an ent. I'm very new to this API but I'm doing my best to learn what I can.

 

When I cut, I check for an ent:

if(client.getMyPlayer().isAnimating() == false) {
	if(closestObjectForName("Willow").getId() != 1719) {

Unless ents have different ID's... That might be my problem, but where could I find a list of those?

 

In my onLoop(), I have this, because I don't know how to check the object I'm interacting with:

if(client.getCurrentRegion().getObjects().contains(1719)) {
	walk(willowsArea);
}

This way, if there's an ent in the area, it'll walk away, and refresh my selected tree (first snippet).

 

Also, another HUGE problem: it seems stop(); doesn't really work for me.

		public void logout() throws InterruptedException {
			if(!client.getMyPlayer().isUnderAttack()) {
				log("Rune axe was not equipped, logging out.");
				logoutTab.open();
				sleep(random(1000,1500));
				logoutTab.logOut();
			} else {
			log("Player is under attacking, retrying.");
				while (client.getMyPlayer().isUnderAttack()) {
						sleep(1000);
				}
				logoutTab.logoutTab.open();
				logoutTab.logoutTab.logOut();
			}
			stop();
		}

All the thing does is logout, login, logout, login. Very freaking bot-like. Shouldn't the entire logout() method complete (as in pass stop()wink.png before the loginhandler activates? Kind've silly to implement that mid-task.. Then, how would I go about logging out and closing the script?

 

 

Answer for ents: NPC ent = closestNPCForName("Willow");

Thank you, Reden.

Edited by thelegacy0
Link to comment
Share on other sites

Like I said I'm very new, so bare with me. I found this:

public boolean isFacing(Character<?> character)

Returns whether this character is facing, or as you may call it interacting, with the specified Character.

Parameters:
    character - The specified character.
Returns:

And that works for characters and NPCs, yes? How would I set this to look for an ent (the ent I encountered was ID 1719)?

 

I'd imagine it'd be like

if(isFacing(ent)) {

//so on

}

 

But I don't know what needs to be implemented or how, like

RS2Object ent = howeverYouDoIDs(1719);

 

Sorry for the very late response, I'm trying to read through the api so I don't have to be spoonfed

Link to comment
Share on other sites

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

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