Jump to content

Importing INodeRouteFinder


Waffe

Recommended Posts

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

Link to comment
Share on other sites

	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
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

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