NissanNut

AutoTalker

Jul 10th, 2012
181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 4.84 KB | None | 0 0
  1. import javax.swing.SwingUtilities;
  2.  
  3. import org.omg.CORBA.Environment;
  4. import org.runedream.api.Script;
  5. import org.runedream.api.ScriptManifest;
  6. import org.runedream.api.methods.Camera;
  7. import org.runedream.api.methods.Game;
  8. import org.runedream.api.methods.Keyboard;
  9. import org.runedream.api.util.Log;
  10. import org.runedream.api.util.Random;
  11. import org.runedream.api.util.Timer;
  12.  
  13. @ScriptManifest(
  14.         authors = { "Nissan Nut" },
  15.         name = "Nissan's AutoTalker",
  16.         version = 1.0,
  17.         description = "Nissan Nut's Auto typing tool.",
  18.         keywords = {"Nissan Nut" , "Auto" , "Talker", "AutoTalker"},
  19.         language = { true, true, true, true })
  20.  
  21. public class AutoTalker extends Script {
  22.  
  23.     AutoTalkerUI UI = new AutoTalkerUI();
  24.    
  25.     private boolean start = false;
  26.     private boolean msg1;
  27.     private boolean msg2;
  28.     private boolean msg3;
  29.     private boolean msg4;
  30.     private boolean msg5;
  31.     private boolean randomize;
  32.     private boolean humanlike;
  33.     private boolean rotation;
  34.     private boolean randomorder;
  35.    
  36.     private String msg_1;
  37.     private String msg_2;
  38.     private String msg_3;
  39.     private String msg_4;
  40.     private String msg_5;
  41.    
  42.     private int intervalS, intervalMs;
  43.     private int keystrokeMin, keystrokeMax;
  44.    
  45.     private Timer interval = new Timer(10);
  46.    
  47.     @Override
  48.     public boolean onStart(){
  49.        
  50.         try {
  51.             SwingUtilities.invokeAndWait(new Runnable() {
  52.                 public void run() {
  53.                     UI.setVisible(true);
  54.                     }
  55.                 });
  56.             } catch (Throwable e) {
  57.         }
  58.        
  59.         return true;
  60.     }
  61.    
  62.     @Override
  63.     public int loop() {
  64.        
  65.         Update();
  66.        
  67.         if (start && interval.getRemaining() <= 0){
  68.            
  69.             if(humanlike && randomorder){
  70.                 if (msg1 && Random.random(1, 5) == 1)
  71.                     Keyboard.sendKeys(msg_1, true, keystrokeMin, keystrokeMax);
  72.                
  73.                 if (msg2 && Random.random(1, 5) == 1)
  74.                     Keyboard.sendKeys(msg_2, true, keystrokeMin, keystrokeMax);
  75.                
  76.                 if (msg3 && Random.random(1, 5) == 1)
  77.                     Keyboard.sendKeys(msg_3, true, keystrokeMin, keystrokeMax);
  78.                
  79.                 if (msg4 && Random.random(1, 5) == 1)
  80.                     Keyboard.sendKeys(msg_4, true, keystrokeMin, keystrokeMax);
  81.                
  82.                 if (msg5 && Random.random(1, 5) == 1)
  83.                     Keyboard.sendKeys(msg_5, true, keystrokeMin, keystrokeMax);
  84.                
  85.             }else if (randomorder){
  86.                 if (msg1 && Random.random(1, 5) == 1)
  87.                     Keyboard.sendKeysInstant(msg_1, true);
  88.                
  89.                 if (msg2 && Random.random(1, 5) == 1)
  90.                     Keyboard.sendKeysInstant(msg_2, true);
  91.                
  92.                 if (msg3 && Random.random(1, 5) == 1)
  93.                     Keyboard.sendKeysInstant(msg_3, true);
  94.                
  95.                 if (msg4 && Random.random(1, 5) == 1)
  96.                     Keyboard.sendKeysInstant(msg_4, true);
  97.                
  98.                 if (msg5 && Random.random(1, 5) == 1)
  99.                     Keyboard.sendKeysInstant(msg_5, true);
  100.                
  101.                
  102.             }else if (humanlike){
  103.                 if (msg1)
  104.                     Keyboard.sendKeys(msg_1, true, keystrokeMin, keystrokeMax);
  105.                
  106.                 if (msg2)
  107.                     Keyboard.sendKeys(msg_2, true, keystrokeMin, keystrokeMax);
  108.                
  109.                 if (msg3)
  110.                     Keyboard.sendKeys(msg_3, true, keystrokeMin, keystrokeMax);
  111.                
  112.                 if (msg4)
  113.                     Keyboard.sendKeys(msg_4, true, keystrokeMin, keystrokeMax);
  114.                
  115.                 if (msg5)
  116.                     Keyboard.sendKeys(msg_5, true, keystrokeMin, keystrokeMax);
  117.                
  118.             }else{
  119.                 if (msg1)
  120.                     Keyboard.sendKeysInstant(msg_1, true);
  121.                
  122.                 if (msg2)
  123.                     Keyboard.sendKeysInstant(msg_2, true);
  124.                
  125.                 if (msg3)
  126.                     Keyboard.sendKeysInstant(msg_3, true);
  127.                
  128.                 if (msg4)
  129.                     Keyboard.sendKeysInstant(msg_4, true);
  130.                
  131.                 if (msg5)
  132.                     Keyboard.sendKeysInstant(msg_5, true);
  133.                
  134.             }
  135.            
  136.             Log.log(msg_1);
  137.            
  138.             int i = intervalS * 1000 + intervalMs;
  139.             if (randomize)
  140.                 i += Random.random(0, 250);
  141.            
  142.             interval.setEndIn(i);
  143.            
  144.             if (rotation)
  145.                 Rotate();
  146.         }
  147.        
  148.         return Random.random(1, 5);
  149.     }
  150.  
  151.     private void Rotate() {
  152.         for (int i=0; i<Random.random(1, 4); i++){
  153.                         if (Random.random(1, 70) == 1)
  154.                                 Camera.rotateLeft(Random.random(100, 1000));
  155.                         if (Random.random(1, 70) == 1)
  156.                                 Camera.rotateRight(Random.random(100, 1000));
  157.                         if (Random.random(1, 70) == 1)
  158.                                 Camera.pitchDown(Random.random(100, 1000));
  159.                         if (Random.random(1, 70) == 1)
  160.                                 Camera.pitchUp(Random.random(100,  1000));
  161.         }
  162.     }
  163.  
  164.     private void Update() {
  165.         start = UI.start;
  166.         msg1 = UI.msg1;
  167.         msg2 = UI.msg2;
  168.         msg3 = UI.msg3;
  169.         msg4 = UI.msg4;
  170.         msg5 = UI.msg5;
  171.         randomize = UI.randomize;
  172.         humanlike = UI.humanlike;
  173.         rotation = UI.rotation;
  174.         randomorder = UI.randomorder;
  175.        
  176.         msg_1 = UI.msg_1;
  177.         msg_2 = UI.msg_2;
  178.         msg_3 = UI.msg_3;
  179.         msg_4 = UI.msg_4;
  180.         msg_5 = UI.msg_5;
  181.        
  182.         intervalS = UI.intervalS;
  183.         intervalMs = UI.intervalMs;
  184.         keystrokeMin = UI.keystrokeMin;
  185.         keystrokeMax = UI.keystrokeMax;
  186.     }
  187.  
  188. }
Advertisement
Add Comment
Please, Sign In to add comment