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 java.awt.Graphics2D;
- import java.awt.Image;
- import java.awt.Polygon;
- import java.io.IOException;
- import java.net.URL;
- import javax.imageio.ImageIO;
- import org.tribot.api.DynamicClicking;
- import org.tribot.api.General;
- import org.tribot.api.Timing;
- 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.Screen;
- 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.api2007.types.RSTile;
- 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_Scripts", name = "ok_miningGuilder")
- public class ok_miningGuilder extends Script implements Painting, Pausing, RandomEvents {
- private final Polygon bankArea = new Polygon(
- new int[] {3009, 3019, 3019, 3009},
- new int[] {3359, 3359, 3354, 3354},
- 4),
- ladderUpArea = new Polygon(
- new int[] {3014, 3025, 3025, 3014},
- new int[] {3343, 3343, 3336, 3336},
- 4),
- ladderDownArea = new Polygon(
- new int[] {3024, 3018, 3018, 3024},
- new int[] {9743, 9743, 9737, 9737},
- 4),
- faladorArea = new Polygon(
- new int[] {3007, 3034, 3034, 3007},
- new int[] {3365, 3365, 3332, 3332},
- 4);
- boolean paused;
- private final String mineOption = "Mine",
- coalOreName = "Coal",
- ladderName = "Ladder",
- pickAxeName = "Rune pickaxe",
- wieldOption = "Wield";
- private final int coalOreID = 453,
- explodingRockID = 2496;
- private final double version = 1.03;
- private final int[] coalRockID = {14915, 14916},
- minedRockID = {10796, 10798};
- private final RSTile bankTile = new RSTile (3012, 3356, 0),
- ladderUpTile = new RSTile (3022, 3338, 0),
- ladderDownTile = new RSTile (3021, 9738, 0),
- secondGuildTile = new RSTile (3037, 9736, 0),
- myPos = Player.getPosition();
- private final RSTile[] ladderUpPath = new RSTile[] { new RSTile (3012, 3356, 0),
- new RSTile (3019, 3361, 0),
- new RSTile (3023, 3356, 0),
- new RSTile (3024, 3350, 0),
- new RSTile (3029, 3342, 0),
- new RSTile (3028, 3336, 0),
- new RSTile (3022, 3338, 0)},
- guildPath = new RSTile[] { new RSTile (3021, 9738, 0),
- new RSTile (3031, 9738, 0),
- new RSTile (3037, 9736, 0),
- new RSTile (3042, 9738, 0)},
- ladderDownPath = new RSTile[] { new RSTile (3042, 9738, 0),
- new RSTile (3036, 9737, 0),
- new RSTile (3029, 9737, 0),
- new RSTile (3021, 9739, 0)},
- bankPath = new RSTile[] { new RSTile (3022, 3338, 0),
- new RSTile (3025, 3337, 0),
- new RSTile (3030, 3341, 0),
- new RSTile (3030, 3345, 0),
- new RSTile (3025, 3350, 0),
- new RSTile (3023, 3356, 0),
- new RSTile (3015, 3359, 0),
- new RSTile (3013, 3356, 0)};
- // RANDOM METHODS
- public boolean isExplodingRock(int distance, int explodingRockID){
- RSObject[] rock = Objects.find(distance, explodingRockID);
- return rock != null && rock.length > 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 havePickAxe(String pickaxename){
- RSItem[] pickAxe = Equipment.find(pickaxename);
- return pickAxe != null && pickAxe.length > 0;
- }
- private void withdrawPickAxe(int withdrawPickAxeAmount, String pickaxename){
- RSItem[] pickAxeBank = Banking.find(pickAxeName);
- if (pickAxeBank != null && pickAxeBank.length > 0){
- if (Banking.withdraw(withdrawPickAxeAmount, pickaxename)){
- 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;
- }
- }
- // COLOR RELATED METHODS
- // 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 coalAvailable(int[] rockID){
- RSObject[] coalRock = Objects.findNearest(6, rockID);
- return coalRock != null && coalRock.length > 0 && coalRock[0].isOnScreen();
- }
- private boolean mineCoal(int[] rockID, String mineOption, int oreID){
- 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);
- }
- }, 9000);
- }
- }
- return false;
- }
- //BANKING METHODS
- private boolean openBank() {
- if (!Banking.isBankScreenOpen()) {
- return Banking.openBankBooth();
- } else {
- if (Banking.isBankScreenOpen());
- return false;
- }
- }
- private void depositCoal(String coalName) {
- RSItem[] coal = Inventory.find(coalName);
- if (coal != null && coal.length > 0 && Banking.isBankScreenOpen()) {
- Banking.depositAll();
- sleep (300, 400);
- }
- }
- //LADDER METHODS
- private void climbLadder(String ladderName) {
- RSObject[] ladder = Objects.findNearest(10, ladderName);
- if (ladder != null && ladder.length > 0 && areaContainsPlayer(ladderUpArea)) {
- if (DynamicClicking.clickRSObject(ladder[0], "Climb-down")) {
- waitFor(new Condition() {
- @Override
- public boolean active() {
- return areaContainsPlayer(ladderUpArea) && !Player.isMoving();
- }
- }, 4000);
- }
- }
- if (ladder != null && ladder.length > 0 && areaContainsPlayer(ladderDownArea)){
- if (DynamicClicking.clickRSObject(ladder[0], "Climb-Up")){
- waitFor(new Condition() {
- @Override
- public boolean active() {
- return areaContainsPlayer(ladderDownArea) && !Player.isMoving() && Inventory.isFull();
- }
- }, 4000);
- }
- }
- }
- //AREA CHECKS
- private boolean atGuild(RSTile guild){
- return myPos.distanceTo(guild) < 28;
- }
- private boolean closeToDestination(RSTile whichTile, int radius){
- return myPos.distanceTo(whichTile) < radius;
- }
- private boolean areaContainsPlayer(Polygon area){
- return area.contains(Player.getPosition().getX(), Player.getPosition().getY());
- }
- //WALKING METHODS
- private void walkDestination(final RSTile[] whichPath, final RSTile whichTile, final Polygon whichArea, final int radius) {
- if (myPos != whichTile && !Player.isMoving()) {
- if (Walking.walkPath(whichPath)) {
- waitFor(new Condition() {
- @Override
- public boolean active() {
- return areaContainsPlayer(whichArea) && closeToDestination(whichTile, radius) && !Player.isMoving();
- }
- }, 4000);
- }
- }
- }
- private void walkDestinationCustom(final RSTile[] whichPath, final RSTile whichTile, final int radius) {
- if (myPos != whichTile && !Player.isMoving()) {
- if (Walking.walkPath(whichPath)) {
- waitFor(new Condition() {
- @Override
- public boolean active() {
- return closeToDestination(whichTile, radius) && !Player.isMoving();
- }
- }, 4000);
- }
- }
- }
- public enum State {
- OPENING_BANK, BANKING_COAL, CLOSING_BANK,
- WALKING_TO_LADDER_UP, WALKING_TO_LADDER_DOWN,
- WALKING_TO_GUILD, WALKING_TO_BANK,
- CLIMBING_LADDER, MINING, EQUIPING_PICKAXE,
- WITHDRAWING_PICKAXE, PAUSING;
- }
- private State getState(){
- if (paused){
- return State.PAUSING;
- }
- if (areaContainsPlayer(bankArea)){
- if (Inventory.isFull() && !Banking.isBankScreenOpen() && !havePickAxe(pickAxeName)){
- return State.OPENING_BANK;
- }
- if (Inventory.isFull() && Banking.isBankScreenOpen() && !havePickAxe(pickAxeName)){
- return State.BANKING_COAL;
- }
- if (Inventory.isFull() && Banking.isBankScreenOpen() && havePickAxe(pickAxeName)){
- return State.BANKING_COAL;
- }
- if (!havePickAxe(pickAxeName) && !Banking.isBankScreenOpen() && !pickAxeInInventory(pickAxeName)){
- return State.OPENING_BANK;
- }
- if (!havePickAxe(pickAxeName) && !Banking.isBankScreenOpen() && pickAxeInInventory(pickAxeName)){
- return State.EQUIPING_PICKAXE;
- }
- if (!havePickAxe(pickAxeName) && Banking.isBankScreenOpen() && !pickAxeInInventory(pickAxeName)){
- return State.WITHDRAWING_PICKAXE;
- }
- if (!havePickAxe(pickAxeName) && Banking.isBankScreenOpen() && pickAxeInInventory(pickAxeName)){
- return State.CLOSING_BANK;
- }
- if (Inventory.isFull() && !Banking.isBankScreenOpen() && havePickAxe(pickAxeName)){
- return State.OPENING_BANK;
- }
- if (!Inventory.isFull() && !Banking.isBankScreenOpen() && havePickAxe(pickAxeName)){
- return State.WALKING_TO_LADDER_UP;
- }
- if (!Inventory.isFull() && Banking.isBankScreenOpen() && havePickAxe(pickAxeName)){
- return State.CLOSING_BANK;
- }
- }
- if (areaContainsPlayer(ladderUpArea)){
- if (!Inventory.isFull() && havePickAxe(pickAxeName)){
- return State.CLIMBING_LADDER;
- }
- if (Inventory.isFull() || !havePickAxe(pickAxeName)){
- return State.WALKING_TO_BANK;
- }
- }
- if (areaContainsPlayer(ladderDownArea)){
- if (!Inventory.isFull() && havePickAxe(pickAxeName)){
- return State.WALKING_TO_GUILD;
- }
- if (Inventory.isFull() || !havePickAxe(pickAxeName)){
- return State.CLIMBING_LADDER;
- }
- }
- if (atGuild(secondGuildTile)){
- if (isExplodingRock(1, explodingRockID)){
- return State.WALKING_TO_GUILD;
- }
- if (!havePickAxe(pickAxeName)){
- return State.WALKING_TO_LADDER_DOWN;
- }
- if (!Inventory.isFull() && havePickAxe(pickAxeName) && coalAvailable(coalRockID)){
- return State.MINING;
- }
- if (Inventory.isFull()){
- return State.WALKING_TO_LADDER_DOWN;
- }
- if (!Inventory.isFull() || !coalAvailable(coalRockID) && havePickAxe(pickAxeName)){
- return State.WALKING_TO_GUILD;
- }
- }
- if (areaContainsPlayer(faladorArea)){
- if (!Inventory.isFull() && havePickAxe(pickAxeName)){
- return State.WALKING_TO_LADDER_UP;
- }
- if (Inventory.isFull() || !havePickAxe(pickAxeName)){
- return State.WALKING_TO_BANK;
- }
- }
- return null;
- }
- private Image getImage(String url) {
- try {
- return ImageIO.read(new URL(url));
- } catch (IOException e) {
- return null;
- }
- }
- private final Image img = getImage("http://i44.tinypic.com/2cmtbgo.jpg");
- private static final long startTime = System.currentTimeMillis();
- private State SCRIPT_STATE = getState();
- Font font = new Font("Calibri", Font.BOLD, 16);
- @SuppressWarnings("deprecation")
- private final int startXP = Skills.getXP("mining");
- private int START_XP;
- @SuppressWarnings("deprecation")
- @Override
- public void onPaint(Graphics g) {
- Graphics2D gg = (Graphics2D) g;
- gg.drawImage(img, 9, 345, null);
- long timeRan = System.currentTimeMillis() - startTime;
- double multiplier = timeRan / 3600000D;
- int price = 200;
- int currentLvl = Skills.getActualLevel("mining");
- int xpToNextLvl = Skills.getXPToNextLevel("mining");
- int xpGained = Skills.getXP("mining") - START_XP;
- double coal = xpGained / 50;
- g.setFont(font);
- g.setColor(new Color(149, 26, 12));
- g.drawString("ok_miningGuilder V" + version, 18, 360);
- g.drawString("Action: " + SCRIPT_STATE, 18, 375);
- g.drawString("Time running: " + Timing.msToString(timeRan), 18, 390);
- g.drawString("Coal p/h: " + (int) (coal / multiplier) + " p/h", 330, 420);
- g.drawString("Profit p/h: " + (int) ((coal / multiplier) * price) + " K", 330, 435);
- g.drawString("Coal mined: " + coal, 330, 450);
- g.drawString("Profit made: " + (double) ((coal * price) / 1000) + " K", 330, 465);
- g.drawString("XP Gained p/h: " + (int) (xpGained / multiplier), 330, 360);
- g.drawString("XP Gained: " + (int) xpGained, 330, 375);
- g.drawString("Current level: " + currentLvl, 330, 390);
- g.drawString("XP to Next Level: " + xpToNextLvl, 330, 405);
- }
- @Override
- public void run() {
- println("Started ok_miningGuilder");
- super.setRandomSolverState(true);
- Walking.setControlClick(true);
- while(true){
- if (loggedOut()) {
- super.setLoginBotState(active);
- } else {
- while (!loggedOut()) {
- START_XP = startXP;
- SCRIPT_STATE = getState();
- int mSpeed = General.random(120, 130);
- Mouse.setSpeed(mSpeed);
- Walking.setControlClick(true);
- switch (SCRIPT_STATE) {
- case BANKING_COAL:
- int rotation = General.random(90, 200);
- antiBan(rotation);
- depositCoal(coalOreName);
- sleep (400, 800);
- break;
- case CLIMBING_LADDER:
- int rotation9 = General.random(90, 200);
- antiBan(rotation9);
- climbLadder(ladderName);
- sleep (400, 800);
- break;
- case CLOSING_BANK:
- int rotation8 = General.random(90, 200);
- antiBan(rotation8);
- Banking.close();
- sleep (400, 800);
- break;
- case MINING:
- int rotation7 = General.random(90, 200);
- antiBan(rotation7);
- mineCoal(coalRockID, mineOption, coalOreID);
- break;
- case OPENING_BANK:
- int rotation6 = General.random(90, 200);
- antiBan(rotation6);
- openBank();
- sleep (400, 800);
- break;
- case WALKING_TO_BANK:
- int rotation1 = General.random(90, 200);
- antiBan(rotation1);
- walkDestination(bankPath, bankTile, bankArea, 8);
- sleep (400, 800);
- break;
- case WALKING_TO_GUILD:
- int rotation3 = General.random(90, 200);
- antiBan(rotation3);
- walkDestinationCustom(guildPath, secondGuildTile, 24);
- sleep (400, 800);
- break;
- case WALKING_TO_LADDER_DOWN:
- int rotation4 = General.random(90, 200);
- antiBan(rotation4);
- walkDestination(ladderDownPath, ladderDownTile, ladderDownArea, 8);
- sleep (400, 800);
- break;
- case WALKING_TO_LADDER_UP:
- int rotation5 = General.random(90, 200);
- antiBan(rotation5);
- walkDestination(ladderUpPath, ladderUpTile, ladderUpArea, 8);
- sleep (400, 800);
- break;
- case EQUIPING_PICKAXE:
- equipPickAxe(pickAxeName, wieldOption);
- break;
- case WITHDRAWING_PICKAXE:
- withdrawPickAxe(1, pickAxeName);
- break;
- case PAUSING:
- sleep (100, 200);
- }
- }
- }
- }
- }
- @Override
- public void onPause() {
- paused = true;
- while (paused){
- sleep (100, 200);
- }
- }
- @Override
- public void onResume() {
- paused = false;
- sleep (100, 200);
- }
- @Override
- public void onRandom(RANDOM_SOLVERS arg0) {
- onPause();
- }
- @Override
- public boolean randomFailed(RANDOM_SOLVERS arg0) {
- return false;
- }
- @Override
- public void randomSolved(RANDOM_SOLVERS arg0) {
- onResume();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement