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.

Multiple path walking

Featured Replies

Hi guys, 

 

Can someone explain or show me how I can use a switch to walk random paths.

 

how can I add arrays to this.

public void Walkpath() throws InterruptedException {
		switch (random(1, 5)) {
		case 1:
                         //path1
			break;
		case 2:
                         //path2
			break;
		case 3:
                      
		break;
		}
		sleep(random(700, 1800));
	
	}

Edited by herojord

 

Hi guys, 

 

Can someone explain or show me how I can use a switch to walk random paths.

 

how can I add arrays to this.

public void Walkpath() throws InterruptedException {
		switch (random(1, 5)) {
		case 1:
                         //path1
			break;
		case 2:
                         //path2
			break;
		case 3:
                      
		break;
		}
		sleep(random(700, 1800));
	
	}
public void Walkpath() throws InterruptedException {
        switch (random(1, 5)) {
        case 1:
            getLocalWalker().walk(new Position(x, y, z));
            break;
        case 2:
            getLocalWalker().walk(new Position(x, y, z));
            break;
        case 3:

        break;
        }
        sleep(random(700, 1800));
    
    }

Not sure what else you mean, perhaps try to explain it a bit better?

If you want to walk multiple paths, you could have a data structure like so:

public class Path {
    private List<Position> path;

    public Path(List<Position> ourPath) {
        path = ourPath;
    }

    public List<Position> getPath() {
        return path;
    }
}

And then you can have something like this:

