Here's a version without any deprecated methods or compilation errors! Going to be messing around with this so I figured I would post this for usability.
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!
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:
This can be solved by calling this line before you initialize your gui:
JFrame.setDefaultLookAndFeelDecorated(false);
On another note, I dislike the library because of 3 reasons:
The close button in DreamHeader exits the client. You should make the following change:
//closeBtn.addActionListener(l -> System.exit(0));
closeBtn.addActionListener(l -> SwingUtilities.windowForComponent(this).dispose());
The DreamBot logo is fetched from the internet for no reason at all. Because of this, the gui initialization must be wrapped in try-catch statement (ImageIO exception) and there is this redundant class VisualTools that resizes the image from the internet. Instead, the library should get the DreamBot icon from the client's JFrame as following:
((JFrame) SwingUtilities.windowForComponent(Instance.getCanvas())).getIconImage()
This library is commonly used in SDN scripts and I cringe every time I see these "flaws" in new scripts to be released.
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.