progamerz Posted November 6, 2017 Share Posted November 6, 2017 (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 November 6, 2017 by progamerz 1 Quote Link to comment Share on other sites More sharing options...
sn0wman Posted November 6, 2017 Share Posted November 6, 2017 (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 November 6, 2017 by sn0wman link edit Quote Link to comment Share on other sites More sharing options...
Charlotte Posted November 6, 2017 Share Posted November 6, 2017 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. You might want to do some null checks if possible. 1 Quote Link to comment Share on other sites More sharing options...
Cloxygen Posted May 26, 2018 Share Posted May 26, 2018 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; } 1 Quote Link to comment Share on other sites More sharing options...
H0rn Posted May 26, 2018 Share Posted May 26, 2018 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 Quote Link to comment Share on other sites More sharing options...
Explv Posted May 26, 2018 Share Posted May 26, 2018 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. 2 Quote Link to comment Share on other sites More sharing options...
Cloxygen Posted May 26, 2018 Share Posted May 26, 2018 (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 May 26, 2018 by Cloxygen Quote Link to comment Share on other sites More sharing options...
HeyImJamie Posted May 27, 2018 Share Posted May 27, 2018 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. Quote Link to comment Share on other sites More sharing options...
Cloxygen Posted May 27, 2018 Share Posted May 27, 2018 32 minutes ago, HeyImJamie said: 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. that works i guess Quote Link to comment Share on other sites More sharing options...
hellcatz Posted September 16, 2020 Share Posted September 16, 2020 this might be crazy but after 3 years this post helped my with my problem opening the bank i got it to work now you guy`s are awsome!!!! Quote Link to comment Share on other sites More sharing options...