Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package WarriorsguildScripts;
- import org.dreambot.api.methods.Calculations;
- import org.dreambot.api.methods.map.Area;
- import org.dreambot.api.methods.map.Tile;
- import org.dreambot.api.methods.skills.Skill;
- import org.dreambot.api.methods.tabs.Tab;
- import org.dreambot.api.script.AbstractScript;
- import org.dreambot.api.script.Category;
- import org.dreambot.api.script.ScriptManifest;
- import org.dreambot.api.script.listener.PaintListener;
- 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.items.Item;
- import org.dreambot.api.wrappers.widgets.WidgetChild;
- import java.awt.*;
- import java.awt.event.MouseEvent;
- import java.awt.event.MouseListener;
- /** WORK ON POLYGONS */
- @ScriptManifest(author = "Infallible", name = "iDefenderer", category = Category.MINIGAME, version = 1)
- public class wgDefenderer extends AbstractScript implements PaintListener, MouseListener{
- public int[] defenderAreaX = {2847, 2848, 2849, 2849, 2877, 2877, 2837, 2837, 2846};
- public int[] defenderAreaY = {3538, 3537, 3536, 3533, 3533, 3557, 3557, 3543, 3543};
- public Polygon defenderAreaPolygon = new Polygon(defenderAreaX, defenderAreaY, defenderAreaX.length);
- public int[] dragonDefenderAreaX = {2912, 2940, 2940, 2905, 2905, 2912};
- public int[] dragonDefenderAreaY = {9973, 9973, 9957, 9957, 9965, 9965};
- public Polygon dragonDefenderAreaPolygon = new Polygon(dragonDefenderAreaX, dragonDefenderAreaY, dragonDefenderAreaX.length);
- public int[] groundFloorAreaX = {2838, 2875, 2875, 2859, 2849, 2848, 2838, 2830, 2830};
- public int[] groundFloorAreaY = {3555, 3555, 3537, 3534, 3534, 3537, 3537, 3537, 3550};
- public Polygon groundFloorPolygon = new Polygon(groundFloorAreaX, groundFloorAreaY, groundFloorAreaX.length);
- public Tile smallCellarAreaTile1 = new Tile(2905, 9973, 0);
- public Tile smallCellarAreaTile2 = new Tile(2911, 9966, 0);
- public Area smallCellarArea = new Area(smallCellarAreaTile1, smallCellarAreaTile2);
- public NPC cyclops;
- public String selectedFoodName;
- public final int[] defenderIDs = {12954, 8850, 8849, 8848, 8847, 8846, 8845, 8844};
- public int Token = 8851;
- public Tile doorArea;
- public GameObject doors;
- public Tile groundFloorStairs = new Tile(2841, 3538, 0);
- public NPC kamfreena;
- public WidgetChild autoRetal;
- public Item food;
- public boolean isInBounds;
- public Rectangle sharkRectangle = new Rectangle(3, 391, 114, 45);
- public Rectangle lobsterRectangle = new Rectangle(2, 341, 114, 45);
- public Tile bankTile = new Tile (2843, 3543);
- public boolean below76 = false;
- public boolean below106 = false;
- public java.util.List<GroundItem> allitems;
- public GroundItem groundDefender;
- public boolean needsToShowDefender = false;
- public int defenderCount = 0;
- public GameObject stairs;
- public GameObject ladder;
- public NPC Lorelai;
- public int bestDefID;
- public enum State {
- EATING,
- LOOT_DEFENDER,
- SHOWING_DEFENDER_TO_KAMFREENA,
- IN_COMBAT,
- ATTACKING,
- GET_TO_ROOM,
- BANKING,
- BANK_FROM_TOP,
- GET_TO_CELLAR,
- BANK_FROM_CELLAR,
- CHECK
- }
- @Override
- public void mouseClicked(MouseEvent e) {
- if (lobsterRectangle.contains(e.getPoint())) {
- selectedFoodName = "Lobster";
- log("Lobster selected as food");
- }
- if (sharkRectangle.contains(e.getPoint())) {
- selectedFoodName = "Shark";
- log("Shark selected as food");
- }
- }
- @Override
- public void mousePressed(MouseEvent e) {
- }
- @Override
- public void mouseReleased(MouseEvent e) {
- }
- @Override
- public void mouseEntered(MouseEvent e) {
- }
- @Override
- public void mouseExited(MouseEvent e) {
- }
- /**
- * gets the current state for onLoop
- */
- private State getState() {
- if(!onDragonDefenders()) {
- if (hasFood()) {
- if (needsToEat())
- return State.EATING;
- else if (nearbyDefender() && isInRoom())
- return State.LOOT_DEFENDER;
- else if (getLocalPlayer().getZ() == 2
- && needsToShowDefender)
- return State.SHOWING_DEFENDER_TO_KAMFREENA;
- else if (inCombat() && !needsToEat())
- return State.IN_COMBAT;
- else if (isInRoom() && !needsToEat() && !inCombat())
- return State.ATTACKING;
- else if (!isInRoom() && hasFood())
- return State.GET_TO_ROOM;
- } else if ((getLocalPlayer().distance(bankTile) < 3))
- return State.BANKING;
- else return State.BANK_FROM_TOP;
- }
- else if(onDragonDefenders()){
- if(hasFood()) {
- if (needsToEat())
- return State.EATING;
- else if (!isInCellarRoom())
- return State.GET_TO_CELLAR;
- else if (nearbyDefender() && isInCellarRoom())
- return State.LOOT_DEFENDER;
- else if (isInCellarRoom() && !needsToEat() && !inCombat())
- return State.ATTACKING;
- else if (inCombat() && !needsToEat())
- return State.IN_COMBAT;
- } else if((getLocalPlayer().distance(bankTile) < 3))
- return State.BANKING;
- else return State.BANK_FROM_CELLAR;
- }
- return State.CHECK;
- }
- @Override
- public int onLoop() {
- switch (getState()) {
- case LOOT_DEFENDER:
- lootDefender();
- break;
- case EATING:
- eat();
- break;
- case ATTACKING:
- attack();
- break;
- case BANK_FROM_TOP:
- getToBank();
- break;
- case GET_TO_ROOM:
- getToRoom();
- break;
- case SHOWING_DEFENDER_TO_KAMFREENA:
- useDefenderOnKamfreena();
- break;
- case BANKING:
- bank();
- break;
- case IN_COMBAT:
- inCombat();
- break;
- case GET_TO_CELLAR:
- getToCellar();
- case BANK_FROM_CELLAR:
- bankFromCellar();
- }
- return 200;
- }
- /**
- * Returns string for paint
- */
- public String stateParser() {
- switch (getState()) {
- case EATING:
- return "Eating";
- case LOOT_DEFENDER:
- return "Looting Defender";
- // case LOOTING:
- // break;
- case SHOWING_DEFENDER_TO_KAMFREENA:
- return "Showing Defender";
- case IN_COMBAT:
- return "In Combat";
- case ATTACKING:
- return "Attacking";
- case GET_TO_ROOM:
- return "Running to Cyclops Room";
- case BANKING:
- return "Banking";
- case BANK_FROM_TOP:
- return "Running to Bank";
- case GET_TO_CELLAR:
- return "Running to Cellar";
- case BANK_FROM_CELLAR:
- return "Running to Bank";
- case CHECK:
- return "check";
- }
- return "NOSTATE";
- }
- /** What the script does at start */
- @Override
- public void onStart() {
- super.onStart();
- below76 = getLocalPlayer().getLevel() < 76;
- below106 = getLocalPlayer().getLevel() < 106;
- setAutoRetaliate(true);
- getSkillTracker().start(Skill.HITPOINTS);
- Item defender = getInventory().get(bestDefender());
- if (isInRoom() || bestDefender() == defenderIDs[0] || defender == null) needsToShowDefender = false;
- selectedFoodName = "nothing";
- sleepUntil(() -> selectedFoodName != "nothing", Calculations.random(10000, 20000));
- if(getInventory().contains(d->d.getName().contains("defender"))); needsToShowDefender = true;
- }
- @Override
- public void onPaint(Graphics g) {
- isInBounds = lobsterRectangle.contains(getClient().getMousePosition());
- if(isInBounds) {g.setColor(isInBounds ? Color.green : Color.red);
- g.fillRect(2, 341, 114, 45);
- }
- isInBounds = sharkRectangle.contains(getClient().getMousePosition());
- if(isInBounds) {g.setColor(isInBounds ? Color.green : Color.red);
- g.fillRect(3, 391, 114, 45);
- }
- g.setColor(new Color(48, 48, 48, 180));
- g.fillRect(2, 341, 114, 45);
- g.fillRect(3, 391, 114, 45);
- g.setColor(Color.white);
- g.drawString("State: " + stateParser(), 370, 360);
- g.drawString("Defender count: " + defenderCount, 370, 375);
- g.drawString("Lobster", 32, 366);
- g.drawString("Shark", 32, 416);
- g.drawString("Levels gained: " + getSkillTracker().getGainedLevels(Skill.HITPOINTS), 370, 390);
- g.drawString("Hitpoints Exp/hr: " + getSkillTracker().getGainedExperiencePerHour(Skill.HITPOINTS), 370, 405);
- }
- /** Methods located here */
- public void attack() {
- if(!onDragonDefenders()) {
- if (isInRoom() && !getLocalPlayer().isInCombat()) {
- cyclops = getNpcs().closest(c -> c.getName().contains("Cyclops") && !c.isAnimating() && c.getHealth() != 0 && !c.isInCombat());
- if (!cyclops.isOnScreen() && cyclopsIsNotNull()) {
- if (getLocalPlayer().distance(cyclops) > 5) {
- getCamera().rotateToEntity(cyclops);
- getWalking().walk(cyclops);
- sleep(Calculations.random(300, 1000));
- }
- } else if (below76) {
- if (cyclopsIsNotNull()) {
- if (cyclops.interactForceRight("Attack")) {
- sleepUntil(() -> getLocalPlayer().isInCombat(), 5000);
- if (cyclops.isInteracting(getLocalPlayer())) {
- cyclops = getNpcs().closest(c -> c.getName().contains("Cyclops") && !c.isAnimating() && c.getHealth() != 0 && !c.isInCombat());
- getCamera().rotateToEntity(cyclops);
- sleepUntil(() -> !getLocalPlayer().isInCombat() || getLocalPlayer().getHealth() < 50 || !getLocalPlayer().isAnimating() || !getLocalPlayer().isHealthBarVisible(), 20000);
- }
- }
- }
- } else if (cyclopsIsNotNull()) {
- if (cyclops.interact("Attack")) {
- sleepUntil(() -> getLocalPlayer().isInCombat(), 5000);
- if (cyclops.isInteracting(getLocalPlayer())) {
- cyclops = getNpcs().closest(c -> c.getName().contains("Cyclops") && !c.isAnimating() && c.getHealth() != 0 && !c.isInCombat());
- getCamera().rotateToEntity(cyclops);
- sleepUntil(() -> !getLocalPlayer().isInCombat() || getLocalPlayer().getHealth() < 50 || !getLocalPlayer().isInteracting(cyclops) || !getLocalPlayer().isAnimating() || !getLocalPlayer().isHealthBarVisible(), 20000);
- }
- }
- }
- }
- }
- else if (onDragonDefenders() && isInCellarRoom() && !getLocalPlayer().isInCombat()) {
- log("Polygon is good!");
- cyclops = getNpcs().closest(c -> c.getName().contains("Cyclops") && !c.isAnimating() && c.getHealth() != 0 && !c.isInCombat());
- if (!cyclops.isOnScreen() && cyclopsIsNotNull()) {
- if (getLocalPlayer().distance(cyclops) > 5) {
- getCamera().rotateToEntity(cyclops);
- getWalking().walk(cyclops);
- sleep(Calculations.random(300, 1000));
- }
- } else if (below106) {
- if (cyclopsIsNotNull()) {
- if (cyclops.interactForceRight("Attack")) {
- sleepUntil(() -> getLocalPlayer().isInCombat(), 5000);
- if (cyclops.isInteracting(getLocalPlayer())) {
- cyclops = getNpcs().closest(c -> c.getName().contains("Cyclops") && !c.isAnimating() && c.getHealth() != 0 && !c.isInCombat());
- getCamera().rotateToEntity(cyclops);
- sleepUntil(() -> !getLocalPlayer().isInCombat() || getLocalPlayer().getHealth() < 50 || !getLocalPlayer().isAnimating() || !getLocalPlayer().isHealthBarVisible(), 20000);
- }
- }
- }
- } else if (cyclopsIsNotNull()) {
- if (cyclops.interact("Attack")) {
- sleepUntil(() -> getLocalPlayer().isInCombat(), 5000);
- if (cyclops.isInteracting(getLocalPlayer())) {
- cyclops = getNpcs().closest(c -> c.getName().contains("Cyclops") && !c.isAnimating() && c.getHealth() != 0 && !c.isInCombat());
- getCamera().rotateToEntity(cyclops);
- sleepUntil(() -> !getLocalPlayer().isInCombat() || getLocalPlayer().getHealth() < 50 || !getLocalPlayer().isInteracting(cyclops) || !getLocalPlayer().isAnimating() || !getLocalPlayer().isHealthBarVisible(), 20000);
- }
- }
- }
- }
- }
- public boolean isInRoom() {return (defenderAreaPolygon.contains(getLocalPlayer().getX(), getLocalPlayer().getY()) && getLocalPlayer().getZ() ==2);}
- public int stopScript() {
- return -1;
- }
- public boolean cyclopsIsNotNull() {return (cyclops != null && cyclops.getHealth() != 0 && !cyclops.isAnimating());}
- public boolean needsToEat() {
- return (getCombat().getHealthPercent() <=Calculations.random(40, 70));
- }
- public boolean hasFood() {
- return (getInventory().contains(f -> f.getName().contains(selectedFoodName)));
- }
- public void eat() {
- if (needsToEat() || getInventory().isFull()) {
- openTabIfClosed(Tab.INVENTORY);
- food = getInventory().getRandom(selectedFoodName);
- if (food != null) {
- if (food.interact("Eat")) sleep(Calculations.random(300, 700));
- }
- }
- }
- public int bestDefender() {
- bestDefID = 0;
- openTabIfClosed(Tab.INVENTORY);
- for (int i : defenderIDs) {
- if (getInventory().contains(i)){
- return i;
- }
- }
- return 0;
- }
- public void openTabIfClosed(Tab tab) {
- long t = System.currentTimeMillis();
- if (!getTabs().isOpen(tab) && (System.currentTimeMillis() - t) <= 5000) {
- getTabs().open(tab);
- sleep(Calculations.random(300, 800));
- }
- }
- public boolean nearbyDefender() {
- allitems = getGroundItems().all(g -> g.getName().contains("defender"));
- for (GroundItem i : allitems) {
- if (i != null && i.exists()) {
- return true;
- }
- }
- return false;
- }
- public void lootDefender() {
- if (nearbyDefender()) {
- openTabIfClosed(Tab.INVENTORY);
- groundDefender = getGroundItems().closest(d ->d.getName().contains("defender"));
- if (getInventory().isFull()) {
- eat();
- }
- if (nearbyDefender()) {
- if (!groundDefender.isOnScreen()) {
- if (getLocalPlayer().distance(groundDefender) > 3) {
- getWalking().walk(groundDefender);
- sleep(Calculations.random(500, 1000));
- }
- }
- int defenderID = groundDefender.getID();
- if (groundDefender.isOnScreen()) {
- if (groundDefender.interactForceRight("Take")) {
- defenderCount++;
- if (defenderID != defenderIDs[0]) {
- if(!onDragonDefenders()) {
- needsToShowDefender = true;
- sleep(500, 600);
- }
- }
- }
- }
- }
- }
- }
- public void getToBank() {
- if (getLocalPlayer().getZ() == 0) {
- if ((getLocalPlayer().distance(bankTile) > 3)) {
- log("Distance >3");
- if (getWalking().walk(bankTile)) {
- log("Walking to bank");
- sleepUntil(() -> !getLocalPlayer().isMoving()
- || getLocalPlayer().distance(getClient().getDestination()) < 5
- , Calculations.random(1500, 3500));
- }
- }
- }else if (getLocalPlayer().getZ() == 1) {
- stairs = getGameObjects().closest(s -> s.getName().contains("Staircase"));
- if (stairs != null && stairs.exists()) {
- if (stairs.interactForceRight("Climb-down")) {
- if (getLocalPlayer().getZ() == 1)
- sleepUntil(() -> getLocalPlayer().getZ() != 1, Calculations.random(3000, 5000));
- }
- }
- } else if (getLocalPlayer().getZ() == 2) {
- if (isInRoom()) {
- doorArea = new Tile(2847, 3541, 2);
- if (getCamera().rotateToPitch(Calculations.random(300, 383)) && getCamera().rotateToYaw(Calculations.random(250, 800))) {
- if(getLocalPlayer().distance(doorArea) > 8) {
- if (getWalking().walk(doorArea)) {
- sleepUntil(() -> getLocalPlayer().isMoving() || getLocalPlayer().distance(getClient().getDestination()) < (Calculations.random(3, 8))
- , Calculations.random(10000, 15000));
- }
- }else doors = getGameObjects().closest(d -> d.getName().contains("Door"));
- if (doors != null && doors.exists()) {
- if (doors.interactForceRight("Open")) {
- if (isInRoom()) sleepUntil(() -> !isInRoom(), Calculations.random(3000, 5000));
- }
- }
- }
- } else {
- stairs = getGameObjects().closest(s -> s.getName().contains("Staircase"));
- }if (stairs != null && stairs.exists()) {
- if (stairs.interactForceRight("Climb-down")) {
- if (getLocalPlayer().getZ() == 2)
- sleepUntil(() -> getLocalPlayer().getZ() != 2, Calculations.random(3000, 5000));
- }
- }
- }
- }
- public void getToRoom() {
- if (getInventory().count(8851) < 100) {
- getTabs().logout();
- sleep(3000);
- stopScript();
- }
- if (getLocalPlayer().getZ() == 0) {
- stairs = getGameObjects().closest(s -> s != null && s.getName().contains("Staircase"));
- if (getLocalPlayer().distance(groundFloorStairs) > 3) {
- getWalking().walk(groundFloorStairs);
- sleepUntil(() -> getLocalPlayer().distance(groundFloorStairs) < 3, Calculations.random(5000, 10000));
- } else if (getGameObjects().closest(s -> s != null && s.getName().contains("Staircase")).interactForceRight("Climb-up")) {
- if (getLocalPlayer().getZ() == 0)
- sleepUntil(() -> getLocalPlayer().getZ() != 0, Calculations.random(3000, 5000));
- }
- } else if (getLocalPlayer().getZ() == 1) {
- stairs = getGameObjects().closest(s -> s.getName().contains("Staircase"));
- if (stairs != null && stairs.exists()) {
- if (stairs.interactForceRight("Climb-up")) {
- if (getLocalPlayer().getZ() == 1)
- sleepUntil(() -> getLocalPlayer().getZ() != 1, Calculations.random(3000, 5000));
- }
- }
- } else if (getLocalPlayer().getZ() == 2 && !isInRoom()) {
- if (getCamera().rotateToPitch(Calculations.random(300, 383)) && getCamera().rotateToYaw(Calculations.random(1335, 1700))) {
- doors = getGameObjects().closest(d -> d.getName().contains("Door"));
- if (doors != null && doors.exists()) {
- if (!isInRoom() && doors.interactForceRight("Open")) {
- sleep(Calculations.random(3000, 5000));
- getDialogues().clickContinue();
- sleep(2000, 2200);
- getDialogues().clickContinue();
- sleep(2000, 2200);
- if (!isInRoom() && doors.interactForceRight("Open")) {
- if (!isInRoom()) sleepUntil(() -> isInRoom(), Calculations.random(3000, 5000));
- }
- }
- }
- }
- }
- }
- /** working here */
- public void getToCellar() {
- if (!smallCellarArea.contains(getLocalPlayer())) {
- // if (groundFloorPolygon.contains(getLocalPlayer().getX(), getLocalPlayer().getY())) {
- ladder = getGameObjects().closest(l -> l.getID() == 10042);
- if (getLocalPlayer().distance(ladder) > 3) {
- log("Ladder>3");
- getWalking().walk(ladder);
- sleepUntil(() -> !getLocalPlayer().isMoving() || getLocalPlayer().distance(ladder) < 3, Calculations.random(15000, 20000));
- } else if (ladder.interact("Climb-down")) {
- sleepUntil(() -> smallCellarArea.contains(getLocalPlayer()), Calculations.random(3000, 5000));
- }
- // }
- } else if (smallCellarArea.contains(getLocalPlayer())){
- log("Area is good!");
- doors = getGameObjects().closest(d -> d.getName().contains("Door"));
- if (doors != null && doors.exists()) {
- if (!isInCellarRoom() && doors.interactForceRight("Open")) {
- sleep(Calculations.random(3000, 5000));
- if (getDialogues().clickContinue() && !isInCellarRoom()) {
- sleep(2000, 2200);
- if (getDialogues().clickContinue()) {
- sleep(2000, 2200);
- if (!isInCellarRoom() && doors.interactForceRight("Open")) {
- if (!isInCellarRoom()) sleepUntil(() -> isInCellarRoom(), Calculations.random(3000, 5000));
- }
- }
- }
- }
- }
- } else if (getLocalPlayer().getZ() == 1) {
- stairs = getGameObjects().closest(s -> s.getName().contains("Staircase"));
- if (stairs != null && stairs.exists()) {
- if (stairs.interactForceRight("Climb-down")) {
- if (getLocalPlayer().getZ() == 1)
- sleepUntil(() -> getLocalPlayer().getZ() != 1, Calculations.random(3000, 5000));
- }
- }
- } else if (getLocalPlayer().getZ() == 2) {
- if (isInRoom()) {
- doorArea = new Tile(2847, 3541, 2);
- if (getCamera().rotateToPitch(Calculations.random(300, 383)) && getCamera().rotateToYaw(Calculations.random(250, 800))) {
- if (getLocalPlayer().distance(doorArea) > 8) {
- if (getWalking().walk(doorArea)) {
- sleepUntil(() -> getLocalPlayer().isMoving() || getLocalPlayer().distance(getClient().getDestination()) < (Calculations.random(3, 8))
- , Calculations.random(10000, 15000));
- }
- } else doors = getGameObjects().closest(d -> d.getName().contains("Door"));
- if (doors != null && doors.exists()) {
- if (doors.interactForceRight("Open")) {
- if (isInRoom()) sleepUntil(() -> !isInRoom(), Calculations.random(3000, 5000));
- }
- }
- }
- } else {
- stairs = getGameObjects().closest(s -> s.getName().contains("Staircase"));
- if (stairs != null && stairs.exists()) {
- if (stairs.interactForceRight("Climb-down")) {
- if (getLocalPlayer().getZ() == 2)
- sleepUntil(() -> getLocalPlayer().getZ() != 2, Calculations.random(3000, 5000));
- }
- }
- }
- }
- }
- public void bankFromCellar(){
- ladder = getGameObjects().closest(l->l.getID() == 9742);
- if(isInCellarRoom() || smallCellarArea.contains(getLocalPlayer())){
- if(ladder !=null && ladder.exists()){
- getWalking().walk(ladder);
- sleepUntil(() -> getLocalPlayer().distance(ladder) <5, Calculations.random(2000, 3000));
- if(ladder.interact("Climb-up")){
- sleepUntil(()-> !smallCellarArea.contains(getLocalPlayer()), Calculations.random(1500, 2000));
- if(getLocalPlayer().distance(bankTile) >5){
- getWalking().walk(bankTile);
- sleepUntil(() -> getLocalPlayer().distance(bankTile) <5, Calculations.random(1000, 3000));
- }
- }
- }
- }
- else if(getLocalPlayer().distance(bankTile) >5){
- getWalking().walk(bankTile);
- sleepUntil(() -> getLocalPlayer().distance(bankTile) <5, Calculations.random(1000, 3000));
- }
- }
- public void setAutoRetaliate(boolean option) {
- openTabIfClosed(Tab.COMBAT);
- if ((getPlayerSettings().getConfig(172) ==1) == option) {
- autoRetal = getWidgets().getWidget(593).getChild(28);
- sleepUntil(() -> getPlayerSettings().getConfig(172) ==0, Calculations.random(1000, 2000));
- }
- }
- public void useDefenderOnKamfreena() {
- if (isInRoom()) {
- doors = getGameObjects().closest(d -> d.getName().contains("Door"));
- doorArea = new Tile(2847, 3540);
- if(getLocalPlayer().distance(doorArea) > 8) {
- if (getWalking().walk(doorArea)) {
- sleepUntil(() -> getLocalPlayer().isMoving() || getLocalPlayer().distance(getClient().getDestination()) < (Calculations.random(3, 8))
- , Calculations.random(10000, 15000));
- }
- } else if (doors != null && doors.exists()) {
- if (doors.interactForceRight("Open")) {
- if (isInRoom()) sleepUntil(() -> !isInRoom(), Calculations.random(3000, 5000));
- }
- }
- } else if (!isInRoom()) {
- kamfreena = getNpcs().closest(k -> k.getName().contains("Kamfreena"));
- if (kamfreena != null && kamfreena.exists()) {
- log("kamfreena ok");
- if(getInventory().get(bestDefender()).interact("Use")) {
- log("used defender");
- if (kamfreena.interact()) {
- sleep(2000, 2200);
- getDialogues().clickContinue();
- sleep(3000, 3300);
- getDialogues().clickContinue();
- sleep(2000, 2200);
- needsToShowDefender = false;
- }
- }
- } else {
- getTabs().logout();
- stopScript();
- }
- }
- }
- public void bank() {
- if(getBank().open()){
- log("Opened bank!");
- if (getBank().depositAllExcept(bestDefender(), Token)) {
- if (getBank().withdraw(selectedFoodName, 28)) {
- sleep(Calculations.random(1000, 2000));
- getBank().close();
- sleepUntil(() -> !getBank().isOpen(), Calculations.random(800, 1000));
- } else {
- getTabs().logout();
- sleep(5000);
- stopScript();
- }
- }
- }
- }
- public boolean inCombat() {
- try {
- if (getLocalPlayer().isInCombat())
- return true;
- } catch (NullPointerException e) {
- }
- return false;
- }
- public boolean onDragonDefenders(){
- int defenderID = getInventory().get(bestDefender()).getID();
- return (defenderID == defenderIDs[1] || defenderID == defenderIDs[0]);
- }
- public boolean isInCellarRoom(){
- return (dragonDefenderAreaPolygon.contains(getLocalPlayer().getX(), getLocalPlayer().getY()));
- }
- @Override
- public void onExit() {
- super.onExit();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement