Slakan Posted September 29, 2021 Share Posted September 29, 2021 Good day, Gets the bug in both mirror & stealth mode. I'm having some issues with a bug i'm dealing with (NOTE: re-writing it, so some if..else..if are partly done. I had this bug in the previous version as well). Note that this happens a few times, not always. I have two else..if statements down below. One is for "outside" building where i identity the door, checks it its open/not open. Then it interact with the door, and if range is !null, visable & in position i click the range. Sometimes that failes, so i have failsafe to walk into the rangeArea. Then the next else..if statement takes over. if check that widget is open first, then if its not open it checks if i'm animating. Sometimes when the first else..if fails with finding the interaction with range, it walks into a random position in the area, then it kinda loops as you see down below in the log. Now i have no idea how i'm supposed to deal with this, because all checks (according to my low lvl coding skillz) are valid, but we can't find the interaction cook, even tho we see the range, its in position AND its not null? - Could be i need some random sleep(s) to force it to go a bit slower? All other feedback to how i can improve stuff is also appreciated Short version of the interaction with range from code: if(range !=null && range.isVisible() && range.getPosition().equals(rangePosition)) { if(canReachRange) { //checking that we can reach it from inside. if(range.interact(option) { //clicking range. } else { // here we get, and i dont know how we get here? } } else { // cant reach range. } } [INFO][Bot #1][09/29 02:18:10 PM]: Inventory is full. [INFO][Bot #1][09/29 02:18:10 PM]: Inventory contains raw fish [INFO][Bot #1][09/29 02:18:10 PM]: We are outside building [INFO][Bot #1][09/29 02:18:10 PM]: We can reach behind door. [INFO][Bot #1][09/29 02:18:10 PM]: Door is open, we can get to range as well [INFO][Bot #1][09/29 02:18:10 PM]: Door open, we can reach range and its pretty mutch there [INFO][Bot #1][09/29 02:18:10 PM]: We can't interact cook from outside [INFO][Bot #1][09/29 02:18:12 PM]: We have lvls under 40 in cooking & fishing! [INFO][Bot #1][09/29 02:18:12 PM]: Inventory is full. [INFO][Bot #1][09/29 02:18:12 PM]: Inventory contains raw fish [INFO][Bot #1][09/29 02:18:12 PM]: We are in range area [INFO][Bot #1][09/29 02:18:12 PM]: Widget is closed, we are inside range area! [INFO][Bot #1][09/29 02:18:12 PM]: We are inside, all checks are done. Lets see if we can reach it. [INFO][Bot #1][09/29 02:18:12 PM]: We can get range entity [INFO][Bot #1][09/29 02:18:12 PM]: Cant interact cook else if(outsideBuilding_failsafe.contains(api.myPosition())) { /*We are outside building * Lets see if we can reach mapGet() position behind door. * if we can reach, door is open. Else we have to open door. * */ api.log("We are outside building"); if(api.getMap().canReach(behindDoorPosition)) { /*We can reach behind door. The door is open*/ api.log("We can reach behind door."); /* * Checking if we can reach range entity. * */ if(api.getMap().canReach(range)) { api.log("Door is open, we can get to range as well"); if(range !=null && range.isVisible() && range.getPosition().equals(rangePosition)) { /* * Pretty sure we can get to range * */ api.log("Door open, we can reach range and its pretty mutch there"); if(range.interact("Cook")) { /* * Since we click the range from outside and sleep, * We need to start the else..if in the "in range area" * to check if interface is open first. Since the interface * Will be open when we interact with the range from outside. * */ script.main.sleep(MethodProvider.random(1000,2000)); Sleep.sleepUntil(() -> getMyWidget().isVisible(), 10000); api.log("We can interact from outside"); } else { /*We cant see interaction cook, even tho we can see the range. * We handle it for now with walking inside. * */ api.log("We can't interact cook from outside"); api.walking.walk(rangeArea); } } else { /*We cant get to range*/ api.log("Outside building, we can getMap() to range, but we cant get to it."); } } else { /*Failsafe for opening door and not able to get to range. * We walk in * */ api.log("We cant get to range."); api.walking.walk(rangeArea); } } else { /*We cant reach behind door. Lets handle door.*/ api.log("We cant reach behind door. Handle the door."); } } else if(rangeArea_Failsafe.contains(api.myPosition())) { /*We are inside the range area * NOTE: * We click the range from outside area. We need to * start with checking if the interface is open. * */ api.log("We are in range area"); if(getMyWidget() != null) { /* * Widget is open! * */ api.log("Widget is open"); if(api.getWidgets().interact(270,14,"Cook")) { /* * We can interact with cook, based on id's. Need to remove id's. * */ api.log("Found cook button and pressing"); script.main.sleep(MethodProvider.random(1000,2000)); api.getMouse().moveOutsideScreen(); Sleep.sleepUntil(() -> !api.myPlayer().isAnimating(), 50000); } else { api.log("Couldn't find cook button"); } } else { /* * Widget is closed, we are inside range area.. * */ api.log("Widget is closed, we are inside range area!"); if(!api.myPlayer().isAnimating()) { /* * Just checking if we are not animating. * */ if(range !=null && range.isVisible() && range.getPosition().equals(rangePosition)) { /* * Do all the checks to see if the range is not null, its visble and its the position. * */ api.log("We are inside, all checks are done. Lets see if we can reach it."); if(api.getMap().canReach(range)) { api.log("We can get range entity"); if(range.interact("Cook")) { /* * We are interacting with range * */ api.log("Clicking range"); script.main.sleep(MethodProvider.random(1000,2000)); Sleep.sleepUntil(() -> getMyWidget().isVisible(), 10000); } else { /* * Now i have no idea what is wrong.. * */ api.log("Cant interact cook"); } } else { /* * We are inside, we have checked that the range is there, but we cant reach it. * */ api.log("We can't get range position"); } } else { /* * We cant find it. * */ api.log("We are in range area, not animating and we cant find range"); } } else { /* * We are animating cooking. * */ api.log("Animating cooking"); } } } Quote Link to comment Share on other sites More sharing options...
Slakan Posted September 30, 2021 Author Share Posted September 30, 2021 Fixed the bug for now with: Optional<RS2Object> object = api.objects.getAll().stream().filter(i -> i.getName().equals("Range")).findAny(); Quote Link to comment Share on other sites More sharing options...