1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Mouse is not always accurate

Discussion in 'Developer Support' started by not_mallard, Jul 25, 2015.

  1. not_mallard

    Joined:
    Mar 22, 2015
    Messages:
    75
    Likes Received:
    17
    I wrote a bot to make Anchovy pizza for me.
    It kind of works...

    Sometimes it mis-clicks and then eats things, or breaks in other scary ways.

    Here's a video to showcase the problem


    This is the code I'm using to make the pizzas

    PHP:
    1. SpriteItem anchovies = Inventory.getItems("Anchovies").first();
    2. SpriteItem pizza = Inventory.getItems("Plain pizza").first();
    3. anchovies.interact("Use");
    4.  
    5. Execution.delay(300, 500);
    6.  
    7. pizza.click();
    8.  
    9. Execution.delayUntil(() -> Interfaces.getLoaded(Interfaces.getTextEqualsFilter("Anchovy pizza")).first() != null, 500, 1000);
    10.  
    11. InterfaceComponent ic = Interfaces.getAt(309, 6);
    12.  
    13. if (ic != null)
    14.     ic.click();
    15.  
    16. Execution.delayUntil(() -> Players.getLocal().getAnimationId() == -1, 500, 1000);
     
  2. Ozzy

    Joined:
    Nov 5, 2014
    Messages:
    505
    Likes Received:
    162
    Try using interact() instead of click() as you can the force the mouse to right click the item and choose the correct option, you should also slow down the bot by adding logic so that you only delayUntil after interactions are successful, something like this:


    Code (Text):
    1. if (ChatDialog.getOptions().isEmpty()) {
    2.             // We don't have the option to make pizza yet
    3.             if (anchovies != null && anchovies.interact("Use")) {
    4.                 if (pizza != null && pizza.click()) {
    5.                     Execution.delayUntil(() -> !ChatDialog.getOptions().isEmpty(), 1000, 2500);
    6.                 }
    7.             }
    8.         } else {
    9.             // The make pizza menu is likely open
    10.             InterfaceComponent pizzaInterface = Interfaces.getAt(309, 6);
    11.             if (pizzaInterface != null && pizzaInterface.click()) {
    12.                 Execution.delayUntil(() -> Players.getLocal().getAnimationId() == -1, 500, 1000);
    13.             }
    14.         }
     
  3. not_mallard

    Joined:
    Mar 22, 2015
    Messages:
    75
    Likes Received:
    17
    Thanks but ChatDialog.getOptions().isEmpty() seems to always be true. Is there a method that I could use to replace this?
     
  4. Eagles13

    Eagles13 The only thing Alpha about me is my bots

    Joined:
    Sep 22, 2014
    Messages:
    618
    Likes Received:
    186
    Check if the interface you're trying to access != null and isVisible(). If that returns true, then you know it's visible. If either of those return false, then you know it's not there yet, so you need to interact with your pizza and anchovies.

    tl;'dr: There's no logic there. It's just a list of things to do which will fire every so often.

    And @Arbiter why is this shit so borked? http://vgy.me/vQvqf6.png (the layout)
     
  5. not_mallard

    Joined:
    Mar 22, 2015
    Messages:
    75
    Likes Received:
    17
    Here's the method I ended up using
    Code (Text):
    1. private boolean hasPizzaBox() {
    2.         return Interfaces.getAt(309, 6) != null && Interfaces.getAt(309, 6).isVisible();
    3.     }
     
  6. Eagles13

    Eagles13 The only thing Alpha about me is my bots

    Joined:
    Sep 22, 2014
    Messages:
    618
    Likes Received:
    186
    I don't see why you need to make it into another method? Are you calling it more than once?
     
  7. not_mallard

    Joined:
    Mar 22, 2015
    Messages:
    75
    Likes Received:
    17
    Calling it in two places.
    In the first if statement (to check if I need to click the anchovies or if I need to click the interface) and also in the Execution.delayUntil
     
  8. Eagles13

    Eagles13 The only thing Alpha about me is my bots

    Joined:
    Sep 22, 2014
    Messages:
    618
    Likes Received:
    186
    Fair enough.
     

Share This Page

Loading...