Advertisement
Guest User

F2P Progressive Lobsters 0.1

a guest
Dec 6th, 2017
211
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 10.21 KB | None | 0 0
  1. import java.awt.Color;
  2. import java.awt.Font;
  3. import java.awt.Graphics2D;
  4. import java.awt.image.BufferedImage;
  5. import org.osbot.rs07.api.map.Area;
  6. import org.osbot.rs07.api.model.NPC;
  7. import org.osbot.rs07.api.model.RS2Object;
  8. import org.osbot.rs07.api.ui.Skill;
  9. import org.osbot.rs07.script.Script;
  10. import org.osbot.rs07.script.ScriptManifest;
  11. import org.osbot.rs07.utility.ConditionalSleep;
  12.  
  13. @ScriptManifest(author = "Castro_", info = "", logo = "https://i.imgur.com/hJ93X3w.png", name = ">C<Progressive Lobsters", version = 0.1)
  14. public class Main extends Script {
  15.  
  16.     public String status = "";
  17.  
  18.     Area LUMBRIDGE_SHRIMP_AREA = new Area(3232, 3142, 3247, 3156);
  19.  
  20.     Area LUMBRIDGE_POWERFISH_AREA = new Area(3238, 3238, 3244, 3255);
  21.  
  22.     Area PORT_SARIM_DEPOSIT_AREA = new Area(3041, 3232, 3047, 3237);
  23.     Area PORT_SARIM_CHARTER_AREA = new Area(3023, 3213, 3029, 3223);
  24.     Area KARAMJA_BOAT_INSIDE_AREA = new Area(2955, 3142, 2957, 3144).setPlane(1);
  25.     Area PORT_SARIM_BOAT_INSIDE_AREA = new Area(3031, 3215, 3033, 3219).setPlane(1);
  26.     Area KARAMJA_CHARTER_AREA = new Area(2949, 3146, 2957, 3150);
  27.     Area LOBSTER_AREA = new Area(2918, 3173, 2929, 3180);
  28.  
  29.     // paint:
  30.     private long startTime;
  31.  
  32.     public final String formatTime(final long ms) {
  33.         long s = ms / 1000, m = s / 60, h = m / 60, d = h / 24;
  34.         s %= 60;
  35.         m %= 60;
  36.         h %= 24;
  37.  
  38.         return d > 0 ? String.format("%02d:%02d:%02d:%02d", d, h, m, s)
  39.                 : h > 0 ? String.format("%02d:%02d:%02d", h, m, s) : String.format("%02d:%02d", m, s);
  40.     }
  41.  
  42.     public final String formatValue(final long l) {
  43.         return (l > 1_000_000) ? String.format("%.2fm", ((double) l / 1_000_000))
  44.                 : (l > 1000) ? String.format("%.1fk", ((double) l / 1000)) : l + "";
  45.     }
  46.  
  47.     public void onStart() {
  48.  
  49.         startTime = System.currentTimeMillis();
  50.         getExperienceTracker().start(Skill.FISHING);
  51.  
  52.     }
  53.  
  54.     @Override
  55.     public int onLoop() throws InterruptedException {
  56.  
  57.                 if (skills.getStatic(Skill.FISHING) < 20) {
  58.  
  59.                     if (LUMBRIDGE_SHRIMP_AREA.contains(myPlayer().getPosition())) {
  60.  
  61.                         FISH_SHRIMPS();
  62.  
  63.                         if (getInventory().isFull()) {
  64.  
  65.                             DROP_FISH();
  66.  
  67.                         }
  68.  
  69.                     } else {
  70.  
  71.                         if (!LUMBRIDGE_SHRIMP_AREA.contains(myPlayer().getPosition())) {
  72.  
  73.                             WALKING_TO_SHRIMPS();
  74.                         }
  75.                     }
  76.  
  77.                 } else {
  78.  
  79.                     if (skills.getStatic(Skill.FISHING) >= 20 && skills.getStatic(Skill.FISHING) < 40) {
  80.  
  81.                         if (skills.getStatic(Skill.FISHING) >= 20 && getInventory().contains("Small fishing net")) {
  82.  
  83.                             DROP_OLD_GEAR();
  84.  
  85.                         } else {
  86.  
  87.                             if (LUMBRIDGE_POWERFISH_AREA.contains(myPlayer().getPosition())) {
  88.  
  89.                                 FISH_TROUT();
  90.  
  91.                                 if (getInventory().isFull()) {
  92.  
  93.                                     DROP_FISH();
  94.  
  95.                                 }
  96.  
  97.                             } else {
  98.  
  99.                                 if (!LUMBRIDGE_POWERFISH_AREA.contains(myPlayer().getPosition())) {
  100.  
  101.                                     WALKING_TO_POWERFISH();
  102.  
  103.                                 }
  104.  
  105.                             }
  106.  
  107.                         }
  108.  
  109.                     } else {
  110.  
  111.                         if (skills.getStatic(Skill.FISHING) >= 40) {
  112.  
  113.                             if (skills.getStatic(Skill.FISHING) >= 40 && getInventory().contains("Fly fishing rod")
  114.                                     || getInventory().contains("Feather")) {
  115.  
  116.                                 DROP_OLD_GEAR();
  117.  
  118.                             } else {
  119.  
  120.                                 if (LOBSTER_AREA.contains(myPlayer().getPosition()) && !getInventory().isFull()) {
  121.  
  122.                                     FISH_LOBSTER();
  123.  
  124.                                 } else {
  125.  
  126.                                     if (getInventory().isFull() && !PORT_SARIM_DEPOSIT_AREA.contains(myPlayer().getPosition())) {
  127.  
  128.                                         WALKING_TO_DEPOSIT_BOX();
  129.  
  130.                                     } else {
  131.  
  132.                                         if (PORT_SARIM_DEPOSIT_AREA.contains(myPlayer().getPosition())
  133.                                                 && getInventory().contains("Raw lobster")) {
  134.  
  135.                                             DEPOSIT_FISH();
  136.  
  137.                                         } else {
  138.  
  139.                                             if (!LOBSTER_AREA.contains(myPlayer().getPosition())
  140.                                                     && getInventory().getAmount("Coins") >= 30
  141.                                                     && !getInventory().contains("Raw lobster")) {
  142.  
  143.                                                 WALKING_TO_LOBSTER_BOAT();
  144.  
  145.                                             } else {
  146.  
  147.                                                 if (!LOBSTER_AREA.contains(myPlayer().getPosition())
  148.                                                         && getInventory().getAmount("Coins") <= 29
  149.                                                         && !getInventory().contains("Raw lobster")) {
  150.  
  151.                                                     status = "Logging out as we do not have enough GP for boat fares...";
  152.                                                     log(status);
  153.                                                     logoutTab.logOut();
  154.  
  155.                                                     status = "Stopping script.";
  156.                                                     log(status);
  157.                                                     stop();
  158.  
  159.                                                 }
  160.  
  161.                                             }
  162.                                         }
  163.                                     }
  164.                                 }
  165.                             }
  166.                         }
  167.                     }
  168.                 }
  169.    
  170.         return 20;
  171.     }
  172.  
  173.     public void WALKING_TO_SHRIMPS() {
  174.  
  175.         status = "Walking to Lumbridge shrimp spot...";
  176.         log(status);
  177.  
  178.         getWalking().webWalk(LUMBRIDGE_SHRIMP_AREA.getRandomPosition());
  179.  
  180.     }
  181.  
  182.     public void WALKING_TO_POWERFISH() {
  183.  
  184.         status = "Walking to Lumbridge Trout and Salmon spot...";
  185.         log(status);
  186.  
  187.         getWalking().webWalk(LUMBRIDGE_POWERFISH_AREA.getRandomPosition());
  188.  
  189.     }
  190.  
  191.     public void WALKING_TO_LOBSTER_BOAT() {
  192.  
  193.         status = "Walking to Lobster spot...";
  194.         log(status);
  195.  
  196.         getWalking().webWalk(LOBSTER_AREA);
  197.  
  198.     }
  199.  
  200.     public void WALKING_TO_DEPOSIT_BOX() {
  201.  
  202.         status = "Walking to Deposit box...";
  203.         log(status);
  204.  
  205.         getWalking().webWalk(PORT_SARIM_DEPOSIT_AREA);
  206.  
  207.     }
  208.  
  209.     public void FISH_SHRIMPS() {
  210.  
  211.         NPC SHRIMP_SPOT = getNpcs().closest("Fishing spot");
  212.  
  213.         if (myPlayer().getAnimation() == -1 && !myPlayer().isMoving() && !getInventory().isFull()) {
  214.  
  215.             if (SHRIMP_SPOT != null) {
  216.  
  217.                 SHRIMP_SPOT.interact("Net");
  218.  
  219.             }
  220.  
  221.             try {
  222.                 sleep(random(1250, 1750));
  223.             } catch (InterruptedException e) {
  224.                 e.printStackTrace();
  225.             }
  226.  
  227.             status = "Fishing: Shrimps";
  228.             log(status);
  229.  
  230.             new ConditionalSleep(random(5000, 10000)) {
  231.                 @Override
  232.                 public boolean condition() {
  233.                     return myPlayer().getAnimation() == -1;
  234.                 }
  235.             }.sleep();
  236.  
  237.         } else {
  238.  
  239.             if (myPlayer().getAnimation() != -1) {
  240.  
  241.                 try {
  242.                     sleep(random(500, 5000));
  243.                 } catch (InterruptedException e) {
  244.                     e.printStackTrace();
  245.                 }
  246.  
  247.             }
  248.         }
  249.  
  250.     }
  251.  
  252.     public void FISH_TROUT() {
  253.  
  254.         NPC TROUT_SALMON_SPOT = getNpcs().closest("Fishing spot");
  255.  
  256.         if (myPlayer().getAnimation() == -1 && !myPlayer().isMoving() && !getInventory().isFull()) {
  257.  
  258.             if (TROUT_SALMON_SPOT != null) {
  259.  
  260.                 TROUT_SALMON_SPOT.interact("Lure");
  261.  
  262.             }
  263.  
  264.             try {
  265.                 sleep(random(1250, 1750));
  266.             } catch (InterruptedException e) {
  267.                 e.printStackTrace();
  268.             }
  269.  
  270.             status = "Fishing: Trout and Salmon";
  271.             log(status);
  272.  
  273.             new ConditionalSleep(random(5000, 10000)) {
  274.                 @Override
  275.                 public boolean condition() {
  276.                     return myPlayer().getAnimation() == -1;
  277.                 }
  278.             }.sleep();
  279.  
  280.         } else {
  281.  
  282.             if (myPlayer().getAnimation() != -1) {
  283.  
  284.                 try {
  285.                     sleep(random(500, 5000));
  286.                 } catch (InterruptedException e) {
  287.                     e.printStackTrace();
  288.                 }
  289.  
  290.             }
  291.         }
  292.  
  293.     }
  294.  
  295.     public void FISH_LOBSTER() {
  296.  
  297.         NPC LOBSTER_SPOT = getNpcs().closest(1522);
  298.  
  299.         if (myPlayer().getAnimation() == -1 && !myPlayer().isMoving() && !getInventory().isFull()) {
  300.  
  301.             LOBSTER_SPOT.interact("Cage");
  302.  
  303.             try {
  304.                 sleep(random(1250, 1750));
  305.             } catch (InterruptedException e) {
  306.                 e.printStackTrace();
  307.             }
  308.  
  309.             status = "Fishing: Lobsters";
  310.             log(status);
  311.  
  312.             new ConditionalSleep(random(5000, 10000)) {
  313.                 @Override
  314.                 public boolean condition() {
  315.                     return myPlayer().getAnimation() == -1;
  316.                 }
  317.             }.sleep();
  318.  
  319.         } else {
  320.  
  321.             if (myPlayer().getAnimation() != -1) {
  322.  
  323.                 try {
  324.                     sleep(random(500, 5000));
  325.                 } catch (InterruptedException e) {
  326.                     e.printStackTrace();
  327.                 }
  328.  
  329.             }
  330.         }
  331.  
  332.     }
  333.  
  334.     public void DROP_FISH() {
  335.  
  336.         try {
  337.             sleep(random(250, 3000));
  338.         } catch (InterruptedException e1) {
  339.             e1.printStackTrace();
  340.         }
  341.  
  342.         status = "Dropping Fish";
  343.         log(status);
  344.  
  345.         getInventory().dropAll("Raw shrimps", "Raw anchovies", "Raw trout", "Raw salmon");
  346.  
  347.         try {
  348.             sleep(random(500, 1500));
  349.         } catch (InterruptedException e) {
  350.             e.printStackTrace();
  351.         }
  352.  
  353.     }
  354.  
  355.     public void DEPOSIT_FISH() {
  356.  
  357.         RS2Object bank_box = getObjects().closest("Bank deposit box");
  358.  
  359.         if (bank_box != null) {
  360.  
  361.             bank_box.interact("Deposit");
  362.  
  363.             new ConditionalSleep(random(5000, 7000)) {
  364.                 @Override
  365.                 public boolean condition() {
  366.                     return depositBox.isOpen();
  367.                 }
  368.  
  369.             }.sleep();
  370.  
  371.             if (depositBox.isOpen()) {
  372.  
  373.                 depositBox.depositAll("Raw lobster");
  374.  
  375.                 new ConditionalSleep(random(5000, 7000)) {
  376.                     @Override
  377.                     public boolean condition() {
  378.                         return !getInventory().contains("Raw lobster");
  379.                     }
  380.  
  381.                 }.sleep();
  382.  
  383.             }
  384.  
  385.         }
  386.  
  387.     }
  388.  
  389.     public void DROP_OLD_GEAR() {
  390.  
  391.         if (skills.getStatic(Skill.FISHING) >= 20 && getInventory().contains("Small fishing net")) {
  392.  
  393.             status = "Dropping un-needed Small fishing net now we are 20 fishing...";
  394.             log(status);
  395.  
  396.             getInventory().drop("Small fishing net");
  397.  
  398.             if (getInventory().contains("Raw shrimps") || getInventory().contains("Raw anchovies")) {
  399.  
  400.                 status = "Dropping any Raw shrimps and Raw anchovies we have in inventory...";
  401.                 log(status);
  402.  
  403.                 getInventory().dropAll("Raw shrimps", "Raw anchovies");
  404.  
  405.                 try {
  406.                     sleep(random(500, 2000));
  407.                 } catch (InterruptedException e) {
  408.                     e.printStackTrace();
  409.                 }
  410.             }
  411.  
  412.         } else {
  413.  
  414.             if (skills.getStatic(Skill.FISHING) >= 40 && getInventory().contains("Fly fishing rod")
  415.                     || getInventory().contains("Feather")) {
  416.  
  417.                 status = "Dropping un-needed Fly fishing rod and Feathers now we are 40 fishing...";
  418.                 log(status);
  419.  
  420.                 getInventory().drop("Fly fishing rod");
  421.                 getInventory().drop("Feather");
  422.  
  423.                 if (getInventory().contains("Raw trout") || getInventory().contains("Raw salmon")) {
  424.  
  425.                     status = "Dropping any Raw trout and Raw salmon we have in inventory...";
  426.                     log(status);
  427.  
  428.                     getInventory().dropAll("Raw trout", "Raw salmon");
  429.  
  430.                     try {
  431.                         sleep(random(500, 2000));
  432.                     } catch (InterruptedException e) {
  433.                         e.printStackTrace();
  434.                     }
  435.                 }
  436.             }
  437.         }
  438.  
  439.     }
  440.  
  441.     @Override
  442.     public void onPaint(final Graphics2D g) {
  443.  
  444.         final long runTime = System.currentTimeMillis() - startTime;
  445.  
  446.         g.setColor(Color.WHITE);
  447.         Font font = new Font("Verdana", Font.BOLD, 16);
  448.         g.setFont(font);
  449.         g.drawString(">C<Progressive Lobsters", 29, 292);
  450.         Font font2 = new Font("Verdana", Font.BOLD, 10);
  451.         g.setFont(font2);
  452.         g.drawString("Runtime: " + formatTime(runTime), 29, 312);
  453.         g.drawString("Fishing XP gained: "+ formatValue(getExperienceTracker().getGainedXP(Skill.FISHING)), 29, 332);
  454.  
  455.     }
  456.  
  457. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement