saintpaul1 Posted April 19, 2023 Share Posted April 19, 2023 Just wondering if anyone has anything that i can take some inspiration from for the anti pk portion of my script. Quote Link to comment Share on other sites More sharing options...
FushigiBot Posted April 19, 2023 Share Posted April 19, 2023 (edited) Use Async events and break the web walker event when you need to eat. Edited April 19, 2023 by FushigiBot Quote Link to comment Share on other sites More sharing options...
FushigiBot Posted April 19, 2023 Share Posted April 19, 2023 Found something you might be able to use. Someone posted this snippet a while back and I had it saved on my PC. If this snippet is yours, lmk so that I can credit you. Custom class Quote import org.osbot.rs07.api.map.Position; import org.osbot.rs07.event.WebWalkEvent; import org.osbot.rs07.utility.ConditionalSleep2; public class CustomWebWalk extends WebWalkEvent { private AsyncWalkEvent asyncWalkEvent; public CustomWebWalk(Position position) { super(position); } @Override public void onStart() { asyncWalkEvent = new AsyncWalkEvent(); execute(asyncWalkEvent); } @Override public int execute() throws InterruptedException { if (asyncWalkEvent.isLooping()) { // Async is still looping, dont let the web walker execute return 600; } return super.execute(); } @Override public void onEnd() throws InterruptedException { // End the async event and wait for it to finish asyncWalkEvent.setFinished(); ConditionalSleep2.sleep(5000, asyncWalkEvent::hasCompleted); } } Then just set the action here Quote import org.osbot.rs07.api.map.Position; import org.osbot.rs07.event.Event; public class AsyncWalkEvent extends Event { private volatile boolean finished = false; private volatile boolean isLooping = false; public AsyncWalkEvent() { setAsync(); } @Override public int execute() throws InterruptedException { if (canPerformAction()) { // Map destination is far enough away, we can perform some actions isLooping = true; if (shouldDoAction()) { // do action } else { // any other necessary action } isLooping = false; } return 600; } @Override public void onEnd() throws InterruptedException { finished = true; } public boolean isLooping() { return isLooping; } public boolean hasCompleted() { return finished; } private boolean canPerformAction() { // Only allow the actions to start if the map destination is far enough away Position dest = getMap().getDestination(); if (dest == null) return false; int dist = getMap().distance(dest); return dist < 20 && dist > 7; } } 1 Quote Link to comment Share on other sites More sharing options...
saintpaul1 Posted April 19, 2023 Author Share Posted April 19, 2023 1 hour ago, FushigiBot said: Found something you might be able to use. Someone posted this snippet a while back and I had it saved on my PC. If this snippet is yours, lmk so that I can credit you. Custom class Then just set the action here Thanks might come in useful! Not going to use webwalker though gonna use pathwalk Quote Link to comment Share on other sites More sharing options...
FushigiBot Posted April 19, 2023 Share Posted April 19, 2023 10 minutes ago, saintpaul1 said: Thanks might come in useful! Not going to use webwalker though gonna use pathwalk Keep in mind that anything other than the web walker and you have to write object interactions as well (door opening, etc). Since pathwalker uses the local walker, make sure to make it break when the position its trying to get to becomes unreachable. Otherwise it will get stuck trying to reach it from, say, lumby or death's office, if you get pked. Quote Link to comment Share on other sites More sharing options...
saintpaul1 Posted April 19, 2023 Author Share Posted April 19, 2023 7 hours ago, FushigiBot said: Keep in mind that anything other than the web walker and you have to write object interactions as well (door opening, etc). Since pathwalker uses the local walker, make sure to make it break when the position its trying to get to becomes unreachable. Otherwise it will get stuck trying to reach it from, say, lumby or death's office, if you get pked. thanks mate Quote Link to comment Share on other sites More sharing options...
shaba123 Posted June 5, 2023 Share Posted June 5, 2023 (edited) On 4/19/2023 at 2:29 PM, FushigiBot said: Found something you might be able to use. Someone posted this snippet a while back and I had it saved on my PC. If this snippet is yours, lmk so that I can credit you. Custom class Then just set the action here How can i execute the customwebwalk from my main class? import org.osbot.rs07.api.map.Position; import org.osbot.rs07.script.Script; import org.osbot.rs07.script.ScriptManifest; @ScriptManifest(name = "Skeleton", author = "Alek", version = 1.0, info = "", logo = "") public class Main extends Script { CustomWebWalk customWebWalk; @Override public void onStart() { //Code here will execute before the loop is started Position destination = new Position(3144, 3485, 0); // Replace with desired destination coordinates customWebWalk = new CustomWebWalk(destination); customWebWalk.exchangeContext(getBot()); customWebWalk.onStart(); } @Override public int onLoop() throws InterruptedException { if (customWebWalk != null) { execute(customWebWalk); } else { log("Web walk null"); } return 100; //The amount of time in milliseconds before the loop starts over } } Something like this? edit: i got it to execute but in asyncwalkevent class canperformaction is false. private boolean canPerformAction() { // Only allow the actions to start if the map destination is far enough away Position dest = getMap().getDestination(); if (dest == null) return false; int dist = getMap().distance(dest); return dist < 20 && dist > 7; } Im trying to walk to edgeville from grand exchange. Final edit: got it to work Edited June 5, 2023 by shaba123 Quote Link to comment Share on other sites More sharing options...
FushigiBot Posted June 10, 2023 Share Posted June 10, 2023 Glad you got it to work. Sorry, I don't visit the forums often. Quote Link to comment Share on other sites More sharing options...