Guest User

Untitled

a guest
Jan 29th, 2016
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 7.24 KB | None | 0 0
  1. import org.osbot.rs07.api.ui.Skill;
  2. import org.osbot.rs07.api.ui.Spells.NormalSpells;
  3. import org.osbot.rs07.script.Script;
  4. import org.osbot.rs07.script.ScriptManifest;
  5.  
  6. import java.awt.*;
  7. import java.awt.event.WindowAdapter;
  8. import java.awt.event.WindowEvent;
  9. import java.util.concurrent.TimeUnit;
  10.  
  11. import javax.swing.JButton;
  12. import javax.swing.JComboBox;
  13. import javax.swing.JFrame;
  14.  
  15. @ScriptManifest(author = "Fugz", info = "Teleports to all Standard Magic locations", name = "fTeleporting", version = 0.2, logo = "")
  16. public class main extends Script {
  17.  
  18.     NormalSpells teleType;
  19.     String spell;
  20.     int startEXP;
  21.     int currentEXP;
  22.     int timesTele;
  23.     private int currentLevel;
  24.     private int beginningLevel;
  25.     private int levelsGained;
  26.     private long timeBegan;
  27.     private long timeRan;
  28.    
  29.     private enum State {
  30.         TELE, IDLE
  31.     };
  32.     @Override
  33.     public void onStart() {
  34.         EventQueue.invokeLater(this::initSettings);
  35.  
  36.         synchronized(main.class) {
  37.             try {
  38.                 main.class.wait(); //forces this thread to wait
  39.             } catch(InterruptedException e) {
  40.                 e.printStackTrace();
  41.             }
  42.             log("Welcome to fTeleporting");
  43.             this.experienceTracker.start(Skill.MAGIC);
  44.             main.this.mouse.setSpeed(4);
  45.             this.startEXP = this.skills.getExperience(Skill.MAGIC);
  46.             beginningLevel = skills.getStatic(Skill.MAGIC);
  47.             timeBegan = System.currentTimeMillis();
  48.            
  49.         }
  50.     }
  51.     private void initSettings() {
  52.         JFrame frame = new JFrame("Settings");
  53.         frame.setLayout(new FlowLayout());
  54.         frame.addWindowListener(new WindowAdapter() {
  55.             public void windowClosing(WindowEvent event) {
  56.                 frame.dispose();
  57.                 main.this.stop();
  58.             }
  59.         });
  60.         frame.setLocationByPlatform(true);
  61.  
  62.         NormalSpells[] teleLocation = { NormalSpells.VARROCK_TELEPORT, NormalSpells.LUMBRIDGE_TELEPORT, NormalSpells.FALADOR_TELEPORT, NormalSpells.HOUSE_TELEPORT, NormalSpells.CAMELOT_TELEPORT, NormalSpells.ARDOUGNE_TELEPORT, NormalSpells.WATCHTOWER_TELEPORT, NormalSpells.TROLLHEIM_TELEPORT, NormalSpells.TELEPORT_TO_APE_ATOLL, NormalSpells.TELEPORT_TO_KOUREND, NormalSpells.TELEPORT_TO_BOUNTY_TARGET };
  63.         JComboBox<NormalSpells> teleOptionBox = new JComboBox<>(teleLocation);
  64.         frame.add(teleOptionBox);
  65.  
  66.         JButton button = new JButton("Start");
  67.         button.addActionListener(event -> {
  68.             teleType = (NormalSpells) teleOptionBox.getSelectedItem();
  69.             frame.dispose();
  70.             synchronized(main.class) {
  71.                 main.class.notify();
  72.             }
  73.         });
  74.         frame.add(button);
  75.         frame.pack();
  76.         frame.setVisible(true);
  77.     }
  78.    
  79.     private State getState() {
  80.         if (this.inventory.contains("Law rune") && (!myPlayer().isAnimating()))
  81.             return State.TELE;
  82.         else
  83.         return State.IDLE;
  84.     }
  85.    
  86.     @Override
  87.     public int onLoop() throws InterruptedException {
  88.         switch (getState()) {
  89.         case TELE:
  90.         {
  91.             teleport();
  92.         }
  93.         break;
  94.         case IDLE:
  95.         {
  96.     idle();
  97.         }
  98.         }
  99.         return random(200, 300);
  100.     }
  101.  
  102.     @Override
  103.     public void onExit() {
  104.         log("Thanks for running fTeleporting!");
  105.     }
  106.  
  107.     @Override
  108.     public void onPaint(Graphics2D g) {
  109.         currentLevel = skills.getStatic(Skill.MAGIC);
  110.         levelsGained = currentLevel - beginningLevel;
  111.         timeRan = System.currentTimeMillis() - this.timeBegan;
  112.         g.setColor(new Color(225, 0, 0, 75));
  113.         g.fill3DRect(271, 237, 245, 100, true);
  114.         g.setColor(new Color(0, 0, 0));
  115.         g.drawString("fTeleporting by Fugz", 281, 252);
  116.         g.drawString("Time running: " + (ft(timeRan)), 281, 267);
  117.         g.drawString("Time teleported: " + this.timesTele, 281, 282);
  118.         g.drawString("Task: " + teleType.toString(), 281, 297);
  119.         g.drawString("EXP Gained: " + this.experienceTracker.getGainedXP(Skill.MAGIC) + " (" + this.experienceTracker.getGainedXPPerHour(Skill.MAGIC) + "/hr)" , 281, 312);
  120.         g.drawString("Levels Gained: " + beginningLevel + " / " + currentLevel + " ( +" + levelsGained + " )", 281, 327);
  121.     }
  122.    
  123.     private String ft(long duration)
  124.     {
  125.         String res = "";
  126.         long days = TimeUnit.MILLISECONDS.toDays(duration);
  127.         long hours = TimeUnit.MILLISECONDS.toHours(duration)
  128.         - TimeUnit.DAYS.toHours(TimeUnit.MILLISECONDS.toDays(duration));
  129.         long minutes = TimeUnit.MILLISECONDS.toMinutes(duration)
  130.         - TimeUnit.HOURS.toMinutes(TimeUnit.MILLISECONDS
  131.         .toHours(duration));
  132.         long seconds = TimeUnit.MILLISECONDS.toSeconds(duration)
  133.         - TimeUnit.MINUTES.toSeconds(TimeUnit.MILLISECONDS
  134.         .toMinutes(duration));
  135.         if (days == 0) {
  136.         res = (hours + ":" + minutes + ":" + seconds);
  137.         } else {
  138.         res = (days + ":" + hours + ":" + minutes + ":" + seconds);
  139.         }
  140.         return res;
  141.     }
  142.     private void teleport() throws InterruptedException{
  143.         runeCheck();
  144.         this.magic.open();
  145.         magic.deselectSpell();
  146.         if (!myPlayer().isAnimating()); {
  147.             sleep(random(800,1200));
  148.             this.magic.castSpell(teleType);
  149.             this.timesTele += 1L;
  150.         }
  151.         currentEXP = (this.skills.getExperience(Skill.MAGIC) - this.startEXP);
  152.         sleep(random(800,1200));
  153. }
  154.             private void idle() throws InterruptedException{
  155.                 runeCheck();
  156.             }
  157.            
  158.     private void runeCheck() throws InterruptedException{
  159.         if (teleType.toString() == "VARROCK_TELEPORT"){
  160.             if (!this.inventory.contains("Law rune") || !this.inventory.contains("Fire rune")){
  161.                 stop();
  162.             }else{
  163.                
  164.             }
  165.         }else if(teleType.toString() == "LUMBRIDGE_TELEPORT"){
  166.             if (!this.inventory.contains("Law rune") || !this.inventory.contains("Earth rune")){
  167.                 stop();
  168.             }else{
  169.                
  170.             }
  171.         }else if(teleType.toString() == "FALADOR_TELEPORT"){
  172.             if (!this.inventory.contains("Law rune") || !this.inventory.contains("Water rune")){
  173.                 stop();
  174.             }else{
  175.            
  176.             }
  177.         }else if(teleType.toString() == "HOUSE_TELEPORT"){
  178.             if (!this.inventory.contains("Law rune") || !this.inventory.contains("Earth rune")){
  179.                 stop();
  180.             }else{
  181.                
  182.             }
  183.         }else if (teleType.toString() == "CAMELOT_TELEPORT"){
  184.             if (!this.inventory.contains("Law rune")){
  185.                 stop();
  186.             }else{
  187.                
  188.             }
  189.         }else if (teleType.toString() == "ARDOUGNE_TELEPORT"){
  190.             if (!this.inventory.contains("Law rune")){
  191.                 stop();
  192.             }else{ 
  193.             }
  194.         }else if (teleType.toString() == "WATCHTOWER_TELEPORT"){
  195.             if (!this.inventory.contains("Law rune")){
  196.             stop();
  197.             }else{
  198.                
  199.             }
  200.         }else if (teleType.toString() == "TROLLHEIM_TELEPORT"){
  201.             if (!this.inventory.contains("Law rune")){
  202.                 stop();
  203.             }else{
  204.                
  205.             }
  206.         }else if (teleType.toString() == "TELEPORT_TO_APE_TOLL"){
  207.             if (!this.inventory.contains("Law rune") || !this.inventory.contains("Banana")){
  208.                 stop();
  209.             }else{
  210.                
  211.             }
  212.         }else if (teleType.toString() == "TELEPORT_TO_KOUREND"){
  213.             if (!this.inventory.contains("Law rune") || !this.inventory.contains("Soul rune")){
  214.                 stop();
  215.             }else{
  216.                
  217.             }
  218.         }else if (teleType.toString() == "TELEPORT_TO_BOUNTY_TARGET"){
  219.             if (!this.inventory.contains("Law rune") || !this.inventory.contains("Death rune") || !this.inventory.contains("Chaos rune")){
  220.                 stop();
  221.             }else{
  222.                
  223.             }
  224.         }
  225.     }
  226. }
Advertisement
Add Comment
Please, Sign In to add comment