Jump to content

Goal Based Event system


Recommended Posts

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) {
    public void remove(Goal... goals) {
        for(Goal goal : goals) {
    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)) {
                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) {
            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)
Edited by Septron
  • Like 4
Link to comment
Share on other sites

This topic is now closed to further replies.

  • Recently Browsing   0 members

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