Jump to content

Ex0rcism

Recommended Posts

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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

2 hours ago, sn0wman said:
  Hide contents

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.

 

7oB74NqfSnCPC3wTbqWtKQ.png 

You might want to do some null checks if possible.

  • Like 1
Link to comment
Share on other sites

  • 6 months later...

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
Link to comment
Share on other sites

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

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

  • 2 years later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

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