Advertisement
Guest User

Pokie's Karamja Lobster Fisher (F2P)

a guest
Jul 16th, 2017
202
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 10.81 KB | None | 0 0
  1. package net.fisher;
  2.  
  3. import java.awt.Color;
  4. import java.awt.Font;
  5. import java.awt.Graphics2D;
  6. import java.awt.Point;
  7. import org.osbot.rs07.api.map.Area;
  8. import org.osbot.rs07.api.model.NPC;
  9. import org.osbot.rs07.api.model.RS2Object;
  10. import org.osbot.rs07.api.ui.Skill;
  11. import org.osbot.rs07.api.ui.Tab;
  12. import org.osbot.rs07.script.Script;
  13. import org.osbot.rs07.script.ScriptManifest;
  14.  
  15. @ScriptManifest(author = "PocketPokie", info = "Start with more than 60 coins in inventory and a lobster pot.", logo = "", name = "Pokie's Lobster Fisher 1.0", version = 0.1)
  16.  
  17. public class Fisher extends Script {
  18.    
  19.     //Areas
  20.     public Area BOAT_KARAMJA = new Area(2955,3141,2957,3144).setPlane(1); //MAKE BIGGER THAN BOAT
  21.     public Area DOCK_KARAMJA = new Area(2945,3146,2960,3147);
  22.     public Area DOCK_SARIM = new Area(3022,3214,3029,3223);
  23.     public Area BOAT_SARIM  = new Area(3038,3210,3031,3223).setPlane(1);
  24.     public Area FISHING_AREA = new Area(2919, 3173,2928,3181);
  25.     public Area DEPOSIT_BOX = new Area(3041,3234,3047,3237);
  26.     public Area DOCK_CUSTOMS = new Area(2953,3146,2955,3147);
  27.     //everything Walking
  28.    
  29.     //tIME
  30.     private long startTime;
  31.    
  32.     int animFishing =619;
  33.     int fishCaught;
  34.     //inAreaCheck
  35.    
  36.     int spotId = 1522;
  37.     String netName = "Lobster pot";
  38.     String coins = "Coins";
  39.     String seamanName = "Seaman";
  40.     String officerName = "Customs officer";
  41.     String[] seamanActions = new String[10];
  42.     String yes = "Yes please.";
  43.    
  44.     //karamjacustomsofficerstrings
  45.     String yesJourney = "Can I journey on this ship?";
  46.     String yesSearch = "Search away, I have nothing to hide.";
  47.     String ok = "Ok.";
  48.     //
  49.     String plankName = "Gangplank";
  50.     String crossPlank = "Cross";
  51.     String payFare = "Pay-Fare";
  52.    
  53.    
  54.     @Override
  55.     public int onLoop() throws InterruptedException {
  56.        
  57.     //TIME STUFF
  58.         final long runTime = System.currentTimeMillis() - startTime;
  59.     //END TIME STUFF
  60.         if(inventory.getAmount("Coins") <=60){ //cheap coin check logout, fix in next version
  61.             logoutTab.logOut();
  62.             stop();
  63.         }
  64.         switch(getState()){
  65.             case WALK_PLANK:
  66.                 log("Walking plank...");
  67.                 clickPlank();
  68.                 sl(); //randomize final tile
  69.             break;
  70.            
  71.             case WALK_TO_FISH:
  72.                 log("attempting to walk to fishing area...");
  73.                 this.walking.webWalk(FISHING_AREA);
  74.                 sl();
  75.                 break;
  76.            
  77.             case FISH:
  78.                 log("Starting to fish...");
  79.                 Fish();
  80.                 sl();
  81.                 break;
  82.                
  83.             case WALK_TO_KARAMJA_DOCK:
  84.                 log("Walking to Karamja Dock...");
  85. //              this.walking.webWalk(DOCK_KARAMJA);
  86.                 this.walking.webWalk(DOCK_CUSTOMS); //gets closer to customs officer
  87.                 break;
  88.            
  89.             case TALK_TO_CUSTOMS_OFFICER:
  90.                 findCustomsKaramja(); //selects the pay-fare option
  91.                 sl();
  92.                 payForBoatKaramja();
  93.                 sl();
  94.                 break;
  95.            
  96.             case TALK_TO_SEAMAN:
  97.                 log("Finding and talking to seaman on Port Sarim Dock...");
  98.                 findSeamanPort();
  99.                 sl();
  100.                 payForBoatPort();
  101.                 break;
  102.            
  103.             case WALK_TO_DEPOSIT:
  104.                 log("Walking to deposit box...");
  105.                 this.walking.webWalk(DEPOSIT_BOX);
  106.                 break;
  107.                
  108.             case FISHING_ANTIBAN:
  109.                 antiban();
  110.                 break;
  111.                
  112.             case MAKE_DEPOSIT:
  113.                 log("Depositing fish...");
  114.                 depositFish();
  115.                 break;
  116.                
  117.             case WALK_TO_SARIM_DOCK:
  118.                 log("Walking to Sarim Dock...");
  119.                 this.walking.webWalk(DOCK_SARIM);
  120.                 break;
  121.            
  122.             case LOST: //this means that you are not in any defined area.       // thus we will use webWalk to get back to an area.
  123.                 log("Player is lost, making back to area that is known...");
  124.                 lostPlayer();
  125.                 sl();
  126.                 break;
  127.            
  128.             case IDLE:
  129.                 log("currently idle");
  130.                 break;
  131.    
  132.         }
  133.         return random(200,600);
  134.     }
  135.     @Override
  136.     public void onStart(){
  137.         log("The script is starting");
  138.          startTime = System.currentTimeMillis();
  139.          this.getExperienceTracker().start(Skill.FISHING);
  140.          fishCaught = 0;
  141.     }
  142.    
  143.     @Override
  144.     public void onExit(){
  145.         log("Thank you for running PokieFisher.");
  146.     }
  147.    
  148.     private void antiban() throws InterruptedException{
  149.         if(random(0,1000)==1){
  150.             switch(random(0,1)){
  151.             case 0:
  152.                 this.mouse.move(random(123,345), random(241,405));
  153.                 break;
  154.             case 1:
  155.                 this.tabs.open(Tab.SKILLS);
  156.                 sleep(random(50,100));
  157.                 this.mouse.move(random(681,725), random(273,285));
  158.                 sleep(random(1000,4000));
  159.                 this.tabs.open(Tab.INVENTORY);
  160.                 break;
  161.             }
  162.         }
  163.     }
  164.    
  165.     private NPC getFishSpot(int spotId){
  166.         NPC fishSpot = this.npcs.closest(spotId);
  167.         return fishSpot;
  168.     }
  169.    
  170.     private void Fish() throws InterruptedException{
  171.         NPC fishSpot =  getFishSpot(spotId);
  172.         if(!this.myPlayer().isAnimating()){
  173.             int x = random(0,1);
  174.             log("x = "+ x);
  175.             switch(x){
  176.             case 0:
  177.                 this.mouse.move(random(100,500),random(100,500));
  178.                 fishSpot.interact("Cage");
  179.                 break;
  180.             case 1:
  181.                 fishSpot.hover();
  182.                 this.mouse.click(true);
  183.                 fishSpot.interact("Cage");
  184.                 break;
  185.             default:
  186.                 fishSpot.interact("Cage");
  187.             }
  188.                
  189.         }
  190.     }
  191.    
  192.     public void findSeamanPort() throws InterruptedException{
  193.         log("Finding seaman...");
  194.        
  195.         while(this.chatbox.isVisible()){
  196.             NPC seaman = this.npcs.closestThatContains(seamanName);
  197.             if(!seaman.isVisible()){
  198.                 this.camera.toEntity(seaman);
  199.             } else {
  200.                 seamanActions = seaman.getActions();
  201.                 seaman.interact(seamanActions[2]);
  202.             }
  203.             sleep(random(1000,2000));
  204.         }
  205.     }
  206.    
  207.     public void findCustomsKaramja() throws InterruptedException{
  208.         log("Finding seaman...");
  209.         while(this.chatbox.isVisible()){
  210.             NPC customsOfficer = this.npcs.closestThatContains(officerName);
  211.                 if(!customsOfficer.isVisible()){
  212.                     this.camera.toEntity(customsOfficer);
  213.                     sl();
  214.                 } else {
  215.                     customsOfficer.interact(payFare);
  216.                     sl();
  217.                 }
  218.         }
  219.     }
  220.    
  221.     public void payForBoatPort() throws InterruptedException{
  222.     while(this.dialogues.inDialogue()){
  223.         if(!this.dialogues.isPendingContinuation() && !this.dialogues.completeDialogue(yes)){
  224.             this.dialogues.clickContinue();
  225.             sleep(random(200,800));
  226.             } else if(this.dialogues.completeDialogue(yes)) {
  227.                 this.dialogues.selectOption(1);
  228.                 sleep(random(200,800));
  229.             }
  230.         }
  231.     }
  232.    
  233.     public void payForBoatKaramja() throws InterruptedException{
  234.         while(this.dialogues.inDialogue()){
  235.             if(!this.dialogues.isPendingContinuation() && !this.dialogues.completeDialogue(yesJourney, yesSearch, ok)){
  236.                 this.dialogues.clickContinue();
  237.                 sl();      
  238.             } else if(this.dialogues.completeDialogue(yesJourney)){
  239.                 this.dialogues.selectOption(yesJourney);
  240.                 sl();
  241.             } else if(this.dialogues.completeDialogue(yesSearch)) {
  242.                 this.dialogues.selectOption(yesSearch);
  243.                 sl();
  244.             } else {
  245.                 this.dialogues.selectOption(ok);
  246.                 sl();
  247.             }
  248.         }
  249.     }
  250.    
  251.     public enum State{
  252.         WALK_PLANK, WALK_TO_FISH, WALK_TO_KARAMJA_DOCK, WALK_TO_SARIM_DOCK,
  253.         WALK_TO_DEPOSIT, LOST, FISH, TALK_TO_CUSTOMS_OFFICER, TALK_TO_SEAMAN,
  254.         FISHING_ANTIBAN, MAKE_DEPOSIT,IDLE
  255.     };
  256.    
  257.     public State getState(){
  258.         log("getState() being called");
  259.         if(BOAT_KARAMJA.contains(this.myPlayer()) || BOAT_SARIM.contains(this.myPlayer())){ //add sarim boat
  260.             log("Position confirmed: On boat.");
  261.             return State.WALK_PLANK;
  262.         }   else if (DOCK_KARAMJA.contains(this.myPlayer()) && !this.inventory.isFull()){ //if at karamja&fullinvy; go to fish){
  263.             log("You are on the karamja dock with a nonfullinvy");
  264.             return State.WALK_TO_FISH;
  265.         } else if(FISHING_AREA.contains(this.myPlayer()) && this.myPlayer().getAnimation()==-1
  266.                 && !this.inventory.isFull() && !myPlayer().isMoving()) {
  267.             log("We are doing nothing. Time to fish");
  268.             return State.FISH;
  269.         } else if(this.inventory.isFull() && FISHING_AREA.contains(this.myPlayer())){ //if fulloffish in fish area
  270.             return State.WALK_TO_KARAMJA_DOCK;
  271.         }  else if (DOCK_KARAMJA.contains(this.myPlayer()) && this.inventory.isFull()){
  272.                 return State.TALK_TO_CUSTOMS_OFFICER; //also pays
  273.         }  else if (DOCK_SARIM.contains(this.myPlayer()) && !this.inventory.isFull() ){
  274.             return State.TALK_TO_SEAMAN;//also pays
  275.         } else if(DOCK_SARIM.contains(this.myPlayer()) && this.inventory.isFull()){
  276.             return State.WALK_TO_DEPOSIT;
  277.         } else if(DEPOSIT_BOX.contains(this.myPlayer()) && this.inventory.isFull()){
  278.             return State.MAKE_DEPOSIT;
  279.         }else if (DEPOSIT_BOX.contains(this.myPlayer()) && !this.inventory.isFull()){
  280.             return State.WALK_TO_SARIM_DOCK;
  281.         } else if(!DOCK_KARAMJA.contains(this.myPlayer())
  282.                 && !DOCK_SARIM.contains(this.myPlayer())
  283.                 && !BOAT_KARAMJA.contains(this.myPlayer())
  284.                 && !FISHING_AREA.contains(this.myPlayer())
  285.                 && !DEPOSIT_BOX.contains(this.myPlayer())
  286.                 && !BOAT_SARIM.contains(this.myPlayer())){
  287.             return State.LOST;
  288.         } else if (animFishing == this.myPlayer().getAnimation()){
  289.             return State.FISHING_ANTIBAN;
  290.         } else {
  291.             return State.IDLE;
  292.         }
  293.    
  294.        
  295.     }
  296.    
  297.     private void depositFish() throws InterruptedException{
  298.         while(!this.myPlayer().isMoving() && this.inventory.isFull()&& !this.depositBox.isOpen()){
  299.             log("Finding deposit box...");
  300.             RS2Object db = this.objects.closest("Bank deposit box");
  301.             db.interact("Deposit");
  302.             sl();
  303.         }
  304.         if(this.depositBox.isOpen() && inventory.contains("Raw lobster")){
  305.             this.depositBox.depositAllExcept(netName, coins);
  306.        
  307.         }
  308.     }
  309.    
  310.     private void clickPlank(){
  311.         log("We are on the boat. Finding plank...");
  312.         this.objects.closest(plankName).interact(crossPlank);
  313.     }
  314.    
  315.     private void sl() throws InterruptedException{
  316.         sleep(random(500,1300));
  317.     }
  318.    
  319.     private void lostPlayer() throws InterruptedException{
  320.         this.walking.webWalk(DOCK_KARAMJA, DOCK_SARIM, DEPOSIT_BOX, FISHING_AREA );
  321.         log("We are lost. Making way to known area.");
  322.     }
  323.    
  324.    
  325.     //EVERYTHING PAINT UNDER HERE
  326.    
  327.     public final String formatTime(final long ms){
  328.         long s = ms / 1000, m = s / 60, h = m / 60;
  329.         s %= 60; m %= 60; h %= 24;
  330.         return String.format("%02d:%02d:%02d", h, m, s);
  331.     }
  332.    
  333.     @Override
  334.      public void onPaint(Graphics2D g) {
  335.        
  336.             Font font = new Font("Comic Sans", Font.BOLD, 14);
  337.             Point mP = getMouse().getPosition();
  338.             g.setColor(Color.WHITE);
  339.             g.drawLine(mP.x - 3, mP.y - 3, mP.x - 3, mP.y + 3);
  340.             g.drawLine(mP.x - 3, mP.y - 3, mP.x + 3, mP.y - 3);
  341.             g.drawLine(mP.x - 3, mP.y + 3, mP.x + 3, mP.y + 3);
  342.             g.drawLine(mP.x + 3, mP.y + 3, mP.x + 3, mP.y - 3);
  343.             g.setColor(Color.CYAN);
  344.             g.drawString("Current Level: "+ getSkills().getStatic(Skill.FISHING), 10, 210);
  345.             fishCaught = getExperienceTracker().getGainedXP(Skill.FISHING)/90;
  346.             g.drawString("Fish caught: "+ fishCaught, 10, 230);
  347.             g.drawString("XP Gained: "+ getExperienceTracker().getGainedXP(Skill.FISHING), 10, 250);
  348.             g.drawString("XP / HR: "+ getExperienceTracker().getGainedXPPerHour(Skill.FISHING), 10, 270);
  349.             g.drawString("Time to LVL: "+ formatTime(getExperienceTracker().getTimeToLevel(Skill.FISHING)), 10, 290);
  350.             final long runTime = System.currentTimeMillis() - startTime;
  351.             g.drawString("Time Ran: "+ formatTime(runTime), 10, 310);
  352.             g.setColor(Color.WHITE);
  353.             g.drawString("Pokie Fisher V1.0",10,330);
  354.         }
  355. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement