Advertisement
Guest User

KanyesSheepShearer

a guest
May 6th, 2015
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 12.13 KB | None | 0 0
  1. import java.util.ArrayList;
  2. import java.util.List;
  3.  
  4. import org.dreambot.api.methods.Calculations;
  5. import org.dreambot.api.methods.map.Area;
  6. import org.dreambot.api.methods.map.Tile;
  7. import org.dreambot.api.script.AbstractScript;
  8. import org.dreambot.api.script.Category;
  9. import org.dreambot.api.script.ScriptManifest;
  10. import org.dreambot.api.wrappers.interactive.GameObject;
  11. import org.dreambot.api.wrappers.interactive.NPC;
  12.  
  13. @ScriptManifest(author = "KanyeWest", name = "SheepShearer", version = 1.0, description = "SheepShearer", category = Category.MONEYMAKING)
  14. public class main extends AbstractScript {
  15.     private Area sheepArea;
  16.     private State state;
  17.     private int inventorySize;
  18.     private int woolAmount = 0;
  19.     private int woolPrice = 200;
  20.     private long startTime;
  21.  
  22.     public void onStart() {
  23.         // new Tile(3212, 3258, 0),new Tile(3193, 3276, 0)
  24.         sheepArea = new Area(new Tile(3194, 3258, 0), new Tile(3212, 3274, 0));
  25.         state = State.SHEARING;
  26.         inventorySize = getInventory().count(1737);
  27.         startTime = System.currentTimeMillis();
  28.     }
  29.  
  30.     public enum State {
  31.         SHEARING, WALKTOBANK, WALKTOSHEEP, WAITING, BANK, OPENGATE;
  32.     }
  33.  
  34.     public void onExit() {
  35.         log("Goodbye scrub shearers");
  36.     }
  37.  
  38.     @Override
  39.     public int onLoop() {
  40.         int timeout = 0;
  41.         switch (state) {
  42.         case SHEARING:
  43.             NPC sheep = getNpcs().closest(2794, 2801, 2800, 2795, 2796, 2802);
  44.             // System.out.println((sheepArea.contains(sheepPos)));
  45.             inventorySize = getInventory().count(1737);
  46.             if (sheepArea.contains(sheep)) {
  47.                 sheep.interact("Shear");
  48.             } else {
  49.                 List<NPC> sheeps = new ArrayList<NPC>();
  50.                 sheeps.addAll(getNpcs().all(2794, 2801, 2800, 2795, 2796, 2802));
  51.                 boolean found = false;
  52.                 for (NPC n : sheeps) {
  53.                     if (sheepArea.contains(n) && !found) {
  54.                         n.interact("Shear");
  55.                         found = true;
  56.                     }
  57.                 }
  58.             }
  59.             state = State.WAITING;
  60.             break;
  61.         case WAITING:
  62.             int newInv = getInventory().count(1737);
  63.             if (getInventory().isFull()) {
  64.                 state = State.WALKTOBANK;
  65.             } else if (newInv > inventorySize) {
  66.                 state = State.SHEARING;
  67.  
  68.             } else if (!getLocalPlayer().isMoving()) {
  69.                 sleep(Calculations.random(300, 400));
  70.                 if (!getLocalPlayer().isMoving())
  71.                     state = State.SHEARING;
  72.             }
  73.             break;
  74.         case WALKTOBANK:
  75.  
  76.             getWalking().walk(new Tile(3209, 3261, 0));
  77.             do {
  78.                 sleep(Calculations.random(400, 600));
  79.             } while (getWalking().getDestinationDistance() > 2);
  80.             GameObject[] gateZone = getGameObjects().getObjectsOnTile(
  81.                     new Tile(3213, 3262));
  82.             GameObject gate = null;
  83.             for (GameObject g : gateZone) {
  84.                 if (g.getID() == 12987 || g.getID() == 12986)
  85.                     gate = g;
  86.             }
  87.             if (gate != null)
  88.                 gate.interact("Open");
  89.             do {
  90.                 timeout++;
  91.                 if (timeout > 4) {
  92.                     gate.interact("Open");
  93.                     timeout = 0;
  94.                 }
  95.                 sleep(Calculations.random(500, 600));
  96.             } while (getGameObjects().closest(12989, 12988) == null);
  97.  
  98.             getWalking().walk(new Tile(3216, 3261, 0));
  99.             sleep(Calculations.random(500, 600));
  100.             do {
  101.                 timeout++;
  102.                 if (timeout > 4) {
  103.                     getWalking().walk(new Tile(3216, 3261, 0));
  104.                     timeout = 0;
  105.                 }
  106.                 sleep(Calculations.random(500, 600));
  107.             } while (getWalking().getDestinationDistance() > 2);
  108.  
  109.             getWalking().walk(new Tile(3216, 3254, 0));
  110.             sleep(Calculations.random(500, 600));
  111.             do {
  112.                 timeout++;
  113.                 if (timeout > 4) {
  114.                     getWalking().walk(new Tile(3216, 3254, 0));
  115.                     timeout = 0;
  116.                 }
  117.                 sleep(Calculations.random(500, 600));
  118.             } while (getWalking().getDestinationDistance() > 2);
  119.  
  120.             getWalking().walk(new Tile(3219, 3246, 0));
  121.             sleep(Calculations.random(500, 600));
  122.             do {
  123.                 timeout++;
  124.                 if (timeout > 4) {
  125.                     getWalking().walk(new Tile(3219, 3246, 0));
  126.                     timeout = 0;
  127.                 }
  128.                 sleep(Calculations.random(500, 600));
  129.             } while (getWalking().getDestinationDistance() > 2);
  130.  
  131.             getWalking().walk(new Tile(3224, 3237, 0));
  132.             sleep(Calculations.random(500, 600));
  133.             do {
  134.                 timeout++;
  135.                 if (timeout > 4) {
  136.                     getWalking().walk(new Tile(3224, 3237, 0));
  137.                     timeout = 0;
  138.                 }
  139.                 sleep(Calculations.random(500, 600));
  140.             } while (getWalking().getDestinationDistance() > 2);
  141.  
  142.             getWalking().walk(new Tile(3231, 3231, 0));
  143.             sleep(Calculations.random(500, 600));
  144.             do {
  145.                 timeout++;
  146.                 if (timeout > 4) {
  147.                     getWalking().walk(new Tile(3231, 3231, 0));
  148.                     timeout = 0;
  149.                 }
  150.                 sleep(Calculations.random(500, 600));
  151.             } while (getWalking().getDestinationDistance() > 2);
  152.  
  153.             getWalking().walk(new Tile(3231, 3231, 0));
  154.             sleep(Calculations.random(500, 600));
  155.             do {
  156.                 timeout++;
  157.                 if (timeout > 4) {
  158.                     getWalking().walk(new Tile(3231, 3231, 0));
  159.                     timeout = 0;
  160.                 }
  161.                 sleep(Calculations.random(500, 600));
  162.             } while (getWalking().getDestinationDistance() > 2);
  163.  
  164.             getWalking().walk(new Tile(3224, 3218, 0));
  165.             sleep(Calculations.random(500, 600));
  166.             do {
  167.                 timeout++;
  168.                 if (timeout > 4) {
  169.                     getWalking().walk(new Tile(3224, 3218, 0));
  170.                     timeout = 0;
  171.                 }
  172.                 sleep(Calculations.random(500, 600));
  173.             } while (getWalking().getDestinationDistance() > 2);
  174.  
  175.             getWalking().walk(new Tile(3217, 3218, 0));
  176.             sleep(Calculations.random(500, 600));
  177.             do {
  178.                 timeout++;
  179.                 if (timeout > 4) {
  180.                     getWalking().walk(new Tile(3217, 3218, 0));
  181.                     timeout = 0;
  182.                 }
  183.                 sleep(Calculations.random(500, 600));
  184.             } while (getLocalPlayer().isMoving());
  185.  
  186.             getWalking().walk(new Tile(3215, 3210, 0));
  187.             sleep(Calculations.random(500, 600));
  188.             do {
  189.                 timeout++;
  190.                 if (timeout > 4) {
  191.                     getWalking().walk(new Tile(3215, 3210, 0));
  192.                     timeout = 0;
  193.                 }
  194.                 sleep(Calculations.random(500, 600));
  195.             } while (getLocalPlayer().isMoving());
  196.  
  197.             getWalking().walk(new Tile(3207, 3209, 0));
  198.             sleep(Calculations.random(500, 600));
  199.             do {
  200.                 timeout++;
  201.                 if (timeout > 4) {
  202.                     getWalking().walk(new Tile(3207, 3209, 0));
  203.                     timeout = 0;
  204.                 }
  205.                 sleep(Calculations.random(500, 600));
  206.             } while (getLocalPlayer().isMoving());
  207.  
  208.             GameObject stairs = getGameObjects().closest(16671);
  209.             stairs.interact("Climb-up");
  210.             do {
  211.                 timeout++;
  212.                 if (timeout > 4) {
  213.                     stairs.interact("Climb-up");
  214.                     timeout = 0;
  215.                 }
  216.                 sleep(Calculations.random(500, 600));
  217.             } while (getGameObjects().closest(16672) == null);
  218.             sleep(Calculations.random(500, 600));
  219.             stairs = getGameObjects().closest(16672);
  220.             stairs.interact("Climb-up");
  221.             do {
  222.                 timeout++;
  223.                 if (timeout > 4) {
  224.                     stairs.interact("Climb-up");
  225.                     timeout = 0;
  226.                 }
  227.                 sleep(Calculations.random(500, 600));
  228.             } while (getGameObjects().closest(16673) == null);
  229.             getWalking().walk(new Tile(3208, 3219, 2));
  230.             sleep(Calculations.random(500, 600));
  231.             do {
  232.  
  233.             } while (getWalking().getDestinationDistance() > 2);
  234.             sleep(Calculations.random(500, 600));
  235.             state = State.BANK;
  236.             break;
  237.         case BANK:
  238.             woolAmount = woolAmount + getInventory().count(1737);
  239.             log("Wool gathered: \t" + woolAmount);
  240.             long profit = woolAmount * woolPrice;
  241.             log("Proft: \t" + profit);
  242.             long currentTime = System.currentTimeMillis();
  243.             long timeTaken = currentTime - startTime;
  244.             timeTaken = (timeTaken / (1000 * 60)) % 60;
  245.             log("Time taken: \t" + timeTaken + " minutes");
  246.             getBank().open();
  247.             sleep(Calculations.random(800, 1000));
  248.  
  249.             do {
  250.                 sleep(Calculations.random(800, 1000));
  251.                 getBank().open();
  252.             } while (!getBank().isOpen());
  253.             getBank().depositAll(1737);
  254.             do {
  255.                 sleep(Calculations.random(800, 1000));
  256.                 getBank().depositAll(1737);
  257.             } while (getInventory().contains(1737));
  258.             sleep(Calculations.random(500, 600));
  259.             getBank().close();
  260.             state = State.WALKTOSHEEP;
  261.             break;
  262.         case WALKTOSHEEP:
  263.             GameObject[] stairsZone = getGameObjects().getObjectsOnTile(
  264.                     new Tile(3205, 3208, 2));
  265.             GameObject stairs2 = null;
  266.             for (GameObject g : stairsZone) {
  267.                 if (g != null)
  268.                     if (g.getID() == 16673)
  269.                         stairs2 = g;
  270.             }
  271.             if (stairs2 != null)
  272.                 stairs2.interact("Climb-down");
  273.             timeout = 0;
  274.             do {
  275.                 timeout++;
  276.                 if (timeout > 4) {
  277.                     stairs2.interact("Climb-down");
  278.                     timeout = 0;
  279.                 }
  280.                 sleep(Calculations.random(500, 600));
  281.             } while (getGameObjects().closest(16672) == null);
  282.  
  283.             stairs2 = getGameObjects().closest(16672);
  284.             stairs2.interact("Climb-down");
  285.             do {
  286.                 timeout++;
  287.                 if (timeout > 4) {
  288.                     stairs2.interact("Climb-down");
  289.                     timeout = 0;
  290.                 }
  291.                 sleep(Calculations.random(500, 600));
  292.             } while (getGameObjects().closest(16671) == null);
  293.  
  294.             getWalking().walk(new Tile(3207, 3209, 0));
  295.             do {
  296.                 timeout++;
  297.                 if (timeout > 4) {
  298.                     getWalking().walk(new Tile(3207, 3209, 0));
  299.                     timeout = 0;
  300.                 }
  301.                 sleep(Calculations.random(500, 600));
  302.             } while (getWalking().getDestinationDistance() > 2);
  303.  
  304.             getWalking().walk(new Tile(3215, 3210, 0));
  305.             do {
  306.                 timeout++;
  307.                 if (timeout > 4) {
  308.                     getWalking().walk(new Tile(3215, 3210, 0));
  309.                     timeout = 0;
  310.                 }
  311.                 sleep(Calculations.random(500, 600));
  312.             } while (getWalking().getDestinationDistance() > 2);
  313.  
  314.             getWalking().walk(new Tile(3217, 3218, 0));
  315.             do {
  316.                 timeout++;
  317.                 if (timeout > 4) {
  318.                     getWalking().walk(new Tile(3217, 3218, 0));
  319.                     timeout = 0;
  320.                 }
  321.                 sleep(Calculations.random(500, 600));
  322.             } while (getWalking().getDestinationDistance() > 2);
  323.  
  324.             getWalking().walk(new Tile(3224, 3218, 0));
  325.             do {
  326.                 timeout++;
  327.                 if (timeout > 4) {
  328.                     getWalking().walk(new Tile(3224, 3218, 0));
  329.                     timeout = 0;
  330.                 }
  331.                 sleep(Calculations.random(500, 600));
  332.             } while (getWalking().getDestinationDistance() > 2);
  333.  
  334.             getWalking().walk(new Tile(3233, 3222, 0));
  335.             do {
  336.                 timeout++;
  337.                 if (timeout > 4) {
  338.                     getWalking().walk(new Tile(3233, 3222, 0));
  339.                     timeout = 0;
  340.                 }
  341.                 sleep(Calculations.random(500, 600));
  342.             } while (getWalking().getDestinationDistance() > 2);
  343.  
  344.             getWalking().walk(new Tile(3231, 3231, 0));
  345.             do {
  346.                 timeout++;
  347.                 if (timeout > 4) {
  348.                     getWalking().walk(new Tile(3231, 3231, 0));
  349.                     timeout = 0;
  350.                 }
  351.                 sleep(Calculations.random(500, 600));
  352.             } while (getWalking().getDestinationDistance() > 2);
  353.  
  354.             getWalking().walk(new Tile(3224, 3237, 0));
  355.             do {
  356.                 timeout++;
  357.                 if (timeout > 4) {
  358.                     getWalking().walk(new Tile(3224, 3237, 0));
  359.                     timeout = 0;
  360.                 }
  361.                 sleep(Calculations.random(500, 600));
  362.             } while (getWalking().getDestinationDistance() > 2);
  363.  
  364.             getWalking().walk(new Tile(3219, 3246, 0));
  365.             do {
  366.                 timeout++;
  367.                 if (timeout > 4) {
  368.                     getWalking().walk(new Tile(3219, 3246, 0));
  369.                     timeout = 0;
  370.                 }
  371.                 sleep(Calculations.random(500, 600));
  372.             } while (getWalking().getDestinationDistance() > 2);
  373.  
  374.             getWalking().walk(new Tile(3216, 3254, 0));
  375.             do {
  376.                 timeout++;
  377.                 if (timeout > 4) {
  378.                     getWalking().walk(new Tile(3216, 3254, 0));
  379.                     timeout = 0;
  380.                 }
  381.                 sleep(Calculations.random(500, 600));
  382.             } while (getWalking().getDestinationDistance() > 2);
  383.            
  384.             getWalking().walk(new Tile(3215, 3260, 0));
  385.             do {
  386.                 timeout++;
  387.                 if (timeout > 4) {
  388.                     getWalking().walk(new Tile(3215, 3260, 0));
  389.                     timeout = 0;
  390.                 }
  391.                 sleep(Calculations.random(500, 600));
  392.             } while (getWalking().getDestinationDistance() > 2);
  393.  
  394.             GameObject[] gateZone2 = getGameObjects().getObjectsOnTile(
  395.                     new Tile(3213, 3262));
  396.             GameObject gate2 = null;
  397.             for (GameObject g : gateZone2) {
  398.                 if (g.getID() == 12987)
  399.                     gate2 = g;
  400.             }
  401.             if (gate2 != null)
  402.                 gate2.interact("Open");
  403.             do {
  404.                 timeout++;
  405.                 if (timeout > 4) {
  406.                     if (gate2 != null)
  407.                         gate2.interact("Open");
  408.                     timeout = 0;
  409.                 }
  410.                 sleep(Calculations.random(500, 600));
  411.             } while (getGameObjects().closest(12989) == null);
  412.             getWalking().walk(new Tile(3208, 3261, 0));
  413.             do {
  414.  
  415.             } while (getWalking().getDestinationDistance() > 2);
  416.             state = State.SHEARING;
  417.             break;
  418.         default:
  419.             break;
  420.  
  421.         }
  422.         return Calculations.random(500, 600);
  423.     }
  424.  
  425.     public void deadFunc() {
  426.         GameObject stairs = getGameObjects().closest(16671);
  427.         stairs.interact("Climb-up");
  428.         sleep(Calculations.random(300, 400));
  429.         stairs = getGameObjects().closest(16672);
  430.         stairs.interact("Climb-up");
  431.         sleep(Calculations.random(300, 400));
  432.         getWalking().walk(new Tile(3208, 3219, 0));
  433.     }
  434. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement