Jump to content
Frequently Asked Questions
  • Are you not able to open the client? Try following our getting started guide
  • Still not working? Try downloading and running JarFix
  • Help! My bot doesn't do anything! Enable fresh start in client settings and restart the client
  • How to purchase with PayPal/OSRS/Crypto gold? You can purchase vouchers from other users
  • Walker stopping premature.


    scjunkie123

    Recommended Posts

    What my issue is, is that I have a walker go to a bank it will click it from far away midway through a walk even though the character hasn't stopped moving. Since it clicks so far away, it sometimes miss clicks other NPCs that move past screen, or fails because the placement of the camera is pitched so low and moving that it is too slow to click the banker.

    public void bank() {
    		if (getLocalPlayer().distance(getBank().getClosestBankLocation().getCenter()) > 5) {
    			if (getWalking().walk(getBank().getClosestBankLocation().getCenter())) {
    				sleep(Calculations.random(2000, 3000));
    				sleepUntil(() -> !getLocalPlayer().isMoving(), Calculations.random(2000, 3000));
    				getBank().open();
    				sleepUntil(() -> getBank().isOpen(), Calculations.random(2000, 3000));
    				getBank().depositAllExcept(f -> f.getName().contains("Coins"));
    				getBank().close();
    				sleepUntil(() -> !getBank().isOpen(), Calculations.random(2000, 3000));
    			}
    		}
    	}

    Also, on a side note, is there a better way to open doors that aren't going to be able to be opened by walker? I have issues walking to bank and back while shopping so I implemented a door interaction method. It's limited and sometimes opens the door when it doesn't need too which is obvious in the code. Is there a better way to implement it? The code is executed by inputting the NPC's distance inside the method.

    public void openDoor(double d) {
    		if (!getWalking().isRunEnabled()) {
    			getWalking().toggleRun();
    		}
    		GameObject door = getGameObjects().closest("Door");
    		if (door != null && door.distance() <= d) {
    			if (door.isOnScreen() && door.hasAction("Open")) {
    				getCamera().rotateToEntity(door);
    			}
    			if (door.interact("Open")) {
    				sleep(Calculations.random(2000, 3000));
    			}
    		}
    	}
    
    Link to comment
    Share on other sites

    Your problem with the banking method comes fro

    m the fact that you're coding everything in a linear faction. 

    Logically your code would perform like this: 

     

    Whenever bank method is called: 

       > if we're more than 5 tiles from the bank, then:

          > Attempt to walk to the center of the bank, and IF we do walk that way:

             >Sleep for a random amount of time AND open the bank AND sleep until the bank is open AND deposit our items AND close the bank

     

    Now, after the bank method is called, your script is going to return to whichever line it was called from. If all goes well then your bank() method went succesfuly, right? But what if something unexcpected happens? Well according to the bank() logic, it will only try to open the bank if you are further than 5 tiles away from the bank.... 

     

    What you need to do is account for those un-intended conditions. 

     

    Here is how I would modify the code:

     

    Whenever bank method is called: 

       > IF we're more than 5 tiles from the bank, then:

          > Attempt to walk to the center of the bank

       > ELSE (we're within 5 tiles of the bank), then:

          >IF the bank is open, then:

             > deposit items and close the bank

          >ELSE (bank is close), then:

             >Open the bank

     

     

    Hopefully this pseudo-code will help you make more sense of the logic going into the script.

    Link to comment
    Share on other sites

    The client should handle most doors, if you have one that it doesn't handle try this.

     

    GameObject closedDoor = getGameObjects().closest(d -> d != null && d.getName().equals("Door") && d.getTile().equals(new Tile(x,y,0))); //where X and Y are the door tile when it is CLOSED, that way it won't try to shut an open door.

    if (door != null) {

       door.interact("Open");

    } else {

       getWalking().walk(bankArea.getRandomTile());

       sleep(1000,2000); //so you don't spam click walking

    }

     

    Edit: getWalking().walk doesn't walk to a location in one step, it walks to the next node in the web in the direction closest to your destination. You have to have this code in a loop until you reach your destination.

    Link to comment
    Share on other sites

    Archived

    This topic is now archived and is closed to further replies.

    ×
    ×
    • Create New...

    Important Information

    We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.