@Override public boolean activate() { int index = 0; final Tile[] tiles = GlobalConstant.TILE_ROCKS[Checks.isGold()]; for (int i = 1; i < tiles.length; i++) { if (Calculations.distanceTo(tiles[i]) < Calculations.distanceTo(tiles[index])) index = i; } if (GlobalConstant.WIELDED_ID != -1 && (Tabs.getCurrent().equals(Tabs.INVENTORY) || Tabs.getCurrent().equals(Tabs.ATTACK)) && Settings.get(300) == 1000) { if (Checks.getLP() < Skills.getRealLevel(Skills.CONSTITUTION) * 10 - 200) return true; } return !Banker.isDepositOpen() && ((inCombat() /* && Calculations.distanceTo(tiles[index]) < 8 && !Inventory.isFull()*/) || Checks.isOutside() || (GlobalConstant.KEEP_ALIVE && Checks.getLP() < Skills.getRealLevel(Skills.CONSTITUTION) * 0.4f * 10)); }
// used when started and to determined what we will do next. public static void getState() { if (inventorySpace()) { // check for full inventory return; // if full return, it will go to bank and then get the state } if (Calculations.distanceTo(surface) < 20) { // case that script started // at surface state = "mining surface"; } else if (Calculations.distanceTo(bank) < 20) { // case that script // started at bank if (karajamaGloves) { teleportToMine(); } else { state = "walking to surface"; } } else if (Calculations.distanceTo(bankChest) < 20) { teleportToMine(); // teleport to mine cuz inventory empty. teleport // method gets state } else if (Calculations.distanceTo(below) < 20) { state = "mining underground"; } else if (Calculations.distanceTo(castleWarsTile) < 20) { teleportToMine(); } else if (karajamaGloves) { // case that we are lost and equipped karajama gloves teleportToMine(); } else { /* * Player is not in any obvious location so we need to check if * player is along a path to or from bank */ if (!(WalkToSurface.checkIfNearPath())) { // we are lost lost = true; state = "lost"; // set state to nothing because we are lost... // needs to be manually reset } // method will check if near path and if it is it will walk to // surface // if this returns false we are lost and should turn off script } }
private void OpenDoors() { if ((SceneEntities.getNearest(Cons.DoorsClosed1).isOnScreen() || SceneEntities.getNearest(Cons.DoorsClosed2).isOnScreen()) && Calculations.distanceTo(SceneEntities.getNearest(Cons.DoorsClosed1)) < 3) { if (SceneEntities.getNearest(Cons.DoorsClosed1).isOnScreen()) { SceneEntities.getNearest(Cons.DoorsClosed1).interact("Open"); Time.sleep(3000, 4000); } if (SceneEntities.getNearest(Cons.DoorsClosed2).isOnScreen()) { SceneEntities.getNearest(Cons.DoorsClosed2).interact("Open"); Time.sleep(3000, 4000); } } }
public static boolean inventorySpace() { if (Inventory.getCount() == 28) { if (dropGems()) return false; if (wickedHood) { state = "wicked hood banking"; } else if (castleWarsBank) { state = "teleporting to castle wars"; } else { // we should validate that we are near the path or break the // script. if (Calculations.distanceTo(surface) < 30) { state = "walking to bank"; } if (!WalkToBank.checkIfNearPath()) { state = "walking to bank"; } } return true; } return false; }
public void onRepaint(Graphics g1) { Graphics2D g = (Graphics2D) g1; // TODO paint da walls?? testing shit here /* SceneObject[] blockages = SceneEntities.getLoaded(new Filter<SceneObject>() { @Override public boolean accept(SceneObject so) { return so != null && so.validate(); } }); if (MiningVars.rockMining != null && MiningVars.rockMining.getBounds() != null) { for (SceneObject b : blockages) { Polygon[] rmBounds = MiningVars.rockMining.getBounds(); long overlap = 0; for (int i = 0 ; i < b.getBounds().length ; i++) { for (int j = 0 ; j < rmBounds.length ; j++) { for (int x = 0 ; x < rmBounds[j].xpoints.length ; x++) { for (int y = 0 ; y < rmBounds[j].ypoints.length ; y++) { if (b.getBounds()[i].contains(rmBounds[j].xpoints[x], rmBounds[j].ypoints[y])) { overlap++; } } } } } System.out.println(overlap); /* if (s.getLocation() != null) { int orientation = Players.getLocal().getOrientation(); switch (orientation) { case 0: //E break; case 90: //N break; case 180: //W break; case 270: //S break; default: break; } } } } */ if (GUI.isFinished) { if (showPaint) { g.setColor(bgColor); g.fillRoundRect(1, 388, 517, 141, 20, 20); g.setFont(titleFont); g.setColor(titleColor); g.drawString("Loneleh Mining", 128, 387); g.drawImage(miningImg, 43, 431, null); g.drawImage(hideButtonImg, hideButtonRect.x, hideButtonRect.y, null); g.setFont(font1); g.setColor(color1); g.drawString(version_s, 477, 67); String gold_s, goldPerHour_s, exp_s, expPerHour_s; long profit = 0; double exp = 0; for (Ore o : MiningVars.oresToMine) { profit += (double) o.getCount() * o.getPrice(); exp += o.getCount() * o.getExp(); } int x = 160; int y = 418; int lineShift = 17; int valueShift = 106; g.setFont(font3); g.drawString("Time Elapsed:", x, y); if (MiningVars.miningStrategy.equalsIgnoreCase("banking")) { g.drawString("Ores mined: ", x, y + lineShift); g.drawString("Gems mined: ", x, y + (2 * lineShift)); g.drawString("Profit: ", x, y + (3 * lineShift)); } g.drawString("Exp: ", x, y + (4 * lineShift)); g.setFont(font4); g.drawString(Variables.miningTimer.getElapsedTimeString(), x + valueShift, y); double d; if (MiningVars.miningStrategy.equalsIgnoreCase("banking")) { g.drawString(String.format("%,d", MiningVars.oresMined), x + valueShift, y + (lineShift)); g.drawString( String.format("%,d", MiningVars.gemsMined), x + valueShift, y + (2 * lineShift)); if (profit >= 10000000) { g.setColor(new Color(0x00, 0x76, 0x33)); gold_s = String.format("%,.1fM gp", (profit / 1000000.0)); } else if (profit >= 100000) { g.setColor(new Color(0xff, 0xff, 0xff)); gold_s = String.format("%,.1fk gp", (profit / 1000.0)); } else if (profit >= 10000) { g.setColor(new Color(0xFF, 0x8B, 0x00)); gold_s = String.format("%,.1fk gp", (profit / 1000.0)); } else { g.setColor(new Color(0xff, 0xff, 0x00)); gold_s = String.format("%,d gp", profit); } g.drawString(gold_s, x + valueShift + 3, y + (3 * lineShift)); d = perHour(profit); if (d >= 10000000) { g.setColor(new Color(0x00, 0x76, 0x33)); goldPerHour_s = String.format("(%,.1fM gp/hr", d / 1000000.0); } else if (d >= 100000) { g.setColor(new Color(0xff, 0xff, 0xff)); goldPerHour_s = String.format("(%,.1fk gp/hr)", d / 1000.0); } else if (d >= 10000) { g.setColor(new Color(0xFF, 0x8B, 0x00)); goldPerHour_s = String.format("(%,.1fk gp/hr)", d / 1000.0); } else { g.setColor(new Color(0xff, 0xff, 0x00)); goldPerHour_s = String.format("(%,.2f gp/hr)", d); } g.drawString( goldPerHour_s, x + valueShift + (g.getFontMetrics().stringWidth(gold_s) + 3), y + (3 * lineShift)); } d = exp; if (d >= 10000000) { g.setColor(new Color(0x00, 0x76, 0x33)); exp_s = String.format("%,.1fM exp", d / 1000000.0); } else if (d >= 100000) { g.setColor(new Color(0xff, 0xff, 0xff)); exp_s = String.format("%,.1fk exp", d / 1000.0); } else if (d >= 10000) { g.setColor(new Color(0xFF, 0x8B, 0x00)); exp_s = String.format("%,.1fk exp", d / 1000.0); } else { g.setColor(new Color(0xff, 0xff, 0x00)); exp_s = String.format("%,.2f exp", d); } g.drawString(exp_s, x + valueShift + 3, y + (4 * lineShift)); d = perHour(exp); if (d >= 10000000) { g.setColor(new Color(0x00, 0x76, 0x33)); expPerHour_s = String.format("(%,.1fM exp/hr", d / 1000000.0); } else if (d >= 100000) { g.setColor(new Color(0xff, 0xff, 0xff)); expPerHour_s = String.format("(%,.1fk exp/hr)", d / 1000.0); } else if (d >= 10000) { g.setColor(new Color(0xFF, 0x8B, 0x00)); expPerHour_s = String.format("(%,.1fk exp/hr)", d / 1000.0); } else { g.setColor(new Color(0xff, 0xff, 0x00)); expPerHour_s = String.format("(%,.2f exp/hr)", d); } g.drawString( expPerHour_s, x + valueShift + (g.getFontMetrics().stringWidth(exp_s) + 3), y + (4 * lineShift)); x = 15; y = 500; d = ((double) (Skills.getExperience(Skills.MINING) - Variables.xpsToLevel[Skills.getLevel(Skills.MINING)]) / (double) (Variables.xpsToLevel[Skills.getLevel(Skills.MINING) + 1] - Variables.xpsToLevel[Skills.getLevel(Skills.MINING)])) * 100.0; String percent = String.format("%,.1f %%", d); percentBar( false, x, y, 485, 20, d, new Color(0xD3, 0xD3, 0xD3), new Color(0x70, 0x80, 0x90), new BasicStroke(1.0f, BasicStroke.CAP_SQUARE, BasicStroke.JOIN_MITER, 1.0f), g); g.setColor(Color.BLACK); g.drawString(String.format("%,d", Skills.getLevel(Skills.MINING)), x + 2, y + 17); x += printCenter(g, percent, x, y + 17, 485); printRight( g, Time.format(Functions.getTimeToNextLv(Skills.MINING, (int) perHour(exp))) + " to " + (Skills.getLevel(Skills.MINING) + 1), 500, y + 17); if (showDetails) { g.drawImage(lessDetailsButtonImg, lessDetailsButtonRect.x, lessDetailsButtonRect.y, null); int detailX = 20; int detailY = 55; // start at (20, 55) if (MiningVars.oresToMine.size() < 9) { detailY += 23; } for (int i = 0; i < MiningVars.oresToMine.size(); i++) { Ore o = MiningVars.oresToMine.get(i); g.drawImage(o.getImage(), detailX, detailY + (35 * i), null); printDetails(g, detailX + 35, detailY + 17 + (35 * i), o); } if (Players.getLocal().getAnimation() != 16385) { if (MiningVars.rockMining != null && MiningVars.rockMining.isOnScreen() && Calculations.distanceTo(MiningVars.rockMining) <= 23 && MiningVars.rockMining.validate()) { g.setColor(miningRockColor); MiningVars.rockMining.draw(g); } if (MiningVars.rockHover != null && MiningVars.rockHover.isOnScreen() && Calculations.distanceTo(MiningVars.rockHover) <= 23 && MiningVars.rockHover.validate()) { if (MiningVars.rockHover.getLocation().getBounds().length > 0) { g.setColor(hoverTileColor); g.fillPolygon(MiningVars.rockHover.getLocation().getBounds()[0]); } } } /* //TODO paint da walls?? SceneObject[] walls = SceneEntities.getLoaded(new Filter<SceneObject>() { @Override public boolean accept(SceneObject so) { return so != null && so.validate() && so.getDefinition() == null; } }); for (SceneObject w : walls) { w.draw(g); } */ } else { g.drawImage(showDetailButtonImg, showDetailButtonRect.x, showDetailButtonRect.y, null); } } else { g.drawImage(showButtonImg, showButtonRect.x, showButtonRect.y, null); } } // end if gui.isfinished }
@Override public void execute() { if (GlobalConstant.WIELDED_ID != -1 && Settings.get(300) == 1000 && Checks.getLP() < Skills.getRealLevel(Skills.CONSTITUTION) * 10 - 200) { if (Players.getLocal().getAppearance()[GlobalConstant.WEAPON] != GlobalConstant.EXCALIBUR && (Tabs.getCurrent().equals(Tabs.INVENTORY) || Tabs.INVENTORY.open())) { final Item excalibur = Inventory.getItem(GlobalConstant.EXCALIBUR); if (excalibur != null) { excalibur.getWidgetChild().click(true); PauseHandler.pause( new PauseHandler.Condition() { @Override public boolean validate() { return Players.getLocal().getAppearance()[GlobalConstant.WEAPON] == GlobalConstant.EXCALIBUR; } }, (long) Random.nextInt(750, 1500)); } } else if (Tabs.getCurrent().equals(Tabs.ATTACK) || Tabs.ATTACK.open()) { final WidgetChild bar = Widgets.get(884, 4); if (bar.validate()) { bar.click(true); PauseHandler.pause( new PauseHandler.Condition() { @Override public boolean validate() { return Settings.get(300) != 1000; } }, (long) Random.nextInt(400, 800)); } } return; } if (GlobalConstant.KEEP_ALIVE && Checks.getLP() < Skills.getRealLevel(Skills.CONSTITUTION) * 0.4f * 10) { if (Checks.isOutside()) { if (Players.getLocal().getAnimation() == -1) { final WidgetChild[] widgets = {Widgets.get(750, 2), Widgets.get(750, 6)}; if (widgets[0].validate() && widgets[1].validate()) { if (widgets[Random.nextInt(0, widgets.length)].interact("Rest")) PauseHandler.pause( new PauseHandler.Condition() { @Override public boolean validate() { return Players.getLocal().getAnimation() != -1; } }, (long) Random.nextInt(750, 1500)); } } Task.sleep(400, 800); } else { if (Calculations.distanceTo(GlobalConstant.TILE_BANK) > 5) { if (Traverse.walk(GlobalConstant.TILE_BANK)) { PauseHandler.pause( new PauseHandler.Condition() { @Override public boolean validate() { return Walking.getDestination() == null || Calculations.distanceTo(Walking.getDestination()) < 8; } }, (long) Random.nextInt(500, 1000)); } } } } else { if (Checks.isOutside()) { final SceneObject ladder = SceneEntities.getNearest(GlobalConstant.ROPE_DOWN_ID); if (ladder != null && ladder.interact("Climb")) PauseHandler.pause( new PauseHandler.Condition() { @Override public boolean validate() { return !Checks.isOutside(); } }, 750l); else if (ladder != null && Calculations.distanceTo(ladder) > 5) PauseHandler.walk(ladder, (long) Random.nextInt(250, 750)); } else if (inCombat() || Players.getLocal().isInCombat()) { final Tile rockTile = GlobalConstant.TILE_ROCKS[Checks.isGold()][Mine.getCurrent()]; if (true || Calculations.distanceTo(GlobalConstant.TILE_BANK) < Calculations.distanceTo(rockTile)) { if (Calculations.distanceTo(GlobalConstant.TILE_BANK) > 6 && Traverse.walk(GlobalConstant.TILE_BANK)) { PauseHandler.pause( new PauseHandler.Condition() { @Override public boolean validate() { return Walking.getDestination() == null || Calculations.distanceTo(Walking.getDestination()) < 8; } }, (long) Random.nextInt(200, 500)); } } else { final SceneObject rock = SceneEntities.getAt(rockTile); final NPC npc = NPCs.getNearest( new Filter<NPC>() { @Override public boolean accept(final NPC npc) { return npc.getInteracting() != null && npc.getInteracting().equals(Players.getLocal()) && Arrays.binarySearch(GlobalConstant.LRC_NPC, npc.getId()) >= 0; } }); if (rock != null && npc != null) { final Tile hardcodedSafe = GlobalConstant.MINE_GOLD && Mine.getCurrent() == 0 ? GlobalConstant.GOLD_SAFE_SPOT : !GlobalConstant.MINE_GOLD && Mine.getCurrent() == 2 ? GlobalConstant.COAL_SAFE_SPOT : null; if (hardcodedSafe != null) { hardcodedSafe .randomize(0, Mine.getCurrent() == 2 ? 4 : 1, 1, Mine.getCurrent() == 0 ? -4 : 1) .clickOnMap(); } else { final Tile[] bounds = rock.getArea().getBoundingTiles(); Arrays.sort( bounds, new Comparator<Tile>() { @Override public int compare(final Tile t1, final Tile t2) { return Calculations.distance(t1, npc.getLocation()) < Calculations.distance(t2, npc.getLocation()) ? 1 : -1; } }); final int[][] flags = Walking.getCollisionFlags(Game.getPlane()); final Tile colOffset = Walking.getCollisionOffset(Game.getPlane()) .derive(Game.getBaseX(), Game.getBaseY()); Tile toWalk = null; for (final int[] offset : new int[][] {{0, 1}, {1, 0}, {0, -1}, {-1, 0}}) { final Tile derive = bounds[0].derive(offset[0], offset[1]); if (Nodes.walkable(flags, colOffset, derive)) { if (toWalk == null || Calculations.distance(derive, npc) > Calculations.distance(toWalk, npc)) toWalk = derive; } } if (toWalk != null) { if (!toWalk.isOnScreen()) Camera.turnTo(toWalk); toWalk.interact("Walk here"); } } Task.sleep(100, 300); final int lp = Checks.getLP(); final Timer timer = new Timer((long) Random.nextInt(7500, 10000)); while (Players.getLocal().isInCombat() && Checks.getLP() >= lp && !Context.get().getScriptHandler().isPaused() && timer.isRunning()) Task.sleep(200, 800); } } } } }
@Override public void run() { if (Cons.PortalNum == 1) { if (Calculations.distanceTo(Cons.TO_EAST_PORTAL[3]) > 10) { Walking.findPath(Cons.TO_EAST_PORTAL[3]).traverse(); OpenDoors(); } if (Calculations.distanceTo(Cons.TO_EAST_PORTAL[3]) > 5) { Walking.newTilePath(Cons.TO_EAST_PORTAL).traverse(); OpenDoors(); } if (Calculations.distanceTo(Cons.TO_EAST_PORTAL[3]) < 5) { Cons.WalkOut = false; Cons.Attacking = true; } } if (Cons.PortalNum == 2) { if (Calculations.distanceTo(Cons.TO_SOUTH_EAST_PORTAL[3]) > 10) { Walking.findPath(Cons.TO_SOUTH_EAST_PORTAL[3]).traverse(); OpenDoors(); } if (Calculations.distanceTo(Cons.TO_SOUTH_EAST_PORTAL[3]) > 5) { Walking.newTilePath(Cons.TO_SOUTH_EAST_PORTAL).traverse(); OpenDoors(); } if (Calculations.distanceTo(Cons.TO_SOUTH_EAST_PORTAL[3]) < 5) { Cons.WalkOut = false; Cons.Attacking = true; } } if (Cons.PortalNum == 3) { if (Calculations.distanceTo(Cons.TO_SOUTH_WEST_PORTAL[3]) > 10) { Walking.findPath(Cons.TO_SOUTH_WEST_PORTAL[3]).traverse(); OpenDoors(); } if (Calculations.distanceTo(Cons.TO_SOUTH_WEST_PORTAL[3]) > 5) { Walking.newTilePath(Cons.TO_SOUTH_WEST_PORTAL).traverse(); OpenDoors(); } if (Calculations.distanceTo(Cons.TO_SOUTH_WEST_PORTAL[3]) < 5) { Cons.WalkOut = false; Cons.Attacking = true; } } if (Cons.PortalNum == 4) { if (Calculations.distanceTo(Cons.TO_WEST_PORTAL[2]) > 10) { Walking.findPath(Cons.TO_WEST_PORTAL[2]).traverse(); OpenDoors(); } if (Calculations.distanceTo(Cons.TO_WEST_PORTAL[2]) > 5) { Walking.newTilePath(Cons.TO_WEST_PORTAL).traverse(); OpenDoors(); } if (Calculations.distanceTo(Cons.TO_WEST_PORTAL[2]) < 5) { Cons.WalkOut = false; Cons.Attacking = true; } } }