Just a simple script that i've been using for a while, and since there isn't a script that just walks to GE i'm releasing mine, and also the few lines of code.
I made a nifty little mouse utility for drawing custom cursors and trails that I thought I would pass onto the community. Some of the trails are meh but I think the final product is still great and it's very straightforward to use.
Credits:
DarkMagican for the original mouse trails & rainbow source
ENFILADE for MousePathPoint
Setup functions
void setCursorColor(Color cursorColor)
Manually set the cursor's colour, default white
void setCursorStroke(BasicStroke cursorStroke)
Manually set the cursor's stroke thickness, default 2
void setTrailColor(Color trailColor)
Manually set the trail's colour, default white
void setRainbow(boolean RAINBOW)
Set the mouse cursor & trail colour to be rainbow
void setRandomColor()
Set the mouse cursor & trail colour to be random, possibly rainbow
Mouse functions
void drawRandomMouse(Graphics g)
Draws the randomly selected mouse graphic.
void drawPlusMouse(Graphics g)
Draws a "+" for the mouse, with shadow.
void drawCrossMouse(Graphics g)
Draws a "x" for the mouse, with shadow.
void drawCircleMouse(Graphics g)
Draws a circle for the mouse, with shadow.
void drawDotMouse(Graphics g)
Draws a dot for the mouse, with shadow.
void drawRotatingCrossMouse(Graphics g)
Draws an "x" for the mouse that rotates, with shadow.
void drawRotatingCircleMouse(Graphics g)
Draws a circle with rotating pie slices, with shadow.
Trail functions
void drawTrail(Graphics g)
Draws a typical line-based mouse trail, varying size line width
void drawZoomTrail(Graphics g)
Draws a "ZOOM" for a trail, varying case and size
void drawTextTrail(Graphics g, String trail)
Draws your specified text for a trail, could work for script status?
void drawDotTrail(Graphics g)
Draws a series of dots as a trail, varying sizes
void drawCircleTrail(Graphics g)
Draws a series of circles as a trail, varying sizes
void drawPlusTrail(Graphics g)
Draws a series of "+" as a trail, varying sizes
void drawRotatingSlashTrail(Graphics g)
Draws a series of "/" as a trail that rotate, varying sizes
void drawRotatingCrossTrail(Graphics g)
Draws a series of "x" as a trail that rotate, varying sizes
Usage example
First, add DrawMouseUtil to your project by copying and pasting it into a file name DrawMouseUtil.java and importing it into your project
Second, create a variable for DrawMouseUtil so you have consistency in your setup and calls.
private DrawMouseUtil drawMouseUtil = new DrawMouseUtil();
Third, set your desired settings and add it to onStart. For this example we will be setting up the mouse randomly:
@Override
public void onStart() {
drawMouseUtil.setRandomColor(); //Set a random colour and leave the stroke setting at default
.....
}
Fourth, call your desired mouse cursor and trail in onPaint. For this example we will be using random settings:
@Override
public void onPaint(Graphics g) {
drawMouseUtil.drawRandomMouse(g);
drawMouseUtil.drawRandomMouseTrail(g);
}
My favourite combination currently is either
drawMouseUtil.drawRotatingCrossMouse(g)
drawMouseUtil.drawRotatingCrossTrail(g)
or
drawMouseUtil.drawRotatingCircleMouse(g);
drawMouseUtil.drawDotTrail(g);
DrawMouseUtil.java:
/** DrawMouseUtil by holic **/
import org.dreambot.api.Client;
import org.dreambot.api.methods.Calculations;
import java.awt.*;
import java.awt.geom.AffineTransform;
import java.awt.geom.Arc2D;
import java.awt.geom.Line2D;
import java.util.LinkedList;
import static org.dreambot.api.methods.MethodProvider.log;
public class DrawMouseUtil {
LinkedList<MousePathPoint> mousePath = new LinkedList<MousePathPoint>();
private boolean RAINBOW = false;
private int STROKE = 2;
private int mX, mY;
private long angle;
private BasicStroke cursorStroke = new BasicStroke(STROKE);
private int randomMouse = Calculations.random(5);
private int randomMouseTrail = Calculations.random(7);
private Color cursorColor = Color.WHITE;
private Color trailColor = cursorColor;
private Color[] cursorColors = {new Color(78, 216, 255), new Color(90, 222, 98), new Color(215, 182, 77), new Color(232, 134, 124), new Color(215, 120, 124), new Color(183, 138, 215), Color.WHITE};
private AffineTransform oldTransform;
private int r = 0, g = 0, b = 0, duration = 650;
public DrawMouseUtil() {
Client.getInstance().setDrawMouse(false);
}
public void setRainbow(boolean RAINBOW) {
if (RAINBOW) {
g = 255;
} else {
g = 0;
}
this.RAINBOW = RAINBOW;
}
public void setRandomColor() {
if (Calculations.random(2) != 1) {
log("Rainbow mouse!");
setRainbow(true);
} else {
setRainbow(false);
cursorColor = getRandomColour();
trailColor = cursorColor;
}
}
private Color getRandomColour() {
return cursorColors[Calculations.random(cursorColors.length - 1)];
}
public void setCursorStroke(BasicStroke cursorStroke) {
this.cursorStroke = cursorStroke;
}
public void setCursorColor(Color cursorColor) {
this.cursorColor = cursorColor;
}
public void setTrailColor(Color trailColor) {
this.trailColor = trailColor;
}
public void drawRandomMouse(Graphics g) {
switch (randomMouse) {
case 0:
drawPlusMouse(g);
break;
case 1:
drawCrossMouse(g);
break;
case 2:
drawCircleMouse(g);
break;
case 3:
drawDotMouse(g);
break;
case 4:
drawRotatingCrossMouse(g);
break;
case 5:
drawRotatingCircleMouse(g);
break;
}
}
public void drawRandomMouseTrail(Graphics g) {
switch (randomMouseTrail) {
case 0:
drawTrail(g);
break;
case 1:
drawZoomTrail(g);
break;
case 2:
drawPlusTrail(g);
break;
case 3:
drawCircleTrail(g);
break;
case 4:
drawDotTrail(g);
break;
case 5:
drawRotatingSlashTrail(g);
break;
case 6:
drawRotatingCrossTrail(g);
break;
case 7:
drawTextTrail(g, "your text here");
break;
}
}
/**
* * ** ** ** **
* Mouse cursor
* * ** ** ** **
**/
public void drawPlusMouse(Graphics g) {
Graphics2D g2 = (Graphics2D) g;
int s = 4;
Point cP = Client.getMousePosition();
int cX = (int) cP.getX();
int cY = (int) cP.getY();
g2.setColor(Color.BLACK);
g2.setStroke(cursorStroke);
/* + Cursor */
g2.drawLine(cX - s + 1, cY + 1, cX + s + 1, cY + 1);
g2.drawLine(cX + 1, cY - s + 1, cX + 1, cY + s + 1);
g2.setColor(cursorColor);
g2.drawLine(cX - s, cY, cX + s, cY);
g2.drawLine(cX, cY - s, cX, cY + s);
g2.setStroke(new BasicStroke(1));
}
public void drawCrossMouse(Graphics g) {
Graphics2D g2 = (Graphics2D) g;
int s = 3;
Point cP = Client.getMousePosition();
int cX = (int) cP.getX();
int cY = (int) cP.getY();
g2.setStroke(cursorStroke);
g2.setColor(Color.BLACK);
/* X Cursor */
g2.drawLine(cX - s + 1, cY - s + 1, cX + s + 1, cY + s + 1);
g2.drawLine(cX - s + 1, cY + s + 1, cX + s + 1, cY - s + 1);
g2.setColor(cursorColor);
g2.drawLine(cX - s, cY - s, cX + s, cY + s);
g2.drawLine(cX - s, cY + s, cX + s, cY - s);
g2.setStroke(new BasicStroke(1));
}
public void drawCircleMouse(Graphics g) {
Graphics2D g2 = (Graphics2D) g;
oldTransform = g2.getTransform();
int mX = Client.getMousePosition().x;
mY = Client.getMousePosition().y;
g2.setRenderingHints(new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON));
if (mX != -1) {
g2.setStroke(cursorStroke);
g2.setColor(Color.BLACK);
g2.drawOval(mX - 1, mY - 1, 4, 4);
g2.setColor(cursorColor);
g2.drawOval(mX - 2, mY - 2, 4, 4);
g2.setStroke(new BasicStroke(1));
}
}
public void drawDotMouse(Graphics g) {
Graphics2D g2 = (Graphics2D) g;
oldTransform = g2.getTransform();
int mX = Client.getMousePosition().x;
mY = Client.getMousePosition().y;
g2.setRenderingHints(new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON));
if (mX != -1) {
g2.setStroke(cursorStroke);
g2.setColor(Color.BLACK);
g2.drawOval(mX - 1, mY - 1, 4, 4);
g2.setColor(cursorColor);
g2.drawOval(mX - 2, mY - 2, 4, 4);
g2.setStroke(new BasicStroke(1));
}
}
public void drawRotatingCircleMouse(Graphics g) {
Graphics2D g2 = (Graphics2D) g;
oldTransform = g2.getTransform();
int mX = Client.getMousePosition().x;
mY = Client.getMousePosition().y;
g2.setRenderingHints(new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON));
if (mX != -1) {
g2.setStroke(cursorStroke);
g2.drawOval(mX - 2, mY - 2, 4, 4);
g2.setColor(cursorColor);
g2.rotate(Math.toRadians(angle += 6), mX, mY);
g2.draw(new Arc2D.Double(mX - 6, mY - 6, 12, 12, 330, 60, Arc2D.OPEN));
g2.draw(new Arc2D.Double(mX - 6, mY - 6, 12, 12, 151, 60, Arc2D.OPEN));
g2.setTransform(oldTransform);
g2.setStroke(new BasicStroke(1));
}
}
public void drawRotatingCrossMouse(Graphics g) {
Graphics2D g2 = (Graphics2D) g;
oldTransform = g2.getTransform();
Point cP = Client.getMousePosition();
int cX = (int) cP.getX();
int cY = (int) cP.getY();
int s = 4;
g2.setRenderingHints(new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON));
if (mX != -1) {
g2.setStroke(cursorStroke);
g2.setColor(Color.BLACK);
//g.rotate(Math.toRadians(angle+=1), mX, mY);
Line2D lineShadow = new Line2D.Double(cX - s + 1, cY + 1, cX + s + 1, cY + 1);
Line2D lineShadow2 = new Line2D.Double(cX + 1, cY - s + 1, cX + 1, cY + s + 1);
AffineTransform atS =
AffineTransform.getRotateInstance(
Math.toRadians(angle += 4), cX + 1, cY + 1);
AffineTransform atS2 =
AffineTransform.getRotateInstance(
Math.toRadians(angle), cX + 1, cY + 1);
g2.draw(atS.createTransformedShape(lineShadow));
g2.draw(atS2.createTransformedShape(lineShadow2));
g2.setColor(nextCursorColor());
Line2D line = new Line2D.Double(cX - s, cY, cX + s, cY);
Line2D line2 = new Line2D.Double(cX, cY - s, cX, cY + s);
AffineTransform at =
AffineTransform.getRotateInstance(
Math.toRadians(angle += 4), cX, cY);
AffineTransform at2 =
AffineTransform.getRotateInstance(
Math.toRadians(angle), cX, cY);
// Draw the rotated line
g2.draw(at.createTransformedShape(line));
g2.draw(at2.createTransformedShape(line2));
g2.setStroke(new BasicStroke(1));
}
}
/**
* * ** ** ** **
* Mouse trails
* * ** ** ** **
**/
public void drawTrail(Graphics g) {
Graphics2D g2 = (Graphics2D) g;
oldTransform = g2.getTransform();
int mX = Client.getMousePosition().x;
mY = Client.getMousePosition().y;
g2.setRenderingHints(new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON));
while (!mousePath.isEmpty() && mousePath.peek().isUp())
mousePath.remove();
Point clientCursor = Client.getMousePosition();
MousePathPoint mpp = new MousePathPoint(clientCursor.x, clientCursor.y, duration);
if (mousePath.isEmpty() || !mousePath.getLast().equals(mpp))
mousePath.add(mpp);
MousePathPoint lastPoint = null;
for (MousePathPoint a : mousePath) {
if (lastPoint != null) {
Color c = nextTrailColor();
int tmpcursorStroke = STROKE;
if (STROKE > 1)
tmpcursorStroke = (a.getAlpha() > 175 ? STROKE : STROKE - 1);
g2.setStroke(new BasicStroke(tmpcursorStroke));
g2.setColor(new Color(c.getRed(), c.getGreen(), c.getBlue(), a.getAlpha())); //trail color
g2.drawLine(a.x, a.y, lastPoint.x, lastPoint.y);
g2.setStroke(new BasicStroke(1));
}
lastPoint = a;
}
}
public void drawZoomTrail(Graphics g) {
String zoom = "zoom zoom ";
int zoomIndex = 0, zoomIndexStart = -1;
Graphics2D g2 = (Graphics2D) g;
oldTransform = g2.getTransform();
g2.setFont(new Font("default", Font.BOLD, 12));
g2.setRenderingHints(new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON));
while (!mousePath.isEmpty() && mousePath.peek().isUp())
mousePath.remove();
Point clientCursor = Client.getMousePosition();
MousePathPoint mpp = new MousePathPoint(clientCursor.x, clientCursor.y, duration * 2);
if (mousePath.isEmpty() || !mousePath.getLast().equals(mpp))
mousePath.add(mpp);
MousePathPoint lastPoint = null;
for (MousePathPoint a : mousePath) {
if (zoomIndex >= zoom.length())
zoomIndex = 0;
String toDraw = String.valueOf(zoom.toCharArray()[zoomIndex]);
if (lastPoint != null) {
Color c = nextTrailColor();
toDraw = a.getAlpha() > 175 ? toDraw.toUpperCase() : toDraw;
g2.setColor(new Color(c.getRed(), c.getGreen(), c.getBlue(), a.getAlpha())); //trail color
g2.drawString(toDraw, a.x, a.y + 5);
}
lastPoint = a;
zoomIndex++;
}
g2.setFont(new Font("default", Font.PLAIN, 12));
}
public void drawTextTrail(Graphics g, String trail) {
int zoomIndex = 0, zoomIndexStart = -1;
Graphics2D g2 = (Graphics2D) g;
oldTransform = g2.getTransform();
g2.setFont(new Font("default", Font.BOLD, 12));
g2.setRenderingHints(new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON));
while (!mousePath.isEmpty() && mousePath.peek().isUp())
mousePath.remove();
Point clientCursor = Client.getMousePosition();
MousePathPoint mpp = new MousePathPoint(clientCursor.x, clientCursor.y, duration * 2);
if (mousePath.isEmpty() || !mousePath.getLast().equals(mpp))
mousePath.add(mpp);
MousePathPoint lastPoint = null;
for (MousePathPoint a : mousePath) {
if (lastPoint != null) {
Color c = nextTrailColor();
g2.setColor(new Color(c.getRed(), c.getGreen(), c.getBlue(), a.getAlpha())); //trail color
g2.drawString(trail, a.x, a.y);
}
lastPoint = a;
zoomIndex++;
}
g2.setFont(new Font("default", Font.PLAIN, 12));
}
public void drawDotTrail(Graphics g) {
Graphics2D g2 = (Graphics2D) g;
oldTransform = g2.getTransform();
g2.setRenderingHints(new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON));
while (!mousePath.isEmpty() && mousePath.peek().isUp())
mousePath.remove();
Point clientCursor = Client.getMousePosition();
MousePathPoint mpp = new MousePathPoint(clientCursor.x, clientCursor.y, duration * 2);
if (mousePath.isEmpty() || !mousePath.getLast().equals(mpp))
mousePath.add(mpp);
MousePathPoint lastPoint = null;
for (MousePathPoint a : mousePath) {
if (lastPoint != null) {
Color c = nextTrailColor();
int size = a.getAlpha() > 200 ? 6 : a.getAlpha() > 150 ? 5 : a.getAlpha() > 100 ? 4 : a.getAlpha() > 50 ? 3 : 2;
g2.setStroke(cursorStroke);
g2.setColor(new Color(c.getRed(), c.getGreen(), c.getBlue(), a.getAlpha())); //trail color
g2.fillOval(a.x, a.y, size, size);
g2.setStroke(new BasicStroke(1));
}
lastPoint = a;
}
}
public void drawCircleTrail(Graphics g) {
Graphics2D g2 = (Graphics2D) g;
oldTransform = g2.getTransform();
g2.setRenderingHints(new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON));
while (!mousePath.isEmpty() && mousePath.peek().isUp())
mousePath.remove();
Point clientCursor = Client.getMousePosition();
MousePathPoint mpp = new MousePathPoint(clientCursor.x, clientCursor.y, duration * 2);
if (mousePath.isEmpty() || !mousePath.getLast().equals(mpp))
mousePath.add(mpp);
MousePathPoint lastPoint = null;
for (MousePathPoint a : mousePath) {
if (lastPoint != null) {
Color c = nextTrailColor();
int size = a.getAlpha() > 200 ? 6 : a.getAlpha() > 150 ? 5 : a.getAlpha() > 100 ? 4 : a.getAlpha() > 50 ? 3 : 2;
g2.setStroke(cursorStroke);
g2.setColor(new Color(c.getRed(), c.getGreen(), c.getBlue(), a.getAlpha())); //trail color
g2.drawOval(a.x, a.y, size, size);
g2.setStroke(new BasicStroke(1));
}
lastPoint = a;
}
}
public void drawPlusTrail(Graphics g) {
Graphics2D g2 = (Graphics2D) g;
oldTransform = g2.getTransform();
g2.setRenderingHints(new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON));
while (!mousePath.isEmpty() && mousePath.peek().isUp())
mousePath.remove();
Point clientCursor = Client.getMousePosition();
MousePathPoint mpp = new MousePathPoint(clientCursor.x, clientCursor.y, duration * 2);
if (mousePath.isEmpty() || !mousePath.getLast().equals(mpp))
mousePath.add(mpp);
MousePathPoint lastPoint = null;
for (MousePathPoint a : mousePath) {
if (lastPoint != null) {
Color c = nextTrailColor();
int size = a.getAlpha() > 200 ? 5 : a.getAlpha() > 150 ? 4 : a.getAlpha() > 100 ? 3 : a.getAlpha() > 50 ? 2 : 1;
g2.setStroke(cursorStroke);
g2.setColor(new Color(c.getRed(), c.getGreen(), c.getBlue(), a.getAlpha())); //trail color
g2.drawLine(a.x - size + 1, a.y + 1, a.x + size + 1, a.y + 1);
g2.drawLine(a.x + 1, a.y - size + 1, a.x + 1, a.y + size + 1);
g2.setStroke(new BasicStroke(1));
}
lastPoint = a;
}
}
public void drawRotatingSlashTrail(Graphics g) {
Graphics2D g2 = (Graphics2D) g;
oldTransform = g2.getTransform();
g2.setRenderingHints(new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON));
while (!mousePath.isEmpty() && mousePath.peek().isUp())
mousePath.remove();
Point clientCursor = Client.getMousePosition();
MousePathPoint mpp = new MousePathPoint(clientCursor.x, clientCursor.y, duration * 2);
if (mousePath.isEmpty() || !mousePath.getLast().equals(mpp))
mousePath.add(mpp);
MousePathPoint lastPoint = null;
for (MousePathPoint a : mousePath) {
if (lastPoint != null) {
Color c = nextTrailColor();
int size = a.getAlpha() > 200 ? 5 : a.getAlpha() > 150 ? 4 : a.getAlpha() > 100 ? 3 : a.getAlpha() > 50 ? 2 : 1;
g2.setStroke(cursorStroke);
g2.setColor(new Color(c.getRed(), c.getGreen(), c.getBlue(), a.getAlpha())); //trail color
Line2D line = new Line2D.Double(a.x - size, a.y, a.x + size, a.y);
Line2D line2 = new Line2D.Double(a.x, a.y - size, a.x, a.y + size);
AffineTransform at =
AffineTransform.getRotateInstance(
Math.toRadians(angle += 4), a.x, a.y);
g2.draw(at.createTransformedShape(line));
g2.setStroke(new BasicStroke(1));
}
lastPoint = a;
}
}
public void drawRotatingCrossTrail(Graphics g) {
Graphics2D g2 = (Graphics2D) g;
oldTransform = g2.getTransform();
g2.setRenderingHints(new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON));
while (!mousePath.isEmpty() && mousePath.peek().isUp())
mousePath.remove();
Point clientCursor = Client.getMousePosition();
MousePathPoint mpp = new MousePathPoint(clientCursor.x, clientCursor.y, duration * 2);
if (mousePath.isEmpty() || !mousePath.getLast().equals(mpp))
mousePath.add(mpp);
MousePathPoint lastPoint = null;
for (MousePathPoint a : mousePath) {
if (lastPoint != null) {
Color c = nextTrailColor();
int size = a.getAlpha() > 200 ? 5 : a.getAlpha() > 150 ? 4 : a.getAlpha() > 100 ? 3 : a.getAlpha() > 50 ? 2 : 1;
g2.setStroke(cursorStroke);
g2.setColor(new Color(c.getRed(), c.getGreen(), c.getBlue(), a.getAlpha())); //trail color
Line2D line = new Line2D.Double(a.x - size, a.y, a.x + size, a.y);
Line2D line2 = new Line2D.Double(a.x, a.y - size, a.x, a.y + size);
AffineTransform at =
AffineTransform.getRotateInstance(
Math.toRadians(angle += 4), a.x, a.y);
g2.draw(at.createTransformedShape(line));
g2.draw(at.createTransformedShape(line2));
g2.setStroke(new BasicStroke(1));
}
lastPoint = a;
}
}
public void nextRGB() {
if (r == 255 && g < 255 & b == 0) {
g++;
}
if (g == 255 && r > 0 && b == 0) {
r--;
}
if (g == 255 && b < 255 && r == 0) {
b++;
}
if (b == 255 && g > 0 && r == 0) {
g--;
}
if (b == 255 && r < 255 && g == 0) {
r++;
}
if (r == 255 && b > 0 && g == 0) {
b--;
}
}
public Color currentCursorColor() {
if (!RAINBOW) {
return cursorColor;
} else {
return new Color(r, g, b);
}
}
public Color currentTrailColor() {
if (!RAINBOW) {
return trailColor;
} else {
return new Color(r, g, b);
}
}
public Color nextCursorColor() {
nextRGB();
return currentCursorColor();
}
public Color nextTrailColor() {
if (!RAINBOW) //Don't call this if it is set to rainbow so we're not double calling nextRGB()
nextRGB();
return currentTrailColor();
}
public class MousePathPoint extends Point {
private long finishTime;
private double lastingTime;
private int alpha = 255;
public MousePathPoint(int x, int y, int lastingTime) {
super(x, y);
this.lastingTime = lastingTime;
finishTime = System.currentTimeMillis() + lastingTime;
}
public int getAlpha() {
int newAlpha = ((int) ((finishTime - System.currentTimeMillis()) / (lastingTime / alpha)));
if (newAlpha > 255)
newAlpha = 255;
if (newAlpha < 0)
newAlpha = 0;
return newAlpha;
}
public boolean isUp() {
return System.currentTimeMillis() >= finishTime;
}
}
}
Enjoy falsely tricking people into thinking your script is better than it is!
Hey all,
Since DB3 officially supports custom mouse algorithms I thought I would port over a classic one: WindMouse.
WindMouse was written by BenLand100 for SCAR some years back (maybe 10 years?) and has been used on so many damn bots throughout the years because it functions really well so it only seemed right to bring it here.
In the source code below, there are two implementations of WindMouse:
Point windMouse(int x, int y)
Which comes directly from the SMART github with minor adjustments to work with DB3.
Better in fixed mode.
void windMouse2(Point point)
My tweaked version from years back that supports all screen sizes.
I've added a random point between the original and the destination point if the distance between them is large to feel more human but has a 50% chance of happening.
By default my implementation is the active algorithm (as it handles all sizes), swap the comments in handleMovement to change to the original.
To use it, simply add the file WindMouse.java to your project and add the following to your onStart method:
Client.getInstance().setMouseMovementAlgorithm(new WindMouse());
All credits go to Benjamin J. Land a.k.a. BenLand100
WindMouse.java:
/**
* WindMouse from SMART by Benland100
* Copyright to Benland100, (Benjamin J. Land)
*
* Prepped for DreamBot 3
**/
import org.dreambot.api.Client;
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.input.mouse.MouseSettings;
import java.awt.*;
import static java.lang.Thread.sleep;
public class WindMouse implements MouseMovementAlgorithm {
private int _mouseSpeed = MouseSettings.getSpeed() > 15 ? MouseSettings.getSpeed() - 10 : 15;
private 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(Client.getMousePosition(), suitPos) < 2;
}
public static void sleep(int min, int max) {
try {
Thread.sleep(Calculations.random(min,max));
} catch (InterruptedException e) {
log(e.getMessage());
}
}
public static void sleep(int ms) {
try {
Thread.sleep(ms);
} catch (InterruptedException e) {
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 = Client.getMousePosition();
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))) {
Mouse.hop(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)))) {
Mouse.hop(new Point(((int) (Math.round(xe))), ((int) (Math.round(ye)))));
}
}
/**
* 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.
*
* 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 = Client.getMousePosition();
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 p) {
Mouse.hop(p.x, p.y);
}
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);
}
}
Happy botting!
Purchase using PayPal, OSRS GOLD, CRYPTO or OTHER
>Start you free 2 hour trial<
Features
Supports stun alching, curse alching, etc.
Supports humidifying
Supports stringing jewellery
Supports plank making
Supports tanning leathers
Supports enchanting
Supports superheating
Supports splashing
Supports teleporting
Active customer support
Gallery
Just a simple script that i've been using for a while, and since there isn't a script that just walks to GE i'm releasing mine, and also the few lines of code.
Just a simple script that i've been using for a while, and since there isn't a script that just walks to GE i'm releasing mine, and also the few lines of code.
Hello everyone, this will be a series of short tutorials expanding on a miner for the DreamBot 3 client, starting with a simple script that just mines and drops, eventually compounding to a fully complete miner that has antiban methods, banking, a GUI, and whatever else I think of
This initial tutorial will be very brief, I won't be explaining every line of code, however future parts may be more in depth.
Prerequisites
This is meant to be for people who are somewhat familiar with Java or similar languages, and new to DreamBot or OSRS bot making. I won't be discussing setting up Java or your development software for building the script's output. This will assume you already have a basic knowledge of Java programming and an IDE ready to go. If you need help with that, check out this guide to get a basic setup ready:
Project Layout
To start, create a new project in your IDE and call it anything you'd like. Inside your project folder, create a folder layout and create the three starting classes, it should look like this:
The 'src' folder is important if you ever decide to upload a script to our SDN.
The Script
Let's start with what the script should be able to do by the end of Part 1:
Mine any rocks, just whatever is closest
If the inventory is full, drop all of the ore
Show a basic paint letting us know how much experience we've gained
For this script, I've decided to go with a node or task setup. Basically we'll make simple, self contained tasks that the client will run whenever they're ready to be ran. We can optionally set a priority so more important tasks will run first, but we'll save that for a later tutorial.
Miner.java, the script's main class
For this basic setup, here's the simple starting class for our miner:
Points of Interest:
@ScriptManifest: This is an annotation that helps us show your script in the script manager.
extends TaskScript: TaskScript is a subclass of AbstractScript that handles the basic task/node logic so we can focus on creating discrete tasks.
onStart(): This method is called whenever someone starts the script through DreamBot.
onPaint(Graphics g): This method is called on every frame render, usually 60 times per second. For performance reasons, you want to minimize the amount of processing you do in this method.
The Tasks
Now that the script's main class is added, let's make the mining task.
Mining
Now we need to figure out how to know which rocks are mine-able. Load into the game and walk by any rocks you can mine.
Now you can enable the Developer Mode in the settings panel:
Then in the menu bar that shows up, open the Game Explorer:
Go to the "Game Objects" tab and choose the closest rock to you so we can see if anything changes when a rock is mined:
After mining the rock, press refresh and select the same rock again:
As you can see, a few things did change: the rock's ID, model colors, modified colors, and index. To avoid hardcoding any specific rock ids, since we don't care what type of rock it is, I think we should just check for non-null model colors.
MiningTask.java
Points of Interest:
accept(): This is used by DreamBot to decide if it should run this task's execute method.
execute(): This is the method called whenever the task runs.
Dropping the Inventory
With the mining task finished, it'll mine until the inventory is full, then just sit around waiting. If you enable input and drop a few ore, the script will pick right back up where it was and mine until it's full again.
Dropping our entire inventory is pretty easy to do, so our task's class file is really simple:
DropTask.java
We're Done!
With that, everything should now compile. Make sure your script's output goes to the (USER_HOME)/DreamBot/Scripts/ folder, then run the script in the client and it should start working, paint and all:
You can find all of the source files attached in case you had trouble setting it up correctly
If you have any questions or have anything you'd like to see included for the end result, please post it below.
Thanks for reading!
Miner.zip
Part Two:
Long story short, I have decided to retire early from my OSRS scripting career and I feel bad leaving all this work I've done behind. So I figure I'll release the source code to everyone and maybe someone can learn something from it and then it isn't a complete waste of time lol.
Features:
Easy to use, robust anti-pattern system that randomizes various activities while botting. The current code will:
Examine random entities (objects, npcs, ground and inventory items etc)
Check a random stat (you can tell it which stats to check with antiban.setStatsToCheck(Skill.ATTACK, Skill.DEFENCE);)
Type something random (gibberish)
Move the mouse to a random location (and sometimes click the left or right button)
Walk to a random location nearby
Chop a random tree nearby
Click on a random entity (object, npc, item etc.)
Go AFK for a while (turns off autologin and random solvers temporarily)
Open your inventory
Open your stats menu
Open your magic menu
Open your combat menu (only if you have included Melee stats in your Stats to Check)
Move the mouse off-screen for a while
Move the camera randomly
Trigger a "DO_RANDOM" flag for custom script-specific anti-pattern measures (eg. drop junk early etc.)
It also includes ChatBot code (for retrieving CleverBot API responses). I will also include the code to my script-helper class just for anyone who is curious and maybe wants to steal some of my helper methods (such as randomized slot-pattern item dropping and general convenience methods).
The way it was designed is to be used as a final callback after your usual script logic is performed. When your character is idling or between actions, call antiban.antiBan() to perform any of the given actions at random.
Enjoy guys have fun.
Script Example:
package ZenTester;
import org.dreambot.api.script.AbstractScript;
import org.dreambot.api.script.Category;
import org.dreambot.api.script.ScriptManifest;
import java.awt.*;
@ScriptManifest(category = Category.MISC, name = "ZenTester", author = "Zenarchist", version = 1.0, description = "For testing")
public class Main extends AbstractScript {
// Declare anti-ban instance
private ZenAntiBan antiban;
@Override
public void onStart() {
// Initialize anti-ban instance
antiban = new ZenAntiBan(this);
}
@Override
public int onLoop() {
// Check for random flag (for adding extra customized anti-ban features)
if(antiban.doRandom())
log("Script-specific random flag triggered");
// Call anti-ban (returns a wait time after performing any actions)
return antiban.antiBan();
}
@Override
// Draw anti-ban info to the screen
public void onPaint(Graphics g) {
g.drawString("Anti-Ban Status: " + (antiban.getStatus().equals("") ? "Inactive" : antiban.getStatus()), 10, 100);
}
}
ZenAntiBan.java:
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.