Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package scripts;
- import java.awt.BorderLayout;
- import java.awt.Color;
- import java.awt.Container;
- import java.awt.Desktop;
- import java.awt.Font;
- import java.awt.Graphics;
- import java.awt.Graphics2D;
- import java.awt.GridBagConstraints;
- import java.awt.GridBagLayout;
- import java.awt.Image;
- import java.awt.Insets;
- import java.awt.RenderingHints;
- import java.awt.event.ActionEvent;
- import java.io.IOException;
- import java.net.MalformedURLException;
- import java.net.URI;
- import java.net.URISyntaxException;
- import java.net.URL;
- import java.util.ArrayList;
- import javax.imageio.ImageIO;
- import javax.swing.DefaultComboBoxModel;
- import javax.swing.GroupLayout;
- import javax.swing.JButton;
- import javax.swing.JCheckBox;
- import javax.swing.JComboBox;
- import javax.swing.JFrame;
- import javax.swing.JLabel;
- import javax.swing.JMenu;
- import javax.swing.JMenuBar;
- import javax.swing.JMenuItem;
- import javax.swing.JPanel;
- import javax.swing.LayoutStyle;
- import javax.swing.border.EmptyBorder;
- import org.tribot.api.DynamicClicking;
- import org.tribot.api.General;
- import org.tribot.api.input.Mouse;
- import org.tribot.api2007.Camera;
- 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.types.RSObject;
- import org.tribot.api2007.types.RSTile;
- import org.tribot.script.Script;
- import org.tribot.script.ScriptManifest;
- import org.tribot.script.interfaces.Painting;
- import scripts.DTools.DAntiban;
- import scripts.DTools.Newsloader;
- @ScriptManifest(authors = { "TheD" }, category = "TheDScripts", name = "DGnomeAgility", description = "Start the script anywhere on the route, the script will pick up!")
- public class DGnomeAgil extends Script implements Painting
- {
- private State scriptState = State.NOTHING;
- private boolean GUIWait = true;
- private boolean use_abcv2 = false;
- private GUI g = new GUI();
- private long Start_XP = Skills.getXP(SKILLS.AGILITY);
- private final long startTime = System.currentTimeMillis();
- private int laps_ran = 0;
- private final Font font2 = new Font("Arial", Font.BOLD, 14);
- private final Font font3 = new Font("Arial", 1, 16);
- private long startNewsTime = System.currentTimeMillis();
- private ArrayList<String> latestNews = new ArrayList<String>();
- private boolean count_lap = false;
- private boolean end_after_time = false;
- private int end_hour = 0;
- private int end_minute = 0;
- private int end_second = General.random(1, 59);
- private enum State {
- NOTHING,WALK_LOG,CLIMB_NET,CLIMB_TREE_UP,WALK_ROPE,CLIMB_DOWN,CLIMB_NET_2,SQUEEZE_PIPE
- }
- private State getState()
- {
- if(end_after_time)
- {
- if((hours == end_hour && minutes >= end_minute && seconds >= end_second) || (hours >= end_hour && minutes > end_minute) || (hours > end_hour))
- {
- System.out.println("Ending script...");
- while(Login.getLoginState() == Login.STATE.INGAME)
- {
- Login.logout();
- sleep(500,5000);
- if(Login.getLoginState() != Login.STATE.INGAME) break;
- }
- System.out.println("Logged out & Ended script...");
- this.stopScript();
- }
- }
- RSTile pos = Player.getPosition();
- if(pos.getY() > 3433 && !Player.isMoving() && Player.getAnimation() < 1)
- return State.WALK_LOG;
- if(pos.getX() == 2474 && Player.isMoving() && pos.getY() > 3429 && pos.getY() < 3436)
- { setCameraAngle(0); return State.NOTHING;}
- if(pos.getY() > 3424 && pos.getY() < 3433 && pos.getX() < 2478 && !Player.isMoving() && Player.getAnimation() < 1)
- return State.CLIMB_NET;
- if(pos.getX() > 2470 && pos.getX() < 2477 && pos.getY() > 3421 && pos.getY() < 3425 && !Player.isMoving() && Player.getAnimation() < 1)
- return State.CLIMB_TREE_UP;
- if(pos.getX() > 2471 && pos.getX() < 2478 && pos.getY() > 3417 && pos.getY() < 3422 && !Player.isMoving() && Player.getAnimation() < 1)
- return State.WALK_ROPE;
- if(pos.getX() > 2482 && pos.getX() < 2489 && pos.getY() > 3417 && pos.getY() < 3422 && !Player.isMoving() && Player.getAnimation() < 1 && Player.getPosition().getPlane() != 0)
- return State.CLIMB_DOWN;
- if(((pos.getX() != 2483 || pos.getX() != 2482) && pos.getY() != 3420) && pos.getX() > 2482 && pos.getX() < 2489 && pos.getY() > 3417 && pos.getY() < 3422 && Player.isMoving() && Player.getPosition().getPlane() != 0)
- setCameraAngle(2);
- if(pos.getY() == 3420 && Player.isMoving() && pos.getX() < 2483 && pos.getX() > 2478)
- { setCameraAngle(1); return State.NOTHING;}
- if(pos.getX() > 2481 && pos.getX() < 2490 && pos.getY() > 3413 && pos.getY() < 3426 && !Player.isMoving() && Player.getAnimation() < 1 && Player.getPosition().getPlane() == 0)
- return State.CLIMB_NET_2;
- if(pos.getX() > 2481 && pos.getX() < 2491 && pos.getY() > 3425 && pos.getY() < 3434 && pos.getY() != 3433 && !Player.isMoving() && Player.getAnimation() < 1)
- return State.SQUEEZE_PIPE;
- if(pos.getX() == 2484 && pos.getY() > 3430 && pos.getY() < 3437 && Player.isMoving())
- { setCameraAngle(3); return State.NOTHING;}
- return State.NOTHING;
- }
- @Override
- public void run()
- {
- DAntiban.setPrintDebug(true);
- Mouse.setSpeed(General.random(160, 170));
- g.setVisible(true);
- latestNews = Newsloader.getNews();
- while(GUIWait == true)
- {
- sleep(500);
- if(!GUIWait) continue;
- }
- while(true)
- {
- loop();
- }
- }
- private void setCameraAngle(int id)
- {
- switch(id)
- {
- case 0:
- if(Camera.getCameraAngle() < 65 || Camera.getCameraAngle() > 75) Camera.setCameraAngle(General.random(67, 73));
- if(Camera.getCameraRotation() < 170 || Camera.getCameraRotation() > 190) Camera.setCameraRotation(General.random(175, 185));
- break;
- case 1:
- if(Camera.getCameraAngle() < 95) Camera.setCameraAngle(100);
- if(Camera.getCameraRotation() < 260 || Camera.getCameraRotation() > 280) Camera.setCameraRotation(General.random(265, 275));
- break;
- case 2:
- if(Camera.getCameraAngle() < 35 || Camera.getCameraAngle() > 45) Camera.setCameraAngle(General.random(35, 45));
- if(Camera.getCameraRotation() < -10 || Camera.getCameraRotation() > 10) Camera.setCameraRotation(General.random(-5, 5));
- break;
- case 3:
- if(Camera.getCameraAngle() < 95) Camera.setCameraAngle(100);
- if(Camera.getCameraRotation() < -10 || Camera.getCameraRotation() > 10) Camera.setCameraRotation(General.random(-5, 5));
- break;
- }
- }
- void loop()
- {
- scriptState = getState();
- DAntiban.activateRun();
- DAntiban.timedActions();
- switch(scriptState)
- {
- case WALK_LOG:
- RSObject[] log = Objects.getAt(new RSTile(2474,3435,0));
- if(log[0] != null && !log[0].isOnScreen())
- DAntiban.goToAnticipated(new RSTile(2474,3437,0));
- DynamicClicking.clickRSObject(log[0], "Walk-across");
- goSleep(1800);
- break;
- case CLIMB_NET:
- RSObject[] net_one = Objects.findNearest(8,"Obstacle net");
- RSObject to_use = null;
- if(net_one.length > 0) to_use = DAntiban.selectNextTarget(net_one);
- if(to_use != null) DynamicClicking.clickRSObject(to_use, "Climb-over");
- count_lap = true;
- goSleep(1000);
- break;
- case CLIMB_TREE_UP:
- RSObject[] tree_up = Objects.getAt(new RSTile(2473,3422,1));
- if(tree_up.length > 0) DynamicClicking.clickRSObject(tree_up[0], "Climb");
- goSleep(1000);
- break;
- case WALK_ROPE:
- RSObject[] rope = Objects.getAt(new RSTile(2478,3420,2));
- if(rope[0] != null && rope.length > 0) DynamicClicking.clickRSObject(rope[0], "Walk-on");
- goSleep(2000);
- break;
- case CLIMB_DOWN:
- RSObject[] tree_down = Objects.getAt(new RSTile(2486,3419,2));
- if(tree_down.length > 0) DynamicClicking.clickRSObject(tree_down[0], "Climb-down");
- goSleep(1000);
- break;
- case CLIMB_NET_2:
- RSObject[] net_two = Objects.findNearest(9, "Obstacle net");
- RSObject net_to_use = null;
- if(net_two.length > 0)
- {
- net_to_use = DAntiban.selectNextTarget(net_two);
- if(!net_to_use.getPosition().isOnScreen()) DAntiban.goToAnticipated(new RSTile(2485,3423,0));
- DynamicClicking.clickRSObject(net_two[0], "Climb-over");
- }
- goSleep(1000);
- break;
- case SQUEEZE_PIPE:
- RSObject[] pipe = Objects.findNearest(10, "Obstacle pipe");
- RSObject pipe_to_use = null;
- if(pipe.length > 0)
- {
- pipe_to_use = DAntiban.selectNextTarget(pipe);
- if(pipe_to_use != null)
- {
- DynamicClicking.clickRSObject(pipe_to_use, "Squeeze-through");
- if(count_lap) laps_ran++;
- }
- }
- goSleep(2000);
- break;
- }
- }
- /**
- * @param max_duration is the maximum estimated time to finish what we are doing
- */
- private void goSleep(int max_duration)
- {
- if(use_abcv2)
- {
- DAntiban.generateTrackers(max_duration);
- DAntiban.sleepReactionTime();
- DAntiban.timedActions();
- }
- else
- {
- DAntiban.smartSleep(max_duration);
- DAntiban.timedActions();
- }
- }
- int newsToShow = 0;
- private void getnewsdata()
- {
- int newsTimer = (int) (System.currentTimeMillis() - startNewsTime) / 1000;
- if(newsTimer > 8)
- {
- startNewsTime = System.currentTimeMillis();
- if(newsToShow == (latestNews.size() -1)) newsToShow = 0;
- else if(newsToShow < (latestNews.size())) newsToShow++;
- }
- }
- long curr_xp = 0;
- int timeRan = 0;
- double multiplier = 0;
- int laps_PH = 0;
- int hours = 0;
- int minutes = 0;
- int seconds = 0;
- private void calculatePaint()
- {
- curr_xp = Skills.getXP(SKILLS.AGILITY) - Start_XP;
- timeRan = (int) (System.currentTimeMillis() - startTime);
- multiplier = timeRan / 3600000D;
- laps_PH = (int) (laps_ran / multiplier);
- hours = timeRan / 3600000;
- timeRan = timeRan - (hours*3600000);
- minutes = timeRan / 60000;
- timeRan = timeRan - (minutes*60000);
- seconds = timeRan / 1000;
- timeRan = timeRan - (seconds*1000);
- }
- private Image getImage(String url)
- {
- try
- {
- return ImageIO.read(new URL(url));
- }
- catch(IOException e)
- {
- return null;
- }
- }
- private final Image dchickenspaintimg = getImage("http://d-scripting.com/DEssentials/paint/dgnomeagilitypaint.png");
- private final RenderingHints aa = new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
- private final Color darkred = new Color(193,48,38);
- int paintOffset = 320;
- @Override
- public void onPaint(Graphics g)
- {
- getnewsdata();
- calculatePaint();
- Graphics2D g2 = (Graphics2D)g;
- g2.setRenderingHints(aa);
- g2.drawImage(dchickenspaintimg, 0, paintOffset, null);
- g.setColor(Color.CYAN);
- g.setFont(font3);
- if(newsToShow < (latestNews.size())) g.drawString("NEWS: "+ latestNews.get(newsToShow), 40,40);
- g.setColor(darkred);
- g.setFont(font2);
- g.drawString("time ran: "+ hours + ":" + minutes + ":" + seconds, 5,paintOffset+60);
- g.drawString("xp gained: "+ curr_xp, 5,paintOffset+75);
- g.drawString("Laps ran "+ laps_ran +" Laps P/H: "+laps_PH, 5,paintOffset+90);
- g.drawString("Using ABCv2: "+use_abcv2, 5,paintOffset+105);
- g.drawString("Debug : "+scriptState, 5,paintOffset+120);
- if(end_after_time) g.drawString("Ending script when we ran "+(end_hour)+":"+(end_minute)+":"+(end_second)+" (HH:MM:SS)", 5,paintOffset+135);
- if(!end_after_time) g.drawString("Not using End-timer", 5,paintOffset+135);
- g.drawString("Version: 1.01", 5,paintOffset+160);
- }
- public class GUI extends JFrame {
- public GUI() {
- initComponents();
- }
- private void thedtribotActionPerformed(ActionEvent e) {
- openSite("https://tribot.org/forums/profile/8498-thed/");
- }
- private void dscriptingcomActionPerformed(ActionEvent e) {
- openSite("http://d-scripting.com");
- }
- private void moredscriptsActionPerformed(ActionEvent e) {
- openSite("http://d-scripting.com/more");
- }
- private void okButtonActionPerformed(ActionEvent e) {
- GUIWait = false;
- use_abcv2 = abcv2reactions.isSelected();
- String whenToQuit = endscriptTimer.getSelectedItem().toString();
- if(whenToQuit.startsWith("0."))
- {
- end_after_time = false;
- }
- if(whenToQuit.startsWith("1."))
- {
- end_after_time = true;
- end_hour = 1;
- end_minute = General.random(1, 59);
- }
- if(whenToQuit.startsWith("2."))
- {
- end_after_time = true;
- end_hour = 2;
- end_minute = General.random(1, 59);
- }
- if(whenToQuit.startsWith("3."))
- {
- end_after_time = true;
- end_hour = 3;
- end_minute = General.random(1, 59);
- }
- if(whenToQuit.startsWith("4."))
- {
- end_after_time = true;
- end_hour = 4;
- end_minute = General.random(1, 59);
- }
- if(whenToQuit.startsWith("5."))
- {
- end_after_time = true;
- end_hour = 5;
- end_minute = General.random(1, 59);
- }
- if(whenToQuit.startsWith("6."))
- {
- end_after_time = true;
- end_hour = 6;
- end_minute = General.random(1, 59);
- }
- if(whenToQuit.startsWith("7."))
- {
- end_after_time = true;
- end_hour = 7;
- end_minute = General.random(1, 59);
- }
- if(whenToQuit.startsWith("8."))
- {
- end_after_time = true;
- end_hour = 8;
- end_minute = General.random(1, 59);
- }
- if(whenToQuit.startsWith("9."))
- {
- end_after_time = true;
- end_hour = 9;
- end_minute = General.random(1, 59);
- }
- if(whenToQuit.startsWith("10."))
- {
- end_after_time = true;
- end_hour = 10;
- end_minute = General.random(1, 59);
- }
- if(whenToQuit.startsWith("11."))
- {
- end_after_time = true;
- end_hour = 11;
- end_minute = General.random(1, 59);
- }
- if(whenToQuit.startsWith("12."))
- {
- end_after_time = true;
- end_hour = 12;
- end_minute = General.random(1, 59);
- }
- g.dispose();
- }
- private void initComponents() {
- //Init TheD
- menuBar1 = new JMenuBar();
- menu1 = new JMenu();
- thedtribot = new JMenuItem();
- dscriptingcom = new JMenuItem();
- moredscripts = new JMenuItem();
- dialogPane = new JPanel();
- contentPanel = new JPanel();
- label1 = new JLabel();
- label2 = new JLabel();
- abcv2reactions = new JCheckBox();
- label3 = new JLabel();
- endscriptTimer = new JComboBox<>();
- label5 = new JLabel();
- buttonBar = new JPanel();
- okButton = new JButton();
- //======== this ========
- setTitle("DScripts by TheD");
- setAlwaysOnTop(true);
- setResizable(false);
- Container contentPane = getContentPane();
- contentPane.setLayout(new BorderLayout());
- //======== menuBar1 ========
- {
- //======== menu1 ========
- {
- menu1.setText("General");
- //---- thedtribot ----
- thedtribot.setText("TheD TRiBot Profile");
- thedtribot.addActionListener(e -> thedtribotActionPerformed(e));
- menu1.add(thedtribot);
- //---- dscriptingcom ----
- dscriptingcom.setText("D-Scripting.com");
- dscriptingcom.addActionListener(e -> dscriptingcomActionPerformed(e));
- menu1.add(dscriptingcom);
- //---- moredscripts ----
- moredscripts.setText("More DScripts");
- moredscripts.addActionListener(e -> moredscriptsActionPerformed(e));
- menu1.add(moredscripts);
- }
- menuBar1.add(menu1);
- }
- setJMenuBar(menuBar1);
- //======== dialogPane ========
- {
- dialogPane.setBorder(new EmptyBorder(12, 12, 12, 12));
- // DScripting
- dialogPane.setBorder(new javax.swing.border.CompoundBorder(
- new javax.swing.border.TitledBorder(new javax.swing.border.EmptyBorder(0, 0, 0, 0),
- "DScripting Limited", javax.swing.border.TitledBorder.CENTER,
- javax.swing.border.TitledBorder.BOTTOM, new java.awt.Font("Dialog", java.awt.Font.BOLD, 12),
- java.awt.Color.red), dialogPane.getBorder())); dialogPane.addPropertyChangeListener(new java.beans.PropertyChangeListener(){public void propertyChange(java.beans.PropertyChangeEvent e){if("border".equals(e.getPropertyName()))throw new RuntimeException();}});
- dialogPane.setLayout(new BorderLayout());
- //======== contentPanel ========
- {
- //---- label1 ----
- label1.setText("DGnomeAgility");
- label1.setFont(new Font("Tahoma", Font.PLAIN, 48));
- //---- label2 ----
- label2.setText("Simple gnome agility course script, start anywhere on the route.");
- label2.setFont(new Font("Tahoma", Font.PLAIN, 12));
- //---- abcv2reactions ----
- abcv2reactions.setText("Use ABCv2 Reaction times");
- abcv2reactions.setFont(new Font("Tahoma", Font.PLAIN, 12));
- //---- label3 ----
- label3.setText("ABCv2 Reaction times make you slower, but it's safer to bot using it.");
- label3.setFont(new Font("Tahoma", Font.PLAIN, 12));
- //---- endscriptTimer ----
- endscriptTimer.setFont(new Font("Tahoma", Font.PLAIN, 14));
- endscriptTimer.setModel(new DefaultComboBoxModel<>(new String[] {
- "0. Never",
- "1. 1 hour",
- "2. 2 hours",
- "3. 3 hours",
- "4. 4 hours",
- "5. 5 hours",
- "6. 6 hours",
- "7. 7 hours",
- "8. 8 hours",
- "9. 9 hours",
- "10. 10 hours",
- "11. 11 hours",
- "12. 12 hours"
- }));
- //---- label5 ----
- label5.setText("End script after:");
- label5.setFont(new Font("Tahoma", Font.PLAIN, 14));
- GroupLayout contentPanelLayout = new GroupLayout(contentPanel);
- contentPanel.setLayout(contentPanelLayout);
- contentPanelLayout.setHorizontalGroup(
- contentPanelLayout.createParallelGroup()
- .addGroup(contentPanelLayout.createSequentialGroup()
- .addComponent(label1)
- .addGap(0, 148, Short.MAX_VALUE))
- .addGroup(contentPanelLayout.createSequentialGroup()
- .addContainerGap()
- .addGroup(contentPanelLayout.createParallelGroup()
- .addComponent(label2)
- .addComponent(abcv2reactions)
- .addComponent(label3)
- .addGroup(contentPanelLayout.createSequentialGroup()
- .addComponent(label5)
- .addGap(45, 45, 45)
- .addComponent(endscriptTimer, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)))
- .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
- );
- contentPanelLayout.setVerticalGroup(
- contentPanelLayout.createParallelGroup()
- .addGroup(contentPanelLayout.createSequentialGroup()
- .addComponent(label1)
- .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(label2)
- .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
- .addComponent(abcv2reactions)
- .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
- .addComponent(label3)
- .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
- .addGroup(contentPanelLayout.createParallelGroup()
- .addGroup(contentPanelLayout.createSequentialGroup()
- .addGap(3, 3, 3)
- .addComponent(label5))
- .addComponent(endscriptTimer, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
- .addGap(0, 24, Short.MAX_VALUE))
- );
- }
- dialogPane.add(contentPanel, BorderLayout.CENTER);
- //======== buttonBar ========
- {
- buttonBar.setBorder(new EmptyBorder(12, 0, 0, 0));
- buttonBar.setLayout(new GridBagLayout());
- ((GridBagLayout)buttonBar.getLayout()).columnWidths = new int[] {0, 80};
- ((GridBagLayout)buttonBar.getLayout()).columnWeights = new double[] {1.0, 0.0};
- //---- okButton ----
- okButton.setText("Start Script");
- okButton.addActionListener(e -> okButtonActionPerformed(e));
- buttonBar.add(okButton, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0,
- GridBagConstraints.CENTER, GridBagConstraints.BOTH,
- new Insets(0, 0, 0, 0), 0, 0));
- }
- dialogPane.add(buttonBar, BorderLayout.SOUTH);
- }
- contentPane.add(dialogPane, BorderLayout.CENTER);
- pack();
- setLocationRelativeTo(getOwner());
- //End of component initialization
- }
- private JMenuBar menuBar1;
- private JMenu menu1;
- private JMenuItem thedtribot;
- private JMenuItem dscriptingcom;
- private JMenuItem moredscripts;
- private JPanel dialogPane;
- private JPanel contentPanel;
- private JLabel label1;
- private JLabel label2;
- private JCheckBox abcv2reactions;
- private JLabel label3;
- private JComboBox<String> endscriptTimer;
- private JLabel label5;
- private JPanel buttonBar;
- private JButton okButton;
- // end of gui
- }
- void openSite(String url)
- {
- System.out.println("Open site");
- URL a = null;
- try {
- a = new URL(url);
- } catch (MalformedURLException e1) {
- System.out.println("ERROR OPENING URL");
- e1.printStackTrace();
- }
- openWebpage(a);
- }
- public void openWebpage(URI uri) {
- System.out.println("Open webpage");
- if(Desktop.isDesktopSupported())
- {
- Desktop desktop = Desktop.getDesktop();
- if (desktop != null) {
- try {
- desktop.browse(uri);
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- }
- }
- public void openWebpage(URL url) {
- try {
- openWebpage(url.toURI());
- } catch (URISyntaxException e) {
- e.printStackTrace();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement