Jump to content

nubsrevenge

Members
  • Posts

    42
  • Joined

  • Last visited

  • Feedback

    0%

Profile Information

  • Gender
    Male

nubsrevenge's Achievements

Bronze Poster

Bronze Poster (2/10)

4

Reputation

  1. 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?
  2. 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.
  3. very true, if somebody took down the targeted tree in the time it took for me to call those it would break.
  4. 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"); } }
×
×
  • Create New...