Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.awt.*;
- import org.vinsert.bot.script.*;
- import org.vinsert.bot.script.api.GameObject;
- import org.vinsert.bot.script.api.tools.Navigation.NavigationPolicy;
- import org.vinsert.bot.script.api.tools.Skills;
- import org.vinsert.bot.util.Filter;
- @ScriptManifest(authors = { "Coordinates" }, name = "Draynor Chop'n'Bank", description = "Chops logs at Draynor and banks them.", version = 1.0)
- public class DraynorChopper extends Script {
- @Override
- public void render(Graphics2D arg0) {
- runtime = System.currentTimeMillis() - startTime;
- xpGained = (skills.getExperience(Skills.WOODCUTTING) - xpStart);
- lvlCurrent = skills.getLevel(Skills.WOODCUTTING);
- int lvlGain = (lvlCurrent - lvlStart);
- int xpHour = (int) ((double) xpGained / runtime * 3600000);
- int stealsHour = (int) ((double) totalLogs / runtime * 3600000);
- Graphics2D g = (Graphics2D) arg0;
- g.setColor(color1);
- g.fillRect(237, 258, 271, 69);
- g.setColor(color3);
- g.setStroke(stroke1);
- g.drawRect(237, 258, 271, 69);
- g.setFont(font1);
- g.drawString("Draynor C'n'B by Coordinates", 241, 271);
- g.drawLine(237, 273, 508, 273);
- g.drawString("Logs: " + totalLogs, 241, 291);
- g.drawString("XP Gained: " + xpGained, 241, 308);
- g.drawString("Current Level: " + lvlCurrent + "(+" + lvlGain + ")",
- 241, 323);
- g.drawString("XP/Hour: " + xpHour, 374, 308);
- g.drawString("Logs/HR: " + stealsHour, 374, 291);
- g.drawString("Run time:" + timeToString((int) runtime), 374, 323);
- g.drawString("Version 1.00", 435, 271);
- }
- @Override
- public void close() {
- log("Thank you for using Draynor Chop'n'Bank by Coordinates.");
- }
- @Override
- public boolean init() {
- startTime = System.currentTimeMillis();
- startLogs = inventory.getCount(false, 1520);
- lvlStart = skills.getLevel(Skills.WOODCUTTING);
- xpStart = skills.getExperience(Skills.WOODCUTTING);
- return true;
- }
- @Override
- public int pulse() {
- tempLogs = inventory.getCount(false, 1520) - startLogs;
- totalLogs = currentLogs + tempLogs;
- if (!inventory.isFull()) {
- doChop();
- }
- if (inventory.isFull()) {
- doBank();
- }
- return 1;
- }
- public void doBank() {
- Filter<GameObject> booth = new Filter<GameObject>() {
- int booth = 16937;
- public boolean accept(GameObject o) {
- return o.getId() == this.booth;
- }
- };
- GameObject bankbooth = objects.getNearest(booth);
- if (players.getLocalPlayer().getLocation()
- .distanceTo(bankbooth.getLocation()) < 6) {
- if (bank.isOpen()) {
- currentLogs += inventory.getCount(false, 1520) - startLogs;
- startLogs = 0;
- bank.depositAll();
- sleep(1250);
- } else {
- bankbooth.interact("Bank");
- sleep(1250);
- }
- }
- if (players.getLocalPlayer().getLocation()
- .distanceTo(bankbooth.getLocation()) > 6
- && !players.getLocalPlayer().isMoving()) {
- navigation.navigate(bankbooth.getLocation(),
- NavigationPolicy.MINIMAP);
- }
- }
- public void doChop() {
- final int tree1 = 17771;
- final int tree2 = 17772;
- final int tree3 = 16711;
- Filter<GameObject> tree = new Filter<GameObject>() {
- public boolean accept(GameObject o) {
- if (o.getId() == tree1) {
- return true;
- } else {
- return false;
- }
- }
- };
- GameObject trees = objects.getNearest(tree);
- if (players.getLocalPlayer().getLocation()
- .distanceTo(trees.getLocation()) > 7
- && !players.getLocalPlayer().isMoving()) {
- navigation.navigate(trees.getLocation(), NavigationPolicy.MINIMAP);
- sleep(2500);
- }
- if (players.getLocalPlayer().getLocation()
- .distanceTo(trees.getLocation()) < 7) {
- if (players.getLocalPlayer().getAnimation() == 867) {
- sleep(500);
- } else {
- trees.interact("Chop down");
- sleep(1000);
- }
- }
- }
- public static String timeToString(int time) {
- int seconds = (int) (time / 1000) % 60;
- int minutes = (int) ((time / (1000 * 60)) % 60);
- int hours = (int) ((time / (1000 * 60 * 60)) % 24);
- return (hours < 10 ? "0" + hours : hours) + ":"
- + (minutes < 10 ? "0" + minutes : minutes) + ":"
- + (seconds < 10 ? "0" + seconds : seconds);
- }
- int tempLogs;
- int startLogs;
- int currentLogs = 0;
- int totalLogs;
- long runtime;
- int xpGained;
- int lvlCurrent;
- int xpStart;
- int lvlStart;
- long startTime;
- private final Color color1 = new Color(34, 139, 34, 151);
- private final Color color3 = new Color(255, 255, 255);
- private final BasicStroke stroke1 = new BasicStroke(1);
- private final Font font1 = new Font("Arial", 0, 13);
- }
Add Comment
Please, Sign In to add comment