Jump to content

WebWalkingEvent.SetBreakCondition?


Recommended Posts

Posted

How do you set a break condition? It says Condition cannot be instantiated as an object?

 

yeah you need to override one of its abstract methods

 

e.g. 

 

Condition c = new Condition() {

   @@Override

   public boolean evaluate() {

            return myPosition().getX() >= 9005;

  }

};

WebWalkingEvent w = new WebWalkingEvent(new Position(1, 2, 3);

w.setBreakCondition©;

 

or you could just do

 

WebWalkingEvent w = new WebWalkingEvent(new Position(1, 2, 3);

 

w.setBreakCondition(new Condition() {

     @@Override

   public boolean evaluate() {

            return myPosition().getX() >= 9005;

   } 

});

Posted (edited)


protected class WebWalk {

private WebWalkEvent e = null;

private boolean teleports = true;

private boolean skills = false;

private boolean quests = false;

public void allowTeleports(boolean b) {

teleports = b;

}

public void allowSkillLinked(boolean b) {

skills = !b;

}

public void allowQuestLinked(boolean b) {

quests = !b;

}

public void walk(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);

profile.checkInventoryForItems(true);

e.setPathPreferenceProfile(profile);

e.setBreakCondition(new Condition() {

@@Override

public boolean evaluate() {

return false;

}

});

api.execute(e);

}

}

}

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...