List<Path> ourPaths = new ArrayList<Path>();
ourPaths.add(new Path(Arrays.asList(new Position[]{ new Position(x, y, z), new Position(x, y, z) }));

Then, you wouldn't even need a switch/case selection. You could just do:

getLocalWalker().walkPath(ourPaths.get(random(1, 5)).getPath());

Edited by Bobrocket

Could also just use an array like this
 


 
Position[][] paths = new Position[][] {
            {
                    new Position(0,0,0), new Position(0,0,0) //path 0
            },

            {
                    new Position(0,0,0), new Position(0,0,0) //path 1
            }
    };
    
    Position[] myPath = paths[random(0, paths.length-1)];

  • Author

 

If you want to walk multiple paths, you could have a data structure like so:

public class Path {
    private List<Position> path;

    public Path(List<Position> ourPath) {
        path = ourPath;
    }

    public List<Position> getPath() {
        return path;
    }
}

And then you can have something like this:

List<Path> ourPaths = new ArrayList<Path>();
ourPaths.add(new Path(Arrays.asList(new Position[]{ new Position(x, y, z), new Position(x, y, z) }));

Then, you wouldn't even need a switch/case selection. You could just do:

getLocalWalker().walkPath(ourPaths.get(random(1, 5)).getPath());

 

Thanks this is what I mean.

But I will get into this when I'm more experienced in Java. smile.png

 

 

Could also just use an array like this

 


 
Position[][] paths = new Position[][] {
            {
                    new Position(0,0,0), new Position(0,0,0) //path 0
            },

            {
                    new Position(0,0,0), new Position(0,0,0) //path 1
            }
    };
    
    Position[] myPath = paths[random(0, paths.length-1)];

 

This is more basic so I'll use this untill I'm able to optimize my code and make it more clever.

Thankyou.

Edited by herojord

  • Author

 

Could also just use an array like this

 


 
Position[][] paths = new Position[][] {
            {
                    new Position(0,0,0), new Position(0,0,0) //path 0
            },

            {
                    new Position(0,0,0), new Position(0,0,0) //path 1
            }
    };
    
    Position[] myPath = paths[random(0, paths.length-1)];

 

 

I tried using this method, but since I'm working with cases it keeps looping so it never reaches the second value of the array.

because myPath gets a diff number everytime it enters the walking case.

 

How can I solve this issue?

I tried using this method, but since I'm working with cases it keeps looping so it never reaches the second value of the array.

because myPath gets a diff number everytime it enters the walking case.

 

How can I solve this issue?

I'm not sure what this issue is, and I'm also not sure what those cases would be since indexing an array means you don't have to use a switch anymore for this. Perhaps I can help if you show some of your code.

Edited by Flamezzz

  • Author

I'm not sure what this issue is, and I'm also not sure what those cases would be since indexing an array means you don't have to use a switch anymore for this. Perhaps I can help if you show some of your code.

Im on my tablet but my script works like this

(!ores && not at bank)

Case: walking to bank

(ores && not at furnace)

Case : walking to furnace

(!ores && at bank)

Case : banking

(ores && at furnace)

Case : smelting

So the switch keeps calling the path arrays.

Edited by herojord


if (randomPath == 0)

{

log("random = 0");

randomPath = random(1,4);

}

if(randomPath == 1)

{

localWalker.walkPath(pathToHouseTwo);

sleep(100 + random (100, 200));

while(myPlayer().isMoving() || myPlayer().isAnimating())

{

sleep(400 + random (100, 200));

}

return 200 + gRandom(200, 400.0D);

}

else if (randomPath == 2)

{

localWalker.walkPath(pathToHouseTwo2);

sleep(100 + random (100, 200));

while(myPlayer().isMoving() || myPlayer().isAnimating())

{

sleep(400 + random (100, 200));

}

return 200 + gRandom(200, 400.0D);

}

else if (randomPath == 3)

{

localWalker.walkPath(pathToHouseTwo3);

sleep(100 + random (100, 200));

while(myPlayer().isMoving() || myPlayer().isAnimating())

{

sleep(400 + random (100, 200));

}

return 200 + gRandom(200, 400.0D);

}

else if (randomPath == 4)

{

localWalker.walkPath(pathToHouseTwo4);

sleep(100 + random (100, 200));

while(myPlayer().isMoving() || myPlayer().isAnimating())

{

sleep(400 + random (100, 200));

}

return 200 + gRandom(200, 400.0D);

}

if (randomPath == 0)
        {
            log("random = 0");
            randomPath = random(1,4);
        }
        if(randomPath == 1)
        {
            localWalker.walkPath(pathToHouseTwo);
            sleep(100 + random (100, 200));
            while(myPlayer().isMoving() || myPlayer().isAnimating())
            {
                sleep(400 + random (100, 200));
            }
            return 200 + gRandom(200, 400.0D);
        }
        else if (randomPath == 2)
        {
            localWalker.walkPath(pathToHouseTwo2);
            sleep(100 + random (100, 200));
            while(myPlayer().isMoving() || myPlayer().isAnimating())
            {
                sleep(400 + random (100, 200));
            }
            return 200 + gRandom(200, 400.0D);
        }
        else if (randomPath == 3)
        {
            localWalker.walkPath(pathToHouseTwo3);
            sleep(100 + random (100, 200));
            while(myPlayer().isMoving() || myPlayer().isAnimating())
            {
                sleep(400 + random (100, 200));
            }
            return 200 + gRandom(200, 400.0D);
        }
        else if (randomPath == 4)
        {
            localWalker.walkPath(pathToHouseTwo4);
            sleep(100 + random (100, 200));
            while(myPlayer().isMoving() || myPlayer().isAnimating())
            {
                sleep(400 + random (100, 200));
            }
            return 200 + gRandom(200, 400.0D);
        }

Didn't really read through the code, but I noticed you are not using a switch statememt. Why not?

Edited by fixthissite

Didn't really read through the code, but I noticed you are not using a switch statememt. Why not?

 

Because Meh

+1 Flamezzz' solution. Simple and effective


I tried using this method, but since I'm working with cases it keeps looping so it never reaches the second value of the array.

because myPath gets a diff number everytime it enters the walking case.

 

How can I solve this issue?

 

You could probably make use of LocalWalker#walkPath instead; or maintain a global value to keep track of progress in your path walking. The first is probably the better way (tho I haven't actually tried it myself)

Edited by FrostBug

  • 1 year later...
On 9/19/2015 at 8:02 AM, Bobrocket said:

If you want to walk multiple paths, you could have a data structure like so:


public class Path {
    private List<Position> path;

    public Path(List<Position> ourPath) {
        path = ourPath;
    }

    public List<Position> getPath() {
        return path;
    }
}

And then you can have something like this:


List<Path> ourPaths = new ArrayList<Path>();
ourPaths.add(new Path(Arrays.asList(new Position[]{ new Position(x, y, z), new Position(x, y, z) }));

Then, you wouldn't even need a switch/case selection. You could just do:


getLocalWalker().walkPath(ourPaths.get(random(1, 5)).getPath());

I tried implementing this class and these methods but getLocalWalk() and walkPath are undefined for more, what do I need to import in order to fix that?

1 hour ago, zeroter5 said:

I tried implementing this class and these methods but getLocalWalk() and walkPath are undefined for more, what do I need to import in order to fix that?

Holy grave dig 

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.