Advertisement
Guest User

Fisher

a guest
Jun 27th, 2013
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 6.15 KB | None | 0 0
  1. import org.osbot.script.Script;
  2. import org.osbot.script.ScriptManifest;
  3. import org.osbot.script.rs2.map.Position;
  4. import org.osbot.script.rs2.model.NPC;
  5. import org.osbot.script.rs2.model.Player;
  6. import org.osbot.script.rs2.model.RS2Object;
  7. import org.osbot.script.rs2.ui.Tab;
  8. import org.osbot.script.rs2.utility.Area;
  9.  
  10. @ScriptManifest(name = "Shrimp Fisher", author = "Merccy", version = 1D, info = "Fishes in Draynor")
  11. public class ShrimpFisher extends Script {
  12.  
  13.     private NPC fish;
  14.  
  15.     private final Position[] bankToFish = { new Position(3092, 3248, 0),
  16.         new Position(3084, 3245, 0), new Position(3085, 3240, 0),
  17.         new Position(3088, 3244, 0), new Position(3087, 3228, 0) };
  18.  
  19.     private final Position[] fishToBank = { new Position(3088, 3244, 0),
  20.         new Position(3085, 3240, 0), new Position(3084, 3245, 0),
  21.         new Position(3092, 3248, 0), new Position(3093, 3242, 0) };
  22.  
  23.     private final Area fishArea = new Area(3082, 3233, 3089, 3225);
  24.     private final Area bankArea = new Area(3095, 3246, 3092, 3240);
  25.  
  26.     // Ids
  27.     public final int fishingNet = 303;
  28.  
  29.     public void onStart() {
  30.     log("ShrimpFisher 1.0 Started");
  31.     }
  32.  
  33.     public int onLoop() {
  34.     try {
  35.         this.antiBan();
  36.         BotStates s = getState();
  37.         handleState(s);
  38.     } catch (InterruptedException e) {
  39.     }
  40.     return 50;
  41.     }
  42.  
  43.     public void handleState(BotStates state) throws InterruptedException {
  44.     switch (state) {
  45.     case shouldWalkToFish:
  46.         this.walkPath(this.bankToFish);
  47.         break;
  48.     case shouldWalkToBank:
  49.         this.walkPath(this.fishToBank);
  50.         break;
  51.     case getFish:
  52.         this.getFish();
  53.         sleep(random(500, 1000));
  54.         this.goFish();
  55.         break;
  56.     case Banking:
  57.         this.bank();
  58.         break;
  59.     }
  60.     }
  61.  
  62.     public BotStates getState() {
  63.     Player player = this.client.getMyPlayer();
  64.     if (this.client.getInventory().isFull()
  65.         && this.bankArea.contains(player)) {
  66.         return BotStates.Banking;
  67.     }
  68.     if (this.client.getInventory().isFull()
  69.         && !this.bankArea.contains(player)) {
  70.         return BotStates.shouldWalkToBank;
  71.     }
  72.     if (player.isAnimating() || player.isMoving()) {
  73.         return BotStates.Fishing;
  74.     }
  75.     if (!this.client.getInventory().isFull()
  76.         && this.fishArea.contains(player)) {
  77.         return BotStates.getFish;
  78.     }
  79.     return BotStates.shouldWalkToFish;
  80.     }
  81.  
  82.     public void bank() throws InterruptedException {
  83.     RS2Object booth = closestObjectForName("Bank Booth");
  84.     if (booth != null) {
  85.         booth.interact("Bank");
  86.         if (this.client.getBank().isOpen()) {
  87.         this.client.getBank().depositAllExcept(this.fishingNet);
  88.         }
  89.     }
  90.     }
  91.  
  92.     public void antiBan() throws InterruptedException {
  93.     int rnd = random(1000);
  94.     if (rnd == 0) {
  95.         log("Antiban");
  96.         int rnd2 = random(16);
  97.         switch (rnd2) {
  98.         case 0:
  99.         if (currentTab() != Tab.SKILLS) {
  100.             openTab(Tab.SKILLS);
  101.             sleep(random(2500, 5000));
  102.             openTab(Tab.INVENTORY);
  103.         }
  104.         break;
  105.         case 1:
  106.         this.client.getInterface(548).getChild(47).hover();
  107.         sleep(random(1000, 2000));
  108.         break;
  109.         case 2:
  110.         this.client.getInterface(548).getChild(48).hover();
  111.         sleep(random(1000, 2000));
  112.         break;
  113.         case 3:
  114.         this.client.getInterface(548).getChild(49).hover();
  115.         sleep(random(1000, 2000));
  116.         break;
  117.         case 4:
  118.         this.client.getInterface(548).getChild(50).hover();
  119.         sleep(random(1000, 2000));
  120.         break;
  121.         case 5:
  122.         this.client.getInterface(548).getChild(51).hover();
  123.         sleep(random(1000, 2000));
  124.         break;
  125.         case 6:
  126.         this.client.getInterface(548).getChild(52).hover();
  127.         sleep(random(1000, 2000));
  128.         break;
  129.         case 7:
  130.         this.client.getInterface(548).getChild(53).hover();
  131.         sleep(random(1000, 2000));
  132.         break;
  133.         case 8:
  134.         this.client.getInterface(548).getChild(30).hover();
  135.         sleep(random(1000, 2000));
  136.         break;
  137.         case 9:
  138.         this.client.getInterface(548).getChild(31).hover();
  139.         sleep(random(1000, 2000));
  140.         break;
  141.         case 10:
  142.         this.client.getInterface(548).getChild(32).hover();
  143.         sleep(random(1000, 2000));
  144.         break;
  145.         case 11:
  146.         this.client.getInterface(548).getChild(33).hover();
  147.         sleep(random(1000, 2000));
  148.         break;
  149.         case 12:
  150.         this.client.getInterface(548).getChild(34).hover();
  151.         sleep(random(1000, 2000));
  152.         break;
  153.         case 13:
  154.         this.client.getInterface(548).getChild(35).hover();
  155.         sleep(random(1000, 2000));
  156.         break;
  157.         case 14:
  158.         this.client.getInterface(548).getChild(36).hover();
  159.         sleep(random(1000, 2000));
  160.         break;
  161.         case 15:
  162.         this.client.setMouseSpeed(random(3, 7));
  163.         break;
  164.         }
  165.     }
  166.     }
  167.  
  168.     public void getFish() throws InterruptedException {
  169.     NPC f = closestNPCForName("Fishing spot");
  170.     if (f != null) {
  171.         if (!f.isVisible()) {
  172.         this.client.moveCameraToEntity(f);
  173.         sleep(random(250, 500));
  174.         }
  175.         this.fish = f;
  176.     }
  177.     }
  178.  
  179.     public void goFish() throws InterruptedException {
  180.     if (this.fish != null) {
  181.         this.fish.interact("Net");
  182.         sleep(random(500, 1000));
  183.     }
  184.     }
  185.  
  186.     public Position randomize(Position p, int min, int max) {
  187.     int rnd = random(6);
  188.     Position p1 = p;
  189.     if (rnd == 0) {
  190.         p1 = new Position((p.getX() + random(min, max)),
  191.             (p.getY() + random(min, max)), p.getZ());
  192.         if (!canReach(p1)) {
  193.         rnd = 1;
  194.         }
  195.     }
  196.     if (rnd == 1) {
  197.         p1 = new Position((p.getX() - random(min, max)),
  198.             (p.getY() + random(min, max)), p.getZ());
  199.         if (!canReach(p1)) {
  200.         rnd = 2;
  201.         }
  202.     }
  203.     if (rnd == 2) {
  204.         p1 = new Position((p.getX() + random(min, max)),
  205.             (p.getY() - random(min, max)), p.getZ());
  206.         if (!canReach(p1)) {
  207.         rnd = 3;
  208.         }
  209.     }
  210.     if (rnd == 3) {
  211.         p1 = new Position((p.getX() - random(min, max)),
  212.             (p.getY() - random(min, max)), p.getZ());
  213.         if (!canReach(p1)) {
  214.         p1 = p;
  215.         }
  216.     }
  217.     return p1;
  218.     }
  219.  
  220.     public void walkPath(Position[] ps) throws InterruptedException {
  221.     for (Position p : ps) {
  222.         if (p == ps[ps.length - 1] || p == ps[0]) {
  223.         p = this.randomize(p, 0, 2);
  224.         } else {
  225.         p = this.randomize(p, 1, 3);
  226.         }
  227.         walkMiniMap(p);
  228.         sleep(random(250, 750));
  229.         while (this.client.getMyPlayer().isMoving()) {
  230.         sleep(100);
  231.         }
  232.     }
  233.     }
  234.  
  235.     public enum BotStates {
  236.     shouldWalkToFish, shouldWalkToBank, Banking, Fishing, getFish
  237.     }
  238. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement