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 java.awt.Image;
- import java.awt.Point;
- import java.io.IOException;
- import java.net.URL;
- import javax.imageio.ImageIO;
- import java.awt.event.MouseEvent;
- import java.awt.Rectangle;
- import org.osbot.script.MethodProvider;
- import org.osbot.script.Script;
- import org.osbot.script.ScriptManifest;
- import org.osbot.script.rs2.map.Position;
- import org.osbot.script.rs2.model.Entity;
- import org.osbot.script.rs2.model.Player;
- import org.osbot.script.rs2.model.RS2Object;
- import org.osbot.script.rs2.ui.Tab;
- import org.osbot.script.rs2.utility.Area;
- @ScriptManifest(author = "BrownBird", name = "BBtoadCollector", version = 1.5, info = "Collects swamp toad for money || V1.5")
- public class BBtoadCollector extends Script {
- boolean hide = false;
- Point p;
- Rectangle close = new Rectangle(499, 274, 509, 287);
- Rectangle open = new Rectangle(464, 316, 514, 336);
- public String TOAD = "Swamp toad";
- public String STAIR = "Staircase";
- public String BANK = "Bank booth";
- String status = "Starting script";
- public long startTime = 0;
- public long millis = 0;
- public long hours = 0;
- public long minutes = 0;
- public long seconds = 0;
- public long last = 0;
- int itemCount = 0;
- int currentItemCount = -1;
- public int toadsPH;
- public long moneyMade;
- public int moneyPH;
- public String run = "False";
- int toadPrice;
- // PATHS
- // Paths to swamp -
- private int[][] swampPath1 = new int[][] { { 2440, 3447 }, { 2433, 3461 },
- { 2428, 3474 }, { 2424, 3490 }, { 2421, 3501 },
- { 2419, 3508 } };
- private int[][] swampPath2 = new int[][] { { 2441, 3447 }, { 2432, 3458 },
- { 2431, 3473 }, { 2426, 3486 }, { 2425, 3500 },
- { 2420, 3508 } };
- private int[][] swampPath3 = new int[][] { { 2441, 3448 }, { 2436, 3460 },
- { 2431, 3471 }, { 2428, 3484 }, { 2428, 3498 },
- { 2419, 3507 } };
- // Paths to staircase -
- private int[][] bankPath1 = new int[][] { { 2419, 3508 }, { 2424, 3502 },
- { 2425, 3487 }, { 2427, 3471 }, { 2423, 3457 }, { 2437, 3449 },
- { 2445, 3437 } };
- private int[][] bankPath2 = new int[][] { { 2423, 3502 }, { 2428, 3488 },
- { 2436, 3478 }, { 2435, 3464 }, { 2438, 3450 }, { 2446, 3437 } };
- private int[][] bankPath3 = new int[][] { { 2426, 3500 }, { 2425, 3486 },
- { 2428, 3473 }, { 2436, 3461 }, { 2448, 3454 }, { 2434, 3443 },
- { 2446, 3437 } };
- private final Area swampArea = (new Area(2431, 3506, 2406, 3520));
- private final Area stairArea = (new Area(2442, 3432, 2449, 3440));
- @Override
- public void onStart() {
- log("BBtoadCollector Started!");
- startTime = System.currentTimeMillis();
- }
- @Override
- public void onExit() {
- log("Thanks for using BBtoadCollector!");
- log("Ran for: " + hours + ":" + minutes + ":" + seconds);
- log("Swamp toad collected: " + itemCount);
- log("Swamp toad collected P/H: " + toadsPH);
- log("Money Made: " + moneyMade);
- log("Money Made PH: " + moneyPH);
- log("Toad price: " + toadPrice);
- }
- @Override
- public int onLoop() throws InterruptedException {
- Player player = myPlayer();
- Entity toad = closestGroundItemForName(TOAD);
- Entity stair = closestObjectForName(STAIR);
- Entity bank = closestObjectForName(BANK);
- if(!Tab.INVENTORY.isOpen(null)) {
- openTab(Tab.INVENTORY);
- }
- int amt = (int) client.getInventory().getAmount(TOAD);
- if(currentItemCount == -1) currentItemCount = amt;
- else if(amt < currentItemCount) {
- currentItemCount = amt;
- } else {
- itemCount += amt - currentItemCount;
- currentItemCount = amt;
- }
- if (client.getInventory().getTotalItemsAmount() < 28
- && player.isInArea(swampArea)) {
- if (toad != null) {
- if (toad.isVisible()) {
- if (!player.isAnimating()) {
- if (!player.isMoving()) {
- status = "Picking up toad";
- toad.interact("Take");
- sleep(random(700,900));
- }
- }
- } else {
- if (!player.isAnimating()) {
- if (!player.isMoving()) {
- status = "Walking to toad";
- toad.getPosition().walkMinimap(bot);
- sleep(random(700, 900));
- }
- }
- }
- }
- }
- if (client.getInventory().isFull() && player.getZ() == 0) {
- status = "Going to bank";
- if (!player.isMoving()) {
- walkToBank();
- }
- }
- if (client.getInventory().isFull() && player.getZ() == 0 && player.isInArea(stairArea)) {
- if (stair != null) {
- if (!player.isAnimating() && !player.isMoving()) {
- if (stair.isVisible()) {
- status = "Climbing up stairs";
- stair.interact("Climb-Up");
- sleep(random(700,900));
- } else {
- client.moveCameraToEntity(stair);
- }
- }
- }
- }
- if (client.getInventory().isFull() && player.getZ() == 1) {
- if (bank != null) {
- if (!player.isAnimating() && !player.isMoving()) {
- if (bank.isVisible()) {
- status = "Banking";
- bankDeposit();
- } else {
- client.rotateCameraToAngle(random(100, 180));
- }
- }
- }
- }
- if (client.getInventory().isEmpty() && player.getZ() == 1) {
- if (stair != null) {
- if (!player.isAnimating() && !player.isMoving()) {
- if (stair.isVisible()) {
- status = "Climbing down stairs";
- stair.interact("Climb-down");
- } else {
- client.rotateCameraToAngle(350);
- }
- }
- }
- }
- if (client.getInventory().getTotalItemsAmount() == 0
- && player.getZ() == 0) {
- status = "Going to swamp";
- if (!player.isMoving()) {
- walkToSwamp();
- }
- }
- if (client.getRunEnergy() == 100 && run == "False") {
- status = "Toggling running";
- settingsTab.open();
- random(199, 246);
- setRunning(true);
- run = "True";
- }
- if(run == "True" && client.getRunEnergy() < 100) {
- run = "False";
- }
- AntiBan();
- return random(500, 650);
- }
- public void walkToBank() {
- switch (random(1, 3)) {
- case 1:
- WalkAlongPath(bankPath1, true);
- case 2:
- WalkAlongPath(bankPath2, true);
- case 3:
- WalkAlongPath(bankPath3, true);
- }
- }
- public void walkToSwamp() {
- switch (random(1, 3)) {
- case 1:
- WalkAlongPath(swampPath1, true);
- case 2:
- WalkAlongPath(swampPath2, true);
- case 3:
- WalkAlongPath(swampPath3, true);
- }
- }
- private Image getImage(String url) {
- try {
- return ImageIO.read(new URL(url));
- } catch (IOException e) {
- return null;
- }
- }
- private final Color color1 = new Color(0, 0, 0);
- private final Font font1 = new Font("Arial", 0, 14);
- private final Image img1 = getImage("http://i40.tinypic.com/1zq4gv6.png");
- private final Image img2 = getImage("http://i39.tinypic.com/29y1hnc.png");
- private final Image img3 = getImage("http://i42.tinypic.com/2lbo0p5.png");
- public void onPaint(Graphics graphics) {
- millis = System.currentTimeMillis() - startTime;
- hours = millis / (1000 * 60 * 60);
- millis -= hours * (1000 * 60 * 60);
- minutes = millis / (1000 * 60);
- millis -= minutes * (1000 * 60);
- seconds = millis / 1000;
- toadsPH = (int) ((itemCount) * 3600000D / (System.currentTimeMillis() - startTime));
- moneyMade = itemCount * toadPrice;
- moneyPH = (int) ((moneyMade) * 3600000D / (System.currentTimeMillis() - startTime));
- Graphics2D g = (Graphics2D) graphics;
- if (!hide) {
- g.drawImage(img1, 1, 196, null);
- g.drawImage(img2, 499, 274, null);
- g.setFont(font1);
- g.setColor(color1);
- g.drawString(" " + hours + " hours " + minutes + " minutes " + seconds + " seconds", 98, 292);
- g.drawString(" " + itemCount , 133, 310);
- g.drawString(" " + toadsPH, 164, 327);
- g.drawString(" " + moneyMade, 407, 293);
- g.drawString(" " + moneyPH, 430, 313);
- g.drawString(" " + status, 362, 334);
- } else {
- g.drawImage(img3, 464, 316, null);
- }
- }
- public void AntiBan() throws InterruptedException {
- Entity toad = closestGroundItemForName(TOAD);
- switch (random(1, 1000)) {
- case 23:
- status = "Anti-ban";
- client.moveCameraToEntity(toad);
- case 14:
- status = "Anti-ban";
- client.rotateCameraPitch(50);
- case 6:
- status = "Anti-ban";
- client.rotateCameraToAngle(350);
- case 3:
- status = "Anti-ban";
- openTab(Tab.SKILLS);
- case 56:
- status = "Anti-ban";
- openTab(Tab.ATTACK);
- case 106:
- status = "Anti-ban";
- openTab(Tab.QUEST);
- case 107:
- status = "Anti-ban";
- openTab(Tab.SETTINGS);
- case 108:
- status = "Anti-ban";
- openTab(Tab.SETTINGS);
- case 109:
- status = "Anti-ban";
- openTab(Tab.SETTINGS);
- case 530:
- status = "Anti-ban";
- client.rotateCameraPitch(50);
- }
- random(100, 500);
- }
- 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 {
- 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 void bankDeposit() throws InterruptedException {
- RS2Object booth = closestObjectForName(new String[] { "Bank booth" });
- if ((booth != null) && (booth.interact("Bank"))) {
- booth.interact("Bank");
- sleep(2500);
- }
- while (this.client.getMyPlayer().isMoving()) {
- sleep(1500);
- }
- if (this.client.getBank().isOpen()) {
- this.client.getBank().depositAll();
- sleep(1000);
- }
- if (this.client.getInventory().isEmpty()) {
- this.client.getBank().close();
- }
- }
- @Override
- public void mouseClicked(MouseEvent e) {
- p = e.getPoint();
- if (close.contains(p) && !hide) {
- hide = true;
- } else if (open.contains(p) && hide) {
- hide = false;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment