Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.awt.BasicStroke;
- import java.awt.Color;
- import java.awt.Container;
- import java.awt.Font;
- import java.awt.Graphics;
- import java.awt.Graphics2D;
- import java.awt.Point;
- import java.awt.Rectangle;
- import java.awt.RenderingHints;
- import java.awt.event.ActionEvent;
- import java.awt.event.ActionListener;
- import java.awt.event.MouseEvent;
- import java.awt.event.MouseListener;
- import javax.swing.DefaultComboBoxModel;
- import javax.swing.GroupLayout;
- import javax.swing.JButton;
- import javax.swing.JComboBox;
- import javax.swing.JFrame;
- import javax.swing.JLabel;
- import javax.swing.LayoutStyle;
- import org.rsbot.event.listeners.PaintListener;
- import org.rsbot.script.Script;
- import org.rsbot.script.ScriptManifest;
- import org.rsbot.script.util.Timer;
- import org.rsbot.script.wrappers.*;
- import java.awt.*;
- @ScriptManifest(authors = { "Itz_Craze" }, name = "cSmither", version = 1.10, description = "AIO Varrock Smither")
- public class cSmither extends Script implements PaintListener, MouseListener{
- private int barID;
- private double barXP;
- private int barsUsed;
- private int expGained;
- private int startXP;
- private long startTime;
- private int anvilID = 2783;
- private int bankID = 782;
- private int interfaceID = 300;
- private int componentID;
- private int hammerID = 2347;
- RSTile banktile = new RSTile(3189, 3435);
- RSTile anviltile = new RSTile(3188, 3425);
- private boolean scroll = false;
- private int runs = 0;
- private static final Color MOUSE_COLOR = new Color(255, 255, 255),
- MOUSE_BORDER_COLOR = new Color(0, 0, 153),
- MOUSE_CENTER_COLOR = new Color(51, 255, 255);
- private boolean pressed = false;
- private int absoluteY = 0;
- private boolean guiwait = true;
- cSmitherGUI g = new cSmitherGUI();
- public boolean onStart(){
- startTime = System.currentTimeMillis();
- startXP = skills.getCurrentExp(skills.SMITHING);
- mouse.setSpeed(random(3, 7));
- g.setVisible(true);
- while(guiwait == true){
- sleep(500);
- }
- return true;
- }
- @Override
- public int loop() {
- if(walking.getEnergy() > 50 && walking.isRunEnabled() == false){
- walking.setRun(true);
- }
- if(inventory.getCount(barID) > 2){
- if(atBank()){
- walkToAnvil();
- } else if(atAnvil()){
- makeItems();
- }
- } else if(inventory.getCount(barID) <= 2){
- if(atBank()){
- useBank();
- } else {
- walkToBank();
- }
- }
- return 0;
- }
- private boolean atAnvil() {
- RSObject anvil = objects.getNearest(anvilID);
- if(anvil != null){
- if(anvil.isOnScreen()){
- return true;
- }
- }
- return false;
- }
- private void walkToBank() {
- walking.walkTileMM(banktile);
- sleep(1000, 1600);
- while(getMyPlayer().isMoving()){
- sleep(180, 400);
- }
- }
- private void useBank() {
- RSObject Bank = objects.getNearest(bankID);
- if(bank.isOpen()){
- bank.depositAllExcept(hammerID, barID);
- sleep(400, 700);
- if(bank.getCount(barID) <= 5){
- env.takeScreenshot(true);
- stopScript();
- }
- bank.withdraw(barID, 27);
- sleep(400, 700);
- bank.close();
- } else {
- Bank.interact("Use-quickly");
- sleep(600, 1000);
- }
- }
- private void makeItems() {
- RSItem bar = inventory.getItem(barID);
- RSObject anvil = objects.getNearest(anvilID);
- if(anvil != null && anvil.isOnScreen()){
- bar.interact("Use");
- sleep(180, 400);
- anvil.doClick();
- sleep(2000, 2400);
- if(interfaces.get(interfaceID).isValid()){
- if(scroll == false){
- interfaces.getComponent(interfaceID, componentID).interact("Make All");
- Timer t = new Timer(3000);
- while(t.isRunning()){
- if(getMyPlayer().getAnimation() != -1){
- t.reset();
- if(interfaces.canContinue()){
- interfaces.clickContinue();
- }
- }
- sleep(100);
- }
- runs++;
- } else {
- if(runs == 0){
- mouse.move(495, 276);
- mouse.click(true);
- interfaces.getComponent(interfaceID, componentID).interact("Make All");
- Timer t = new Timer(3000);
- while(t.isRunning()){
- if(getMyPlayer().getAnimation() != -1){
- t.reset();
- if(interfaces.canContinue()){
- interfaces.clickContinue();
- }
- }
- sleep(100);
- }
- } else {
- interfaces.getComponent(interfaceID, componentID).interact("Make All");
- Timer t = new Timer(3000);
- while(t.isRunning()){
- if(getMyPlayer().getAnimation() != -1){
- t.reset();
- if(interfaces.canContinue()){
- interfaces.clickContinue();
- }
- }
- sleep(100);
- }
- }
- runs++;
- }
- }
- }
- }
- private void walkToAnvil() {
- walking.walkTileMM(anviltile);
- sleep(1000, 1600);
- while(getMyPlayer().isMoving()){
- sleep(180, 400);
- }
- }
- private boolean atBank() {
- RSObject bank = objects.getNearest(bankID);
- if(bank != null){
- if(bank.isOnScreen()){
- return true;
- }
- }
- return false;
- }
- private void drawMouse(Graphics a) {
- ((Graphics2D) a).setRenderingHints(new RenderingHints(
- RenderingHints.KEY_ANTIALIASING,
- RenderingHints.VALUE_ANTIALIAS_ON));
- Point p = mouse.getLocation();
- Graphics2D spinG = (Graphics2D) a.create();
- Graphics2D spinGRev = (Graphics2D) a.create();
- Graphics2D spinG2 = (Graphics2D) a.create();
- spinG.setColor(MOUSE_BORDER_COLOR);
- spinGRev.setColor(MOUSE_COLOR);
- spinG.rotate(System.currentTimeMillis() % 2000d / 2000d * (360d) * 2
- * Math.PI / 180.0, p.x, p.y);
- spinGRev.rotate(System.currentTimeMillis() % 2000d / 2000d * (-360d)
- * 2 * Math.PI / 180.0, p.x, p.y);
- final int outerSize = 20;
- final int innerSize = 12;
- spinG.setStroke(new BasicStroke(1.0f, BasicStroke.CAP_ROUND,
- BasicStroke.JOIN_ROUND));
- spinGRev.setStroke(new BasicStroke(1.0f, BasicStroke.CAP_ROUND,
- BasicStroke.JOIN_ROUND));
- spinG.drawArc(p.x - (outerSize / 2), p.y - (outerSize / 2), outerSize,
- outerSize, 100, 75);
- spinG.drawArc(p.x - (outerSize / 2), p.y - (outerSize / 2), outerSize,
- outerSize, -100, 75);
- spinGRev.drawArc(p.x - (innerSize / 2), p.y - (innerSize / 2),
- innerSize, innerSize, 100, 75);
- spinGRev.drawArc(p.x - (innerSize / 2), p.y - (innerSize / 2),
- innerSize, innerSize, -100, 75);
- a.setColor(MOUSE_CENTER_COLOR);
- a.fillOval(p.x, p.y, 2, 2);
- spinG2.setColor(MOUSE_CENTER_COLOR);
- spinG2.rotate(System.currentTimeMillis() % 2000d / 2000d * 360d
- * Math.PI / 180.0, p.x, p.y);
- spinG2.setStroke(new BasicStroke(1.0f, BasicStroke.CAP_ROUND,
- BasicStroke.JOIN_ROUND));
- spinG2.drawLine(p.x - 5, p.y, p.x + 5, p.y);
- spinG2.drawLine(p.x, p.y - 5, p.x, p.y + 5);
- }
- //START: Code generated using Enfilade's Easel
- private final Color color1 = new Color(0, 0, 102);
- private final Color color2 = new Color(0, 0, 0);
- private final Color color3 = new Color(255, 255, 255);
- private final BasicStroke stroke1 = new BasicStroke(1);
- private final Font font1 = new Font("Arial", 0, 18);
- private final Font font2 = new Font("Arial", 0, 13);
- public void onRepaint(Graphics g1) {
- drawMouse(g1);
- expGained = skills.getCurrentExp(skills.SMITHING) - startXP;
- long milis = System.currentTimeMillis() - startTime;
- long hours = milis / (1000 * 60 * 60);
- milis -= hours * (1000 * 60 * 60);
- long minutes = milis / (1000 * 60);
- milis -= minutes * (1000 * 60);
- long seconds = milis / (1000);
- milis = seconds * 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;
- barsUsed = (int) (expGained / barXP);
- Graphics2D g = (Graphics2D)g1;
- g.setColor(color1);
- g.fillRoundRect(8, 11, 171, 104, 16, 16);
- g.setColor(color2);
- g.setStroke(stroke1);
- g.drawRoundRect(8, 11, 171, 104, 16, 16);
- g.setFont(font1);
- g.setColor(color3);
- g.drawString("cSmither", 50, 30);
- g.setFont(font2);
- g.drawString("Time Run: " + hours + ":" + minutes + ":" + seconds, 13, 50);
- g.drawString("Bars Used: " + barsUsed, 13, 70);
- g.drawString("XP Gained: " + expGained, 13, 90);
- g.drawString("XP Per Hr: " + xphour, 13, 110);
- }
- //END: Code generated using Enfilade's Easel
- /**
- * @author Alex Martin
- */
- public class cSmitherGUI extends JFrame {
- public cSmitherGUI() {
- initComponents();
- }
- private void button1ActionPerformed(ActionEvent e) {
- String bar = comboBox1.getSelectedItem().toString();
- if(bar.equals("Bronze")){
- barID = 2349;
- barXP = 12.5;
- } else if(bar.equals("Iron")){
- barID = 2351;
- barXP = 25;
- } else if(bar.equals("Steel")){
- barID = 2353;
- barXP = 37.5;
- } else if(bar.equals("Mithril")){
- barID = 2359;
- barXP = 50;
- } else if(bar.equals("Adamant")){
- barID = 2361;
- barXP = 62.5;
- } else if(bar.equals("Rune")){
- barID = 2363;
- barXP = 75;
- }
- String item = comboBox2.getSelectedItem().toString();
- if(item.equals("Dagger")){
- componentID = 18;
- } else if(item.equals("Hatchet")){
- componentID = 26;
- } else if(item.equals("Mace")){
- componentID = 34;
- } else if(item.equals("Medium Helm")){
- componentID = 42;
- } else if(item.equals("Crossbow Bolts")){
- componentID = 50;
- } else if(item.equals("Sword")){
- componentID = 58;
- } else if(item.equals("Dart Tips")){
- componentID = 66;
- } else if(item.equals("Nails")){
- componentID = 74;
- } else if(item.equals("Wire")){
- componentID = 82;
- } else if(item.equals("Arrow Tips")){
- componentID = 106;
- } else if(item.equals("Scimitar")){
- componentID = 114;
- } else if(item.equals("Crossbow Limbs")){
- componentID = 122;
- } else if(item.equals("Longsword")){
- componentID = 130;
- } else if(item.equals("Throwing Knife")){
- componentID = 138;
- } else if(item.equals("Full Helm")){
- componentID = 146;
- } else if(item.equals("Square Shield")){
- componentID = 154;
- } else if(item.equals("War Hammer")){
- componentID = 178;
- } else if(item.equals("Battle Axe")){
- componentID = 186;
- } else if(item.equals("Chainbody")){
- componentID = 194;
- scroll = true;
- } else if(item.equals("Kite Shield")){
- componentID = 202;
- scroll = true;
- } else if(item.equals("Claws")){
- componentID = 210;
- scroll = true;
- } else if(item.equals("2-Handed Sword")){
- componentID = 218;
- scroll = true;
- } else if(item.equals("Plateskirt")){
- componentID = 226;
- scroll = true;
- } else if(item.equals("Platelegs")){
- componentID = 234;
- scroll = true;
- } else if(item.equals("Platebody")){
- componentID = 242;
- scroll = true;
- } else if(item.equals("Pickaxe")){
- componentID = 267;
- scroll = true;
- }
- guiwait = false;
- g.dispose();
- }
- private void initComponents() {
- // JFormDesigner - Component initialization - DO NOT MODIFY //GEN-BEGIN:initComponents
- // Generated using JFormDesigner Evaluation license - Alex Martin
- button1 = new JButton();
- label1 = new JLabel();
- label2 = new JLabel();
- comboBox1 = new JComboBox();
- label3 = new JLabel();
- comboBox2 = new JComboBox();
- label4 = new JLabel();
- //======== this ========
- Container contentPane = getContentPane();
- //---- button1 ----
- button1.setText("Start");
- button1.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- button1ActionPerformed(e);
- }
- });
- //---- label1 ----
- label1.setText("cSmither");
- label1.setFont(new Font("Tahoma", Font.PLAIN, 26));
- //---- label2 ----
- label2.setText("Bar to Use:");
- label2.setFont(new Font("Tahoma", Font.PLAIN, 18));
- //---- comboBox1 ----
- comboBox1.setModel(new DefaultComboBoxModel(new String[] {
- "Bronze",
- "Iron",
- "Steel",
- "Mithril",
- "Adamant",
- "Rune"
- }));
- //---- label3 ----
- label3.setText("Item To Make: ");
- label3.setFont(new Font("Tahoma", Font.PLAIN, 18));
- //---- comboBox2 ----
- comboBox2.setModel(new DefaultComboBoxModel(new String[] {
- "Dagger",
- "Hatchet",
- "Mace",
- "Medium Helm",
- "Crossbow Bolts",
- "Sword",
- "Dart Tips",
- "Nails",
- "Wire",
- "Arrow Tips",
- "Scimitar",
- "Crossbow Limbs",
- "Longsword",
- "Throwing Knife",
- "Full Helm",
- "Square Shield",
- "War Hammer",
- "Battle Axe",
- "Chainbody",
- "Kite Shield",
- "Claws",
- "2-Handed Sword",
- "Plateskirt",
- "Platelegs",
- "Platebody",
- "Pickaxe"
- }));
- //---- label4 ----
- label4.setText("By: Itz_Craze");
- label4.setFont(new Font("Tahoma", Font.PLAIN, 14));
- GroupLayout contentPaneLayout = new GroupLayout(contentPane);
- contentPane.setLayout(contentPaneLayout);
- contentPaneLayout.setHorizontalGroup(
- contentPaneLayout.createParallelGroup()
- .addGroup(GroupLayout.Alignment.TRAILING, contentPaneLayout.createSequentialGroup()
- .addContainerGap()
- .addComponent(label4)
- .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, 241, Short.MAX_VALUE)
- .addComponent(button1, GroupLayout.PREFERRED_SIZE, 88, GroupLayout.PREFERRED_SIZE)
- .addGap(33, 33, 33))
- .addGroup(contentPaneLayout.createSequentialGroup()
- .addGap(137, 137, 137)
- .addComponent(label1)
- .addContainerGap(154, Short.MAX_VALUE))
- .addGroup(contentPaneLayout.createSequentialGroup()
- .addGap(48, 48, 48)
- .addGroup(contentPaneLayout.createParallelGroup(GroupLayout.Alignment.LEADING, false)
- .addGroup(contentPaneLayout.createSequentialGroup()
- .addComponent(label3)
- .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
- .addComponent(comboBox2, 0, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
- .addGroup(contentPaneLayout.createSequentialGroup()
- .addComponent(label2)
- .addGap(18, 18, 18)
- .addComponent(comboBox1, GroupLayout.PREFERRED_SIZE, 167, GroupLayout.PREFERRED_SIZE)))
- .addContainerGap(70, Short.MAX_VALUE))
- );
- contentPaneLayout.setVerticalGroup(
- contentPaneLayout.createParallelGroup()
- .addGroup(GroupLayout.Alignment.TRAILING, contentPaneLayout.createSequentialGroup()
- .addGap(21, 21, 21)
- .addComponent(label1)
- .addGap(25, 25, 25)
- .addGroup(contentPaneLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
- .addComponent(label2)
- .addComponent(comboBox1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
- .addGap(36, 36, 36)
- .addGroup(contentPaneLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
- .addComponent(label3)
- .addComponent(comboBox2, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
- .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, 53, Short.MAX_VALUE)
- .addGroup(contentPaneLayout.createParallelGroup(GroupLayout.Alignment.TRAILING)
- .addComponent(button1, GroupLayout.PREFERRED_SIZE, 37, GroupLayout.PREFERRED_SIZE)
- .addComponent(label4))
- .addGap(21, 21, 21))
- );
- pack();
- setLocationRelativeTo(getOwner());
- // JFormDesigner - End of component initialization //GEN-END:initComponents
- }
- // JFormDesigner - Variables declaration - DO NOT MODIFY //GEN-BEGIN:variables
- // Generated using JFormDesigner Evaluation license - Alex Martin
- private JButton button1;
- private JLabel label1;
- private JLabel label2;
- private JComboBox comboBox1;
- private JLabel label3;
- private JComboBox comboBox2;
- private JLabel label4;
- // JFormDesigner - End of variables declaration //GEN-END:variables
- }
- @Override
- public void mouseClicked(MouseEvent arg0) {
- // TODO Auto-generated method stub
- }
- @Override
- public void mouseEntered(MouseEvent arg0) {
- // TODO Auto-generated method stub
- }
- @Override
- public void mouseExited(MouseEvent arg0) {
- // TODO Auto-generated method stub
- }
- @Override
- public void mousePressed(MouseEvent arg0) {
- Point mp = arg0.getPoint();
- final Rectangle toggleRectangle = new Rectangle(493, absoluteY + 3, 16,
- 15);
- if (toggleRectangle.contains(mp)) {
- pressed = !pressed;
- }
- }
- @Override
- public void mouseReleased(MouseEvent arg0) {
- // TODO Auto-generated method stub
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement