Jump to content
View in the app

A better way to browse. Learn more.

OSBot :: 2007 OSRS Botting

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Pathing issue with my bot

Featured Replies

I'm new and need some help. I'm writing a script and need my bot to be able to walk from the Lumbridge sheep farm to the bank and then back. from everything I've read my code seems sound but for some reason about 50% the time my bot passes through the gate of Lumbridge castle(going in either direction) it randomly turns around and bolts toward the swamp for no apparent reason. I pretty sure the problem lies somewhere in path or path 4. As path2 and path 3 take place upstairs in the castle and haven't exhibited any problems.

 

I'm stumped as to what might be causing this. All my code related to walking the path follows. Any insight as to the possible root of my problem would be greatly appreciated. As would any advice on how to possibly do this better.

private Position[] path = {
            new Position(3217,3258, 0), new Position(3219,3245, 0), new Position(3229,3233, 0),
            new Position(3235,3219, 0), new Position(3218,3219, 0), new Position(3214,3219, 0),
            new Position(3215,3224, 0), new Position(3213,3228, 0), new Position(3207,3228, 0),
            new Position(3207,3228, 0)};
    private Position[] path2 = {
    	    new Position(3206,3225, 2), new Position(3206,3221, 2), new Position(3214,3219, 2),
            new Position(3208,3220, 2)};
    private Position[] path3 = {
            new Position(3214,3219, 2), new Position(3206,3221, 2), new Position(3206,3225, 2)};
    private Position[] path4 = {
    	    new Position(3207,3228, 0), new Position(3213,3228, 0), new Position(3215,3224, 0), 
            new Position(3214,3219, 0), new Position(3218,3219, 0), new Position(3235,3219, 0),
            new Position(3229,3233, 0), new Position(3219,3245, 0), new Position(3217,3258, 0)};
    
    @Override
    public int onLoop() throws InterruptedException {
    	localWalker.walk(3212,3262);
    	while(myPlayer().isMoving())
    		sleep(random(300,500));
    	sleep(random(2000,4000));
    	if(objects.closest("Gate").hasAction("Open"))
    	{
    		while (objects.closest("Gate").hasAction("Open")){
    		objects.closest("Gate").interact("Open");
    		sleep(random(500,1000));}
    	}	
    	localWalker.walkPath(path);
    	while(myPlayer().isMoving())
    		sleep(random(300,500));
    	sleep(random(1000,2000));
    	if(objects.closest("Staircase").hasAction("Climb-up"))
    	{
    		while (objects.closest("Staircase").hasAction("Climb-up")){
    			objects.closest("Staircase").interact("Climb-up");
    			sleep(random(500,1000));}
    	}
		localWalker.walkPath(path2);
    	while(myPlayer().isMoving())
    		sleep(random(300,500));
		RS2Object bankBooth = objects.closest("Bank booth");
        if (bankBooth != null) {
            if (bankBooth.interact("Bank")) {
                while (!bank.isOpen())
                    sleep(250);
                bank.depositAllExcept("Shears");
            }
        }
        sleep(random(2000,4000));
        localWalker.walkPath(path3);
    	while(myPlayer().isMoving())
    		sleep(random(300,500));
    	sleep(random(2000,4000));
    	if(objects.closest("Staircase").hasAction("Climb-down"))
    	{
    		while (objects.closest("Staircase").hasAction("Climb-down")){
    			objects.closest("Staircase").interact("Climb-down");
    			sleep(random(500,1000));}
    	}
		localWalker.walkPath(path4);
    	while(myPlayer().isMoving())
    		sleep(random(300,500));
    	sleep(random(2000,4000));
    	if(objects.closest("Gate").hasAction("Open"))
    	{
    		while (objects.closest("Gate").hasAction("Open")){
    		objects.closest("Gate").interact("Open");
    		sleep(random(500,1000));}
    	}
    	while(myPlayer().isAnimating())
    		sleep(random(300,500));
    	Area sheepFarm = new Area (3195,3273,3210,3259);
    	localWalker.walk(sheepFarm.getRandomPosition(0));
    	while(myPlayer().isMoving())
    		sleep(random(300,500));

:o

 

the problemo is most likely with the style of code, where it fails to do one step and the rest of it is redundant.

 

Try using a statemachine system which allows you to work on 1 step at a time and if it fails it allows you to retry. This may well fix your problem.

More details on the state based system can be found here: http://osbot.org/forum/topic/58775-a-beginners-guide-to-writing-osbot-scripts-where-to-get-started-by-apaec/

 

PS Don't use while loops without a timeout (if at all!) these can cause it to get stuck.

 

Apaec

Its good to see new scripters, but there a few points that have to be worked on :)

 

Stop using so much while loops xD

I suggest you to get rid of them or atleast add a break timer so it can't get stuck.

 

Walking to the swamp could also be in the localwalker,

since it has been walking to several wrong positions for me too lately... not sure what the issue is :s

 

Try to have a better code style,

More checks where your player is located and what to do next.

Don't just put everything back to back.

Like APA said: Use states or use some way the logic of the script improves smile.png

 

This will also give NPE's:

if(objects.closest("Staircase").hasAction("Climb-down"))
objects.closest("Staircase").interact("Climb-down");
if(objects.closest("Gate").hasAction("Open"))

You should get the Object first, then Null check it before you do anything with it.

 

Khaleesi

Edited by Khaleesi

  • Author

Thanks for the help guys between you guys and some help from chat i rewrote the pathing system to be more random and less detectable using areas. And fixed the bug along the way.

Create an account or sign in to comment

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.