Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package BFungus;
- import java.awt.Color;
- import java.awt.Font;
- import java.awt.Graphics;
- import java.awt.Graphics2D;
- import java.util.ArrayList;
- import java.util.Iterator;
- 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.Player;
- import org.osbot.script.rs2.model.RS2Object;
- import org.osbot.script.rs2.skill.Skill;
- import org.osbot.script.rs2.ui.Tab;
- import org.osbot.script.rs2.utility.Area;
- @ScriptManifest(name = "BFungus", info = "Collects fungus in mort myre swamp - v1.9.20", version = 1.9, author = "Zappa")
- public class BFungus extends Script {
- private State state;
- static Timer runTime = new Timer(0);
- private int[] praypots = { 139, 141, 143, 2434 };
- private int[][] Gate = { { 3506, 3480, 0 }, { 3496, 3481, 0 },
- { 3486, 3480, 0 }, { 3477, 3476, 0 }, { 3467, 3474, 0 },
- { 3456, 3473, 0 }, { 3449, 3467, 0 }, { 3444, 3462, 0 },
- { 3444, 3458, 0 } };
- private int[][] Fungus = { { 3437, 3455, 0 }, { 3431, 3449, 0 },
- { 3426, 3443, 0 } };
- private int[][] Gate_Back = { { 3426, 3443, 0 }, { 3431, 3449, 0 },
- { 3437, 3455, 0 } };
- private int[][] Bank = { { 3449, 3467, 0 }, { 3456, 3473, 0 },
- { 3467, 3474, 0 }, { 3477, 3476, 0 }, { 3486, 3480, 0 },
- { 3496, 3481, 0 }, { 3506, 3480, 0 }, { 3512, 3480, 0 } };
- private int[][] Altar = { { 3228, 3218, 0 }, { 3237, 3210, 0 } };
- private int[][] AncientBank = { { 3494, 3478, 0 }, { 3502, 3481, 0 },
- { 3511, 3478, 0 } };
- private int runs;
- private int fungiamount;
- private int fungiID = 3509;
- private Area Gate_North = new Area(3453, 3472, 3439, 3458);
- private Area Gate_South = new Area(3448, 3457, 3432, 3450);
- private Area Fungi_Area = new Area(3428, 3445, 3417, 3434);
- private Area Bank_Area = new Area(3507, 3484, 3515, 3473);
- private Area lumbTeleArea = new Area(3219, 3212, 3225, 3226);
- private Area AltarDoor = new Area(3235, 3212, 3237, 3208);
- private Area Chapel = new Area(3240, 3205, 3247, 3215);
- private Area barArea = new Area(3489, 3471, 3499, 3477);
- int pot3 = 0;
- int lumbPath = 0;
- private Position FUNGI = new Position(3421, 3439, 0);
- public void onStart() {
- if (this.client.getInventory().contains(8008)
- && (this.client.getInventory().contains(565) && this.client
- .getInventory().contains(563))) {
- lumbPath = 1;
- }
- if (lumbPath == 0) {
- if (this.client.getInventory().contains(139)) {
- pot3 = 0;
- } else if (this.client.getInventory().contains(2434)) {
- pot3 = 1;
- } else if (!this.client.getInventory().contains(139)
- && (!this.client.getInventory().contains(2434))) {
- try {
- stop();
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- }
- }
- this.state = State.Gate_Path;
- 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 void onMessage(String message) {
- if (message.contains("You skip gladly")) {
- this.state = State.Bank_Path;
- this.runs += 1;
- } else if (message.contains("You walk into the gloomy")) {
- this.state = State.TOFUNGUS;
- } else if (message.contains("You have finished")) {
- if (lumbPath == 0) {
- this.state = State.DROP;
- }
- } else if (message.contains("You've run out")) {
- if (lumbPath == 0) {
- this.state = State.PRAYPOT;
- }
- } else if (message.contains("You have no more space")) {
- if (lumbPath == 0) {
- this.state = State.Gate_Path_Back;
- } else if (lumbPath == 1) {
- this.state = State.TOLUMB;
- }
- } else if (message.contains("You need some prayer points")) {
- if (lumbPath == 0) {
- this.state = State.Gate_Path_Back;
- } else if (lumbPath == 1) {
- this.state = State.TOLUMB;
- }
- }
- if (message.contains("You pick a mushroom"))
- this.fungiamount += 1;
- }
- public int onLoop() throws InterruptedException {
- if ((this.client.getRunEnergy() > 40) && (this.state != State.OPERATE)
- && (this.state != State.PICKUP))
- try {
- setRunning(true);
- } catch (Exception localException) {
- }
- if (this.state == State.BANK) {
- return bank();
- } else if (this.state == State.Gate_Path) {
- return Gate_Path();
- } else if (this.state == State.TOFUNGUS) {
- return toFungus();
- } else if (this.state == State.DROP) {
- return dropPot();
- } else if (this.state == State.PRAYPOT) {
- return drinkPot();
- } else if (this.state == State.PICKUP) {
- return pickup();
- } else if (this.state == State.OPERATE) {
- return operate();
- } else if (this.state == State.OPENGATE) {
- return openGate();
- } else if (this.state == State.Gate_Path_Back) {
- return Gate_Path_Back();
- } else if (this.state == State.Bank_Path) {
- return Bank_Path();
- } else if (this.state == State.TOLUMB) {
- return teleToLumb();
- } else if (this.state == State.TOPRAY) {
- return toPray();
- } else if (this.state == State.PRAY) {
- return pray();
- } else if (this.state == State.TELETOBANK) {
- return teleToBank();
- } else if (this.state == State.ANCIENTWALKTOBANK) {
- return ancientWalkToBank();
- } else if (this.state == State.OPENDOOR) {
- return openDoor();
- } else if (this.state == State.ENTERCHAPEL) {
- return enterChapel();
- }
- return 250 + random(50);
- }
- public int teleToLumb() throws InterruptedException {
- if (currentTab() != Tab.INVENTORY) {
- openTab(Tab.INVENTORY);
- sleep(110 + random(40, 50));
- }
- if (this.client.getInventory().contains(8008)) {
- selectInventoryOption(
- this.client.getInventory().getSlotForId(8008), "Break");
- sleep(6000);
- }
- if (this.client.getMyPlayer().isInArea(lumbTeleArea)) {
- this.state = State.TOPRAY;
- }
- return 250;
- }
- public int toPray() {
- try {
- WalkAlongPath(Altar, true);
- Thread.sleep(3000L);
- } catch (Exception localException) {
- }
- if (this.client.getMyPlayer().isInArea(AltarDoor)) {
- this.state = State.OPENDOOR;
- }
- return 250;
- }
- public int openDoor() throws InterruptedException {
- Entity door = closestObject(20131);
- if (door != null) {
- log("Door found!");
- if (door.isVisible()) {
- door.interact("Open");
- sleep(random(700, 800));
- } else {
- client.moveCameraToEntity(door);
- }
- } else {
- log("Door Not Found");
- }
- this.state = State.ENTERCHAPEL;
- return 250;
- }
- public int enterChapel() throws InterruptedException {
- walkExact(new Position(3243, 3210, 0));
- if (this.client.getMyPlayer().isInArea(Chapel)) {
- this.state = State.PRAY;
- }
- return 250;
- }
- private int pray() throws InterruptedException {
- Entity altar = closestObject(409);
- if (altar != null) {
- log("Altar found!");
- if (altar.isVisible()) {
- altar.interact("Pray-at");
- sleep(random(1000, 1200));
- } else {
- client.moveCameraToEntity(altar);
- }
- } else {
- log("Altar Not Found");
- }
- this.state = State.TELETOBANK;
- return 250;
- }
- private int teleToBank() 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(621, 280, 10, 10),
- false, true, false);
- sleep(6000);
- }
- if (this.client.getMyPlayer().isInArea(barArea)) {
- this.state = State.ANCIENTWALKTOBANK;
- }
- return 250;
- }
- public int ancientWalkToBank() throws InterruptedException {
- if (currentTab() != Tab.INVENTORY) {
- openTab(Tab.INVENTORY);
- sleep(110 + random(40, 50));
- }
- try {
- WalkAlongPath(AncientBank, true);
- Thread.sleep(3000L);
- } catch (Exception localException) {
- }
- if (this.client.getMyPlayer().isInArea(Bank_Area)) {
- this.state = State.BANK;
- }
- return 250;
- }
- public int dropPot() {
- try {
- selectInventoryOption(this.client.getInventory().getSlotForId(229),
- "Drop");
- } catch (Exception localException) {
- }
- if (this.client.getMyPlayer().isInArea(this.Fungi_Area))
- this.state = State.OPERATE;
- else if ((this.client.getMyPlayer().isInArea(this.Gate_North))
- || (this.client.getMyPlayer().isInArea(this.Gate_South)))
- this.state = State.OPENGATE;
- else {
- this.state = State.Gate_Path;
- }
- return 250;
- }
- public int toFungus() {
- try {
- WalkAlongPath(Fungus, true);
- walkMainScreen(this.FUNGI, false);
- Thread.sleep(3000L);
- } catch (Exception localException) {
- }
- if (this.client.getMyPlayer().isInArea(this.Fungi_Area))
- this.state = State.OPERATE;
- return 250;
- }
- public int drinkPot() {
- try {
- if (currentTab() != Tab.INVENTORY) {
- openTab(Tab.INVENTORY);
- }
- if (this.client.getInventory().contains(143))
- selectInventoryOption(
- this.client.getInventory().getSlotForId(143), "Drink");
- else if (this.client.getInventory().contains(141))
- selectInventoryOption(
- this.client.getInventory().getSlotForId(141), "Drink");
- else if (this.client.getInventory().contains(139))
- selectInventoryOption(
- this.client.getInventory().getSlotForId(139), "Drink");
- else if (this.client.getInventory().contains(2434)) {
- selectInventoryOption(
- this.client.getInventory().getSlotForId(2434), "Drink");
- }
- Thread.sleep(1000L);
- } catch (Exception localException) {
- }
- this.state = State.PICKUP;
- 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 {
- if (lumbPath == 0) {
- this.client.getBank().depositAllExcept(this.praypots);
- if (pot3 != 0) {
- if (client.getBank().isOpen()
- && !client.getBank().contains(2434)) {
- client.getBank().close();
- stop();
- }
- } else {
- if (client.getBank().isOpen()
- && !client.getBank().contains(139)) {
- client.getBank().close();
- stop();
- }
- }
- } else {
- this.client.getBank().depositAllExcept(
- new int[] { 8008, 565, 563 });
- }
- if (lumbPath == 0) {
- if (pot3 != 0) {
- if ((!this.client.getInventory().contains(2434))
- && (!this.client.getInventory().contains(
- 141))) {
- this.client.getBank().withdraw1(2434);
- } else {
- if ((!this.client.getInventory().contains(139))
- && (!this.client.getInventory()
- .contains(141))) {
- this.client.getBank().withdraw1(139);
- }
- }
- }
- }
- if (this.client.getSkills()
- .getCurrentLevel(Skill.HITPOINTS) <= 32)
- this.client.getBank().withdraw1(379);
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- if (lumbPath == 0) {
- if ((this.client.getInventory().contains(139))
- || (this.client.getInventory().contains(141))
- || (this.client.getInventory().contains(2434))) {
- this.client.getBank().close();
- this.state = State.Gate_Path;
- }
- } else {
- this.client.getBank().close();
- this.state = State.Gate_Path;
- }
- }
- } catch (InterruptedException localInterruptedException1) {
- }
- return 1000;
- }
- public int Gate_Path_Back() {
- try {
- WalkAlongPath(Gate_Back, true);
- } catch (Exception localException) {
- }
- if (this.client.getMyPlayer().isInArea(this.Gate_South))
- this.state = State.OPENGATE;
- return 250;
- }
- public int operate() {
- try {
- if (this.client.getSkills().getCurrentLevel(Skill.PRAYER) <= 1) {
- if (lumbPath != 0) {
- this.state = State.TOLUMB;
- } else if (lumbPath == 0) {
- this.state = State.Gate_Path_Back;
- return 250;
- }
- }
- if (this.client.getMyPlayer().getPosition() != this.FUNGI) {
- walkMainScreen(this.FUNGI, false);
- Thread.sleep(100L);
- }
- if (currentTab() != Tab.EQUIPMENT) {
- openTab(Tab.EQUIPMENT);
- }
- this.client.getInterface(387).getChild(16).interact("Operate");
- Thread.sleep(2000L);
- } catch (Exception localException) {
- }
- this.state = State.PICKUP;
- return 250;
- }
- public int pickup() throws InterruptedException {
- for (RS2Object obj : this.client.getCurrentRegion().getObjects())
- if (obj.getId() == this.fungiID)
- try {
- obj.interact("Pick", "Fungi on log", false, 5, false, false);
- sleep(random(1200, 1600));
- } catch (Exception localException) {
- }
- this.state = State.OPERATE;
- return 250;
- }
- public int Bank_Path() {
- try {
- WalkAlongPath(Bank, true);
- } catch (Exception localException) {
- }
- if (this.client.getMyPlayer().isInArea(this.Bank_Area)) {
- this.state = State.BANK;
- }
- return 250;
- }
- public int openGate() {
- for (RS2Object obj : this.client.getCurrentRegion().getObjects()) {
- if ((obj.getName() != null)
- && (obj.getName().equalsIgnoreCase("gate")))
- try {
- obj.interact("Open");
- sleep(random(600, 1200));
- } catch (Exception localException) {
- }
- }
- return 250;
- }
- public int Gate_Path() {
- try {
- WalkAlongPath(Gate, true);
- if (lumbPath == 0) {
- if (this.client.getSkills().getCurrentLevel(Skill.PRAYER) <= 2) {
- if (this.client.getInventory().contains(143)) {
- selectInventoryOption(this.client.getInventory()
- .getSlotForId(143), "Drink");
- } else if (this.client.getInventory().contains(141)) {
- selectInventoryOption(this.client.getInventory()
- .getSlotForId(141), "Drink");
- } else if (this.client.getInventory().contains(139)) {
- selectInventoryOption(this.client.getInventory()
- .getSlotForId(139), "Drink");
- } else if (this.client.getInventory().contains(2434)) {
- selectInventoryOption(this.client.getInventory()
- .getSlotForId(2434), "Drink");
- Thread.sleep(1000L);
- }
- }
- }
- if (this.client.getSkills().getCurrentLevel(Skill.HITPOINTS) <= 32) {
- selectInventoryOption(
- this.client.getInventory().getSlotForId(379), "Eat");
- Thread.sleep(1000L);
- }
- } catch (Exception localException) {
- }
- if (this.client.getMyPlayer().isInArea(this.Gate_North))
- this.state = State.OPENGATE;
- return 250;
- }
- public void onPaint(Graphics g) {
- Graphics2D gr = (Graphics2D) g;
- gr.setColor(Color.WHITE);
- gr.setFont(new Font("Arial", 0, 10));
- g.drawString("BFungus", 25, 50);
- if (runTime != null) {
- g.drawString("Runtime: " + Timer.format(runTime.getElapsed()), 25,
- 65);
- }
- g.drawString("Fungi picked: " + this.fungiamount, 25, 80);
- g.drawString("Fungi/hour: " + getPerHour(fungiamount), 25, 95);
- g.drawString("Number of runs: " + this.runs, 25, 110);
- g.drawString("Runs/hour: " + getPerHour(runs), 25, 125);
- g.drawString("Money Made: " + this.fungiamount * 700, 25, 140);
- g.drawString("Money Made/hour: " + getPerHour(fungiamount) * 700, 25,
- 155);
- gr.drawString("Lumb Path: " + " (" + lumbPath + ")", 25, 170);
- gr.drawString("Pray Pot: " + " (" + pot3 + ")", 25, 185);
- gr.drawString("State: " + this.state, 25, 200);
- 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;
- }
- }
- static enum State {
- BANK, Gate_Path, TOFUNGUS, OPERATE, PICKUP, Gate_Path_Back, Bank_Path, PRAYPOT, DROP, OPENGATE, TOLUMB, TOPRAY, PRAY, TELETOBANK, ANCIENTWALKTOBANK, OPENDOOR, ENTERCHAPEL;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment