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.Camera;
- import org.tribot.api2007.Equipment;
- import org.tribot.api2007.GameTab;
- import org.tribot.api2007.GroundItems;
- 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.RSGroundItem;
- 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.Pausing;
- import org.tribot.script.interfaces.RandomEvents;
- @ScriptManifest(authors = { "Okokokok" }, category = "ok_StarterPack", name = "ok_StarterMiner")
- public class ok_StarterMiner extends Script implements Painting, Pausing, RandomEvents {
- boolean paused = false;
- private double version = 1.00;
- private final int[] oreID = {7180, 7179, 7181, 7184, 7182, 7183},
- minedRockID = {10946, 10947, 10948};
- private final int explodingRockID = 7158;
- private final String mineOption = "Mine",
- pickAxeName = "Bronze pickaxe",
- wieldOption = "Wield",
- takeOption = "Take";
- private final String[] oreNames = {"Tin ore", "Copper ore"},
- nothing = {""};
- public RSArea miningArea = new RSArea (new RSTile(3219, 3144, 0), new RSTile(3232, 3149, 0)),
- walkingArea = new RSArea (new RSTile(3214, 3141, 0), new RSTile(3257, 3226, 0)),
- stairsArea = new RSArea (new RSTile(3223, 3211), new RSTile(3232, 3217));
- private final RSTile[] miningPath = new RSTile[] {new RSTile(3225, 3214, 0),
- new RSTile(3227, 3217, 0),
- new RSTile(3232, 3216, 0),
- new RSTile(3233, 3212, 0),
- new RSTile(3235, 3208, 0),
- new RSTile(3236, 3204, 0),
- new RSTile(3240, 3200, 0),
- new RSTile(3242, 3196, 0),
- new RSTile(3244, 3192, 0),
- new RSTile(3242, 3188, 0),
- new RSTile(3239, 3184, 0),
- new RSTile(3236, 3180, 0),
- new RSTile(3234, 3176, 0),
- new RSTile(3232, 3172, 0),
- new RSTile(3231, 3168, 0),
- new RSTile(3230, 3164, 0),
- new RSTile(3231, 3158, 0),
- new RSTile(3231, 3154, 0),
- new RSTile(3230, 3149, 0),
- new RSTile(3226, 3146, 0)};
- // RANDOM METHODS
- public boolean isExplodingRock(int distance, int explodingRockID){
- RSObject[] rock = Objects.find(distance, explodingRockID);
- return rock != null && rock.length > 0;
- }
- public boolean randomTrue(){
- return paused;
- }
- // 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;
- }
- public boolean havePickAxe(String pickaxename){
- RSItem[] pickAxe = Equipment.find(pickaxename);
- return pickAxe != null && pickAxe.length > 0;
- }
- private boolean pickaxeground(){
- RSGroundItem[] pickaxe = GroundItems.find(pickAxeName);
- if (pickaxe != null && pickaxe.length > 0){
- return true;
- }
- return false;
- }
- private void pickUpAxe(){
- RSGroundItem[] pickaxe = GroundItems.findNearest(pickAxeName);
- int plane = Player.getPosition().getPlane();
- if (plane == 2 && pickaxe != null && pickaxe.length > 0){
- if (pickaxe[0].click(takeOption)){
- waitFor(new Condition (){
- @Override
- public boolean active(){
- return pickAxeInInventory(pickAxeName);
- }
- }, 4000);
- }
- }
- }
- private boolean pickAxeInInventory(String pickaxename){
- RSItem[] pickAxeInventory = Inventory.find(pickaxename);
- return pickAxeInventory != null && pickAxeInventory.length > 0;
- }
- private void equipPickAxe(String pickaxename, String wieldOption){
- RSItem[] pickAxeInventory = Inventory.find(pickaxename);
- if (pickAxeInventory != null && pickAxeInventory.length > 0){
- if (pickAxeInventory[0].click(wieldOption)){
- waitFor(new Condition(){
- @Override
- public boolean active(){
- return havePickAxe(pickAxeName);
- }
- }, 4000);
- }
- }
- }
- // 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;
- }
- }
- // MINING RELATED METHODS
- private boolean minedRock(int[] ID){
- RSObject[] minedRock = Objects.findNearest(1, ID);
- return minedRock != null && minedRock.length > 0 && Player.getAnimation() == -1;
- }
- public int invCount(){
- return Inventory.getAll().length;
- }
- private boolean rockAvailable(int[] rockID){
- RSObject[] coalRock = Objects.findNearest(6, rockID);
- return coalRock != null && coalRock.length > 0 && coalRock[0].isOnScreen();
- }
- private boolean mineRock(int[] rockID, String mineOption){
- RSObject[] coalRock = Objects.findNearest(6, rockID);
- if (coalRock != null && coalRock.length > 0){
- if (coalRock[0].click(mineOption)){
- sleep(1500, 2000);
- waitFor(new Condition(){
- @Override
- public boolean active(){
- return minedRock(minedRockID) || isExplodingRock(1, explodingRockID) || !havePickAxe(pickAxeName);
- }
- }, 30000);
- }
- }
- return false;
- }
- // DROPPING METHODS
- private void dropAll(){
- RSItem[] ores = Inventory.find(oreNames);
- if (Inventory.isFull() && ores != null && ores.length > 0){
- Inventory.dropAllExcept(nothing);
- }
- }
- // DOOR METHODS
- private RSTile getDoor(){
- RSObject[] door = Objects.findNearest(7, "Door");
- return door[0].getPosition();
- }
- private boolean isDoorOpen(){
- RSObject[] door = Objects.findNearest(7, "Door");
- if (door != null && door.length > 0 && getDoor().equals(new RSTile(3227, 3214, 0))){
- return true;
- }
- return false;
- }
- private void openDoor(){
- RSObject[] door = Objects.findNearest(7, "Door");
- if (door != null && door.length > 0 && !isDoorOpen()){
- if (DynamicClicking.clickRSObject(door[0], "Open")){
- waitFor(new Condition(){
- @Override
- public boolean active(){
- return isDoorOpen();
- }
- }, 4000);
- }
- }
- }
- // LADDER METHODS
- private void climbLadderUp(){
- RSObject[] ladder = Objects.findNearest(5, "Ladder");
- final int plane = Player.getPosition().getPlane();
- if (!havePickAxe(pickAxeName) && ladder != null && ladder.length > 0){
- if (plane == 0){
- if (DynamicClicking.clickRSObject(ladder[0], "Climb-up")){
- waitFor(new Condition(){
- @Override
- public boolean active(){
- return plane == 1;
- }
- }, 4000);
- }
- }
- if (plane == 1){
- if (DynamicClicking.clickRSObject(ladder[0], "Climb-Up")){
- waitFor(new Condition(){
- @Override
- public boolean active(){
- return plane == 2;
- }
- }, 4000);
- }
- }
- }
- }
- private void climbLadderDown(){
- RSObject[] ladder = Objects.findNearest(5, "Ladder");
- final int plane = Player.getPosition().getPlane();
- if (havePickAxe(pickAxeName) && ladder != null && ladder.length > 0){
- if (plane == 2){
- if (DynamicClicking.clickRSObject(ladder[0], "Climb-down")){
- waitFor(new Condition(){
- @Override
- public boolean active(){
- return plane == 1;
- }
- }, 4000);
- }
- }
- if (plane == 1){
- if (DynamicClicking.clickRSObject(ladder[0], "Climb-Down")){
- waitFor(new Condition(){
- @Override
- public boolean active(){
- return plane == 0;
- }
- }, 4000);
- }
- }
- }
- }
- // WALKING METHODS
- private void walkingPickaxe(){
- final RSTile myPos = Player.getPosition();
- if (myPos != new RSTile(3225, 3214, 0)){
- if (Walking.walkPath(Walking.invertPath(miningPath))){
- waitFor(new Condition(){
- @Override
- public boolean active(){
- return stairsArea.contains(myPos);
- }
- }, 4000);
- }
- }
- }
- private void walkingMining(){
- final RSTile myPos = Player.getPosition();
- if (myPos != new RSTile(3226, 3146, 0)){
- if (Walking.walkPath(miningPath)){
- waitFor(new Condition(){
- @Override
- public boolean active(){
- return miningArea.contains(myPos) || !isDoorOpen();
- }
- }, 4000);
- }
- }
- }
- // STATE METHODS
- public enum State{
- WALKING_TO_MINING_AREA, WALKING_TO_LADDER_AREA,
- CLIMBING_LADDER_UP, CLIMBING_LADDER_DOWN,
- OPENING_DOOR, PICKING_UP_PICKAXE, EQUIPPING_PICKAXE,
- MINING, DROPPING, SOLVING_RANDOM, LOGING_OUT;
- }
- private boolean planeCheck0(){
- int plane = Player.getPosition().getPlane();
- return plane == 0;
- }
- private boolean planeCheck1(){
- int plane = Player.getPosition().getPlane();
- return plane == 1;
- }
- private State getState(){
- RSTile myPos = Player.getPosition();
- int plane = Player.getPosition().getPlane();
- if (paused){
- return State.SOLVING_RANDOM;
- }
- if (walkingArea.contains(myPos)){
- if (!havePickAxe(pickAxeName) && !pickAxeInInventory(pickAxeName) && !stairsArea.contains(myPos)){
- return State.WALKING_TO_LADDER_AREA;
- }
- if (planeCheck0() && !havePickAxe(pickAxeName) && !pickAxeInInventory(pickAxeName) && !isDoorOpen() && stairsArea.contains(myPos)){
- return State.OPENING_DOOR;
- }
- if (planeCheck0() && havePickAxe(pickAxeName) && pickAxeInInventory(pickAxeName) && stairsArea.contains(myPos)){
- return State.OPENING_DOOR;
- }
- if (planeCheck0() && !havePickAxe(pickAxeName) && !pickAxeInInventory(pickAxeName) && isDoorOpen() && stairsArea.contains(myPos)){
- return State.CLIMBING_LADDER_UP;
- }
- if (planeCheck1() && !havePickAxe(pickAxeName) && !pickAxeInInventory(pickAxeName) && stairsArea.contains(myPos)){
- return State.CLIMBING_LADDER_UP;
- }
- if (pickaxeground() && plane == 2 && !havePickAxe(pickAxeName) && !pickAxeInInventory(pickAxeName)){
- return State.PICKING_UP_PICKAXE;
- }
- if (!havePickAxe(pickAxeName) && pickAxeInInventory(pickAxeName) && stairsArea.contains(myPos)){
- return State.EQUIPPING_PICKAXE;
- }
- if (havePickAxe(pickAxeName) && plane != 0 && stairsArea.contains(myPos)){
- return State.CLIMBING_LADDER_DOWN;
- }
- if (havePickAxe(pickAxeName) && !miningArea.contains(myPos)){
- return State.WALKING_TO_MINING_AREA;
- }
- if (!havePickAxe(pickAxeName) && pickAxeInInventory(pickAxeName) && miningArea.contains(myPos)){
- return State.EQUIPPING_PICKAXE;
- }
- if (!Inventory.isFull() && havePickAxe(pickAxeName) && miningArea.contains(myPos) && rockAvailable(oreID)){
- return State.MINING;
- }
- if (Inventory.isFull() && havePickAxe(pickAxeName) && miningArea.contains(myPos)){
- return State.DROPPING;
- }
- }
- return State.LOGING_OUT;
- }
- @Override
- public void onRandom(RANDOM_SOLVERS arg0) {
- paused = true;
- }
- @Override
- public boolean randomFailed(RANDOM_SOLVERS arg0) {
- sleep(5000, 6000);
- paused = false;
- return false;
- }
- @Override
- public void randomSolved(RANDOM_SOLVERS arg0) {
- sleep(5000, 6000);
- paused = false;
- }
- @Override
- public void onPause() {
- while(paused){
- sleep(100, 200);
- }
- }
- @Override
- public void onResume() {
- paused = false;
- }
- 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("mining");
- 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("mining") - START_XP;
- g.setFont(font);
- g.setColor(new Color(255, 255, 255));
- g.drawString("ok_StarterMiner 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("Ores p/h: " + (int)((xpGained / 17.5) / multiplier), 558, 295);
- g.drawString("Ores mined: " + (int) (xpGained / 17.5), 558, 310);
- }
- @SuppressWarnings("deprecation")
- @Override
- public void run() {
- println("Started ok_StarterCombat from the StarterPack");
- 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 CLIMBING_LADDER_DOWN:
- climbLadderDown();
- sleep(200, 300);
- break;
- case CLIMBING_LADDER_UP:
- climbLadderUp();
- sleep(200, 300);
- break;
- case DROPPING:
- dropAll();
- sleep(200, 300);
- break;
- case EQUIPPING_PICKAXE:
- equipPickAxe(pickAxeName, wieldOption);
- sleep(200, 300);
- break;
- case LOGING_OUT:
- logout();
- stopScript();
- sleep(200, 300);
- break;
- case MINING:
- mineRock(oreID, mineOption);
- sleep(200, 300);
- int rotation5 = General.random(90, 200);
- antiBan(rotation5);
- break;
- case OPENING_DOOR:
- openDoor();
- sleep(200, 300);
- break;
- case PICKING_UP_PICKAXE:
- pickUpAxe();
- sleep(200, 300);
- break;
- case WALKING_TO_LADDER_AREA:
- walkingPickaxe();
- sleep(200, 300);
- break;
- case WALKING_TO_MINING_AREA:
- walkingMining();
- sleep(200, 300);
- break;
- case SOLVING_RANDOM:
- while(paused){
- sleep(100, 200);
- }
- break;
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement