Septron Posted July 2, 2013 Share Posted July 2, 2013 (edited) This is just something I threw together really quick import org.osbot.script.rs2.skill.Skill; public class Goal { public final Skill skill; public final int target; public final GoalEvent event; public Goal(Skill skill, int target, GoalEvent event) { this.skill = skill; this.target = target; this.event = event; } } import org.osbot.script.Script; public abstract class GoalEvent { private final Script script; public GoalEvent(Script script) { this.script = script; } public abstract void onGoalReached(); } import java.util.ArrayList; import java.util.Iterator; import java.util.List; import org.osbot.script.Script; public class HandleGoals { private final List<Goal> goals; private final Script script; public HandleGoals(Script script) { this.script = script; this.goals = new ArrayList<>(); } public void provide(Goal... goals) { for(Goal goal : goals) { if(!this.goals.contains(goal)) this.goals.add(goal); } } public void remove(Goal... goals) { for(Goal goal : goals) { if(this.goals.contains(goal)) this.goals.remove(goal); } } public boolean check() { Iterator<Goal> iterator = this.goals.iterator(); while(iterator.hasNext()) { Goal goal = iterator.next(); if(goal.target >= this.script.client.getSkills().getCurrentLevel(goal.skill)) { goal.event.onGoalReached(); this.remove(goal); return true; } } return false; } } Example Implementation... //put this anywhere in the script class private HandleGoals handle = null; //in your onStart put this... this.handle = new HandleGoals(this); handle.provide(new Goal(Skill.ATTACK, 99, new GoalEvent(this) { @Override public void onGoalReached() { log("I have reached my goal, tell me what to do now in this method"); } })); //in your onLoop put this... if(handle != null) handle.check(); Edited July 2, 2013 by Septron 4 Link to comment Share on other sites More sharing options...
Skype Posted July 2, 2013 Share Posted July 2, 2013 Very nice, I'll save that Thanks! Link to comment Share on other sites More sharing options...
Prayer Posted July 2, 2013 Share Posted July 2, 2013 Pretty sweet well made septron. Link to comment Share on other sites More sharing options...
Jordan Posted July 2, 2013 Share Posted July 2, 2013 Very nice. Link to comment Share on other sites More sharing options...
Peter Posted July 2, 2013 Share Posted July 2, 2013 So tell me what does this do. 1 Link to comment Share on other sites More sharing options...
Skype Posted July 2, 2013 Share Posted July 2, 2013 So tell me what does this do. Forgive me if I'm wrong, but it checks if you reached a certain goal (see example, 99 attack), and when that goal is reached, you can paste your own code in the onGoalReached method's body to do something Link to comment Share on other sites More sharing options...
Septron Posted July 2, 2013 Author Share Posted July 2, 2013 Forgive me if I'm wrong, but it checks if you reached a certain goal (see example, 99 attack), and when that goal is reached, you can paste your own code in the onGoalReached method's body to do something Bingo. 2 Link to comment Share on other sites More sharing options...