Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package source;
- import org.osbot.script.Script;
- import org.osbot.script.ScriptManifest;
- import org.osbot.script.rs2.map.Position;
- import org.osbot.script.rs2.model.GroundItem;
- import org.osbot.script.rs2.model.RS2Object;
- @ScriptManifest(author = "Zach (LifezHatred)", info = "Chops yews man", name = "XYewCutter", version = 1.0)
- public class Main extends Script {
- public long lastRun = 0;
- public Position lastClick = null;
- public int randomDistance = 0;
- public int treeId = 12611;
- public int logId = 0;
- public int axeId = 6739;
- public int axeHeadId = 6743;
- public boolean atTrees = false;
- public RS2Object tree = null;
- public boolean checkGround() {
- GroundItem axeHead = closestGroundItem(axeHeadId);
- GroundItem nest = closestGroundItemForName("Bird nest");
- if(axeHead != null && axeHead.exists()) {
- try {
- axeHead.interact("Take");
- return true;
- } catch (InterruptedException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
- if(nest != null && nest.exists()) {
- try {
- nest.interact("Take");
- return true;
- } catch (InterruptedException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
- return false;
- }
- public int onLoop() {
- if(checkGround()) {
- return 3000;
- }
- if(myPlayer().getClient().getInventory().getEmptySlots() == 0) {
- tree = null;
- atTrees = false;
- try {
- if(walkToLocation(new Position(2809, 3441, 0))) {
- RS2Object bankBooth = closestObjectForName("Bank booth");
- if(client.getBank().isOpen()) {
- try {
- client.getBank().depositAllExcept(axeId);
- sleep(1000);
- client.getBank().close();
- return 2000;
- } catch (InterruptedException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- } else {
- if(bankBooth.isVisible()) {
- try {
- bankBooth.interact("Bank");
- } catch (InterruptedException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- return 1200 + (int) (Math.random() * 600);
- } else {
- try {
- client.moveCameraToEntity(bankBooth);
- } catch (InterruptedException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
- }
- }
- } catch (InterruptedException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- } else {
- if(!atTrees) {
- try {
- atTrees = walkToLocation(new Position(2769, 3430, 0));
- } catch (InterruptedException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- } else {
- if(tree == null || !tree.exists()) {
- tree = closestObject(treeId);
- try {
- tree.interact("Chop down");
- return 2400;
- } catch (InterruptedException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- } else if(myPlayer().getAnimation() > 0) {
- try {
- sleep(600);
- } catch (InterruptedException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- } else {
- if(tree.exists()) {
- try {
- tree.interact("Chop down");
- return 2400;
- } catch (InterruptedException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
- }
- }
- }
- return 100;
- }
- public boolean walkToLocation(Position p) throws InterruptedException {
- int maxY;
- int maxX;
- boolean revY = false;
- boolean revX = false;
- Position playerPosition = myPlayer().getPosition();
- if(playerPosition.getX() < p.getX()) {
- revX = true;
- int distance = p.getX()-playerPosition.getX();
- if(distance > 17) {
- maxX = 17;
- } else {
- maxX = distance;
- }
- } else {
- int distance = playerPosition.getX()-p.getX();
- if(distance > 17) {
- maxX = 17;
- } else {
- maxX = distance;
- }
- }
- if(playerPosition.getY() < p.getY()) {
- revY = true;
- int distance = p.getY()-playerPosition.getY();
- if(distance > 17) {
- maxY = 17;
- } else {
- maxY = distance;
- }
- } else {
- int distance = playerPosition.getY()-p.getY();
- if(distance > 17) {
- maxY = 17;
- } else {
- maxY = distance;
- }
- }
- int addX = (int) (10+(Math.random()*(maxX-10)));
- int addY = (int) (10+(Math.random()*(maxY-10)));
- if(maxX < 10) {
- addX = maxX;
- }
- if(maxY < 10) {
- addY = maxY;
- }
- if(!revX) {
- addX = addX*-1;
- }
- if(!revY) {
- addY = addY*-1;
- }
- if(lastClick == null) {
- if(walk(new Position(playerPosition.getX()+addX, playerPosition.getY()+addY, playerPosition.getZ()))) {
- lastClick = new Position(playerPosition.getX()+addX, playerPosition.getY()+addY, playerPosition.getZ());
- randomDistance = (int) (3+(Math.random() * 3));
- }
- } else {
- if(lastClick.distance(myPlayer().getPosition()) < randomDistance) {
- if(walk(new Position(playerPosition.getX()+addX, playerPosition.getY()+addY, playerPosition.getZ()))) {
- lastClick = new Position(playerPosition.getX()+addX, playerPosition.getY()+addY, playerPosition.getZ());
- randomDistance = (int) (3+(Math.random() * 3));
- }
- }
- }
- if(lastClick.distance(p) < 5) {
- lastClick = null;
- return true;
- }
- return false;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement