Guest User

Accurate Interaction

a guest
Mar 8th, 2014
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.84 KB | None | 0 0
  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() == 1 && entities.contains(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.                 if (!containsInteraction(e, interaction)) {
  24.                     client.moveMouse(new RectangleDestination(520, 170, 750, 500), false);
  25.                     return false;
  26.                 }
  27.                 return false;
  28.             }
  29.             if (containsInteraction(e, interaction)) {
  30.                 client.clickMouse(false);
  31.                 return true;
  32.             }
  33.             return false;
  34.         }
  35.     }
  36.    
  37.     public int getMenuBoxSlot(Entity e, String interaction) {
  38.         for (int i = 0; i < client.getMenu().size(); i++) {
  39.             Option option = client.getMenu().get(i);
  40.             if (option.action.equalsIgnoreCase(interaction) && option.noun.contains(e.getName())) {
  41.                 return i;
  42.             }
  43.         }
  44.         return -1;
  45.     }
  46.    
  47.     public boolean containsInteraction(Entity e, String interaction) {
  48.         for (int i = 0; i < client.getMenu().size(); i++) {
  49.             Option option = client.getMenu().get(i);
  50.             if (option.action.equalsIgnoreCase(interaction) && option.noun.contains(e.getName())) {
  51.                 return true;
  52.             }
  53.         }
  54.         return false;
  55.     }
Advertisement
Add Comment
Please, Sign In to add comment