Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package main;
- import org.dreambot.api.Client;
- import org.dreambot.api.input.event.impl.InteractionEvent;
- import org.dreambot.api.input.event.impl.InteractionSetting;
- import org.dreambot.api.input.mouse.destination.impl.EntityDestination;
- import org.dreambot.api.methods.Calculations;
- import org.dreambot.api.methods.magic.Normal;
- import org.dreambot.api.methods.map.Area;
- import org.dreambot.api.methods.map.Tile;
- import org.dreambot.api.methods.prayer.Prayer;
- import org.dreambot.api.methods.skills.Skill;
- import org.dreambot.api.script.AbstractScript;
- import org.dreambot.api.script.Category;
- import org.dreambot.api.script.ScriptManifest;
- import org.dreambot.api.script.listener.AdvancedMessageListener;
- import org.dreambot.api.wrappers.graphics.Projectile;
- import org.dreambot.api.wrappers.interactive.FloorDecoration;
- import org.dreambot.api.wrappers.interactive.GameObject;
- import org.dreambot.api.wrappers.interactive.NPC;
- import org.dreambot.api.wrappers.items.GroundItem;
- import org.dreambot.api.wrappers.map.TileReference;
- import org.dreambot.api.wrappers.widgets.message.Message;
- import sun.awt.geom.AreaOp;
- import java.awt.*;
- import java.io.BufferedReader;
- import java.io.InputStream;
- import java.io.InputStreamReader;
- import java.net.URL;
- import java.net.URLConnection;
- import java.util.List;
- import java.util.concurrent.ExecutorService;
- import java.util.concurrent.Executors;
- import java.util.concurrent.TimeUnit;
- @ScriptManifest(author = "Nebscape", category = Category.MISC, name = "NebVorkath", version = 1.0, description = "Kills Vorkath")
- public class Main extends AbstractScript implements AdvancedMessageListener {
- boolean frozen = false;
- boolean prayerDisabled = false;
- boolean antiFireExpired = false;
- boolean foundPoisonTiles = false;
- Tile startTile = null;
- Tile vorkathTile = null;
- Tile poisonTile1 = null;
- Tile poisonTile2 = null;
- Tile iceChunkTile = null;
- Tile pokeTile = null;
- Tile wooxTile = null;
- boolean timeToCast = false;
- int vorkiKc = 0;
- int vorkiDeaths = 0;
- int vorkiTies = 0;
- int gpGained = 0;
- boolean poolRunning = false;
- boolean scriptRunning = true;
- boolean canAttack = false;
- Area DEATH_AREA = new Area(new Tile(3097, 3473), new Tile(3092, 3468));
- // fire dodge
- Area leftSide = null;
- Area rightSide = null;
- //
- //areas for poison phase
- Area farLeftSide = null;
- Area farRightSide = null;
- public void onStart() {
- if (!poolRunning) {
- log("are we in here?");
- //System.out.println("Inside : " + Thread.currentThread().getName());
- //System.out.println("Creating Executor Service...");
- ExecutorService executorService = Executors.newSingleThreadExecutor();
- // System.out.println("Creating a Runnable...");
- Runnable runnable = () -> {
- while (scriptRunning && getClient().isLoggedIn()) {
- if (getNpcs().closest("Vorkath") != null) {
- if (getNpcs().closest("Zombified Spawn") != null) {
- if (getCamera().rotateToTile(getNpcs().closest("Zombified Spawn").getTile())) {
- timeToCast = true;
- log("New thread moved camera to spawn");
- } else {
- log("We fucked up camera movement");
- }
- } else if (getNpcs().closest("Vorkath") != null && getNpcs().closest("Vorkath").getAnimation() == 7960 && !frozen) {
- if (canAttack == true) {
- canAttack = false;
- }
- log("Fireball phase");
- // if (foundPoisonTiles == true) {
- // foundPoisonTiles = false;
- // }
- sleep(600);
- if (getNpcs().closest("Vorkath") != null && !frozen) {
- log("Fireball MOVE!");
- if (rightSide.contains(getLocalPlayer().getTile())) {
- Tile ourPosition = getLocalPlayer().getTile();
- int xAxis = ourPosition.getX();
- int yAxis = ourPosition.getY();
- int newX = xAxis - 5;
- if (getWalking().walk(new Tile(newX, yAxis))) {
- log("We should have dodged fire ball");
- sleepUntil(() -> getLocalPlayer().getTile() != ourPosition || frozen, Calculations.random(500, 600));
- sleepUntil(() -> getNpcs().closest("Vorkath") != null && getNpcs().closest("Vorkath").getAnimation() != 7960, Calculations.random(4000,5000));
- }
- } else if (leftSide.contains(getLocalPlayer().getTile())) {
- Tile ourPosition = getLocalPlayer().getTile();
- int xAxis = ourPosition.getX();
- int yAxis = ourPosition.getY();
- int newX = xAxis + 5;
- if (getWalking().walk(new Tile(newX, yAxis))) {
- log("We should have dodged fireball");
- sleepUntil(() -> getLocalPlayer().getTile() != ourPosition || frozen, Calculations.random(500, 600));
- sleepUntil(() -> getNpcs().closest("Vorkath") != null && getNpcs().closest("Vorkath").getAnimation() != 7960, Calculations.random(4000,5000));
- }
- } else {
- getWalking().walk(leftSide.getRandomTile());
- }
- }
- } else if (frozen && canAttack) {
- canAttack = false;
- } else if (timeToCast && getNpcs().closest("Zombified Spawn") == null) {
- timeToCast = false;
- } else if (!timeToCast && getNpcs().closest("Zombified Spawn") != null && getNpcs().closest("Zombified Spawn").isOnScreen()) {
- timeToCast = true;
- } else {
- if (!canAttack && !frozen) {
- canAttack = true;
- }
- }
- // log("Vorkath New Thread Animation: " + getNpcs().closest("Vorkath").getAnimation());
- }
- sleep(50);
- }
- // System.out.println("Inside : " + Thread.currentThread().getName());
- };
- executorService.submit(runnable);
- }
- // thread.start();
- // log("Thread state" + thread.getState().name());
- getWalking().setRunThreshold(101);
- getMouse().setAlwaysHop(true);
- timeBegan = System.currentTimeMillis();
- log("Script started");
- }
- public void createAreas() {
- startTile = getLocalPlayer().getTile();
- int xAxis = startTile.getX();
- int yAxis = startTile.getY();
- int leftSouthWestX = xAxis - 10;
- int leftSouthWestY = yAxis - 7;
- leftSide = new Area(startTile, new Tile(leftSouthWestX, leftSouthWestY));
- int rightNorthEastX = xAxis + 11;
- int rightSouthWestX = xAxis + 1;
- int rightSouthWestY = yAxis - 7;
- rightSide = new Area(new Tile(rightNorthEastX, yAxis), new Tile(rightSouthWestX, rightSouthWestY));
- int farLeftNorthEastX = xAxis - 7;
- farLeftSide = new Area(new Tile(farLeftNorthEastX, yAxis), new Tile(leftSouthWestX, leftSouthWestY));
- int farRightSouthWestX = xAxis + 8;
- farRightSide = new Area(new Tile(rightNorthEastX, yAxis), new Tile(farRightSouthWestX, rightSouthWestY));
- int vorkathYAxis = yAxis + 3;
- vorkathTile = new Tile(xAxis, vorkathYAxis);
- log("Areas created");
- }
- public void looting() {
- List<GroundItem> items = getGroundItems().all();
- if (!getGroundItems().all().isEmpty() && !getInventory().isFull()) {
- for (GroundItem gi : items) {
- if (gi.exists()) {
- if (!gi.isOnScreen()) {
- getWalking().walk(gi.getTile());
- } else if (gi.isOnScreen()) {
- if (gi.interact("Take")) {
- int itemID = gi.getID();
- int itemPrice = getPrice(itemID);
- if (gi.getAmount() > 1) {
- int stackAmount = gi.getAmount();
- int stackTotal = itemPrice * stackAmount;
- log("We just looted " + stackTotal);
- gpGained = gpGained + stackTotal;
- if (gi.getName().contains("Coins")) {
- gpGained = gpGained + gi.getAmount();
- }
- } else {
- log("We just looted " + itemPrice);
- gpGained = gpGained + itemPrice;
- }
- sleepUntil(() -> !gi.exists() || getInventory().isFull(), Calculations.random(10000, 11000));
- log("Grabbing loot");
- } else {
- if (getWalking().walk(gi.getTile())) {
- sleepUntil(() -> gi.isOnScreen() || getInventory().isFull(), Calculations.random(10000, 11000));
- }
- }
- }
- }
- }
- } else if (!getGroundItems().all().isEmpty() && getInventory().isFull()) {
- getInventory().interact("Anglerfish", "Eat");
- } else if (getGroundItems().all().isEmpty() && getInventory().contains("Blue dragonhide") && getInventory().contains("Superior dragon bones")) {
- log("Picked up all the loot");
- state = 3;
- vorkiKc++;
- }
- }
- public void vorkathFight() {
- if (getNpcs().closest("Vorkath") != null && getGroundItems().all().isEmpty()) {
- if (getInventory().isItemSelected() || getMagic().isSpellSelected()) {
- getInventory().deselect();
- } else if (getNpcs().closest("Vorkath").hasAction("Poke") && getGroundItems().all().isEmpty() && getInventory().count("Anglerfish") > 10) {
- if (getNpcs().closest("Vorkath").distance() > 8) {
- if (getWalking().walkExact(pokeTile)) {
- log("Walking closer");
- sleepUntil(() -> getNpcs().closest("Vorkath").distance() <= 5, Calculations.random(6000, 7000));
- }
- } else if (getNpcs().closest("Vorkath").interact("Poke")) {
- sleepUntil(() -> getNpcs().closest("Vorkath").distance() == 1, Calculations.random(5000, 6000));
- createAreas();
- sleepUntil(() -> !getNpcs().closest("Vorkath").hasAction("Poke"), Calculations.random(7000, 8000));
- log("Vorkath poked");
- }
- } else if (getNpcs().closest("Vorkath").getAnimation() == 7949) {
- log("Vorkath killed");
- //switch to looting state
- state = 2;
- } else if (getNpcs().closest("Vorkath").getAnimation() == 7957) {
- if (!foundPoisonTiles) {
- poisonPathFinding();
- }
- if (getWalking().isRunEnabled()) {
- if (getWalking().toggleRun()) {
- sleepUntil(()-> !getWalking().isRunEnabled(), Calculations.random(600,800));
- log("Turned run off");
- }
- }
- // poison phase
- //log("Poison phase");
- // if (getSkills().getBoostedLevels(Skill.HITPOINTS) < 70) {
- if (!foundPoisonTiles) {
- if (rightSide.contains(getLocalPlayer().getTile())) {
- if (getWalking().walk(farLeftSide.getRandomTile())) {
- if (getSkills().getBoostedLevels(Skill.HITPOINTS) < 70) {
- log("Eating");
- if (getInventory().contains("Anglerfish")) {
- if (getInventory().interact("Anglerfish", "Eat")) {
- if (getSkills().getBoostedLevels(Skill.PRAYER) < 50) {
- if (getInventory().contains("Super restore(1)")) {
- getInventory().interact("Super restore(1)", "Drink");
- } else if (getInventory().contains("Super restore(2)")) {
- getInventory().interact("Super restore(2)", "Drink");
- } else if (getInventory().contains("Super restore(3)")) {
- getInventory().interact("Super restore(3)", "Drink");
- } else if (getInventory().contains("Super restore(4)")) {
- getInventory().interact("Super restore(4)", "Drink");
- }
- }
- }
- } else if (!getInventory().contains("Anglerfish") && getSkills().getBoostedLevels(Skill.HITPOINTS) < 35) {
- if (getInventory().interact("Teleport to house", "Break")) {
- state = 3;
- sleepUntil(() -> getGameObjects().closest("Portal") != null, Calculations.random(4000, 5000));
- }
- }
- }
- }
- } else {
- if (getWalking().walk(farRightSide.getRandomTile())) {
- if (getSkills().getBoostedLevels(Skill.HITPOINTS) < 70) {
- log("Eating");
- if (getInventory().contains("Anglerfish", "Eat")) {
- if (getInventory().interact("Anglerfish", "Eat")) {
- if (getSkills().getBoostedLevels(Skill.PRAYER) < 50) {
- if (getInventory().contains("Super restore(1)")) {
- getInventory().interact("Super restore(1)", "Drink");
- } else if (getInventory().contains("Super restore(2)")) {
- getInventory().interact("Super restore(2)", "Drink");
- } else if (getInventory().contains("Super restore(3)")) {
- getInventory().interact("Super restore(3)", "Drink");
- } else if (getInventory().contains("Super restore(4)")) {
- getInventory().interact("Super restore(4)", "Drink");
- }
- }
- }
- } else if (!getInventory().contains("Anglerfish") && getSkills().getBoostedLevels(Skill.HITPOINTS) < 35) {
- if (getInventory().interact("Teleport to house", "Break")) {
- state = 3;
- sleepUntil(() -> getGameObjects().closest("Portal") != null, Calculations.random(4000, 5000));
- }
- }
- }
- }
- }
- } else {
- if (!getInventory().contains("Anglerfish") && getSkills().getBoostedLevels(Skill.HITPOINTS) < 40) {
- getInventory().interact("Teleport to house","Break");
- }
- //walk on our new found poison tiles
- if (poisonTile1.distance() >= poisonTile2.distance()) {
- if (getWalking().walk(poisonTile1)) {
- log("We walked to poison tile1");
- if (getSkills().getBoostedLevels(Skill.HITPOINTS) < 70) {
- log("Eating");
- if (getInventory().interact("Anglerfish", "Eat")) {
- if (getSkills().getBoostedLevels(Skill.PRAYER) < 50) {
- if (getInventory().contains("Super restore(1)")) {
- getInventory().interact("Super restore(1)", "Drink");
- } else if (getInventory().contains("Super restore(2)")) {
- getInventory().interact("Super restore(2)", "Drink");
- } else if (getInventory().contains("Super restore(3)")) {
- getInventory().interact("Super restore(3)", "Drink");
- } else if (getInventory().contains("Super restore(4)")) {
- getInventory().interact("Super restore(4)", "Drink");
- }
- }
- }
- }
- sleep(600);
- //sleepUntil(()-> poisonTile2.distance() >= 3, Calculations.random(300,500));
- getWalking().walk(poisonTile2);
- }
- } else {
- if (getWalking().walk(poisonTile2)) {
- log("We walked poisonTile2");
- if (getSkills().getBoostedLevels(Skill.HITPOINTS) < 70) {
- log("Eating");
- if (getInventory().interact("Anglerfish", "Eat")) {
- if (getSkills().getBoostedLevels(Skill.PRAYER) < 50) {
- if (getInventory().contains("Super restore(1)")) {
- getInventory().interact("Super restore(1)", "Drink");
- } else if (getInventory().contains("Super restore(2)")) {
- getInventory().interact("Super restore(2)", "Drink");
- } else if (getInventory().contains("Super restore(3)")) {
- getInventory().interact("Super restore(3)", "Drink");
- } else if (getInventory().contains("Super restore(4)")) {
- getInventory().interact("Super restore(4)", "Drink");
- }
- }
- }
- }
- sleep(600);
- // sleepUntil(()-> poisonTile1.distance() >= 3, Calculations.random(300,500));
- getWalking().walk(poisonTile1);
- }
- }
- }
- }
- // else {
- // //Tile ourPosition = getLocalPlayer().getTile();
- // //int xAxis = ourPosition.getX();
- // //int yAxis = ourPosition.getY();
- // // walkTile = new Tile(xAxis, yAxis - 1, 0);
- // if (getWalking().isRunEnabled()) {
- // if (getWalking().toggleRun()) {
- // getWalking().clickTileOnMinimap(wooxTile);
- // sleepUntil(()-> !getWalking().isRunEnabled(), Calculations.random(500,600));
- // log("Turned run off");
- // }
- // } else if (getCamera().getX() != 6208 && getCamera().getYaw() != 0) {
- // getMouse().click(new Point(560,20));
- // } else if (getCamera().getPitch() > 128) {
- // getCamera().rotateToPitch(128);
- // } else {
- // log("Entered the woox method");
- // if (wooxTile.distance() <= 3) {
- // Tile tileCheck = getLocalPlayer().getTile();
- // if (getWalking().walkExact(wooxTile)) {
- // log("We clicked the wooxTile");
- // int x = 0;
- // while (getSkills().getBoostedLevels(Skill.HITPOINTS) >= 65 && getNpcs().closest("Vorkath").getAnimation() == 7957) {
- //// if (getMouse().move(new Point(250,45))) {
- //// log("moved mouse to vorkath");
- //// if (getMouse().click()) {
- //// log("Clicked vorkath");
- //// if (getMouse().move(new Point(248,235))) {
- //// log("Moved mouse to tile behind me");
- //// getMouse().click();
- //// log("Clicked tile behind me");
- //// }
- //// }
- //// }
- // if (getNpcs().closest("Vorkath").distance() >= 7) {
- // if (getMouse().move(new Point(250,45))) {
- // log("moved mouse to Vorkath");
- // if (getMouse().click()) {
- // log("Clicked vorkath");
- // sleep(600);
- // if (getMouse().move(new Point(251, 263))) {
- // log("Moved mouse to tile behind me");
- // Tile ourPosition = getLocalPlayer().getTile();
- // getMouse().click();
- // getMouse().click();
- // log("Clicked tile behind me");
- // sleep(600);
- // //sleepUntil(() -> !getLocalPlayer().getTile().toString().equals(ourPosition.toString()), Calculations.random(5000, 6000));
- // }
- // }
- // }
- // } else {
- // if (getMouse().move(new Point(251, 263))) {
- // log("Moved mouse to tile behind me");
- // Tile ourPosition = getLocalPlayer().getTile();
- // getMouse().click();
- // getMouse().click();
- // sleep(600);
- // log("Clicked tile behind me");
- // //sleepUntil(() -> !getLocalPlayer().getTile().toString().equals(ourPosition.toString()), Calculations.random(5000, 6000));
- // }
- // }
- // }
- // //sleepUntil(() -> wooxTile.distance() <= 2, Calculations.random(6000, 7000));
- // return;
- //// EntityDestination ed = new EntityDestination(getClient(), getNpcs().closest("Vorkath"));
- //// InteractionEvent ie = new InteractionEvent(ed);
- //// //getMouse().click(new Point(243,48))
- //// log("Made it out of the sleep");
- //// if (ie.interact("Attack",InteractionSetting.FORCE_LEFT_CLICK)) {
- //// log("We attacked the drag in woox mode");
- //// //sleepUntil(() -> getLocalPlayer().isInCombat() && getLocalPlayer().getTile() != wooxTile, Calculations.random(200, 500));
- //// int y = 0;
- //// while (getLocalPlayer().getTile() == wooxTile) {
- //// sleep(10);
- //// //y++;
- //// }
- //// log("made it out of the 2nd sleep");
- //// } else {
- //// log("We missclicked on out woox attack");
- //// }
- //
- //
- // }
- // } else {
- // if (getWalking().clickTileOnMinimap(wooxTile)) {
- // log("We clicked the wooxTile on minimap");
- // if (getCamera().getYaw() != 0) {
- // getMouse().click(new Point(560,20));
- // }
- // if (getCamera().getPitch() > 128) {
- // getCamera().rotateToPitch(128);
- // }
- //
- // }
- // }
- // }
- // //walk on our new found poison tiles
- //// if (poisonTile1.distance() >= poisonTile2.distance()) {
- //// if (getWalking().walkExact(poisonTile1)) {
- //// if (getWalking().isRunEnabled()) {
- //// if (getWalking().toggleRun()) {
- //// sleepUntil(() -> getWalking().isRunEnabled(), Calculations.random(1000, 1200));
- //// }
- //// }
- //// if (getSkills().getBoostedLevels(Skill.HITPOINTS) < 70) {
- //// log("Eating");
- //// if (getInventory().interact("Anglerfish", "Eat")) {
- //// if (getSkills().getBoostedLevels(Skill.PRAYER) < 50) {
- //// if (getInventory().contains("Super restore(1)")) {
- //// getInventory().interact("Super restore(1)", "Drink");
- //// } else if (getInventory().contains("Super restore(2)")) {
- //// getInventory().interact("Super restore(2)", "Drink");
- //// } else if (getInventory().contains("Super restore(3)")) {
- //// getInventory().interact("Super restore(3)", "Drink");
- //// } else if (getInventory().contains("Super restore(4)")) {
- //// getInventory().interact("Super restore(4)", "Drink");
- //// }
- //// }
- //// }
- //// }
- //// }
- //// } else {
- //// if (getWalking().walkExact(poisonTile2)) {
- //// if (getWalking().isRunEnabled()) {
- //// if (getWalking().toggleRun()) {
- //// sleepUntil(() -> getWalking().isRunEnabled(), Calculations.random(1000, 1200));
- //// }
- //// }
- //// if (getSkills().getBoostedLevels(Skill.HITPOINTS) < 70) {
- //// log("Eating");
- //// if (getInventory().interact("Anglerfish", "Eat")) {
- //// if (getSkills().getBoostedLevels(Skill.PRAYER) < 50) {
- //// if (getInventory().contains("Super restore(1)")) {
- //// getInventory().interact("Super restore(1)", "Drink");
- //// } else if (getInventory().contains("Super restore(2)")) {
- //// getInventory().interact("Super restore(2)", "Drink");
- //// } else if (getInventory().contains("Super restore(3)")) {
- //// getInventory().interact("Super restore(3)", "Drink");
- //// } else if (getInventory().contains("Super restore(4)")) {
- //// getInventory().interact("Super restore(4)", "Drink");
- //// }
- //// }
- //// }
- //// }
- //// }
- //// }
- //// }
- // }
- // }
- // else if (getNpcs().closest("Vorkath").getAnimation() == 7960 && !frozen) {
- // log("Fireball phase");
- //// if (foundPoisonTiles == true) {
- //// foundPoisonTiles = false;
- //// }
- // if (!frozen) {
- // log("Fireball MOVE!");
- // if (rightSide.contains(getLocalPlayer().getTile())) {
- // Tile ourPosition = getLocalPlayer().getTile();
- // int xAxis = ourPosition.getX();
- // int yAxis = ourPosition.getY();
- // int newX = xAxis - 5;
- // if (getWalking().walk(new Tile(newX, yAxis))) {
- // sleepUntil(() -> getNpcs().closest("Vorkath").getAnimation() != 7960 || frozen, Calculations.random(4000, 5000));
- // }
- // } else if (leftSide.contains(getLocalPlayer().getTile())) {
- // Tile ourPosition = getLocalPlayer().getTile();
- // int xAxis = ourPosition.getX();
- // int yAxis = ourPosition.getY();
- // int newX = xAxis + 5;
- //
- // if (getWalking().walk(new Tile(newX, yAxis))) {
- // sleepUntil(() -> getNpcs().closest("Vorkath").getAnimation() != 7960 || frozen, Calculations.random(4000, 5000));
- // }
- // } else {
- // getWalking().walk(leftSide.getRandomTile());
- // }
- // }
- // }
- else if (frozen || getNpcs().closest("Zombified Spawn") != null) {
- log("Frozen phase");
- if (!getPrayer().isQuickPrayerActive() || getNpcs().closest("Vorkath").getAnimation() == 7957 || getNpcs().closest("Vorkath").getAnimation() == 7952 || getNpcs().closest("Vorkath").getAnimation() == 7948) {
- frozen = false;
- return;
- }
- if (getSkills().getBoostedLevels(Skill.HITPOINTS) <= 64) {
- if (getInventory().contains("Anglerfish")) {
- if (getInventory().interact("Anglerfish", "Eat")) {
- if (getInventory().contains("Cooked karambwan")) {
- if (getInventory().interact("Cooked karambwan", "Eat")) {
- sleep(200);
- }
- } else {
- sleep(200);
- }
- }
- } else {
- getInventory().interact("Teleport to house", "Break");
- }
- } else if (getLocalPlayer().isInCombat()) {
- log("Clicking to get out of combat");
- Tile ourSpot = getLocalPlayer().getTile();
- if (getMouse().move(ourSpot)) {
- getMouse().click();
- getMouse().click();
- }
- }
- // if (getInventory().contains("Anglerfish")) {
- // //if (getInventory().interact("Anglerfish", "Eat")) {
- // if (getLocalPlayer().isInCombat()) {
- // if (getMouse().move(getLocalPlayer().getTile())) {
- // getMouse().click();
- // getMouse().click();
- // }
- // }
- // if (!getMagic().isSpellSelected()) {
- // if (getMagic().castSpell(Normal.CRUMBLE_UNDEAD)) {
- // getMouse().move(new Point(250, 138));
- // //sleepUntil(() -> getNpcs().closest("Zombified Spawn") != null && getNpcs().closest("Zombified Spawn").isOnScreen(), Calculations.random(5000, 7000));
- //// Tile cameraTile = getNpcs().closest("Zombified Spawn").getTile();
- ////// if (getNpcs().closest("Zombified Spawn") != null && !getNpcs().closest("Zombified Spawn").isOnScreen()) {
- ////// getCamera().mouseRotateToEntity(getNpcs().closest("Zombified Spawn"));
- ////// }
- //// if (!getNpcs().closest("Zombified Spawn").isOnScreen()) {
- //// getCamera().mouseRotateToTile(cameraTile);
- //// } else
- ////
- // if (getNpcs().closest("Zombified Spawn").isOnScreen()) {
- // EntityDestination ed = new EntityDestination(getClient(), getNpcs().closest("Zombified Spawn"));
- // InteractionEvent ie = new InteractionEvent(ed);
- //
- //
- // if (ie.interact("Cast", InteractionSetting.FORCE_RIGHT_CLICK)) {
- // log("We tried out our new casting method");
- // int magicXP = getSkills().getExperience(Skill.MAGIC);
- // sleepUntil(() -> magicXP < getSkills().getExperience(Skill.MAGIC) || getNpcs().closest("Zombified Spawn") == null, Calculations.random(1500, 3000));
- // frozen = false;
- // if (getSkills().getBoostedLevels(Skill.HITPOINTS) <= 90) {
- // getInventory().interact("Anglerfish", "Eat");
- // }
- // }
- //
- // }
- //// if (getMagic().castSpellOn(Normal.CRUMBLE_UNDEAD, getNpcs().closest("Zombified Spawn"))) {
- //// int magicXP = getSkills().getExperience(Skill.MAGIC);
- //// frozen = false;
- //// sleepUntil(()-> magicXP < getSkills().getExperience(Skill.MAGIC) || getNpcs().closest("Zombified Spawn") == null, Calculations.random(1500,3000));
- //// if (getSkills().getBoostedLevels(Skill.HITPOINTS) < 90) {
- //// if (getMagic().isSpellSelected()) {
- //// getMouse().click(true);
- //// }
- //// log("Eating");
- //// if (getInventory().contains("Anglerfish")) {
- //// getInventory().interact("Anglerfish", "Eat");
- //// }
- //// }
- //// } else {
- ////
- //// if (getSkills().getBoostedLevels(Skill.HITPOINTS) <= 35) {
- //// getInventory().interact("Teleport to house", "Break");
- //// } else if (!getInventory().contains("Anglerfish") && getSkills().getBoostedLevels(Skill.HITPOINTS) < 60) {
- //// getInventory().interact("Teleport to house", "Break");
- //// log("Spawn would of fucked us up we teled");
- //// }
- //// getInventory().interact("Anglerfish", "Eat");
- //// frozen = false;
- //// }
- // } else {
- // if (getSkills().getBoostedLevels(Skill.HITPOINTS) <= 35) {
- // getInventory().interact("Teleport to house", "Break");
- // } else if (!getInventory().contains("Anglerfish") && getSkills().getBoostedLevels(Skill.HITPOINTS) < 60) {
- // getInventory().interact("Teleport to house", "Break");
- // log("Spawn would of fucked us up we teled");
- // }
- // getInventory().interact("Anglerfish", "Eat");
- // frozen = false;
- // }
- // }
- // //}
- // else {
- // if (getSkills().getBoostedLevels(Skill.HITPOINTS) <= 35) {
- // getInventory().interact("Teleport to house", "Break");
- // } else if (!getInventory().contains("Anglerfish") && getSkills().getBoostedLevels(Skill.HITPOINTS) < 60) {
- // getInventory().interact("Teleport to house", "Break");
- // log("Spawn would of fucked us up we teled");
- // }
- // getInventory().interact("Anglerfish", "Eat");
- // frozen = false;
- // }
- // }
- else if (!getMagic().isSpellSelected()) {
- if (getMagic().castSpell(Normal.CRUMBLE_UNDEAD)) {
- sleepUntil(() -> getNpcs().closest("Zombified Spawn") != null, Calculations.random(5000, 7000));
- //Tile cameraTile = getNpcs().closest("Zombified Spawn").getTile();
- // if (!getNpcs().closest("Zombified Spawn").isOnScreen()) {
- // getCamera().mouseRotateToTile(cameraTile);
- // } else
- //
- if (getNpcs().closest("Zombified Spawn").isOnScreen()) {
- if (getMagic().castSpellOn(Normal.CRUMBLE_UNDEAD, getNpcs().closest("Zombified Spawn"))) {
- log("We tried out our new casting method");
- int magicXP = getSkills().getExperience(Skill.MAGIC);
- sleepUntil(() -> magicXP < getSkills().getExperience(Skill.MAGIC) || getNpcs().closest("Zombified Spawn") == null, Calculations.random(1500, 3000));
- frozen = false;
- }
- } else {
- getMagic().castSpellOn(Normal.CRUMBLE_UNDEAD, getNpcs().closest("Zombified Spawn"));
- }
- }
- } else if (getMagic().isSpellSelected()) {
- // if (getMagic().castSpell(Normal.CRUMBLE_UNDEAD)) {
- // sleepUntil(() -> getNpcs().closest("Zombified Spawn") != null, Calculations.random(5000, 7000));
- // Tile cameraTile = getNpcs().closest("Zombified Spawn").getTile();
- // if (!getNpcs().closest("Zombified Spawn").isOnScreen()) {
- // getCamera().mouseRotateToTile(cameraTile);
- // } else
- //
- if (getNpcs().closest("Zombified Spawn").isOnScreen()) {
- // EntityDestination ed = new EntityDestination(getClient(), getNpcs().closest("Zombified Spawn"));
- // InteractionEvent ie = new InteractionEvent(ed);
- //
- //
- // if (ie.interact("Cast", InteractionSetting.FORCE_RIGHT_CLICK)) {
- // log("We tried out our new casting method");
- // int magicXP = getSkills().getExperience(Skill.MAGIC);
- // sleepUntil(() -> magicXP < getSkills().getExperience(Skill.MAGIC) || getNpcs().closest("Zombified Spawn") == null, Calculations.random(1500, 3000));
- // frozen = false;
- //
- // }
- getMagic().castSpellOn(Normal.CRUMBLE_UNDEAD, getNpcs().closest("Zombified Spawn"));
- } else {
- if (getSkills().getBoostedLevels(Skill.HITPOINTS) <= 35) {
- getInventory().interact("Teleport to house", "Break");
- } else if (!getInventory().contains("Anglerfish") && getSkills().getBoostedLevels(Skill.HITPOINTS) < 60) {
- getInventory().interact("Teleport to house", "Break");
- log("Spawn would of fucked us up we teled");
- }
- getInventory().interact("Anglerfish", "Eat");
- frozen = false;
- }
- // }
- }
- }
- // else if (prayerDisabled) {
- // log("Turning prayer on");
- // if (getMouse().click(new Point(556,101))) {
- // prayerDisabled = false;
- // }
- // }
- else if (getSkills().getBoostedLevels(Skill.HITPOINTS) < 35) {
- if (getMagic().isSpellSelected()) {
- getMouse().click(true);
- }
- log("Eating");
- if (getInventory().contains("Anglerfish")) {
- if (getInventory().interact("Anglerfish", "Eat")) {
- if (getInventory().contains("Cooked karambwan")) {
- getInventory().interact("Cooked karambwan", "eat");
- }
- }
- } else {
- if (getInventory().interact("Teleport to house", "Break")) {
- state = 3;
- sleepUntil(() -> getGameObjects().closest("Portal") != null, Calculations.random(4000, 5000));
- }
- }
- } else if (getSkills().getBoostedLevels(Skill.PRAYER) < 25 && !frozen) {
- log("Drinking restore pot");
- if (getInventory().contains("Super restore(1)")) {
- getInventory().interact("Super restore(1)", "Drink");
- } else if (getInventory().contains("Super restore(2)")) {
- getInventory().interact("Super restore(2)", "Drink");
- } else if (getInventory().contains("Super restore(3)")) {
- getInventory().interact("Super restore(3)", "Drink");
- } else if (getInventory().contains("Super restore(4)")) {
- getInventory().interact("Super restore(4)", "Drink");
- }
- } else if ((getInventory().contains("Toxic blowpipe") || getInventory().contains("Archers ring (i)") || getInventory().contains("Void ranger helm") || getInventory().contains("Ava's assembler") || getInventory().contains("Pegasian boots")) && getCombat().getSpecialPercentage() < 50) {
- if (getInventory().contains("Toxic blowpipe")) {
- if (getInventory().interact("Toxic blowpipe", "Wield")) {
- sleepUntil(() -> !getInventory().contains("Toxic blowpipe"), Calculations.random(1000, 2000));
- }
- } else if (getInventory().contains("Archers ring (i)")) {
- if (getInventory().interact("Archers ring (i)", "Wear")) {
- sleepUntil(() -> !getInventory().contains("Archers ring (i)"), Calculations.random(1000, 2000));
- }
- } else if (getInventory().contains("Void ranger helm")) {
- if (getInventory().interact("Void ranger helm", "Wear")) {
- sleepUntil(() -> !getInventory().contains("Void ranger helm"), Calculations.random(1000, 2000));
- }
- } else if (getInventory().contains("Ava's assembler")) {
- if (getInventory().interact("Ava's assembler", "Wear")) {
- sleepUntil(() -> !getInventory().contains("Ava's assembler"), Calculations.random(1000, 2000));
- }
- } else if (getInventory().contains("Pegasian boots")) {
- if (getInventory().interact("Pegasian boots", "Wear")) {
- sleepUntil(() -> !getInventory().contains("Pegasian boots"), Calculations.random(1000, 2000));
- }
- }
- } else if (getCombat().getSpecialPercentage() >= 50 && !getCombat().isSpecialActive()) {
- if (!getCombat().isSpecialActive()) {
- if (getCombat().toggleSpecialAttack(true)) {
- sleepUntil(() -> getCombat().isSpecialActive(), Calculations.random(1000, 2000));
- }
- }
- }
- else if ((!getPrayer().isQuickPrayerActive() && getCombat().getSpecialPercentage() < 50) || prayerDisabled) {
- if (!getPrayer().isQuickPrayerActive()) {
- if (getMouse().click(new Point(556,101))) {
- sleepUntil(() -> getPrayer().isQuickPrayerActive(), Calculations.random(2000, 3000));
- }
- }
- }
- else if (antiFireExpired) {
- if (getInventory().contains("Super antifire potion(1)")) {
- if (getInventory().interact("Super antifire potion(1)", "Drink")) {
- antiFireExpired = false;
- }
- } else if (getInventory().contains("Super antifire potion(2)")) {
- if (getInventory().interact("Super antifire potion(2)", "Drink")) {
- antiFireExpired = false;
- }
- } else if (getInventory().contains("Super antifire potion(3)")) {
- if (getInventory().interact("Super antifire potion(3)", "Drink")) {
- antiFireExpired = false;
- }
- } else if (getInventory().contains("Super antifire potion(4)")) {
- if (getInventory().interact("Super antifire potion(4)", "Drink")) {
- antiFireExpired = false;
- }
- }
- } else if (!getWalking().isRunEnabled() && getWalking().getRunEnergy() >= 1) {
- if (getWalking().toggleRun()) {
- log("Turned run on");
- sleepUntil(() -> getWalking().isRunEnabled(), Calculations.random(1000, 1200));
- }
- } else {
- if (foundPoisonTiles == true) {
- foundPoisonTiles = false;
- }
- if (!getLocalPlayer().isInCombat() && canAttack) {
- if (foundPoisonTiles) {
- foundPoisonTiles = false;
- }
- if (!getNpcs().closest("Vorkath").isOnScreen()) {
- if (getCamera().rotateToEntity(getNpcs().closest("Vorkath"))) {
- log("Rotated camera to vorkath");
- }
- // else {
- // log("Vorkath out of range moving closer");
- // getWalking().walk(startTile);
- // }
- } else {
- EntityDestination ed = new EntityDestination(getClient(), getNpcs().closest("Vorkath"));
- InteractionEvent ie = new InteractionEvent(ed);
- if ((getNpcs().closest("Vorkath").distance() < 8 || getNpcs().closest("Vorkath").isOnScreen()) && getNpcs().closest("Vorkath").getAnimation() != 7960) {
- if (ie.interact("Attack", InteractionSetting.FORCE_LEFT_CLICK)) {
- log("Tried out new attack");
- } else {
- //getCamera().rotateToEntity(getNpcs().closest("Vorkath"));
- log("Missclicked our attack");
- }
- } else {
- if (getNpcs().closest("Vorkath").distance() >= 8) {
- getWalking().walk(startTile);
- }
- }
- // }
- log("Vorki animations" + getNpcs().closest("Vorkath").getAnimation());
- log("Vorki time" + getNpcs().closest("Vorkath").getCombatTime());
- }
- } else if (!getCombat().isSpecialActive() && getCombat().getSpecialPercentage() >= 50) {
- if (getCombat().toggleSpecialAttack(true)) {
- sleepUntil(() -> getCombat().isSpecialActive(), Calculations.random(1000, 2000));
- }
- }
- }
- } else {
- if (DEATH_AREA.contains(getLocalPlayer().getTile())) {
- state = 8;
- vorkiDeaths++;
- vorkiTies = vorkiTies - 1;
- }
- if ((getNpcs().closest("Vorkath") != null && getNpcs().closest("Vorkath").getAnimation() == 7949) || (!getGroundItems().all().isEmpty() && getNpcs().closest("Vorkath") != null)) {
- state = 2;
- }
- if (getGameObjects().closest("Ornate Jewellery Box") != null) {
- log("We ran out of food and teled out of the fight");
- state = 3;
- }
- }
- }
- public void restoreStats() {
- if (getNpcs().closest("Vorkath") != null) {
- if (getInventory().interact("Teleport to house", "Break")) {
- sleepUntil(() -> getGameObjects().closest("Portal") != null, Calculations.random(4000, 5000));
- }
- } else if (getGameObjects().closest("Ornate Jewellery Box") != null && (getSkills().getBoostedLevels(Skill.HITPOINTS) < 99 || getSkills().getBoostedLevels(Skill.PRAYER) < 77) || getWalking().getRunEnergy() <= 90) {
- if (getPrayer().isQuickPrayerActive()) {
- log("Turning quick prayers off");
- getPrayer().toggleQuickPrayer(false);
- } else {
- if (getGameObjects().closest("Ornate rejuvenation pool").interact("Drink")) {
- sleepUntil(() -> getSkills().getBoostedLevels(Skill.HITPOINTS) == 99 && getSkills().getBoostedLevels(Skill.PRAYER) == 77 && getWalking().getRunEnergy() == 100, Calculations.random(5000, 7000));
- }
- }
- } else if (getGameObjects().closest("Ornate Jewellery Box") != null && getWidgets().getWidgetChild(590, 7, 5) == null) {
- if (getGameObjects().closest("Ornate Jewellery Box").interact("Teleport")) {
- sleepUntil(() -> getWidgets().getWidgetChild(590, 7, 5) != null, Calculations.random(5000, 6000));
- }
- } else if (getWidgets().getWidgetChild(590, 7, 5) != null) {
- getKeyboard().type("m");
- sleepUntil(() -> getGameObjects().closest("Portal") == null, Calculations.random(5000, 6000));
- } else if (getGameObjects().closest("Ornate Jewelery Box") == null && getBank().getClosestBankLocation().getCenter().distance() < 50) {
- //we are out of the house and this is probably the best time to switch to the next state
- state = 4;
- if (!getInventory().contains("Blue dragonhide")) {
- vorkiTies++;
- }
- }
- }
- public void reSupply() {
- //1. we eat a angler to get above 99 hp
- //2. deposit everything in inventory and pull out whats needed
- //3. perform some checks on bp/karils/serp helm to make sure we can keep going
- if (!getInventory().isEmpty() && !DEATH_AREA.contains(getLocalPlayer().getTile())) {
- if (getSkills().getBoostedLevels(Skill.HITPOINTS) == 99 && getInventory().contains("Anglerfish")) {
- if (getInventory().interact("Anglerfish", "Eat")) {
- sleepUntil(() -> getSkills().getBoostedLevels(Skill.HITPOINTS) > 99, Calculations.random(5000, 6000));
- }
- } else if (!getBank().isOpen() && (!getInventory().isFull() || getInventory().contains("Blue dragonhide"))) {
- getBank().openClosest();
- } else if (getBank().isOpen()) {
- getBank().depositAllItems();
- }
- } else if (DEATH_AREA.contains(getLocalPlayer().getTile())) {
- state = 8;
- } else {
- state = 9;
- }
- }
- public void withdrawSupplies() {
- if (gotPet == false) {
- if (!getInventory().isFull() && !getBank().isOpen()) {
- getBank().openClosest();
- } else if (!getInventory().contains("Bandos godsword")) {
- if (getBank().withdraw("Bandos godsword")) {
- sleepUntil(() -> getInventory().contains("Bandos godsword"), Calculations.random(5000, 6000));
- }
- } else if (!getInventory().contains("Fire cape")) {
- if (getBank().withdraw("Fire cape")) {
- sleepUntil(() -> getInventory().contains("Fire cape"), Calculations.random(5000, 6000));
- }
- } else if (!getInventory().contains("Berserker ring (i)")) {
- if (getBank().withdraw("Berserker ring (i)")) {
- sleepUntil(() -> getInventory().contains("Berserker ring (i)"), Calculations.random(5000, 6000));
- }
- } else if (!getInventory().contains("Void melee helm")) {
- if (getBank().withdraw("Void melee helm")) {
- sleepUntil(() -> getInventory().contains("Void melee helm"), Calculations.random(5000, 6000));
- }
- } else if (!getInventory().contains("Primordial boots")) {
- if (getBank().withdraw("Primordial boots")) {
- sleepUntil(() -> getInventory().contains("Primordial boots"), Calculations.random(5000, 6000));
- }
- } else if (!getInventory().contains("Rune pouch")) {
- if (getBank().withdraw("Rune pouch")) {
- sleepUntil(() -> getInventory().contains("Rune pouch"), Calculations.random(5000, 6000));
- }
- } else if (!getInventory().contains("Teleport to house")) {
- if (getBank().contains("Teleport to house")) {
- if (getBank().withdraw("Teleport to house", 10)) {
- sleepUntil(() -> getInventory().contains("Teleport to house"), Calculations.random(5000, 6000));
- }
- } else {
- log("out of house teleports");
- stop();
- }
- } else if (!getInventory().contains("Anti-venom+(4)")) {
- if (getBank().contains("Anti-venom+(4)")) {
- if (getBank().withdraw("Anti-venom+(4)")) {
- sleepUntil(() -> getInventory().contains("Anti-venom+(4)"), Calculations.random(5000, 6000));
- }
- } else {
- log("out of Anti-venom+(4)");
- stop();
- }
- } else if (!getInventory().contains("Super combat potion(4)")) {
- if (getBank().contains("Super combat potion(4)")) {
- if (getBank().withdraw("Super combat potion(4)")) {
- sleepUntil(() -> getInventory().contains("Super combat potion(4)"), Calculations.random(5000, 6000));
- }
- } else {
- log("out of super combats");
- stop();
- }
- } else if (!getInventory().contains("Ranging potion(4)")) {
- if (getBank().contains("Ranging potion(4)")) {
- if (getBank().withdraw("Ranging potion(4)")) {
- sleepUntil(() -> getInventory().contains("Ranging potion(4)"), Calculations.random(5000, 6000));
- }
- } else {
- log("out of ranging pots");
- stop();
- }
- } else if (!getInventory().contains("Super antifire potion(4)")) {
- if (getBank().contains("Super antifire potion(4)")) {
- if (getBank().withdraw("Super antifire potion(4)")) {
- sleepUntil(() -> getInventory().contains("Super antifire potion(4)"), Calculations.random(5000, 6000));
- }
- } else {
- log("out of antifire pots");
- stop();
- }
- } else if (!getInventory().contains("Super restore(4)")) {
- if (getBank().contains("Super restore(4)") && getBank().count("Super restore(4)") >= 2) {
- if (getBank().withdraw("Super restore(4)", 2)) {
- sleepUntil(() -> getInventory().contains("Super restore(4)"), Calculations.random(5000, 6000));
- }
- } else {
- log("out of super restores");
- stop();
- }
- } else if (!getInventory().contains("Cooked karambwan")) {
- if (getBank().contains("Cooked karambwan") && getBank().count("Cooked karambwan") >= 3) {
- if (getBank().withdraw("Cooked karambwan", 3)) {
- sleepUntil(() -> getInventory().contains("Cooked karambwan"), Calculations.random(5000, 6000));
- }
- } else {
- log("out of Cooked karambwan");
- stop();
- }
- } else if (getInventory().count("Anglerfish") < 12) {
- if (getBank().contains("Anglerfish") && getBank().count("Anglerfish") >= 15) {
- if (getBank().withdraw("Anglerfish", 12)) {
- sleepUntil(() -> getInventory().contains("Anglerfish"), Calculations.random(5000, 6000));
- }
- } else {
- log("out of Anglerfish");
- stop();
- }
- } else if (getBank().isOpen()) {
- getBank().close();
- } else if (getSkills().getBoostedLevels(Skill.HITPOINTS) == 99) {
- if (getInventory().interact("Anglerfish", "Eat")) {
- sleepUntil(() -> getSkills().getBoostedLevels(Skill.HITPOINTS) > 99, Calculations.random(4000, 5000));
- if (getBank().openClosest()) {
- sleepUntil(() -> getBank().isOpen(), Calculations.random(5000, 6000));
- if (getBank().withdraw("Anglerfish")) {
- sleepUntil(() -> getInventory().isFull(), Calculations.random(5000, 6000));
- }
- }
- }
- } else if (getInventory().isFull() && getGameObjects().closest("Portal") == null) {
- if (getInventory().interact("Teleport to house", "Break")) {
- sleepUntil(() -> getGameObjects().closest("Portal") != null, Calculations.random(5000, 6000));
- }
- } else if (getGameObjects().closest("Portal") != null) {
- log("We are back in our house ready to travel to the docks");
- state = 5;
- }
- } else if (gotPet) {
- log("We got the pet(figure out how to screenshot kc)");
- stop();
- }
- }
- Area RELLEKA_DOCKS_AREA = new Area(new Tile(2641, 3699), new Tile(2640, 3692));
- Area CLIMBOVER_AREA = new Area(new Tile(2273, 4052), new Tile(2271, 4049));
- Area myArea = new Area(new Tile(2273, 4048), new Tile(2271, 4048), new Tile(2271, 4044), new Tile(2270, 4037), new Tile(2274, 4036), new Tile(2277, 4034), new Tile(2278, 4034), new Tile(2279, 4035), new Tile(2281, 4037), new Tile(2279, 4037), new Tile(2278, 4037), new Tile(2277, 4037), new Tile(2273, 4043), new Tile(2273, 4047));
- Tile boatTile = new Tile(2640, 3699, 0);
- public void travelToRelleka() {
- //1. if edge bank contains us tele to house
- //2. if ornate pool not null exit out the house portal
- //3. run to the docks.
- //4. switch states
- if (getGameObjects().closest("Ornate Jewellery Box") != null) {
- if (getGameObjects().closest("Portal").interact("Enter")) {
- sleepUntil(() -> getGameObjects().closest("Ornate Jewellery Box") == null, Calculations.random(5000, 6000));
- }
- } else if (!RELLEKA_DOCKS_AREA.contains(getLocalPlayer()) && CLIMBOVER_AREA.getCenter().distance() > 50) {
- getWalking().walk(RELLEKA_DOCKS_AREA.getRandomTile());
- } else if (RELLEKA_DOCKS_AREA.contains(getLocalPlayer().getTile())) {
- // if (getGameObjects().closest("Fremennik Boat") != null) {
- // if (getNpcs().closest("Fremennik Boat").interact("Travel")) {
- // sleepUntil(()-> !RELLEKA_DOCKS_AREA.contains(getLocalPlayer().getTile()), Calculations.random(5000,6000));
- // }
- // }
- if (getWalking().walkExact(boatTile)) {
- sleepUntil(() -> getLocalPlayer().isMoving() && boatTile.distance() == 0, Calculations.random(4000, 5000));
- if (getMouse().click(new Point(562, 21))) {
- sleep(500);
- if (getMouse().move(new Point(205, 165))) {
- sleep(500);
- log("We clicked the boat");
- getMouse().click();
- sleepUntil(() -> !RELLEKA_DOCKS_AREA.contains(getLocalPlayer().getTile()), Calculations.random(5000, 6000));
- }
- }
- }
- } else if (CLIMBOVER_AREA.getCenter().distance() <= 50) {
- log("We should be on the island");
- state = 6;
- }
- }
- public void travelToVorkath() {
- //right click travel.
- //hop the ice
- //walk right up beside vorkath
- //switch states
- if (!CLIMBOVER_AREA.contains(getLocalPlayer().getTile()) && myArea.contains(getLocalPlayer().getTile())) {
- getWalking().walk(CLIMBOVER_AREA.getRandomTile());
- } else if (CLIMBOVER_AREA.contains(getLocalPlayer().getTile())) {
- if (getGameObjects().closest(ice -> ice.getName().equals("Ice chunks") && ice.hasAction("Climb-over")) != null) {
- if (getGameObjects().closest(ice -> ice.getName().equals("Ice chunks") && ice.hasAction("Climb-over")).interact("Climb-over")) {
- sleepUntil(() -> !CLIMBOVER_AREA.contains(getLocalPlayer().getTile()) && getLocalPlayer().getAnimation() == -1, Calculations.random(5000, 6000));
- }
- }
- } else if (getNpcs().closest("Vorkath") != null && getNpcs().closest("Vorkath").distance() == 11 && !getLocalPlayer().isMoving() && !CLIMBOVER_AREA.contains(getLocalPlayer().getTile()) && !myArea.contains(getLocalPlayer().getTile())) {
- log("Switching to fight prep state");
- sleep(2000);
- iceChunkTile = getLocalPlayer().getTile();
- int yAxis = iceChunkTile.getY();
- int xAxis = iceChunkTile.getX();
- wooxTile = new Tile(xAxis, yAxis + 2, 0);
- pokeTile = new Tile(xAxis, yAxis + 7);
- state = 7;
- }
- }
- public void fightPrep() {
- //equip melle gear
- // enable special attack
- //drink all pots needed
- // turn on prot magic and piety
- // switch to fight state
- if (getInventory().contains("Bandos godsword")) {
- if (getInventory().interact("Bandos godsword", "Wield")) {
- sleepUntil(() -> !getInventory().contains("Bandos godsword"), Calculations.random(5000, 6000));
- }
- } else if (getInventory().contains("Fire cape")) {
- if (getInventory().interact("Fire cape", "Wear")) {
- sleepUntil(() -> !getInventory().contains("Fire cape"), Calculations.random(5000, 6000));
- }
- } else if (getInventory().contains("Berserker ring (i)")) {
- if (getInventory().interact("Berserker ring (i)", "Wear")) {
- sleepUntil(() -> !getInventory().contains("Berserker ring (i)"), Calculations.random(5000, 6000));
- }
- } else if (getInventory().contains("Void melee helm")) {
- if (getInventory().interact("Void melee helm", "Wear")) {
- sleepUntil(() -> !getInventory().contains("Void melee helm"), Calculations.random(5000, 6000));
- }
- } else if (getInventory().contains("Primordial boots")) {
- if (getInventory().interact("Primordial boots", "Wear")) {
- sleepUntil(() -> !getInventory().contains("Primordial boots"), Calculations.random(5000, 6000));
- }
- } else if (getInventory().contains("Ranging potion(4)")) {
- if (getInventory().interact("Ranging potion(4)", "Drink")) {
- sleepUntil(() -> !getInventory().contains("Ranging potion(4)"), Calculations.random(1000, 2000));
- }
- } else if (getInventory().contains("Super combat potion(4)")) {
- if (getInventory().interact("Super combat potion(4)", "Drink")) {
- sleepUntil(() -> !getInventory().contains("Super combat potion(4)"), Calculations.random(1000, 2000));
- }
- } else if (getInventory().contains("Super antifire potion(4)")) {
- if (getInventory().interact("Super antifire potion(4)", "Drink")) {
- sleepUntil(() -> !getInventory().contains("Super antifire potion(4)"), Calculations.random(1000, 2000));
- }
- } else if (getInventory().contains("Anti-venom+(4)")) {
- if (getInventory().interact("Anti-venom+(4)", "Drink")) {
- sleepUntil(() -> !getInventory().contains("Anti-venom+(4)"), Calculations.random(1000, 2000));
- }
- } else if (getSkills().getBoostedLevels(Skill.HITPOINTS) == 99) {
- if (getInventory().interact("Anglerfish", "Eat")) {
- sleepUntil(() -> getSkills().getBoostedLevels(Skill.HITPOINTS) > 99, Calculations.random(1000, 2000));
- }
- } else if (!getPrayer().isActive(Prayer.PROTECT_FROM_MAGIC)) {
- if (getPrayer().toggle(true, Prayer.PROTECT_FROM_MAGIC)) {
- sleepUntil(() -> getPrayer().isActive(Prayer.PROTECT_FROM_MAGIC), Calculations.random(2000, 4000));
- }
- } else if (!getPrayer().isActive(Prayer.PIETY)) {
- if (getPrayer().toggle(true, Prayer.PIETY)) {
- sleepUntil(() -> getPrayer().isActive(Prayer.PIETY), Calculations.random(2000, 4000));
- }
- } else if (!getCombat().isSpecialActive()) {
- if (getCombat().toggleSpecialAttack(true)) {
- sleepUntil(() -> getCombat().isSpecialActive(), Calculations.random(4000, 5000));
- }
- } else {
- state = 1;
- log("Switching to vorkath fight state");
- }
- }
- public void deathRecovery() {
- //equip the gear we are wearing
- //go to edge bank grab 100k and house tele
- // travel to the docks
- // collect our gear
- // equip range gear and make our way back to the resupply state.
- // log("Made it to state 10");
- // // log("We dead");
- // log("Runtime: " + timeRan);
- // log("GP MADE: " + gpGained);
- // log("Vorki Kills: " + vorkiKc);
- // log("Vorki ties: " + vorkiTies);
- // stop();
- if (getCamera().getYaw() != 0) {
- getMouse().click(new Point(562, 21));
- }
- if (!getEquipment().contains("Pegasian boots") && !getInventory().contains("Coins") && !getBank().isOpen() && getBank().getClosestBankLocation().getCenter().distance() < 50) {
- if (getBank().openClosest()) {
- sleepUntil(()-> getBank().isOpen(), Calculations.random(4000,5000));
- }
- } else if (getBank().isOpen() && !getEquipment().contains("Pegasian boots") && !getInventory().contains("Coins")) {
- if (!getInventory().contains("Teleport to house")) {
- if (getBank().contains("Teleport to house")) {
- if (getBank().withdraw("Teleport to house")) {
- sleepUntil(() -> getInventory().contains("Teleport to house"), Calculations.random(4000, 5000));
- }
- } else {
- log("We are out of house teles");
- stop();
- }
- } else if (!getInventory().contains("Coins")) {
- if (getBank().count("Coins") >= 100000) {
- if (getBank().withdraw("Coins", 100000)) {
- sleepUntil(()-> getInventory().contains("Coins"), Calculations.random(3000,4000));
- }
- } else {
- log("out of money");
- stop();
- }
- }
- } else if (getBank().isOpen() && !getEquipment().contains("Pegasian boots") && getInventory().contains("Coins")) {
- getBank().close();
- } else if (getBank().getClosestBankLocation().getCenter().distance() < 50 && !getEquipment().contains("Pegasian boots") && getInventory().contains("Coins")) {
- if (getInventory().interact("Teleport to house", "Break")) {
- sleepUntil(()-> getBank().getClosestBankLocation().getCenter().distance() < 50, Calculations.random(5000,7000));
- }
- } else if (getGameObjects().closest("Ornate Jewellery Box") != null && !getEquipment().contains("Pegasian boots") && getInventory().contains("Coins")) {
- if (getGameObjects().closest("Portal").interact("Enter")) {
- sleepUntil(()-> getGameObjects().closest("Ornate Jewellery Box") == null, Calculations.random(5000,6000));
- }
- } else if (!RELLEKA_DOCKS_AREA.contains(getLocalPlayer().getTile()) && !getEquipment().contains("Pegasian boots") && getInventory().contains("Coins")) {
- getWalking().walk(RELLEKA_DOCKS_AREA.getRandomTile());
- } else if ((RELLEKA_DOCKS_AREA.contains(getLocalPlayer().getTile()) || getNpcs().closest("Vorkath") != null) && !getEquipment().contains("Pegasian boots") && getInventory().contains("Coins") && !getDialogues().inDialogue() && getWidgets().getWidgetChild(602,1,1) == null) {
- if (getNpcs().closest(7504) != null) {
- Tile clickTile = getNpcs().closest(7504).getTile();
- if (clickTile.distance() > 2) {
- getWalking().walk(clickTile);
- } else {
- if (getMouse().move(clickTile)) {
- sleep(400);
- if (getMouse().click()) {
- sleepUntil(() -> getDialogues().inDialogue(), Calculations.random(4000, 5000));
- }
- }
- }
- }
- } else if (getDialogues().inDialogue() && getDialogues().canContinue()) {
- if (getDialogues().clickContinue()) {
- sleep(1000);
- }
- } else if (getDialogues().inDialogue() && getDialogues().getOptions().length == 2) {
- if (getDialogues().chooseOption(1)) {
- sleep(1000);
- }
- } else if (getDialogues().inDialogue() && getDialogues().getOptions().length == 3) {
- if (getDialogues().chooseOption(2)) {
- sleep(1000);
- }
- } else if (!getEquipment().contains("Pegasian boots") && getInventory().contains("Coins") && getWidgets().getWidgetChild(602,1,1) != null) {
- if (getWidgets().getWidgetChild(602,6) != null) {
- if (getWidgets().getWidgetChild(602,6).interact()) {
- sleepUntil(()-> getDialogues().inDialogue(), Calculations.random(5000,6000));
- }
- }
- } else if (getWidgets().getWidgetChild(602,6) != null && getWidgets().getWidgetChild(602,6).isVisible()) {
- log("Switching to a new state to keep it simple");
- state = 10;
- }
- // stop();
- }
- boolean stackCountZero = false;
- int stackCount;
- public int stackCount() {
- if (getWidgets().getWidgetChild(602,10) != null) {
- String ourTxtBerforeParse;
- String ourTxtAfterParse;
- ourTxtBerforeParse = getWidgets().getWidgetChild(602,10).getText();
- ourTxtAfterParse = ourTxtBerforeParse.substring(ourTxtBerforeParse.indexOf(">") + 1);
- ourTxtAfterParse = ourTxtAfterParse.substring(0, ourTxtAfterParse.indexOf("<"));
- stackCount = Integer.parseInt(ourTxtAfterParse);
- if (stackCount == 0) {
- stackCountZero = true;
- }
- return stackCount;
- }
- return -1;
- }
- public void grabGear() {
- if (getCamera().getYaw() != 0) {
- getMouse().click(new Point(562, 21));
- }
- if (!stackCountZero) {
- stackCount();
- if (getWidgets().getWidgetChild(602,6) != null && !getInventory().isFull() && stackCount > 0) {
- if (getWidgets().getWidgetChild(602,6).interact()) {
- sleepUntil(()-> getInventory().isFull() || stackCount() == 0, Calculations.random(5000,6000));
- }
- } else if (getWidgets().getWidgetChild(602,6) != null && getInventory().isFull()) {
- if (getWidgets().getWidgetChild(602,1,11).interact()) {
- sleepUntil(()-> getWidgets().getWidgetChild(602,6) == null, Calculations.random(4000,5000));
- }
- } else if (getInventory().contains("Anglerfish")) {
- getInventory().dropAll("Anglerfish");
- } else if (getInventory().contains("Cooked karambwan")) {
- getInventory().dropAll("Cooked karambwan");
- } else if (!getInventory().contains("Anglerfish") && getWidgets().getWidgetChild(602,6) == null) {
- if ((RELLEKA_DOCKS_AREA.contains(getLocalPlayer().getTile()) || getNpcs().closest("Vorkath") != null) && !getEquipment().contains("Pegasian boots") && !getDialogues().inDialogue() && getWidgets().getWidgetChild(602,10) == null) {
- if (getNpcs().closest(7504) != null) {
- Tile clickTile = getNpcs().closest(7504).getTile();
- if (getMouse().move(clickTile)) {
- sleep(400);
- if (getMouse().click()) {
- sleepUntil(()-> getDialogues().inDialogue(), Calculations.random(4000,5000));
- }
- }
- }
- } else if (getDialogues().inDialogue() && getDialogues().canContinue()) {
- if (getDialogues().clickContinue()) {
- sleep(1000);
- }
- } else if (getDialogues().inDialogue() && getDialogues().getOptions().length == 2) {
- if (getDialogues().chooseOption(1)) {
- sleep(1000);
- }
- } else if (getDialogues().inDialogue() && getDialogues().getOptions().length == 3) {
- if (getDialogues().chooseOption(2)) {
- sleep(1000);
- }
- }
- }
- } else if (getInventory().contains("Toxic blowpipe")) {
- if (getInventory().interact("Toxic blowpipe", "Wield")) {
- sleepUntil(() -> !getInventory().contains("Toxic blowpipe"), Calculations.random(1000, 2000));
- }
- } else if (getInventory().contains("Archers ring (i)")) {
- if (getInventory().interact("Archers ring (i)", "Wear")) {
- sleepUntil(() -> !getInventory().contains("Archers ring (i)"), Calculations.random(1000, 2000));
- }
- } else if (getInventory().contains("Void ranger helm")) {
- if (getInventory().interact("Void ranger helm", "Wear")) {
- sleepUntil(() -> !getInventory().contains("Void ranger helm"), Calculations.random(1000, 2000));
- }
- } else if (getInventory().contains("Ava's assembler")) {
- if (getInventory().interact("Ava's assembler", "Wear")) {
- sleepUntil(() -> !getInventory().contains("Ava's assembler"), Calculations.random(1000, 2000));
- }
- } else if (getInventory().contains("Pegasian boots")) {
- if (getInventory().interact("Pegasian boots", "Wear")) {
- sleepUntil(() -> !getInventory().contains("Pegasian boots"), Calculations.random(1000, 2000));
- }
- } else if (getInventory().contains("Ancient blessing")) {
- if (getInventory().interact("Ancient blessing", "Equip")) {
- sleepUntil(() -> !getInventory().contains("Ancient blessing"), Calculations.random(1000, 2000));
- }
- } else if (getInventory().contains("Salve amulet(ei)")) {
- if (getInventory().interact("Salve amulet(ei)", "Wear")) {
- sleepUntil(() -> !getInventory().contains("Salve amulet(ei)"), Calculations.random(1000, 2000));
- }
- } else if (getInventory().contains("Void knight top")) {
- if (getInventory().interact("Void knight top", "Wear")) {
- sleepUntil(() -> !getInventory().contains("Void knight top"), Calculations.random(1000, 2000));
- }
- } else if (getInventory().contains("Void knight robe")) {
- if (getInventory().interact("Void knight robe", "Wear")) {
- sleepUntil(() -> !getInventory().contains("Void knight robe"), Calculations.random(1000, 2000));
- }
- } else if (getInventory().contains("Void knight gloves")) {
- if (getInventory().interact("Void knight gloves", "Wear")) {
- sleepUntil(() -> !getInventory().contains("Void knight gloves"), Calculations.random(1000, 2000));
- }
- } else if (!getInventory().isFull() && getGroundItems().closest("Anglerfish") != null) {
- getGroundItems().closest("Anglerfish").interact("Take");
- } else if (!getInventory().isFull() && getGroundItems().closest("Cooked karambwan") != null) {
- getGroundItems().closest("Cooked karambwan").interact("Take");
- }
- else {
- state = 11;
- }
- // if (!getEquipment().contains("Toxic blowpipe")) {
- // if (!getInventory().isFull())
- // }
- }
- public void fillPouch() {
- if (getInventory().contains("Chaos rune")) {
- if (getInventory().interact("Chaos rune", "Use")) {
- if (getInventory().interact("Rune pouch", "Use")) {
- sleepUntil(()-> !getInventory().contains("Chaos rune"), Calculations.random(5000,6000));
- }
- }
- } else if (getInventory().contains("Air rune")) {
- if (getInventory().interact("Air rune", "Use")) {
- if (getInventory().interact("Rune pouch", "Use")) {
- sleepUntil(()-> !getInventory().contains("Air rune"), Calculations.random(5000,6000));
- }
- }
- } else if (getInventory().contains("Earth rune")) {
- if (getInventory().interact("Earth rune", "Use")) {
- if (getInventory().interact("Rune pouch", "Use")) {
- sleepUntil(()-> !getInventory().contains("Air rune"), Calculations.random(5000,6000));
- }
- }
- } else if (!getInventory().isFull() && getGroundItems().closest("Anglerfish") != null) {
- getGroundItems().closest("Anglerfish").interact("Take");
- } else if (!getInventory().isFull() && getGroundItems().closest("Cooked karambwan") != null) {
- getGroundItems().closest("Cooked karambwan").interact("Take");
- } else if (getNpcs().closest(7504) != null) {
- if (getInventory().interact("Teleport to house", "Break")) {
- sleepUntil(()-> getNpcs().closest(7504) == null, Calculations.random(4000,6000));
- }
- } else if (getNpcs().closest(7504) == null) {
- state = 3;
- stackCount = -1;
- stackCountZero = false;
- }
- }
- //States: 1 = fight vorkath, 2 = loot, 3 = House(Bank), 4 = resupply, 5 = house(relleka), 6 = travel to fight, 7 = fight prep, 8 = Death recovery
- int state = 9;
- @Override
- public int onLoop() {
- if (state == 1) {
- vorkathFight();
- } else if (state == 2) {
- looting();
- } else if (state == 3) {
- restoreStats();
- } else if (state == 4) {
- reSupply();
- } else if (state == 5) {
- travelToRelleka();
- } else if (state == 6) {
- travelToVorkath();
- } else if (state == 7) {
- fightPrep();
- } else if (state == 8) {
- deathRecovery();
- } else if (state == 9) {
- withdrawSupplies();
- } else if (state == 10) {
- grabGear();
- } else if (state == 11) {
- fillPouch();
- }
- return Calculations.random(100, 200);
- }
- public void poisonPathFinding() {
- GameObject closestAcidPool = getGameObjects().closest(acid -> acid.getID() == 32000 && (leftSide.contains(acid) || rightSide.contains(acid)));
- if (closestAcidPool != null) {
- log("We found the closest acid pool");
- Tile closestAcidPoolsTile = closestAcidPool.getTile();
- int closestAcidPoolX = closestAcidPoolsTile.getX();
- int closestAcidPoolY = closestAcidPoolsTile.getY();
- // code 5 tiles in all directions and then perform a check on them
- //west//
- Tile oneW = new Tile(closestAcidPoolX - 1, closestAcidPoolY,0);
- Tile twoW = new Tile(closestAcidPoolX - 2, closestAcidPoolY,0);
- Tile threeW = new Tile(closestAcidPoolX - 3, closestAcidPoolY,0);
- Tile fourW = new Tile(closestAcidPoolX - 4, closestAcidPoolY,0);
- Tile fiveW = new Tile(closestAcidPoolX - 5, closestAcidPoolY,0);
- Tile sixW = new Tile(closestAcidPoolX - 6, closestAcidPoolY, 0);
- Tile sevenW = new Tile(closestAcidPoolX - 7, closestAcidPoolY, 0);
- Tile eightW = new Tile(closestAcidPoolX - 8, closestAcidPoolY, 0);
- //east//
- Tile oneE = new Tile(closestAcidPoolX + 1, closestAcidPoolY,0);
- Tile twoE = new Tile(closestAcidPoolX + 2, closestAcidPoolY,0);
- Tile threeE = new Tile(closestAcidPoolX + 3, closestAcidPoolY,0);
- Tile fourE = new Tile(closestAcidPoolX + 4, closestAcidPoolY,0);
- Tile fiveE = new Tile(closestAcidPoolX + 5, closestAcidPoolY,0);
- Tile sixE = new Tile(closestAcidPoolX + 6, closestAcidPoolY, 0);
- Tile sevenE = new Tile(closestAcidPoolX + 7, closestAcidPoolY, 0);
- Tile eightE = new Tile(closestAcidPoolX + 8, closestAcidPoolY, 0);
- GameObject acidOneW = getGameObjects().closest(acid -> acid.getID() == 32000 && acid.getTile().equals(oneW));
- GameObject acidTwoW = getGameObjects().closest(acid -> acid.getID() == 32000 && acid.getTile().equals(twoW));
- GameObject acidThreeW = getGameObjects().closest(acid -> acid.getID() == 32000 && acid.getTile().equals(threeW));
- GameObject acidFourW = getGameObjects().closest(acid -> acid.getID() == 32000 && acid.getTile().equals(fourW));
- GameObject acidFiveW = getGameObjects().closest(acid -> acid.getID() == 32000 && acid.getTile().equals(fiveW));
- GameObject acidSixW = getGameObjects().closest(acid -> acid.getID() == 32000 && acid.getTile().equals(sixW));
- GameObject acidSevenW = getGameObjects().closest(acid -> acid.getID() == 32000 && acid.getTile().equals(sevenW));
- GameObject acidEightW = getGameObjects().closest(acid -> acid.getID() == 32000 && acid.getTile().equals(eightW));
- GameObject acidOneE = getGameObjects().closest(acid -> acid.getID() == 32000 && acid.getTile().equals(oneE));
- GameObject acidTwoE = getGameObjects().closest(acid -> acid.getID() == 32000 && acid.getTile().equals(twoE));
- GameObject acidThreeE = getGameObjects().closest(acid -> acid.getID() == 32000 && acid.getTile().equals(threeE));
- GameObject acidFourE = getGameObjects().closest(acid -> acid.getID() == 32000 && acid.getTile().equals(fourE));
- GameObject acidFiveE = getGameObjects().closest(acid -> acid.getID() == 32000 && acid.getTile().equals(fiveE));
- GameObject acidSixE = getGameObjects().closest(acid -> acid.getID() == 32000 && acid.getTile().equals(sixE));
- GameObject acidSevenE = getGameObjects().closest(acid -> acid.getID() == 32000 && acid.getTile().equals(sevenE));
- GameObject acidEightE = getGameObjects().closest(acid -> acid.getID() == 32000 && acid.getTile().equals(eightE));
- if (acidOneW == null && acidTwoW == null && acidThreeW == null && acidFourW == null && acidFiveW == null && acidSixW == null && acidSevenW == null && acidEightW == null) {
- //we found our clear path
- //now we want to start walking between tile oneW and tile fiveW
- log("Path found");
- foundPoisonTiles = true;
- poisonTile1 = oneW;
- poisonTile2 = eightW;
- } else if (acidOneE == null && acidTwoE == null && acidThreeE == null && acidFourE == null && acidFiveE == null && acidSixE == null && acidSevenE == null && acidEightE == null) {
- log("Path found");
- foundPoisonTiles = true;
- poisonTile1 = oneE;
- poisonTile2 = eightE;
- } else {
- // maybe keep moving and try again
- log("No clear path found");
- }
- } else {
- log("Acid pool not found");
- }
- }
- @Override
- public void onAutoMessage(Message message) {
- }
- @Override
- public void onPrivateInfoMessage(Message message) {
- }
- @Override
- public void onClanMessage(Message message) {
- }
- boolean gotPet = false;
- @Override
- public void onGameMessage(Message m) {
- if (m.getMessage().contains("You have been frozen!") && !frozen) {
- log("Chat detected we are frozen");
- frozen = true;
- } else if (m.getMessage().contains("Your prayers have been disabled!") && !prayerDisabled) {
- prayerDisabled = true;
- // if (getPrayer().toggleQuickPrayer(true)) {
- // prayerDisabled = false;
- // }
- if (frozen == true) {
- frozen = false;
- }
- } else if ((m.getMessage().contains("Your super antifire potion is about to expire.") || m.getMessage().contains("Your super antifire potion has expired.")) && !antiFireExpired && state == 1) {
- antiFireExpired = true;
- } else if (m.getMessage().contains("You have a funny feeling like you're being followed")) {
- gotPet = true;
- }
- }
- @Override
- public void onPlayerMessage(Message message) {
- }
- @Override
- public void onTradeMessage(Message message) {
- }
- @Override
- public void onPrivateInMessage(Message message) {
- }
- @Override
- public void onPrivateOutMessage(Message message) {
- }
- private long timeBegan;
- private long timeRan;
- @Override
- public void onPaint(Graphics g) {
- Color orange = new Color(254, 127, 0);
- g.setColor(orange);
- timeRan = System.currentTimeMillis() - this.timeBegan;
- g.drawString(ft(timeRan), 100, 100);
- g.drawString("Vorki Kills: " + vorkiKc, 100, 90);
- g.drawString("Vorki Ties: " + vorkiTies, 100, 80);
- g.drawString("Vorki Deaths: " + vorkiDeaths, 100, 70);
- g.drawString("GP Gained: " + gpGained, 100, 50);
- if (getNpcs().closest("Vorkath") != null && getNpcs().closest("Vorkath").isHealthBarVisible()) {
- g.drawString("Vorkis Current HP%: " + getNpcs().closest("Vorkath").getHealthPercent(), 100, 60);
- }
- }
- private String ft(long duration) {
- String res = "";
- long days = TimeUnit.MILLISECONDS.toDays(duration);
- long hours = TimeUnit.MILLISECONDS.toHours(duration) - TimeUnit.DAYS.toHours(TimeUnit.MILLISECONDS.toDays(duration));
- long minutes = TimeUnit.MILLISECONDS.toMinutes(duration) - TimeUnit.HOURS.toMinutes(TimeUnit.MILLISECONDS.toHours(duration));
- long seconds = TimeUnit.MILLISECONDS.toSeconds(duration) - TimeUnit.MINUTES.toSeconds(TimeUnit.MILLISECONDS.toMinutes(duration));
- if (days == 0) {
- res = (hours + ":" + minutes + ":" + seconds);
- } else {
- res = (days + ":" + hours + ":" + minutes + ":" + seconds);
- }
- return res;
- }
- private static URLConnection con;
- private static InputStream is;
- private static InputStreamReader isr;
- private static BufferedReader br;
- private static String[] getData(int itemID) {
- try {
- URL url = new URL("https://api.rsbuddy.com/grandExchange?a=guidePrice&i=" + itemID);
- con = url.openConnection();
- is = con.getInputStream();
- isr = new InputStreamReader(is);
- br = new BufferedReader(isr);
- String line = br.readLine();
- if (line != null) {
- log(line);
- return line.split(",");
- }
- } catch (Exception e) {
- e.printStackTrace();
- } finally {
- try {
- if (br != null) {
- br.close();
- } else if (isr != null) {
- isr.close();
- } else if (is != null) {
- is.close();
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- return null;
- }
- public static int getPrice(int itemID) {
- String[] data = getData(itemID);
- if (data != null && data.length == 5) {
- log(data.toString());
- if (Integer.parseInt(data[0].replaceAll("\\D", "")) == 0) {
- String[] dataNoted = getData(itemID - 1);
- log("Data returned 0 trying new itemid: " + Integer.parseInt(dataNoted[0].replaceAll("\\D", "")));
- return Integer.parseInt(dataNoted[0].replaceAll("\\D", ""));
- } else {
- return Integer.parseInt(data[0].replaceAll("\\D", ""));
- }
- } else {
- if (data != null && data.length != 5) {
- log("We bumped into a noted item i hope");
- data = getData(itemID - 1);
- if (data != null && data.length == 5) {
- return Integer.parseInt(data[0].replaceAll("\\D", ""));
- }
- }
- }
- log("Looks like we returned 0");
- return 0;
- }
- public static int getAverageBuyOffer(int itemID) {
- String[] data = getData(itemID);
- if (data != null && data.length == 5) {
- return Integer.parseInt(data[1].replaceAll("\\D", ""));
- }
- return 0;
- }
- public static int getAverageSellOffer(int itemID) {
- String[] data = getData(itemID);
- if (data != null && data.length == 5) {
- return Integer.parseInt(data[3].replaceAll("\\D", ""));
- }
- return 0;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement