Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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.MessageListener;
- import org.dreambot.api.utilities.Timer;
- import org.dreambot.api.wrappers.interactive.GameObject;
- import org.dreambot.api.wrappers.items.GroundItem;
- import org.dreambot.api.wrappers.widgets.message.Message;
- import java.awt.*;
- @ScriptManifest(category = Category.WOODCUTTING, name = "GE Yews", author = "Diddy", version = 1.5)
- public class Main extends AbstractScript implements MessageListener {
- private boolean startScript;
- private boolean newNest;
- private YewsGUI gui;
- private int logsgained;
- private int logsanhour;
- private int xnests;
- private Area treeArea = new Area(3201, 3506, 3224, 3501, 0);
- private Area startArea = new Area(3201, 3506, 3207, 3501, 0);
- Tile t1 = new Tile(3204, 3505, 0);
- Tile t2 = new Tile(3210, 3500, 0);
- Tile t3 = new Tile(3222, 3504, 0);
- String Status = " ";
- Timer timer;
- static String status = null;
- private GameObject tree;
- @Override
- public void onStart() { // making the GUI visable
- gui = new YewsGUI(this);
- gui.setVisible(true);
- sleepUntil(() -> startScript, 60000); // sleeping until logged in
- sleepUntil(() -> getClient().isLoggedIn(),
- Calculations.random(40000, 60000));
- getSkillTracker().start(Skill.WOODCUTTING); // tracking all woodcutting
- // exp gained
- }
- private enum State {
- CHOP, BANK, WAIT,
- }
- private State getState() { // we are seperating the script into pieces
- // making it more convenient
- tree = getGameObjects().closest(
- gameObject -> gameObject != null
- && gameObject.getName().equals("Yew")
- && gameObject.distance() < 17
- && treeArea.contains(gameObject));
- if (startScript) {
- if (!getInventory().isFull() && !getLocalPlayer().isAnimating()) {
- return State.CHOP;
- } else if (getInventory().isFull()) {
- return State.BANK;
- } else if (treeArea.contains(getLocalPlayer())
- && getLocalPlayer().isAnimating()) {
- return State.WAIT;
- }
- }
- return null;
- }
- @Override
- public int onLoop() {
- tree = getGameObjects().closest(
- gameObject -> gameObject != null
- && gameObject.getName().equals("Yew")
- && gameObject.distance() < 17
- && treeArea.contains(gameObject));
- switch (getState()) {
- case CHOP:
- if (treeArea.contains(getLocalPlayer())) {
- if (!newNest) { // checking if there isn't a birdsnest
- if (tree != null && treeArea.contains(tree)) {
- if (tree.isOnScreen()) {
- chop(); // chop the tree
- } else {
- move(); // move the camera a bit
- }
- } else {
- hopWorlds(); // hop worlds
- }
- } else {
- GroundItem nest = getGroundItems().closest("Bird nest");
- if (nest != null && nest.interact()) {
- sleepUntil(() -> nest == null
- || !getLocalPlayer().isMoving(),
- Calculations.random(2500, 3800));
- newNest = false;
- }
- }
- } else {
- if (getWalking().walk(startArea.getRandomTile())) {
- log("walking to yews");
- sleepUntil(
- () -> (getClient().getDestination().distance() < Calculations.random(
- 6, 9))
- || getLocalPlayer().isStandingStill(),
- Calculations.random(4100, 5110));
- }
- }
- break;
- case BANK:
- bank();
- break;
- case WAIT:
- antiBan();
- sleepUntil(() -> !getLocalPlayer().isAnimating(),
- Calculations.random(7000, 12000));
- break;
- }
- return Calculations.random(250, 350);
- }
- private void move() {
- log("getting new tree.");
- if (tree.distance() < Calculations.random(5, 7)) {
- Status = "Moving camera";
- getCamera().rotateToEntity(tree);
- getCamera().rotateToPitch(Calculations.random(32, 39));
- } else {
- Status = "Walking to stuff";
- if (tree != null) {
- getWalking().walk(tree);
- sleepUntil(
- () -> (getClient().getDestination().distance() < Calculations.random(
- 4, 6))
- || getLocalPlayer().isStandingStill(),
- Calculations.random(4100, 5110));
- }
- }
- }
- private int F2PWorld() { // Don't do this pls
- int random = Calculations.random(1, 12);
- // 1|8|16|26|35|81|82|83|84|85|93|94
- int world = 0;
- if (random == 1) {
- world = 1;
- } else if (random == 2) {
- world = 8;
- } else if (random == 3) {
- world = 16;
- } else if (random == 4) {
- world = 26;
- } else if (random == 5) {
- world = 35;
- } else if (random == 6) {
- world = 81;
- } else if (random == 7) {
- world = 82;
- } else if (random == 8) {
- world = 83;
- } else if (random == 9) {
- world = 84;
- } else if (random == 10) {
- world = 85;
- } else if (random == 11) {
- world = 93;
- } else if (random == 12) {
- world = 94;
- }
- if (world != getClient().getCurrentWorld()) {
- return world;
- } else {
- return F2PWorld();
- }
- }
- private int P2PWorld() { // this looks more legit
- int world = getWorlds().getRandomWorld(
- w -> w.isMembers() && w.getID() != (319) && w.getID() != (325)
- && w.getID() != (337) && w.getID() != (345)
- && w.getID() != (352) && w.getID() != (357)
- && w.getID() != (360) && w.getID() != (374)
- && w.getID() != (373) && w.getID() != (366)
- && w.getID() != (365) && w.getID() != (361)
- && w.getID() != (353)
- && w.getID() != getClient().getCurrentWorld()).getID();
- return world;
- }
- private void hopWorlds() {
- if (gui.getway() == "Free2Play") {
- if (getWorldHopper().hopWorld(F2PWorld())) {
- sleep(Calculations.random(1000, 2500));
- sleepUntil(() -> getLocalPlayer().exists()
- && getClient().isLoggedIn(),
- Calculations.random(5000, 8500));
- sleepUntil(() -> treeArea.contains(tree),
- Calculations.random(2000, 3500));
- }
- } else {
- if (getWorldHopper().hopWorld(P2PWorld())) {
- sleep(Calculations.random(1000, 2500));
- sleepUntil(() -> getLocalPlayer().exists()
- && getClient().isLoggedIn(),
- Calculations.random(5000, 8500));
- sleepUntil(() -> treeArea.contains(tree),
- Calculations.random(2000, 3500));
- }
- }
- }
- private void chop() {
- sleep(Calculations.random(50, 160));
- if (tree != null && tree.interact("Chop down")) {
- log("Chopping new tree.");
- sleep(Calculations.random(600, 1200));
- sleepUntil(() -> !getLocalPlayer().isMoving(),
- Calculations.random(3500, 5000));
- sleep(Calculations.random(150, 311));
- if (getLocalPlayer().isAnimating()) {
- antiBan();
- sleepUntil(() -> !getLocalPlayer().isAnimating(),
- Calculations.random(7000, 12000));
- }
- }
- }
- private void bank() {
- if (!getTabs().isOpen(Tab.INVENTORY)) {
- getTabs().open(Tab.INVENTORY);
- } else {
- if (getBank().isOpen()) {
- if (!getInventory().onlyContains("Bronze axe", "Iron axe",
- "Steel axe", "Black axe", "Mithril axe", "Adamant axe",
- "Rune axe", "Dragon axe", "Infernal axe")) {
- getBank().depositAllExcept("Bronze axe", "Iron axe",
- "Steel axe", "Black axe", "Mithril axe",
- "Adamant axe", "Rune axe", "Dragon axe",
- "Infernal axe");
- } else {
- if (getBank().close()) {
- sleepUntil(() -> !getBank().isOpen(),
- Calculations.random(6000, 8000));
- }
- }
- } else {
- if (getLocalPlayer().distance(
- getBank().getClosestBankLocation().getCenter()) > Calculations
- .random(6, 9)) {
- if (getWalking().walk(
- getBank().getClosestBankLocation().getCenter())) {
- sleepUntil(
- () -> !getLocalPlayer().isMoving()
- || getLocalPlayer().distance(
- getClient().getDestination()) < 8,
- Calculations.random(3450, 5800));
- }
- } else {
- getBank().open();
- sleepUntil(() -> getBank().isOpen(),
- Calculations.random(6000, 8000));
- }
- }
- }
- }
- private void antiBan() { // most simple 'antiban' to make
- int random = Calculations.random(1, 250);
- if (random == 1) {
- if (!getTabs().isOpen(Tab.STATS)) {
- getTabs().open(Tab.STATS);
- getSkills().hoverSkill(Skill.WOODCUTTING);
- sleep(Calculations.random(1000, 2000));
- getTabs().open(Tab.INVENTORY);
- }
- } else if (random <= 10) {
- if (!getTabs().isOpen(Tab.INVENTORY)) {
- getTabs().open(Tab.INVENTORY);
- }
- } else if (random <= 15) {
- getCamera().rotateToTile(treeArea.getRandomTile());
- } else if (random <= 20) {
- getCamera().rotateToEntity(getLocalPlayer());
- } else if (random <= 88) {
- if (getMouse().isMouseInScreen()) {
- if (getMouse().moveMouseOutsideScreen()) {
- sleep(Calculations.random(1500, 3000));
- }
- }
- } else {
- //
- }
- }
- /*
- * Paint
- */
- private final Color color1 = new Color(51, 51, 51, 147);
- private final Color color2 = new Color(35, 77, 19);
- private final Color color3 = new Color(255, 255, 255);
- private final BasicStroke stroke1 = new BasicStroke(5);
- private final Font font1 = new Font("Arial", Font.BOLD, 13);
- private final Font font2 = new Font("Arial", Font.BOLD, 0);
- private final Font font3 = new Font("Arial", 0, 13);
- private Timer t = new Timer();
- public void onPaint(Graphics g1) {
- logsgained = (int) Math.floor(getSkillTracker().getGainedExperience(
- Skill.WOODCUTTING) / 175); // Detects chopped logs
- logsanhour = t.getHourlyRate(logsgained);
- if (t == null) {
- t = new Timer(0);
- }
- Graphics2D g = (Graphics2D) g1;
- Stroke stroke = g.getStroke();
- g.setColor(color1);
- g.fillRect(3, 4, 175, 165);
- g.setColor(color2);
- g.setStroke(stroke1);
- g.drawRect(3, 4, 175, 165);
- g.setFont(font1);
- g.setColor(color3);
- g.drawString(getManifest().name() + " " + "v"
- + getManifest().version(), 12, 29);
- g.setFont(font2);
- g.setFont(font3);
- g.drawString("Time running: " + Timer.formatTime(t.elapsed()), 12, 59);
- g.drawString(
- "Levels gained: " + getSkills().getRealLevel(Skill.WOODCUTTING)
- + "(+"
- + getSkillTracker().getGainedLevels(Skill.WOODCUTTING)
- + ")", 12, 79);
- g.drawString(
- "XP gained: "
- + getSkillTracker().getGainedExperience(
- Skill.WOODCUTTING)
- + "("
- + getSkillTracker().getGainedExperiencePerHour(
- Skill.WOODCUTTING) + ")", 12, 99);
- g.drawString(
- "XP to level: "
- + getSkills().getExperienceToLevel(Skill.WOODCUTTING),
- 12, 121);
- g.drawString(
- "Chopped [P/H]: " + logsgained + " ["
- + t.getHourlyRate(logsgained) + "]", 12, 141);
- g.drawString("GP(/h): " + (int) Math.floor(logsgained * 400) + " ["
- + (int) Math.floor(logsanhour * 400) + "]", 12, 161);
- if (gui.getway() == "Member") {
- g.drawString("{" + xnests + "}", 150, 161);
- }
- g.setStroke(stroke);
- }
- public void setStartScript(boolean startScript) {
- this.startScript = startScript;
- }
- @Override
- public void onGameMessage(Message message) {
- if (message.getMessage().contains("A bird's nest falls")) {
- xnests++;
- newNest = true;
- }
- }
- @Override
- public void onPlayerMessage(Message arg0) {
- }
- @Override
- public void onPrivateInMessage(Message arg0) {
- }
- @Override
- public void onPrivateOutMessage(Message arg0) {
- }
- @Override
- public void onTradeMessage(Message arg0) {
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement