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));