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.

first script... the chop and burn

Featured Replies

major update, first of all its personalized so its prioritizing willow logs now that i have the level for it, will do more trees after i get the level too.  the biggest challenge on this script is finding a blank spot to light the fire, because its not looking for a long line(which i will do later) i have it look for tiles on the map with 0 objects on them, but this means certain ground decoration that you actually are allowed to light fires on will be avoided.  

import java.util.ArrayList;
import java.util.List;

import org.osbot.script.Script;
import org.osbot.script.ScriptManifest;
import org.osbot.script.rs2.map.Position;
import org.osbot.script.rs2.model.RS2Object;

@ScriptManifest(author="nubsrevenge", info="chops and burns trees", name="chopNburn", version=1.3)
public class ChopNBurn extends Script{
	public ChopNBurn(){}

	int tinderbox = 590, fire = 2716;
	int oak = 12608, willow = 12604;
	int[] trees = {1276, 1278};
	int[] logs = {1511, 1521, 1519};
	RS2Object tree;

	enum State {
		BURN, CHOP, WAIT;
	}

	private State state;

	public void onStart(){

	}

	public int onLoop() throws InterruptedException{
		tree = closestObject(willow);
		if(tree == null)
			tree = closestObject(oak);
		if(tree == null)
			tree = closestObject(trees);
		if(tree != null)
			state = State.CHOP;
		if(inventoryContains(logs) && client.getInventory().contains(tinderbox))
			state = State.BURN;
		if(client.getMyPlayer().getAnimation() != -1)
			state = State.WAIT;
		if(this.closestNPCForName("Ent") != null && this.closestNPCForName("Ent").getPosition().distance(this.client.getMyPlayer().getPosition()) <= 1)
			state = State.CHOP;

		switch (state){
		case WAIT:
			sleep(random(300,400));
			break;
		case CHOP:
			chop();
			break;
		case BURN:
			burn();
			break;
		default:
			log("something wrong");
			stop();
		}
		return random(100, 200);
	}

	public void onMessage(String message) throws InterruptedException{
		if(message.contains("level to use"))
			stop();
		if(message.contains("light a fire here"))
			walkToBlankTile();
	}

	void chop() throws InterruptedException{
		tree.interact("Chop down");
		sleep(random(300,400));
	}

	void burn() throws InterruptedException{
		if(getObjectsAt(client.getMyPlayer().getPosition()).size() != 0)
			walkToBlankTile();
		client.getInventory().interactWithId(tinderbox, "Use", false);
		client.getInventory().interactWithNameThatContains("logs", "Use", null, true);
		sleep(random(700,800));
	}

	void walkToBlankTile() throws InterruptedException{
		int x = client.getMyPlayer().getPosition().getX(), y = client.getMyPlayer().getPosition().getY(), z = client.getMyPlayer().getPosition().getZ();

		for(int i = 10; i > 0; i--){
			for(int j = 1; j < 10; j++){
				if(getObjectsAt(new Position(x+i,y+j,z)).size() == 0){
					walkExact(new Position(x+i,y+j,z));
					return;
				}
			}
		}
	}

	public ArrayList<RS2Object> getObjectsAt(Position p){
		List<RS2Object> objects = client.getCurrentRegion().getObjects();
		ArrayList<RS2Object> list = new ArrayList<RS2Object>();
		for(int x = 0; x < objects.size();x++)
			if(objects.get(x).getPosition().equals(p))
				list.add(objects.get(x));
		return list;
	}

	public boolean inventoryContains(int [] ids){
		for(int x = 0; x < ids.length; x++)
			if(client.getInventory().contains(ids[x]))
				return true;
		return false;
	}

	public void onExit(){
		log("died or stopped");
	}
}

Edited by nubsrevenge

Why this?

void chop() throws InterruptedException{
		tree.interact("Chop down");
		sleep(random(300,400));
	}

You have no null checks.

 

Change to this ; 

void chop() throws InterruptedException{
                if(tree != null);
                if(tree.isVisible());
		tree.interact("Chop down");
		sleep(random(300,400));
	}

You got this but I prefer to check it again for nulls.

if(tree != null)
			state = State.CHOP;

Edited by jonkohoofd

  • Author

 

Why this?

void chop() throws InterruptedException{
		tree.interact("Chop down");
		sleep(random(300,400));
	}

You have no null checks.

 

Change to this ; 

void chop() throws InterruptedException{
                if(tree != null);
                if(tree.isVisible());
		tree.interact("Chop down");
		sleep(random(300,400));
	}

You got this but I prefer to check it again for nulls.

if(tree != null)
			state = State.CHOP;

very true, if somebody took down the targeted tree in the time it took for me to call those it would break.

  • 2 weeks later...
  • Author

updated first post, still has a little trouble with trying to light the next logs without finishing the first and it leaves it on the ground.  now does willow first, then oak trees if no willow trees found, then reg trees.  also avoids ent.  

Edited by nubsrevenge

in the chop method you should find the tree and check for nulls and stuff

RS2Object tree = this.closestObjectForName(area,"Tree"); //dont really know the method w.e. it is you get what i am saying
if(tree != null)
   if(tree.isVisible() && tree.exsists())
       tree.interact("Chop Down");

Something along those lines

also you should make a getState() method in which returns the current state instead of having one global state that you are going off of. and do

switch(getState())
{
case CHOP:
}
  • Author

 

in the chop method you should find the tree and check for nulls and stuff

RS2Object tree = this.closestObjectForName(area,"Tree"); //dont really know the method w.e. it is you get what i am saying
if(tree != null)
   if(tree.isVisible() && tree.exsists())
       tree.interact("Chop Down");

Something along those lines

also you should make a getState() method in which returns the current state instead of having one global state that you are going off of. and do

switch(getState())
{
case CHOP:
}

oh you're right i never did add null checks.  as for a getState(), why make a getter method when the global variable can be seen at all times?

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.