Advertisement
Guest User

Untitled

a guest
Oct 26th, 2015
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.49 KB | None | 0 0
  1. public class zCopperMiner extends AbstractScript{
  2.  
  3. private int state;
  4. private String ore;
  5. private int rockID = 7474;
  6. private GameObject rock = getGameObjects().closest(rockID);
  7. Area bankArea = new Area(2977, 3248, 3092, 3246, 0);
  8. Tile finalDestination = new Tile(2977, 3248);
  9. Area bankArea2 = new Area(2977, 3248, 3012, 3355, 0);
  10. private int count;
  11.  
  12. public void onStart() {
  13. ore = "Copper Ore";
  14. count = 0;
  15. state = 0;
  16. }
  17.  
  18. @Override
  19. public int onLoop() {
  20. if (state == 0) {
  21. getWalking().walk(finalDestination);
  22. mine();
  23. } else if (state == 1) {
  24. getWalking().walk(bankArea.getCenter());
  25. bank();
  26. } else if (state == 2) {
  27. getWalking().walk(bankArea2.getCenter());
  28. bank2();
  29. } else {
  30. }
  31. return 500;
  32. }
  33.  
  34. private void mine() {
  35. if (!getInventory().isFull()) {
  36. rock = getGameObjects().closest(rockID);
  37. if(rock != null) {
  38. if(rock.interact("Mine")) {
  39. sleepUntil(() -> getInventory().count(ore) > count, Calculations.random(1000, 10000));
  40. if (getInventory().count(ore) > count) {
  41. count++;
  42. }
  43. }
  44. }
  45.  
  46. } else {
  47. state = 1;
  48. }
  49.  
  50. }
  51.  
  52.  
  53. private void bank() {
  54. if (getBank().isOpen()) {
  55. getBank().depositAll(ore);
  56. } else {
  57. getBank().open();
  58. sleepUntil(getBank().isOpen());
  59. state = 2;
  60. }
  61.  
  62. }
  63.  
  64. private void bank2() {
  65. if (getBank().isOpen()) {
  66. getBank().depositAll(ore);
  67. } else {
  68. getBank().open();
  69. sleepUntil(getBank().isOpen());
  70. state = 0;
  71. }
  72.  
  73. }
  74.  
  75. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement