Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package BClayMiner;
- import java.awt.Color;
- import java.awt.Font;
- import java.awt.Graphics;
- import java.awt.Graphics2D;
- import org.osbot.script.MethodProvider;
- import org.osbot.script.Script;
- import org.osbot.script.ScriptManifest;
- import org.osbot.script.mouse.RectangleDestination;
- import org.osbot.script.rs2.map.Position;
- import org.osbot.script.rs2.model.Entity;
- import org.osbot.script.rs2.model.GroundItem;
- import org.osbot.script.rs2.model.Player;
- import org.osbot.script.rs2.skill.Skill;
- import org.osbot.script.rs2.skill.Skills;
- import org.osbot.script.rs2.ui.Inventory;
- import org.osbot.script.rs2.ui.Tab;
- import org.osbot.script.rs2.utility.Area;
- @ScriptManifest(author = "Zappa", info = "Mines Clay v1.3", name = "BClayMiner", version = 1.3)
- public class BClayMiner extends Script {
- private State state;
- static Timer runTime = new Timer(0);
- private int[][] MinePos = { { 2964, 3224, 0 }, { 2971, 3228, 0 },
- { 2976, 3235, 0 }, { 2986, 3240, 0 } };
- private Area Bank = new Area(2438, 3082, 2444, 3096);
- private Area MineArea = new Area(2984, 3236, 2989, 3242);
- private static final int[] RockID = { 3032, 10778 };
- private final int[] pickAxeHeadId = { 480, 481, 482, 483, 484, 485, 486,
- 487, 488, 489, 490, 491 };
- private final int[] pickAxe = { 1275, 1265, 1267, 1269, 1273, 1271 };
- int claymined = 0;
- int startEXP;
- int startLevel;
- public int runes = 0;
- public void onStart() {
- if (this.client.getMyPlayer().isInArea(Bank)
- && (this.client.getInventory().contains(8013) && ((this.client
- .getInventory().contains(2554) || (this.client
- .getInventory().contains(2556) || (this.client
- .getInventory().contains(2558) || (this.client
- .getInventory().contains(2560) || (this.client
- .getInventory().contains(2562) || (this.client
- .getInventory().contains(2564) || (this.client
- .getInventory().contains(2566) || (this.client
- .getInventory().contains(2552)))))))))))) {
- this.state = State.TELETOHOUSE;
- } else if (this.client.getMyPlayer().isInArea(Bank)
- && (this.client.getInventory().contains(563) && (this.client
- .getInventory().contains(557) && ((this.client
- .getInventory().contains(2554) || (this.client
- .getInventory().contains(2556) || (this.client
- .getInventory().contains(2558) || (this.client
- .getInventory().contains(2560) || (this.client
- .getInventory().contains(2562) || (this.client
- .getInventory().contains(2564) || (this.client
- .getInventory().contains(2566) || (this.client
- .getInventory().contains(2552))))))))))))) {
- runes = 1;
- this.state = State.TELETOHOUSERUNES;
- }
- runTime = new Timer(0);
- startEXP = client.getSkills().getExperience(Skill.MINING);
- startLevel = client.getSkills().getLevel(Skill.MINING);
- }
- public boolean WalkAlongPath(int[][] path, boolean AscendThroughPath,
- int distanceFromEnd) {
- if (distanceToPoint(AscendThroughPath ? path[path.length - 1][0]
- : path[0][0], AscendThroughPath ? path[path.length - 1][1]
- : path[0][1]) <= distanceFromEnd)
- return true;
- else {
- WalkAlongPath(path, AscendThroughPath);
- return false;
- }
- }
- public void WalkAlongPath(int[][] path, boolean AscendThroughPath) {
- int destination = 0;
- for (int i = 0; i < path.length; i++)
- if (distanceToPoint(path[i][0], path[i][1]) < distanceToPoint(
- path[destination][0], path[destination][1]))
- destination = i;
- if (client.getMyPlayer().isMoving()
- && distanceToPoint(path[destination][0], path[destination][1]) > (isRunning() ? 3
- : 2))
- return;
- if (AscendThroughPath && destination != path.length - 1
- || !AscendThroughPath && destination != 0)
- destination += (AscendThroughPath ? 1 : -1);
- try {
- log("Walking to node:" + destination);
- walk(new Position(path[destination][0], path[destination][1], 0));
- Thread.sleep(700 + MethodProvider.random(600));
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- }
- private int distanceToPoint(int pointX, int pointY) {
- return (int) Math.sqrt(Math
- .pow(client.getMyPlayer().getX() - pointX, 2)
- + Math.pow(client.getMyPlayer().getY() - pointY, 2));
- }
- public int onLoop() throws InterruptedException {
- if (((this.client.getRunEnergy() > 40) && (this.state != State.MINE) && (this.state != State.BANK))) {
- try {
- setRunning(true);
- } catch (Exception localException) {
- }
- }
- if (this.state == State.TELETOHOUSE) {
- return teleToHouse();
- } else if (this.state == State.LEAVEHOUSE) {
- return leaveHouse();
- } else if (this.state == State.WALKTOMINE) {
- return walkToMine();
- } else if (this.state == State.MINE) {
- return mine();
- } else if (this.state == State.TELETOBANK) {
- return teleToBank();
- } else if (this.state == State.BANK) {
- return bank();
- } else if (this.state == State.TELETOHOUSERUNES) {
- return teleToHouseRunes();
- }
- return 250 + (50);
- }
- public int teleToHouse() throws InterruptedException {
- if (currentTab() != Tab.INVENTORY) {
- openTab(Tab.INVENTORY);
- sleep(110 + random(40, 50));
- }
- if (this.client.getInventory().contains(8013)) {
- selectInventoryOption(
- this.client.getInventory().getSlotForId(8013), "Break");
- sleep(7000);
- }
- this.state = State.LEAVEHOUSE;
- return 250;
- }
- public int teleToHouseRunes() throws InterruptedException {
- Player player = client.getMyPlayer();
- if (!player.isAnimating()) {
- if (currentTab() != Tab.MAGIC) {
- openTab(Tab.MAGIC);
- sleep(110 + random(40, 50));
- }
- client.moveMouseTo(new RectangleDestination(618, 309, 10, 10),
- false, true, false);
- sleep(7000);
- }
- this.state = State.LEAVEHOUSE;
- return 250;
- }
- public int leaveHouse() throws InterruptedException {
- Entity portal = closestObject(4525);
- if (portal != null) {
- log("Portal found!");
- if (portal.isVisible()) {
- portal.interact("Enter");
- sleep(random(1000, 1200));
- } else {
- client.moveCameraToEntity(portal);
- }
- } else {
- log("Portal Not Found");
- }
- this.state = State.WALKTOMINE;
- return 250;
- }
- public int walkToMine() {
- try {
- WalkAlongPath(MinePos, true);
- } catch (Exception localException) {
- }
- if (this.client.getMyPlayer().isInArea(MineArea)) {
- this.state = State.MINE;
- }
- return 250;
- }
- public int mine() {
- try {
- Player player = this.client.getMyPlayer();
- Inventory inven = this.client.getInventory();
- Entity rocks = closestObject(RockID);
- if (inven.isFull()) {
- this.state = State.TELETOBANK;
- return 250;
- }
- if (!player.isAnimating() && (rocks != null)) {
- rocks.interact("Mine");
- getTheHead();
- checkForSmoker();
- sleep(random(600, 1100));
- }
- } catch (Exception localException) {
- }
- return 250;
- }
- public int teleToBank() throws InterruptedException {
- try {
- if (currentTab() != Tab.INVENTORY) {
- openTab(Tab.INVENTORY);
- }
- if (this.client.getInventory().contains(2552))
- selectInventoryOption(
- this.client.getInventory().getSlotForId(2552), "Rub");
- else if (this.client.getInventory().contains(2554))
- selectInventoryOption(
- this.client.getInventory().getSlotForId(2554), "Rub");
- else if (this.client.getInventory().contains(2556))
- selectInventoryOption(
- this.client.getInventory().getSlotForId(2556), "Rub");
- else if (this.client.getInventory().contains(2558))
- selectInventoryOption(
- this.client.getInventory().getSlotForId(2558), "Rub");
- else if (this.client.getInventory().contains(2560))
- selectInventoryOption(
- this.client.getInventory().getSlotForId(2560), "Rub");
- else if (this.client.getInventory().contains(2562))
- selectInventoryOption(
- this.client.getInventory().getSlotForId(2562), "Rub");
- else if (this.client.getInventory().contains(2564))
- selectInventoryOption(
- this.client.getInventory().getSlotForId(2564), "Rub");
- else if (this.client.getInventory().contains(2566)) {
- selectInventoryOption(
- this.client.getInventory().getSlotForId(2566), "Rub");
- }
- Thread.sleep(1000L);
- } catch (Exception localException) {
- }
- sleep(1000);
- client.moveMouseTo(new RectangleDestination(255, 417, 10, 10), false,
- true, false);
- sleep(5000);
- if (this.client.getMyPlayer().isInArea(Bank)) {
- walkExact(new Position(2443, 3083, 0));
- this.state = State.BANK;
- }
- return 250;
- }
- public int bank() {
- try {
- if (!this.client.getBank().isOpen()) {
- try {
- selectEntityOption(
- closestObjectForName(new String[] { "Bank Chest" }),
- true, "Use");
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- } else {
- try {
- this.client.getBank().depositAllExcept(
- new int[] { 8013, 563, 556, 557, 2554, 2556, 2558,
- 2560, 2562, 2564, 2566, 2522, 1275, 1265,
- 1267, 1269, 1273, 1271 });
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- if (runes == 0) {
- if (this.client.getInventory().contains(8013)
- && ((this.client.getInventory().contains(2554) || (this.client
- .getInventory().contains(2556) || (this.client
- .getInventory().contains(2558) || (this.client
- .getInventory().contains(2560) || (this.client
- .getInventory().contains(2562) || (this.client
- .getInventory().contains(2564) || (this.client
- .getInventory().contains(2566) || (this.client
- .getInventory().contains(2552))))))))))) {
- if (!client.getInventory().isFull()) {
- this.client.getBank().close();
- if (runes == 0) {
- this.state = State.TELETOHOUSE;
- } else if (runes == 1) {
- this.state = State.TELETOHOUSERUNES;
- }
- }
- } else {
- this.client.getBank().withdraw1(2552);
- this.client.getBank().close();
- if (runes == 0) {
- this.state = State.TELETOHOUSE;
- } else if (runes == 1) {
- this.state = State.TELETOHOUSERUNES;
- }
- }
- } else if (runes == 1) {
- if (this.client.getInventory().contains(563)
- && (this.client.getInventory().contains(557) && ((this.client
- .getInventory().contains(2554) || (this.client
- .getInventory().contains(2556) || (this.client
- .getInventory().contains(2558) || (this.client
- .getInventory().contains(2560) || (this.client
- .getInventory().contains(2562) || (this.client
- .getInventory().contains(2564) || (this.client
- .getInventory().contains(2566) || (this.client
- .getInventory().contains(2552)))))))))))) {
- if (!client.getInventory().isFull()) {
- this.client.getBank().close();
- if (runes == 0) {
- this.state = State.TELETOHOUSE;
- } else if (runes == 1) {
- this.state = State.TELETOHOUSERUNES;
- }
- }
- } else {
- this.client.getBank().withdraw1(2552);
- this.client.getBank().close();
- if (runes == 0) {
- this.state = State.TELETOHOUSE;
- } else if (runes == 1) {
- this.state = State.TELETOHOUSERUNES;
- }
- }
- }
- }
- } catch (InterruptedException localInterruptedException1) {
- }
- return 1000;
- }
- public void checkForSmoker() throws InterruptedException {
- Position da = myPlayer().getPosition();
- Entity rocks = closestObject(RockID);
- while ((this.client.getMyPlayer().isAnimating())
- && (!rocks.isInArea(this.MineArea))) {
- log("SmokinRocks");
- da.interact(this.bot, "Walk here");
- sleep(random(9000, 10000));
- }
- }
- public void getTheHead() throws InterruptedException {
- GroundItem pickAxeHead = closestGroundItem(this.pickAxeHeadId);
- if (pickAxeHead == null) {
- return;
- }
- if (pickAxeHead.isVisible()) {
- pickAxeHead.interact("Take");
- } else {
- this.client.moveCameraToEntity(pickAxeHead);
- pickAxeHead.interact("Take");
- stop();
- }
- }
- public void onPaint(Graphics g) {
- Graphics2D gr = (Graphics2D) g;
- gr.setColor(Color.WHITE);
- gr.setFont(new Font("Arial", Font.PLAIN, 10));
- Skills skills = client.getSkills();
- gr.drawString("State: " + this.state, 25, 140);
- gr.drawString("Clay Mined: " + claymined, 25, 50);
- gr.drawString("Clay Mined/h: " + getPerHour(claymined), 25, 65);
- gr.drawString("Exp gained: "
- + (skills.getExperience(Skill.MINING) - startEXP), 25, 80);
- gr.drawString(
- "Exp gained/h: "
- + getPerHour(skills.getExperience(Skill.MINING)
- - startEXP), 25, 95);
- gr.drawString(
- "Level: " + (startLevel) + " + ("
- + (skills.getLevel(Skill.MINING) - startLevel + ")"),
- 25, 110);
- if (runTime != null) {
- g.drawString("Runtime: " + Timer.format(runTime.getElapsed()), 25,
- 125);
- }
- g.drawString("By Zappa", 443, 465);
- }
- public static int getPerHour(int value) {
- if (runTime != null && runTime.getElapsed() > 0) {
- return (int) (value * 3600000d / runTime.getElapsed());
- } else {
- return 0;
- }
- }
- public static long getPerHour(long value) {
- if (runTime != null && runTime.getElapsed() > 0) {
- return (long) (value * 3600000d / runTime.getElapsed());
- } else {
- return 0;
- }
- }
- public void onMessage(String message) throws InterruptedException {
- if (message.contains("You manage to mine some clay")) {
- claymined++;
- }
- }
- static enum State {
- TELETOHOUSE, LEAVEHOUSE, WALKTOMINE, MINE, TELETOBANK, BANK, TELETOHOUSERUNES;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment