Jump to content

Welcome to DreamBot!

Download for Free

Supercharge Your Bots

Run unlimited bots today using DreamBot's Covert Mode and
stay more protected.

Upgrade Now
Frequently Asked Questions
  • Are you not able to open the client? Make sure you have Java installed
  • 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 gold? You can purchase vouchers from other users
  • Try asking for help in the chatbox
osrs gold
Bottinghub.com

Interested in advertising your business? Reach out today!

holic

EaseMouse -Another Custom Mouse Movement Algorithm

Recommended Posts

Another snippet for you all

EaseMouse, originally named brakeWindMouse, is another port of a SCAR/Simba mouse movement algorithm. With EaseMouse, movement speed is determined by distance (as well as the gravity variable) and slows down as it approaches its destination hence the rename to EaseMouse

The original brakeWindMouse comes from the Aerolib include for Simba/SCAR which is a tweaked implementation of Benland100's WindMouse

I figured the more algorithms the better.

void easeMouse(Point point, int ranX, int ranY, boolean reverse)

point   The destination point
ranX    Random offset for X coord
ranY    Random offset for Y coord
reverse if true, speed starts slow and increases through the first 15% of the path.

To use it, simply add the file EaseMouse.java to your project and add the following to your onStart method:

Client.getInstance().setMouseMovementAlgorithm(new EaseMouse());

All credits go to Flight and Benjamin J. Land a.k.a. BenLand100 of Villavu

EaseMouse.java:

/**
 * EaseMouse (Originally "brakeWindMouse") from Aerolib by Benland100 & Flight
 * 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.Math.*;
import static org.dreambot.api.methods.MethodProvider.sleep;

public class EaseMouse implements MouseMovementAlgorithm {

    private int _mouseSpeed = MouseSettings.getSpeed() > 15 ? MouseSettings.getSpeed() - 10 : 15;
    private int _mouseSpeedLow = round(_mouseSpeed / 2);
    private int _mouseGravity = Calculations.random(5, 10);

    private static double distance(double x1, double y1, double x2, double y2) {
        return sqrt((pow((round(x2) - round(x1)), 2) + pow((round(y2) - round(y1)), 2)));
    }

    @Override
    public boolean handleMovement(AbstractMouseDestination abstractMouseDestination) {
        //Get a suitable point for the mouse's destination
        Point suitPos = abstractMouseDestination.getSuitablePoint();
        easeMouse(suitPos, Calculations.random(1,3), Calculations.random(1,3), (Calculations.random(4) == 1));
        return distance(Client.getMousePosition(), suitPos) < 1;
    }


    /*******************************************************************************
     * void easeMouse(Point point, int ranX, int ranY, boolean reverse)
     * By: holic
     * Description: Mouse speed decreases as it approaches destination point.
     * @param point   The destination point
     * @param ranX    Random offset for X coord
     * @param ranY    Random offset for Y coord
     * @param reverse if true, speed starts slow and increases through the first 15% of the path.
     *******************************************************************************/
    public void easeMouse(Point point, int ranX, int ranY, boolean reverse) {
        double randSpeed;
        Point curPoint = Client.getMousePosition();
        randSpeed = (Calculations.random(_mouseSpeedLow, _mouseSpeed) / 8.0);
        easeWindMouse(curPoint.x, curPoint.y, Calculations.random(point.x, point.x + ranX), Calculations.random(point.y, point.y + ranY), _mouseGravity, Calculations.random(3, 5), 3 * randSpeed, reverse);
        _mouseGravity = Calculations.random(5, 10);
    }

    /*******************************************************************************
     * void easeWindMouse(double xs, double ys, double xe, double ye, double gravity,
     * double wind, double targetArea, boolean reverse)
     * By: Flight & Benland100
     * Description: Mouse movement based on distance to determine speed, slows as it
     * approaches destination point.
     * @param xs         The start point x
     * @param ys         The start point y
     * @param xs         The destination point x
     * @param ys         The destination point y
     * @param gravity    How hard to pull mouse to target
     * @param wind       How much to deviate from destination path
     * @param targetArea Accuracy of target, area in which target is accepted
     * @param reverse    if true, speed starts slow and increases through the first 15% of the path.
     *******************************************************************************/
    public void easeWindMouse(double xs, double ys, double xe, double ye, double gravity, double wind, double targetArea, boolean reverse) {
        long T;
        double veloX = 0, veloY = 0, windX = 0, windY = 0, veloMag, dist, randomDist, D = 0;
        int lastX, lastY, W, TDist;
        double sqrt2, sqrt3, sqrt5, PDist, maxStep, dModA, dModB, nModA = 0, nModB = 0;

        sqrt2 = sqrt(2);
        sqrt3 = sqrt(3);
        sqrt5 = sqrt(5);

        TDist = (int) distance(round(xs), round(ys), round(xe), round(ye));
        if (TDist < 1) {
            TDist = 1;
        }

        dModA = 0.88;
        dModB = 0.95;

        if (TDist > 220) {
            nModA = 0.08;
            nModB = 0.04;
        } else if (TDist <= 220) {
            nModA = 0.20;
            nModB = 0.10;
        }

        T = System.currentTimeMillis();
        do {
            if (System.currentTimeMillis() - T > 5000) {
                break;
            }

            dist = hypot(xs - xe, ys - ye);
            wind = min(wind, dist);
            if (dist < 1) {
                dist = 1;
            }
            PDist = (dist / TDist);
            if (PDist < 0.01) {
                PDist = 0.01;
            }

            if (reverse) {

                if (PDist <= dModA) {
                    D = (round((round(dist) * 0.3)) / 5);
                    if (D < 20) {
                        D = 20;
                    }

                } else if (PDist > dModA) {
                    if (PDist < dModB) {
                        D = Calculations.random(5, 8);
                    } else if (PDist >= dModB) {
                        D = Calculations.random(3, 4);
                    }
                }
            }

            if (PDist >= nModA) {
                D = (round((round(dist) * 0.3)) / 5);
                if (D < 20) {
                    D = 20;
                }
            } else if (PDist < nModA) {
                if (PDist >= nModB) {
                    D = Calculations.random(5, 8);
                } else if (PDist < nModB) {
                    D = Calculations.random(3, 4);
                }
            }

            if (D <= round(dist)) {
                maxStep = D;
            } else {
                maxStep = round(dist);
            }
            maxStep = maxStep * 0.85;

            if (dist >= targetArea) {
                windX = windX / sqrt3 + (Calculations.random((int) (round(wind) * 2 + 1)) - wind) / sqrt5;
                windY = windY / sqrt3 + (Calculations.random((int) (round(wind) * 2 + 1)) - wind) / sqrt5;
            } else {
                windX = windX / sqrt2;
                windY = windY / sqrt2;
            }

            veloX = veloX + windX;
            veloY = veloY + windY;
            veloX = veloX + gravity * (xe - xs) / dist;
            veloY = veloY + gravity * (ye - ys) / dist;

            if (hypot(veloX, veloY) > maxStep) {
                int tmp = maxStep > 2 ? Calculations.random((int) (round(maxStep) / 2)) : 1;
                randomDist = maxStep / 2.0 + tmp;
                veloMag = sqrt(veloX * veloX + veloY * veloY);
                veloX = (veloX / veloMag) * randomDist;
                veloY = (veloY / veloMag) * randomDist;
            }

            lastX = (int) round(xs);
            lastY = (int) round(ys);
            xs = xs + veloX;
            ys = ys + veloY;

            if (lastX != round(xs) || lastY != round(ys)) {
                Mouse.hop((int) round(xs), (int) round(ys));
            }

            W = (Calculations.random((round(100 / _mouseSpeed))) * 6);
            W = max(W, 5);
            if (reverse) {
                if (PDist > dModA) {
                    W = (int) round(W * 2.5);
                }
            } else {
                W = (int) round(W * 1.2);
            }
            sleep(W);
        } while (hypot(xs - xe, ys - ye) > 1);

        if (round(xe) != round(xs) || round(ye) != round(ys)) {
            Mouse.hop((int) round(xe), (int) round(ye));
        }
    }

    private double distance(Point p1, Point p2) {
        return sqrt((p2.y - p1.y) * (p2.y - p1.y) + (p2.x - p1.x) * (p2.x - p1.x));
    }
}

 

