Share Pastebin
Guest
Public paste!

Pyratepig

By: a guest | Mar 21st, 2010 | Syntax: JavaScript | Size: 7.50 KB | Hits: 64 | Expires: Never
Copy text to clipboard
  1. import java.awt.Color;
  2. import java.awt.Font;
  3. import java.awt.Graphics;
  4. import java.awt.Point;
  5. import java.util.Map;
  6.  
  7. import org.rsbot.event.listeners.PaintListener;
  8. import org.rsbot.script.Calculations;
  9. import org.rsbot.script.Constants;
  10. import org.rsbot.script.Script;
  11. import org.rsbot.script.ScriptManifest;
  12. import org.rsbot.script.wrappers.RSInterface;
  13. import org.rsbot.script.wrappers.RSNPC;
  14. import org.rsbot.script.wrappers.RSObject;
  15. import org.rsbot.script.wrappers.RSTile;
  16. import java.awt.Graphics2D;
  17. import java.awt.RenderingHints;
  18. import org.rsbot.event.events.ServerMessageEvent;
  19.  
  20. @ScriptManifest(authors = "Pyratepig", category = "Mining", name = "Pyratepig'sTinMiner", version = 1.0, description =
  21.  
  22. "Pyrate's TinMiner. Start in bank, minining area, with pickaxe wielded or in inventory.")
  23. public class PyratePigTinMiner extends Script implements PaintListener{
  24.  
  25.  public RSObject rock;
  26.     RSTile [ ]  bankToRocks = {new RSTile (3168, 3425), new RSTile(3172, 3408), new RSTile(3173, 3394), new RSTile
  27.  
  28. (3177, 3381), new RSTile(3174, 3367) } ;
  29.     RSTile [ ]  rocksToBank = {new RSTile (3177, 3369), new RSTile(3168, 3372), new RSTile(3162, 3382), new RSTile
  30.  
  31. (3164, 3398), new RSTile(3164, 3413), new RSTile(3173, 3426), new RSTile(3182, 3436) } ;
  32.     public int oreID = (11957);
  33.     public int pickaxeID [] = {1265, 1267, 1269, 1273, 1271, 1275} ;
  34.     RSObject tinrock;
  35.     RSTile bankTile = new RSTile(3182, 3436) ;
  36.     RSTile miningAreaTile = new RSTile(3177, 3369) ;
  37.     RSNPC banker;
  38.     int Tin = 11957;
  39.     int pickaxe=1265;
  40.     public long startTime = System.currentTimeMillis();
  41.     public int startexp;
  42.     public int tinPrice = 91;
  43.     public int exp;
  44.     public int expGained;
  45.     public int levelsGained;
  46.     public int energyToRunAt = random(25, 100);
  47.     public int bankerID = 6533;
  48.     private String status = "";
  49.  
  50.  
  51.  
  52.         public boolean onStart( Map<String,String> args ) {
  53.         setCompass('n');
  54.             return true;
  55.         }
  56.     public void serverMessageRecieved(ServerMessageEvent e) {
  57.         if(e.getMessage().contains("You've just advanced a Mining level!")) {
  58.         levelsGained++;
  59.         }
  60.     }
  61.  
  62.     private boolean openBank() {
  63.         RSNPC banker = getNearestNPCByID(5912);
  64.         if (banker != null) {
  65.         if (tileOnScreen(banker.getLocation())) {
  66.             wait(random(50,100));
  67.             turnToTile(banker.getLocation(), 15);
  68.             atNPC(banker, "Bank Banker");
  69.         }
  70.     }
  71.     return false;
  72.         }
  73.     public int Mine() {
  74.     if(getMyPlayer().getAnimation() == -1) {
  75.         RSObject Rock = getNearestObjectByID(11959);
  76.         if (Rock != null){
  77.                     if(distanceTo(Rock.getLocation()) <= 3){
  78.             turnToTile(Rock.getLocation());
  79.             wait(random(300, 500));
  80.         }
  81.        
  82.         if (distanceTo(Rock.getLocation()) >= 4) {
  83.              turnToTile(Rock.getLocation());
  84.              wait(random(300, 500));
  85.          }
  86.  
  87.         if (distanceTo(Rock.getLocation()) > random(5,6)) {
  88.             walkTileMM(Rock.getLocation());
  89.             wait(random(200, 500));
  90.         }
  91.             if(tileOnScreen(Rock.getLocation())) {
  92.             setCompass('w');
  93.             setCameraAltitude(true);
  94.             atObject(Rock,"Mine Tin");
  95.             wait(random(300,500));
  96.             }
  97.     }
  98.         }
  99.             return 500;
  100. }
  101.     public boolean walkToBank(){
  102.         if (distanceTo(bankTile) > 8) {
  103.         if (distanceTo(getDestination()) < random(5, 12)
  104.                 || distanceTo(getDestination()) > 100) {
  105.         if (!walkPathMM(rocksToBank)) {
  106.                 walkToClosestTile(rocksToBank);
  107.         }
  108. }
  109.         }
  110.   return true;
  111.    
  112.     }
  113.     public boolean walkToRocks(){
  114.         if (distanceTo(miningAreaTile) > 20) {
  115.         if (distanceTo(getDestination()) < random(5, 12)
  116.                 || distanceTo(getDestination()) > 40) {
  117.         if (!walkPathMM(bankToRocks)) {
  118.                 walkToClosestTile(bankToRocks);
  119.         }
  120. }
  121.         }
  122. return true;
  123.     }
  124.     private int antiBan(){
  125.         final int random = random(1,20);
  126.         switch (random) {
  127.         case 1:
  128.        
  129.         if(random(1, 45) == 3){
  130.             moveMouseRandomly(300);
  131.            
  132.            
  133.         }
  134.         return random(100, 500);
  135.        
  136.         case 2:
  137.         if(random(1, 50) == 19){
  138.             setCameraRotation(75);
  139.            
  140.  
  141.         }
  142.         return random(100, 500);
  143.         case 3:
  144.         if(random(1, 35) == 4){
  145.             openTab(Constants.TAB_STATS);
  146.             moveMouse(random(665, 395), random(709, 412));
  147.         }
  148.         return random(100, 500);
  149.        
  150.         case 4:
  151.         if(random(1, 23) == 8){
  152.             moveMouseRandomly(600);
  153.         }
  154.         return random(100, 500);
  155.         case 5:
  156.         if(random(1, 29) == 6){
  157.             setCameraRotation(189);
  158.         }
  159.         return random(100, 500);
  160.         }
  161.         return 800;
  162.        
  163.     }
  164. public int loop() {
  165.     if(getEnergy() >= energyToRunAt){
  166.         setRun(true);
  167.     }
  168.     if(getMyPlayer().getAnimation() != -1){
  169.     setCameraAltitude(true);
  170.     status = "Mining...";
  171.     }
  172.     if(isInventoryFull()){
  173.     antiBan();
  174.     status = "Walking to bank..";
  175.         walkToBank();
  176.         if (RSInterface.getInterface(Constants.INTERFACE_BANK).isValid()) {
  177.             bank.depositAllExcept(pickaxeID);
  178.         } else {
  179.             openBank();
  180.         }
  181.     }else{
  182.         walkToRocks();
  183.         Mine();
  184.        
  185.     }
  186.     return random(800, 1000);
  187. }
  188. public void onRepaint(Graphics g) {
  189.     ((Graphics2D) g).setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
  190.      if (isLoggedIn()) {
  191.          
  192.          if ( startexp == 0) {
  193.             startexp = skills.getCurrentSkillExp(Constants.STAT_MINING);
  194.        }
  195.            
  196.        expGained = skills.getCurrentSkillExp(Constants.STAT_MINING) - startexp;
  197.  
  198.          
  199.          
  200.          long millis = System.currentTimeMillis() - startTime;
  201.         long hours = millis / (1000 * 60 * 60);
  202.         millis -= hours * (1000 * 60 * 60);
  203.         long minutes = millis / (1000 * 60);
  204.         millis -= minutes * (1000 * 60);
  205.         long seconds = millis / 1000;
  206.         long minutes2 = minutes + (hours * 60);
  207.         g.setColor(new Color(0, 0, 0, 140));
  208.         g.fillRect(549, 207, 186, 256);
  209.         g.setColor(new Color(47, 47, 89, 200));
  210.         g.setColor(Color.GREEN);
  211.         g.setFont(new Font("southpark", Font.PLAIN, 14));
  212.         g.drawString("Pyrate Tin Miner", 565, 237);
  213.         g.setFont(new Font("southpark", Font.PLAIN, 10));
  214.         g.drawString("Script by Pyratepig" , 578, 253);
  215.         g.drawString("Gained : " + levelsGained+" Level(s)" , 580, 272);
  216.         g.setFont(new Font("southpark", Font.PLAIN, 10));
  217.         g.drawString("Time running:"+hours+":"+minutes+":"+seconds+"." , 566, 309);
  218.         g.drawString("EXP Gained:"+expGained , 566, 349);
  219.         g.drawString("Tin Mined: "+ expGained / 175  + "Tin Mined" , 569, 443);
  220.         g.drawString("Status:"+ status , 566, 410);
  221.         g.setFont(new Font("southpark", Font.PLAIN, 10));
  222.         g.setColor(Color.RED);  
  223.         g.fill3DRect(566, 386, 150, 11, true);
  224.         g.setColor(Color.GREEN);
  225.         g.fill3DRect(566, 386, skills.getPercentToNextLevel(Constants.STAT_MINING), 11, true);  
  226.          g.setColor(Color.BLACK);
  227.         g.drawString(skills.getPercentToNextLevel(Constants.STAT_MINING) + "%  to " +
  228.  
  229. (skills.getCurrentSkillLevel
  230.  
  231. (Constants.STAT_MINING) + 1), 586, 396);        
  232.     }
  233. }
  234. }