Jump to content

mouse to option


Recommended Posts

Posted

So I want my mouse to move to a entity, right click on it and then move to an option from the "Choose option" menu but not click on it.

I already have this for example:

 

Entity door = objects.closest("Door");

EntityDestination mouseDoor = new EntityDestination(getBot(),door);

 

getMouse().click(mouseChest, true); 

 

now the mouse just moves to the door and right clicks on it. But what should i add to make it even move to the "Open" action but not click on it yet?

Posted

Umm maybe something along the lines of this:

(Not sure if it works but the logic is there and could be tweaked)

void hovenEntityOption(Entity entity, String option){
        if(menu.isOpen() && menuContains(option)){
         Rectangle optionBox = menu.getOptionRectangle(menuIndex(option));
            if(optionBox != null){
                if(optionBox.contains(mouse.getPosition())){
                    //idling
                }else{
                    int x,y;
                    do {
                        x = (int) (optionBox.getX() + optionBox.getWidth() * Math.random());
                        y = (int) (optionBox.getY() + optionBox.getHeight() * Math.random());
                    } while(!optionBox.contains(x,y)) ;
                    mouse.move(x,y);
                }
            }
        }else{
            if(menu.isOpen() && !menuContains(option)){
                menu.selectAction("Cancel");
            }else {
                if (entity.hover()) {
                    mouse.click(false);
                }
            }
        }
    }
  • Like 1

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