Share this post


Link to post
Share on other sites
32 minutes ago, Pseudo said:

Big up on the releases fam. Continuing on from what Neff said, do you have any stats or opinions as to whether the mouse algo has an effect on bans?

I don't have stats unfortunately, it's just from experience and looking at other clients as well

Share this post


Link to post
Share on other sites
1 minute ago, Neffarion said:

I don't have stats unfortunately, it's just from experience and looking at other clients as well

Yeah forgive my wording, I was more so querying if OP has any info on the subject, I'm inclined to lean towards what you're saying from personal experience too.

Share this post


Link to post
Share on other sites
28 minutes ago, Pseudo said:

Yeah forgive my wording, I was more so querying if OP has any info on the subject, I'm inclined to lean towards what you're saying from personal experience too.

I haven't done any extensive testing on it to see how it affects ban rates but can say anecdotally I haven't been banned on any accounts using WindMouse or EaseMouse to date. I've been using WM in my scripts for about a month and a bit, maybe more, for about 8hrs a day using one public script and the rest private scripts. That could be pure coincidence or the fact that I wrote my own scripts.

2 hours ago, Neffarion said:

Nice share!
I'm still wondering how much this matters though. I'm kinda skeptical that changing the algorithm does any noticeable difference to bans

Totally agree but I think it's important still to have options for the sake of variety. I think it really comes down to how you use the different algorithms, whether that's in setup or when you use which one.

For me, I'm only calling EaseMouse when my mouse is moving almost the entire screen to a small target so it eases into it otherwise it's always WindMouse/default depending on the "profile" the script created for that account.

Share this post


Link to post
Share on other sites

Depending what algos and winapi functions u use. Will determine ban rates. If you use real mouse driver vs fake one. they can find out. And some things ban faster than others. Just go from client to client on the web and ull see some get u banned uber quick while others fly under radar pretty good. be careful. just do what works.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...