Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package Base;
- //HA ITS UPPERCASE B YOU SCRUBS
- import java.util.ArrayList;
- import java.util.List;
- import java.util.Random;
- import org.osbot.script.Script;
- import org.osbot.script.rs2.model.RS2Object;
- public class MainScript extends Script {
- public enum State{
- IDLE,OBSERVE,GO_TO_AREA,CLICK_ON_RESOURCE,WAIT_FOR_RESOURCE,QUEUE_NEXT_ACTION,DROP_ITEMS;
- }
- State sState = State.IDLE;
- public void onStart(){
- }
- public void preExecution(){
- if(this.client.getInventory().getFullSlots() == 28){
- sState = State.DROP_ITEMS;
- }
- if(sState.equals(State.IDLE)){
- if(myPlayer().isInArea(null)){
- //Main area replace null with an area object
- sState = State.OBSERVE;
- }else{
- sState = State.GO_TO_AREA;
- }
- }
- }
- @Override
- public int onLoop(){
- runStates();
- return 0;
- }
- Random r = new Random();
- Timer pauser = new Timer(0);
- RS2Object myTargetObject = null;
- private void runStates() {
- String targetName = "Tree/Vein/FishSpot";
- switch(sState){
- case OBSERVE:
- List<RS2Object> targets = closestObjectListForName(targetName);
- int distance = 20;
- RS2Object fillTarget = null;
- int targetDistance = 0;
- for(int i = 0; i < targets.size(); i++){
- fillTarget = targets.get(i);
- targetDistance = fillTarget.getPosition().distance(myPosition());
- if(targetDistance < distance){
- myTargetObject = fillTarget;
- }
- }
- if(fillTarget != null && !myPlayer().isAnimating() && !myPlayer().isMoving()){
- sState = State.CLICK_ON_RESOURCE;
- //If you haven't figured this state case out
- //we're just searching for the closest object.
- //you can do this many ways for the next step.
- //Either make a method that returns the state
- //and pass it through here, make a boolean
- //and if it becomes true, push to the next desired state.
- //you can do MANY MANY things with this. Even surpass premium
- //script capability with this, but since most of them are lame
- //scrubs in the first place, we don't have to worry about that.
- //it's all you here. No offense. Imagination is key.
- }
- break;
- case CLICK_ON_RESOURCE:
- //So here we have to verify if the object exists and then click on it.
- if(myTargetObject != null && myTargetObject.exists()){
- interactWithObject();
- sState = State.WAIT_FOR_RESOURCE;
- }else{
- sState = State.OBSERVE;
- }
- break;
- case WAIT_FOR_RESOURCE:
- if(myInventoryCountChanged() || objectIsGone()){
- sState = State.OBSERVE;
- }else{
- if(myPlayer().isAnimating()){
- sState = State.QUEUE_NEXT_ACTION;
- }
- }
- break;
- //That's all i really care to share atm. But as you can see, if you are
- //specific in the switching of states, you can chain many together
- //to do sequentially performed checks.
- case DROP_ITEMS:
- break;
- case GO_TO_AREA:
- break;
- case QUEUE_NEXT_ACTION:
- break;
- }
- }
- public void interactWithObject(){
- }
- public boolean myInventoryCountChanged(){
- return false;
- }
- public boolean objectIsGone(){
- return false;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment