Hosfad 154 Share Posted August 8, 2022 (edited) Scripting behavior tree Hello guys i have decided to open source my Behavior tree I have included a full example over at https://github.com/Hosfad/Scripting-Behaviour-Tree , but i will include a brief example here too : This is a Behaviour , This is where youre gonna write youre code for interacting with the game public class InteractWithBank extends RSBehavior { public InteractWithBank(String name) { super(name); } @Override public void go(Object agent, Macro parent) { if (Bank.isOpen()){ Bank.withdrawAll("Coins"); MethodProvider.sleep(600); Bank.close(); }else { Bank.open(); } } } This is a Macro , This is what controls your different behaviours NOTE : Macros can be nested , meaning a macro can also be a behaviour inside another macro public class Banking extends RSMacro { Area closestBank = org.dreambot.api.methods.container.impl.bank.Bank.getClosestBankLocation().getArea(8); public Banking(String name) { super(name); // These are the current behaviors in our Banking Macro this.behaviors = new Behavior[]{ new WalkToArea("walkToBank" ,closestBank), new InteractWithBank("withdrawCoins") }; } @Override public String getTransition(Object agent, Macro parent) { // You call the different behaviours in the macro by returning their super String // eg: to call the InteractWithBank behaviour return "withdrawCoins"; if (closestBank.contains(Players.localPlayer())){ return "withdrawCoins"; }else { return "walkToBank"; } } } To run your Macro : RSMacro macro = new MainBranch("super name"); @Override public int onLoop() { // The arguments are null because this behaviour has no parent macro.behaviourGo(null,null); return 100; } Source : https://github.com/Hosfad/Scripting-Behaviour-Tree Edited August 8, 2022 by Hosfad Link to comment Share on other sites More sharing options...
obersi 10 Share Posted August 8, 2022 Scuffed Israeli TBL camelCase and SubCZ 2 Link to comment Share on other sites More sharing options...
camelCase 219 Share Posted August 8, 2022 Area closestBank = org.dreambot.api.methods.container.impl.bank.Bank.getClosestBankLocation().getArea(8); Reaz 1 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now