Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import org.rsbot.event.listeners.PaintListener;
- import org.rsbot.script.Script;
- import org.rsbot.script.ScriptManifest;
- import org.rsbot.script.methods.Game;
- import org.rsbot.script.methods.Skills;
- import org.rsbot.script.wrappers.RSArea;
- import org.rsbot.script.wrappers.RSItem;
- import org.rsbot.script.wrappers.RSObject;
- import org.rsbot.script.wrappers.RSTile;
- import java.awt.*;
- import java.awt.event.MouseEvent;
- import java.awt.event.MouseListener;
- import java.util.Date;
- @ScriptManifest(authors = {"TechGuard"}, keywords = "Smithing", name = "TechSmither", version = 1.0, description = "Smelts Everything at Al Kharid")
- public class TechSmither extends Script implements PaintListener, MouseListener {
- public boolean running, usedBank = false;
- public long startTime;
- public int startExp = 0, startLevel = 0, gainedExp = 0, gainedLevel = 0,
- smeltedBars = 0, barID = 0, runEnergy = 50;
- public int[] oreID;
- RSTile bankTile, furnaceTile;
- RSArea bankArea, furnaceArea;
- public boolean onStart(){
- camera.setPitch(true);
- camera.setPitch(true);
- startTime = System.currentTimeMillis();
- startExp = skills.getCurrentExp(Skills.SMITHING);
- startLevel = skills.getCurrentLevel(Skills.SMITHING);
- trentCrafterGUI g = new trentCrafterGUI();
- g.setVisible(true);
- while(g.isVisible()){
- sleep(100);
- }
- running = true;
- Date date = new Date(startTime);
- sm("Started at "+String.format("%02d:%02d:%02d", date.getHours(), date.getMinutes(), date.getSeconds()));
- return true;
- }
- public void onFinish(){
- running = false;
- Date date = new Date(System.currentTimeMillis());
- sm("Stopped at "+String.format("%02d:%02d:%02d", date.getHours(), date.getMinutes(), date.getSeconds()));
- Date date2 = new Date(System.currentTimeMillis()-startTime);
- sm("Runned for "+String.format("%02d:%02d:%02d", date2.getHours(), date2.getMinutes(), date2.getSeconds()));
- }
- public void sm(String s){
- log(s);
- }
- public boolean onBreakStart(){
- running = false;
- return true;
- }
- public void onBreakFinish(){
- running = true;
- }
- public void mouseClicked(MouseEvent m) {
- }
- public void mouseEntered(MouseEvent m) {
- }
- public void mouseExited(MouseEvent m) {
- }
- public void mousePressed(MouseEvent m) {
- }
- public void mouseReleased(MouseEvent m) {
- }
- public void antiBan(){
- int rand = random(0, 1099);
- if (rand < 99) {
- runEnergy = random(30, 100);
- } else if (rand >= 99 && rand < 199) {
- camera.setAngle(random(1, 360));
- } else if (rand >= 199 && rand < 299) {
- mouse.move(random(1, 770), random(1, 550));
- } else if (rand >= 299 && rand < 399) {
- mouse.move(random(1, 770), random(1, 550));
- } else if (rand >= 399 && rand < 499) {
- mouse.setSpeed(random(6, 8));
- } else if (rand >= 499 && rand < 599) {
- if(game.getCurrentTab() != Game.TAB_INVENTORY){
- game.openTab(Game.TAB_INVENTORY);
- } else
- if(game.getCurrentTab() != Game.TAB_STATS){
- game.openTab(Game.TAB_STATS);
- sleep(random(500, 1000));
- skills.doHover(Skills.SMITHING);
- }
- }
- }
- public int loop(){
- if(!running) return 50;
- if(game.isLoggedIn()){
- mouse.setSpeed(random(6, 8));
- }
- while(interfaces.get(906).containsText("Logging")){
- sleep(10000);
- }
- if(walking.getEnergy() >= runEnergy && getMyPlayer().isMoving()){
- walking.setRun(true);
- return random(500, 1000);
- }
- if(getMyPlayer().isMoving()){
- antiBan();
- sleep(random(500, 1000));
- }
- if((inventory.getCount(oreID) > 0 && inventory.getCount(barID) < 1) && usedBank){
- if(!atBank()) usedBank = false;
- walking.walkTo(furnaceTile);
- return random(1000, 1500);
- }
- if(atBank()){
- if(bank.isOpen()){
- sleep(random(500, 800));
- if(inventory.getCount(barID) > 0){
- smeltedBars += inventory.getCount(barID);
- deposit(barID, inventory.getCount(barID));
- sleep(random(600, 1200));
- }
- for(int i = 0; i < oreID.length; i++){
- if(inventory.getCount(oreID[i]) > 0){
- deposit(oreID[i], inventory.getCount(oreID[i]));
- sleep(random(600, 1200));
- }
- }
- int j = (int)(28 / oreID.length);
- for(int i = 0; i < oreID.length; i++){
- withdraw(oreID[i], j);
- sleep(random(500, 1000));
- }
- bank.close();
- usedBank = true;
- return random(500, 100);
- } else {
- RSObject banker = objects.getNearest(35648);
- if(banker != null){
- if(!calc.tileOnScreen(banker.getLocation())){
- walking.walkTo(bankTile);
- return random(500, 1000);
- }
- if(!banker.doAction("Use-quickly")){
- camera.turnTo(banker);
- } else {
- sleep(800, 900);
- }
- return random(500, 900);
- }
- }
- }
- if(atFurnace()){
- if((inventory.getCount(oreID) < 1 && inventory.getCount(barID) > 0) && !isSmelting()){
- walking.walkTo(bankTile);
- return random(1000, 1500);
- }
- if(isSmelting()){
- antiBan();
- return random(100, 1500);
- } else {
- RSObject furnace = objects.getNearest(11666);
- if(furnace != null){
- if(!furnace.isOnScreen()){
- walking.walkTo(furnaceTile);
- return random(500, 1000);
- }
- if(!furnace.doAction("Smelt")){
- camera.turnTo(furnace);
- } else {
- interfaces.getComponent(905, 16).doClick(true);
- sleep(800, 900);
- }
- return random(500, 900);
- }
- }
- }
- if((inventory.getCount(oreID) > 0 && inventory.getCount(barID) < 1)){
- walking.walkTo(furnaceTile);
- return random(500, 1000);
- }
- if((inventory.getCount(oreID) < 1 && inventory.getCount(barID) > 0)){
- walking.walkTo(bankTile);
- return random(500, 1000);
- }
- return 50;
- }
- public boolean atBank(){
- return bankArea.contains(getMyPlayer().getLocation());
- }
- public boolean atFurnace(){
- return furnaceArea.contains(getMyPlayer().getLocation());
- }
- public boolean isSmelting(){
- if(getMyPlayer().getAnimation() == -1){
- sleep(random(200, 500));
- if(getMyPlayer().getAnimation() == -1){
- sleep(random(200, 500));
- if(getMyPlayer().getAnimation() == -1){
- return false;
- }
- }
- }
- return true;
- }
- public void withdraw(int itemId, int amount){
- RSItem item = bank.getItem(itemId);
- String action = "";
- if(amount == 1){
- item.doClick(true);
- return;
- }
- if(amount == 0){
- action = "Withdraw-All";
- }
- if(item.getComponent().containsAction("Withdraw-"+amount)){
- action = "Withdraw-"+amount;
- } else {
- action = "Withdraw-X";
- }
- item.getComponent().doAction(action);
- if(action.equals("Withdraw-X")){
- sleep(random(1000, 1500));
- keyboard.sendText(""+amount, true);
- }
- }
- public void deposit(int itemId, int amount){
- RSItem item = inventory.getItem(itemId);
- String action = "";
- if(amount == 1){
- item.doClick(true);
- return;
- }
- if(amount == 0){
- action = "Deposit-All";
- }
- if(item.getComponent().containsAction("Deposit-"+amount)){
- action = "Deposit-"+amount;
- } else {
- action = "Deposit-X";
- }
- item.getComponent().doAction(action);
- if(action.equals("Deposit-X")){
- sleep(random(1000, 1500));
- keyboard.sendText(""+amount, true);
- }
- }
- private final BasicStroke stroke1 = new BasicStroke(1);
- private final Font font1 = new Font("Arial", 1, 18);
- private final Font font2 = new Font("Arial", 1, 24);
- public void onRepaint(Graphics g1){
- gainedExp = skills.getCurrentExp(Skills.SMITHING)-startExp;
- gainedLevel = skills.getCurrentLevel(Skills.SMITHING)-startLevel;
- String time = (new Date(System.currentTimeMillis())).getHours()+
- " hours and "+(new Date(System.currentTimeMillis())).getMinutes()+" minutes";
- /*
- Graphics2D g = (Graphics2D)g1;
- g.setColor(new Color(255, 255, 255));
- g.fillRect(3, 341, 504, 127);
- String str = "TechSmither v1.0";
- g.setFont(font2);
- g.setColor(new Color(0, 0, 0));
- g.drawString(str, 350, 173-(str.length()/2));
- g.setFont(font1);
- g.drawString("Gained Exp: "+gainedExp, 10, 350);
- g.drawString("Gained Level(s): "+gainedLevel, 10, 365);
- g.drawString("Bars Smelted: "+smeltedBars, 10, 380);
- g.drawString("Running for: "+time, 10, 395);*/
- }
- public class trentCrafterGUI extends javax.swing.JFrame {
- public trentCrafterGUI() {
- initComponents();
- }
- @SuppressWarnings("unchecked")
- private void initComponents() {
- jLabel1 = new javax.swing.JLabel();
- jComboBox1 = new javax.swing.JComboBox();
- jComboBox2 = new javax.swing.JComboBox();
- jLabel2 = new javax.swing.JLabel();
- jLabel3 = new javax.swing.JLabel();
- jButton1 = new javax.swing.JButton();
- jLabel1.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
- jLabel1.setText("TechSmither v1.0");
- String[] bars = {"Bronze Bar", "Iron Bar", "Silver Bar",
- "Steel Bar", "Gold Bar", "Mithril Bar", "Adamant Bar", "Rune Bar"};
- jComboBox1.setModel(new javax.swing.DefaultComboBoxModel(bars));
- jComboBox2.setModel(new javax.swing.DefaultComboBoxModel(new String[]{"Al Kharid"}));
- jLabel2.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
- jLabel2.setText("Bar to Smelt:");
- jLabel3.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
- jLabel3.setText("Location:");
- jButton1.setText("Start");
- jButton1.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- jButton1ActionPerformed(evt);
- }
- });
- javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
- getContentPane().setLayout(layout);
- layout.setHorizontalGroup(layout
- .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(layout.createSequentialGroup()
- .addContainerGap()
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(javax.swing.GroupLayout.Alignment.TRAILING,layout.createSequentialGroup()
- .addComponent(jLabel1)
- .addGap(174,174,174))
- .addGroup(layout.createSequentialGroup()
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addComponent(jComboBox1,javax.swing.GroupLayout.PREFERRED_SIZE,276,javax.swing.GroupLayout.PREFERRED_SIZE)
- .addComponent(jComboBox2,javax.swing.GroupLayout.PREFERRED_SIZE,276,javax.swing.GroupLayout.PREFERRED_SIZE)
- .addGroup(layout.createSequentialGroup()
- .addComponent(jLabel2)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,168,javax.swing.GroupLayout.PREFERRED_SIZE))
- .addGroup(layout.createSequentialGroup()
- .addComponent(jLabel3)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,219,javax.swing.GroupLayout.PREFERRED_SIZE)))
- .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE,Short.MAX_VALUE))
- .addGroup(layout.createSequentialGroup()
- .addComponent(jButton1,javax.swing.GroupLayout.DEFAULT_SIZE,276,Short.MAX_VALUE)
- .addContainerGap()))));
- layout.setVerticalGroup(layout
- .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(layout.createSequentialGroup()
- .addContainerGap()
- .addComponent(jLabel1)
- .addGap(18, 18, 18)
- .addComponent(jLabel2)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(jComboBox1,javax.swing.GroupLayout.PREFERRED_SIZE,javax.swing.GroupLayout.DEFAULT_SIZE,javax.swing.GroupLayout.PREFERRED_SIZE)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
- .addComponent(jLabel3)
- .addGap(4, 4, 4)
- .addComponent(jComboBox2,javax.swing.GroupLayout.PREFERRED_SIZE,javax.swing.GroupLayout.DEFAULT_SIZE,javax.swing.GroupLayout.PREFERRED_SIZE)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(jButton1)
- .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE,Short.MAX_VALUE)));
- pack();
- }
- private javax.swing.JButton jButton1;
- private javax.swing.JComboBox jComboBox1;
- private javax.swing.JComboBox jComboBox2;
- private javax.swing.JLabel jLabel1;
- private javax.swing.JLabel jLabel2;
- private javax.swing.JLabel jLabel3;
- private void jButton1ActionPerformed(java.awt.event.ActionEvent evt){
- String itemName = jComboBox1.getSelectedItem().toString();
- String location = jComboBox2.getSelectedItem().toString();
- if(location.contains("Al Kharid")){
- bankTile = new RSTile(3269, 3168);
- bankArea = new RSArea(new RSTile(3272, 3173), new RSTile(3269, 3161));
- furnaceTile = new RSTile(3274, 3186);
- furnaceArea = new RSArea(new RSTile(3276, 3188), new RSTile(3273, 3184));
- //RSArea = new RSArea( north-east RSTile, South-west RSTile );
- }
- if(itemName.equals("Bronze Bar")){
- barID = 2349;
- oreID = new int[]{436,438};
- }
- if(itemName.equals("Iron Bar")){
- barID = 2351;
- oreID = new int[]{440};
- }
- if(itemName.equals("Silver Bar")){
- barID = 2355;
- oreID = new int[]{442};
- }
- if(itemName.equals("Steel Bar")){
- barID = 2353;
- oreID = new int[]{440,453,453};
- }
- if(itemName.equals("Gold Bar")){
- barID = 2357;
- oreID = new int[]{444};
- }
- if(itemName.equals("Mithril Bar")){
- barID = 2359;
- oreID = new int[]{447,453,453,453};
- }
- if(itemName.equals("Adamant Bar")){
- barID = 2361;
- oreID = new int[]{449,453,453,453,453,453,453};
- }
- if(itemName.equals("Rune Bar")){
- barID = 2363;
- oreID = new int[]{451,453,453,453,453,453,453,453,453};
- }
- this.setVisible(false);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement