Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package scripts.Cannon;
- import javax.swing.JFrame;
- import org.tribot.api.General;
- import org.tribot.api.input.Mouse;
- import org.tribot.api2007.Game;
- import org.tribot.api2007.Inventory;
- import org.tribot.api2007.Player;
- import org.tribot.api2007.Skills;
- import org.tribot.api2007.Skills.SKILLS;
- import org.tribot.script.Script;
- import org.tribot.script.ScriptManifest;
- import org.tribot.script.interfaces.MessageListening07;
- import org.tribot.script.interfaces.Painting;
- import java.awt.*;
- import javax.imageio.ImageIO;
- import java.io.IOException;
- import java.net.URL;
- @ScriptManifest(authors = { "Netami" }, category = "Combat", name = "Netami's Cannonner", version = 1.00, description = "Uses your cannon for you! Supports cannon decay and food usage", gameMode = 1)
- public class Main extends Script implements MessageListening07, Painting{
- @Override
- public void run() {
- Methods.GetNextLoad(Variables.NextLoad);
- Methods.GetNextEat(Variables.NextEat);
- CannonGUI GUI = new CannonGUI();
- JFrame f = new JFrame();
- f.getContentPane();
- f.add(GUI);
- f.setVisible(true);
- Dimension screensize = Toolkit.getDefaultToolkit().getScreenSize();
- int screenW = (screensize.width) / 2;
- int screenH = (screensize.height / 2);
- f.setLocation(screenW / 2, screenH / 2);
- f.setSize(385,175);
- while(Variables.GUI_Complete == false){
- sleep(250);
- }
- f.setVisible(false);
- Mouse.setSpeed(Variables.MouseSpeed);
- Variables.CannonSpot = Player.getPosition();
- while (Variables.RunScript){
- sleep(100,250);
- stateHandler();
- }
- }
- enum State {
- PUT_DOWN_CANNON,
- LOAD_CANNON,
- PICK_UP_CANNON,
- EAT_FOOD,
- WAIT;
- }
- public static State getState(){
- if(Methods.OurCannon().length > 0){
- if(Skills.getCurrentLevel(SKILLS.HITPOINTS) <= Variables.NextEat && Methods.randomPercent(80, 100)){
- Methods.GetNextEat(Variables.NextEat);
- return State.EAT_FOOD;
- }
- if(Variables.NeedPickup){
- return State.PICK_UP_CANNON;
- }
- if(Variables.NeedReload){
- if(Inventory.find("Cannonball").length > 0){
- return State.LOAD_CANNON;
- }else{
- return State.PICK_UP_CANNON;
- }
- }
- if(Game.getSetting(3) <= Variables.NextLoad && Methods.randomPercent(70,100)){
- Methods.GetNextLoad(Variables.NextLoad);
- return State.LOAD_CANNON;
- }else
- {
- return State.WAIT;
- }
- }else{
- if(Inventory.find("Cannonball").length > 0){
- return State.PUT_DOWN_CANNON;
- }else{
- General.println("We have no cannonballs! Ending script...");
- Variables.RunScript = false;
- return State.WAIT;
- }
- }
- }
- public static void stateHandler(){
- switch (getState()){
- case PUT_DOWN_CANNON:
- Methods.PutDownCannon();
- break;
- case LOAD_CANNON:
- Methods.LoadCannon();
- break;
- case PICK_UP_CANNON:
- Methods.PickUpCannon();
- break;
- case WAIT:
- Methods.Wait();
- break;
- case EAT_FOOD:
- Methods.Eat();
- break;
- }
- }
- //START: Code generated using Enfilade's Easel
- private Image getImage(String url) {
- try {
- return ImageIO.read(new URL(url));
- } catch(IOException e) {
- return null;
- }
- }
- private final Color white = new Color(255, 255, 255);
- private final Color darkGray = new Color(29, 29, 29);
- private final BasicStroke stroke1 = new BasicStroke(1);
- private final Font font1 = new Font("Arial", 1, 13);
- private final Font font2 = new Font("Arial", 1, 10);
- private final Image img1 = getImage("http://ge.2007hq.com/img/items/large/2.png");
- public void onPaint(Graphics g1) {
- final RenderingHints antialias = new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
- double percent = (double)128 * ((double)Skills.getPercentToNextLevel(Skills.SKILLS.RANGED) / (double)100);
- Graphics2D g = (Graphics2D)g1;
- g.setRenderingHints(antialias);
- g.setColor(darkGray);
- g.fillRoundRect(354, 348, 136, 100, 16, 16);
- g.setColor(white);
- g.setStroke(stroke1);
- g.drawRoundRect(354, 348, 136, 100, 16, 16);
- g.setFont(font1);
- g.drawString("Netami's Cannonner", 358, 365);
- g.drawImage(img1, 276, 373, null);
- g.drawImage(img1, 238, 372, null);
- g.drawImage(img1, 257, 336, null);
- g.setFont(font2);
- g.drawString("Current Range: " + Skills.getCurrentLevel(SKILLS.RANGED), 358, 385);
- g.drawString("XP Gained: " + (Skills.getXP(SKILLS.RANGED) - Variables.StartingXP), 358, 400);
- g.setColor(Color.white);
- g.fillRoundRect(358, 424, (int)percent,15,9,9);
- g.drawRoundRect(358, 424, 128, 15,9,9);
- g.drawString("Cannonballs left: " + Inventory.find("Cannonball")[0].getStack(), 358, 415);
- }
- //END: Code generated using Enfilade's Easel
- public void serverMessageReceived(String message) {
- if(message.equals("That isn't your cannon!")){
- println("We clicked on someone elses cannon!");
- Variables.RunScript = false;
- }
- if(message.contains("decay")){
- Variables.NeedPickup = true;
- }
- if(message.equals("Your cannon is out of ammo!")){
- Variables.NeedReload = true;
- }
- if(Variables.NeedPickup && message.equals("You pick up the cannon. It's really heavy.")){
- Variables.NeedPickup = false;
- }
- if(Variables.NeedReload && message.contains("You load")){
- Variables.NeedReload = false;
- }
- if(Variables.NeedReload && message.contains("Your cannon is already")){
- if(Methods.PickUpCannon()){
- Variables.RunScript = false;
- }
- }
- if(message.contains("There isn't enough")){
- println("Can't place a cannon here!");
- Variables.RunScript = false;
- }
- }
- @SuppressWarnings("serial")
- public class CannonGUI extends javax.swing.JPanel {
- /**
- * Creates new form CannonGUI
- */
- public CannonGUI() {
- 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() {
- jLabel1 = new javax.swing.JLabel();
- jButton2 = new javax.swing.JButton();
- jSlider1 = new javax.swing.JSlider();
- jLabel2 = new javax.swing.JLabel();
- jLabel3 = new javax.swing.JLabel();
- jLabel4 = new javax.swing.JLabel();
- jLabel1.setFont(new java.awt.Font("Segoe UI", 0, 36)); // NOI18N
- jLabel1.setText("Netami's Cannonner");
- jButton2.setText("Start!");
- jButton2.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- jButton2ActionPerformed(evt);
- }
- });
- jSlider1.setMaximum(110);
- jSlider1.setMinimum(90);
- jSlider1.setMinorTickSpacing(1);
- jSlider1.setValue(100);
- jSlider1.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
- jLabel2.setText("Mouse Speed:");
- jLabel3.setText("90");
- jLabel4.setText("110");
- javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
- this.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(91, 91, 91)
- .addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 131, javax.swing.GroupLayout.PREFERRED_SIZE))
- .addGroup(layout.createSequentialGroup()
- .addContainerGap()
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
- .addComponent(jLabel2)
- .addGap(34, 34, 34)
- .addComponent(jLabel3)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(jSlider1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
- .addComponent(jLabel1))
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(jLabel4)))
- .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
- );
- layout.setVerticalGroup(
- layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(layout.createSequentialGroup()
- .addContainerGap()
- .addComponent(jLabel1)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
- .addComponent(jLabel2)
- .addComponent(jLabel3))
- .addComponent(jSlider1, javax.swing.GroupLayout.PREFERRED_SIZE, 21, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addComponent(jLabel4))
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 24, Short.MAX_VALUE)
- .addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 31, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addContainerGap())
- );
- }// </editor-fold>
- private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
- Variables.CannonSpot = Player.getPosition();
- Variables.GUI_Complete = true;
- Variables.MouseSpeed = jSlider1.getValue();
- }
- // Variables declaration - do not modify
- private javax.swing.JButton jButton2;
- private javax.swing.JLabel jLabel1;
- private javax.swing.JLabel jLabel2;
- private javax.swing.JLabel jLabel3;
- private javax.swing.JLabel jLabel4;
- private javax.swing.JSlider jSlider1;
- // End of variables declaration
- }
- public void clanMessageReceived(String arg0, String arg1) {
- }
- public void duelRequestReceived(String arg0, String arg1) {
- }
- public void personalMessageReceived(String arg0, String arg1) {
- }
- public void playerMessageReceived(String arg0, String arg1) {
- }
- public void tradeRequestReceived(String arg0) {
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement