Guest User

Accurate Interaction

a guest
Mar 8th, 2014
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public boolean interact(Entity e, String interaction) throws InterruptedException {
  2.     if (e == null || !canReach(e) || !e.exists())
  3.         return false;
  4.     int distance = e.getPosition().distance(myPlayer().getPosition());
  5.     if (distance > 10) this.walkMainScreen(e.getPosition(), false);
  6.     client.moveCameraToEntity(e);
  7.     List<Entity> entities = client.getEntitiesOnCursor();
  8.     client.moveMouse(e.getMouseDestination(), false);
  9.     if (entities.size() > 0 && entities.get(0).equals(e)) {
  10.         client.clickMouse(false);
  11.         return true;
  12.     } else {
  13.         if (!entities.contains(e))
  14.             client.moveMouse(e.getMouseDestination(), false);
  15.         client.clickMouse(true);
  16.         int slot = getMenuBoxSlot(e, interaction);
  17.         int x = client.getMenuX() + 15;
  18.         int y = ((client.getMenuY() + 19) + (slot * 15));
  19.         int width = client.getMenuWidth() - 20;
  20.         int height = 10;
  21.         client.moveMouse(new RectangleDestination(x, y, width, height), false);
  22.         if (slot == -1) {
  23.             client.moveMouse(new RectangleDestination(520, 170, 750, 500), false);
  24.             return false;
  25.         }
  26.         client.clickMouse(false);
  27.         return true;
  28.     }
  29. }
  30.  
  31. public int getMenuBoxSlot(Entity e, String interaction) {
  32.     for (int i = 0; i < client.getMenu().size(); i++) {
  33.         Option option = client.getMenu().get(i);
  34.         if (option.action.equalsIgnoreCase(interaction) && option.noun.contains(e.getName()))
  35.             return i;
  36.     }
  37.     return -1;
  38. }
Advertisement
Add Comment
Please, Sign In to add comment