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
  • [In Progress] Mad Framework


    Mad Moxxi

    Recommended Posts

    looks prety clunky fam

     

     

    ^exactly... too much code packed into a single statement

     

    Of course the buildTask method can get overcrowded, but that's looking at only the implementation I whipped up in a matter of minutes. It's designed to be used wherever you see fit. It can be implemented pretty much anywhere in your existing framework with a few lines.

    Link to comment
    Share on other sites

    Of course the buildTask method can get overcrowded, but that's looking at only the implementation I whipped up in a matter of minutes. It's designed to be used wherever you see fit. It can be implemented pretty much anywhere in your existing framework with a few lines.

    Node frameworks really seems to eliminate the need for this, and also looks a little better imo. I don't like the look of 4 lines for a single statement.

    Link to comment
    Share on other sites

    Node frameworks really seems to eliminate the need for this, and also looks a little better imo. I don't like the look of 4 lines for a single statement.

    You can use it within your node framework. Instead of doing

    NPC npc = getContext().getNPCs().closest((npc) -> npc.getName().equals("Flesh crawler"));
    if (npc != null) npc.interact("Attack");
    

    you could do

            getContext().getTaskExecutor().execute(new InteractEntityTask(getContext(),
                    (npc) -> npc.getName().equals("Flesh crawler"), "Attack"));
    

    which also handles walking, camera movement and will attempt to WebWalk, if no matching local Entity is found.

     

    Edit: You can also use them as nodes. Here is an example of what a banking node would look like.

    public class BankingTask extends ChainableTask {
        private final String axeName;
        private boolean hasAxe;
    
        public BankingTask(Context context, String axeName) {
            super(context);
            this.axeName = axeName;
        }
    
        @Override
        public boolean execute() {
            // Standard processing method
            return getContext().getTaskExecutor().execute(
                    hasAxe ? new DepositAllExceptTask(getContext(), false, axeName)
                           : new WithdrawTask(getContext(), axeName, 1));
        }
    
        @Override
        public void prepare() {
            // This executes if canExecute returns false
        }
    
        @Override
        public boolean canExecute() {
            // Can it execute?
            hasAxe = getContext().getInventory().contains(axeName) || getContext().getEquipment().contains(axeName);
            return getContext().getInventory().isFull() || !hasAxe;
        }
    }
    
    Link to comment
    Share on other sites

    Personally I really like the idea behind this. It's much easier to use a simple lambda then create an entire class for an "eat" action.

     

    @Everyone complaining about large projects getting messy, just create a container class to hold methods which return their respective lambdas or even group them within multiple classes. You can still receive all the benefits of this with the organization of the typical task framework.

    Link to comment
    Share on other sites

    Archived

    This topic is now archived and is closed to further replies.

    ×
    ×
    • 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.