Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import org.tribot.api.DynamicClicking;
- import org.tribot.api.General;
- import org.tribot.api.Timing;
- import org.tribot.api.types.generic.Condition;
- import org.tribot.api2007.Banking;
- import org.tribot.api2007.Inventory;
- import org.tribot.api2007.NPCs;
- import org.tribot.api2007.Objects;
- import org.tribot.api2007.Player;
- import org.tribot.api2007.Walking;
- import org.tribot.api2007.WebWalking;
- import org.tribot.api2007.types.RSNPC;
- import org.tribot.api2007.types.RSObject;
- import org.tribot.api2007.types.RSTile;
- import org.tribot.script.Script;
- import org.tribot.script.ScriptManifest;
- @ScriptManifest(authors = { "Podgorsek" }, category = "Woodcutting", name = "podChopper")
- public class PodChopp extends Script {
- private RSTile last_tree_tile = null;
- private boolean isAtTrees() {
- final RSObject[] trees = Objects.findNearest(20, "Tree");
- if (trees.length < 1)
- return false;
- return trees[0].isOnScreen();
- }
- private boolean isInBank() {
- final RSObject[] booths = Objects.findNearest(20, "Bank booth");
- if (booths.length > 1) {
- if (booths[0].isOnScreen())
- return true;
- }
- final RSNPC[] bankers = NPCs.findNearest("Banker");
- if (bankers.length < 1)
- return false;
- return bankers[0].isOnScreen();
- }
- private boolean cut() {
- if (isCutting()) {
- final long timeout = System.currentTimeMillis()
- + General.random(60000, 90000);
- while (isCutting() && System.currentTimeMillis() < timeout) {
- sleep(100, 150);
- if (this.last_tree_tile != null) {
- if (!Objects.isAt(this.last_tree_tile, "Tree")) {
- break;
- }
- }
- }
- }
- final RSObject[] tree = Objects.findNearest(50, "Tree");
- if (tree.length < 1)
- return false;
- if (!tree[0].isOnScreen()) {
- if (!Walking.walkPath(Walking.generateStraightPath(tree[0])))
- return false;
- if (!Timing.waitCondition(new Condition() {
- @Override
- public boolean active() {
- General.sleep(100);
- return tree[0].isOnScreen();
- }
- }, General.random(8000, 9300)))
- return false;
- }
- if (!DynamicClicking.clickRSObject(tree[0], "Chop down"))
- return false;
- Timing.waitCondition(new Condition() {
- @Override
- public boolean active() {
- return !isCutting();
- }
- }, General.random(1000, 1200));
- if (Timing.waitCondition(new Condition() {
- @Override
- public boolean active() {
- return isCutting();
- }
- }, General.random(8000, 9000))) {
- this.last_tree_tile = tree[0].getPosition().clone();
- return true;
- }
- return false;
- }
- private boolean isCutting() {
- return Player.getAnimation() > 0;
- }
- private boolean walkToBank() {
- if (!WebWalking.walkToBank()) {
- return false;
- }
- return Timing.waitCondition(new Condition() {
- @Override
- public boolean active() {
- General.sleep(200, 300);
- return isInBank();
- }
- }, General.random(8000, 9000));
- }
- private boolean walkToTrees() {
- final RSObject[] trees = Objects.findNearest(50, "Tree");
- if (trees.length < 1)
- return false;
- if (!WebWalking.walkTo(trees[0]))
- return false;
- return Timing.waitCondition(new Condition() {
- @Override
- public boolean active() {
- General.sleep(200, 300);
- return isAtTrees();
- }
- }, General.random(8000, 9000));
- }
- private boolean bank() {
- if (!Banking.isBankScreenOpen()) {
- if (!Banking.openBank())
- return false;
- }
- final String[] axe_names = { "Bronze axe", "Iron axe", "Black axe",
- "Steel axe", "Mithril axe", "Adamant axe", "Rune axe",
- "Dragon axe" };
- if (Inventory.find(axe_names).length > 0) {
- if (Banking.depositAllExcept(axe_names) < 1)
- return false;
- } else {
- if (Banking.depositAll() < 1)
- return false;
- }
- return Timing.waitCondition(new Condition() {
- @Override
- public boolean active() {
- return !Inventory.isFull();
- }
- }, General.random(3000, 4000));
- }
- @Override
- public void run() {
- while (true) {
- sleep(50);
- if (isAtTrees()) {
- if (Inventory.isFull()) {
- walkToBank();
- } else
- cut();
- } else if (isInBank()) {
- if (Inventory.isFull())
- bank();
- else {
- walkToTrees();
- }
- } else {
- if (Inventory.isFull())
- walkToBank();
- else
- walkToTrees();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement