Jump to content
Frequently Asked Questions
  • Are you not able to open the client? Try following our getting started guide
  • Still not working? Try downloading and running JarFix
  • Help! My bot doesn't do anything! Enable fresh start in client settings and restart the client
  • How to purchase with PayPal/OSRS/Crypto gold? You can purchase vouchers from other users
  • Questions on TaskScript and best practices


    Tier3

    Recommended Posts

    First off, is TaskScript still the preferred framework? If not, what would be? [Currently I'm using Abstract Script with a state/node framework, but my decision making is making my scripts feel cluttered and messy]

    Second, while it seems great for simple repetitive tasks in the same order, how would I go about choosing a random activity to do? Make a Decision node with the highest priority where the Accept is based on, say, a Timer. This would force me to use a variable to determine which activity I'm going to do, wouldn't it? And all nodes would need to have that variable check in their Accept? [See attached image for a visual on what I'm talking about]

    Spoiler

    79851877_TaskScriptFlow.thumb.jpg.53bdcb9ea8ca3c0d8b4daee13f7ee09f.jpg

    And lastly, have I structured this correctly? [Basic Woodcutting Script - mostly copied from an old Hashtag Tut, updated for DB3 + added a few extras]

    ChopChop.jpg.28f004b5c24622a701f3e4d881fbaa70.jpg

    • Main.java
    Spoiler
    package chopper;
    
    import org.dreambot.api.script.Category;
    import org.dreambot.api.script.ScriptManifest;
    import org.dreambot.api.script.impl.TaskScript;
    
    @ScriptManifest(version = 0.1, author = "Tier3", category = Category.WOODCUTTING, name = "ChopChop")
    
    public class Main extends TaskScript {
    	
    	@Override
    	public void onStart() {
    		addNodes(new nodes.ChopNode(), new nodes.ChopOak(), new nodes.ChopWillow(), new nodes.DropNode(), new nodes.LvlNode());		
    	}	
    }

     

    • DropNode.java
      Spoiler
      package nodes;
      
      import org.dreambot.api.methods.Calculations;
      import org.dreambot.api.methods.container.impl.Inventory;
      import org.dreambot.api.script.TaskNode;
      
      public class DropNode extends TaskNode {
      	
      	@Override
      	public int priority() {
      		return 2;
      	}
      	
      	@Override
      	public boolean accept() {
      		return Inventory.isFull();
      	}
      	
      	@Override
      	public int execute() {
      		Inventory.dropAll(l -> l != null && l.getName().contains("ogs"));
      		return Calculations.random(1600, 3200);
      	}
      
      }

       

       

    • ChopNode.java

      Spoiler
      package nodes;
      
      import org.dreambot.api.methods.Calculations;
      import org.dreambot.api.methods.interactive.GameObjects;
      import org.dreambot.api.methods.interactive.Players;
      import org.dreambot.api.methods.skills.Skill;
      import org.dreambot.api.methods.skills.Skills;
      import org.dreambot.api.script.TaskNode;
      import org.dreambot.api.wrappers.interactive.GameObject;
      
      public class ChopNode extends TaskNode {
      	
      	@Override
      	public int priority() {
      		return 1;
      	}
      	
      	@Override
      	public boolean accept() {
      		return Skills.getRealLevel(Skill.WOODCUTTING) < 15;
      	}
      	
      	@Override
      	public int execute() {
      		if (!isChopping()) {
      			GameObject tree = GameObjects.closest(t -> t != null && t.getName().equals("Tree") && t.hasAction("Chop down"));
      			if (tree != null) {
      				if (tree.interact("Chop down")) {
      					sleepUntil(() -> Players.localPlayer().isMoving(), Calculations.random(1500,2600));
      					sleepUntil(() -> isChopping() || tree == null, Calculations.random(3500,5600));
      				}
      			} else {
      				//Walk to Trees
      			}
      		}
      		
      		return Calculations.random(1900,3600);
      	}
      	
      	private boolean isChopping() {
      		return Players.localPlayer().isAnimating();
      	}
      
      }

       

      ChopOak (WC between 15 and 30) and ChopWillow (WC > 30) are the same as ChopNode, except chops the corresponding tree type based on WC lvl. (As for the "isChopping()" method, because I'm using it 3 times, could I instead have isChopping() in a Helper class? Obviously 3 one line methods is no big deal to just copy/paste, but lets say I had 15 or fifty lines of code? Helper class would be preferred?)

    • LvlNode just checks for Dialogues.canContinue and continues (Priority 3)

    Obviously this script is probably 100% ban rate as is, what I'm most interested in knowing is:

    1. Is it structured correctly
    2. Am I correct on my "Decision Node" assumption
    3. Would a "Variable" class be worth it? Or just shove any variables into Main along with setters and getters?
    4. Would "isChopping" be better in a Helper class, or is there some benefit to keeping it in each 'Chop' node?
    5. If upscaling this to the suggested attached flow chart (Obviously renaming everything) is there an issue with adding nodes from several different packages in the "addNodes" in "Main.java" (chopNodes package, mineNodes package, fishNodes package for example) Or would there be a better solution to all of this?

     

    Link to comment
    Share on other sites

    7 hours ago, Tier3 said:

    First off, is TaskScript still the preferred framework? If not, what would be?

    TBL is better for larger scripts https://github.com/LostVirt/Dreambot-Tree-Branch-Framework/

    7 hours ago, Tier3 said:

    ChopOak (WC between 15 and 30) and ChopWillow (WC > 30) are the same as ChopNode, except chops the corresponding tree type based on WC lvl.

    i prefer having 1 leaf / node to handle wood cutting and the location & tree type and decided in that leaf based off level or whatever

    8 hours ago, Tier3 said:

    Second, while it seems great for simple repetitive tasks in the same order, how would I go about choosing a random activity to do? Make a Decision node with the highest priority where the Accept is based on, say, a Timer. This would force me to use a variable to determine which activity I'm going to do, wouldn't it? And all nodes would need to have that variable check in their Accept?

    yeah

     

    8 hours ago, Tier3 said:

    Would "isChopping" be better in a Helper class, or is there some benefit to keeping it in each 'Chop' node

    id say you should just get rid of isChopping and straight check if animating

     

    8 hours ago, Tier3 said:
    1. If upscaling this to the suggested attached flow chart (Obviously renaming everything) is there an issue with adding nodes from several different packages in the "addNodes" in "Main.java" (chopNodes package, mineNodes package, fishNodes package for example) Or would there be a better solution to all of this?

    theres no problem doing that (except that packages are named in all lowercase not camelCase :P) id recommend using TBL if you are going to do multiple skills in one script,  i never really got around to adding anything to this but heres a skeleton of how i was doing something similar https://github.com/Amoz3/FOSS-AIO-Dreambot3

    Link to comment
    Share on other sites

    Thank you for this, I remember stumbling on a post about tree behavior and then another one about 420 OP 1337 or something silly, basically exactly what you linked me to but it was from 2018 or something so I wasn't sure about it's relevance. This is a much better skeleton to work with anyway haha thanks. I think this will make multi skilling easier, I like that paint too! I'll have a go at it using this framework

    Link to comment
    Share on other sites

    On 7/30/2022 at 6:53 AM, Tier3 said:

    Thank you for this, I remember stumbling on a post about tree behavior and then another one about 420 OP 1337 or something silly, basically exactly what you linked me to but it was from 2018 or something so I wasn't sure about it's relevance. This is a much better skeleton to work with anyway haha thanks. I think this will make multi skilling easier, I like that paint too! I'll have a go at it using this framework

    I have a big multi skill, multi quest script. And I use this framework too: https://github.com/LostVirt/Dreambot-Tree-Branch-Framework/ can definitely vouch for it on larger scripts

    Link to comment
    Share on other sites

    • 5 months later...

    Is this framework still up to date with current API? Trying to use it and I noticed that both these import arent available anymore

    org.dreambot.framework.Branch;

    org.dreambot.framework.Tree;

     

    seem to have been replaced with org.dreambot.api.script.frameworks.treebranch.TreeScript;

    but the Main.java actually extends AbstractScript ???

    Link to comment
    Share on other sites

    On 1/21/2023 at 9:58 AM, mexxxy said:

    Is this framework still up to date with current API? Trying to use it and I noticed that both these import arent available anymore

    org.dreambot.framework.Branch;

    org.dreambot.framework.Tree;

     

    seem to have been replaced with org.dreambot.api.script.frameworks.treebranch.TreeScript;

    but the Main.java actually extends AbstractScript ???

    Extend TreeScript

    Link to comment
    Share on other sites

    Create an account or sign in to comment

    You need to be a member in order to leave a comment

    Create an account

    Sign up for a new account in our community. It's easy!

    Register a new account

    Sign in

    Already have an account? Sign in here.

    Sign In Now
    ×
    ×
    • Create New...

    Important Information

    We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.