Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.awt.Color;
- import java.awt.Font;
- import java.awt.Graphics;
- import java.awt.Point;
- import java.awt.Rectangle;
- import java.awt.image.BufferedImage;
- import org.rsbot.event.listeners.PaintListener;
- import org.rsbot.script.Script;
- import org.rsbot.script.ScriptManifest;
- import org.rsbot.script.methods.Calculations;
- import org.rsbot.script.methods.Interfaces;
- import org.rsbot.script.methods.Inventory;
- import org.rsbot.script.methods.Keyboard;
- import org.rsbot.script.methods.Mouse;
- import org.rsbot.script.methods.NPCs;
- import org.rsbot.script.methods.Objects;
- import org.rsbot.script.methods.Skills;
- import org.rsbot.script.methods.Walking;
- import org.rsbot.script.util.Timer;
- import org.rsbot.script.wrappers.RSComponent;
- import org.rsbot.script.wrappers.RSInterface;
- import org.rsbot.script.wrappers.RSNPC;
- import org.rsbot.script.wrappers.RSObject;
- import org.rsbot.script.wrappers.RSPlayer;
- import org.rsbot.script.wrappers.RSTile;
- @ScriptManifest(authors={"happyfeet"}, name="DemonButlerOakLarder", version=1.0D, description="<html><head></head><body><center><strong><h2>Pedreiro</h2></strong><br /><br />Start near the oak larder space with butler following you.<br />Fetch 24 Planks once before starting.<br /><br />Options: <select name=\"Op\"><option>Oak Larder<option>Oak Dungeon Door<option>Mahogany Table</select><br />Butler: <select name=\"BUTLER\"><option>Rick<option>Maid<option>Cook<option>Butler<option>Demon Butler</select></center><br /></body></html>")
- public class DemonButlerOakLarder extends Script
- implements PaintListener
- {
- private int oakB = 13566;
- private int oakUn = 15403;
- public String status = "";
- private int oakPlank = 8778;
- private int oakDB = 13345;
- private int oakDUn = 15327;
- private int mahB = 13298;
- private int mahUn = 15298;
- private int mahPlank = 8782;
- private long startingTime;
- private int startXP = 0;
- private int startLvl = 0;
- private long scriptStartTime = 0L;
- final ScriptManifest properties = (ScriptManifest)getClass().getAnnotation(ScriptManifest.class);
- private Rectangle experienceProgressBar;
- private int rick = 4235;
- private int maid = 4237;
- private int cook = 4239;
- BufferedImage normal = null;
- BufferedImage clicked = null;
- private int nbutler = 4241;
- private int dbutler = 4243;
- private int Built;
- private int Unbuilt;
- private int plank;
- private int choose;
- private int butler;
- private long startExp;
- private long st;
- private long startLevel;
- private RSTile nearLarder;
- private boolean ButlerHere = true;
- public int waitForInventoryCount(int item, int count, int timeout)
- {
- long start = System.currentTimeMillis();
- while (System.currentTimeMillis() - start < timeout) {
- if (this.inventory.getCount(new int[] { item }) >= count) {
- break;
- }
- }
- return this.inventory.getCount(new int[] { item });
- }
- public int loop()
- {
- if (this.calc.distanceTo(this.nearLarder) > 3) {
- this.walking.walkTo(this.nearLarder);
- return 1300;
- }
- if (manageInterfaces()) {
- return 800;
- }
- if (this.inventory.getCount(new int[] { this.plank }) < 16) {
- if (this.npcs.getNearest(new int[] { this.butler }) != null) {
- if (!this.ButlerHere) {
- this.ButlerHere = true;
- int waitCount = 24;
- if (this.inventory.getCount(new int[] { this.plank }) < 1) {
- waitForInventoryCount(this.plank, waitCount, 3000);
- }
- }
- if (this.inventory.getCount(new int[] { this.plank }) <= 6) if (this.objects.getNearest(new int[] { this.Built }) != null) {
- this.npcs.getNearest(new int[] { this.butler }).doAction("Fetch-from-bank");
- sleep(1300);
- }
- if ((this.interfaces.get(242).isValid()) || (this.interfaces.get(232).isValid()) || (this.interfaces.get(234).isValid())) {
- if (this.inventory.getCount(new int[] { this.plank }) < 16) {
- manageInterfaces();
- return 1500;
- }
- }
- if (this.inventory.getCount(new int[] { this.plank }) >= 16)
- return 1500;
- }
- else
- {
- this.ButlerHere = false;
- if (this.objects.getNearest(new int[] { this.Built }) != null) {
- this.objects.getNearest(new int[] { this.Built }).doAction("Remove");
- return 1500;
- }
- }
- }
- if (this.objects.getNearest(new int[] { this.Built }) != null) if (this.inventory.getCount(new int[] { this.plank }) > 6) {
- this.objects.getNearest(new int[] { this.Built }).doAction("Remove");
- return 1500;
- }
- if (this.objects.getNearest(new int[] { this.Unbuilt }) != null) if (this.inventory.getCount(new int[] { this.plank }) > 7) {
- this.objects.getNearest(new int[] { this.Unbuilt }).doAction("Build");
- this.objects.getNearest(new int[] { this.Unbuilt }).doAction("Build");
- this.objects.getNearest(new int[] { this.Unbuilt }).doAction("Build");
- sleep(1500);
- this.mouse.move(110, 140);
- sleep(600);
- this.mouse.click(true);
- sleep(2000);
- return 1200;
- }
- return 1;
- }
- public int getMouseSpeed() {
- return 0;
- }
- private boolean manageInterfaces() {
- if ((isValid(this.interfaces.get(242), 5)) &&
- (this.interfaces.get(232).containsText("any of those ite"))) {
- log("Out of planks! Thanks for using Oak Larder maker :)");
- stopScript(true);
- return true;
- }
- if (this.interfaces.get(394).isValid()) {
- clickThaLarder(8234);
- this.nearLarder = getMyPlayer().getLocation();
- return true;
- }
- if ((isValid(this.interfaces.get(232), 3)) &&
- (this.interfaces.get(232).containsText("Pay servant"))) {
- this.interfaces.getComponent(232, 3).doClick();
- return true;
- }
- if (isValid(this.interfaces.get(228), 2)) {
- this.mouse.move(random(250, 280), random(398, 412));
- sleep(random(15, 50));
- this.mouse.click(true);
- return true;
- }
- if (isValid(this.interfaces.get(241), 5)) {
- if ((this.interfaces.get(241).containsText("Yes, madam?")) || (this.interfaces.get(241).containsText("Yes, sir?")) || (this.interfaces.get(241).containsText("Your goods")))
- return false;
- this.interfaces.getComponent(241, 5).doClick();
- return true;
- }
- if (isValid(this.interfaces.get(234), 2)) {
- if (this.inventory.getCount(new int[] { this.plank }) < 16) {
- this.interfaces.getComponent(234, 2).doClick();
- }
- else {
- this.objects.getNearest(new int[] { this.Built }).doAction("Walk here");
- }
- return true;
- }
- if (isValid(this.interfaces.get(232), 3)) {
- this.interfaces.getComponent(232, 3).doClick();
- sleep(random(1000, 2000));
- this.keyboard.sendText("24", true);
- sleep(random(100, 200));
- return true;
- }
- if (isValid(this.interfaces.get(242), 6)) { this.interfaces.getComponent(242, 6).doClick();
- return true; }
- if (this.interfaces.get(243).containsText("until thou art ready."))
- return false;
- if (isValid(this.interfaces.get(243), 7)) {
- this.interfaces.getComponent(243, 7).doClick();
- return true;
- }
- return false;
- }
- private boolean isValid(RSInterface a, int child) {
- return (a.isValid()) && (a.getComponent(child).getAbsoluteY() > 30);
- }
- public boolean onStart()
- {
- this.mouse.setSpeed(random(0, 5));
- this.scriptStartTime = System.currentTimeMillis();
- this.startXP = this.skills.getCurrentExp(22);
- this.startLvl = this.skills.getCurrentLevel(22);
- this.st = System.currentTimeMillis();
- this.butler = this.dbutler;
- this.Built = this.oakB;
- this.Unbuilt = 15403;
- this.plank = this.oakPlank;
- this.choose = 0;
- return true;
- }
- public boolean clickThaLarder(int itemID)
- {
- RSComponent LarderMenu = this.interfaces.get(394).getComponent(11);
- if ((LarderMenu == null) || (LarderMenu.getComponents() == null)) {
- return false;
- }
- for (RSComponent item : LarderMenu.getComponents()) {
- if ((item != null) && (item.getComponentID() == itemID)) {
- LarderMenu.doClick();
- sleep(2000);
- }
- }
- return true;
- }
- public void drawMouse(Graphics g) {
- if (this.normal != null) {
- double mouseX = this.mouse.getLocation().getX() - 8.0D;
- double mouseY = this.mouse.getLocation().getY() - 8.0D;
- double mousePressX = this.mouse.getPressLocation().getX() - 8.0D;
- double mousePressY = this.mouse.getPressLocation().getY() - 8.0D;
- if (System.currentTimeMillis() - this.mouse.getPressTime() < 400L) {
- g.drawImage(this.clicked, (int)mousePressX, (int)mousePressY, null);
- }
- g.drawImage(this.normal, (int)mouseX, (int)mouseY, null);
- }
- }
- public void onRepaint(Graphics g)
- {
- long runTime = 0L;
- long seconds = 0L;
- long minutes = 0L;
- long hours = 0L;
- int percent = 0;
- int currentXP = 0;
- int currentLVL = 0;
- int gainedXP = 0;
- int gainedLVL = 0;
- int lapsPerHour = 0;
- int expPerHour = 0;
- runTime = System.currentTimeMillis() - this.scriptStartTime;
- percent = this.skills.getPercentToNextLevel(22);
- currentXP = this.skills.getCurrentExp(22);
- currentLVL = this.skills.getCurrentLevel(22);
- gainedXP = currentXP - this.startXP;
- gainedLVL = currentLVL - this.startLvl;
- expPerHour = (int)(3600000.0D / runTime * gainedXP);
- int fillBar = (int)(4.7D * percent);
- drawMouse(g);
- g.setColor(new Color(32, 0, 0, 175));
- g.fillRect(23, 387, 470, 26);
- g.setColor(new Color(108, 108, 108, 200));
- g.fillRect(25, 389, 470, 26);
- g.setColor(new Color(0, 0, 0, 175));
- g.fillRoundRect(7, 345, 506, 129, 7, 7);
- g.setColor(new Color(139, 0, 0, 175));
- g.fillRect(24, 388, 470, 26);
- g.setColor(new Color(0, 166, 0, 200));
- g.fillRect(24, 388, fillBar, 26);
- g.setColor(new Color(207, 58, 58, 175));
- g.fillRect(24, 401, 470, 13);
- g.setColor(new Color(128, 219, 128, 200));
- g.fillRect(24, 401, fillBar, 13);
- g.setFont(new Font("Verdana", 0, 14));
- g.setColor(new Color(0, 0, 0, 255));
- g.drawString(percent + "% - " + this.skills.getExpToNextLevel(22) + "xp remaining", 43, 406);
- g.setFont(new Font("Verdana", 3, 20));
- g.setColor(Color.red);
- g.drawString("DemonButlerOakLarder by Happyfeet", 48, 375);
- g.setFont(new Font("Verdana", 0, 12));
- g.setColor(new Color(225, 225, 225, 175));
- g.drawString("Current Lvl: " + currentLVL + " (+ " + gainedLVL + ")", 24, 445);
- g.drawString("Exp Gained: " + gainedXP + " (" + expPerHour + "/hr)", 24, 460);
- g.drawString("Run Time: " + Timer.format(runTime), 250, 445);
- try {
- if (expPerHour > 0) {
- long sTNL = this.skills.getExpToNextLevel(22) / (expPerHour / 3600);
- long hTNL = sTNL / 3600L;
- sTNL -= hTNL * 3600L;
- long mTNL = sTNL / 60L;
- sTNL -= mTNL * 60L;
- g.drawString("Level in: " + hTNL + ":" + mTNL + ":" + sTNL + " (" + percent + "%)", 250, 460);
- }
- else {
- g.drawString("Level in: 0:0:0 (" + percent + "%)", 250, 460);
- }
- }
- catch (Exception e) {
- g.drawString("Level in: -1:-1:-1 (" + percent + "%)", 250, 460);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement