Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @ScriptManifest(author = "keitaro", name = "Copper Miner", version = 1.0, description = "Copper Miner", category = Category.MINING)
- public class zCopperMiner extends AbstractScript{
- public void onStart() {
- log ("welcome to zCopperMiner, by keitaro");
- count = 0;
- state = 0;
- }
- private int state;
- private String ore;
- private int count;
- private int rockID = 7478;
- private GameObject rock = getGameObjects().closest(rockID);
- Area bankArea = new Area(2977, 3248, 3092, 3246, 0);
- Tile finalDestination = new Tile(2977, 3248);
- Area bankArea2 = new Area(2977, 3248, 3012, 3355, 0);
- @Override
- public int onLoop() {
- if (state == 0) {
- getWalking().walk(finalDestination);
- mine();
- } else if (state == 1) {
- getWalking().walk(bankArea.getCenter());
- bank();
- } else if (state == 2) {
- getWalking().walk(bankArea2.getCenter());
- bank2();
- } else {
- }
- if (getDialogues().canContinue()){
- if(getDialogues().continueDialogue()){
- sleepUntil(() -> !getDialogues().canContinue(), 3000);
- }
- }
- return Calculations.random(2000, 10000);
- }
- @Override
- public void onExit() {
- }
- private void mine() {
- if (!getInventory().isFull()) {
- rock = getGameObjects().closest(rockID);
- if(rock != null) {
- if(rock.interact("Mine")) {
- sleepUntil(() -> getInventory().count(ore) > count, Calculations.random(1000, 10000));
- if (getInventory().count(ore) > count) {
- count++;
- }
- }
- }
- } else {
- state = 1;
- }
- }
- private void bank() {
- if (getBank().isOpen()) {
- getBank().depositAll(ore);
- } else {
- getBank().open();
- sleepUntil(() -> getBank().isOpen(), Calculations.random(500, 1000));
- state = 2;
- }
- }
- private void bank2() {
- if (getBank().isOpen()) {
- getBank().depositAll(ore);
- } else {
- getBank().open();
- sleepUntil(() -> getBank().isOpen(), Calculations.random(500, 1000));
- state = 0;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement