Created
August 31, 2011 05:35
-
-
Save SwipeX/1182889 to your computer and use it in GitHub Desktop.
3.0 Walker
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import javax.swing.SwingUtilities; | |
import org.rsbot.script.Script; | |
import org.rsbot.script.ScriptManifest; | |
import org.rsbot.script.methods.Calculations; | |
import org.rsbot.script.methods.Walking; | |
import org.rsbot.script.wrappers.Path; | |
import org.rsbot.script.wrappers.Tile; | |
@ScriptManifest(authors = { "Swipe" }, keywords = "Walking", name = "ReWalk", version = 1.0, description = "Walker for 3.0") | |
public class ReWalk extends Script { | |
class WGui extends javax.swing.JFrame { | |
/** | |
* | |
*/ | |
private static final long serialVersionUID = -2123524786020503172L; | |
// Variables declaration - do not modify | |
private javax.swing.JButton jButton1; | |
private javax.swing.JComboBox jComboBox1; | |
private javax.swing.JLabel jLabel1; | |
private javax.swing.JSeparator jSeparator1; | |
private javax.swing.JSeparator jSeparator2; | |
// End of variables declaration | |
/** Creates new form WGui */ | |
public WGui() { | |
initComponents(); | |
} | |
/** | |
* This method is called from within the constructor to initialize the | |
* form. WARNING: Do NOT modify this code. The content of this method is | |
* always regenerated by the Form Editor. | |
*/ | |
@SuppressWarnings("unchecked") | |
// <editor-fold defaultstate="collapsed" desc="Generated Code"> | |
private void initComponents() { | |
jButton1 = new javax.swing.JButton(); | |
jComboBox1 = new javax.swing.JComboBox(); | |
jLabel1 = new javax.swing.JLabel(); | |
jSeparator1 = new javax.swing.JSeparator(); | |
jSeparator2 = new javax.swing.JSeparator(); | |
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); | |
setTitle("ReWalk"); | |
jButton1.setText("Walk"); | |
jButton1.addActionListener(new java.awt.event.ActionListener() { | |
public void actionPerformed(java.awt.event.ActionEvent evt) { | |
jButton1ActionPerformed(evt); | |
} | |
}); | |
jComboBox1.setModel(new javax.swing.DefaultComboBoxModel( | |
new String[] { "Grand Exchange", "Lumbridge", "Falador", | |
"Varrock", "Al-Kharid", "RimmingTon", "Draynor", | |
"Barb-Vill", "Port-Sarim", "Wizzy Tower", | |
"Edgeville", "Seers", "Catherby", "Relleka", | |
"Ardougne" })); | |
jLabel1.setFont(new java.awt.Font("Tahoma", 1, 24)); // NOI18N | |
jLabel1.setForeground(new java.awt.Color(0, 153, 0)); | |
jLabel1.setText("ReWalk"); | |
javax.swing.GroupLayout layout = new javax.swing.GroupLayout( | |
getContentPane()); | |
getContentPane().setLayout(layout); | |
layout.setHorizontalGroup(layout | |
.createParallelGroup( | |
javax.swing.GroupLayout.Alignment.LEADING) | |
.addGroup( | |
layout.createSequentialGroup() | |
.addGroup( | |
layout.createParallelGroup( | |
javax.swing.GroupLayout.Alignment.LEADING) | |
.addGroup( | |
layout.createSequentialGroup() | |
.addGap(40, | |
40, | |
40) | |
.addComponent( | |
jLabel1)) | |
.addGroup( | |
layout.createSequentialGroup() | |
.addGap(35, | |
35, | |
35) | |
.addComponent( | |
jButton1, | |
javax.swing.GroupLayout.PREFERRED_SIZE, | |
107, | |
javax.swing.GroupLayout.PREFERRED_SIZE))) | |
.addContainerGap(37, Short.MAX_VALUE)) | |
.addComponent(jSeparator1, | |
javax.swing.GroupLayout.DEFAULT_SIZE, 179, | |
Short.MAX_VALUE) | |
.addComponent(jSeparator2, | |
javax.swing.GroupLayout.DEFAULT_SIZE, 179, | |
Short.MAX_VALUE) | |
.addGroup( | |
layout.createSequentialGroup() | |
.addGap(21, 21, 21) | |
.addComponent( | |
jComboBox1, | |
javax.swing.GroupLayout.PREFERRED_SIZE, | |
135, | |
javax.swing.GroupLayout.PREFERRED_SIZE) | |
.addContainerGap(23, Short.MAX_VALUE))); | |
layout.setVerticalGroup(layout | |
.createParallelGroup( | |
javax.swing.GroupLayout.Alignment.LEADING) | |
.addGroup( | |
layout.createSequentialGroup() | |
.addComponent(jLabel1) | |
.addPreferredGap( | |
javax.swing.LayoutStyle.ComponentPlacement.RELATED) | |
.addComponent( | |
jSeparator1, | |
javax.swing.GroupLayout.PREFERRED_SIZE, | |
10, | |
javax.swing.GroupLayout.PREFERRED_SIZE) | |
.addPreferredGap( | |
javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) | |
.addComponent( | |
jComboBox1, | |
javax.swing.GroupLayout.PREFERRED_SIZE, | |
javax.swing.GroupLayout.DEFAULT_SIZE, | |
javax.swing.GroupLayout.PREFERRED_SIZE) | |
.addGap(18, 18, 18) | |
.addComponent( | |
jSeparator2, | |
javax.swing.GroupLayout.PREFERRED_SIZE, | |
10, | |
javax.swing.GroupLayout.PREFERRED_SIZE) | |
.addGap(5, 5, 5) | |
.addComponent(jButton1) | |
.addContainerGap( | |
javax.swing.GroupLayout.DEFAULT_SIZE, | |
Short.MAX_VALUE))); | |
pack(); | |
}// </editor-fold> | |
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) { | |
w.setVisible(false); | |
} | |
} | |
Tile dest[] = { new Tile(3212, 3435), new Tile(3222, 3220), | |
new Tile(3092, 3261), new Tile(3293, 3186), new Tile(3164, 3478), | |
new Tile(2957, 3225), new Tile(2965, 3381), new Tile(3086, 3421), | |
new Tile(3041, 3254), new Tile(3111, 3170), new Tile(3087, 3492), | |
new Tile(2702, 3484), new Tile(2808, 3437), new Tile(2658, 3658), | |
new Tile(2662, 3307) }; | |
Tile loc = null; | |
Path myPath; | |
WGui w = new WGui(); | |
@Override | |
public int loop() { | |
// check for nulls | |
if (myPath != null) { | |
// if we are more than 5 tiles away | |
if (Calculations.distanceTo(myPath.getEnd()) > 5) { | |
// walk there | |
myPath.traverse(); | |
} else{ | |
stop(); | |
} | |
} | |
return 500; | |
} | |
public boolean onRun() { | |
// w.setResizable(false); | |
w.setVisible(true); | |
// dont move ontill they click start | |
while (w.isVisible()) { | |
// standby | |
} | |
loc = dest[w.jComboBox1.getSelectedIndex()]; | |
// gen path | |
myPath = Walking.getPath(loc); | |
// end gui | |
w.dispose(); | |
return true; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment