kushroom Posted January 8, 2017 Share Posted January 8, 2017 Hey guys im working on a ge cooker, where I have tiles closest to the bank at the ge that are able to have fires lighted at. When i run the code to detect the fires in the area around the bank it does that fine and logs all of them. So i try and take and check those locations vs the locations of lite fires so the script knows where to make a new fire that is closest to the bank, here is my variables and code commented for easy reading. If anyone could help me detect which free spaces in my array of positions that do not contain a ground object so I can have it light fires, that would be more than appreicated! Thanks as always guys! Variables: private final Area fireZone = new Area(3161,3486,3168,3493); private ArrayList<Position> positions = new ArrayList<Position>(); private final Position[] fireSpots = { new Position(3166,3492,0), new Position(3163, 3492, 0), new Position(3162, 3492, 0), new Position(3162, 3491, 0), new Position(3161, 3490, 0), new Position(3161, 3489, 0), new Position(3162, 3488, 0), new Position(3162, 3487, 0), new Position(3163, 3487, 0), new Position(3164, 3486, 0), new Position(3165, 3486, 0), new Position(3166, 3487, 0), new Position(3167, 3487, 0), new Position(3167, 3488, 0), new Position(3168, 3489, 0), new Position(3168, 3490, 0), new Position(3167, 3491, 0), new Position(3167, 3492, 0), new Position(3166, 3492, 0), new Position(3165, 3493, 0), new Position(3164, 3493, 0), new Position(3163, 3492, 0)}; private boolean done = false; Methods: private Position getNearestFree(){ if(done){ try { sleep(5000); } catch (InterruptedException e) { e.printStackTrace(); } return null; } else { //start of else statement removeAll(positions); //Emptys the arraylist to ensure that there is no previous saved variables ArrayList<RS2Object> fires = new ArrayList<RS2Object>(); for(Position p : fireSpots){ positions.add(p); //Adds the spots in which you can light logs from an array to an array list } List<RS2Object> fire2 = getObjects().getAll(); for(int i=0;i<fire2.size();i++){ if(fireZone.contains(fire2.get(i)) && fire2.get(i).getName().equals("Fire")){ fires.add(fire2.get(i)); //Adds fires from fireZone (Space around ge) } } for(int i=0;i<fires.size();i++){ //Remove fires that are lit from array of positions that are lightable for(int j=0;j<positions.size();j++){ if(fires.get(i).getPosition() == positions.get(j)){ positions.remove(j); } } } int dis = 513; int temp = 513; int objIndex = 0; for(int i=0;i<positions.size();i++){ temp = map.distance(positions.get(i)); if(temp < dis){ dis = temp; objIndex = i; } } done = true; return positions.get(objIndex); } //end of else statement } private void removeAll(ArrayList<?> objs){ if(objs.size() > 0){ for(int i=0;i<objs.size();i++){ objs.remove(i); } } } Quote Link to comment Share on other sites More sharing options...
Muffins Posted January 8, 2017 Share Posted January 8, 2017 use onMessage to detect if a fire can be lit in that spot 1 Quote Link to comment Share on other sites More sharing options...
Team Cape Posted January 8, 2017 Share Posted January 8, 2017 theres only 4 spots you need to add in manually. then there's a small area that surrounds the center of the GE that you cant put fires in. no need to lay out each individual usable positions. and if you missed one and the bot tries to use it, add it to a list of invalid positions. Quote Link to comment Share on other sites More sharing options...
kushroom Posted January 8, 2017 Author Share Posted January 8, 2017 There is about 12 spots in which you cannot light a fire. And as for a message listener, that seems to be more work than just finding what tiles are available instead of running around looking alike a bot after everytime you bank. Quote Link to comment Share on other sites More sharing options...