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
  • The most important snippet: walkTo method


    m4rr3co

    Recommended Posts

    package YourPackage;
    
    import org.dreambot.api.methods.Calculations;
    import org.dreambot.api.methods.MethodContext;
    import org.dreambot.api.methods.MethodProvider;
    import org.dreambot.api.methods.map.Tile;
    import org.dreambot.api.script.impl.TaskScript;
    
    public class Helper extends TaskScript {
    
        public static void walkTo(MethodContext context, Tile destination) {
            int runEnabled;
            if (context.getWalking().isRunEnabled())
                runEnabled = 1;
            else
                runEnabled = 2;
            if (destination.distance() > 10) {
                context.getWalking().walk(destination);
                MethodProvider.sleepUntil(() -> context.getLocalPlayer().isMoving(), Calculations.random(1000,1500));
                Tile dest = context.getClient().getDestination();
                if (dest != null) {
                    MethodProvider.sleepUntil(() -> dest.distance() < 6,runEnabled*Calculations.random(3000,3500));
                } else {
                    MethodProvider.sleepUntil(() -> !context.getLocalPlayer().isMoving(),runEnabled*Calculations.random(3000,3500));
                }
            } else {
                context.getWalking().walk(destination);
                MethodProvider.sleepUntil(() -> !context.getLocalPlayer().isMoving(),runEnabled*Calculations.random(3000,3500));
            }
        }
    }

    Please bear in mind I'm starting, I'm still studying Java and stuff. But anyways, I built this "walkto" method and am calling it from other parts of my script with:

    Helper.walkTo(Context,Tile)

    My little humble doubt is: is this the "efficient" way? do you guys have other ideas for making the "walking around" more efficient/less ban prone? Or am I like "dude, study more"?

    Cheers

    Link to comment
    Share on other sites

    i would also like more feedback on this, i've been thinking the same thing to create a walk method so i can re=cycle it in my scripts

     

    @Articron pls help 

    Link to comment
    Share on other sites

    Extract from my fighter for basic walking:

    package org.script.behaviour.traversal;
    
    import org.DreamFighter;
    import org.dreambot.api.methods.Calculations;
    import org.dreambot.api.methods.MethodProvider;
    import org.dreambot.api.methods.map.Area;
    import org.dreambot.api.methods.map.Tile;
    import org.script.internal.ScriptNode;
    
    import java.util.function.BooleanSupplier;
    
    /**
     * @author Articron
     */
    public class WalkToTarget extends ScriptNode<DreamFighter> {
        private final Area fightZone;
    
        public WalkToTarget(BooleanSupplier when, Area fightZone) {
            super(when);
            this.fightZone = fightZone;
        }
    
        @Override
        public int priority() {
            return 0;
        }
    
        @Override
        public String status() {
            return "Walking to targets";
        }
    
        @Override
        public int onLoop(DreamFighter ctx) {
            Tile rand = fightZone.getRandomTile();
            Tile dest = ctx.getClient().getDestination();
            if (dest != null && fightZone.contains(dest))
                return 600;
            if (ctx.getWalking().walk(rand)) {
                MethodProvider.sleep(600);
                dest = ctx.getClient().getDestination();
                if (dest != null) {
                    long sleep = Math.round(dest.distance() * (ctx.getWalking().isRunEnabled() ? 600 : 1200));
                    double randomDistance = Calculations.random(6, 15);
                    Tile finalDest = dest;
                    MethodProvider.sleepUntil(() -> finalDest.distance() <= randomDistance || ctx.getLocalPlayer().isStandingStill(), sleep);
                }
            }
            return 0;
        }
    }

     

    Link to comment
    Share on other sites

    9 hours ago, Articron said:

    Extract from my fighter for basic walking:

    
    package org.script.behaviour.traversal;
    
    import org.DreamFighter;
    import org.dreambot.api.methods.Calculations;
    import org.dreambot.api.methods.MethodProvider;
    import org.dreambot.api.methods.map.Area;
    import org.dreambot.api.methods.map.Tile;
    import org.script.internal.ScriptNode;
    
    import java.util.function.BooleanSupplier;
    
    /**
     * @author Articron
     */
    public class WalkToTarget extends ScriptNode<DreamFighter> {
        private final Area fightZone;
    
        public WalkToTarget(BooleanSupplier when, Area fightZone) {
            super(when);
            this.fightZone = fightZone;
        }
    
        @Override
        public int priority() {
            return 0;
        }
    
        @Override
        public String status() {
            return "Walking to targets";
        }
    
        @Override
        public int onLoop(DreamFighter ctx) {
            Tile rand = fightZone.getRandomTile();
            Tile dest = ctx.getClient().getDestination();
            if (dest != null && fightZone.contains(dest))
                return 600;
            if (ctx.getWalking().walk(rand)) {
                MethodProvider.sleep(600);
                dest = ctx.getClient().getDestination();
                if (dest != null) {
                    long sleep = Math.round(dest.distance() * (ctx.getWalking().isRunEnabled() ? 600 : 1200));
                    double randomDistance = Calculations.random(6, 15);
                    Tile finalDest = dest;
                    MethodProvider.sleepUntil(() -> finalDest.distance() <= randomDistance || ctx.getLocalPlayer().isStandingStill(), sleep);
                }
            }
            return 0;
        }
    }

     

    Amazing as always @Articron !

    Wondering how come you didn't add (if inventory contains stamina, energy, etc...) use them? i feel that including that in a walk method would make it fully complete

    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.