Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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.NPC;
- import org.osbot.script.rs2.model.Player;
- import org.osbot.script.rs2.utility.Area;
- @ScriptManifest(author = "Zappa", info = "Tans hides in Al Kharid v1.1", name = "BTanner", version = 1.1)
- public class BHideTanner extends Script {
- private State state;
- static Timer runTime = new Timer(0);
- private int[][] TannerPos = { { 3275, 3169, 0 }, { 3278, 3178, 0 },
- { 3281, 3185, 0 }, { 3278, 3191, 0 } };
- private int[][] BankPos = { { 3281, 3189, 0 }, { 3280, 3182, 0 },
- { 3278, 3175, 0 }, { 3275, 3170, 0 }, { 3270, 3167, 0 } };
- private Area TanArea = new Area(3273, 3189, 3276, 3194);
- private Area BankArea = new Area(3269, 3161, 3272, 3173);
- private final int[] hides = { 1739, 1747, 1749, 1751, 1753 };
- int cowHide = 0;
- int greenD = 0;
- int blueD = 0;
- int redD = 0;
- int blackD = 0;
- int hidesTanned = 0;
- int coins = 995;
- int npcID = 5808;
- int hideWithdraw;
- public void onStart() {
- if (this.client.getInventory().contains(1739)) {
- cowHide = 1;
- hideWithdraw = 1739;
- } else if (this.client.getInventory().contains(1747)) {
- blackD = 1;
- hideWithdraw = 1747;
- } else if (this.client.getInventory().contains(1749)) {
- redD = 1;
- hideWithdraw = 1749;
- } else if (this.client.getInventory().contains(1751)) {
- blueD = 1;
- hideWithdraw = 1751;
- } else if (this.client.getInventory().contains(1753)) {
- greenD = 1;
- hideWithdraw = 1753;
- }
- if (this.client.getMyPlayer().isInArea(this.BankArea)) {
- this.state = State.TOTANNER;
- }
- if (this.client.getMyPlayer().isInArea(this.TanArea)) {
- this.state = State.TAN;
- }
- runTime = new Timer(0);
- }
- 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.TAN)
- && (this.state != State.BANK)) {
- try {
- setRunning(true);
- } catch (Exception localException) {
- }
- }
- if (this.state == State.TOBANK) {
- return toBank();
- } else if (this.state == State.TOTANNER) {
- return toTan();
- } else if (this.state == State.TAN) {
- return tan();
- } else if (this.state == State.BANK) {
- return bank();
- } else if (this.state == State.ENTERSHOP) {
- return enterShop();
- }
- return 250 + random(50);
- }
- public int toTan() throws InterruptedException {
- try {
- WalkAlongPath(TannerPos, true);
- } catch (Exception localException) {
- }
- sleep(2000);
- this.state = State.ENTERSHOP;
- return 250;
- }
- public int enterShop() throws InterruptedException {
- walkExact(new Position(3276, 3191, 0));
- if (this.client.getMyPlayer().isInArea(this.TanArea))
- this.state = State.TAN;
- return 250;
- }
- public int tan() throws InterruptedException {
- if (this.client.getOpenInterface() == null) {
- NPC localNPC = closestNPCForName("Ellis");
- if (localNPC == null) {
- log("Cannot find shop keeper: " + this.npcID + " !");
- return 0;
- }
- if (localNPC != null) {
- if (localNPC.isVisible()) {
- localNPC.interact("Trade");
- } else {
- client.moveCameraToEntity(localNPC);
- }
- }
- return 1000;
- }
- if (greenD != 0) {
- client.moveMouseTo(new RectangleDestination(91, 235, 10, 10),
- false, true, true);
- client.moveMouseTo(new RectangleDestination(60, 307, 10, 10),
- false, true, false);
- } else if (cowHide != 0) {
- client.moveMouseTo(new RectangleDestination(91, 101, 10, 10),
- false, true, true);
- client.moveMouseTo(new RectangleDestination(64, 172, 10, 10),
- false, true, false);
- } else if (blackD != 0) {
- client.moveMouseTo(new RectangleDestination(431, 234, 10, 10),
- false, true, true);
- client.moveMouseTo(new RectangleDestination(401, 306, 10, 10),
- false, true, false);
- } else if (redD != 0) {
- client.moveMouseTo(new RectangleDestination(323, 231, 10, 10),
- false, true, true);
- client.moveMouseTo(new RectangleDestination(291, 302, 10, 10),
- false, true, false);
- } else if (blueD != 0) {
- client.moveMouseTo(new RectangleDestination(210, 235, 10, 10),
- false, true, true);
- client.moveMouseTo(new RectangleDestination(179, 306, 10, 10),
- false, true, false);
- }
- walkExact(new Position(3277, 3191, 0));
- sleep(200);
- this.state = State.TOBANK;
- return 250;
- }
- public int toBank() {
- try {
- WalkAlongPath(BankPos, true);
- } catch (Exception localException) {
- }
- if (this.client.getMyPlayer().isInArea(this.BankArea))
- this.state = State.BANK;
- return 250;
- }
- public int bank() {
- try {
- if (!this.client.getBank().isOpen()) {
- try {
- selectEntityOption(
- closestObjectForName(new String[] { "Bank booth" }),
- true, "Bank");
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- } else {
- try {
- this.client.getBank().depositAllExcept(this.coins);
- this.client.getBank().withdrawAll(hideWithdraw);
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- if (client.getInventory().isFull()) {
- this.client.getBank().close();
- this.state = State.TOTANNER;
- }
- }
- } catch (InterruptedException localInterruptedException1) {
- }
- return 1000;
- }
- public void onPaint(Graphics g) {
- Graphics2D gr = (Graphics2D) g;
- gr.setColor(Color.WHITE);
- gr.setFont(new Font("Arial", Font.PLAIN, 10));
- gr.drawString("State: " + this.state, 25, 95);
- gr.drawString("Hides Tanned: " + hidesTanned, 25, 50);
- gr.drawString("Hides Tanned/h: " + getPerHour(hidesTanned), 25, 65);
- if (runTime != null) {
- g.drawString("Runtime: " + Timer.format(runTime.getElapsed()), 25,
- 80);
- }
- 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("The tanner tans")) {
- hidesTanned = hidesTanned + 27;
- }
- }
- static enum State {
- TOTANNER, TAN, TOBANK, BANK, ENTERSHOP;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment