Jump to content
Frequently Asked Questions
  • Are you not able to open the client? Try following our getting started guide
  • Still not working? Try downloading and running JarFix
  • Help! My bot doesn't do anything! Enable fresh start in client settings and restart the client
  • How to purchase with PayPal/OSRS/Crypto gold? You can purchase vouchers from other users
  • TheHero

    Members
    • Posts

      6
    • Joined

    • Last visited

    • Days Won

      1

    TheHero last won the day on July 4 2023

    TheHero had the most liked content!

    Profile Information

    • Gender
      Male

    Contact Methods

    • Discord
      Hero#0130

    Recent Profile Visitors

    The recent visitors block is disabled and is not being shown to other users.

    TheHero's Achievements

    1. Fixes for new MouseAlgorithm class for version 3.19.0: WindMouse.java: package hero.farm.misc; /** * WindMouse from SMART by Benland100 * Copyright to Benland100, (Benjamin J. Land) * Originally modified for use with DreamBot 3 by holic * Mouse dragging issues fixed by Hero with help from Pandemic * <p> * Prepped for DreamBot 3 **/ import org.dreambot.api.input.Mouse; import org.dreambot.api.input.event.impl.mouse.MouseButton; import org.dreambot.api.input.mouse.algorithm.MouseAlgorithm; import org.dreambot.api.input.mouse.destination.AbstractMouseDestination; import org.dreambot.api.methods.Calculations; import org.dreambot.api.methods.ViewportTools; import org.dreambot.api.methods.input.mouse.MouseSettings; import org.dreambot.api.utilities.Logger; import org.dreambot.core.Instance; import java.awt.*; import java.awt.event.MouseEvent; public class WindMouse implements MouseAlgorithm { // https://dreambot.org/forums/index.php?/topic/21147-windmouse-custom-mouse-movement-algorithm/ private int _mouseSpeed = MouseSettings.getSpeed() > 15 ? MouseSettings.getSpeed() - 10 : 15; private final int _mouseSpeedLow = Math.round(_mouseSpeed / 2); private int _mouseGravity = Calculations.random(4, 20); private int _mouseWind = Calculations.random(1, 10); @Override public boolean handleMovement(AbstractMouseDestination abstractMouseDestination) { //Get a suitable point for the mouse's destination Point suitPos = abstractMouseDestination.getSuitablePoint(); // Select which implementation of WindMouse you'd like to use // by uncommenting out the line you want to use below: //windMouse(suitPos.x, suitPos.y); //Original implementation windMouse2(suitPos); //Tweaked implementation return distance(Mouse.getPosition(), suitPos) < 2; } @Override public boolean handleClick(MouseButton mouseButton) { return Mouse.getDefaultMouseAlgorithm().handleClick(mouseButton); } public static void sleep(int min, int max) { try { Thread.sleep(Calculations.random(min, max)); } catch (InterruptedException e) { Logger.log(e.getMessage()); } } public static void sleep(int ms) { try { Thread.sleep(ms); } catch (InterruptedException e) { Logger.log(e.getMessage()); } } /** * Tweaked implementation of WindMouse * Moves to a mid point on longer moves to seem a little more human-like * Remove the if statement below if you'd rather straighter movement * * @param point The destination point */ public void windMouse2(Point point) { Point curPos = Mouse.getPosition(); if (distance(point, curPos) > 250 && Calculations.random(1) == 2) { Point rp = randomPoint(point, curPos); windMouse2(curPos.x, curPos.y, rp.x, rp.y, _mouseGravity, _mouseWind, _mouseSpeed, Calculations.random(5, 25)); sleep(1, 150); } windMouse2(curPos.x, curPos.y, point.x, point.y, _mouseGravity, _mouseWind, _mouseSpeed, Calculations.random(5, 25)); _mouseGravity = Calculations.random(4, 20); _mouseWind = Calculations.random(1, 10); _mouseSpeed = Calculations.random(_mouseSpeedLow, MouseSettings.getSpeed()); } /** * Tweaked implementation of WindMouse by holic * All credit to Benjamin J. Land for the original. (see below) * * @param xs The x start * @param ys The y start * @param xe The x destination * @param ye The y destination * @param gravity Strength pulling the position towards the destination * @param wind Strength pulling the position in random directions * @param targetArea Radius of area around the destination that should * trigger slowing, prevents spiraling */ private void windMouse2(double xs, double ys, double xe, double ye, double gravity, double wind, double speed, double targetArea) { double dist, veloX = 0, veloY = 0, windX = 0, windY = 0; double sqrt2 = Math.sqrt(2); double sqrt3 = Math.sqrt(3); double sqrt5 = Math.sqrt(5); int tDist = (int) distance(xs, ys, xe, ye); long t = System.currentTimeMillis() + 10000; while (!(Math.hypot((xs - xe), (ys - ye)) < 1)) { if (System.currentTimeMillis() > t) break; dist = Math.hypot((xs - xe), (ys - ye)); wind = Math.min(wind, dist); if ((dist < 1)) { dist = 1; } long d = (Math.round((Math.round(((double) (tDist))) * 0.3)) / 7); if ((d > 25)) { d = 25; } if ((d < 5)) { d = 5; } double rCnc = Calculations.random(6); if ((rCnc == 1)) { d = 2; } double maxStep = (Math.min(d, Math.round(dist))) * 1.5; if ((dist >= targetArea)) { windX = (windX / sqrt3) + ((Calculations.random((int) ((Math.round(wind) * 2) + 1)) - wind) / sqrt5); windY = (windY / sqrt3) + ((Calculations.random((int) ((Math.round(wind) * 2) + 1)) - wind) / sqrt5); } else { windX = (windX / sqrt2); windY = (windY / sqrt2); } veloX += windX + gravity * (xe - xs) / dist; veloY += windY + gravity * (ye - ys) / dist; if ((Math.hypot(veloX, veloY) > maxStep)) { maxStep = ((maxStep / 2) < 1) ? 2 : maxStep; double randomDist = (maxStep / 2) + Calculations.random((int) (Math.round(maxStep) / 2)); double veloMag = Math.sqrt(((veloX * veloX) + (veloY * veloY))); veloX = (veloX / veloMag) * randomDist; veloY = (veloY / veloMag) * randomDist; } int lastX = ((int) (Math.round(xs))); int lastY = ((int) (Math.round(ys))); xs += veloX; ys += veloY; if ((lastX != Math.round(xs)) || (lastY != Math.round(ys))) { setMousePosition(new Point((int) Math.round(xs), (int) Math.round(ys))); } int w = Calculations.random((int) (Math.round(100 / speed))) * 6; if ((w < 5)) { w = 5; } w = (int) Math.round(w * 0.9); sleep(w); } if (((Math.round(xe) != Math.round(xs)) || (Math.round(ye) != Math.round(ys)))) { setMousePosition(new Point((int) Math.round(xs), (int) Math.round(ys))); } } /** * Internal mouse movement algorithm from SMART. Do not use this without credit to either * Benjamin J. Land or BenLand100. This was originally synchronized to prevent multiple * motions and bannage but functions poorly with DB3. * <p> * BEST USED IN FIXED MODE * * @param xs The x start * @param ys The y start * @param xe The x destination * @param ye The y destination * @param gravity Strength pulling the position towards the destination * @param wind Strength pulling the position in random directions * @param minWait Minimum relative time per step * @param maxWait Maximum relative time per step * @param maxStep Maximum size of a step, prevents out of control motion * @param targetArea Radius of area around the destination that should * trigger slowing, prevents spiraling * @result The actual end point */ private Point windMouseImpl(double xs, double ys, double xe, double ye, double gravity, double wind, double minWait, double maxWait, double maxStep, double targetArea) { final double sqrt3 = Math.sqrt(3); final double sqrt5 = Math.sqrt(5); double dist, veloX = 0, veloY = 0, windX = 0, windY = 0; while ((dist = Math.hypot(xs - xe, ys - ye)) >= 1) { wind = Math.min(wind, dist); if (dist >= targetArea) { windX = windX / sqrt3 + (2D * Math.random() - 1D) * wind / sqrt5; windY = windY / sqrt3 + (2D * Math.random() - 1D) * wind / sqrt5; } else { windX /= sqrt3; windY /= sqrt3; if (maxStep < 3) { maxStep = Math.random() * 3D + 3D; } else { maxStep /= sqrt5; } } veloX += windX + gravity * (xe - xs) / dist; veloY += windY + gravity * (ye - ys) / dist; double veloMag = Math.hypot(veloX, veloY); if (veloMag > maxStep) { double randomDist = maxStep / 2D + Math.random() * maxStep / 2D; veloX = (veloX / veloMag) * randomDist; veloY = (veloY / veloMag) * randomDist; } int lastX = ((int) (Math.round(xs))); int lastY = ((int) (Math.round(ys))); xs += veloX; ys += veloY; if ((lastX != Math.round(xs)) || (lastY != Math.round(ys))) { setMousePosition(new Point((int) Math.round(xs), (int) Math.round(ys))); } double step = Math.hypot(xs - lastX, ys - lastY); sleep((int) Math.round((maxWait - minWait) * (step / maxStep) + minWait)); } return new Point((int) xs, (int) ys); } /** * Moves the mouse from the current position to the specified position. * Approximates human movement in a way where smoothness and accuracy are * relative to speed, as it should be. * * @param x The x destination * @param y The y destination * @result The actual end point */ public Point windMouse(int x, int y) { Point c = Mouse.getPosition(); double speed = (Math.random() * 15D + 15D) / 10D; return windMouseImpl(c.x, c.y, x, y, 9D, 3D, 5D / speed, 10D / speed, 10D * speed, 8D * speed); } private void setMousePosition(Point endPoint) { if (Mouse.getMouseSettings().isDrag()) { // pan told me to do this for dragging. more info in the DreamBot EDU server: https://discord.com/channels/426346091173380096/462764560772759563/1125126497343123566 Instance.dispatchCanvasEvent(new MouseEvent(Instance.getCanvas(), MouseEvent.MOUSE_DRAGGED, System.currentTimeMillis(), 0, endPoint.x, endPoint.y, ViewportTools.getAbsoluteXCoordinate() + endPoint.x, ViewportTools.getAbsoluteYCoordinate() + endPoint.y, 0, false, MouseEvent.BUTTON2)); } else { Mouse.hop(endPoint); } } private static double distance(double x1, double y1, double x2, double y2) { return Math.sqrt((Math.pow((Math.round(x2) - Math.round(x1)), 2) + Math.pow((Math.round(y2) - Math.round(y1)), 2))); } public double distance(Point p1, Point p2) { return Math.sqrt((p2.y - p1.y) * (p2.y - p1.y) + (p2.x - p1.x) * (p2.x - p1.x)); } public static float randomPointBetween(float corner1, float corner2) { if (corner1 == corner2) { return corner1; } float delta = corner2 - corner1; float offset = Calculations.getRandom().nextFloat() * delta; return corner1 + offset; } public Point randomPoint(Point p1, Point p2) { int randomX = (int) randomPointBetween(p1.x, p2.x); int randomY = (int) randomPointBetween(p1.y, p2.y); return new Point(randomX, randomY); } } In onStart: Mouse.setMouseAlgorithm(new WindMouse());
    2. This likely is due to the currently on going osrs maintenance. The servers are down and dreambot likely cant get something it needs from osrs to even partially start. Servers are supposed to back up in around 1.5h https://secure.runescape.com/m=news/game-status-information-centre?oldschool=1
    3. Oh also the way of implementing the algorithm that holic recommends has now been deprecated. Mouse.setMouseMovementAlgorithm(new WindMouse()); should now be used instead of Client.getInstance().setMouseMovementAlgorithm(new WindMouse());
    4. I had some issues with this code relating to mouse dragging that caused very erratic camera movement. To fix this, I had to switch a couple of Mouse#hop calls into setMousePosition, and add a canvas event to the setMousePosition for when the mouse should be dragged instead of moved. Here is a fixed version: /** * WindMouse from SMART by Benland100 * Copyright to Benland100, (Benjamin J. Land) * Originally modified for use with DreamBot 3 by holic * Mouse dragging issues fixed by Hero with help from Pandemic * <p> * Prepped for DreamBot 3 **/ import org.dreambot.api.input.Mouse; import org.dreambot.api.input.mouse.algorithm.MouseMovementAlgorithm; import org.dreambot.api.input.mouse.destination.AbstractMouseDestination; import org.dreambot.api.methods.Calculations; import org.dreambot.api.methods.ViewportTools; import org.dreambot.api.methods.input.mouse.MouseSettings; import org.dreambot.api.utilities.Logger; import org.dreambot.core.Instance; import java.awt.*; import java.awt.event.MouseEvent; public class WindMouse implements MouseMovementAlgorithm { // https://dreambot.org/forums/index.php?/topic/21147-windmouse-custom-mouse-movement-algorithm/ private int _mouseSpeed = MouseSettings.getSpeed() > 15 ? MouseSettings.getSpeed() - 10 : 15; private final int _mouseSpeedLow = Math.round(_mouseSpeed / 2); private int _mouseGravity = Calculations.random(4, 20); private int _mouseWind = Calculations.random(1, 10); @Override public boolean handleMovement(AbstractMouseDestination abstractMouseDestination) { //Get a suitable point for the mouse's destination Point suitPos = abstractMouseDestination.getSuitablePoint(); // Select which implementation of WindMouse you'd like to use // by uncommenting out the line you want to use below: //windMouse(suitPos.x, suitPos.y); //Original implementation windMouse2(suitPos); //Tweaked implementation return distance(Mouse.getPosition(), suitPos) < 2; } public static void sleep(int min, int max) { try { Thread.sleep(Calculations.random(min, max)); } catch (InterruptedException e) { Logger.log(e.getMessage()); } } public static void sleep(int ms) { try { Thread.sleep(ms); } catch (InterruptedException e) { Logger.log(e.getMessage()); } } /** * Tweaked implementation of WindMouse * Moves to a mid point on longer moves to seem a little more human-like * Remove the if statement below if you'd rather straighter movement * * @param point The destination point */ public void windMouse2(Point point) { Point curPos = Mouse.getPosition(); if (distance(point, curPos) > 250 && Calculations.random(1) == 2) { Point rp = randomPoint(point, curPos); windMouse2(curPos.x, curPos.y, rp.x, rp.y, _mouseGravity, _mouseWind, _mouseSpeed, Calculations.random(5, 25)); sleep(1, 150); } windMouse2(curPos.x, curPos.y, point.x, point.y, _mouseGravity, _mouseWind, _mouseSpeed, Calculations.random(5, 25)); _mouseGravity = Calculations.random(4, 20); _mouseWind = Calculations.random(1, 10); _mouseSpeed = Calculations.random(_mouseSpeedLow, MouseSettings.getSpeed()); } /** * Tweaked implementation of WindMouse by holic * All credit to Benjamin J. Land for the original. (see below) * * @param xs The x start * @param ys The y start * @param xe The x destination * @param ye The y destination * @param gravity Strength pulling the position towards the destination * @param wind Strength pulling the position in random directions * @param targetArea Radius of area around the destination that should * trigger slowing, prevents spiraling */ private void windMouse2(double xs, double ys, double xe, double ye, double gravity, double wind, double speed, double targetArea) { double dist, veloX = 0, veloY = 0, windX = 0, windY = 0; double sqrt2 = Math.sqrt(2); double sqrt3 = Math.sqrt(3); double sqrt5 = Math.sqrt(5); int tDist = (int) distance(xs, ys, xe, ye); long t = System.currentTimeMillis() + 10000; while (!(Math.hypot((xs - xe), (ys - ye)) < 1)) { if (System.currentTimeMillis() > t) break; dist = Math.hypot((xs - xe), (ys - ye)); wind = Math.min(wind, dist); if ((dist < 1)) { dist = 1; } long d = (Math.round((Math.round(((double) (tDist))) * 0.3)) / 7); if ((d > 25)) { d = 25; } if ((d < 5)) { d = 5; } double rCnc = Calculations.random(6); if ((rCnc == 1)) { d = 2; } double maxStep = (Math.min(d, Math.round(dist))) * 1.5; if ((dist >= targetArea)) { windX = (windX / sqrt3) + ((Calculations.random((int) ((Math.round(wind) * 2) + 1)) - wind) / sqrt5); windY = (windY / sqrt3) + ((Calculations.random((int) ((Math.round(wind) * 2) + 1)) - wind) / sqrt5); } else { windX = (windX / sqrt2); windY = (windY / sqrt2); } veloX += windX + gravity * (xe - xs) / dist; veloY += windY + gravity * (ye - ys) / dist; if ((Math.hypot(veloX, veloY) > maxStep)) { maxStep = ((maxStep / 2) < 1) ? 2 : maxStep; double randomDist = (maxStep / 2) + Calculations.random((int) (Math.round(maxStep) / 2)); double veloMag = Math.sqrt(((veloX * veloX) + (veloY * veloY))); veloX = (veloX / veloMag) * randomDist; veloY = (veloY / veloMag) * randomDist; } int lastX = ((int) (Math.round(xs))); int lastY = ((int) (Math.round(ys))); xs += veloX; ys += veloY; if ((lastX != Math.round(xs)) || (lastY != Math.round(ys))) { setMousePosition(new Point((int) Math.round(xs), (int) Math.round(ys))); } int w = Calculations.random((int) (Math.round(100 / speed))) * 6; if ((w < 5)) { w = 5; } w = (int) Math.round(w * 0.9); sleep(w); } if (((Math.round(xe) != Math.round(xs)) || (Math.round(ye) != Math.round(ys)))) { setMousePosition(new Point((int) Math.round(xs), (int) Math.round(ys))); } } /** * Internal mouse movement algorithm from SMART. Do not use this without credit to either * Benjamin J. Land or BenLand100. This was originally synchronized to prevent multiple * motions and bannage but functions poorly with DB3. * <p> * BEST USED IN FIXED MODE * * @param xs The x start * @param ys The y start * @param xe The x destination * @param ye The y destination * @param gravity Strength pulling the position towards the destination * @param wind Strength pulling the position in random directions * @param minWait Minimum relative time per step * @param maxWait Maximum relative time per step * @param maxStep Maximum size of a step, prevents out of control motion * @param targetArea Radius of area around the destination that should * trigger slowing, prevents spiraling * @result The actual end point */ private Point windMouseImpl(double xs, double ys, double xe, double ye, double gravity, double wind, double minWait, double maxWait, double maxStep, double targetArea) { final double sqrt3 = Math.sqrt(3); final double sqrt5 = Math.sqrt(5); double dist, veloX = 0, veloY = 0, windX = 0, windY = 0; while ((dist = Math.hypot(xs - xe, ys - ye)) >= 1) { wind = Math.min(wind, dist); if (dist >= targetArea) { windX = windX / sqrt3 + (2D * Math.random() - 1D) * wind / sqrt5; windY = windY / sqrt3 + (2D * Math.random() - 1D) * wind / sqrt5; } else { windX /= sqrt3; windY /= sqrt3; if (maxStep < 3) { maxStep = Math.random() * 3D + 3D; } else { maxStep /= sqrt5; } } veloX += windX + gravity * (xe - xs) / dist; veloY += windY + gravity * (ye - ys) / dist; double veloMag = Math.hypot(veloX, veloY); if (veloMag > maxStep) { double randomDist = maxStep / 2D + Math.random() * maxStep / 2D; veloX = (veloX / veloMag) * randomDist; veloY = (veloY / veloMag) * randomDist; } int lastX = ((int) (Math.round(xs))); int lastY = ((int) (Math.round(ys))); xs += veloX; ys += veloY; if ((lastX != Math.round(xs)) || (lastY != Math.round(ys))) { setMousePosition(new Point((int) Math.round(xs), (int) Math.round(ys))); } double step = Math.hypot(xs - lastX, ys - lastY); sleep((int) Math.round((maxWait - minWait) * (step / maxStep) + minWait)); } return new Point((int) xs, (int) ys); } /** * Moves the mouse from the current position to the specified position. * Approximates human movement in a way where smoothness and accuracy are * relative to speed, as it should be. * * @param x The x destination * @param y The y destination * @result The actual end point */ public Point windMouse(int x, int y) { Point c = Mouse.getPosition(); double speed = (Math.random() * 15D + 15D) / 10D; return windMouseImpl(c.x, c.y, x, y, 9D, 3D, 5D / speed, 10D / speed, 10D * speed, 8D * speed); } private void setMousePosition(Point endPoint) { if (Mouse.getMouseSettings().isDrag()) { // pan told me to do this for dragging. more info in the DreamBot EDU server: https://discord.com/channels/426346091173380096/462764560772759563/1125126497343123566 Instance.dispatchCanvasEvent(new MouseEvent(Instance.getCanvas(), MouseEvent.MOUSE_DRAGGED, System.currentTimeMillis(), 0, endPoint.x, endPoint.y, ViewportTools.getAbsoluteXCoordinate() + endPoint.x, ViewportTools.getAbsoluteYCoordinate() + endPoint.y, 0, false, MouseEvent.BUTTON2)); } else { Mouse.hop(endPoint); } } private static double distance(double x1, double y1, double x2, double y2) { return Math.sqrt((Math.pow((Math.round(x2) - Math.round(x1)), 2) + Math.pow((Math.round(y2) - Math.round(y1)), 2))); } public double distance(Point p1, Point p2) { return Math.sqrt((p2.y - p1.y) * (p2.y - p1.y) + (p2.x - p1.x) * (p2.x - p1.x)); } public static float randomPointBetween(float corner1, float corner2) { if (corner1 == corner2) { return corner1; } float delta = corner2 - corner1; float offset = Calculations.getRandom().nextFloat() * delta; return corner1 + offset; } public Point randomPoint(Point p1, Point p2) { int randomX = (int) randomPointBetween(p1.x, p2.x); int randomY = (int) randomPointBetween(p1.y, p2.y); return new Point(randomX, randomY); } }
    5. just used this to map a completely unmapped area. so much easier then doing it manually, plus useful for checking if areas are mapped or not. great tool. thoughts about open sourcing it? Oh also it appears to load very slowly for me. not really sure what causes that, although on a refresh it appears to be fine so it appears to cache whatever the issue is.
    6. public static int totalTimePlayed() { int minutesPlayed = 0; String[] splitArr = Widgets.getWidgetChild(712, 2, 100).getText().split(">", 2)[1].split("<", 2)[0].split(","); HashMap<String, Integer> timeWordsKey = new HashMap<>(); timeWordsKey.put("day", 24*60); timeWordsKey.put("hour", 60); timeWordsKey.put("minute", 1); for (String time: splitArr) { for (String timeWord : timeWordsKey.keySet()) { if (time.contains(timeWord)) { time = time.split(" "+timeWord, 2)[0]; if (time.charAt(0) == ' ') { time = time.substring(1); } minutesPlayed += Integer.parseInt(time)*timeWordsKey.get(timeWord); } } } return minutesPlayed; } Hi. I saw this and rewrote it as a method that returns the time played in minutes. I have to say my version doesn't really feel very clean due to the weird string manipulation at the top with a ton of splits, the hashMap makes it kind of unclear, and the weird char selection in the double for loop, but it works. I will warn you that both my and 420x69x420's version only update the widget text when the time text is viewed or when the account is logged into, so this method doesn't exactly give the most accurate data.
    ×
    ×
    • Create New...

    Important Information

    We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.