Taytot 4 Posted April 5 (edited) I have coded my script fine, but my bot just continually walks finding trees, and I would like him to stay within a set boundary. I see the constructor: Area(XXXX,XXXX,XXXX,XXXX) but how do I implement that in my code? How would I say something like if bot is in Area(X,X,X,X) then stay; else, go back to area Edited April 5 by Taytot
KCBot 74 Posted April 5 (edited) Area nameOfArea= new Area(x1, y1, x2, y2); So an example of one of my own scripts: private Area houseWaitingArea = new Area(1628, 3111, 1630, 3109); So you could do; Area nameHere = new Area(1111, 2222, 3333, 4444); If (!nameHere.contains(Players.getLocal())) { then xxxx } Edited April 5 by KCBot Taytot 1
Taytot 4 Author Posted April 6 thanks I used a private final int walk_delay and a check after every action loop to ensure the bot always stays in the zone!
KCBot 74 Posted April 6 (edited) 5 hours ago, Taytot said: thanks I used a private final int walk_delay and a check after every action loop to ensure the bot always stays in the zone! That works! I myself would do this: Area nameHere = new Area(1111, 2222, 3333, 4444); If (!nameHere.contains(Players.getLocal())) { Walking.walk(nameHere.getRandomTile()); sleep(Calculations.random(1000, 4000)); } Edited April 6 by KCBot
Luxe 82 Posted April 6 while(!myAreaName.contains(Players.getLocal().getTile())) { Walking.walk(myAreaName.getRandomTile()); sleep.sleepUntil(() -> Players.getLocal().isMoving(), Calculations.random(1250,7500)); } like this
KCBot 74 Posted April 6 9 minutes ago, ImLife said: while(!myAreaName.contains(Players.getLocal().getTile())) { Walking.walk(myAreaName.getRandomTile()); sleep.sleepUntil(() -> Players.getLocal().isMoving(), Calculations.random(1250,7500)); } like this Ideally you don't want to use while loops, specially if you are using taskscript (even if you are not, use states). Basically your node would accept if your player is not in myAreaName, with the highest priority. Then you only have this in your node: Walking.walk(myAreaName.getRandomTile()); sleep.sleepUntil(() -> Players.getLocal().isMoving(), Calculations.random(1250,7500));
Taytot 4 Author Posted April 6 private final Area treeArea = new Area(X, x, X, X); private final int WALK_DELAY = 3000; // Delay between walk check private Timer timer; etc etc if (!treeArea.contains(Players.getLocal())) { walkBackToTreeArea(); return WALK_DELAY;
Luxe 82 Posted April 6 24 minutes ago, KCBot said: Ideally you don't want to use while loops, specially if you are using taskscript (even if you are not, use states). Basically your node would accept if your player is not in myAreaName, with the highest priority. Then you only have this in your node: Walking.walk(myAreaName.getRandomTile()); sleep.sleepUntil(() -> Players.getLocal().isMoving(), Calculations.random(1250,7500)); Ahh thats true. I havent worked too much with anything other than the onLoop architecture. But great point!
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