ChrisJ Posted July 2, 2018 Share Posted July 2, 2018 Hello everyone. This is a bug report / call for help to make my script work. In the abyss, i run RS2Object.interact() on one of the obstacles in the outer ring to go through. Sometimes this method is called on an unlucky moment and the player is already in the inner ring. When this happens the bot keeps clicking on the minimap every ~5 seconds to go towards the object, which obviously wont work because it cannot reach it. The log after the interact() method is never called untill i stop the script. I had a look at the source for the interact() method, and took that + added setMaximumAttempts() on the interactionEvent. final InteractionEvent interactionEvent = new InteractionEvent(closest, outerRingObject.getObjectOption()); interactionEvent.setMaximumAttempts(3); this.getBot().getEventExecutor().execute(interactionEvent); failed = !interactionEvent.hasFinished(); It still entered an endless loop on the execute()... I tried starting a seperate thread to set the interactionEvent as finished when the player ended up in the inner ring.. Also didnt help: new Thread(() -> { long start = System.currentTimeMillis(); while (!interactionEvent.hasFinished() && (System.currentTimeMillis() - start < 25000)) { if (getState() == State.INNER_RING) { interactionEvent.interrupt(); interactionEvent.setFinished(); } else { w8(2500 + random(500)); } } }).start(); Made the script override onMessage() to set a waitingForObstacle boolean when the message pops up that we try to mine/distract/go through, and set it to false again when the succes or fail message pops up. To make sure we dont call interact() while mining/distracting or w/e. Checked that boolean just before starting the interactionEvent if (waitingForObstacle) { return 450 + random(450); } And added another check that we're in the outer ring and not the inner ring if (getState().equals(State.OUTER_RING)) { ... Still it ended up trying to interact with the object in the outer ring while being in the inner ring... Any help is appreciated! Quote Link to comment Share on other sites More sharing options...
IDontEB Posted July 2, 2018 Share Posted July 2, 2018 I'm not exactly sure what the structure of your script looks like but can you try switching final InteractionEvent interactionEvent = new InteractionEvent(closest, outerRingObject.getObjectOption()); interactionEvent.setMaximumAttempts(3); this.getBot().getEventExecutor().execute(interactionEvent); to: final InteractionEvent interactionEvent = new InteractionEvent(closest, outerRingObject.getObjectOption()); interactionEvent.setMaximumAttempts(3); log("Event has finished = " + (this.getBot().getEventExecutor().execute(interactionEvent).hasFinished())); Then check the logger whether you're getting that message or not. Quote Link to comment Share on other sites More sharing options...
ChrisJ Posted July 2, 2018 Author Share Posted July 2, 2018 @IDontEB Yea that's equivalent to what i did to test. It usually runs fine but sometimes gets stuck in the .execute(interactionEvent) part and won't log the message. Quote Link to comment Share on other sites More sharing options...
Alek Posted July 2, 2018 Share Posted July 2, 2018 I guarantee you that InteractionEvent does not have an infinite loop, if thats the question you were asking by reading your title. Quote Link to comment Share on other sites More sharing options...
IDontEB Posted July 2, 2018 Share Posted July 2, 2018 33 minutes ago, ChrisJ said: @IDontEB Yea that's equivalent to what i did to test. It usually runs fine but sometimes gets stuck in the .execute(interactionEvent) part and won't log the message. Either somewhere else your script just reloops that one part or the final on the declaration is interfering with the how Osb executes events. Quote Link to comment Share on other sites More sharing options...
CJ7 Posted July 2, 2018 Share Posted July 2, 2018 This might be really dumb, but you can't you put your code in an if(canReach && pos == outerring)? Wouldn't this stop clicking the object? To be sure, you could put a break condition in your event, to stop it if the player is in the outerring/object is no longer reachable. So basically: If (canReach && pos == outerring) { //only execute event if we can reach the object and we're in the outerring Interaction event // set the interaction event to manually stop the event if we're in the innerring/object is not reachable } I just started scripting myself, don't know if this will help you! Goodluck! Quote Link to comment Share on other sites More sharing options...
HeyImJamie Posted July 2, 2018 Share Posted July 2, 2018 20 minutes ago, CJ7 said: This might be really dumb, but you can't you put your code in an if(canReach && pos == outerring)? Wouldn't this stop clicking the object? To be sure, you could put a break condition in your event, to stop it if the player is in the outerring/object is no longer reachable. So basically: If (canReach && pos == outerring) { //only execute event if we can reach the object and we're in the outerring Interaction event // set the interaction event to manually stop the event if we're in the innerring/object is not reachable } I just started scripting myself, don't know if this will help you! Goodluck! Considering you're using a state method, couldn't you just break the state if the outer loop method is run if you're in the inner loop? I'm not quite sure how or why your state is executing as you're not showing us the code, but I'd assume that would solve it. case OUTER_LOOP: if (INNER_LOOP_AREA.contains(Player)) { break; } // rest of code break; Quote Link to comment Share on other sites More sharing options...
Hel Posted July 3, 2018 Share Posted July 3, 2018 config checks, correct area checks nd you'll be sweet. Quote Link to comment Share on other sites More sharing options...
FrostBug Posted July 3, 2018 Share Posted July 3, 2018 Same problem was resolved here (Interact with mousedestination) Quote Link to comment Share on other sites More sharing options...
ChrisJ Posted July 3, 2018 Author Share Posted July 3, 2018 Thanks for the suggestions although Im pretty sure that it just doesnt exit the interact() method. If this is true then an OSBot dev should look at it, so Ill try to reproduce it consistently in a seperate script. Quote Link to comment Share on other sites More sharing options...