Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package Main;
- import org.dreambot.api.methods.Calculations;
- import org.dreambot.api.methods.container.impl.bank.Bank;
- import org.dreambot.api.methods.map.Area;
- import org.dreambot.api.methods.map.Tile;
- import org.dreambot.api.methods.skills.Skill;
- import org.dreambot.api.script.AbstractScript;
- import org.dreambot.api.script.Category;
- import org.dreambot.api.script.ScriptManifest;
- import org.dreambot.api.wrappers.interactive.GameObject;
- import org.dreambot.api.wrappers.interactive.NPC;
- import org.dreambot.api.methods.skills.Skills;
- import sun.reflect.generics.tree.Tree;
- import java.awt.*;
- import static org.dreambot.api.script.Category.WOODCUTTING;
- @ScriptManifest(category = WOODCUTTING, name = "my first script", author = "Mjwizy", version = 1.3)
- public class Main extends AbstractScript{
- //banking & tree areas
- //bank areas
- Area bankAreadraynor = new Area(3092, 3240, 3097, 3246, 0);
- // Area bankAreaLumbridge = new Area(3209, 3220, 3208, 3220, 2);
- //tree areas
- Area yewtreeArea = new Area(3145, 3256, 3164, 3219, 0);
- Area treetooaktreeArea = new Area(3167, 3243, 3198, 3207, 0);
- Area WillowtreeArea = new Area(3087, 3230, 3090, 3226, 0);
- // int for wc lvl
- public int wcLevel;
- //timer for checking wc lvl set to 20 to check in the beginnign
- int timepassed = 20;
- //log hi for start of program
- @Override
- public void onStart (){
- log("Hi");
- }
- //start of bot
- @Override public int onLoop() {
- if (timepassed == 20) {
- // Grab wc lvl
- wcLevel = getSkills().getRealLevel(Skill.WOODCUTTING);
- log("wc time pass reset");
- log(wcLevel);
- timepassed = 0;
- }
- // add one to the timepass
- timepassed ++;
- // walk to bank
- if (getInventory().isFull() && !bankAreadraynor.contains(getLocalPlayer())) {
- log("walk to bank in lumbridge");
- while (!bankAreadraynor.contains(getLocalPlayer())) {
- if (getWalking().shouldWalk(Calculations.random(10, 12))) {
- getWalking().walk(bankAreadraynor.getRandomTile());
- }
- }
- }
- // walk for normal and oak trees
- if(!getInventory().isFull() && !treetooaktreeArea.contains(getLocalPlayer()) && wcLevel >= 1 && wcLevel <= 29) {
- log("walk behind lumbridge");
- while (!treetooaktreeArea.contains(getLocalPlayer())) {
- if (getWalking().shouldWalk(Calculations.random(10, 12))) {
- getWalking().walk(treetooaktreeArea.getRandomTile());
- }
- }
- }
- // chop normal tree
- if (!getInventory().isFull() && treetooaktreeArea.contains(getLocalPlayer())&& wcLevel >= 1 && wcLevel <= 14) {
- log("prepare to cut normal tree");
- if (!getLocalPlayer().isAnimating() && (!getLocalPlayer().isMoving())) {
- chopTree("Tree");
- sleep(Calculations.random(1000,3000));
- }
- }
- // chop oak tree
- if (!getInventory().isFull() && treetooaktreeArea.contains(getLocalPlayer())&& wcLevel >= 15 && wcLevel <= 29) {
- log("prepare to cut oak tree");
- if (!getLocalPlayer().isAnimating() && (!getLocalPlayer().isMoving())) {
- chopoakTree("Oak");
- sleep(Calculations.random(3000,4000));
- }
- }
- // walk to willows
- if(!getInventory().isFull() && !WillowtreeArea.contains(getLocalPlayer()) && wcLevel >= 30 && wcLevel <= 59) {
- log("walk to willows in draynor");
- while (!WillowtreeArea.contains(getLocalPlayer())) {
- if (getWalking().shouldWalk(Calculations.random(10, 12))) {
- getWalking().walk(WillowtreeArea.getRandomTile());
- }
- }
- }
- // chop willow tree
- if (!getInventory().isFull() && WillowtreeArea.contains(getLocalPlayer())&& wcLevel >= 30 && wcLevel <= 59) {
- log("prepare to cut willow tree");
- if (!getLocalPlayer().isAnimating() && (!getLocalPlayer().isMoving())) {
- chopwillowTree("Willow");
- sleep(Calculations.random(3000,4000));
- }
- }
- // walk to yew tree area
- if(!getInventory().isFull() && !yewtreeArea.contains(getLocalPlayer()) && wcLevel >= 60) {
- log("walk to yews in draynor");
- while (!yewtreeArea.contains(getLocalPlayer())) {
- if (getWalking().shouldWalk(Calculations.random(10, 12))) {
- getWalking().walk(yewtreeArea.getRandomTile());
- }
- }
- }
- // chop yew tree
- if (!getInventory().isFull() && yewtreeArea.contains(getLocalPlayer())&& wcLevel >= 60) {
- log("prepare to cut yew tree");
- if (!getLocalPlayer().isAnimating() && (!getLocalPlayer().isMoving())) {
- chopyewTree("Yew");
- sleep(Calculations.random(3000,4000));
- }
- }
- //Bank at Lumbridge or draynor
- if(getInventory().isFull() && bankAreadraynor.contains(getLocalPlayer())){
- log("Banking");
- bank();
- }
- return 5000;
- }
- //allows to log wclvl
- private void log(int wcLevel) {
- }
- @Override
- public void onExit(){
- }
- //chop normal tree
- private void chopTree(String Tree) {
- log("chop tree");
- GameObject treenormal = getGameObjects().closest(gameObject -> gameObject.getName().equals("Tree"));
- if(treenormal != null && treenormal.interact("Chop down")) {
- }else{
- sleep(1000,1500);
- }
- }
- //chop oak tree
- private void chopoakTree(String Oak) {
- log("chop oak tree");
- GameObject treeoak = getGameObjects().closest(gameObject -> gameObject.getName().equals("Oak"));
- if(treeoak != null && treeoak.interact("Chop down")) {
- }else{
- sleep(1000,1500);
- }
- }
- //Choop willow tree
- private void chopwillowTree(String Willow) {
- log("willow tree");
- GameObject treewillow = getGameObjects().closest(gameObject -> gameObject.getName().equals("Willow")
- && gameObject.isOnScreen()) ;
- if(treewillow != null && treewillow.interact("Chop down")) {
- }else{
- sleep(1000,1500);
- }
- }
- //chop yew tree
- private void chopyewTree(String Yew) {
- log("chop yew tree");
- GameObject treeyew = getGameObjects().closest(tree -> (tree != null) && tree.getName().equals("Yew") && tree.hasAction("Chop Down"));
- if (treeyew.interact("Chop Down")){
- treeyew.interact("Chop down");
- while(getLocalPlayer().isAnimating()){
- // Pretty much just wait here while you're chopping it down
- }
- sleep(1000,1500); // Realism break after tree is chopped down
- }
- }
- //bank
- private void bank() {
- NPC banker = getNpcs().closest(npc -> npc != null && npc.hasAction("Bank"));
- log("clicked on banker");
- if(banker.interact("Bank")) {
- if (sleepUntil(() -> getBank().isOpen(), 7000)) {
- log("bank menu opened");
- if (getBank().depositAllExcept(item -> item != null && item.getName().contains("axe"))) {
- log("banked all items");
- if (sleepUntil(() -> !getInventory().isFull(), 5000)) {
- if (getBank().close()) {
- log("close bank");
- sleepUntil(() -> !getBank().isOpen(), 8000);
- log("banking completed");
- }
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement