Guest User

Untitled

a guest
Sep 11th, 2013
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 24.17 KB | None | 0 0
  1. import groovy.swing.factory.ComboBoxFactory;
  2. import groovyjarjarantlr.Version;
  3. import groovyjarjarantlr.debug.MessageEvent;
  4.  
  5. import java.awt.AWTException;
  6. import java.util.Timer;
  7. import java.awt.BasicStroke;
  8. import java.awt.Color;
  9. import java.awt.EventQueue;
  10. import java.awt.Font;
  11. import java.awt.Graphics;
  12. import java.awt.Graphics2D;
  13. import java.awt.Paint;
  14. import java.awt.PaintContext;
  15. import java.awt.Point;
  16. import java.awt.Rectangle;
  17. import java.awt.RenderingHints;
  18. import java.awt.Toolkit;
  19. import java.awt.event.ActionEvent;
  20. import java.awt.event.ActionListener;
  21. import java.awt.event.MouseEvent;
  22. import java.awt.geom.AffineTransform;
  23. import java.awt.geom.Rectangle2D;
  24. import java.awt.image.BufferedImage;
  25. import java.awt.image.ColorModel;
  26. import java.awt.peer.RobotPeer;
  27. import java.math.BigDecimal;
  28. import java.text.NumberFormat;
  29. import java.util.Arrays;
  30. import java.util.Collections;
  31. import java.util.List;
  32. import java.util.Timer;
  33. import java.util.concurrent.TimeUnit;
  34. import java.awt.BorderLayout;
  35. import java.awt.EventQueue;
  36.  
  37. import javax.swing.JFrame;
  38. import javax.swing.JPanel;
  39. import javax.swing.border.EmptyBorder;
  40. import javax.swing.plaf.ComboBoxUI;
  41. import javax.swing.plaf.PanelUI;
  42. import javax.swing.ComboBoxModel;
  43. import javax.swing.JTabbedPane;
  44. import javax.swing.JLabel;
  45. import javax.swing.SwingConstants;
  46.  
  47. import com.jgoodies.forms.factories.DefaultComponentFactory;
  48.  
  49. import java.awt.GridBagLayout;
  50. import java.awt.GridBagConstraints;
  51.  
  52. import javax.swing.JComboBox;
  53.  
  54. import java.awt.Insets;
  55.  
  56. import javax.swing.DefaultComboBoxModel;
  57. import javax.swing.JButton;
  58.  
  59. import org.apache.log4j.helpers.QuietWriter;
  60. import org.omg.CORBA.Environment;
  61. import org.osbot.*;
  62. import org.osbot.engine.Bot;
  63. import org.osbot.script.mouse.*;
  64. import org.osbot.script.rs2.Client;
  65. import org.osbot.script.rs2.model.*;
  66. import org.osbot.script.rs2.ui.*;
  67. import org.osbot.script.MessageListener;
  68. import org.osbot.script.MethodProvider;
  69. import org.osbot.script.MouseListener;
  70. import org.osbot.script.Painter;
  71. import org.osbot.script.RandomEventSolver;
  72. import org.osbot.script.Script;
  73. import org.osbot.script.ScriptManifest;
  74. import org.osbot.script.rs2.utility.*;
  75. import org.osbot.script.rs2.map.Position;
  76. import org.osbot.script.rs2.model.Character;
  77. import org.osbot.script.rs2.model.GroundItem;
  78. import org.osbot.script.rs2.model.Item;
  79. import org.osbot.script.rs2.model.NPC;
  80. import org.osbot.script.rs2.model.Player;
  81. import org.osbot.script.rs2.randoms.RandomManager;
  82. import org.osbot.script.rs2.skill.*;
  83. import org.osbot.script.rs2.utility.Area;
  84. import org.osbot.script.rs2.ui.Tab;
  85. import org.osbot.script.rs2.map.*;
  86. import org.osbot.utility.PathFinder;
  87.  
  88. import com.jgoodies.forms.factories.DefaultComponentFactory;
  89.  
  90. @SuppressWarnings("unused")
  91. @ScriptManifest(name = "RFisher", author = "Reminiscence", version = 1.5, info = "Barbarian fly fishing and Shilo Village Fly Fishing!")
  92.  
  93.  
  94. public class RFisher extends Script{
  95.    
  96.     enum State {
  97.         START, FISHING, DROPPING, IDLE,
  98.         BANKINGEDGE, WALKTOBANKEDGE, WALKTOSPOTEDGE,
  99.         BANKINGSHILO, WALKTOBANKSHILO, WALKTOSPOTSHILO
  100.     }
  101.  
  102.     State state = State.START;
  103.     private static String status = "Unknown";
  104.     boolean banking;
  105.     boolean bankingShilo;
  106.     boolean bankingEdge;
  107.     boolean hasBanked;
  108.     boolean usingShilo;
  109.     boolean usingEdge;
  110.    
  111.     private int[][] toBankEdge = new int[][] { { 3104, 3432 }, { 3097, 3440 }, {3091, 3444}, {3091, 3460},  { 3095, 3453 }, { 3099, 3470 }, { 3104, 3432 }};
  112.     private int[][] toSpotEdge = new int[][] { { 3096, 3485 }, { 3099, 3470 }, { 3095, 3454 }, {3091, 3444}, { 3097, 3440 }, { 3104, 3432 }};
  113.     private int[][] toBankShilo = new int[][] { {2857, 2970}, {2856, 2959}, { 2852, 2955 }};
  114.     private int[][] toSpotShilo = new int[][] { {2856, 2959}, { 2849, 2966 }, { 2858, 2970 }};
  115.    
  116.    
  117.     final Area FISHING_AREA = new Area(3098, 3438, 3113, 3420);
  118.     final Area BANK_AREA_SHILO = new Area(2846, 2958, 2859, 2950);
  119.    
  120.     int lvlUp = 0;
  121.     int rodID = 309;
  122.     int barbID = 11323;
  123.     int feathers = 314;
  124.     int troutCaught = 0;
  125.     int salmonCaught = 0;
  126.     int coins = 995;
  127.     int caught = 0;
  128.    
  129.     int spotID = 4106;
  130.     int spotIDShilo = 636;
  131.     int bankID = 2196;
  132.     int bankerID = 1316;
  133.    
  134.     public long startTime;
  135.     public int startLevel = 0;
  136.     private long startXP;
  137.     long runTime = System.currentTimeMillis() - startTime;
  138.  
  139.     public void idle() throws InterruptedException {
  140.         int b = random(1, 250);
  141.         if (state == State.IDLE) {
  142.             switch(b) {
  143.             default: break;  
  144.     case 1: {
  145.         status = "Antiban";
  146.         client.rotateCameraToAngle(random(60, 120));  
  147.     }
  148.         break;  
  149.        
  150.     case 12: {
  151.         client.rotateCameraToAngle(random(5, 120));
  152.         status = "Antiban";
  153.     }
  154.         break;  
  155.        
  156.     case 46:
  157.         if(random(1, 12) == 1) {
  158.             status = "Antiban";
  159.             client.rotateCameraToAngle(random(15, 34));
  160.         }
  161.         break;  
  162.        
  163.     case 244:
  164.         if(random(1, 7) == 3) {
  165.             status = "Antiban";
  166.             client.rotateCameraToAngle(random(100, 140));
  167.         }
  168.         break;  
  169.        
  170.     case 32:
  171.         if(random(1, 33) == 16) {
  172.             status = "Antiban";
  173.             client.rotateCameraToAngle(random(30, 70));
  174.         }
  175.         break;
  176.     case 19:
  177.         if(random(1, 15) == 2) {
  178.             status = "Antiban";
  179.             moveMouseOutsideScreen();
  180.         }
  181.         break;  
  182.     case 26:
  183.         if(random(1, 2) == 1) {
  184.             status = "Antiban";
  185.             moveMouseOutsideScreen();
  186.         }
  187.         break;  
  188.     case 41:
  189.         if(random(0, 23) == 4) {
  190.             status = "Antiban";
  191.             client.rotateCameraToAngle(random(random(90, 100)));
  192.         }
  193.         break;  
  194.     case 178:
  195.         if(random(1, 3) == 1) {
  196.             status = "Antiban";
  197.             moveMouseOutsideScreen();
  198.         }
  199.         break;  
  200.     case 87:
  201.         if(random(1, 3) == 3) {
  202.             status = "Antiban";
  203.             moveMouseOutsideScreen();
  204.         }
  205.         break;  
  206.     case 132:
  207.         if(random(1, 40) == 5) {
  208.             status = "Antiban";
  209.             moveMouseOutsideScreen();
  210.             } break;
  211.         }
  212.     }
  213. }
  214.    
  215.     GUI g = new GUI();
  216.     private boolean guiWait = true;
  217.     private JPanel contentPane;
  218.    
  219.     public void onStart() {
  220.         g.setVisible(true);
  221.         while(guiWait)
  222.             try {
  223.                 sleep(500);
  224.             } catch (InterruptedException e) {
  225.                 e.printStackTrace();
  226.             }
  227.        
  228.        
  229.         status = "Starting...";
  230.         startTime = System.currentTimeMillis();
  231.         startXP = client.getSkills().getExperience(Skill.FISHING);
  232.         startLevel = client.getSkills().getLevel(Skill.STRENGTH);
  233.         Player player = client.getMyPlayer();
  234.        
  235.         if (client.getInventory().contains(rodID) && client.getInventory().contains(feathers) && !FISHING_AREA.contains(player.getPosition()) && usingEdge == true) {
  236.             state = State.WALKTOSPOTEDGE;
  237.         }
  238.        
  239.         if (client.getInventory().isFull() && banking == true && closestObject(bankID) != null && bankingEdge == true) {
  240.             state = State.BANKINGEDGE;
  241.         }
  242.        
  243.         if (client.getInventory().isFull() && banking == false && FISHING_AREA.contains(player.getPosition())) {
  244.             state = State.DROPPING;
  245.         }
  246.        
  247.         if (!client.getInventory().isFull() && FISHING_AREA.contains(player.getPosition()) || !BANK_AREA_SHILO.contains(player.getPosition())) {
  248.             state = State.FISHING;
  249.         }
  250.        
  251.         if (!client.getInventory().isFull() && !FISHING_AREA.contains(player.getPosition()) && usingEdge == true) {
  252.             state = State.WALKTOSPOTEDGE;
  253.         }
  254.        
  255.         if (!client.getInventory().isFull() && BANK_AREA_SHILO.contains(player.getPosition()) && usingShilo == true) {
  256.             state = State.WALKTOSPOTSHILO;
  257.         }
  258.        
  259.         if (client.getInventory().contains(rodID) && client.getInventory().contains(feathers) && BANK_AREA_SHILO.contains(player.getPosition()) && usingShilo == true) {
  260.             state = State.WALKTOSPOTSHILO;
  261.         }
  262.     }
  263.    
  264.     public int onLoop() throws InterruptedException{
  265.        
  266.         if (client.getRunEnergy() >= 70) {
  267.             if (isRunning() == false){
  268.                 setRunning(true);
  269.             }
  270.         }
  271.        
  272.         //start of shilo
  273.        
  274.         if (state == State.WALKTOSPOTSHILO) {
  275.             WalkToSpotShilo();
  276.         }
  277.        
  278.         if (state == State.BANKINGSHILO) {
  279.             bankingShilo();
  280.         }
  281.        
  282.         if (state == State.WALKTOBANKSHILO) {
  283.             WalkToBankShilo();
  284.         }
  285.        
  286.         if (client.getInventory().isFull() && bankingShilo == true) {
  287.             state = State.WALKTOBANKSHILO;
  288.         }
  289.        
  290.         if (!client.getInventory().isFull() && bankingShilo == true && BANK_AREA_SHILO.contains(client.getMyPlayer().getPosition())) {
  291.             state = State.WALKTOSPOTSHILO;
  292.         }
  293.        
  294.         if (state == State.WALKTOBANKSHILO && closestNPC(bankerID) == null) {
  295.             status = "State = walktobank";
  296.             WalkToBankShilo();
  297.         }
  298.        
  299.         if (client.getInventory().isFull() && bankingShilo == true && closestObject(bankerID) != null && BANK_AREA_SHILO.contains(client.getMyPlayer().getPosition())){
  300.             state = State.BANKINGSHILO;
  301.         }
  302.        
  303.         if (!BANK_AREA_SHILO.contains(client.getMyPlayer().getPosition()) && state == State.FISHING && usingShilo == true) {
  304.             fishingShilo();
  305.         }
  306.        
  307.         if (BANK_AREA_SHILO.contains(client.getMyPlayer().getPosition()) && state == State.WALKTOSPOTSHILO && usingShilo == true) {
  308.             WalkToSpotShilo();
  309.         }
  310.        
  311.         if (client.getInventory().isFull() && bankingShilo == true && closestNPC(bankerID) != null){
  312.             state = State.BANKINGSHILO;
  313.             bankingShilo();
  314.         }
  315.        
  316.         if (client.getInventory().isFull() && banking == true && bankingShilo && closestNPC(bankerID) != null) {
  317.             state = State.BANKINGSHILO;
  318.             bankingShilo();
  319.         } else if (client.getInventory().isFull() && banking == true && bankingShilo && closestNPC(bankerID) == null) {
  320.             state = State.WALKTOBANKSHILO;
  321.             WalkToBankShilo();
  322.         }
  323.        
  324.         //end of shilo
  325.        
  326.         //start of barbarian village
  327.        
  328.         if (state == State.WALKTOSPOTEDGE) {
  329.             WalkToSpotEdge();
  330.         }
  331.        
  332.         if (state == State.WALKTOSPOTEDGE && !FISHING_AREA.contains(client.getMyPlayer().getPosition())) {
  333.             status = "State = walktospot";
  334.             WalkToSpotEdge();
  335.         }
  336.        
  337.         if (state == State.WALKTOBANKEDGE && !closestObject(bankID).isVisible()) {
  338.             status = "State = walktobank";
  339.             WalkToBankEdge();
  340.         }
  341.        
  342.         if (state == State.BANKINGEDGE) {
  343.             status = "State = bankingEdge";
  344.             bankingEdge();
  345.         }
  346.        
  347.         if (client.getInventory().isFull() && bankingEdge == true) {
  348.             state = State.WALKTOBANKEDGE;
  349.         }
  350.        
  351.         if (client.getInventory().isFull() && bankingEdge == true && closestObject(bankID) != null && !FISHING_AREA.contains(client.getMyPlayer().getPosition())){
  352.             state = State.BANKINGEDGE;
  353.             bankingEdge();
  354.         }
  355.        
  356.         if (client.getInventory().isFull() && state == State.BANKINGEDGE) {
  357.             state = State.WALKTOBANKEDGE;
  358.             WalkToBankEdge();
  359.         }
  360.        
  361.         if (FISHING_AREA.contains(client.getMyPlayer().getPosition()) && state == State.FISHING && usingEdge == true) {
  362.             fishingEdge();
  363.         }
  364.        
  365.         if (client.getInventory().isFull() && banking == true && usingEdge == true) {
  366.             state = State.WALKTOBANKEDGE;
  367.             WalkToBankEdge();
  368.         }
  369.        
  370.         if (!client.getInventory().isFull() && !FISHING_AREA.contains(client.getMyPlayer().getPosition()) && usingEdge == true){
  371.             WalkToSpotEdge();
  372.         }
  373.        
  374.         if (client.getInventory().isFull() && banking == true && bankingEdge && closestObject(bankID) != null) {
  375.             state = State.BANKINGEDGE;
  376.             bankingEdge();
  377.         } else if (client.getInventory().isFull() && banking == true && bankingEdge && closestObject(bankID) == null) {
  378.             state = State.WALKTOBANKEDGE;
  379.             WalkToBankEdge();
  380.         }
  381.        
  382.         // end of barbarian village
  383.        
  384.        
  385.         //start of misc
  386.        
  387.         if (state == State.DROPPING && banking == false) {
  388.             status = "State = dropping";
  389.             dropping();
  390.         }
  391.        
  392.         if (!client.getInventory().isFull()) {
  393.             state = State.FISHING;
  394.         }
  395.        
  396.         if (client.getInventory().isFull() && banking == false) {
  397.             state = State.DROPPING;
  398.         }
  399.        
  400.         if (state == State.FISHING && client.getMyPlayer().isAnimating() && !client.getInventory().isFull()) {
  401.             state = State.IDLE;
  402.         }
  403.        
  404.         if (client.getInventory().contains(rodID) && client.getInventory().contains(feathers) && state == State.FISHING && usingEdge) {
  405.             fishingEdge();
  406.         } else if (!client.getInventory().contains(rodID) || !client.getInventory().contains(barbID) && !client.getInventory().contains(feathers)){
  407.             log("Missing rod/barb and feathers.");
  408.             stop();
  409.         } else {
  410.             fishingShilo();
  411.         }
  412.        
  413.         if(!client.getInventory().contains(feathers)){
  414.             log("No remaining feathers.");
  415.             stop();
  416.         }
  417.        
  418.         if (client.getInventory().isFull() && state == State.DROPPING) {
  419.             dropping();
  420.         }
  421.        
  422.         if (!client.getInventory().contains(rodID)){
  423.             if (closestGroundItem(rodID)!= null){
  424.                 closestGroundItem(rodID).interact("Take");
  425.             } else if (!client.getInventory().contains(rodID) && closestGroundItem(rodID) == null){
  426.                 log("Missing rod!");
  427.                 stop();
  428.             }
  429.         }
  430.         return random(10, 20);
  431.     }
  432.  
  433.     private void fishingShilo() throws InterruptedException {
  434.         if (closestNPC(spotIDShilo) != null && !client.getMyPlayer().isAnimating() && !client.getInventory().isFull() && usingShilo == true) {
  435.             if (closestNPC(spotIDShilo).isVisible()) {
  436.                 state = State.FISHING;
  437.                 status = "Luring...";
  438.                 closestNPC(spotIDShilo).interact("Lure");
  439.                 sleep(random(3000, 4500));
  440.             }
  441.            
  442.             if (!closestNPC(spotIDShilo).isVisible() && closestNPC(spotIDShilo).exists() && !client.getMyPlayer().isAnimating()){
  443.                 status = "Walking...";
  444.                 closestNPC(spotIDShilo).getPosition().walkMinimap(bot);
  445.                 sleep(random(1500, 2000));
  446.             }
  447.            
  448.             if (closestNPC(spotIDShilo) == null && state == State.FISHING) {
  449.                 status = "Sleeping...";
  450.                 sleep(random(50, 250));
  451.             }
  452.        
  453.             if (closestNPC(spotIDShilo) != null && closestNPC(spotIDShilo).isVisible()){
  454.                 closestNPC(spotIDShilo).getPosition().walkHere(bot);
  455.             }
  456.         }
  457.    
  458. }
  459.  
  460.     private void WalkToBankShilo() {
  461.         if (client.getInventory().isFull() && state == State.WALKTOBANKSHILO){
  462.             status = "Walking to Bank...";
  463.             WalkAlongPath(toBankShilo, true);
  464.         }
  465.     }
  466.  
  467.     private void bankingShilo() throws InterruptedException {
  468.         status = "Banking...";
  469.         if (closestNPC(bankerID) != null && client.getClient().getInventory().isFull()) {
  470.             closestNPC(bankerID).interact("Bank");
  471.             sleep(random(1000, 1500));
  472.             client.getBank().depositAllExcept(rodID, barbID, feathers);
  473.             sleep(random(400, 600));
  474.             client.getBank().close();
  475.             sleep(random(500, 600));
  476.             if (!client.getInventory().isFull()) {
  477.             state = State.WALKTOSPOTSHILO;
  478.             }
  479.         }
  480.     }
  481.  
  482.     public void WalkToSpotShilo() throws InterruptedException {
  483.         if (!client.getInventory().isFull() && BANK_AREA_SHILO.contains(client.getMyPlayer().getPosition())) {
  484.             status = "Walking to spot...";
  485.             WalkAlongPath(toSpotShilo, true);
  486.         }
  487.     }
  488.  
  489.     public void WalkToBankEdge() throws InterruptedException {
  490.         if (client.getInventory().isFull() && state == State.WALKTOBANKEDGE){
  491.             status = "Walking to Bank...";
  492.             WalkAlongPath(toBankEdge, true);
  493.         }
  494.     }
  495.    
  496.     public void WalkToSpotEdge() throws InterruptedException {
  497.         if (!client.getInventory().isFull() && !FISHING_AREA.contains(client.getMyPlayer().getPosition())) {
  498.             status = "Walking to spot...";
  499.             WalkAlongPath(toSpotEdge, true);
  500.         }
  501.     }
  502.    
  503.     public void fishingEdge() throws InterruptedException {
  504.         if (closestNPC(spotID) != null && !client.getMyPlayer().isAnimating() && !client.getInventory().isFull() && usingEdge == true) {
  505.             if (closestNPC(spotID).isVisible()) {
  506.                 state = State.FISHING;
  507.                 status = "Luring...";
  508.                 closestNPC(spotID).interact("Lure");
  509.                 sleep(random(1500, 2200));
  510.             }
  511.            
  512.             if (!closestNPC(spotID).isVisible() && closestNPC(spotID).exists()){
  513.                 status = "Walking...";
  514.                 closestNPC(spotID).getPosition().walkMinimap(bot);
  515.                 sleep(random(450, 700));
  516.             }
  517.            
  518.             if (!closestNPC(spotID).isVisible() && closestNPC(spotID) == null && state == State.FISHING) {
  519.                 status = "Sleeping...";
  520.                 sleep(random(50, 250));
  521.             }
  522.        
  523.             if (closestNPC(spotID) != null && closestNPC(spotID).isVisible()){
  524.                 closestNPC(spotID).getPosition().walkHere(bot);
  525.             }
  526.         }
  527.     }
  528.  
  529.     public void dropping() throws InterruptedException {
  530.         if (state == State.DROPPING) {
  531.             status = "Dropping...";
  532.             client.getInventory().dropAllExcept(rodID, feathers);
  533.         }
  534.     }
  535.  
  536.     public void bankingEdge() throws InterruptedException {
  537.         status = "Banking...";
  538.         if (closestObject(bankID) != null && client.getClient().getInventory().isFull()) {
  539.             closestObject(bankID).interact("Bank");
  540.             sleep(random(1000, 1500));
  541.             client.getBank().depositAllExcept(rodID, barbID, feathers);
  542.             sleep(random(400, 600));
  543.             client.getBank().close();
  544.             sleep(random(500, 600));
  545.             if (!client.getInventory().isFull()) {
  546.             state = State.WALKTOSPOTEDGE;
  547.             }
  548.         }
  549.     }
  550.    
  551.     public void WalkAlongPath(int[][] path, boolean AscendThroughPath) {
  552.         int destination = 0;
  553.         for (int i = 0; i < path.length; i++)
  554.             if (distanceToPoint(path[i][0], path[i][1]) < distanceToPoint(
  555.                     path[destination][0], path[destination][1]))
  556.                 destination = i;
  557.         if (client.getMyPlayer().isMoving()
  558.                 && distanceToPoint(path[destination][0], path[destination][1]) > (client
  559.                         .getMyPlayer().isMoving() ? 3 : 2))
  560.             return;
  561.         if (AscendThroughPath && destination != path.length - 1
  562.                 || !AscendThroughPath && destination != 0)
  563.             destination += (AscendThroughPath ? 1 : -1);
  564.         try {
  565.             log("Walking to node:" + destination);
  566.             walk(new Position(path[destination][0], path[destination][1], 0));
  567.             Thread.sleep(700 + MethodProvider.random(600));
  568.         } catch (InterruptedException e) {
  569.             e.printStackTrace();
  570.         }
  571.     }
  572.    
  573.     private int distanceToPoint(int pointX, int pointY) {
  574.         return (int) Math.sqrt(Math
  575.                 .pow(client.getMyPlayer().getX() - pointX, 2)
  576.                 + Math.pow(client.getMyPlayer().getY() - pointY, 2));
  577.     }
  578.    
  579.     public void onExit() throws InterruptedException{
  580.         long currentEXP = this.client.getSkills().getExperience(Skill.FISHING);
  581.         long expGain = client.getSkills().getExperience(Skill.FISHING) - startXP;
  582.         log("Caught: " +caught);
  583.         log("Exp Gained: " +NumberFormat.getIntegerInstance().format(expGain));
  584.         log("Runtime: " + runTime);
  585.      }
  586.    
  587.    
  588.     //paint
  589.     private final RenderingHints antialiasing = new RenderingHints(
  590.             RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
  591.  
  592.     private final Color color1 = new Color(0, 0, 0, 189);
  593.     private final Color color2 = new Color(0, 204, 255);
  594.     private final Color color3 = new Color(255, 255, 255);
  595.  
  596.     private final Font font1 = new Font("Arial", 0, 10);
  597.     private final Font font2 = new Font("Arial", 0, 14);
  598.  
  599.     private int getExpToLevel(Skill index) {
  600.         int lvl = client.getSkills().getLevel(index);
  601.         int xpTotal = xpTable[lvl + 1] - xpTable[lvl];
  602.         int xpDone = client.getSkills().getExperience(index) - xpTable[lvl];
  603.         if(lvl == 99) return 0;
  604.         if(xpTotal == 0) return 0;
  605.         else return xpTotal - xpDone;
  606.     }
  607.    
  608.     private final int xpTable[] = { 0, 0, 83, 174, 276, 388, 512, 650, 801, 969,
  609.             1154, 1358, 1584, 1833, 2107, 2411, 2746, 3115, 3523, 3973, 4470, 5018,
  610.             5624, 6291, 7028, 7842, 8740, 9730, 10824, 12031, 13363, 14833, 16456,
  611.             18247, 20224, 22406, 24815, 27473, 30408, 33648, 37224, 41171, 45529, 50339,
  612.             55649, 61512, 0x1098f, 0x12577, 0x14446, 0x16649, 0x18bd5, 0x1b549, 0x1e30c,
  613.             0x21592, 0x24d58, 0x28aec, 0x2cee8, 0x319f6, 0x36cd2, 0x3c84e, 0x42d4e, 0x49cd0,
  614.             0x517ec, 0x59fd7, 0x635e7, 0x6db94, 0x7927e, 0x85c71, 0x93b68, 0xa3193, 0xb415b,
  615.             0xc6d6d, 0xdb8b9, 0xf267f, 0x10ba56, 0x127835, 0x14647b, 0x1683fd, 0x18dc10,
  616.             0x1b7298, 0x1e4e14, 0x2175b2, 0x24f15f, 0x28c9da, 0x2d08cd, 0x31b8e2, 0x36e5e0,
  617.             0x3c9cc6, 0x42ebf0, 0x49e337, 0x51941c, 0x5a11ef, 0x637205, 0x6dcbed, 0x7939a6,
  618.             0x85d7e6, 0x93c661, 0xa32815, 0xb423a6, 0xc6e3bf
  619.     };
  620.  
  621.    
  622.     public String format(long time) {
  623.         StringBuilder string = new StringBuilder();
  624.  
  625.         long totalSeconds = time / 1000L;
  626.         long totalMinutes = totalSeconds / 60L;
  627.         long totalHours = totalMinutes / 60L;
  628.  
  629.         int seconds = (int)totalSeconds % 60;
  630.         int minutes = (int)totalMinutes % 60;
  631.         int hours = (int)totalHours % 24;
  632.  
  633.         if (hours > 0) {
  634.         string.append(hours + "h ");
  635.         }
  636.         if (minutes > 0) {
  637.         string.append(minutes + "m ");
  638.         }
  639.         string.append(seconds +"s");
  640.  
  641.         return string.toString();
  642.     }
  643.    
  644.     private int getSeconds(long time) {
  645.         return (int)((time/1000L)%60);
  646.     }
  647.    
  648.     public void onPaint(Graphics g) {
  649.         long currentEXP = this.client.getSkills().getExperience(Skill.FISHING);
  650.         long expGain = client.getSkills().getExperience(Skill.FISHING) - startXP;
  651.        
  652.        
  653.         g.setColor(color1);
  654.         g.fillRect(558, 335, 167, 103);
  655.         g.setColor(color2);
  656.         g.drawRect(558, 335, 167, 103);
  657.         g.setFont(font1);
  658.         g.setColor(color3);
  659.         g.drawString("Runtime: " + format((System.currentTimeMillis()-startTime)) , 565, 369);
  660.         g.drawString("Status: " + status, 565, 379);
  661.         g.drawString("EXP Gained: " + NumberFormat.getIntegerInstance().format(expGain), 565, 388);
  662.         g.drawString("EXP/Hour: " + NumberFormat.getIntegerInstance().format(expGain *3600000D / (System.currentTimeMillis() - startTime)) , 565, 397);
  663.         g.drawString("Level: " + client.getSkills().getLevel(Skill.FISHING), 565, 405);
  664.         g.drawString("Levels Gained: " + lvlUp, 565, 414);
  665.         g.drawString("Total Caught: " + (caught), 565, 424);
  666.         g.drawString("Caught/Hour: " +getHourlyRate(caught), 565, 433);
  667.         g.setColor(color2);
  668.         g.drawLine(566, 354, 717, 354);
  669.         g.drawLine(683, 336, 683, 354);
  670.         g.drawLine(597, 336, 597, 353);
  671.         g.setFont(font2);
  672.         g.drawString("RFisher", 615, 350);
  673.     }
  674.    
  675.     public int getHourlyRate(int variable) {
  676.         return (int)((variable - 0) * 3600000.0D / (System.currentTimeMillis() - this.startTime));
  677.     }
  678.    
  679.     public void onMessage(String message) throws InterruptedException {
  680.         if(message.contains("You catch a trout.") || message.contains("You catch a salmon.")) {
  681.             caught++;
  682.         }
  683.        
  684.         if(message.contains("You catch a trout.")) {
  685.             troutCaught++;
  686.         }
  687.        
  688.         if(message.contains("You catch a salmon.")) {
  689.             salmonCaught++;
  690.         }
  691.        
  692.         if(message.contains("advanced a")) {
  693.             lvlUp++;
  694.         }
  695.     }
  696.    
  697.     public class GUI extends JFrame {
  698.         private JPanel contentPane;
  699.         private static final long serialVersionUID = 1L;
  700.  
  701.         @SuppressWarnings({ "rawtypes", "unchecked" })
  702.         public GUI() {
  703.             setTitle("RFisher 1.6");
  704.             setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
  705.             setBounds(100, 100, 221, 134);
  706.             contentPane = new JPanel();
  707.             contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
  708.             setContentPane(contentPane);
  709.             contentPane.setLayout(null);
  710.            
  711.             final JComboBox comboBox = new JComboBox();
  712.             comboBox.setModel(new DefaultComboBoxModel(new String[] {"Barbarian Village", "Shilo Village"}));
  713.             comboBox.setBounds(66, 11, 130, 20);
  714.             contentPane.add(comboBox);
  715.            
  716.             JLabel lblArea = new JLabel("Area:");
  717.             lblArea.setBounds(10, 14, 46, 14);
  718.             contentPane.add(lblArea);
  719.            
  720.             JLabel lblMethod = new JLabel("Method: ");
  721.             lblMethod.setBounds(10, 46, 55, 14);
  722.             contentPane.add(lblMethod);
  723.            
  724.             final JComboBox comboBox_1 = new JComboBox();
  725.             comboBox_1.setModel(new DefaultComboBoxModel(new String[] {"Banking", "Powerfishing"}));
  726.             comboBox_1.setBounds(66, 43, 130, 20);
  727.             contentPane.add(comboBox_1);
  728.            
  729.             JButton btnStart = new JButton("Start");
  730.             btnStart.addActionListener(new ActionListener() {
  731.                 public void actionPerformed(ActionEvent arg0) {
  732.                     if (comboBox.getSelectedItem().equals("Shilo Village") && (comboBox_1.getSelectedItem().equals("Banking"))) {
  733.                         usingShilo = true;
  734.                         bankingShilo = true;
  735.                         banking = true;
  736.                         log("Banking in Shilo Village.");
  737.                     }
  738.                    
  739.                     if (comboBox.getSelectedItem().equals("Shilo Village") && (comboBox_1.getSelectedItem().equals("Powerfishing"))) {
  740.                         usingShilo = true;
  741.                         bankingShilo = false;
  742.                         banking = false;
  743.                         log("Powefishing in Shilo Village.");
  744.                     }
  745.                    
  746.                     if (comboBox.getSelectedItem().equals("Barbarian Village") && (comboBox_1.getSelectedItem().equals("Banking"))) {
  747.                         usingEdge = true;
  748.                         bankingEdge = true;
  749.                         banking = true;
  750.                         log("Banking in Edgeville.");
  751.                     }
  752.                     if (comboBox.getSelectedItem().equals("Barbarian Village") && (comboBox_1.getSelectedItem().equals("Powerfishing"))) {
  753.                         usingEdge = true;
  754.                         bankingEdge = false;
  755.                         banking = false;
  756.                         log("Powerfishing in Barbarian Village.");
  757.                     }
  758.                     guiWait = false;
  759.                     dispose();
  760.                 }
  761.             });
  762.             btnStart.setBounds(60, 74, 89, 23);
  763.             contentPane.add(btnStart);
  764.         }
  765.     }
  766. }
Advertisement
Add Comment
Please, Sign In to add comment