Advertisement
Guest User

GE Yews

a guest
Mar 14th, 2016
1,952
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 11.37 KB | None | 0 0
  1. import org.dreambot.api.methods.Calculations;
  2. import org.dreambot.api.methods.map.Area;
  3. import org.dreambot.api.methods.map.Tile;
  4. import org.dreambot.api.methods.skills.Skill;
  5. import org.dreambot.api.methods.tabs.Tab;
  6. import org.dreambot.api.script.AbstractScript;
  7. import org.dreambot.api.script.Category;
  8. import org.dreambot.api.script.ScriptManifest;
  9. import org.dreambot.api.script.listener.MessageListener;
  10. import org.dreambot.api.utilities.Timer;
  11. import org.dreambot.api.wrappers.interactive.GameObject;
  12. import org.dreambot.api.wrappers.items.GroundItem;
  13. import org.dreambot.api.wrappers.widgets.message.Message;
  14.  
  15. import java.awt.*;
  16.  
  17. @ScriptManifest(category = Category.WOODCUTTING, name = "GE Yews", author = "Diddy", version = 1.5)
  18. public class Main extends AbstractScript implements MessageListener {
  19.  
  20.     private boolean startScript;
  21.     private boolean newNest;
  22.     private YewsGUI gui;
  23.  
  24.     private int logsgained;
  25.     private int logsanhour;
  26.     private int xnests;
  27.  
  28.     private Area treeArea = new Area(3201, 3506, 3224, 3501, 0);
  29.     private Area startArea = new Area(3201, 3506, 3207, 3501, 0);
  30.  
  31.     Tile t1 = new Tile(3204, 3505, 0);
  32.     Tile t2 = new Tile(3210, 3500, 0);
  33.     Tile t3 = new Tile(3222, 3504, 0);
  34.  
  35.     String Status = " ";
  36.     Timer timer;
  37.     static String status = null;
  38.  
  39.     private GameObject tree;
  40.  
  41.     @Override
  42.     public void onStart() { // making the GUI visable
  43.         gui = new YewsGUI(this);
  44.         gui.setVisible(true);
  45.         sleepUntil(() -> startScript, 60000); // sleeping until logged in
  46.         sleepUntil(() -> getClient().isLoggedIn(),
  47.                 Calculations.random(40000, 60000));
  48.         getSkillTracker().start(Skill.WOODCUTTING); // tracking all woodcutting
  49.                                                     // exp gained
  50.     }
  51.  
  52.     private enum State {
  53.         CHOP, BANK, WAIT,
  54.  
  55.     }
  56.  
  57.     private State getState() { // we are seperating the script into pieces
  58.                                 // making it more convenient
  59.         tree = getGameObjects().closest(
  60.                 gameObject -> gameObject != null
  61.                         && gameObject.getName().equals("Yew")
  62.                         && gameObject.distance() < 17
  63.                         && treeArea.contains(gameObject));
  64.         if (startScript) {
  65.             if (!getInventory().isFull() && !getLocalPlayer().isAnimating()) {
  66.                 return State.CHOP;
  67.             } else if (getInventory().isFull()) {
  68.                 return State.BANK;
  69.             } else if (treeArea.contains(getLocalPlayer())
  70.                     && getLocalPlayer().isAnimating()) {
  71.                 return State.WAIT;
  72.             }
  73.         }
  74.         return null;
  75.     }
  76.  
  77.     @Override
  78.     public int onLoop() {
  79.  
  80.         tree = getGameObjects().closest(
  81.                 gameObject -> gameObject != null
  82.                         && gameObject.getName().equals("Yew")
  83.                         && gameObject.distance() < 17
  84.                         && treeArea.contains(gameObject));
  85.  
  86.         switch (getState()) {
  87.  
  88.         case CHOP:
  89.             if (treeArea.contains(getLocalPlayer())) {
  90.                 if (!newNest) { // checking if there isn't a birdsnest
  91.                     if (tree != null && treeArea.contains(tree)) {
  92.                         if (tree.isOnScreen()) {
  93.                             chop(); // chop the tree
  94.                         } else {
  95.                             move(); // move the camera a bit
  96.                         }
  97.                     } else {
  98.                         hopWorlds(); // hop worlds
  99.                     }
  100.                 } else {
  101.                     GroundItem nest = getGroundItems().closest("Bird nest");
  102.                     if (nest != null && nest.interact()) {
  103.                         sleepUntil(() -> nest == null
  104.                                 || !getLocalPlayer().isMoving(),
  105.                                 Calculations.random(2500, 3800));
  106.                         newNest = false;
  107.                     }
  108.  
  109.                 }
  110.             } else {
  111.                 if (getWalking().walk(startArea.getRandomTile())) {
  112.                     log("walking to yews");
  113.                     sleepUntil(
  114.                             () -> (getClient().getDestination().distance() < Calculations.random(
  115.                                     6, 9))
  116.                                     || getLocalPlayer().isStandingStill(),
  117.                             Calculations.random(4100, 5110));
  118.                 }
  119.             }
  120.             break;
  121.  
  122.         case BANK:
  123.  
  124.             bank();
  125.  
  126.             break;
  127.  
  128.         case WAIT:
  129.             antiBan();
  130.             sleepUntil(() -> !getLocalPlayer().isAnimating(),
  131.                     Calculations.random(7000, 12000));
  132.             break;
  133.  
  134.         }
  135.  
  136.         return Calculations.random(250, 350);
  137.     }
  138.  
  139.     private void move() {
  140.         log("getting new tree.");
  141.         if (tree.distance() < Calculations.random(5, 7)) {
  142.             Status = "Moving camera";
  143.             getCamera().rotateToEntity(tree);
  144.             getCamera().rotateToPitch(Calculations.random(32, 39));
  145.         } else {
  146.             Status = "Walking to stuff";
  147.             if (tree != null) {
  148.                 getWalking().walk(tree);
  149.                 sleepUntil(
  150.                         () -> (getClient().getDestination().distance() < Calculations.random(
  151.                                 4, 6))
  152.                                 || getLocalPlayer().isStandingStill(),
  153.                         Calculations.random(4100, 5110));
  154.             }
  155.  
  156.         }
  157.     }
  158.  
  159.     private int F2PWorld() { // Don't do this pls
  160.         int random = Calculations.random(1, 12);
  161.         // 1|8|16|26|35|81|82|83|84|85|93|94
  162.         int world = 0;
  163.  
  164.         if (random == 1) {
  165.             world = 1;
  166.         } else if (random == 2) {
  167.             world = 8;
  168.         } else if (random == 3) {
  169.             world = 16;
  170.         } else if (random == 4) {
  171.             world = 26;
  172.         } else if (random == 5) {
  173.             world = 35;
  174.         } else if (random == 6) {
  175.             world = 81;
  176.         } else if (random == 7) {
  177.             world = 82;
  178.         } else if (random == 8) {
  179.             world = 83;
  180.         } else if (random == 9) {
  181.             world = 84;
  182.         } else if (random == 10) {
  183.             world = 85;
  184.         } else if (random == 11) {
  185.             world = 93;
  186.         } else if (random == 12) {
  187.             world = 94;
  188.         }
  189.  
  190.         if (world != getClient().getCurrentWorld()) {
  191.             return world;
  192.         } else {
  193.             return F2PWorld();
  194.         }
  195.     }
  196.  
  197.     private int P2PWorld() { // this looks more legit
  198.  
  199.         int world = getWorlds().getRandomWorld(
  200.                 w -> w.isMembers() && w.getID() != (319) && w.getID() != (325)
  201.                         && w.getID() != (337) && w.getID() != (345)
  202.                         && w.getID() != (352) && w.getID() != (357)
  203.                         && w.getID() != (360) && w.getID() != (374)
  204.                         && w.getID() != (373) && w.getID() != (366)
  205.                         && w.getID() != (365) && w.getID() != (361)
  206.                         && w.getID() != (353)
  207.                         && w.getID() != getClient().getCurrentWorld()).getID();
  208.         return world;
  209.     }
  210.  
  211.     private void hopWorlds() {
  212.         if (gui.getway() == "Free2Play") {
  213.             if (getWorldHopper().hopWorld(F2PWorld())) {
  214.                 sleep(Calculations.random(1000, 2500));
  215.                 sleepUntil(() -> getLocalPlayer().exists()
  216.                         && getClient().isLoggedIn(),
  217.                         Calculations.random(5000, 8500));
  218.                 sleepUntil(() -> treeArea.contains(tree),
  219.                         Calculations.random(2000, 3500));
  220.             }
  221.         } else {
  222.             if (getWorldHopper().hopWorld(P2PWorld())) {
  223.                 sleep(Calculations.random(1000, 2500));
  224.                 sleepUntil(() -> getLocalPlayer().exists()
  225.                         && getClient().isLoggedIn(),
  226.                         Calculations.random(5000, 8500));
  227.                 sleepUntil(() -> treeArea.contains(tree),
  228.                         Calculations.random(2000, 3500));
  229.             }
  230.         }
  231.     }
  232.  
  233.     private void chop() {
  234.         sleep(Calculations.random(50, 160));
  235.         if (tree != null && tree.interact("Chop down")) {
  236.             log("Chopping new tree.");
  237.             sleep(Calculations.random(600, 1200));
  238.             sleepUntil(() -> !getLocalPlayer().isMoving(),
  239.                     Calculations.random(3500, 5000));
  240.             sleep(Calculations.random(150, 311));
  241.             if (getLocalPlayer().isAnimating()) {
  242.                 antiBan();
  243.                 sleepUntil(() -> !getLocalPlayer().isAnimating(),
  244.                         Calculations.random(7000, 12000));
  245.             }
  246.         }
  247.     }
  248.  
  249.     private void bank() {
  250.  
  251.         if (!getTabs().isOpen(Tab.INVENTORY)) {
  252.             getTabs().open(Tab.INVENTORY);
  253.         } else {
  254.             if (getBank().isOpen()) {
  255.                 if (!getInventory().onlyContains("Bronze axe", "Iron axe",
  256.                         "Steel axe", "Black axe", "Mithril axe", "Adamant axe",
  257.                         "Rune axe", "Dragon axe", "Infernal axe")) {
  258.                     getBank().depositAllExcept("Bronze axe", "Iron axe",
  259.                             "Steel axe", "Black axe", "Mithril axe",
  260.                             "Adamant axe", "Rune axe", "Dragon axe",
  261.                             "Infernal axe");
  262.                 } else {
  263.                     if (getBank().close()) {
  264.                         sleepUntil(() -> !getBank().isOpen(),
  265.                                 Calculations.random(6000, 8000));
  266.                     }
  267.                 }
  268.             } else {
  269.                 if (getLocalPlayer().distance(
  270.                         getBank().getClosestBankLocation().getCenter()) > Calculations
  271.                         .random(6, 9)) {
  272.                     if (getWalking().walk(
  273.                             getBank().getClosestBankLocation().getCenter())) {
  274.                         sleepUntil(
  275.                                 () -> !getLocalPlayer().isMoving()
  276.                                         || getLocalPlayer().distance(
  277.                                                 getClient().getDestination()) < 8,
  278.                                 Calculations.random(3450, 5800));
  279.                     }
  280.                 } else {
  281.                     getBank().open();
  282.                     sleepUntil(() -> getBank().isOpen(),
  283.                             Calculations.random(6000, 8000));
  284.                 }
  285.             }
  286.         }
  287.     }
  288.  
  289.     private void antiBan() { // most simple 'antiban' to make
  290.         int random = Calculations.random(1, 250);
  291.  
  292.         if (random == 1) {
  293.             if (!getTabs().isOpen(Tab.STATS)) {
  294.                 getTabs().open(Tab.STATS);
  295.                 getSkills().hoverSkill(Skill.WOODCUTTING);
  296.                 sleep(Calculations.random(1000, 2000));
  297.                 getTabs().open(Tab.INVENTORY);
  298.             }
  299.         } else if (random <= 10) {
  300.             if (!getTabs().isOpen(Tab.INVENTORY)) {
  301.                 getTabs().open(Tab.INVENTORY);
  302.             }
  303.         } else if (random <= 15) {
  304.             getCamera().rotateToTile(treeArea.getRandomTile());
  305.         } else if (random <= 20) {
  306.             getCamera().rotateToEntity(getLocalPlayer());
  307.         } else if (random <= 88) {
  308.             if (getMouse().isMouseInScreen()) {
  309.                 if (getMouse().moveMouseOutsideScreen()) {
  310.                     sleep(Calculations.random(1500, 3000));
  311.                 }
  312.             }
  313.         } else {
  314.             //
  315.         }
  316.     }
  317.  
  318.     /*
  319.      * Paint
  320.      */
  321.  
  322.     private final Color color1 = new Color(51, 51, 51, 147);
  323.     private final Color color2 = new Color(35, 77, 19);
  324.     private final Color color3 = new Color(255, 255, 255);
  325.     private final BasicStroke stroke1 = new BasicStroke(5);
  326.     private final Font font1 = new Font("Arial", Font.BOLD, 13);
  327.     private final Font font2 = new Font("Arial", Font.BOLD, 0);
  328.     private final Font font3 = new Font("Arial", 0, 13);
  329.     private Timer t = new Timer();
  330.  
  331.     public void onPaint(Graphics g1) {
  332.         logsgained = (int) Math.floor(getSkillTracker().getGainedExperience(
  333.                 Skill.WOODCUTTING) / 175); // Detects chopped logs
  334.         logsanhour = t.getHourlyRate(logsgained);
  335.  
  336.         if (t == null) {
  337.             t = new Timer(0);
  338.         }
  339.         Graphics2D g = (Graphics2D) g1;
  340.         Stroke stroke = g.getStroke();
  341.         g.setColor(color1);
  342.         g.fillRect(3, 4, 175, 165);
  343.         g.setColor(color2);
  344.         g.setStroke(stroke1);
  345.         g.drawRect(3, 4, 175, 165);
  346.         g.setFont(font1);
  347.         g.setColor(color3);
  348.         g.drawString(getManifest().name() + "         " + "v"
  349.                 + getManifest().version(), 12, 29);
  350.         g.setFont(font2);
  351.         g.setFont(font3);
  352.         g.drawString("Time running: " + Timer.formatTime(t.elapsed()), 12, 59);
  353.         g.drawString(
  354.                 "Levels gained: " + getSkills().getRealLevel(Skill.WOODCUTTING)
  355.                         + "(+"
  356.                         + getSkillTracker().getGainedLevels(Skill.WOODCUTTING)
  357.                         + ")", 12, 79);
  358.         g.drawString(
  359.                 "XP gained: "
  360.                         + getSkillTracker().getGainedExperience(
  361.                                 Skill.WOODCUTTING)
  362.                         + "("
  363.                         + getSkillTracker().getGainedExperiencePerHour(
  364.                                 Skill.WOODCUTTING) + ")", 12, 99);
  365.         g.drawString(
  366.                 "XP to level: "
  367.                         + getSkills().getExperienceToLevel(Skill.WOODCUTTING),
  368.                 12, 121);
  369.         g.drawString(
  370.                 "Chopped [P/H]: " + logsgained + " ["
  371.                         + t.getHourlyRate(logsgained) + "]", 12, 141);
  372.         g.drawString("GP(/h): " + (int) Math.floor(logsgained * 400) + " ["
  373.                 + (int) Math.floor(logsanhour * 400) + "]", 12, 161);
  374.         if (gui.getway() == "Member") {
  375.             g.drawString("{" + xnests + "}", 150, 161);
  376.         }
  377.         g.setStroke(stroke);
  378.     }
  379.  
  380.     public void setStartScript(boolean startScript) {
  381.         this.startScript = startScript;
  382.     }
  383.  
  384.     @Override
  385.     public void onGameMessage(Message message) {
  386.         if (message.getMessage().contains("A bird's nest falls")) {
  387.             xnests++;
  388.             newNest = true;
  389.         }
  390.     }
  391.  
  392.     @Override
  393.     public void onPlayerMessage(Message arg0) {
  394.     }
  395.  
  396.     @Override
  397.     public void onPrivateInMessage(Message arg0) {
  398.     }
  399.  
  400.     @Override
  401.     public void onPrivateOutMessage(Message arg0) {
  402.     }
  403.  
  404.     @Override
  405.     public void onTradeMessage(Message arg0) {
  406.     }
  407. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement