Guest User

Untitled

a guest
Dec 7th, 2017
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 8.07 KB | None | 0 0
  1. import org.rsbot.script.*;
  2. import org.rsbot.script.wrappers.*;
  3. import org.rsbot.event.events.MessageEvent;
  4. import org.rsbot.event.listeners.*;
  5. import java.awt.*;
  6.  
  7. @ScriptManifest(
  8.         authors = {"Legobumb",""},
  9.         keywords = {"",""},
  10.         name = "Legobumb Lobster Fisher BETA",
  11.         description = "Improved Lobster fishing script",
  12.         version = 1.1
  13.         )
  14.  
  15. public class LegoLobster extends Script implements PaintListener,
  16.                                                    MessageListener
  17. {
  18.     int lobSpotID = 324;
  19.     int lobPotID = 301;
  20.     int stilesID = 11267;
  21.     int fishAnim = 619;
  22.     int gainedLevels = 0;
  23.     int caughtFish = 0;
  24.     int expGained = 0;
  25.    
  26.     Timer t;
  27.    
  28.     String status = "Nothing";
  29.    
  30.     RSArea atStiles;
  31.     RSArea atFish;
  32.    
  33.     RSTilePath pathToStiles;
  34.     RSTilePath pathToFish;
  35.     RSTile tilesToFish[] = {new RSTile(2857,3146),new RSTile(2863,3149),
  36.                               new RSTile(2869,3149),new RSTile(2875,3153),
  37.                               new RSTile(2882,3157),new RSTile(2887,3161),
  38.                               new RSTile(2893,3164),new RSTile(2900,3169),
  39.                               new RSTile(2907,3172),new RSTile(2913,3172),
  40.                               new RSTile(2920,3174),new RSTile(2924,3178)};
  41.     /*RSTile tilesToStiles[] = {new RSTile(2922,3176),new RSTile(2917,3174),
  42.                             new RSTile(2912,3172),new RSTile(2906,3171),
  43.                             new RSTile(2900,3169),new RSTile(2894,3168),
  44.                             new RSTile(2888,3165),new RSTile(2884,3161),
  45.                             new RSTile(2882,3157),new RSTile(2879,3153),
  46.                             new RSTile(2873,3151),new RSTile(2867,3148),
  47.                             new RSTile(2861,3147),new RSTile(2855,3144),
  48.                             new RSTile(2851,3142)};*/
  49.     RSTile toStiles;
  50.    
  51.     @Override
  52.     public boolean onStart()
  53.     {
  54.         if(!inventory.contains(lobPotID))
  55.         {
  56.             log("No Lobster Pot in inventory. Script stopping...");
  57.             return false;
  58.         }
  59.         initialize();
  60.         return true;
  61.     }
  62.     @Override
  63.     public void onFinish()
  64.     {
  65.     }
  66.     @Override
  67.     public int loop()
  68.     {
  69.         if(atFish.contains(players.getMyPlayer().getLocation()))
  70.         {
  71.             if(inventory.isFull())
  72.             {
  73.                 camera.setCompass('n');
  74.                 camera.setPitch(true);
  75.                 walking.walkTo(toStiles);
  76.                 status = "Walking to Stiles";
  77.             }
  78.             else
  79.             {
  80.                 status = "Finding fishing spot";
  81.                 nextSpot();
  82.             }
  83.         }
  84.         else if(atStiles.contains(players.getMyPlayer().getLocation()))
  85.         {
  86.             if(inventory.isFull())
  87.             {
  88.                 status = "Echanging fish";
  89.                 stiles();
  90.             }
  91.             else
  92.             {
  93.                 status = "Walking to fishing spots";
  94.                 pathToFish.traverse();
  95.             }
  96.         }
  97.         else
  98.         {
  99.             if(inventory.isFull())
  100.             {
  101.                 status = "Walking to Stiles";
  102.                 walking.walkTo(toStiles);
  103.             }
  104.             else
  105.             {
  106.                 status = "Walking to fishing spots";
  107.                 pathToFish.traverse();
  108.             }
  109.         }
  110.         return random(10,50);
  111.     }
  112.    
  113.    
  114.    
  115.     private void initialize()
  116.     {
  117.         mouse.setSpeed(6);
  118.         atFish = new RSArea(2920,3174,2927,3181);
  119.         atStiles = new RSArea(2849,3141,2853,3145);
  120.         toStiles = new RSTile(2851,3142);
  121.         //pathToStiles = walking.newTilePath(tilesToStiles);
  122.         pathToFish = walking.newTilePath(tilesToFish);
  123.         startTime = System.currentTimeMillis();
  124.         t = new Timer();
  125.         t.setStart();
  126.     }
  127.     private void nextSpot()
  128.     {
  129.         if(players.getMyPlayer().getAnimation() != fishAnim)
  130.         {
  131.             RSNPC spots[] = npcs.getAll(lobSpotID);
  132.             camera.setCompass('s');
  133.             camera.setPitch(true);
  134.             for(int i=0; i<spots.length; i++)
  135.             {
  136.                 RSNPC spot = spots[i];
  137.                 if(spot != null && spot.isOnScreen())
  138.                 {
  139.                     if(spot.interact("Cage"))
  140.                     {
  141.                         sleep(3000);
  142.                         break;
  143.                     }
  144.                 }
  145.             }
  146.         }
  147.         else
  148.         {
  149.             status = "Fishing";
  150.             if(t.end <= System.currentTimeMillis())
  151.             {
  152.                 t.reset();
  153.                 antiAutoLog();
  154.             }
  155.         }
  156.     }
  157.     private void stiles()
  158.     {
  159.         RSNPC stiles = npcs.getNearest(stilesID);
  160.         if(stiles != null)
  161.         {
  162.             stiles.interact("Exchange");
  163.             sleep(1500);
  164.         }
  165.     }
  166.     private void antiAutoLog()
  167.     {
  168.         int r = random(0,500);
  169.         if(r >= 485)
  170.         {
  171.             keyboard.sendText("Fishing levels?", true);
  172.         }
  173.         else
  174.         {
  175.             camera.moveRandomly(random(100,1000));
  176.         }
  177.     }
  178.    
  179.    
  180.     private class Timer
  181.     {
  182.         long end = 0;
  183.         private void setStart()
  184.         {
  185.             end = System.currentTimeMillis()+random(15000,120000);
  186.         }
  187.         private void reset()
  188.         {
  189.             end = System.currentTimeMillis()+random(15000,120000);
  190.         }
  191.     }
  192.    
  193.    
  194.    
  195.     @Override
  196.     public void messageReceived(MessageEvent e)
  197.     {
  198.         String txt = e.getMessage().toLowerCase();
  199.         if(txt.contains("advanced"))
  200.         {
  201.             gainedLevels ++;
  202.         }
  203.         else if(txt.contains("you catch"))
  204.         {
  205.             caughtFish ++;
  206.             expGained += 90;
  207.         }
  208.     }
  209.    
  210.     private final Color teal = new Color(0, 204, 255);
  211.  
  212.     private final Font font1 = new Font("Verdana", 1, 14);
  213.     private final Font font2 = new Font("Verdana", 1, 12);
  214.  
  215.     private long startTime = 0, millis = 0, seconds = 0, minutes = 0, hours = 0;
  216.    
  217.     @Override
  218.     public void onRepaint(Graphics g1)
  219.     {
  220.         Graphics2D g = (Graphics2D) g1;
  221.         g.setFont(font1);
  222.         g.setColor(teal);
  223.         g.drawString("Fishing Level:", 5, 45);
  224.         g.fillRoundRect(402, 480, 113, 22, 16, 16);
  225.         g.drawString("Fishing Progress:", 5, 63);
  226.         g.drawString("Time:",5,81);
  227.         g.drawString("Fish Caught:",5,99);
  228.         g.drawString("per hour:",29,117);
  229.         g.drawString("Exp Gained:",5,135);
  230.         g.drawString("per hour:",24,153);
  231.         g.drawString("Fish till Level:",5,171);
  232.         g.setColor(Color.red);
  233.         millis = System.currentTimeMillis()-startTime;
  234.         hours = millis/(1000*60*60);
  235.         millis -= hours*(1000*60*60);
  236.         minutes = millis/(1000*60);
  237.         millis -= minutes*(1000*60);
  238.         seconds = millis/1000;
  239.         g.drawString(hours+":"+minutes+":"+seconds,50,81);
  240.         g.setColor(Color.green);
  241.         g.drawString(String.valueOf(caughtFish),106,99);
  242.         int perHour = (int) ((caughtFish*3600000D)/(System.currentTimeMillis()-startTime));
  243.         if(perHour < 0)
  244.         {
  245.             perHour = 0;
  246.         }
  247.         g.drawString(String.valueOf(perHour),106,117);
  248.         g.drawString(String.valueOf(expGained),100,135);
  249.         perHour = (int) ((expGained*3600000D)/(System.currentTimeMillis()-startTime));
  250.         if(perHour < 0)
  251.         {
  252.             perHour = 0;
  253.         }
  254.         g.drawString(String.valueOf(perHour),100,153);
  255.         String str = String.valueOf(skills.getCurrentLevel(skills.FISHING))+" (+"+String.valueOf(gainedLevels)+")";
  256.         g.drawString(str, 115, 45);
  257.         int percent = skills.getPercentToNextLevel(skills.FISHING);
  258.         g.drawString(String.valueOf(percent) +"%", 144, 63);
  259.         g.setColor(Color.orange);
  260.         int tillLvl = skills.getExpToNextLevel(skills.FISHING)/90;
  261.         g.drawString(String.valueOf(tillLvl),110,171);
  262.         g.setColor(Color.black);
  263.         g.drawString("by Legobumb", 406, 497);
  264.         g.setFont(font2);
  265.         g.setColor(Color.orange);
  266.         g.drawString("Lego Lobster v1.1", 395, 335);
  267.         g.setColor(Color.red);
  268.         g.drawString("Status:", 4, 334);
  269.         g.setColor(Color.green);
  270.         g.drawString(status, 53, 334);
  271.     }
  272. }
Add Comment
Please, Sign In to add comment