Jump to content

Importing INodeRouteFinder


Recommended Posts

Posted

I need it to set a break condition so i can exit out of my webwalk, to make it less bot like i guess. Any ideas how?

 

Such as 

webwalk(bank)

if bank.isVisible

    interact with bank.

Yes, you don't need the inoderoutefinder to set a break condition, all you have to use is the setbreakcondition method

Posted (edited)
	protected abstract static class WebWalk {

		private static WebWalkEvent e = null;
		private static boolean teleports = true;
		private static boolean skills = false;
		private static boolean quests = false;

		public static void allowTeleports(boolean b) {
			teleports = b;
		}

		public static void allowSkillLinked(boolean b) {
			skills = !b;
		}

		public static void allowQuestLinked(boolean b) {
			quests = !b;
		}

		public static void walk(Area bounds, Area walkArea, int thresh) {
			if (e == null || e.hasFailed() || e.hasFinished()) {
				e = new WebWalkEvent(walkArea);
				PathPreferenceProfile profile = new PathPreferenceProfile();
				profile.setAllowTeleports(teleports);
				profile.ignoreAllSkillLinks(skills);
				profile.ignoreAllQuestLinks(quests);
				e.setPathPreferenceProfile(profile);
				e.setBreakCondition(new Condition() {
					@Override
					public boolean evaluate() {
						if (bounds.contains(s.myPlayer().getPosition()) && s.myPlayer().getPosition().distance(e.getDestination()) <= thresh) {
							return true;
						}
						return false;
					}
				});
				s.execute(e);
			}
		}

		public static void walk(Position pos) {
			if (e == null || e.hasFailed() || e.hasFinished()) {
				e = new WebWalkEvent(pos);
				PathPreferenceProfile profile = new PathPreferenceProfile();
				profile.setAllowTeleports(teleports);
				profile.ignoreAllSkillLinks(skills);
				profile.ignoreAllQuestLinks(quests);
				e.setPathPreferenceProfile(profile);
				e.setBreakCondition(new Condition() {
					@Override
					public boolean evaluate() {
						if (s.myPlayer().getPosition().equals(pos)) {
							return true;
						}
						return false;
					}
				});
				s.execute(e);
			}
		}
	}

I have static instances like this for various classes and helper methods so then I can just do WebWalk.walk(area, area, int); You can make them nonstatic / protected / abstract but I have this in an abstract class that all my tasks extend

Edited by LoudPacks
  • Like 1

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...