Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package scripts;
- import java.awt.Dimension;
- import java.awt.Graphics;
- import java.awt.Toolkit;
- import javax.swing.JFrame;
- import org.tribot.api.DynamicClicking;
- import org.tribot.api.General;
- import org.tribot.api.Timing;
- import org.tribot.api.types.generic.Condition;
- import org.tribot.api.util.ABCUtil;
- import org.tribot.api2007.Banking;
- import org.tribot.api2007.Inventory;
- import org.tribot.api2007.Login;
- import org.tribot.api2007.Objects;
- import org.tribot.api2007.Player;
- import org.tribot.api2007.Skills;
- import org.tribot.api2007.Skills.SKILLS;
- import org.tribot.api2007.WebWalking;
- import org.tribot.api2007.types.RSItem;
- import org.tribot.api2007.types.RSObject;
- import org.tribot.api2007.types.RSTile;
- import org.tribot.script.Script;
- import org.tribot.script.ScriptManifest;
- import org.tribot.script.interfaces.Painting;
- @ScriptManifest(authors = { "Netami" }, category = "Mining", name = "Lumbridge Miner", version = 1.00, description = "Mines Tin/Copper in Lumbridge swamp to get to a desired level. Currently supports logging off or walking to Motherlode mine following target level being reached. Please post on forums with any bugs/improvements, thanks!", gameMode = 1)
- public class Miner_v2 extends Script implements Painting{
- public boolean runScript = true;
- public boolean GUI_COMPLETE = false;
- public boolean walkToMotherload = false;
- public boolean logoutOnTarget = true;
- public int targetLevel;
- public ABCUtil abc = new ABCUtil();
- RSTile rockSpots[] = {new RSTile(3228,3145,0),new RSTile(3223,3147,0),new RSTile(3229,3147,0)};
- public RSTile rockSpot = rockSpots[General.random(0,2)];
- public int initialXp = Skills.getXP(SKILLS.MINING);
- public int initialLevel = Skills.getCurrentLevel(SKILLS.MINING);
- @Override
- public void run() {
- miner_v2_GUI GUI = new miner_v2_GUI();
- JFrame f = new JFrame();
- f.getContentPane();
- f.add(GUI);
- Dimension screensize = Toolkit.getDefaultToolkit().getScreenSize();
- int screenW = (screensize.width) / 2;
- int screenH = (screensize.height / 2);
- f.setVisible(true);
- f.setLocation(screenW / 2, screenH / 2);
- f.setSize(450,265);
- while(!GUI_COMPLETE){
- sleep(300);
- }
- f.setVisible(false);
- startBank();
- if(Player.getPosition() != rockSpot && Skills.getCurrentLevel(SKILLS.MINING) != targetLevel){
- println("We are not at the mining spot, walking there now...");
- WebWalking.walkTo(rockSpot);
- }
- while(runScript){
- if(Skills.getCurrentLevel(SKILLS.MINING) < targetLevel){
- mine();
- sleep(50);
- }else{
- if(walkToMotherload){
- walkToMotherload();
- runScript = false;
- }else{
- Login.logout();
- runScript = false;
- }
- }
- }
- }
- public void startBank(){
- WebWalking.walkToBank();
- sleep(1000,2000);
- Banking.openBank();
- sleep(500,800);
- Banking.depositAll();
- sleep(1000,2000);
- RSItem[] pick = Banking.find(1265,1267,1269,1271,1273,1275);
- if(pick.length == 0){
- runScript = false;
- println("No pickaxe found!");
- }else{
- Banking.withdrawItem(pick[0], 1);
- }
- sleep(1000,2000);
- Banking.close();
- sleep(500,900);
- RSItem[] inventPick = Inventory.find(1265,1267,1269,1271,1273,1275);
- if(inventPick[0] != null){
- inventPick[0].click("Wield");
- }
- sleep(2000,4000);
- }
- public void mine(){
- if(this.abc.TIME_TRACKER.ROTATE_CAMERA.next() > System.currentTimeMillis()){
- abc.performRotateCamera();
- this.abc.TIME_TRACKER.ROTATE_CAMERA.reset();
- abc.performTimedActions(SKILLS.MINING);
- }
- if(Inventory.isFull()){
- Inventory.dropAllExcept(1265,1267,1269,1271,1273,1275);
- }
- if(!Player.isMoving() && Player.getAnimation() == -1 && !Inventory.isFull()){
- final RSObject rocks[]= Objects.findNearest(5, 14886,14884,14885,14864,14883);
- RSObject rockToClick = rocks[0];
- if(rocks.length > 0 && this.abc.BOOL_TRACKER.USE_CLOSEST.next()){
- rockToClick = rocks[1];
- }
- if(DynamicClicking.clickRSObject(rockToClick, "Mine")){
- sleep(500,1000);
- Timing.waitCondition(new Condition()
- {
- @Override
- public boolean active()
- {
- return Player.getAnimation() != -1;
- }
- }, General.random(500, 1000));
- }
- }
- }
- private void walkToMotherload()
- {
- WebWalking.walkTo(new RSTile (3061, 3376, 0));
- sleep(2000,5000);
- RSObject[] stairs = Objects.findNearest(10, 16664);
- if(stairs != null){
- DynamicClicking.clickRSObject(stairs[0], "Climb-down");
- }
- sleep(3000,5000);
- WebWalking.walkTo(new RSTile(3060,9766,0));
- sleep(500,800);
- RSObject[] cave = Objects.findNearest(10, 26654);
- if(cave != null){
- DynamicClicking.clickRSObject(cave[0], "Enter");
- }
- sleep(3000,5000);
- Login.logout();
- }
- @SuppressWarnings("serial")
- class miner_v2_GUI extends javax.swing.JPanel {
- public miner_v2_GUI() {
- initComponents();
- }
- private void initComponents() {
- buttonGroup1 = new javax.swing.ButtonGroup();
- jRadioButton1 = new javax.swing.JRadioButton();
- jRadioButton2 = new javax.swing.JRadioButton();
- jSpinner1 = new javax.swing.JSpinner();
- jButton1 = new javax.swing.JButton();
- jLabel1 = new javax.swing.JLabel();
- jLabel2 = new javax.swing.JLabel();
- jLabel3 = new javax.swing.JLabel();
- buttonGroup1.add(jRadioButton1);
- jRadioButton1.setFont(new java.awt.Font("Segoe UI", 0, 11)); // NOI18N
- jRadioButton1.setText("Logout when target reached");
- buttonGroup1.add(jRadioButton2);
- jRadioButton2.setFont(new java.awt.Font("Segoe UI", 0, 11)); // NOI18N
- jRadioButton2.setText("Walk to motherload when target reached");
- jSpinner1.setModel(new javax.swing.SpinnerNumberModel(30, 2, 99, 1));
- jButton1.setFont(new java.awt.Font("Segoe UI", 0, 36)); // NOI18N
- jButton1.setText("Start");
- jButton1.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));
- jButton1.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- jButton1ActionPerformed(evt);
- }
- });
- jLabel1.setFont(new java.awt.Font("Segoe UI", 0, 48)); // NOI18N
- jLabel1.setText("Lumby Miner ");
- jLabel2.setFont(new java.awt.Font("Segoe UI", 0, 36)); // NOI18N
- jLabel2.setText("Target Level:");
- jLabel3.setFont(new java.awt.Font("Segoe UI", 0, 12)); // NOI18N
- jLabel3.setText("by Netami");
- javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
- this.setLayout(layout);
- layout.setHorizontalGroup(
- layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(layout.createSequentialGroup()
- .addGap(31, 31, 31)
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(layout.createSequentialGroup()
- .addGap(9, 9, 9)
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addComponent(jRadioButton1)
- .addComponent(jRadioButton2))
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 120, Short.MAX_VALUE)
- .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 120, javax.swing.GroupLayout.PREFERRED_SIZE))
- .addGroup(layout.createSequentialGroup()
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(layout.createSequentialGroup()
- .addComponent(jLabel2)
- .addGap(18, 18, 18)
- .addComponent(jSpinner1, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE))
- .addGroup(layout.createSequentialGroup()
- .addComponent(jLabel1)
- .addGap(18, 18, 18)
- .addComponent(jLabel3)))
- .addGap(0, 0, Short.MAX_VALUE)))
- .addContainerGap())
- );
- layout.setVerticalGroup(
- layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
- .addGroup(layout.createSequentialGroup()
- .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
- .addComponent(jButton1))
- .addGroup(layout.createSequentialGroup()
- .addGap(29, 29, 29)
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
- .addGroup(layout.createSequentialGroup()
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
- .addComponent(jLabel1)
- .addComponent(jLabel3))
- .addGap(28, 28, 28)
- .addComponent(jLabel2))
- .addComponent(jSpinner1, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE))
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 28, Short.MAX_VALUE)
- .addComponent(jRadioButton1)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
- .addComponent(jRadioButton2)))
- .addGap(26, 26, 26))
- );
- }// </editor-fold>
- private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
- if(jRadioButton1.isSelected()){
- logoutOnTarget = true;
- walkToMotherload = false;
- }else{
- walkToMotherload = true;
- logoutOnTarget = false;
- }
- targetLevel = (Integer) jSpinner1.getValue();
- GUI_COMPLETE = true;
- }
- // Variables declaration - do not modify
- private javax.swing.ButtonGroup buttonGroup1;
- private javax.swing.JButton jButton1;
- private javax.swing.JRadioButton jRadioButton1;
- private javax.swing.JRadioButton jRadioButton2;
- private javax.swing.JSpinner jSpinner1;
- private javax.swing.JLabel jLabel1;
- private javax.swing.JLabel jLabel2;
- private javax.swing.JLabel jLabel3;
- // End of variables declaration
- }
- public void onPaint(Graphics g) {
- int gainedXp = (int)Skills.getXP(Skills.SKILLS.MINING) - initialXp;
- int currentLevel = (int)Skills.getCurrentLevel(Skills.SKILLS.MINING);
- int gainedLevels = currentLevel - initialLevel;
- g.drawString("Time Ran: " + Timing.msToString(getRunningTime()), 10, 40);
- g.drawString("Mining xp gained: " + gainedXp, 10, 60);
- g.drawString("Current Level: " + currentLevel + " (" + gainedLevels + ")" , 10, 80);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement