Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Map;
- import org.rsbot.event.events.MessageEvent;
- import org.rsbot.event.listeners.MessageListener;
- import org.rsbot.script.Script;
- import org.rsbot.script.ScriptManifest;
- import org.rsbot.script.wrappers.RSArea;
- import org.rsbot.script.wrappers.RSObject;
- import org.rsbot.script.wrappers.RSTile;
- import org.rsbot.event.listeners.PaintListener;
- import java.awt.*;
- @ScriptManifest(authors = "DrOstler", name = "Willow Cutter", version = 1.0, description = "Cuts and banks willows at Draynor.")
- public class DraynorWillows extends Script implements PaintListener, MessageListener {
- int[] WillowTreeID = {5551,5552,5553};
- int[] HatchetsID = {1359};
- int BankBoothID = 2213;
- int WillowsID = 1519;
- int TimeToMoveCamera = 0;
- int MoveTime = 0;
- String status = "Waiting";
- public long startTime = System.currentTimeMillis();
- int expGained = 0;
- int startExp = 0;
- int LogsCut = 0;
- private final Color color1 = new Color(255, 255, 255);
- private final Color color2 = new Color(255, 51, 51);
- private final Color color3 = new Color(0, 0, 0);
- private final Color color4 = new Color(102, 255, 102);
- private final Color color5 = new Color(51, 102, 255);
- private final BasicStroke stroke1 = new BasicStroke(1);
- private final Font font1 = new Font("Arial", 0, 10);
- private final Font font2 = new Font("Arial", 1, 11);
- private final Font font3 = new Font("Times New Roman", 1, 23);
- RSTile[] BankFromTrees = { new RSTile(3088, 3237), new RSTile(3094, 3243)};
- RSTile[] TreesFromBank = { new RSTile(3094, 3243), new RSTile(3088, 3237)};
- public boolean onStart(){
- log("You are using DrOstler's Willow Cutter, Enjoy.");
- startExp = skills.getCurrentExp(skills.WOODCUTTING);
- return true;
- }
- private boolean AtWillows(){
- RSArea area = new RSArea(new RSTile(3091, 3239), new RSTile(3070, 3225));
- return area.contains(getMyPlayer().getLocation());
- }
- private boolean AtBank(){
- RSArea area = new RSArea(new RSTile(3095, 3246), new RSTile(3085, 3240));
- return area.contains(getMyPlayer().getLocation());
- }
- private void ChopTree(){
- RSObject tree = objects.getNearest(WillowTreeID);
- if (tree != null && getMyPlayer().getAnimation() == -1) {
- tree.doAction("chop");
- status = "Chopping";
- }
- }
- private boolean WalkToBank() {
- status = "Walking To Bank";
- return walking.walkPathMM(BankFromTrees);
- }
- private boolean WalkToTrees() {
- status = "Walking To Trees";
- return walking.walkPathMM(TreesFromBank);
- }
- private void openBank() {
- status = "Opening Bank";
- RSObject bankBooth = objects.getNearest(BankBoothID);
- if (bankBooth != null && !bank.isOpen()) {
- bankBooth.doAction("uickly");
- }
- }
- private void depositWillows() {
- status = "Depositing Willows";
- if (bank.isOpen()) {
- bank.deposit(WillowsID, 0);
- sleep(200, 500);
- }
- }
- private void closeBank() {
- status = "Closing Bank";
- if (bank.isOpen()) {
- mouse.move(490, 36, 3, 3);
- sleep(200, 500);
- mouse.click(true);
- }
- }
- private void bank() {
- openBank();
- depositWillows();
- closeBank();
- }
- private void MoveCamera(){
- camera.setAngle(random(1, 360));
- camera.setPitch(random(1,180));
- }
- private void MoveMouse(){
- mouse.move(random(1,764), random(1,500));
- }
- public void messageRecieved(MessageEvent e){
- String text = e.getMessage();
- if (text.contains("You get some")){
- LogsCut += 1;
- }
- }
- public void onRepaint(Graphics g1) {
- expGained = skills.getCurrentExp(skills.WOODCUTTING) - startExp ;
- long millis = System.currentTimeMillis() - startTime;
- long hours = millis / (1000 * 60 * 60);
- millis -= hours * (1000 * 60 * 60);
- long minutes = millis / (1000 * 60);
- millis -= minutes * (1000 * 60);
- long seconds = millis / 1000;
- float xpsec = 0;
- if ((minutes > 0 || hours > 0 || seconds > 0) && expGained > 0){
- xpsec = ((float) expGained)/ (float)(seconds + (minutes * 60) + (hours*60*60));
- }
- float xpmin = xpsec * 60;
- float xphour = xpmin * 60;
- Graphics2D g = (Graphics2D)g1;
- g.setColor(color1);
- g.fillRect(6, 52, 127, 91);
- g.setColor(color2);
- g.fillRoundRect(7, 313, 503, 19, 16, 16);
- g.setColor(color3);
- g.setStroke(stroke1);
- g.drawRoundRect(7, 313, 503, 19, 16, 16);
- g.setColor(color4);
- g.fillRoundRect(7, 313, 503, 19, 16, 16);
- g.setColor(color3);
- g.drawRoundRect(7, 313, 503, 19, 16, 16);
- g.setFont(font1);
- g.drawString("Time Running:" + hours + ": " + minutes + ": " + seconds, 7, 66);
- g.drawString("Exp Gained : " + expGained, 8, 83);
- g.drawString("Logs Cut : " + LogsCut, 8, 137);
- g.drawString("Exp Per Hour : " + (int)xphour, 8, 101);
- g.drawString("Profit Made : ", 7, 120);
- g.setFont(font2);
- g.drawString("How Much Exp til what Level", 179, 327);
- g.setFont(font3);
- g.setColor(color5);
- g.drawString("DrOstler's Willow Cutter", 7, 39);
- }
- public void onFinish(){
- log("Thank you and Goodbye.");
- }
- @Override
- public int loop() {
- if (AtWillows() && inventory.isFull()) {
- WalkToBank();
- }
- else if (AtBank() && inventory.isFull()) {
- bank();
- }
- else if (AtBank() && !inventory.isFull()) {
- WalkToTrees();
- }
- else if (AtWillows() && !inventory.isFull()) {
- ChopTree();
- }
- if (TimeToMoveCamera == 50) {
- MoveCamera();
- TimeToMoveCamera = 0;
- }
- else if (TimeToMoveCamera != 50){
- TimeToMoveCamera += 1;
- }
- if (status == "Chopping"){
- MoveMouse();
- }
- return (random(650, 950));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement