Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import org.rsbot.script.*;
- import org.rsbot.event.listeners.PaintListener;
- import java.awt.*;
- import java.text.DecimalFormat;
- import java.text.NumberFormat;
- @ScriptManifest(authors = "Danielmedvec", keywords = "HunterKit", name = "DmKitOpener", version = 1.2, description = "Flawless!")
- public class DMKITOPENER extends Script implements PaintListener {
- public int kit = 11159;
- public int[] content = {10150, 10010, 10006, 10031, 10029, 10008};
- public int contentPrice;
- public int kitPrice;
- public int profitPerKit;
- public int kitsopened = 0;
- public int kitsperhour;
- public int kitcount;
- public NumberFormat groupingFormat = new DecimalFormat("###,###,###");
- public long startTime = System.currentTimeMillis();
- private final RenderingHints antialiasing = new RenderingHints(
- RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
- private final Color color1 = new Color(255, 255, 255, 100);
- private final Color color2 = new Color(0, 0, 0);
- private final Color color3 = new Color(0, 0, 255);
- private final Color color4 = new Color(255, 0, 0);
- private final BasicStroke stroke1 = new BasicStroke(1);
- private final BasicStroke stroke2 = new BasicStroke(2);
- private final Font font1 = new Font("Calibri", 1, 17);
- private final Font font2 = new Font("Calibri", 0, 17);
- private final Font font3 = new Font("Calibri", 0, 10);
- private final Font font4 = new Font("Calibri", 1, 12);
- @Override
- public boolean onStart() {
- mouse.setSpeed(random(7,10));
- calculateProfits();
- kitcount = inventory.getCount(kit);
- return true;
- }
- private void calculateProfits()
- {
- kitPrice = grandExchange.lookup(kit).getGuidePrice();
- contentPrice = 0;
- for(int itemID : content)
- {
- contentPrice += grandExchange.lookup(itemID).getGuidePrice();
- }
- profitPerKit = contentPrice - kitPrice;
- }
- public boolean openKit() {
- inventory.getItem(kit).doAction("Open");
- if(inventory.getCount(kit) < kitcount)
- {
- kitcount--;
- kitsopened++;
- return true;
- }
- return false;
- }
- public boolean deposit() {
- bank.open();
- bank.depositAll();
- return true;
- }
- public boolean withdraw() {
- if (!bank.isOpen()) {
- bank.open();
- bank.withdraw(kit, 4);
- bank.close();
- } else {
- if (bank.isOpen()) {
- bank.withdraw(kit, 4);
- }
- bank.close();
- sleep(50, 400);
- }
- kitcount = inventory.getCount(kit);
- return true;
- }
- private String formatTime(long millis) {
- long hours = millis / (1000 * 60 * 60);
- millis -= hours * (1000 * 60 * 60);
- long minutes = millis / (1000 * 60);
- millis -= minutes * (1000 * 60);
- long seconds = millis / 1000;
- return String.format("%02d", hours) + ":" + String.format("%02d", minutes) + ":" + String.format("%02d", seconds);
- }
- public void onRepaint(Graphics g1) {
- Graphics2D g = (Graphics2D) g1;
- g.setRenderingHints(antialiasing);
- int x = (int) mouse.getLocation().getX();
- int y = (int) mouse.getLocation().getY();
- g.setColor(color4);
- g.setStroke(stroke2);
- g.drawLine(x-6, y, x+6, y);
- g.drawLine(x, y-6, x, y+6);
- long millis = System.currentTimeMillis() - startTime;
- float hours = (float) millis / 3600000f;
- int profit = kitsopened * profitPerKit;
- int profitPerHour = (int) (profit / hours);
- String runtimeStr = formatTime(millis);
- String kitsopenedStr = Integer.toString(kitsopened);
- String profitStr = groupingFormat.format(profit);
- String profitPerHourStr = groupingFormat.format(profitPerHour);
- g.setColor(color1);
- g.fillRoundRect(275, 266, 218, 69, 16, 16);
- g.setColor(color2);
- g.setStroke(stroke1);
- g.drawRoundRect(275, 266, 218, 69, 16, 16);
- g.setFont(font1);
- g.drawString("DM Kit Opener", 286, 282);
- g.setFont(font2);
- g.drawString("v" + Double.toString(DMKITOPENER.class.getAnnotation(ScriptManifest.class).version()), 457, 283);
- g.setFont(font3);
- g.drawString("Profit/hour", 387, 324);
- g.drawString("Profit", 387, 308);
- g.drawString("Runtime", 283, 308);
- g.drawString("Kits opened", 283, 324);
- g.setFont(font4);
- g.setColor(color3);
- g.drawString(profitPerHourStr, 436, 324);
- g.drawString(profitStr, 436, 308);
- g.drawString(kitsopenedStr, 336, 324);
- g.drawString(runtimeStr, 336, 308);
- }
- @Override
- public int loop() {
- if (inventory.contains(kit)) {
- openKit();
- } else if (inventory.containsAll(content) && !inventory.contains(kit)) {
- deposit();
- } else if (!inventory.containsAll(content) && !inventory.contains(kit)) {
- withdraw();
- }
- return random(600, 1600);
- }
- }
Add Comment
Please, Sign In to add comment