Jump to content

Accurate Interaction


Recommended Posts

  • 2 weeks later...
Posted

It's been a while since I've tested this out, but I looked at it and found that I wasn't checking for the entity name inside of the menu box. I fixed that and tested it out. Everything seems fine, it would be nice for people to test it out and criticize the worst.

  • 11 months later...
Posted

I was trying to help you, don't act like a know it all when you just had a static sleep timer of 500-1500 please.

1) I'm not sure why you still think you're doing it right, but this:

2950fb51d2ecd38f4eb36b686fa697f2.png

NEVER GETS ANY OPTION. All it does is click, and that's assuming there's one thing on the cursor (you're not even checking that that's the correct entity, just that there's one there).

2) Your while loop just assures that the mouse gets moved to the bounding box. This could be good I guess, but it's kind of redundant when you could just return false if a menu is not open when you go to interact with it.

3) Fine if you're going to act like that I will:

public boolean interactNPC(NPC npc, String action) throws InterruptedException {	if (npc != null && npc.getDefinition().getActions() != null) {		Rectangle boundingBox = npc.getMouseDestination().getBoundingBox();		if (Arrays.asList(npc.getDefinition().getActions()).get(0).equalsIgnoreCase(action)) {			client.moveMouseTo(new RectangleDestination(boundingBox.x+5, boundingBox.y+5, boundingBox.width-10, boundingBox.height-10), false, false, false);			if (client.getEntitiesOnCursor().get(0).getName().equalsIgnoreCase(npc.getName())) {				client.clickMouse(false);				return true;			}			else {				client.moveMouseTo(new RectangleDestination(boundingBox.x+5, boundingBox.y+5, boundingBox.width-10, boundingBox.height-10), false, true, true);				return selectMenuOption(action);			}		}		else {			client.moveMouseTo(new RectangleDestination(boundingBox.x+5, boundingBox.y+5, boundingBox.width-10, boundingBox.height-10), false, true, true);			return selectMenuOption(action);		}	}	return false;}	public boolean selectMenuOption(String action) throws InterruptedException {	if (client.isMenuOpen()) {		List<Option> options = client.getMenu();		for (int i= 0; i < options.size(); i++) {			if (options.get(i).action.equalsIgnoreCase(action)) {				return client.moveMouseTo(new RectangleDestination(client.getMenuX(), client.getMenuY()+19+(i*15), client.getMenuWidth(), 15), false, true, false);			}		}	}	return false;}
Of course I could do more checking, but that can easily be accomplished by checking the boolean returned when the scripter calls the method.
can i use this in my scripts?

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...