Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.awt.*;
- import java.awt.event.*;
- import java.awt.event.MouseListener;
- import java.awt.image.BufferedImage;
- import javax.imageio.ImageIO;
- import java.io.IOException;
- import java.net.URL;
- import java.lang.String.*;
- import org.rsbot.event.events.MessageEvent;
- import org.rsbot.event.listeners.PaintListener;
- import org.rsbot.event.listeners.MessageListener;
- import org.rsbot.script.*;
- import org.rsbot.script.wrappers.*;
- import org.rsbot.script.methods.*;
- import org.rsbot.script.wrappers.RSTilePath;
- import org.rsbot.script.util.Timer;
- @ScriptManifest ( authors = { "Ministry" },
- keywords = { "Crafting, Smelting, Tiara" },
- name = "<html><b>MinistryOfTiaras</b></html>",
- description = "Smelts Silver ore to bars and crafts Tiaras",
- version = 1.0 )
- @SuppressWarnings("static-access")
- public class MinistryOfTiaras extends Script implements PaintListener, MouseListener, MessageListener {
- private static int tiaras, percentTNL,startLvlC, startLvlS, expHourC, expToLvlC,
- startExpC, startExpS, lvlsGainedC, currentLvlC, tiarasHr,
- expGainedC, expGainedS, currentExpC, currentExpS, lvldC;
- private final static int bar_ID = 2355, tiara_ID = 5525, mould_ID = 5523, ore_ID = 442, furnace_ID = 11666, booth_ID = 35647;
- private final double tXP = 52.5;
- private boolean showPaint = true;
- private Timer idle;
- private long startTime, millis, hours, minutes, seconds, STL, MTL, HTL, currentSystemTime;
- private float sXP, mXP, hXP;
- private String status = "";
- private BufferedImage normal = null, clicked = null;
- final ScriptManifest update = getClass().getAnnotation(ScriptManifest.class);
- private final RSArea bankArea = new RSArea(new RSTile(3265, 3160), new RSTile(3273, 3175));
- private final RSArea furnaceArea = new RSArea(new RSTile(3274, 3184), new RSTile(3279, 3188));
- private enum State { Deposit, Withdraw, To_Bank, To_Furnace, Smelt, Craft, Wait, Mould, antiBan }
- private enum LocationStates { AT_BANK, AT_FURNACE }
- RSTile[] toBank = {new RSTile(3277, 3176), new RSTile(3271, 3167)};
- RSTile[] toFurnace = {new RSTile(3278, 3177), new RSTile(3275, 3186)};
- private RSTilePath pathToBank;
- private RSTilePath pathToFurnace;
- @Override
- public boolean onStart() {
- status = "Loading...";
- startTime = System.currentTimeMillis();
- startExpC = skills.getCurrentExp(skills.CRAFTING);
- startExpS = skills.getCurrentExp(skills.SMITHING);
- startLvlC = skills.getCurrentLevel(skills.CRAFTING);
- startLvlS = skills.getCurrentLevel(skills.SMITHING);
- mouse.setSpeed(random(8, 11));
- idle = new Timer (3000);
- try {
- final URL cursorURL = new URL("http://i53.tinypic.com/28b7bf9.png");
- final URL clickedURL = new URL("http://i55.tinypic.com/30vkjz9.png");
- normal = ImageIO.read(cursorURL);
- clicked = ImageIO.read(clickedURL);
- } catch (Exception e) {
- log.severe("Error obtaining custom cursor.");
- }
- log("Welcome to Ministry Of Tiaras v" + update.version());
- return true;
- }
- private void antiBan() {
- int b = random(0, 24);
- switch (b) {
- case 1:
- if (random(0, 10) == 5) {
- mouse.moveSlightly();
- sleep(200, 600);
- mouse.moveRandomly(150, 350);
- }
- break;
- case 2:
- if (random(0, 13) == 2) {
- camera.setAngle(random(30, 70));
- sleep(400, 1200);
- }
- break;
- case 3:
- if (random(0, 24) == 6) {
- mouse.moveOffScreen();
- sleep(1200, 2000);
- }
- break;
- case 4:
- if (random(0, 18) == 3) {
- game.openTab(1);
- skills.doHover(skills.INTERFACE_CRAFTING);
- sleep(1100, 2400);
- if (lvldC == 1) {
- mouse.click(true);
- lvldC = 0;
- }
- sleep(500, 750);
- }
- break;
- case 5:
- if (random(0, 15) == 4) {
- mouse.moveRandomly(8);
- sleep(1400, 2400);
- }
- break;
- case 6:
- if (random(0, 19) == 5) {
- game.openTab(random(random(4, 7), random(3, 5)));
- mouse.sleep(1500);
- sleep(400, 500);
- }
- case 7:
- if(random(0,15) == 3){
- mouse.move(535, 60);
- mouse.click(true);
- sleep(1000, 2500);
- }
- break;
- case 8:
- if(random(0, 19) == 8) {
- game.openTab(1);
- skills.doHover(skills.INTERFACE_SMITHING);
- sleep(1800, 3150);
- }
- default:
- break;
- }
- }
- private void runEnable() {
- if(walking.isRunEnabled() == false && walking.getEnergy() >= random(45, 67)) {
- walking.setRun(true);
- }
- }
- public void messageReceived(MessageEvent e) {
- String x = e.getMessage().toLowerCase();
- if (x.contains("gained a crafting")) {
- lvldC = 1;
- }
- }
- private boolean atBank(){
- return bankArea.contains(getMyPlayer().getLocation());
- }
- private boolean atFurnace() {
- return furnaceArea.contains(getMyPlayer().getLocation());
- }
- private void getMould() {
- RSTilePath pathToBank = walking.newTilePath(toBank);
- RSObject booth = objects.getNearest(booth_ID);
- status = "Getting Mould";
- if(!atBank() && inventory.getCount(mould_ID) == 0) {
- pathToBank.traverse();
- sleep(400);
- if(booth.isOnScreen()) {
- bank.open();
- if(bank.isOpen() && bank.getCount(mould_ID) == 0) {
- log.severe("Cannot find tiara mould!");
- stopScript(true);
- }
- if (bank.isOpen() && bank.getCount(mould_ID) >= 1 && !inventory.containsOneOf(mould_ID)) {
- bank.depositAll();
- sleep(random(460, 590));
- bank.withdraw(mould_ID, 1);
- sleep(random(200, 400));
- withdraw();
- }
- }
- }
- }
- private void toBank() {
- status = "Walking to Bank";
- RSTilePath pathToBank = walking.newTilePath(toBank);
- pathToBank.traverse();
- sleep(200);
- }
- private void toFurnace() {
- status = "Walking to Furnace";
- RSTilePath pathToFurnace = walking.newTilePath(toFurnace);
- pathToFurnace.traverse();
- sleep(200);
- }
- private boolean deposit() {
- status = "Depositing...";
- RSObject booth = objects.getNearest(booth_ID);
- camera.turnTo(booth);
- bank.open();
- sleep(320, 500);
- if (bank.isOpen() && inventory.contains(tiara_ID)) {
- bank.depositAllExcept(mould_ID);
- mouse.moveOffScreen();
- sleep(400, 600);
- }
- return true;
- }
- private void withdraw() {
- status = "Withdrawing...";
- RSObject booth = objects.getNearest(booth_ID);
- int w = random(1, 2);
- camera.turnTo(booth);
- bank.open();
- if (!inventory.contains(mould_ID)) {
- sleep(400);
- getMould();
- } else {
- if (bank.isOpen() && bank.getCount(ore_ID) < 27) {
- sleep(random(850, 1400));
- log.severe("We have ran out of ore! Stopping script.");
- stopScript(true);
- } else {
- if (bank.isOpen() && bank.getCount(ore_ID) >= 27 && !inventory.contains(ore_ID)) {
- sleep(400, 550);
- bank.withdraw(ore_ID, 27);
- mouse.moveRandomly(8);
- sleep(150, 400);
- if (random(1,2) == 1) {
- bank.close(); }
- else {
- toFurnace(); }
- }
- }
- }
- }
- private void smelt() {
- status = "Smelting";
- RSItem ore = inventory.getItem(ore_ID);
- RSObject furnace = objects.getNearest(furnace_ID);
- if (!interfaces.getComponent(905, 14).isValid() && inventory.contains(ore_ID) && idle.getRemaining() <= 500) {
- inventory.useItem(ore, furnace);
- sleep(random(2400, 2600));
- }
- if (interfaces.getComponent(905, 14).isValid() && idle.getRemaining() <= 500) {
- interfaces.getComponent(905, 14).doAction("Make All");
- while(players.getMyPlayer().getAnimation() == 3243) {
- camera.moveRandomly(650);
- mouse.moveRandomly(4);
- }
- }
- }
- private void craft() {
- status = "Crafting";
- RSItem bar = inventory.getItem(bar_ID);
- RSObject furnace = objects.getNearest(furnace_ID);
- if (!interfaces.getComponent(438, 45).isValid() && idle.getRemaining() <= 500) {
- inventory.useItem(bar, furnace);
- sleep(random(2400, 2600));
- }
- if (interfaces.getComponent(438, 45).isValid() && idle.getRemaining() <= 500) {
- interfaces.getComponent(438, 45).doAction("Make All");
- sleep(random(400,600));
- while(players.getMyPlayer().getAnimation() == 3243) {
- camera.moveRandomly(650);
- mouse.moveRandomly(4);
- }
- }
- }
- private State checkState() {
- RSObject furnace = objects.getNearest(furnace_ID);
- RSObject booth = objects.getNearest(booth_ID);
- if (game.isLoggedIn()) {
- if (inventory.getCount(mould_ID) == 0) {
- return State.Mould;
- }
- if (!atBank() && inventory.getCount(tiara_ID) == 27 && !inventory.contains(bar_ID)) {
- return State.To_Bank;
- }
- if (booth.isOnScreen() && players.getMyPlayer().getAnimation() == -1 && !bank.isOpen() && inventory.getCount(tiara_ID) == 27) {
- return State.Deposit;
- }
- if (booth.isOnScreen() && !inventory.contains(ore_ID) && !inventory.contains(bar_ID) && !inventory.contains(tiara_ID)) {
- return State.Withdraw;
- }
- if (atFurnace() && furnace.isOnScreen() && !inventory.contains(ore_ID) && inventory.getCount(bar_ID) >= 27 && idle.getRemaining() < 500) {
- return State.Craft;
- }
- if (furnace.isOnScreen() && inventory.getCount(ore_ID) >= 27 && idle.getRemaining() < 500) {
- return State.Smelt;
- }
- if (!atFurnace() && inventory.getCount(ore_ID) >= 27 || inventory.getCount(bar_ID) >= 27) {
- return State.To_Furnace;
- } else {
- return State.antiBan;
- }
- }
- return State.Wait;
- }
- public int loop() {
- if (interfaces.canContinue()) {
- interfaces.clickContinue();
- }
- if (!getMyPlayer().isIdle() || players.getMyPlayer().getAnimation() == 3243) {
- idle.reset();
- }
- runEnable();
- antiBan();
- switch (checkState()) {
- case Mould:
- getMould();
- return random (150, 750);
- case Smelt:
- smelt();
- return random (150, 750);
- case Craft:
- craft();
- return random (150, 750);
- case To_Bank:
- toBank();
- return random (150, 750);
- case Deposit:
- deposit();
- return random (150, 750);
- case Withdraw:
- withdraw();
- return random (150, 750);
- case To_Furnace:
- toFurnace();
- return random (150, 750);
- case Wait:
- sleep(random(400, 500));
- return random (150, 750);
- case antiBan:
- antiBan();
- return random (150, 750);
- }
- return (random(150, 750));
- }
- private Image getImage(String url) {
- try {
- return ImageIO.read(new URL(url));
- } catch(IOException e) {
- return null;
- }
- }
- private final Color color1 = new Color(255, 255, 255);
- private final Color color2 = new Color(204, 0, 0, 135);
- private final Color color3 = new Color(51, 204, 0, 135);
- private final Color color4 = new Color(0, 0, 0, 135);
- private final BasicStroke stroke1 = new BasicStroke(1);
- private final Font font1 = new Font("Arial", 1, 14);
- private final Font font2 = new Font("Arial", 1, 12);
- private final Font font3 = new Font("Arial", 0, 10);
- Rectangle tab1 = new Rectangle(496, 345, 30, 30);
- private final Image Simg = getImage("http://i52.tinypic.com/21jaich.png");
- private final Image Himg = getImage("http://i56.tinypic.com/2502r28.png");
- public void mouseClicked(MouseEvent e){
- if(tab1.contains(e.getPoint())){
- showPaint = !showPaint;
- }
- }
- public void mouseEntered(MouseEvent e){
- }
- public void mouseExited(MouseEvent e){
- }
- public void mouseReleased(MouseEvent e){
- }
- public void mousePressed(MouseEvent e){
- }
- public void onRepaint(Graphics g1) {
- millis = System.currentTimeMillis() - startTime;
- hours = millis / (1000 * 60 * 60);
- millis -= hours * (1000 * 60 * 60);
- minutes = millis / (1000 * 60);
- millis -= minutes * (1000 * 60);
- seconds = millis / 1000;
- currentExpC = skills.getCurrentExp(skills.CRAFTING);
- currentExpS = skills.getCurrentExp(skills.SMITHING);
- currentLvlC = skills.getCurrentLevel(skills.CRAFTING);
- expToLvlC = skills.getExpToNextLevel(Skills.CRAFTING);
- percentTNL = skills.getPercentToNextLevel(skills.CRAFTING);
- currentSystemTime = System.currentTimeMillis();
- lvlsGainedC = currentLvlC-startLvlC;
- expGainedC = currentExpC-startExpC;
- expGainedS = currentExpS-startExpS;
- expHourC = (int) ((expGainedC) * 3600000D / (currentSystemTime - startTime));
- tiarasHr = (int) ((tiarasHr) * 3600000D/ (System.currentTimeMillis() - startTime));
- tiaras = (int) ((currentExpC - startExpC) / tXP);
- final int percentBar = (int) (skills.getPercentToNextLevel(Skills.CRAFTING)*5.16);
- if (sXP > 0) {
- STL = (int) (expToLvlC / sXP);
- }
- if (STL >= 60) {
- MTL = STL / 60;
- STL -= MTL * 60;
- } else {
- MTL = 0;
- }
- if (MTL >= 60) {
- HTL = MTL / 60;
- MTL -= HTL * 60;
- } else {
- HTL = 0;
- }
- if (game.isLoggedIn() && !game.isWelcomeScreen()) {
- Graphics2D g = (Graphics2D)g1;
- if (showPaint == false) {
- g.drawImage(Simg, 496, 345, null);
- }
- if (showPaint == true) {
- g.drawImage(Himg, 496, 345, null);
- g.setColor(color1);
- g.setStroke(stroke1);
- g.setColor(color2);
- g.fillRect(0, 480, 516, 27);
- g.setColor(color3);
- g.fillRect(0, 480, percentBar, 27);
- g.setColor(color4);
- g.fillRect(549, 312, 183, 150);
- g.drawRect(549, 312, 183, 150);
- g.setFont(font1);
- g.setColor(color1);
- g.drawString("Ministry Of Tiaras", 564, 330);
- g.drawString( percentTNL +"%", 258, 498);
- g.setFont(font2);
- g.drawString("v" +update.version(), 693, 330);
- g.drawString("Status : " + status , 564, 456);
- g.setFont(font3);
- g.drawString("Tiaras Crafted : " +tiaras, 564, 348);
- g.drawString("Tiaras p/hr : " +tiarasHr, 564, 363);
- g.drawString("Crafting Exp : " + expGainedC, 564, 378);
- g.drawString("Craft Exp p/hr : " + expHourC, 564, 393);
- g.drawString("Smithing Exp : " + expGainedS, 564, 408);
- g.drawString("Current Level : " +currentLvlC + "(+" +lvlsGainedC +")", 564, 423);
- g.drawString("Runtime : " +hours + ":" + minutes + ":" + seconds, 564, 438);
- }
- if (clicked != null) {
- final int mx = (int)mouse.getLocation().getX();
- final int my = (int)mouse.getLocation().getY();
- final long mpt = System.currentTimeMillis() - mouse.getPressTime();
- if (mouse.getPressTime() == -1 || mpt >= 300)
- g.drawImage(normal, mx - 10, my - 6, null);
- if (mpt < 300)
- g.drawImage(clicked, mx - 10, my - 6, null);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment