matthew2112 Posted April 13, 2020 Share Posted April 13, 2020 RS2Object logbalance = getObjects().closest("Log balance"); RS2Object logbalance2 = getObjects().closest(new Filter<RS2Object>() { @Override public boolean match(RS2Object rs2Object) { return rs2Object != null && rs2Object.getName().equals("Log balance"); } }); RS2Object obstaclenet = getObjects().closest("Obstacle net"); RS2Object treebranch = getObjects().closest("Tree branch"); RS2Object treebranch2 = getObjects().closest(new Filter<RS2Object>() { @Override public boolean match(RS2Object rs2Object) { return rs2Object != null && rs2Object.getName().equals("Tree branch"); } }); RS2Object balancingrope = getObjects().closest("Balancing rope"); RS2Object obstaclepipe = getObjects().closest("Obstacle pipe"); /*if (logbalance2 != null){ log("logbalance2 exists"); if (logbalance2.interact("Walk-across")) { new ConditionalSleep(10000, 1000) { @Override public boolean condition() throws InterruptedException { return myPlayer().isAnimating(); } }.sleep(); log("Walking logbalance2"); } if (obstaclenet !=null){ log("obstaclenet exists"); if (obstaclenet.interact("Climb-over")) new ConditionalSleep(10000, 1000) { @Override public boolean condition() throws InterruptedException { return myPlayer().isMoving(); } }.sleep(); log("Climb-over obstaclenet"); } if (treebranch2 !=null){ log("treebranch2 exists"); if (treebranch2.interact("Climb")) new ConditionalSleep(10000, 1000) { @Override public boolean condition() throws InterruptedException { return myPlayer().isAnimating(); } }.sleep(); log("Climb Treebranch"); } }*/ The problem i am running into is with treebranch2. This is the 3rd obstacle in the gnome agility course. You cross the log then the obstacle net then you have to climb up a tree branch. When i run all three of the actions together it never clicks on the treebranch. Once my player climbus op the obstacle net. The treebranch is never identified as in the debugger doesn't log "treebranch2 exists" So i assume the problem as to be starting here. However, when i run just that snippet of script involving treebranch2 alone it clicks the treebranch2 just fine. Any help/advice would be greatly appreciated as i am new and i think this could be a fun hobby. Also is there some action i should be using with my conditional sleeps that is different than .isanimating. Quote Link to comment Share on other sites More sharing options...
BravoTaco Posted April 14, 2020 Share Posted April 14, 2020 (edited) I would recommend when doing agility scripts to make it more task based. Or checkpoint based. IE remember the last obstacle you used, than with that knowledge move onto the next obstacle until interacting with it is successful than set that obstacle as the last completed obstacle and repeat. The example below will have to be restructured as I have no clue in what order the obstacle were going to be performed, nor did I know if that is all the obstacles. As for it not interacting with the second tree branch. The current way you have the variables being set is one after the other. So the second tree branch might not be available as it is not loaded yet or some other issue. Try after interacting with the first branch, use a conditional sleep to set the second branch with a max time-out of like 10 seconds. Quote private Obstacle lastObstacle; private Obstacle currentObstacle = null; @Override public int onLoop() throws InterruptedException { if (lastObstacle == null) { lastObstacle = Obstacle.LOGBALANCE; currentObstacle = lastObstacle; } if (currentObstacle != null && useCurrentObstacle(currentObstacle)) { log("Used obstacle."); currentObstacle = setNextObstacle(currentObstacle); } return random(800, 3000); } private boolean useCurrentObstacle(Obstacle currentObstacle) { RS2Object object = getObjects().closest(currentObstacle.getIdentifier()); final RS2Object[] nextObstacleObject = {null}; if (object == null) { log(String.format("Object NULL: [{%s}]", currentObstacle.getIdentifier())); return false; } else { if (object.interact(currentObstacle.getAction())) { new ConditionalSleep(10000, 100) { @Override public boolean condition() throws InterruptedException { final Obstacle nextObstacle = setNextObstacle(currentObstacle); RS2Object rs2Object = null; if (nextObstacle != null) rs2Object = nextObstacle.rs2Object(getBot().getMethods()); if (rs2Object != null) { nextObstacleObject[0] = rs2Object; return true; } return false; } }.sleep(); return nextObstacleObject[0] != null; } } return false; } private Obstacle setNextObstacle(Obstacle currentObstacle) { switch (currentObstacle) { case LOGBALANCE: return Obstacle.OBSTACLENET; case LOGBALANCE2: return Obstacle.LOGBALANCE; case TREEBRANCH1: return Obstacle.TREEBRANCH2; case TREEBRANCH2: return Obstacle.LOGBALANCE2; default: return null; } } private enum Obstacle { LOGBALANCE("Walk-across", "Log balance"), LOGBALANCE2("Walk-across", "Log balance"), OBSTACLENET("Climb-over", "Obstacle net"), TREEBRANCH1("Climb", "Tree branch"), TREEBRANCH2("Climb", "Tree branch"); String action, identifier; Obstacle(String action, String identifier) { this.action = action; this.identifier = identifier; } public String getAction() { return action; } public String getIdentifier() { return identifier; } public RS2Object rs2Object(MethodProvider mp) { return mp.getObjects().closest(this.identifier); } } Edited April 14, 2020 by BravoTaco Quote Link to comment Share on other sites More sharing options...
matthew2112 Posted April 14, 2020 Author Share Posted April 14, 2020 13 hours ago, BravoTaco said: I would recommend when doing agility scripts to make it more task based. Or checkpoint based. IE remember the last obstacle you used, than with that knowledge move onto the next obstacle until interacting with it is successful than set that obstacle as the last completed obstacle and repeat. The example below will have to be restructured as I have no clue in what order the obstacle were going to be performed, nor did I know if that is all the obstacles. As for it not interacting with the second tree branch. The current way you have the variables being set is one after the other. So the second tree branch might not be available as it is not loaded yet or some other issue. Try after interacting with the first branch, use a conditional sleep to set the second branch with a max time-out of like 10 seconds. BravoTaco, i appreciate the feedback as i am very new to scripting. Not sure if all of your reply took a lot of time or not. I was not familiar with the way you coded it. I only used if states. However, after reviewing your code, i was able to make it work in OSBOT. This is the correct order of the Obstacles at the gnome agility course with each of them having their own name. I got the script to complete a full lap around the agility course!!! That was super exciting. The timing seems off between starting the interactions if and clicking onto the next interaction. Example When two obstacles are on the same z plane. Such as LOGBALANCE and OBSTACLENET, the script will interact with LOGBALANCE and then immediate attempt to climb the OBSTACLENET while still crossing the LOGBALANCE. This leads the script to finish crossing the LOGBALANCE and having to wait for the script to cycle back through before it again attempts to Climb the OBSTACLENET. Any input/suggestions would be greatly appreciated. private Obstacle setNextObstacle(Obstacle currentObstacle) { switch (currentObstacle) { case LOGBALANCE: return Obstacle.OBSTACLENET; case OBSTACLENET: return Obstacle.TREEBRANCH1; case TREEBRANCH1: return Obstacle.BALANCINGROPE; case BALANCINGROPE: return Obstacle.TREEBRANCH2; case TREEBRANCH2: return Obstacle.OBSTACLENET2; case OBSTACLENET2: return Obstacle.OBSTACLEPIPE; default: return null; } } private enum Obstacle { LOGBALANCE("Walk-across", "Log balance"), OBSTACLENET("Climb-over", "Obstacle net"), TREEBRANCH1("Climb", "Tree branch"), BALANCINGROPE("Walk-on", "Balancing rope"), TREEBRANCH2("Climb-down", "Tree branch"), OBSTACLENET2("Climb-over", "Obstacle net"), OBSTACLEPIPE("Squeeze-through", "Obstacle pipe"); Quote Link to comment Share on other sites More sharing options...
Ace99 Posted April 14, 2020 Share Posted April 14, 2020 Check this thread out. This shows what @BravoTaco was talking about by making an "object next" and an "object last." You can keep your enum instead of the two string arrays in the link. Quote Link to comment Share on other sites More sharing options...
BravoTaco Posted April 15, 2020 Share Posted April 15, 2020 9 hours ago, matthew2112 said: BravoTaco, i appreciate the feedback as i am very new to scripting. Not sure if all of your reply took a lot of time or not. I was not familiar with the way you coded it. I only used if states. However, after reviewing your code, i was able to make it work in OSBOT. This is the correct order of the Obstacles at the gnome agility course with each of them having their own name. I got the script to complete a full lap around the agility course!!! That was super exciting. The timing seems off between starting the interactions if and clicking onto the next interaction. Example When two obstacles are on the same z plane. Such as LOGBALANCE and OBSTACLENET, the script will interact with LOGBALANCE and then immediate attempt to climb the OBSTACLENET while still crossing the LOGBALANCE. This leads the script to finish crossing the LOGBALANCE and having to wait for the script to cycle back through before it again attempts to Climb the OBSTACLENET. Any input/suggestions would be greatly appreciated. For it trying to click the next interaction before the last interaction is done. You will have to modify the useCurrentObstacle() method to accommodate for this. Try adding a check to see if the player is animating before returning true. Ex. Quote private boolean useCurrentObstacle(Obstacle currentObstacle) { RS2Object object = getObjects().closest(currentObstacle.getIdentifier()); final RS2Object[] nextObstacleObject = {null}; if (object == null) { log(String.format("Object NULL: [{%s}]", currentObstacle.getIdentifier())); return false; } else { if (object.interact(currentObstacle.getAction())) { new ConditionalSleep(10000, 100) { @Override public boolean condition() throws InterruptedException { final Obstacle nextObstacle = setNextObstacle(currentObstacle); RS2Object rs2Object = null; if (nextObstacle != null) rs2Object = nextObstacle.rs2Object(getBot().getMethods()); if (rs2Object != null && !myPlayer().isAnimating()) { // Added the check here. nextObstacleObject[0] = rs2Object; return true; } return false; } }.sleep(); return nextObstacleObject[0] != null; } } return false; } Quote Link to comment Share on other sites More sharing options...
matthew2112 Posted April 15, 2020 Author Share Posted April 15, 2020 @BravoTaco Thanks! You have taught me a lot! Quote Link to comment Share on other sites More sharing options...
BravoTaco Posted April 16, 2020 Share Posted April 16, 2020 10 hours ago, matthew2112 said: @BravoTaco Thanks! You have taught me a lot! Np. Feel free to pm me if ya need help with anything else Quote Link to comment Share on other sites More sharing options...