Advertisement
Guest User

Untitled

a guest
Nov 29th, 2015
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 29.10 KB | None | 0 0
  1. package WarriorsguildScripts;
  2.  
  3. import org.dreambot.api.methods.Calculations;
  4. import org.dreambot.api.methods.map.Area;
  5. import org.dreambot.api.methods.map.Tile;
  6. import org.dreambot.api.methods.skills.Skill;
  7. import org.dreambot.api.methods.tabs.Tab;
  8. import org.dreambot.api.script.AbstractScript;
  9. import org.dreambot.api.script.Category;
  10. import org.dreambot.api.script.ScriptManifest;
  11. import org.dreambot.api.script.listener.PaintListener;
  12. import org.dreambot.api.wrappers.interactive.GameObject;
  13. import org.dreambot.api.wrappers.interactive.NPC;
  14. import org.dreambot.api.wrappers.items.GroundItem;
  15. import org.dreambot.api.wrappers.items.Item;
  16. import org.dreambot.api.wrappers.widgets.WidgetChild;
  17.  
  18. import java.awt.*;
  19. import java.awt.event.MouseEvent;
  20. import java.awt.event.MouseListener;
  21. /** WORK ON POLYGONS */
  22. @ScriptManifest(author = "Infallible", name = "iDefenderer", category = Category.MINIGAME, version = 1)
  23. public class wgDefenderer extends AbstractScript implements PaintListener, MouseListener{
  24.  
  25.     public int[] defenderAreaX = {2847, 2848, 2849, 2849, 2877, 2877, 2837, 2837, 2846};
  26.     public int[] defenderAreaY = {3538, 3537, 3536, 3533, 3533, 3557, 3557, 3543, 3543};
  27.     public Polygon defenderAreaPolygon = new Polygon(defenderAreaX, defenderAreaY, defenderAreaX.length);
  28.     public int[] dragonDefenderAreaX = {2912, 2940, 2940, 2905, 2905, 2912};
  29.     public int[] dragonDefenderAreaY = {9973, 9973, 9957, 9957, 9965, 9965};
  30.     public Polygon dragonDefenderAreaPolygon = new Polygon(dragonDefenderAreaX, dragonDefenderAreaY, dragonDefenderAreaX.length);
  31.     public int[] groundFloorAreaX = {2838, 2875, 2875, 2859, 2849, 2848, 2838, 2830, 2830};
  32.     public int[] groundFloorAreaY = {3555, 3555, 3537, 3534, 3534, 3537, 3537, 3537, 3550};
  33.     public Polygon groundFloorPolygon = new Polygon(groundFloorAreaX, groundFloorAreaY, groundFloorAreaX.length);
  34.     public Tile smallCellarAreaTile1 = new Tile(2905, 9973, 0);
  35.     public Tile smallCellarAreaTile2 = new Tile(2911, 9966, 0);
  36.     public Area smallCellarArea = new Area(smallCellarAreaTile1, smallCellarAreaTile2);
  37.     public NPC cyclops;
  38.     public String selectedFoodName;
  39.     public final int[] defenderIDs = {12954, 8850, 8849, 8848, 8847, 8846, 8845, 8844};
  40.     public int Token = 8851;
  41.     public Tile doorArea;
  42.     public GameObject doors;
  43.     public Tile groundFloorStairs = new Tile(2841, 3538, 0);
  44.     public NPC kamfreena;
  45.     public WidgetChild autoRetal;
  46.     public Item food;
  47.     public boolean isInBounds;
  48.     public Rectangle sharkRectangle = new Rectangle(3, 391, 114, 45);
  49.     public Rectangle lobsterRectangle = new Rectangle(2, 341, 114, 45);
  50.     public Tile bankTile = new Tile (2843, 3543);
  51.     public boolean below76 = false;
  52.     public boolean below106 = false;
  53.     public java.util.List<GroundItem> allitems;
  54.     public GroundItem groundDefender;
  55.     public boolean needsToShowDefender = false;
  56.     public int defenderCount = 0;
  57.     public GameObject stairs;
  58.     public GameObject ladder;
  59.     public NPC Lorelai;
  60.     public int bestDefID;
  61.     public enum State {
  62.         EATING,
  63.         LOOT_DEFENDER,
  64.         SHOWING_DEFENDER_TO_KAMFREENA,
  65.         IN_COMBAT,
  66.         ATTACKING,
  67.         GET_TO_ROOM,
  68.         BANKING,
  69.         BANK_FROM_TOP,
  70.         GET_TO_CELLAR,
  71.         BANK_FROM_CELLAR,
  72.         CHECK
  73.  
  74.     }
  75.  
  76.     @Override
  77.     public void mouseClicked(MouseEvent e) {
  78.         if (lobsterRectangle.contains(e.getPoint())) {
  79.             selectedFoodName = "Lobster";
  80.             log("Lobster selected as food");
  81.         }
  82.         if (sharkRectangle.contains(e.getPoint())) {
  83.             selectedFoodName = "Shark";
  84.             log("Shark selected as food");
  85.         }
  86.     }
  87.     @Override
  88.     public void mousePressed(MouseEvent e) {
  89.     }
  90.     @Override
  91.     public void mouseReleased(MouseEvent e) {
  92.     }
  93.     @Override
  94.     public void mouseEntered(MouseEvent e) {
  95.     }
  96.     @Override
  97.     public void mouseExited(MouseEvent e) {
  98.     }
  99.  
  100.     /**
  101.      * gets the current state for onLoop
  102.      */
  103.     private State getState() {
  104.         if(!onDragonDefenders()) {
  105.             if (hasFood()) {
  106.                 if (needsToEat())
  107.                     return State.EATING;
  108.                 else if (nearbyDefender() && isInRoom())
  109.                     return State.LOOT_DEFENDER;
  110.                 else if (getLocalPlayer().getZ() == 2
  111.                         && needsToShowDefender)
  112.                     return State.SHOWING_DEFENDER_TO_KAMFREENA;
  113.                 else if (inCombat() && !needsToEat())
  114.                     return State.IN_COMBAT;
  115.                 else if (isInRoom() && !needsToEat() && !inCombat())
  116.                     return State.ATTACKING;
  117.                 else if (!isInRoom() && hasFood())
  118.                     return State.GET_TO_ROOM;
  119.             } else if ((getLocalPlayer().distance(bankTile) < 3))
  120.                 return State.BANKING;
  121.             else return State.BANK_FROM_TOP;
  122.         }
  123.         else if(onDragonDefenders()){
  124.             if(hasFood()) {
  125.                 if (needsToEat())
  126.                     return State.EATING;
  127.                 else if (!isInCellarRoom())
  128.                     return State.GET_TO_CELLAR;
  129.                 else if (nearbyDefender() && isInCellarRoom())
  130.                     return State.LOOT_DEFENDER;
  131.                 else if (isInCellarRoom() && !needsToEat() && !inCombat())
  132.                     return State.ATTACKING;
  133.                 else if (inCombat() && !needsToEat())
  134.                     return State.IN_COMBAT;
  135.             } else if((getLocalPlayer().distance(bankTile) < 3))
  136.                 return State.BANKING;
  137.             else return State.BANK_FROM_CELLAR;
  138.         }
  139.         return State.CHECK;
  140.     }
  141.  
  142.     @Override
  143.     public int onLoop() {
  144.         switch (getState()) {
  145.             case LOOT_DEFENDER:
  146.                 lootDefender();
  147.                 break;
  148.             case EATING:
  149.                 eat();
  150.                 break;
  151.             case ATTACKING:
  152.                 attack();
  153.                 break;
  154.             case BANK_FROM_TOP:
  155.                 getToBank();
  156.                 break;
  157.             case GET_TO_ROOM:
  158.                 getToRoom();
  159.                 break;
  160.             case SHOWING_DEFENDER_TO_KAMFREENA:
  161.                 useDefenderOnKamfreena();
  162.                 break;
  163.             case BANKING:
  164.                 bank();
  165.                 break;
  166.             case IN_COMBAT:
  167.                 inCombat();
  168.                 break;
  169.             case GET_TO_CELLAR:
  170.                 getToCellar();
  171.             case BANK_FROM_CELLAR:
  172.                 bankFromCellar();
  173.         }
  174.         return 200;
  175.     }
  176.  
  177.     /**
  178.      * Returns string for paint
  179.      */
  180.     public String stateParser() {
  181.         switch (getState()) {
  182.             case EATING:
  183.                 return "Eating";
  184.             case LOOT_DEFENDER:
  185.                 return "Looting Defender";
  186. //            case LOOTING:
  187. //                break;
  188.             case SHOWING_DEFENDER_TO_KAMFREENA:
  189.                 return "Showing Defender";
  190.             case IN_COMBAT:
  191.                 return "In Combat";
  192.             case ATTACKING:
  193.                 return "Attacking";
  194.             case GET_TO_ROOM:
  195.                 return "Running to Cyclops Room";
  196.             case BANKING:
  197.                 return "Banking";
  198.             case BANK_FROM_TOP:
  199.                 return "Running to Bank";
  200.             case GET_TO_CELLAR:
  201.                 return "Running to Cellar";
  202.             case BANK_FROM_CELLAR:
  203.                 return "Running to Bank";
  204.             case CHECK:
  205.                 return "check";
  206.         }
  207.         return "NOSTATE";
  208.     }
  209.  
  210.     /** What the script does at start */
  211.     @Override
  212.     public void onStart() {
  213.         super.onStart();
  214.         below76 = getLocalPlayer().getLevel() < 76;
  215.         below106 = getLocalPlayer().getLevel() < 106;
  216.         setAutoRetaliate(true);
  217.         getSkillTracker().start(Skill.HITPOINTS);
  218.         Item defender = getInventory().get(bestDefender());
  219.         if (isInRoom() || bestDefender() == defenderIDs[0] || defender  == null) needsToShowDefender = false;
  220.         selectedFoodName = "nothing";
  221.         sleepUntil(() -> selectedFoodName != "nothing", Calculations.random(10000, 20000));
  222.         if(getInventory().contains(d->d.getName().contains("defender"))); needsToShowDefender = true;
  223.     }
  224.     @Override
  225.     public void onPaint(Graphics g) {
  226.         isInBounds = lobsterRectangle.contains(getClient().getMousePosition());
  227.         if(isInBounds) {g.setColor(isInBounds ? Color.green : Color.red);
  228.             g.fillRect(2, 341, 114, 45);
  229.         }
  230.         isInBounds = sharkRectangle.contains(getClient().getMousePosition());
  231.         if(isInBounds) {g.setColor(isInBounds ? Color.green : Color.red);
  232.             g.fillRect(3, 391, 114, 45);
  233.         }
  234.         g.setColor(new Color(48, 48, 48, 180));
  235.         g.fillRect(2, 341, 114, 45);
  236.         g.fillRect(3, 391, 114, 45);
  237.         g.setColor(Color.white);
  238.         g.drawString("State: " + stateParser(), 370, 360);
  239.         g.drawString("Defender count: " + defenderCount, 370, 375);
  240.         g.drawString("Lobster", 32, 366);
  241.         g.drawString("Shark", 32, 416);
  242.         g.drawString("Levels gained: " + getSkillTracker().getGainedLevels(Skill.HITPOINTS), 370, 390);
  243.         g.drawString("Hitpoints Exp/hr: " + getSkillTracker().getGainedExperiencePerHour(Skill.HITPOINTS), 370, 405);
  244.     }
  245.  
  246.     /** Methods located here */
  247.     public void attack() {
  248.         if(!onDragonDefenders()) {
  249.             if (isInRoom() && !getLocalPlayer().isInCombat()) {
  250.                 cyclops = getNpcs().closest(c -> c.getName().contains("Cyclops") && !c.isAnimating() && c.getHealth() != 0 && !c.isInCombat());
  251.                 if (!cyclops.isOnScreen() && cyclopsIsNotNull()) {
  252.                     if (getLocalPlayer().distance(cyclops) > 5) {
  253.                         getCamera().rotateToEntity(cyclops);
  254.                         getWalking().walk(cyclops);
  255.                         sleep(Calculations.random(300, 1000));
  256.                     }
  257.                 } else if (below76) {
  258.                     if (cyclopsIsNotNull()) {
  259.                         if (cyclops.interactForceRight("Attack")) {
  260.                             sleepUntil(() -> getLocalPlayer().isInCombat(), 5000);
  261.                             if (cyclops.isInteracting(getLocalPlayer())) {
  262.                                 cyclops = getNpcs().closest(c -> c.getName().contains("Cyclops") && !c.isAnimating() && c.getHealth() != 0 && !c.isInCombat());
  263.                                 getCamera().rotateToEntity(cyclops);
  264.                                 sleepUntil(() -> !getLocalPlayer().isInCombat() || getLocalPlayer().getHealth() < 50 || !getLocalPlayer().isAnimating() || !getLocalPlayer().isHealthBarVisible(), 20000);
  265.                             }
  266.                         }
  267.                     }
  268.                 } else if (cyclopsIsNotNull()) {
  269.                     if (cyclops.interact("Attack")) {
  270.                         sleepUntil(() -> getLocalPlayer().isInCombat(), 5000);
  271.                         if (cyclops.isInteracting(getLocalPlayer())) {
  272.                             cyclops = getNpcs().closest(c -> c.getName().contains("Cyclops") && !c.isAnimating() && c.getHealth() != 0 && !c.isInCombat());
  273.                             getCamera().rotateToEntity(cyclops);
  274.                             sleepUntil(() -> !getLocalPlayer().isInCombat() || getLocalPlayer().getHealth() < 50 || !getLocalPlayer().isInteracting(cyclops) || !getLocalPlayer().isAnimating() || !getLocalPlayer().isHealthBarVisible(), 20000);
  275.                         }
  276.                     }
  277.                 }
  278.             }
  279.         }
  280.         else if (onDragonDefenders() && isInCellarRoom() && !getLocalPlayer().isInCombat()) {
  281.             log("Polygon is good!");
  282.             cyclops = getNpcs().closest(c -> c.getName().contains("Cyclops") && !c.isAnimating() && c.getHealth() != 0 && !c.isInCombat());
  283.             if (!cyclops.isOnScreen() && cyclopsIsNotNull()) {
  284.                 if (getLocalPlayer().distance(cyclops) > 5) {
  285.                     getCamera().rotateToEntity(cyclops);
  286.                     getWalking().walk(cyclops);
  287.                     sleep(Calculations.random(300, 1000));
  288.                 }
  289.             } else if (below106) {
  290.                 if (cyclopsIsNotNull()) {
  291.                     if (cyclops.interactForceRight("Attack")) {
  292.                         sleepUntil(() -> getLocalPlayer().isInCombat(), 5000);
  293.                         if (cyclops.isInteracting(getLocalPlayer())) {
  294.                             cyclops = getNpcs().closest(c -> c.getName().contains("Cyclops") && !c.isAnimating() && c.getHealth() != 0 && !c.isInCombat());
  295.                             getCamera().rotateToEntity(cyclops);
  296.                             sleepUntil(() -> !getLocalPlayer().isInCombat() || getLocalPlayer().getHealth() < 50 || !getLocalPlayer().isAnimating() || !getLocalPlayer().isHealthBarVisible(), 20000);
  297.                         }
  298.                     }
  299.                 }
  300.             } else if (cyclopsIsNotNull()) {
  301.                 if (cyclops.interact("Attack")) {
  302.                     sleepUntil(() -> getLocalPlayer().isInCombat(), 5000);
  303.                     if (cyclops.isInteracting(getLocalPlayer())) {
  304.                         cyclops = getNpcs().closest(c -> c.getName().contains("Cyclops") && !c.isAnimating() && c.getHealth() != 0 && !c.isInCombat());
  305.                         getCamera().rotateToEntity(cyclops);
  306.                         sleepUntil(() -> !getLocalPlayer().isInCombat() || getLocalPlayer().getHealth() < 50 || !getLocalPlayer().isInteracting(cyclops) || !getLocalPlayer().isAnimating() || !getLocalPlayer().isHealthBarVisible(), 20000);
  307.                     }
  308.                 }
  309.             }
  310.         }
  311.     }
  312.     public boolean isInRoom() {return (defenderAreaPolygon.contains(getLocalPlayer().getX(), getLocalPlayer().getY()) && getLocalPlayer().getZ() ==2);}
  313.     public int stopScript() {
  314.         return -1;
  315.     }
  316.     public boolean cyclopsIsNotNull() {return (cyclops != null && cyclops.getHealth() != 0 && !cyclops.isAnimating());}
  317.     public boolean needsToEat() {
  318.         return (getCombat().getHealthPercent() <=Calculations.random(40, 70));
  319.     }
  320.     public boolean hasFood() {
  321.         return (getInventory().contains(f -> f.getName().contains(selectedFoodName)));
  322.     }
  323.     public void eat() {
  324.         if (needsToEat() || getInventory().isFull()) {
  325.             openTabIfClosed(Tab.INVENTORY);
  326.             food = getInventory().getRandom(selectedFoodName);
  327.             if (food != null) {
  328.                 if (food.interact("Eat")) sleep(Calculations.random(300, 700));
  329.             }
  330.         }
  331.     }
  332.     public int bestDefender() {
  333.         bestDefID = 0;
  334.         openTabIfClosed(Tab.INVENTORY);
  335.         for (int i : defenderIDs) {
  336.             if (getInventory().contains(i)){
  337.                 return i;
  338.             }
  339.         }
  340.         return 0;
  341.     }
  342.     public void openTabIfClosed(Tab tab) {
  343.         long t = System.currentTimeMillis();
  344.         if (!getTabs().isOpen(tab) && (System.currentTimeMillis() - t) <= 5000) {
  345.             getTabs().open(tab);
  346.             sleep(Calculations.random(300, 800));
  347.         }
  348.     }
  349.     public boolean nearbyDefender() {
  350.         allitems = getGroundItems().all(g -> g.getName().contains("defender"));
  351.         for (GroundItem i : allitems) {
  352.             if (i != null && i.exists()) {
  353.                 return true;
  354.             }
  355.         }
  356.         return false;
  357.     }
  358.     public void lootDefender() {
  359.         if (nearbyDefender()) {
  360.             openTabIfClosed(Tab.INVENTORY);
  361.             groundDefender = getGroundItems().closest(d ->d.getName().contains("defender"));
  362.             if (getInventory().isFull()) {
  363.                 eat();
  364.             }
  365.             if (nearbyDefender()) {
  366.                 if (!groundDefender.isOnScreen()) {
  367.                     if (getLocalPlayer().distance(groundDefender) > 3) {
  368.                         getWalking().walk(groundDefender);
  369.                         sleep(Calculations.random(500, 1000));
  370.                     }
  371.                 }
  372.                 int defenderID = groundDefender.getID();
  373.                 if (groundDefender.isOnScreen()) {
  374.                     if (groundDefender.interactForceRight("Take")) {
  375.                         defenderCount++;
  376.                         if (defenderID != defenderIDs[0]) {
  377.                             if(!onDragonDefenders()) {
  378.                                 needsToShowDefender = true;
  379.                                 sleep(500, 600);
  380.                             }
  381.                         }
  382.                     }
  383.                 }
  384.             }
  385.         }
  386.     }
  387.     public void getToBank() {
  388.         if (getLocalPlayer().getZ() == 0) {
  389.             if ((getLocalPlayer().distance(bankTile) > 3)) {
  390.                 log("Distance >3");
  391.                 if (getWalking().walk(bankTile)) {
  392.                     log("Walking to bank");
  393.                     sleepUntil(() -> !getLocalPlayer().isMoving()
  394.                                     || getLocalPlayer().distance(getClient().getDestination()) < 5
  395.                             , Calculations.random(1500, 3500));
  396.                 }
  397.             }
  398.         }else if (getLocalPlayer().getZ() == 1) {
  399.             stairs = getGameObjects().closest(s -> s.getName().contains("Staircase"));
  400.             if (stairs != null && stairs.exists()) {
  401.                 if (stairs.interactForceRight("Climb-down")) {
  402.                     if (getLocalPlayer().getZ() == 1)
  403.                         sleepUntil(() -> getLocalPlayer().getZ() != 1, Calculations.random(3000, 5000));
  404.                 }
  405.             }
  406.         } else if (getLocalPlayer().getZ() == 2) {
  407.             if (isInRoom()) {
  408.                 doorArea = new Tile(2847, 3541, 2);
  409.                 if (getCamera().rotateToPitch(Calculations.random(300, 383)) && getCamera().rotateToYaw(Calculations.random(250, 800))) {
  410.                     if(getLocalPlayer().distance(doorArea) > 8) {
  411.                         if (getWalking().walk(doorArea)) {
  412.                             sleepUntil(() -> getLocalPlayer().isMoving() || getLocalPlayer().distance(getClient().getDestination()) < (Calculations.random(3, 8))
  413.                                     , Calculations.random(10000, 15000));
  414.                         }
  415.                     }else doors = getGameObjects().closest(d -> d.getName().contains("Door"));
  416.                     if (doors != null && doors.exists()) {
  417.                         if (doors.interactForceRight("Open")) {
  418.                             if (isInRoom()) sleepUntil(() -> !isInRoom(), Calculations.random(3000, 5000));
  419.                         }
  420.                     }
  421.                 }
  422.             } else {
  423.                 stairs = getGameObjects().closest(s -> s.getName().contains("Staircase"));
  424.             }if (stairs != null && stairs.exists()) {
  425.                 if (stairs.interactForceRight("Climb-down")) {
  426.                     if (getLocalPlayer().getZ() == 2)
  427.                         sleepUntil(() -> getLocalPlayer().getZ() != 2, Calculations.random(3000, 5000));
  428.                 }
  429.             }
  430.         }
  431.     }
  432.     public void getToRoom() {
  433.         if (getInventory().count(8851) < 100) {
  434.             getTabs().logout();
  435.             sleep(3000);
  436.             stopScript();
  437.         }
  438.         if (getLocalPlayer().getZ() == 0) {
  439.             stairs = getGameObjects().closest(s -> s != null && s.getName().contains("Staircase"));
  440.             if (getLocalPlayer().distance(groundFloorStairs) > 3) {
  441.                 getWalking().walk(groundFloorStairs);
  442.                 sleepUntil(() -> getLocalPlayer().distance(groundFloorStairs) < 3, Calculations.random(5000, 10000));
  443.             } else if (getGameObjects().closest(s -> s != null && s.getName().contains("Staircase")).interactForceRight("Climb-up")) {
  444.  
  445.                 if (getLocalPlayer().getZ() == 0)
  446.                     sleepUntil(() -> getLocalPlayer().getZ() != 0, Calculations.random(3000, 5000));
  447.             }
  448.         } else if (getLocalPlayer().getZ() == 1) {
  449.             stairs = getGameObjects().closest(s -> s.getName().contains("Staircase"));
  450.             if (stairs != null && stairs.exists()) {
  451.                 if (stairs.interactForceRight("Climb-up")) {
  452.                     if (getLocalPlayer().getZ() == 1)
  453.                         sleepUntil(() -> getLocalPlayer().getZ() != 1, Calculations.random(3000, 5000));
  454.                 }
  455.             }
  456.         } else if (getLocalPlayer().getZ() == 2 && !isInRoom()) {
  457.             if (getCamera().rotateToPitch(Calculations.random(300, 383)) && getCamera().rotateToYaw(Calculations.random(1335, 1700))) {
  458.                 doors = getGameObjects().closest(d -> d.getName().contains("Door"));
  459.                 if (doors != null && doors.exists()) {
  460.                     if (!isInRoom() && doors.interactForceRight("Open")) {
  461.                         sleep(Calculations.random(3000, 5000));
  462.                         getDialogues().clickContinue();
  463.                         sleep(2000, 2200);
  464.                         getDialogues().clickContinue();
  465.                         sleep(2000, 2200);
  466.                         if (!isInRoom() && doors.interactForceRight("Open")) {
  467.                             if (!isInRoom()) sleepUntil(() -> isInRoom(), Calculations.random(3000, 5000));
  468.                         }
  469.                     }
  470.                 }
  471.             }
  472.         }
  473.     }
  474.     /** working here */
  475.     public void getToCellar() {
  476.         if (!smallCellarArea.contains(getLocalPlayer())) {
  477. //            if (groundFloorPolygon.contains(getLocalPlayer().getX(), getLocalPlayer().getY())) {
  478.                 ladder = getGameObjects().closest(l -> l.getID() == 10042);
  479.                 if (getLocalPlayer().distance(ladder) > 3) {
  480.                     log("Ladder>3");
  481.                     getWalking().walk(ladder);
  482.                     sleepUntil(() -> !getLocalPlayer().isMoving() || getLocalPlayer().distance(ladder) < 3, Calculations.random(15000, 20000));
  483.                 } else if (ladder.interact("Climb-down")) {
  484.                         sleepUntil(() -> smallCellarArea.contains(getLocalPlayer()), Calculations.random(3000, 5000));
  485.                     }
  486. //            }
  487.         } else if (smallCellarArea.contains(getLocalPlayer())){
  488.             log("Area is good!");
  489.             doors = getGameObjects().closest(d -> d.getName().contains("Door"));
  490.             if (doors != null && doors.exists()) {
  491.                 if (!isInCellarRoom() && doors.interactForceRight("Open")) {
  492.                     sleep(Calculations.random(3000, 5000));
  493.                     if (getDialogues().clickContinue() && !isInCellarRoom()) {
  494.                         sleep(2000, 2200);
  495.                         if (getDialogues().clickContinue()) {
  496.                             sleep(2000, 2200);
  497.                             if (!isInCellarRoom() && doors.interactForceRight("Open")) {
  498.                                 if (!isInCellarRoom()) sleepUntil(() -> isInCellarRoom(), Calculations.random(3000, 5000));
  499.                             }
  500.                         }
  501.                     }
  502.                 }
  503.             }
  504.         } else if (getLocalPlayer().getZ() == 1) {
  505.             stairs = getGameObjects().closest(s -> s.getName().contains("Staircase"));
  506.             if (stairs != null && stairs.exists()) {
  507.                 if (stairs.interactForceRight("Climb-down")) {
  508.                     if (getLocalPlayer().getZ() == 1)
  509.                         sleepUntil(() -> getLocalPlayer().getZ() != 1, Calculations.random(3000, 5000));
  510.                 }
  511.             }
  512.         } else if (getLocalPlayer().getZ() == 2) {
  513.             if (isInRoom()) {
  514.                 doorArea = new Tile(2847, 3541, 2);
  515.                 if (getCamera().rotateToPitch(Calculations.random(300, 383)) && getCamera().rotateToYaw(Calculations.random(250, 800))) {
  516.                     if (getLocalPlayer().distance(doorArea) > 8) {
  517.                         if (getWalking().walk(doorArea)) {
  518.                             sleepUntil(() -> getLocalPlayer().isMoving() || getLocalPlayer().distance(getClient().getDestination()) < (Calculations.random(3, 8))
  519.                                     , Calculations.random(10000, 15000));
  520.                         }
  521.                     } else doors = getGameObjects().closest(d -> d.getName().contains("Door"));
  522.                     if (doors != null && doors.exists()) {
  523.                         if (doors.interactForceRight("Open")) {
  524.                             if (isInRoom()) sleepUntil(() -> !isInRoom(), Calculations.random(3000, 5000));
  525.                         }
  526.                     }
  527.                 }
  528.             } else {
  529.                 stairs = getGameObjects().closest(s -> s.getName().contains("Staircase"));
  530.                 if (stairs != null && stairs.exists()) {
  531.                     if (stairs.interactForceRight("Climb-down")) {
  532.                         if (getLocalPlayer().getZ() == 2)
  533.                             sleepUntil(() -> getLocalPlayer().getZ() != 2, Calculations.random(3000, 5000));
  534.                     }
  535.                 }
  536.             }
  537.         }
  538.     }
  539.     public void bankFromCellar(){
  540.         ladder = getGameObjects().closest(l->l.getID() == 9742);
  541.         if(isInCellarRoom() || smallCellarArea.contains(getLocalPlayer())){
  542.             if(ladder !=null && ladder.exists()){
  543.                 getWalking().walk(ladder);
  544.                 sleepUntil(() -> getLocalPlayer().distance(ladder) <5, Calculations.random(2000, 3000));
  545.                 if(ladder.interact("Climb-up")){
  546.                     sleepUntil(()-> !smallCellarArea.contains(getLocalPlayer()), Calculations.random(1500, 2000));
  547.                     if(getLocalPlayer().distance(bankTile) >5){
  548.                         getWalking().walk(bankTile);
  549.                         sleepUntil(() -> getLocalPlayer().distance(bankTile) <5, Calculations.random(1000, 3000));
  550.                     }
  551.                 }
  552.             }
  553.         }
  554.         else if(getLocalPlayer().distance(bankTile) >5){
  555.             getWalking().walk(bankTile);
  556.             sleepUntil(() -> getLocalPlayer().distance(bankTile) <5, Calculations.random(1000, 3000));
  557.         }
  558.     }
  559.     public void setAutoRetaliate(boolean option) {
  560.         openTabIfClosed(Tab.COMBAT);
  561.         if ((getPlayerSettings().getConfig(172) ==1) == option) {
  562.             autoRetal = getWidgets().getWidget(593).getChild(28);
  563.             sleepUntil(() -> getPlayerSettings().getConfig(172) ==0, Calculations.random(1000, 2000));
  564.         }
  565.  
  566.     }
  567.     public void useDefenderOnKamfreena() {
  568.         if (isInRoom()) {
  569.             doors = getGameObjects().closest(d -> d.getName().contains("Door"));
  570.             doorArea = new Tile(2847, 3540);
  571.             if(getLocalPlayer().distance(doorArea) > 8) {
  572.                 if (getWalking().walk(doorArea)) {
  573.                     sleepUntil(() -> getLocalPlayer().isMoving() || getLocalPlayer().distance(getClient().getDestination()) < (Calculations.random(3, 8))
  574.                             , Calculations.random(10000, 15000));
  575.                 }
  576.             } else if (doors != null && doors.exists()) {
  577.                 if (doors.interactForceRight("Open")) {
  578.                     if (isInRoom()) sleepUntil(() -> !isInRoom(), Calculations.random(3000, 5000));
  579.                 }
  580.             }
  581.         } else if (!isInRoom()) {
  582.             kamfreena = getNpcs().closest(k -> k.getName().contains("Kamfreena"));
  583.             if (kamfreena != null && kamfreena.exists()) {
  584.                 log("kamfreena ok");
  585.                 if(getInventory().get(bestDefender()).interact("Use")) {
  586.                     log("used defender");
  587.                     if (kamfreena.interact()) {
  588.                         sleep(2000, 2200);
  589.                         getDialogues().clickContinue();
  590.                         sleep(3000, 3300);
  591.                         getDialogues().clickContinue();
  592.                         sleep(2000, 2200);
  593.                         needsToShowDefender = false;
  594.                     }
  595.                 }
  596.             } else {
  597.                 getTabs().logout();
  598.                 stopScript();
  599.             }
  600.         }
  601.     }
  602.     public void bank() {
  603.         if(getBank().open()){
  604.             log("Opened bank!");
  605.             if (getBank().depositAllExcept(bestDefender(), Token)) {
  606.                 if (getBank().withdraw(selectedFoodName, 28)) {
  607.                     sleep(Calculations.random(1000, 2000));
  608.                     getBank().close();
  609.                     sleepUntil(() -> !getBank().isOpen(), Calculations.random(800, 1000));
  610.                 } else {
  611.                     getTabs().logout();
  612.                     sleep(5000);
  613.                     stopScript();
  614.                 }
  615.             }
  616.         }
  617.     }
  618.     public boolean inCombat() {
  619.         try {
  620.             if (getLocalPlayer().isInCombat())
  621.                 return true;
  622.         } catch (NullPointerException e) {
  623.         }
  624.         return false;
  625.     }
  626.     public boolean onDragonDefenders(){
  627.         int defenderID = getInventory().get(bestDefender()).getID();
  628.         return (defenderID == defenderIDs[1] || defenderID == defenderIDs[0]);
  629.     }
  630.     public boolean isInCellarRoom(){
  631.         return (dragonDefenderAreaPolygon.contains(getLocalPlayer().getX(), getLocalPlayer().getY()));
  632.     }
  633.  
  634.     @Override
  635.     public void onExit() {
  636.         super.onExit();
  637.     }
  638. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement