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

Question Anyone got a basic 07 treebot i can look at?

Discussion in 'Developer Support' started by trapeze4, Jan 7, 2020.

  1. trapeze4

    Joined:
    Jan 6, 2020
    Messages:
    2
    Likes Received:
    0
    CS student here who just got into scripting. Started writing my first bot but I think my life would be a lot easier to get over the learning barrier if i had a basic treebot bot to look at? Anyone got any of their beginer/first bot they wouldn't mind sharing (for me to learn from)? Would be greatly appreciated. I looked around on here for a bit but could only find examples of looping scripts bots.
     
  2. CuppaJava

    CuppaJava cuppa.drink(java);

    Joined:
    Mar 13, 2018
    Messages:
    6,121
    Likes Received:
    1,378
    You can find some open source ones on the bot store I think.

    I learned from Snufalufugus' YouTube video tutorial called runemate tree bot tutorial or something.
     
  3. lb25

    Joined:
    Feb 9, 2019
    Messages:
    44
    Likes Received:
    3
    Cut and Drop? Follow Snufalufugus'zzz vid to set up your code and be able to debug. Then you can use the below as a basic chop and drop script bot.

    Code (Text):
    1. final String dropList[] = {"Logs", "Oak logs", "Willow logs", "Maple logs", "Yew logs", "Magic logs", "Redwood logs"};
    2. final String target_tree = "Maple tree";
    3. final Coordinate coord_player = Players.getLocal().getPosition();
    4. final boolean collect_birds_nest = true;
    5.  
    6. if (Inventory.isFull()) {
    7.     //go through twice in case we miss any logs
    8.     //shift drop all the logs...
    9.     Keyboard.pressKey(KeyEvent.VK_SHIFT);
    10.     for (int i = 0; i < 2; i++) {
    11.         SpriteItemQueryResults items = Inventory.getItems(dropList);
    12.  
    13.         for (SpriteItem item: items) {
    14.             item.click();
    15.         }
    16.     }
    17.     Keyboard.releaseKey(KeyEvent.VK_SHIFT);
    18.     return false;
    19. }
    20.  
    21.  
    22. if (collect_birds_nest) {
    23.     GroundItem birdNest = GroundItems.newQuery().filter(o-> o.getDefinition() !=null && o.getDefinition().getName().contains("nest")).results().first();
    24.     if (birdNest != null) {
    25.         birdNest.interact("Take");
    26.         return false;
    27.     }
    28. }
    29.  
    30. //get some more logs
    31. GameObject targetTree = GameObjects.newQuery().names(target_tree).actions("Chop down").filter(o-> o.distanceTo(coord_player, Algorithm.EUCLIDEAN) < 4).results().nearest(Algorithm.EUCLIDEAN_SQUARED);
    32. if (targetTree != null) {
    33.     if (!targetTree.isVisible()) {
    34.         BresenhamPath path = BresenhamPath.buildTo(targetTree.getPosition());
    35.         if (path != null) {
    36.             path.step();
    37.             Execution.delayUntil(()-> Players.getLocal().isMoving(), 750, 1500);
    38.             return false;
    39.         }
    40.     }
    41.  
    42.     //I had a few issues in the past where the target tree was right next to a bank and would try
    43.     //to interact with the tree while the interface was still open...
    44.     if (com.runemate.game.api.hybrid.local.hud.interfaces.Bank.isOpen())
    45.         com.runemate.game.api.hybrid.local.hud.interfaces.Bank.close();
    46.     else if (com.runemate.game.api.hybrid.local.hud.interfaces.DepositBox.isOpen())
    47.         com.runemate.game.api.hybrid.local.hud.interfaces.DepositBox.close();
    48.  
    49.     //InteractablePoint inter = obj.getInteractionPoint();
    50.     boolean res = targetTree.interact("Chop down");
    51.     if (!res) {
    52.         Camera.turnTo(targetTree);
    53.         targetTree.interact("Chop down");
    54.     }
    55.     Execution.delayUntil(()->Players.getLocal().getAnimationId() != -1, 750, 1500);
    56. }
     

Share This Page

Loading...