Advertisement
keitaro2

Untitled

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