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

Bug Client aren't returning more than 1 nearest object

Discussion in 'Developer Support' started by LucasSousa, Jul 14, 2017.

  1. LucasSousa

    Joined:
    Jan 25, 2015
    Messages:
    121
    Likes Received:
    19
    Hello, I started to code some bots but the client don't interact with all objects avaliable, as the nearests. After problems I tried write a simple code to check if the problem was in my code or no. Look:

    Code (Javascript):
    1. public class Test extends Task {
    2.  
    3.     @Override
    4.     public void execute() {
    5.  
    6.         GameObject tree = GameObjects.newQuery().names("Willow").results().nearest();
    7.  
    8.         if (tree != null){
    9.  
    10.             if (tree.interact("Chop down")){
    11.  
    12.                 System.out.println("Chopping...");
    13.             }
    14.         }
    15.     }
    16.  
    17.     @Override
    18.     public boolean validate() {
    19.  
    20.         return Players.getLocal().getAnimationId() == -1 && !Inventory.isFull();
    21.     }
    22. }
    If I run this, the local player will only chop the nearest tree. When the tree falls, character don't go interact with the next avaliable object, just stuck, without log messages.

    Runemate version: 2.48.0
    Game affected: RS3

    EDIT:

    I tried to use LoopingBot instead Task bot and got the same problem. This is the test in LoopingBot:

    Code (Javascript):
    1. public class Main extends LoopingBot {
    2.  
    3.     @Override
    4.     public void onLoop() {
    5.         GameObject t = GameObjects.newQuery().names("Willow").results().nearest();
    6.  
    7.         if (Players.getLocal().getAnimationId() == -1 && !Inventory.isFull() && t != null){
    8.  
    9.             t.interact("Chop down");
    10.         }
    11.     }
    12. }
    I tried too delete my cache folders and reinstall legacy client and didn't solved the problem.
     
    #1 LucasSousa, Jul 14, 2017
    Last edited: Jul 15, 2017
  2. Derk

    Derk 12 year old normie

    Joined:
    Jan 8, 2015
    Messages:
    2,766
    Likes Received:
    1,339
    How are you adding this task to the tasklist? Assuming you're using TaskBot.

    Also, why not declare tree, initialize and nullcheck in validate() and interact with in execute()? Try to move as much to the validate() as possible that might cripple the execute() (such as nullchecking).
     
    LucasSousa likes this.
  3. LucasSousa

    Joined:
    Jan 25, 2015
    Messages:
    121
    Likes Received:
    19
    Just using add() at my TaskBot main class like:
    Code (Text):
    1. add(new Test());
    I tried move all inicializations and verifications to validate(), as you recomended, and stil got the same state, stuck after chopping aquired tree.

    This is the test code after corrections:

    Code (Text):
    1. public class Test extends Task {
    2.  
    3.     private GameObject tree;
    4.  
    5.     @Override
    6.     public void execute() {
    7.         tree.interact("Chop down");
    8.     }
    9.  
    10.     @Override
    11.     public boolean validate() {
    12.         tree = GameObjects.newQuery().names("Willow").results().nearest();
    13.  
    14.         return Players.getLocal().getAnimationId() == -1 &&
    15.  
    16.                 !Inventory.isFull() &&
    17.  
    18.                 tree != null;
    19.     }
    20. }
     

Share This Page

Loading...