m4rr3co 67 Posted April 29, 2020 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
kamilo 7 Posted May 3, 2020 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
Articron 746 Posted May 3, 2020 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; } }
kamilo 7 Posted May 3, 2020 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
Recommended Posts
Archived
This topic is now archived and is closed to further replies.