Jump to content
View in the app

A better way to browse. Learn more.

OSBot :: 2007 OSRS Botting

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Goal Based Event system

Featured Replies

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 by Septron

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

  • Author

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.

Guest
This topic is now closed to further replies.

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.