Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package scripts;
- import java.awt.Color;
- import java.awt.Font;
- import java.awt.Graphics;
- import org.tribot.api.Timing;
- import org.tribot.api.General;
- import org.tribot.api2007.Screen;
- import org.tribot.api2007.types.RSTile;
- import org.tribot.api.DynamicClicking;
- import org.tribot.api.input.Mouse;
- import org.tribot.api.types.generic.Condition;
- import org.tribot.api2007.Banking;
- import org.tribot.api2007.Camera;
- import org.tribot.api2007.Equipment;
- import org.tribot.api2007.GameTab;
- import org.tribot.api2007.Inventory;
- import org.tribot.api2007.Login;
- import org.tribot.api2007.Objects;
- import org.tribot.api2007.Player;
- import org.tribot.api2007.Skills;
- import org.tribot.api2007.Walking;
- import org.tribot.api2007.GameTab.TABS;
- import org.tribot.api2007.types.RSItem;
- import org.tribot.api2007.types.RSObject;
- import org.tribot.script.Script;
- import org.tribot.script.ScriptManifest;
- import org.tribot.script.interfaces.Painting;
- import org.tribot.script.interfaces.RandomEvents;
- @ScriptManifest(authors = { "Okokokok" }, category = "ok_StarterPack", name = "ok_StarterWoodcutter")
- public class ok_StarterWoodcutter extends Script implements Painting, RandomEvents {
- private boolean paused = false;
- private double version = 1.00;
- private String[] nothing;
- private RSArea bankArea = new RSArea(new RSTile(3207, 3215, 2), new RSTile(3210, 3221, 2)),
- stairArea = new RSArea(new RSTile(3205, 3206), new RSTile(3207, 3211)),
- treeArea = new RSArea(new RSTile(3178, 3207, 0), new RSTile(3200, 3235, 0)),
- walkingArea = new RSArea(new RSTile(3160, 3198), new RSTile(3245, 3251));
- private RSTile[] bankPath = new RSTile[] {new RSTile(3205, 3210, 2), new RSTile(3208, 3219, 2), new RSTile(3206, 3215, 2), new RSTile(3208, 3220, 2)},
- treePath = new RSTile[] {new RSTile(3205, 3209, 0), new RSTile(3213, 3210, 0),
- new RSTile(3215, 3216, 0), new RSTile(3223, 3219, 0),
- new RSTile(3229, 3220, 0), new RSTile(3231, 3226, 0),
- new RSTile(3227, 3234, 0), new RSTile(3221, 3239, 0),
- new RSTile(3215, 3239, 0), new RSTile(3208, 3240, 0),
- new RSTile(3202, 3240, 0), new RSTile(3196, 3238, 0),
- new RSTile(3190, 3234, 0), new RSTile(3190, 3226, 0),
- new RSTile(3192, 3219, 0), new RSTile(3186, 3214, 0),
- new RSTile(3189, 3207, 0), new RSTile(3193, 3212, 0)};
- // MISC METHODS
- public boolean waitFor(Condition c, long timeout) {
- Timer t = new Timer(timeout);
- while (t.isRunning()) {
- if (c.active()) {
- return true;
- }
- sleep(60, 80);
- }
- return false;
- }
- public boolean loggedOut() {
- return (Login.getLoginState() == Login.STATE.LOGINSCREEN)
- && (!Screen.getColorAt(100, 200).equals(new Color(0, 0, 0)));
- }
- public boolean logout() {
- if (Login.getLoginState() == Login.STATE.INGAME)
- {
- Login.logout();
- for(int x = 0; x < 6; x++)
- {
- if(loggedOut())
- {
- return true;
- }
- sleep(490,510);
- }
- }
- return false;
- }
- // ANTI-BAN BY SOKCRA
- public void antiBan(int rotation) {
- int number = General.random(1, 500);
- sleep(200);
- switch (number) {
- case 1:
- case 2:
- case 3:
- case 4:
- case 5:
- Camera.setCameraRotation(Camera.getCameraRotation() + rotation);
- break;
- case 20:
- case 21:
- case 22:
- case 23:
- case 24:
- case 25:
- case 26:
- case 27:
- case 28:
- case 29:
- case 30:
- case 31:
- Mouse.move(General.random(100, 200), General.random(200, 400));
- sleep(200);
- break;
- case 50:
- GameTab.open(TABS.INVENTORY);
- sleep(200);
- break;
- case 75:
- GameTab.open(TABS.STATS);
- sleep(300);
- Mouse.moveBox(678, 386, 725, 366);
- sleep(1000, 1500);
- GameTab.open(TABS.INVENTORY);
- break;
- case 76:
- GameTab.open(TABS.FRIENDS);
- sleep(2000, 3000);
- GameTab.open(TABS.INVENTORY);
- break;
- case 89:
- case 90:
- case 91:
- case 92:
- case 93:
- case 94:
- Camera.setCameraAngle(Camera.getCameraRotation() + rotation);
- sleep(200, 400);
- break;
- case 95:
- case 96:
- case 97:
- case 98:
- case 99:
- case 100:
- Camera.setCameraAngle(Camera.getCameraRotation() + rotation);
- sleep(200, 400);
- break;
- }
- }
- // HATCHET METHODS
- private boolean haveHatchetInv(){
- RSItem[] hatchet = Inventory.find("Bronze axe");
- return hatchet != null && hatchet.length > 0;
- }
- private boolean haveHatchetEquipped(){
- RSItem[] hatchet = Equipment.find("Bronze axe");
- return hatchet != null && hatchet.length > 0;
- }
- private void equipHatchet(){
- RSItem[] hatchet = Inventory.find("Bronze axe");
- if (hatchet != null && hatchet.length > 0){
- if(hatchet[0].click("Wield")){
- waitFor(new Condition(){
- @Override
- public boolean active(){
- return haveHatchetEquipped();
- }
- }, 4000);
- }
- }
- }
- // BANKING METHODS
- private void openBank(){
- if(Banking.isBankScreenOpen()){
- sleep(100);
- }
- if(!Banking.isBankScreenOpen()){
- Banking.openBankBooth();
- }
- }
- private void withdrawHatchet(){
- RSItem[] hatchet = Banking.find("Bronze axe");
- if(hatchet != null && hatchet.length > 0){
- if(Banking.withdraw(1, "Bronze axe")){
- waitFor(new Condition(){
- @Override
- public boolean active(){
- return haveHatchetInv();
- }
- }, 4000);
- }
- }
- }
- // WALKING METHODS
- private void bankWalk(){
- final RSTile myPos = Player.getPosition();
- if(!bankArea.contains(myPos)){
- if(Walking.walkPath(bankPath)){
- waitFor(new Condition(){
- @Override
- public boolean active(){
- return !Player.isMoving() && bankArea.contains(myPos);
- }
- }, 6000);
- }
- }
- }
- private void stairWalkP2(){
- final RSTile myPos = Player.getPosition();
- if(!stairArea.contains(myPos)){
- if(Walking.walkPath(Walking.invertPath(bankPath))){
- waitFor(new Condition(){
- @Override
- public boolean active(){
- return !Player.isMoving() && stairArea.contains(myPos);
- }
- }, 4000);
- }
- }
- }
- private void stairWalkP0(){
- final RSTile myPos = Player.getPosition();
- if(!stairArea.contains(myPos)){
- if(Walking.walkPath(Walking.invertPath(treePath))){
- waitFor(new Condition(){
- @Override
- public boolean active(){
- return stairArea.contains(myPos);
- }
- }, 4000);
- }
- }
- }
- private void treeWalk(){
- final RSTile myPos = Player.getPosition();
- if(!treeArea.contains(myPos)){
- if(Walking.walkPath(treePath)){
- waitFor(new Condition(){
- @Override
- public boolean active(){
- return treeArea.contains(myPos) && !Player.isMoving();
- }
- }, 6000);
- }
- }
- }
- // LADDER METHODS
- private void climbLadder(){
- RSObject[] stairs = Objects.findNearest(5, "Staircase");
- final int plane = Player.getPosition().getPlane();
- if(stairs != null && stairs.length > 0){
- if(haveHatchetEquipped() && plane == 2){
- if(DynamicClicking.clickRSObject(stairs[0], "Climb-down")){
- waitFor(new Condition(){
- @Override
- public boolean active(){
- return plane == 1;
- }
- }, 4000);
- }
- }
- if(haveHatchetEquipped() && plane == 1){
- if(DynamicClicking.clickRSObject(stairs[0], "Climb-down")){
- waitFor(new Condition(){
- @Override
- public boolean active(){
- return plane == 0;
- }
- }, 4000);
- }
- }
- if(!haveHatchetEquipped() && plane == 0){
- if(DynamicClicking.clickRSObject(stairs[0], "Climb-up")){
- waitFor(new Condition(){
- @Override
- public boolean active(){
- return plane == 1;
- }
- }, 4000);
- }
- }
- if(!haveHatchetEquipped() && plane == 1){
- if(DynamicClicking.clickRSObject(stairs[0], "Climb-up")){
- waitFor(new Condition(){
- @Override
- public boolean active(){
- return plane == 2;
- }
- }, 4000);
- }
- }
- }
- }
- private void walkTree(){
- if(Walking.walkTo(getTree())){
- waitFor(new Condition(){
- @Override
- public boolean active(){
- return !Player.isMoving();
- }
- }, 8000);
- }
- }
- // TREE METHODS
- private boolean treeLength(){
- RSObject[] tree = Objects.findNearest(30, "Tree");
- return tree != null && tree.length > 0 && tree[0].getModel().getPoints().length == 366;
- }
- private RSTile getTree(){
- RSObject[] tree = Objects.findNearest(30, "Tree");
- return tree[0].getPosition();
- }
- public boolean treeInArea(){
- RSObject[] tree = Objects.findNearest(30, "Tree");
- if(tree != null && tree.length > 0){
- if(treeArea.contains(getTree())){
- return true;
- }
- }
- return false;
- }
- private boolean isTreeChopped(){
- final RSTile myPos = Player.getPosition();
- return myPos.distanceTo(getTree()) > 1;
- }
- private boolean isTreeOnscreen(){
- RSObject[] tree = Objects.findNearest(30, "Tree");
- return tree != null && tree.length > 0 && tree[0].isOnScreen();
- }
- private boolean isTreeOffscreen(){
- RSObject[] tree = Objects.findNearest(30, "Tree");
- return tree != null && tree.length > 0 && !tree[0].isOnScreen();
- }
- // WOODCUTTING METHODS
- private void chopTree(){
- RSObject[] tree = Objects.findNearest(30, "Tree");
- if(tree != null && tree.length > 0){
- if(DynamicClicking.clickRSObject(tree[0], "Chop down")){
- sleep(1500, 1700);
- waitFor(new Condition(){
- @Override
- public boolean active(){
- return Player.getAnimation() == -1 && isTreeChopped() || !treeLength();
- }
- }, 10000);
- }
- }
- }
- // DROPPING METHODS
- private void dropInventory(){
- if(Inventory.isFull()){
- Inventory.dropAllExcept(nothing);
- }
- }
- // STATES
- private enum State{
- OPENING_BANK, WITHDRAWING_HATCHET,
- WALKING_BANK, WALKING_STAIRS_UP,
- WALKING_STAIRS_DOWN, WALKING_TO_TREES,
- WALK_TREE, CLIMBING_LADDER,
- CHOPPING, DROPPING, CLOSING_BANK,
- EQUIPPING_HATCHET, SOLVING_RANDOM,
- LOGING_OUT;
- }
- private State getState(){
- final RSTile myPos = Player.getPosition();
- final int plane = Player.getPosition().getPlane();
- if(paused){
- return State.SOLVING_RANDOM;
- }
- if(bankArea.contains(myPos)){
- if(!haveHatchetInv() && !haveHatchetEquipped() && !Banking.isBankScreenOpen() && plane == 2){
- return State.OPENING_BANK;
- }
- if(!haveHatchetInv() && !haveHatchetEquipped() && Banking.isBankScreenOpen()){
- return State.WITHDRAWING_HATCHET;
- }
- if(haveHatchetInv() && !haveHatchetEquipped() && Banking.isBankScreenOpen()){
- return State.CLOSING_BANK;
- }
- if(haveHatchetInv() && !haveHatchetEquipped() && !Banking.isBankScreenOpen()){
- return State.EQUIPPING_HATCHET;
- }
- if(!haveHatchetInv() && haveHatchetEquipped() && !Banking.isBankScreenOpen()){
- return State.WALKING_STAIRS_UP;
- }
- }
- if(stairArea.contains(myPos)){
- if(!haveHatchetEquipped() && !bankArea.contains(myPos) && plane == 2){
- return State.WALKING_BANK;
- }
- if(haveHatchetEquipped() && plane == 2){
- return State.CLIMBING_LADDER;
- }
- if(haveHatchetEquipped() && plane == 1){
- return State.CLIMBING_LADDER;
- }
- if(haveHatchetEquipped() && plane == 0){
- return State.WALKING_TO_TREES;
- }
- if(!haveHatchetEquipped() && plane == 0){
- return State.CLIMBING_LADDER;
- }
- if(!haveHatchetEquipped() && plane == 1){
- return State.CLIMBING_LADDER;
- }
- }
- if(treeArea.contains(myPos)){
- if(haveHatchetEquipped()){
- if(!Inventory.isFull()){
- if(isTreeOnscreen() && treeArea.contains(getTree())){
- return State.CHOPPING;
- }
- if(isTreeOffscreen() && treeArea.contains(getTree())){
- return State.WALK_TREE;
- }
- }
- if(Inventory.isFull()){
- return State.DROPPING;
- }
- }
- if(!haveHatchetEquipped()){
- return State.WALKING_STAIRS_DOWN;
- }
- }
- if(walkingArea.contains(myPos) && !bankArea.contains(myPos) && !stairArea.contains(myPos) && treeArea.contains(myPos)){
- return State.WALK_TREE;
- }
- if(walkingArea.contains(myPos) && !bankArea.contains(myPos) && !stairArea.contains(myPos) && !treeArea.contains(myPos)){
- if(haveHatchetEquipped()){
- if(plane == 0){
- return State.WALKING_TO_TREES;
- }
- if(plane == 1){
- return State.CLIMBING_LADDER;
- }
- if(plane == 2){
- return State.WALKING_STAIRS_UP;
- }
- }
- if(!haveHatchetEquipped()){
- if(plane == 0){
- return State.WALKING_STAIRS_DOWN;
- }
- if(plane == 1){
- return State.CLIMBING_LADDER;
- }
- if(plane == 2){
- return State.WALKING_BANK;
- }
- }
- }
- if(paused){
- return State.SOLVING_RANDOM;
- }
- return State.LOGING_OUT;
- }
- private static final long startTime = System.currentTimeMillis();
- Font font = new Font("Calibri", Font.BOLD, 16);
- private State SCRIPT_STATE = getState();
- @SuppressWarnings("deprecation")
- private final int startXP = Skills.getXP("woodcutting");
- private int START_XP;
- @SuppressWarnings("deprecation")
- @Override
- public void onPaint(Graphics g) {
- long timeRan = System.currentTimeMillis() - startTime;
- double multiplier = timeRan / 3600000D;
- int xpGained = Skills.getXP("woodcutting") - START_XP;
- g.setFont(font);
- g.setColor(new Color(255, 255, 255));
- g.drawString("ok_StarterWoodcutter V" + version, 558, 220);
- g.drawString("Action: " + SCRIPT_STATE, 558, 235);
- g.drawString("Time running: " + Timing.msToString(timeRan), 558, 250);
- g.drawString("XP Gained p/h: " + (int) (xpGained / multiplier), 558, 265);
- g.drawString("XP Gained: " + (int) xpGained, 558, 280);
- g.drawString("Logs p/h: " + (int)((xpGained / 25) / multiplier), 558, 295);
- g.drawString("Logs chopped: " + (int) (xpGained / 25), 558, 310);
- }
- @SuppressWarnings("deprecation")
- @Override
- public void run() {
- // TODO Auto-generated method stub
- println("Started ok_StarterWoodcutter");
- START_XP = startXP;
- super.setRandomSolverState(true);
- Walking.setControlClick(true);
- while(true){
- if (loggedOut()) {
- super.setLoginBotState(active);
- } else {
- while (!loggedOut()) {
- SCRIPT_STATE = getState();
- int mSpeed = General.random(180, 200);
- Mouse.setSpeed(mSpeed);
- Walking.setControlClick(true);
- switch (SCRIPT_STATE) {
- case CHOPPING:
- chopTree();
- sleep(200, 300);
- int rotation5 = General.random(90, 200);
- antiBan(rotation5);
- break;
- case CLIMBING_LADDER:
- climbLadder();
- sleep(200, 300);
- break;
- case DROPPING:
- dropInventory();
- sleep(200, 300);
- break;
- case LOGING_OUT:
- logout();
- stopScript();
- sleep(200, 300);
- break;
- case OPENING_BANK:
- openBank();
- sleep(200, 300);
- break;
- case WALKING_BANK:
- bankWalk();
- sleep(200, 300);
- break;
- case WALKING_STAIRS_DOWN:
- stairWalkP0();
- sleep(200, 300);
- break;
- case WALKING_STAIRS_UP:
- stairWalkP2();
- sleep(200, 300);
- break;
- case WALKING_TO_TREES:
- treeWalk();
- sleep(200, 300);
- break;
- case WALK_TREE:
- walkTree();
- sleep(200, 300);
- break;
- case WITHDRAWING_HATCHET:
- withdrawHatchet();
- sleep(200, 300);
- break;
- case CLOSING_BANK:
- Banking.close();
- sleep(200, 300);
- break;
- case EQUIPPING_HATCHET:
- equipHatchet();
- sleep(200, 300);
- break;
- case SOLVING_RANDOM:
- while(paused){
- sleep(100, 150);
- println("Solving Random");
- }
- break;
- }
- }
- }
- }
- }
- @Override
- public void onRandom(RANDOM_SOLVERS arg0) {
- paused = true;
- }
- @Override
- public boolean randomFailed(RANDOM_SOLVERS arg0) {
- paused = false;
- return false;
- }
- @Override
- public void randomSolved(RANDOM_SOLVERS arg0) {
- paused = false;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement