rendered paste bodyimport java.awt.BasicStroke;import java.awt.Color;import java.awt.Font;import java.awt.Graphics;import java.awt.Graphics2D;import java.awt.GridLayout;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import javax.swing.JButton;import javax.swing.JComboBox;import javax.swing.JFrame;import javax.swing.JLabel;import org.rsbot.event.events.ServerMessageEvent;import org.rsbot.event.listeners.PaintListener;import org.rsbot.event.listeners.ServerMessageListener;import org.rsbot.script.Script;import org.rsbot.script.ScriptManifest;import org.rsbot.script.wrappers.RSArea;import org.rsbot.script.wrappers.RSComponent;import org.rsbot.script.wrappers.RSItem;import org.rsbot.script.wrappers.RSNPC;@ScriptManifest(authors = "aonbyte", keywords = "Money, Junk", name = "Fire Arrow Maker", version = 1.0, description = "Makes fire arrows in the underground pass.")public class FireArrowMaker extends Script implements PaintListener, ServerMessageListener { //Possible inventory states private enum Invy{ GOOD, NO_ARROWS, NO_CLOTH, NO_SPACE }; private final String[] ARROW_TYPE = {"Bronze", "Iron", "Steel", "Mithril", "Adamant", "Rune", "Dragon"}; //Arrow ID Constants private final int[] REGULAR_ARROW_ID = {882, 884, 886, 888, 890, 892, 11212}; private final int[] FIRE_ARROW_ID = {942, 2532, 2354, 2536, 2538, 2540, 11217}; //Other ID Constants private int NPC_ID = 973; private int CLOTH_ID = 1485; //Placeholders private int arrowID; private int fireArrowID; private String arrowType; //Valid player zone. If player is not in the area then script stops. private RSArea playerArea = new RSArea(2447, 9712, 2456, 9718); //Paint variables private long runTime, startTime; private long hours, minutes, seconds; private long regArrowPrice, fireArrowPrice, arrowsMadeHr, arrowsMade; private long profitEach, profitTotal, profitHr; //Paint private final Color color1 = new Color(201, 0, 5); private final Color color2 = new Color(0, 0, 0); private final Color color3 = new Color(254, 254, 254); private final BasicStroke stroke1 = new BasicStroke(1); private final Font font1 = new Font("Arial", 0, 14); private final Font font2 = new Font("Arial", 0, 12); public void onRepaint(Graphics g1) { runTime = (System.currentTimeMillis() - startTime) / 1000; hours = runTime / 3600; minutes = (runTime % 3600) / 60; seconds = runTime - ((hours * 3600) + (minutes * 60)); profitEach = fireArrowPrice - regArrowPrice; profitTotal = arrowsMade * profitEach; arrowsMadeHr = (int) ( ((double) arrowsMade/runTime) * 3600 ) ; profitHr = profitEach * arrowsMadeHr; Graphics2D g = (Graphics2D)g1; g.setColor(color1); g.fillRoundRect(6, 5, 506, 106, 16, 16); g.setColor(color2); g.setStroke(stroke1); g.drawRoundRect(6, 5, 506, 106, 16, 16); g.setFont(font1); g.setColor(color3); g.drawString("Aonbyte's Fire Arrow Maker", 164, 24); g.setFont(font2); g.drawString("Arrow Type: " + arrowType, 20, 50); g.drawString("Regular Arrow Price (Max): " + regArrowPrice, 20, 70); g.drawString("Fire Arrow Price(Mid): " + fireArrowPrice, 20, 85); g.drawString("Profit Per Arrow: " + profitEach, 20, 105); g.drawString("Profit (p/hr): " + profitHr, 270, 105); g.drawString("Total Profit: " + profitTotal, 270, 85); g.drawString("Hours: " + hours, 425, 70); g.drawString("Seconds: " + seconds, 425, 105); g.drawString("Minutes: " + minutes, 425, 85); g.drawString("Arrows Made: " + arrowsMade, 270, 50); g.drawString("Arrows Made (p/hr): " + arrowsMadeHr, 270, 70); g.drawString("Time Running: " , 425, 50); } public void serverMessageRecieved(ServerMessageEvent e) { if(e.getMessage().equals("You wrap the damp cloth around the arrow head...") || e.getMessage().equals("You wrap the damp cloth around the arrow head.")) arrowsMade++; } public boolean onStart() { GUI gui = new GUI(); while (gui.isVisible()) { sleep(1000); } startTime = System.currentTimeMillis(); regArrowPrice = grandExchange.getMaxPrice(arrowID); fireArrowPrice = grandExchange.getMarketPrice(fireArrowID); mouse.setSpeed(random(8,9)); return true; } public void onFinish() { } private boolean inArea() { //Returns true if player is in the valid script area. if(playerArea.contains(getMyPlayer().getLocation())) return true; log("Not in correct area. Stopping script."); return false; } private Invy getInventoryState() { //Returns the state of the player's inventory. if(!inventory.contains(arrowID)) { log("No arrows in inventory."); return Invy.NO_ARROWS; } if(!inventory.contains(CLOTH_ID)) { if(inventory.isFull()) return Invy.NO_SPACE; else return Invy.NO_CLOTH; } if(!inventory.contains(fireArrowID)) { if(inventory.isFull()) return Invy.NO_SPACE; } return Invy.GOOD; } private boolean getCloth() { //Talks to the NPC and gets cloth. RSNPC dude = npcs.getNearest(NPC_ID); RSComponent clickHere1 = interfaces.getComponent(64, 5); RSComponent clickHere2 = interfaces.getComponent(242,6); while(!dude.isOnScreen()) camera.turnToCharacter(dude); dude.doAction("Talk-to"); int tries = 0; while(!inventory.contains(CLOTH_ID)) { clickHere1.doClick(); clickHere2.doClick(); sleep(random(25,100)); tries++; if(tries == 40) { dude.doAction("Talk-to"); tries = 0; } } return true; } private boolean makeArrow() { //Uses the damp cloth with an arrow to make a fire arrow. RSItem cloth = inventory.getItem(CLOTH_ID); RSItem arrow = inventory.getItem(arrowID); inventory.useItem(cloth, arrow); sleep(random(1000,1200)); return true; } public int loop() { if(!inArea()) return -1; switch(getInventoryState()) { case NO_SPACE: log("Not enough space in inventory to continue."); return -1; case NO_ARROWS: log("Stopping script"); return -1; case NO_CLOTH: getCloth(); break; case GOOD: makeArrow(); break; } return random(50,100); } class GUI extends JFrame { private static final long serialVersionUID = 4491918393383484729L; private JComboBox arrow_menu; private JLabel label; private JButton startButton, closeButton; public GUI() { createAndShowGUI(); setDefaultCloseOperation(DISPOSE_ON_CLOSE); } private void createAndShowGUI() { arrow_menu = new JComboBox(ARROW_TYPE); label = new JLabel("Arrow Type: "); startButton = new JButton("Start"); closeButton = new JButton("Close script"); startButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { arrowID = REGULAR_ARROW_ID[arrow_menu.getSelectedIndex()]; fireArrowID = FIRE_ARROW_ID[arrow_menu.getSelectedIndex()]; arrowType = ARROW_TYPE[arrow_menu.getSelectedIndex()]; dispose(); } }); closeButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { dispose(); stopScript(); } }); setSize(350, 200); setLayout(new GridLayout(0, 2)); add(label); add(arrow_menu); add(startButton); add(closeButton); setVisible(true); } }}