Jump to content

Recommended Posts

Posted (edited)
1 hour ago, sn0wman said:

https://gist.github.com/git-sm/a07058582302b7c8af76a83cd26cdc81 so heres a rewrite with @progamerz edit. Has one issue any suggestions or help more than welcome.

 

To come:

gui with a combobox to select which bank with a nearest option as default.

Again why u used that in the onstart() method? onstart is only for the script to run specific code when started what i sent should be in the onloop.

Edit: not being rude, but do you know basic java? and did you try looking at the tutorial section? would help you out

https://osbot.org/forum/forum/250-tutorials/

 

Edited by progamerz
  • Like 1
Posted (edited)
Spoiler
3 hours ago, sn0wman said:

https://gist.github.com/git-sm/a07058582302b7c8af76a83cd26cdc81 so heres a rewrite with @progamerz edit. Has one issue any suggestions or help more than welcome.

 

To come:

gui with a combobox to select which bank with a nearest option as default.

Issues sorted, rewite is finished should work not tested.

new link : https://gist.github.com/git-sm/fb8f52b2089ec3fb41ea258b67a702cc

TODO: GUI with selection of banks and nearest options.

 

Edited by sn0wman
link edit
  • 6 months later...
Posted

Is it me or is this way over complicated? This is what I use...

private Area closestBank;
    
public void onStart() {     
    closestBank = getClosestBank(); 
}
private Area getClosestBank(){

    Area SHILOBANK = new Area(new Position(2854,2957,0),new Position(2850,2951,0));
    Area PORTSARIMBANK = new Area(new Position(3047,3233,0),new Position(3043,3237,0));

    org.osbot.rs07.api.map.Area[] bankAreas = {
            Banks.AL_KHARID, Banks.ARCEUUS_HOUSE, Banks.ARDOUGNE_NORTH, Banks.ARDOUGNE_SOUTH, Banks.CAMELOT, Banks.CANIFIS,
            Banks.CASTLE_WARS, Banks.CATHERBY, Banks.DRAYNOR, Banks.DUEL_ARENA, Banks.EDGEVILLE, Banks.FALADOR_EAST, Banks.FALADOR_WEST,
            Banks.GNOME_STRONGHOLD, Banks.GRAND_EXCHANGE, Banks.HOSIDIUS_HOUSE, Banks.LOVAKENGJ_HOUSE, Banks.LOVAKITE_MINE,
            Banks.LUMBRIDGE_LOWER, Banks.LUMBRIDGE_UPPER, Banks.PEST_CONTROL, Banks.PISCARILIUS_HOUSE, Banks.SHAYZIEN_HOUSE,
            Banks.TZHAAR, Banks.VARROCK_EAST, Banks.VARROCK_WEST, Banks.YANILLE,SHILOBANK,PORTSARIMBANK
    };

    Area closestBank = null;

    for (int i = 0; i < bankAreas.length; i++) {
        if (closestBank == null) {
            closestBank = bankAreas[i];
        } else if (myPosition().distance(bankAreas[i].getRandomPosition()) < myPosition().distance(closestBank.getRandomPosition())) {
            closestBank = bankAreas[i];
        }
    }
    return closestBank;
}
  • Like 1
Posted
18 minutes ago, Cloxygen said:

Is it me or is this way over complicated? This is what I use...


private Area closestBank;
    
public void onStart() {     
    closestBank = getClosestBank(); 
}

private Area getClosestBank(){

    Area SHILOBANK = new Area(new Position(2854,2957,0),new Position(2850,2951,0));
    Area PORTSARIMBANK = new Area(new Position(3047,3233,0),new Position(3043,3237,0));

    org.osbot.rs07.api.map.Area[] bankAreas = {
            Banks.AL_KHARID, Banks.ARCEUUS_HOUSE, Banks.ARDOUGNE_NORTH, Banks.ARDOUGNE_SOUTH, Banks.CAMELOT, Banks.CANIFIS,
            Banks.CASTLE_WARS, Banks.CATHERBY, Banks.DRAYNOR, Banks.DUEL_ARENA, Banks.EDGEVILLE, Banks.FALADOR_EAST, Banks.FALADOR_WEST,
            Banks.GNOME_STRONGHOLD, Banks.GRAND_EXCHANGE, Banks.HOSIDIUS_HOUSE, Banks.LOVAKENGJ_HOUSE, Banks.LOVAKITE_MINE,
            Banks.LUMBRIDGE_LOWER, Banks.LUMBRIDGE_UPPER, Banks.PEST_CONTROL, Banks.PISCARILIUS_HOUSE, Banks.SHAYZIEN_HOUSE,
            Banks.TZHAAR, Banks.VARROCK_EAST, Banks.VARROCK_WEST, Banks.YANILLE,SHILOBANK,PORTSARIMBANK
    };

    Area closestBank = null;

    for (int i = 0; i < bankAreas.length; i++) {
        if (closestBank == null) {
            closestBank = bankAreas[i];
        } else if (myPosition().distance(bankAreas[i].getRandomPosition()) < myPosition().distance(closestBank.getRandomPosition())) {
            closestBank = bankAreas[i];
        }
    }
    return closestBank;
}

 

Nice :)

Posted
22 minutes ago, Cloxygen said:

Is it me or is this way over complicated? This is what I use...

Although yours is simpler, both solutions are incorrect as you are calculating straight line distance instead of actual path distance. So it may return a bank that is not actually closest (you may have to walk around a bunch of stuff to get there).

Why do you need to know which bank is closest anyway?

If you use web walking with an Area[] it will walk to the closest Area in the array, so:

getWalking().webWalk(bankAreas)

will walk to the closest bank.

  • Like 2
Posted (edited)
51 minutes ago, Explv said:

Although yours is simpler, both solutions are incorrect as you are calculating straight line distance instead of actual path distance. So it may return a bank that is not actually closest (you may have to walk around a bunch of stuff to get there).

Why do you need to know which bank is closest anyway?

If you use web walking with an Area[] it will walk to the closest Area in the array, so:

getWalking().webWalk(bankAreas)

will walk to the closest bank.

Didn't know it would do that, thanks. would this work if you're under ground as well? Also how would you check if your player is in the bank? you would have to loop through the whole array constantly right?

Edited by Cloxygen
Posted
22 minutes ago, Cloxygen said:

Didn't know it would do that, thanks. would this work if you're under ground as well? Also how would you check if your player is in the bank? you would have to loop through the whole array constantly right?

If webwalking works there, yes. In regards to your second question, I can't remember if osbot has an isInBank method but if it doesn't, why would you need to check the area. Just check a bank object like a booth or a banker exists.

  • 2 years later...

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...