Don't like ads? PRO users don't see any ads ;-)
Guest

Draynor Net Fisher v0.1

By: a guest on Aug 19th, 2012  |  syntax: Java  |  size: 12.86 KB  |  hits: 10  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. package scripts;
  2.  
  3. import java.awt.Color;
  4. import java.awt.Graphics;
  5. import java.awt.Point;
  6. import java.util.HashMap;
  7. import java.util.Random;
  8.  
  9. import org.tribot.api.Banking;
  10. import org.tribot.api.Game;
  11. import org.tribot.api.Inventory;
  12. import org.tribot.api.Minimap;
  13. import org.tribot.api.Player;
  14. import org.tribot.api.ScreenModels;
  15. import org.tribot.api.Timing;
  16. import org.tribot.api.input.Mouse;
  17. import org.tribot.api.types.InventoryItem;
  18. import org.tribot.api.types.MinimapIcon;
  19. import org.tribot.api.types.ScreenModel;
  20. import org.tribot.script.Script;
  21. import org.tribot.script.ScriptManifest;
  22. import org.tribot.script.interfaces.Arguments;
  23. import org.tribot.script.interfaces.Painting;
  24.  
  25. @ScriptManifest(authors = { "Emu" }, category = "Fishing", name = "Draynor Fisher v0.1",
  26. description =
  27. "<html>"+
  28. "<head>"+
  29. "       <title>Emu's Fisher</title>"+
  30. "</head>"+
  31. "<body>"+
  32. "       <h1>"+
  33. "               Emu&#39;s Draynor Fisher V0.1</h1>"+
  34. "       <p>"+
  35. "               Credits: JJ for Paint and Methods, Mercatres for GUI</p>"+
  36. "       <p>"+
  37. "               How to use:</p>"+
  38. "       <ul>"+
  39. "               <li>"+
  40. "                       Start at Draynor Village willows 2, squares away from other players</li>"+
  41. "               <li>"+
  42. "                       Have a net in your toolbelt (NOT in your inventory), Have your inventory tab open</li>"+
  43. "               <li>"+
  44. "                       Have the camera &#39;up&#39; as high as possible (Birds&#39; Eye View)</li>"+
  45. "               <li>"+
  46. "                       Fill out the GUI below</li>"+
  47. "               <li>"+
  48. "                       Click Start!</li>"+
  49. "       </ul>"+
  50. "       <p>"+
  51. "               Enter Mouse Speed&nbsp;&nbsp;<input maxlength=\"3\" name=\"MouseSpeed\" type=\"text\" value=\"80\" /></p>"+
  52. "       <p>"+
  53. "               Number of Trips <input maxlength=\"9\" name=\"runtime\" type=\"text\" value=\"60\" /></p>"+
  54. "       <p>"+
  55. "               Please report any bugs on the forums - Thanks!</p>"+
  56. "       <hr />"+
  57. "</body>"+
  58. "</html>")
  59.  
  60. public class EmusDraynorFisherAlphaRelease extends Script implements Painting, Arguments {
  61.        
  62.        
  63.         final Random Randomizer = new Random();
  64.         long startTime = 0, animationID = 0, playerID = 0;
  65.         final long[] notAnimation = {1417827556L, 4390934L, 2457391002L, 949177853L};
  66.         public String status;
  67.         final long fishspotID = 2704514198L;
  68.         final int fishID = 282419, FishID = 8292, BankID = 30858, bankcounterID = 1189553980;
  69.         public long idle = 0;
  70.         public int temp = 0;
  71.         int stoptime = 60, mspeed = 50, totaltrips = 0;
  72.         final Point mmMiddle = new Point(627, 135);
  73.         public boolean killswitch = false;
  74.          
  75.         @Override
  76.         public void passArguments(HashMap<String, String> m) {
  77.                 mspeed = Integer.parseInt(m.get("MouseSpeed"));
  78.                 stoptime = Integer.parseInt(m.get("runtime"));
  79.         }
  80.  
  81.  
  82.         @Override
  83.     public void onPaint(Graphics g){
  84.         g.setColor(Color.WHITE);
  85.         g.drawString("Emu's Draynor Fisher v0.1", 5, 100);
  86.         g.drawString("Time Running: " + Timing.msToString(System.currentTimeMillis() - startTime), 5, 120);
  87.         g.drawString("Player ID: " + playerID, 5, 140);
  88.         g.drawString("Animation ID: " + animationID, 5, 160);
  89.         g.drawString("Status: " + status, 5, 180);
  90.         g.drawString("Mouse Speed: " + mspeed, 5, 200);
  91.         g.drawString("Current Trip: " + totaltrips, 5, 220);
  92.         g.drawString("Stopping At: " + stoptime , 5, 240);
  93.         g.drawString("Credits: JJ for Paint and Methods",  5, 355);
  94.        
  95.     }
  96.        
  97.        
  98.        
  99.     private void grabID(String which){
  100.         if (which.equals("animationID") || which.equals("playerID")){
  101.                 ScreenModel[] ids = ScreenModels.getAll();
  102.                 for (int i=0; i<ids.length; i++){
  103.                         if (ids[i].points[0].x > 220 && ids[i].points[0].x < 310){
  104.                                 if (ids[i].points[0].y > 180 && ids[i].points[0].y < 250){
  105.                                         int k=0;
  106.                                         for (int j=0; j<notAnimation.length; j++){
  107.                                                 if (ids[i].id != notAnimation[j]){
  108.                                                         k++;
  109.                                         }
  110.                                         }
  111.                                                 if (k == notAnimation.length){
  112.                                                         if (which.equals("animationID")){
  113.                                                                 if (ids[i].id != playerID)
  114.                                                                         animationID = ids[i].id;
  115.                                                         }else{
  116.                                                                 playerID = ids[i].id;
  117.                                                         }
  118.                                                         break;
  119.                                                 }
  120.                                 }
  121.                         }
  122.                 }
  123.         }
  124. }
  125.    
  126.     public long getAnimationID() {
  127.                 ScreenModel[] ids = ScreenModels.getAll();
  128.         for (int i=0; i<ids.length; i++){
  129.                 if (ids[i].points[0].x > 250 && ids[i].points[0].x < 280){
  130.                         if (ids[i].points[0].y > 190 && ids[i].points[0].y < 230){
  131.                                 animationID = ids[i].id;
  132.                                 break;
  133.                         }
  134.                 }
  135.         }
  136.                 return animationID;
  137.         }
  138.    
  139.  
  140.    
  141.     public boolean animationcheck(){
  142.         if(getAnimationID()==playerID){
  143.                 return true;
  144.         } else {
  145.                 return false;
  146.         }
  147.        
  148.     }
  149.    
  150.    
  151.     public boolean findfish(){
  152.         ScreenModel[] fish = ScreenModels.find(fishspotID);
  153.         if(fish.length > 0){
  154.                 sleep(500, 700);
  155.                 return true;
  156.         } else {
  157.                 sleep(500, 700);
  158.                 return false;
  159.         }
  160.     }
  161.    
  162.     public void EScreenMouse(long fishspotID2){
  163.         ScreenModel[] object = ScreenModels.find(fishspotID2);
  164.         int x = Randomizer.nextInt(20);
  165.         switch(x){
  166.         case 1: Point FS = new Point(object[temp].points[temp].x - Randomizer.nextInt(30), object[temp].points[temp].y - Randomizer.nextInt(16)); Mouse.move(FS);
  167.         case 2: Point FD = new Point(object[temp].points[temp].x + Randomizer.nextInt(17), object[temp].points[temp].y - Randomizer.nextInt(24)); Mouse.move(FD);
  168.         case 3: Point FF = new Point(object[temp].points[temp].x - Randomizer.nextInt(12), object[temp].points[temp].y + Randomizer.nextInt(22)); Mouse.move(FF);
  169.         case 4: Point FG = new Point(object[temp].points[temp].x + Randomizer.nextInt(24), object[temp].points[temp].y + Randomizer.nextInt(17)); Mouse.move(FG);
  170.         default: sleep(300, 400);
  171.         }
  172.        
  173.     }
  174.    
  175.    
  176.    
  177.     public boolean fishspot(){
  178.         boolean tempwtf = false;
  179.         if((findfish()) && (animationcheck())){
  180.                 EScreenMouse(fishspotID);
  181.                 ScreenModel[] fish = ScreenModels.find(fishspotID);
  182.                   // Credits JJ
  183.                
  184.                         Point FS = new Point(fish[temp].points[temp].x - Randomizer.nextInt(10), fish[temp].points[temp].y - Randomizer.nextInt(10));
  185.            
  186.                         if (FS.y < 160 || FS.y > 430){
  187.                 status = "Moving to Fish";
  188.             }else{
  189.                        
  190.                 Mouse.move(FS);
  191.                
  192.                 if (Timing.waitUptext("Net Fishing Spot", 800)){
  193.                         sleep(50, 100);
  194.                         Mouse.click(1);
  195.                         sleep(1300, 2000);
  196.                         tempwtf = true;
  197.                         }else{
  198.                         Mouse.click(3);
  199.                         sleep(50, 100);
  200.                         Timing.waitChooseOption("Net", 800);
  201.                         sleep(1300, 2000);
  202.                         tempwtf = true;
  203.                         }
  204.                 }      
  205.         }
  206.        
  207.         while(Player.isMoving()){
  208.                 sleep(2000, 3000);
  209.         }
  210.                 return tempwtf;
  211.     }
  212.    
  213.     public void movetoloc(int ID){
  214.         MinimapIcon[] symbol = Minimap.findIcons(ID);
  215.         if (symbol.length < 3){
  216.                 Point SS = new Point(symbol[0].x + Randomizer.nextInt(5), symbol[0].y + Randomizer.nextInt(5));
  217.                 Mouse.move(SS);
  218.                 Mouse.click(SS, 1);
  219.                 sleep(3000, 5000);
  220.         }
  221.     }
  222.    
  223.    
  224.     public boolean bankall(){
  225.        
  226.         while(Player.isMoving()){
  227.                 sleep(1000, 2000);
  228.         }
  229.        
  230.         EScreenMouse(bankcounterID);
  231.             ScreenModel[] bank = ScreenModels.find(bankcounterID);
  232.                   // Clicking on the fishing spot, if there are two then randomly picks one
  233.        
  234.                 Point FS = new Point(bank[temp].points[temp].x + Randomizer.nextInt(10), bank[temp].points[temp].y + Randomizer.nextInt(10));
  235.             Mouse.move(FS);
  236.                
  237.             if (Timing.waitUptext("Bank Counter", 800)){
  238.                 sleep(50, 100);
  239.                 Mouse.click(1);
  240.                 sleep(1300, 2000);
  241.                 return true;
  242.             }else{
  243.                 Mouse.click(3);
  244.                 sleep(50, 100);
  245.                 if ((Timing.waitChooseOption("Bank Counter", 800)) || (Timing.waitChooseOption("Bank Banker", 800))){
  246.                         sleep(1300, 2000);
  247.                         return true;
  248.                 }
  249.             }
  250.           return false;
  251.     }
  252.    
  253.     public void depositfish(){
  254.         InventoryItem[] fish =Inventory.find(fishID);
  255.         int randtemp = (Randomizer.nextInt(fish.length));
  256.         if(randtemp<1){
  257.                 randtemp = randtemp - 1;
  258.         }
  259.                 Point FS = new Point(fish[randtemp].x - Randomizer.nextInt(2) + 15, fish[randtemp].y - Randomizer.nextInt(2) + 15);
  260.             Mouse.move(FS);
  261.  
  262.                     if (Timing.waitUptext("Deposit", 800)){
  263.                         if (fish.length == 1){
  264.                                 Mouse.click(1);
  265.                         } else {
  266.                         Mouse.click(3);
  267.                         sleep(50, 200);
  268.                                 if(Timing.waitChooseOption("All", 800)){
  269.                                         sleep(600, 800);
  270.                                 }
  271.                         }
  272.                     }
  273.     }
  274.    
  275.     public void antiban(){
  276.         int x = Randomizer.nextInt(20);
  277.         switch(x){
  278.         case 1: mouseoffscreen();
  279.         default: sleep(300, 400);
  280.         }
  281.     }
  282.                
  283.  
  284.         private void mouseoffscreen() {
  285.                 Mouse.moveBox(1000, 600, 200, 200);
  286.                 println("Antiban: Mouse moving");
  287.         }
  288.        
  289.        
  290.  
  291.         public void mainloop(){
  292.        
  293.         //Credits to JJ for this loop
  294.         //Based heavily on http://pastebin.com/CKVCZvmt
  295.  
  296.         if(animationcheck()){
  297.                 sleep(700, 900);
  298.                 if(animationcheck()){
  299.                         status = "Idle";
  300.                 }
  301.         }
  302.                 if(!findfish()){
  303.                         status = "Moving to Fish";
  304.                         }
  305.                         if((!animationcheck())&&(Inventory.find(fishID).length < 27)){
  306.                                 status = "Fishing";
  307.                                 }
  308.                         if (Inventory.find(fishID).length > 27){
  309.                                 status = "Banking";
  310.                         }
  311.                
  312.        
  313.        
  314.        
  315.         if (status == "Fishing"){
  316.                 sleep(1000, 2000);
  317.                 antiban();
  318.         }
  319.        
  320.         if (status == "Idle"){
  321.                 if(!fishspot()){
  322.                         while(Player.isMoving()){
  323.                                 sleep(100, 300);
  324.                         }
  325.                         println("Debug: Idle - Moving to fish");
  326.                         status = "Moving to Fish";
  327.                 }else{
  328.                         status = "Fishing";
  329.                 }
  330.         }
  331.        
  332.        
  333.         if (status == "Moving to Fish"){
  334.                 movetoloc(FishID);
  335.                 while(Player.isMoving()){
  336.                         sleep(700, 1000);
  337.                 }
  338.         }
  339.        
  340.         if (status == "Banking"){
  341.                 movetoloc(BankID);
  342.                 while(Player.isMoving()){
  343.                         sleep(100, 4000);
  344.                 }
  345.                 status = "At Bank";
  346.            
  347.         }
  348.        
  349.         if (status == "At Bank"){
  350.                 if (bankall()){
  351.                         status = "Deposit Fish";
  352.                         sleep(600, 900);
  353.                 } else {
  354.                         sleep(1000, 2000);
  355.                         if (bankall()){
  356.                                 sleep(200, 400);
  357.                                 status = "Deposit Fish";
  358.                         } else {
  359.                                 println("Could not open bank twice - Killing Script");
  360.                                 killswitch = true;
  361.                         }
  362.                 }
  363.         }
  364.        
  365.        
  366.         if(status == "Deposit Fish"){
  367.                 totaltrips ++;
  368.                 int fail = 0;
  369.                         while((fail<4) && ((Inventory.find(fishID).length != 0))){
  370.                         sleep(800, 100);
  371.                         depositfish();
  372.                         fail ++;
  373.                 }
  374.                 if ((Inventory.find(fishID).length != 0)){
  375.                 status = "Failed to Deposit... :(";
  376.                 killswitch = true;
  377.                 }
  378.         }      
  379.     }
  380.    
  381.     public void onClose(){
  382.         println("Script Ending...");
  383.         println("Please report any bugs on the forums - Thanks!");
  384.         println("Total Runtime: " + Timing.msToString(System.currentTimeMillis() - startTime));
  385.         Banking.closeBankScreen();
  386.         Mouse.moveBox(750, 56, 759, 64);
  387.         Mouse.click(1);
  388.         Mouse.moveBox(570, 443, 706, 466);
  389.         Mouse.click(1);
  390.     }
  391.    
  392.  
  393.    
  394.     public boolean onStart(){
  395.                 println("Emu's Draynor Fisher: Starting...");
  396.                 status = "Starting...";
  397.                
  398.                 Game.setRunMode(true);
  399.         Mouse.setSpeed(mspeed);
  400.                 startTime  = System.currentTimeMillis();
  401.                 grabID("playerID");
  402.                 getAnimationID();
  403.                 if (playerID == animationID){
  404.                         return true;
  405.                 } else {
  406.                         println("Animation ID was wrong, please start the bot away from other players");
  407.                         return false;
  408.                 }
  409.                
  410.     }
  411.    
  412.  
  413.    
  414.    
  415.     public boolean tripsmet(){
  416.         if (totaltrips <= stoptime){
  417.                 return true;
  418.         }else {
  419.                 return false;
  420.         }
  421.     }
  422.  
  423.  
  424.  
  425.         @Override
  426.         public void run() {
  427.                 startTime  = System.currentTimeMillis();
  428.                 if(onStart()){
  429.                         while((!killswitch)&&(tripsmet())){
  430.                                 mainloop();
  431.                                 sleep(600, 800);
  432.                         }
  433.                        
  434.                 }
  435.                 onClose();
  436.         }
  437. }