Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.awt.Color;
- import java.awt.Point;
- import java.awt.Graphics;
- import java.awt.*;
- import java.awt.event.KeyEvent;
- import java.util.List;
- import java.util.Map;
- import org.rsbot.accessors.Model;
- import org.rsbot.accessors.RSAnimable;
- import org.rsbot.bot.Bot;
- import org.rsbot.event.events.ServerMessageEvent;
- import org.rsbot.event.listeners.PaintListener;
- import org.rsbot.event.listeners.ServerMessageListener;
- import org.rsbot.script.Calculations;
- import org.rsbot.script.Script;
- import org.rsbot.script.ScriptManifest;
- import org.rsbot.script.wrappers.RSNPC;
- import org.rsbot.script.wrappers.RSObject;
- import org.rsbot.script.wrappers.RSTile;
- // /code
- @ScriptManifest(authors = { "harnum" }, category = "Fishing", name = "HBarbBanker", version = 2.0,
- description =
- "<html>" +
- "<body>" +
- "<h2><center>HBarbBanker v2.1</center></h2>" +
- "<br>" +
- "<center>By harnum</center>" +
- "<p>" +
- "<br><center> Drop fish?</center>" +
- "<br><center><select name='dropping'><option>True<option>False</select></center>" +
- "</body>" +
- "</html>"
- )
- public class HBarbBanker extends Script implements PaintListener, ServerMessageListener{
- final ScriptManifest properties = getClass().getAnnotation(ScriptManifest.class);
- // Ints
- public int[] need = { 314, 309 }; // feathers and pole IDs
- public int mang = 328; // fishing spot id
- public int bankID = 26972;
- public int runEnergy = random(15, 40);
- public int amntcaught;
- public int xpg;
- public int startlevel, levelsgained;
- public boolean drop;
- // For paint
- public long startTime = System.currentTimeMillis();
- // Tiles n such
- RSTile bankTile = new RSTile(3093, 3489);
- RSTile fishTile = new RSTile(3104, 3431);
- RSTile[] toBank = {new RSTile(3104,3431),new RSTile(3099,3434),new RSTile(3094,3439),new RSTile
- (3091,3445),new RSTile(3090,3451),new RSTile(3090,3457),new RSTile(3087,3463),new RSTile(3093,3464),new
- RSTile(3098,3468),new RSTile(3099,3474),new RSTile(3099,3480),new RSTile(3093,3484),new RSTile
- (3090,3490),new RSTile(3094,3491)};
- RSTile[] toFish = reversePath(toBank);
- public void onFinish(){
- return;
- }
- public boolean onStart(Map<String, String> args){
- startlevel = skills.getCurrentSkillLevel(STAT_FISHING);
- if (args.get("dropping").equals("True")) {
- drop = true;
- log("Dropping fish.");
- } else {
- drop = false;
- log("Banking fish.");
- }
- return true;
- }
- public int loop() {
- if (!inventoryContains(need)) {
- log("No rod/feathers, logging out!");
- logout();
- stopScript();
- }
- if (!isRunning() && getEnergy() >= runEnergy) {
- runEnergy = random(15, 40);
- setRun(true);
- wait(random(300, 700));
- }
- switch (getState()) {
- case BANK:
- bank.depositAllExcept(need);
- break;
- case OPEN_BANK:
- RSObject banky = getNearestObjectByID(bankID);
- if (banky != null) {
- RSTile loc = banky.getLocation();
- if (distanceTo(loc) >= 4) {
- walkTileMM(loc);
- wait(random(1000,1500));
- }
- if (!tileOnScreen(banky.getLocation()))
- turnToTile(banky.getLocation());
- atBank(banky);
- }
- wait(random(1800,2000));
- break;
- case WALK_TO_BANK:
- walkPathMM2(toBank,13);
- return random(1000,2000);
- //break;
- case WALK_TO_FISHING_AREA:
- walkPathMM2(toFish,13);
- return random(1000,2000);
- //break;
- case FISH:
- RSNPC mayne = getNearestNPCByID(mang);
- if (mayne != null) {
- RSTile mloc = mayne.getLocation();
- if (distanceTo(mloc) >= 4) {
- walkTileMM(mloc);
- wait(random(2000,3000));
- }
- if (!tileOnScreen(mloc))
- turnToTile(mloc);
- clickNPC(mayne, "Lure");
- wait(random(2000,3000));
- }
- break;
- case WAIT:
- wait(random(1000, 2000));
- antiBan();
- break;
- case DROP:
- dropAllExcept(need);
- break;
- }
- return random(300, 400);
- }
- //PAINT:
- private final Color color1 = new Color(0, 0, 0, 222);
- private final Color color2 = new Color(0, 0, 0);
- private final Color color3 = new Color(255, 255, 255);
- private final Color color4 = new Color(0, 0, 0, 143);
- private final Color color5 = new Color(153, 153, 153);
- private final BasicStroke stroke1 = new BasicStroke(1);
- private final Font font1 = new Font("Traditional Arabic", 0, 30);
- private final Font font2 = new Font("Arial", 0, 15);
- private final Font font3 = new Font("Arial", 0, 16);
- private final Font font4 = new Font("Tunga", 1, 22);
- public void onRepaint(Graphics g1) {
- Graphics2D g = (Graphics2D)g1;
- long millis = System.currentTimeMillis() - startTime;
- long hours = millis / (1000 * 60 * 60);
- millis -= hours * (1000 * 60 * 60);
- long minutes = millis / (1000 * 60);
- millis -= minutes * (1000 * 60);
- long seconds = millis / 1000;
- levelsgained = skills.getCurrentSkillLevel(STAT_FISHING) - startlevel;
- float xpsec = 0;
- if ((minutes > 0 || hours > 0 || seconds > 0) && xpg > 0) {
- }
- g.setColor(color1);
- g.fillRect(6, 345, 504, 112);
- g.setColor(color2);
- g.setStroke(stroke1);
- g.drawRect(6, 345, 504, 112);
- g.setColor(color3);
- g.fillRect(7, 457, 96, 16);
- g.setColor(color2);
- g.drawRect(7, 457, 96, 16);
- g.setColor(color4);
- g.fillRoundRect(546, 411, 192, 55, 16, 16);
- g.setFont(font1);
- g.setColor(color3);
- g.drawString("H barb fisher", 9, 373);
- g.setFont(font2);
- g.setColor(color2);
- g.drawString("*********", 26, 474);
- g.setFont(font3);
- g.setColor(color5);
- g.drawString("visit: rune-site.webs.com", 556, 454);
- g.setFont(font4);
- g.drawString("made by harnum", 564, 436);
- g.drawString("Time running: " + hours + ":" + minutes + ":" + seconds + "." , 14, 398);
- g.drawString("Caught: " + amntcaught + ".", 14, 416);
- g.drawString("Exp gained: " + xpg + ".", 14, 438);
- g.drawString("Lvls gained: " + levelsgained + ".", 260, 416);
- }
- public void serverMessageRecieved(ServerMessageEvent e) {
- String message = e.getMessage();
- if (message.contains("You catch"))
- amntcaught++;
- if (message.contains("trout"))
- xpg += 50;
- if (message.contains("salmon"))
- xpg += 70;
- }
- private enum State {
- BANK, FISH, WALK_TO_FISHING_AREA, WALK_TO_BANK, OPEN_BANK, WAIT, DROP
- }
- private State getState() {
- if (isInventoryFull() && drop == true) {
- return State.DROP;
- }
- if (isInventoryFull()) {
- if (bank.isOpen()) {
- return State.BANK;
- } else if (distanceTo(bankTile) <= 8 && !getMyPlayer().isMoving()) {
- return State.OPEN_BANK;
- } else {
- return State.WALK_TO_BANK;
- }
- } else {
- if (checkSpot()) {
- return State.WAIT;
- } else if (distanceTo(fishTile) <= 8) {
- return State.FISH;
- } else {
- return State.WALK_TO_FISHING_AREA;
- }
- }
- }
- private void antiBan() {
- if (random(0, 15) == 0) {
- final char[] LR = new char[] { KeyEvent.VK_LEFT,
- KeyEvent.VK_RIGHT };
- final char[] UD = new char[] { KeyEvent.VK_DOWN,
- KeyEvent.VK_UP };
- final char[] LRUD = new char[] { KeyEvent.VK_LEFT,
- KeyEvent.VK_RIGHT, KeyEvent.VK_UP,
- KeyEvent.VK_UP };
- final int random2 = random(0, 2);
- final int random1 = random(0, 2);
- final int random4 = random(0, 4);
- if (random(0, 3) == 0) {
- Bot.getInputManager().pressKey(LR[random1]);
- wait(random(100, 400));
- Bot.getInputManager().pressKey(UD[random2]);
- wait(random(300, 600));
- Bot.getInputManager().releaseKey(UD[random2]);
- wait(random(100, 400));
- Bot.getInputManager().releaseKey(LR[random1]);
- } else {
- Bot.getInputManager().pressKey(LRUD[random4]);
- if (random4 > 1) {
- wait(random(300, 600));
- } else {
- wait(random(500, 900));
- }
- Bot.getInputManager().releaseKey(LRUD[random4]);
- }
- if(random(0, 1) == 0)
- {
- int x = random(0, 750);
- int y = random(0, 500);
- moveMouse(x, y);
- }
- } else {
- wait(random(200, 2000));
- }
- }
- private boolean clickNPC(final RSNPC npc, final String action) {
- // THANKS TO RUSKI
- try {
- int a;
- final StringBuffer npcCommandBuf = new StringBuffer();
- npcCommandBuf.append(action);
- npcCommandBuf.append(" ");
- npcCommandBuf.append(npc.getName());
- final String npcCommand = npcCommandBuf.toString();
- for (a = 10; a-- >= 0;) {
- final List<String> menuItems = getMenuItems();
- if (menuItems.size() > 1) {
- if (listContainsString(menuItems, npcCommand)) {
- if (menuItems.get(0).contains(npcCommand)) {
- clickMouse(true);
- return true;
- } else {
- // clickMouse(false);
- wait(random(50, 200));
- return atMenu(npcCommand);
- }
- }
- }
- final Point screenLoc = npc.getScreenLocation();
- if (!pointOnScreen(screenLoc)) {
- return false;
- }
- final Point randomP = new Point(random(screenLoc.x - 10,
- screenLoc.x + 10), random(screenLoc.y - 10,
- screenLoc.y + 10));
- if (randomP.x >= 0 && randomP.y >= 0) {
- moveMouse(randomP);
- }
- }
- return false;
- } catch (final Exception e) {
- return false;
- }
- }
- private boolean listContainsString(final List<String> list,
- final String string) {
- // THANKS TO RUSKI
- try {
- int a;
- for (a = list.size() - 1; a-- >= 0;) {
- if (list.get(a).contains(string)) {
- return true;
- }
- }
- } catch (final Exception e) {
- }
- return false;
- }
- public boolean atBank(RSObject bank) {
- if (!(bank.getObject() instanceof RSAnimable)) {
- return atTree(bank, "uickly");
- }
- RSAnimable anim = (RSAnimable) bank.getObject();
- Model model = bank.getModel();
- int index = random(0, model.getXPoints().length);
- int xoff = model.getXPoints()[index];
- int yoff = model.getZPoints()[index];
- int zoff = model.getYPoints()[index];
- Point p = Calculations.worldToScreen(anim.getX() + xoff, anim.getY() + zoff, -yoff);
- if (p.x == -1)
- return false;
- moveMouse(p, 3, 3);
- return atMenu("uickly");
- }
- public boolean checkSpot() {
- RSNPC check = (RSNPC) getMyPlayer().getInteracting();
- if (check != null
- && getMyPlayer().getAnimation() != -1)
- return true;
- return false;
- }
- public boolean walkPathMM2(final RSTile[] path, final int maxDist) {
- try {
- final RSTile next = nextTile(path, maxDist);
- if (next != null) {
- walkTileMM2(next);
- current = next;
- wait(random(1000,2000));
- return false;
- } else if (next != null && next.equals(current)) {
- return false;
- }
- } catch (final Exception e) {
- return false;
- }
- return true;
- }
- public boolean walkTileMM2(final RSTile t)
- {
- final Point p = tileToMinimap(t);
- if (p.x == -1 || p.y == -1) {
- return false;
- }
- clickMouse(p, 0, 0, true);
- return true;
- }
- private static RSTile current = new RSTile(0, 0);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement