コード例 #1
5
 public void run() {
   targetName =
       (Settings.getFindTargetName() == null)
           ? "gfx/kritter/dragonfly/dragonfly"
           : Settings.getFindTargetName();
   BotUtils.sysMsg("Target " + targetName, Color.WHITE);
   window = BotUtils.gui().add(new StatusWindow(), 300, 200);
   ui.root.findchild(FlowerMenu.class);
   while (BotUtils.getItemAtHand() == null) {
     GameUI gui = HavenPanel.lui.root.findchild(GameUI.class);
     IMeter.Meter stam = gui.getmeter("stam", 0);
     // Check energy stop if it is lower than 1500
     IMeter.Meter nrj = gui.getmeter("nrj", 0);
     if (nrj.a <= 30) {
       t.stop();
       return;
     } else if (stam.a <= 30 && nrj.a >= 95) {
       BotUtils.drink();
     }
     //					if (!BotUtils.isMoving()) {
     Gob gob = BotUtils.findObjectByNames(BotUtils.player().rc, 1000, targetName);
     if (gob != null) {
       BotUtils.goToCoord(gob.rc, 200, true);
       BotUtils.doClick(gob, 3, 0);
     }
     //					}
     if (gob.getres().name.contains("terobjs")) {
       sleep(800);
     }
     sleep(800);
   }
   window.destroy();
   t.stop();
 }
コード例 #2
0
 public void run() {
   stop:
   while (running) {
     BotUtils.sysMsg("Carrot Farmer Started", Color.WHITE);
     window = BotUtils.gui().add(new StatusWindow(), 300, 200);
     for (Gob gob : gobs) {
       GameUI gui = HavenPanel.lui.root.findchild(GameUI.class);
       IMeter.Meter stam = gui.getmeter("stam", 0);
       if (stam.a <= 30) {
         BotUtils.drink();
       }
       BotUtils.pfRightClick(gob, 0);
       while (ui.root.findchild(FlowerMenu.class) == null) {
         sleep(100);
       }
       @SuppressWarnings("deprecation")
       FlowerMenu menu = ui.root.findchild(FlowerMenu.class);
       if (menu != null) {
         for (FlowerMenu.Petal opt : menu.opts) {
           if (opt.name.equals("Harvest")) {
             menu.choose(opt);
             menu.destroy();
           }
         }
       }
       while (BotUtils.findObjectById(gob.id) != null) {
         sleep(100);
       }
       // Some better method should be implemented, but now it just waits a bit for items
       // to appear on inventory and stuff
       sleep(100);
       GItem item = BotUtils.getItemAtHand();
       if (item == null) {
         Inventory inv = BotUtils.playerInventory();
         for (Widget w = inv.child; w != null; w = w.next) {
           if (w instanceof GItem && isCarrot((GItem) w)) {
             item = (GItem) w;
             break;
           }
         }
         BotUtils.takeItem(item);
       }
       // Planttaa, siemen käteen tähän vaiheeseen mennessä
       BotUtils.mapInteractClick(1);
       while (BotUtils.findNearestStageCrop(5, 0, "gfx/terobjs/plants/carrot") == null) {
         sleep(100);
       }
       //  TODO Droppaa kaikki siemenet tms. invistä + kädestä = saa toimimaan kaikkiin
       // siemeniin joku hieno
       //	juttu jolla saa valittua mitä kasvia farmaa jne.
     }
     running = false;
   }
   window.destroy();
 }
コード例 #3
0
ファイル: LightWithTorch.java プロジェクト: b0r3d0m/amber
  @Override
  public void run() {
    synchronized (gui.map.glob.oc) {
      for (Gob gob : gui.map.glob.oc) {
        Resource res = gob.getres();
        if (res != null
            && (res.name.equals("gfx/terobjs/oven")
                || res.name.equals("gfx/terobjs/smelter")
                || res.name.equals("gfx/terobjs/steelcrucible")
                || res.name.equals("gfx/terobjs/kiln"))) {
          if (this.gob == null) this.gob = gob;
          else if (gob.rc.dist(gui.map.player().rc) < this.gob.rc.dist(gui.map.player().rc))
            this.gob = gob;
        }
      }
    }

    try {
      if (gob == null) {
        gui.error("No ovens/smelters/steelboxes/kilns found.");
        return;
      }

      Equipory e = gui.getequipory();
      WItem l = e.quickslots[6];
      WItem r = e.quickslots[7];

      boolean noltorch = true;
      boolean nortorch = true;

      if (l != null) {
        String lname = l.item.getname();
        if (lname.contains("Lit Torch")) noltorch = false;
      }
      if (r != null) {
        String rname = r.item.getname();
        if (rname.contains("Lit Torch")) nortorch = false;
      }

      if (noltorch && nortorch) {
        gui.error("No lit torch is equipped.");
        return;
      }

      WItem w = e.quickslots[noltorch ? 7 : 6];
      w.mousedown(new Coord(w.sz.x / 2, w.sz.y / 2), 1);

      try {
        Thread.sleep(100);
      } catch (InterruptedException ie) {
        e.wdgmsg("drop", noltorch ? 7 : 6);
        return;
      }

      gui.map.wdgmsg("itemact", Coord.z, gob.rc, 0, 0, (int) gob.id, gob.rc, 0, -1);

      if (!Utils.waitForProgressFinish(
          gui,
          TIMEOUT_ACT,
          "Oops something went wrong. Timeout when trying to light with torch.")) {
        e.wdgmsg("drop", noltorch ? 7 : 6);
        return;
      }

      e.wdgmsg("drop", noltorch ? 7 : 6);
    } catch (InterruptedException ie) {
    }
  }