sopuli
Viestien lukumäärä : 4 Join date : 29.03.2011 Ikä : 29 Paikkakunta : lahti
| Aihe: UnReleased NGHunter v2 Ti Maalis 29, 2011 10:37 pm | |
| kakkos versio RSBotin default hunting botista~ (En ole siis itse kirjoittanut) +Näkyy Paljon $saatu XPsaatu H/Skauan ollu päällä etc.. +Bug fixes +Hiiri näkyy Edit: Pic Ei saanu statseja koska oli membut loppunu just seuraavana päivänä ku oli bot jättäny yöks )= CREDITS TO RAKURACode - Koodi:
-
import java.awt.Color; import java.awt.Font; import java.awt.Graphics; import java.awt.Point; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.List; import javax.swing.JOptionPane; import org.rsbot.event.events.MessageEvent; import org.rsbot.event.listeners.MessageListener; import org.rsbot.event.listeners.PaintListener; import org.rsbot.script.Script; import org.rsbot.script.ScriptManifest; import org.rsbot.script.methods.Game; import org.rsbot.script.methods.Objects; import org.rsbot.script.methods.Skills; import org.rsbot.script.util.Timer; import org.rsbot.script.wrappers.RSComponent; import org.rsbot.script.wrappers.RSObject; import org.rsbot.script.wrappers.RSGroundItem; import org.rsbot.script.wrappers.RSItem; import org.rsbot.script.wrappers.RSTile; @ScriptManifest(name = "NGHunter", authors = "Rakura", keywords = "Hunter", version = 1.11, description = "crim swifts, trop wags, <grey,red> chins") public class NGHunter extends Script implements PaintListener, MessageListener { private static enum TileType { FALLEN(new Color(255, 0, 0, 100)), // prevent formatting CAUGHT(new Color(0, 255, 0, 100)), // EMPTY(new Color(255, 255, 255, 100)), // FAILED(new Color(0, 0, 0, 100)), // UP(new Color(0, 0, 255, 100));// final Color highlightColor; TileType(Color highlightColor) { this.highlightColor = highlightColor; } } private class HunterTile extends RSTile implements Comparable<HunterTile> { boolean isOurTrap; TileType type; Object associated; HunterTile(int x, int y) { super(x, y); } @Override public int compareTo(HunterTile other) { int typeComparison = type.ordinal() - other.type.ordinal(); if (typeComparison != 0) return typeComparison; else return calc.distanceTo(this) - calc.distanceTo(other); } } private static class Constants { static final int BOX = 10008; static final int BOX_WAIT = 19187; static final int BOX_FAILED = 19192; static final int BOX_RED_CAUGHT = 19190; static final int BOX_GREY_CAUGHT = 19189; static final int SNARE = 10006; static final int SNARE_WAIT = 19175; static final int SNARE_FAILED = 19174; static final int TROPICAL_WAGTAIL_CAUGHT = 19178; static final int CRIMSON_SWIFT_CAUGHT = 19180; static final int BIRD_MEAT = 9978; static final int BONES = 526; final int level; final int trap; final int wait; final int failed; final int caught; static final int RED_CHIN = 10034; static final int GREY_CHIN = 10033; static final int STRIPY_FEATHER = 10087; static final int RED_FEATHER = 10088; final int objectOfValue; final boolean bury; public Constants(int level) { this.level = level; if (level >= 53) {// we're goin boxtrappin trap = BOX; wait = BOX_WAIT; failed = BOX_FAILED; if (level >= 63) { caught = BOX_RED_CAUGHT; objectOfValue = RED_CHIN; } else { caught = BOX_GREY_CAUGHT; objectOfValue = GREY_CHIN; } bury = false;// undef } else {// we're goin snarin trap = SNARE; wait = SNARE_WAIT; failed = SNARE_FAILED; if (level >= 19) { caught = TROPICAL_WAGTAIL_CAUGHT; objectOfValue = STRIPY_FEATHER; } else { caught = CRIMSON_SWIFT_CAUGHT; objectOfValue = RED_FEATHER; } int selection = JOptionPane.showConfirmDialog(null, "Bury bones?", "NGHunter", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE); bury = selection == JOptionPane.YES_OPTION; } } } private Constants consts; private HunterTile originalTile; private int nTraps; private final ArrayList<HunterTile> myTiles = new ArrayList<HunterTile>(); private int phailCount; private HunterTile currentTile; @Override public boolean onStart() { setPaused(true);// block paint if (!walking.isRunEnabled()) walking.setRun(true); int startLevel = skills.getCurrentLevel(Skills.HUNTER); consts = new Constants(startLevel); RSTile origTile = getMyPlayer().getLocation(); originalTile = new HunterTile(origTile.getX(), origTile.getY()); if (startLevel < 20) { nTraps = 1; myTiles.add(originalTile); } else if (startLevel < 40) { nTraps = 2; // quad 1 myTiles.add(new HunterTile(originalTile.getX() + 1, originalTile .getY() + 1)); // quad 2 myTiles.add(new HunterTile(originalTile.getX() - 1, originalTile .getY() + 1)); } else if (startLevel < 60) { nTraps = 3; // origin myTiles.add(originalTile); // quad 1 myTiles.add(new HunterTile(originalTile.getX() + 1, originalTile .getY() + 1)); // quad 2 myTiles.add(new HunterTile(originalTile.getX() - 1, originalTile .getY() + 1)); } else if (startLevel < 80) { nTraps = 4; // quad 1 myTiles.add(new HunterTile(originalTile.getX() + 1, originalTile .getY() + 1)); // quad 2 myTiles.add(new HunterTile(originalTile.getX() - 1, originalTile .getY() + 1)); // quad 3 myTiles.add(new HunterTile(originalTile.getX() - 1, originalTile .getY() - 1)); // quad 4 myTiles.add(new HunterTile(originalTile.getX() + 1, originalTile .getY() - 1)); } else { // startLevel >= 80 nTraps = 5; // origin myTiles.add(originalTile); // quad 1 myTiles.add(new HunterTile(originalTile.getX() + 1, originalTile .getY() + 1)); //quad 2 myTiles.add(new HunterTile(originalTile.getX() - 1, originalTile .getY() + 1)); // quad 3 myTiles.add(new HunterTile(originalTile.getX() - 1, originalTile .getY() - 1)); // quad 4 myTiles.add(new HunterTile(originalTile.getX() + 1, originalTile .getY() - 1)); } // paint variables startTime = System.currentTimeMillis(); startExp = skills.getCurrentExp(Skills.HUNTER); price = grandExchange.lookup(consts.objectOfValue).getGuidePrice(); setPaused(false);// resume paint return true; } private boolean needCleaning() { return inventory.getCount() >= 26; } private void cleanInventory() { RSItem[] meatNBones = inventory.getItems(Constants.BIRD_MEAT, Constants.BONES); List<RSItem> items = new ArrayList<RSItem>(Arrays.asList(meatNBones)); Collections.shuffle(items); for (RSItem item : items) { if (item.getID() == Constants.BIRD_MEAT) { item.doAction("Drop"); } else if (item.getID() == Constants.BONES) { if (consts.bury) { item.doClick(true); } else { item.doAction("Drop"); } } } } @Override public int loop() { if (consts.level < 53) { if (!needAction() || needCleaning()) cleanInventory(); } return loop0(); } private boolean needAction() { for (HunterTile tile : myTiles) { if (tile.type != TileType.UP) return true; } return false; } private int loop0() { mouse.setSpeed(random(7, 9)); verifyTiles(); if (myTiles.size() == 0) { throw new RuntimeException("Unexpected badness!"); } updateTiles(); if (needAction()) { currentTile = nextTile(null); if (currentTile != null) { if (act(currentTile)) { phailCount = 0; } else { phailCount++; } } if (phailCount > 25) { log("Ban prevention mechanism kicking in..."); return -1; } } return 0; } private void verifyTiles() { HunterTile[] tiles = myTiles.toArray(new HunterTile[myTiles.size()]); for (int i = 0; i < tiles.length; i++) { HunterTile tile = tiles[i]; if (!tile.isOurTrap && !isFree(tile)) { HunterTile optimalTile = getOptimalTile(4); if (optimalTile != null) { myTiles.set(i, optimalTile); } else { myTiles.remove(i); nTraps--; } } } } private void updateTiles() { outer: for (HunterTile tile : myTiles) { for (RSGroundItem gritem : groundItems.getAllAt(tile)) { if (gritem.getItem().getID() == consts.trap) { tile.type = TileType.FALLEN; tile.associated = gritem; continue outer; } } for (RSObject obj : objects.getAt(tile, Objects.TYPE_INTERACTABLE)) { int id = obj.getID(); if (id == consts.caught) { tile.type = TileType.CAUGHT; tile.associated = obj; continue outer; } else if (id == consts.failed) { tile.type = TileType.FAILED; tile.associated = obj; continue outer; } else if (id == consts.wait) { tile.type = TileType.UP; tile.associated = obj; continue outer; } } if (isFree(tile)) { tile.type = TileType.EMPTY; continue outer; } } } private HunterTile nextTile(HunterTile exclude) { Collections.sort(myTiles); for (HunterTile tile : myTiles) { if (tile == exclude) continue; if (tile.type == TileType.FALLEN && !isFree(tile)) continue; if (tile.type == TileType.UP) return null; return tile; } return null; } private boolean act(HunterTile currentTile) { switch (currentTile.type) { case FALLEN: return reset(currentTile); case CAUGHT: case FAILED: return collect(currentTile); case EMPTY: if (inventory.containsOneOf(consts.trap)) { return setup(currentTile); } else { myTiles.remove(currentTile); nTraps--; return true; } default: throw new InternalError(); } } private HunterTile getOptimalTile(int maxOutwards) { int minX = originalTile.getX() - maxOutwards; int maxX = originalTile.getX() + maxOutwards; int minY = originalTile.getY() - maxOutwards; int maxY = originalTile.getY() + maxOutwards; List<HunterTile> available = new ArrayList<HunterTile>(); for (int x = minX; x <= maxX; x++) { for (int y = minY; y <= maxY; y++) { HunterTile t = new HunterTile(x, y); if (isFree(t)) available.add(t); } } return getNearest(originalTile, available); } private boolean isFree(HunterTile tile) { RSObject[] objs = objects.getAt(tile, Objects.TYPE_INTERACTABLE | Objects.TYPE_BOUNDARY); return objs.length == 0; } private HunterTile getNearest(HunterTile locus, List<HunterTile> tiles) { HunterTile nearest = null; double min = Double.MAX_VALUE; for (HunterTile tile : tiles) { double dist = calc.distanceBetween(locus, tile); if (dist < min) { nearest = tile; min = dist; } } return nearest; } private boolean setup(HunterTile tile) { if (!onTile(tile)) { boolean there = walk(tile); if (!there) return false; } if (clickInventoryItem(consts.trap)) return trapUp(tile); return false; } private boolean reset(HunterTile tile) { RSGroundItem trap = (RSGroundItem) tile.associated; if (trap.doAction("Lay")) { return trapUp(tile); } return false; } private boolean trapUp(HunterTile tile) { if (waitForAnim(3000)) { HunterTile nextTile = nextTile(tile); if (nextTile != null) hoverTile(nextTile); while (!getMyPlayer().isIdle()) { sleep(100); } // player shifts if (nextTile != null) hoverTile(nextTile); if (trapIsHere(tile)) { tile.isOurTrap = true; tile.type = TileType.UP; return true; } } return false; } private boolean collect(final HunterTile tile) { RSObject trap = (RSObject) tile.associated; trap.doClick(); if (waitForAnim(3000)) { while (trapIsHere(tile)) { if (getMyPlayer().isIdle()) break; sleep(100); } if (!trapIsHere(tile)) { tile.isOurTrap = false; tile.type = TileType.EMPTY; return true; } } return false; } private void hoverTile(RSTile tile) { if (!tile.equals(tiles.getTileUnderMouse())) { Point location = calc.tileToScreen(tile); mouse.move(location, 5, 5); } } private void atTile(RSTile tile) { hoverTile(tile); mouse.click(true); } private boolean trapIsHere(RSTile tile) { for (RSObject obj : objects.getAt(tile, Objects.TYPE_INTERACTABLE)) { int id = obj.getID(); if (id == consts.wait || id == consts.caught || id == consts.failed) { return true; } } return false; } private boolean walk(RSTile tile) { atTile(tile); waitForMove(3000); while (!onTile(tile)) { if (getMyPlayer().isIdle()) break; moveToInventoryItem(consts.trap); sleep(100); } return onTile(tile); } private boolean onTile(RSTile tile) { return getMyPlayer().getLocation().equals(tile) && getMyPlayer().isIdle(); } private boolean clickInventoryItem(int itemID) { if (moveToInventoryItem(itemID)) { mouse.click(true); return true; } return false; } private boolean moveToInventoryItem(int itemID) { if (game.getCurrentTab() != Game.TAB_INVENTORY) game.openTab(Game.TAB_INVENTORY); RSItem item = inventory.getItem(itemID); if (item == null)// not possible but somehow... return false; RSComponent wrappedComp = item.getComponent(); if (wrappedComp == null) return false; wrappedComp.doHover(); return true; } private boolean waitForAnim(int maxMillis) { long start = System.currentTimeMillis(); while (System.currentTimeMillis() - start < maxMillis) { if (getMyPlayer().getAnimation() != -1) return true; sleep(100); } return false; } private boolean waitForMove(int maxMillis) { long start = System.currentTimeMillis(); while (System.currentTimeMillis() - start < maxMillis) { if (getMyPlayer().isMoving()) return true; sleep(100); } return false; } private int caught; private long startTime; private int startExp; private int price; private static final Font FONT = new Font(Font.SANS_SERIF, Font.BOLD, 12); private static final int HEIGHT = 135; private static final int WIDTH = 120; private static final Point ORIGIN = new Point(6, 344 - HEIGHT); private static final Color COLOR = new Color(0, 0, 0, 100); private static final int X_BORDER_OFF = 7; private static final int SPACING = 5; private static final int PROGBAR_WIDTH = WIDTH - 2 * X_BORDER_OFF; @Override public void onRepaint(Graphics g) { for (HunterTile myTile : myTiles) { highlight(g, myTile, myTile.type.highlightColor); } g.setClip(ORIGIN.x, ORIGIN.y, WIDTH, HEIGHT); g.setColor(COLOR); g.fillRect(ORIGIN.x, ORIGIN.y, WIDTH, HEIGHT); g.setColor(Color.WHITE); g.setFont(FONT); int fontHeight = g.getFontMetrics().getHeight(); int dy = SPACING + fontHeight; int x = ORIGIN.x + X_BORDER_OFF; int y = ORIGIN.y + dy; String time = Timer.format(System.currentTimeMillis() - startTime); g.drawString("Elapsed: " + time, x, y); y += dy; g.drawString("Caught: " + caught, x, y); y += dy; int exp = skills.getCurrentExp(Skills.HUNTER) - startExp; g.drawString("Exp Gained: " + exp, x, y); y += dy; int moneyz = caught * price; g.drawString("$$$: " + moneyz, x, y); y += dy; int level = skills.getCurrentLevel(Skills.HUNTER); String levelString = Integer.toString(skills .getCurrentLevel(Skills.HUNTER)); int levelStringOccupation = (int) g.getFontMetrics() .getStringBounds(levelString, g).getMaxX(); g.drawString(levelString, x, y); g.drawString(Integer.toString(level + 1), ORIGIN.x + WIDTH - X_BORDER_OFF - levelStringOccupation, y); y += dy; y -= fontHeight; int progHeight = g.getFontMetrics().getAscent(); g.fill3DRect(x, y, PROGBAR_WIDTH, progHeight, false); int precent = skills.getPercentToNextLevel(Skills.HUNTER); g.fill3DRect(x, y, (int) (PROGBAR_WIDTH * (precent / 100.0)), progHeight, true); } // @author Jacmob private void highlight(Graphics g, RSTile t, Color fill) { Point pn = calc.tileToScreen(t, 0, 0, 0); Point px = calc.tileToScreen(t, 1, 0, 0); Point py = calc.tileToScreen(t, 0, 1, 0); Point pxy = calc.tileToScreen(t, 1, 1, 0); if (py.x != -1 && pxy.x != -1 && px.x != -1 && pn.x != -1) { g.setColor(fill); g.fillPolygon(new int[] { py.x, pxy.x, px.x, pn.x }, new int[] { py.y, pxy.y, px.y, pn.y }, 4); } } @Override public void messageReceived(MessageEvent arg0) { String message = arg0.getMessage(); if (message.contains("caught")) { caught++; } } } Tallentaminen Nimellä NGHunter.java Tätä versiota ei siis ole vielä pistetty ilmoille | |
|