Exemple #1
0
        public void Trigger(MouseInjector injector, Point current, Point target, Rectangle region, Esp esp, ref bool aim, double dt)
        {
            time += dt;

            if (Conditions != Condition.Never)
            {
                if (target != Point.Empty && esp != null)
                {
                    esp.Add(new CircleShape(new Point(target.X, target.Y), Proximity, Color.Transparent, Color.Yellow, 1));
                }

                bool trigger = (aim == true && (Conditions & Condition.WhenAiming) != 0) ||
                               (aim == false && (Conditions & Condition.WhenNotAiming) != 0);

                if (trigger && time >= TriggerRate)
                {
                    var distanceSq = current.DistanceSq(target);
                    if (distanceSq <= Proximity * Proximity)
                    {
                        injector.Click(TriggerButton, 50);
                        time = 0.0;
                        if (ContinueAiming == false)
                        {
                            aim = false;
                        }
                    }
                }
            }
        }
Exemple #2
0
        public void Aim(MouseInjector injector, Point target, Point position, double dt)
        {
            this.target   = target;
            this.position = position;

            Move(injector, dt);
        }
Exemple #3
0
 public void Tick(MouseInjector injector, bool aiming, double dt)
 {
     if (aiming == false)
     {
         Clear();
     }
 }
Exemple #4
0
        private static void Flick(MouseInjector injector, Point target, Point position, double speed, double horizontalSensitivity, double verticalSensitivity, int timestepMs, int triggerDelayMs, int cooldownMs, bool trigger)
        {
            double ex = 0.0;
            double ey = 0.0;

            var screenx = target.X - position.X;
            var screeny = target.Y - position.Y;

            var mousex = screenx * horizontalSensitivity;
            var mousey = screeny * verticalSensitivity;

            var distance = Math.Sqrt(mousex * mousex + mousey * mousey);
            var time     = distance / speed;

            var frames = (int)Math.Ceiling((time * 1000) / timestepMs);

            if (frames > 0)
            {
                for (int i = 0; i < frames; ++i)
                {
                    var dx = ex + (double)mousex / frames;
                    var dy = ey + (double)mousey / frames;

                    var px = (int)Math.Round(dx);
                    var py = (int)Math.Round(dy);

                    ex = dx - px;
                    ey = dy - py;

                    if (px != 0 || py != 0)
                    {
                        injector.Move(px, py);
                    }

                    if (i < frames - 1)
                    {
                        Thread.Sleep(timestepMs);
                    }
                    else if (trigger)
                    {
                        Thread.Sleep(triggerDelayMs);
                        var rng = new Random();
                        injector.Click(0, rng.Next(50, 80));
                    }
                }
            }
            else if (trigger)
            {
                Thread.Sleep(triggerDelayMs);
                var rng = new Random();
                injector.Click(0, rng.Next(50, 80));
            }

            if (cooldownMs > 0)
            {
                Thread.Sleep(cooldownMs);
            }
        }
Exemple #5
0
 public void Aim(MouseInjector injector, Point target, Point position, double dt)
 {
     if (flick && target.IsEmpty == false && (thread == null || thread.IsAlive == false))
     {
         flick  = continueAiming; // Wait for aim key/button to be pressed again?
         thread = new Thread(() => Flick(injector, target, position, ms, hs, vs, ts, td, cd, trigger));
         thread.Start();
     }
 }
Exemple #6
0
 public void Tick(MouseInjector injector, bool aiming, double dt)
 {
     if (aiming)
     {
         Move(injector, dt);
     }
     else
     {
         Clear();
     }
 }
Exemple #7
0
        public Bot()
        {
            grabber  = null;
            detector = null;
            tracker  = null;
            selector = null;
            injector = null;
            aimer    = null;
            trigger  = null;

            stopwatch = new Stopwatch();

            activationKey    = ActivationKeys.None;
            activationButton = ActivationButtons.None;

            process   = null;
            time      = 0.0;
            activated = false;
            disposed  = false;
        }
Exemple #8
0
        private void Move(MouseInjector injector, double dt)
        {
            time += dt;

            if (target != Point.Empty)
            {
                var errorx = target.X - position.X;
                var errory = target.Y - position.Y;

                var dx = pidx.Tick(errorx, time);
                var dy = pidy.Tick(errory, time);

                var xs = dx / dt;
                var ys = dy / dt;

                if (errorx * errorx < cxd * cxd)
                {
                    xs *= (errorx * errorx) / (cxd * cxd);
                }
                if (errory > 0 && errory * errory < cyud * cyud)
                {
                    ys *= (errory * errory) / (cyud * cyud);
                }
                if (errory < 0 && errory * errory < cydd * cydd)
                {
                    ys *= (errory * errory) / (cydd * cydd);
                }

                var xa = (xs - pxs) / dt;
                var ya = (ys - pys) / dt;

                if (Math.Sign(xs) * Math.Sign(pxs) >= 0)
                {
                    // Same direction.
                    if (Math.Abs(xs) >= Math.Abs(pxs))
                    {
                        // Acceleration.
                        if (mxa > 0.0)
                        {
                            if (xa > mxa)
                            {
                                xa = mxa;
                            }
                            if (xa < -mxa)
                            {
                                xa = -mxa;
                            }
                        }
                    }
                    else
                    {
                        // Deceleration
                        if (mxd > 0.0)
                        {
                            if (xa > mxd)
                            {
                                xa = mxd;
                            }
                            if (xa < -mxd)
                            {
                                xa = -mxd;
                            }
                        }
                    }

                    if (Math.Abs(ys) >= Math.Abs(pys))
                    {
                        // Acceleration.
                        if (mxa > 0.0)
                        {
                            if (ya > mya)
                            {
                                ya = mya;
                            }
                            if (ya < -mya)
                            {
                                ya = -mya;
                            }
                        }
                    }
                    else
                    {
                        // Deceleration
                        if (mxd > 0.0)
                        {
                            if (ya > myd)
                            {
                                ya = myd;
                            }
                            if (ya < -myd)
                            {
                                ya = -myd;
                            }
                        }
                    }
                }
                else
                {
                    // Different direction.
                    // We need to decelerate to a stop.
                    if (mxa > 0.0)
                    {
                        if (xa > mxd)
                        {
                            xa = mxd;
                        }
                        if (xa < -mxd)
                        {
                            xa = -mxd;
                        }
                    }

                    if (mxd > 0.0)
                    {
                        if (ya > myd)
                        {
                            ya = myd;
                        }
                        if (ya < -myd)
                        {
                            ya = -myd;
                        }
                    }
                }

                xs = pxs + xa * dt;
                ys = pys + ya * dt;

                if (xs > mxs)
                {
                    xs = mxs;
                }
                if (xs < -mxs)
                {
                    xs = -mxs;
                }
                if (ys > mys)
                {
                    ys = mys;
                }
                if (ys < -mys)
                {
                    ys = -mys;
                }

                dx = xs * dt + ex;
                dy = ys * dt + ey;

                var px = (int)Math.Round(dx);
                var py = (int)Math.Round(dy);

                ex = dx - px;
                ey = dy - py;

                pxs = xs;
                pys = ys;

                if (px != 0 || py != 0)
                {
                    injector.Move(px, py);
                }
            }
            else
            {
                Clear();
            }

            time = 0.0;
        }
Exemple #9
0
        private void Move(MouseInjector injector, bool canFlick, double dt)
        {
            if (ready && (thread == null || thread.IsAlive == false))
            {
                time += dt;

                if (target != Point.Empty)
                {
                    var errorx = target.X - position.X;
                    var errory = target.Y - position.Y;

                    // Determine speed using proportional control.
                    var dx = errorx * gain * time * 100.0 + ex;
                    var dy = errory * gain * time * 100.0 + ey;

                    var xs = dx / dt;
                    var ys = dy / dt;

                    if (xs > ms)
                    {
                        xs = ms;
                    }
                    if (xs < -ms)
                    {
                        xs = -ms;
                    }
                    if (ys > ms)
                    {
                        ys = ms;
                    }
                    if (ys < -ms)
                    {
                        ys = -ms;
                    }

                    // Can we flick?
                    if (canFlick && ft > 0.0 || Math.Sqrt(errorx * errorx + errory * errory) <= fr)
                    {
                        if (ft >= fd * 0.001)
                        {
                            ft     = 0.0;
                            ready  = continueAiming; // Wait for aim key/button to be pressed again?
                            thread = new Thread(() => Flick(injector, target, position, ms, hs, vs, ts, td, cd, trigger));
                            thread.Start();
                        }
                        else
                        {
                            ft += dt;
                        }
                    }
                    else // Move using proportional control.
                    {
                        dx = xs * dt;
                        dy = ys * dt;

                        var px = (int)Math.Round(dx);
                        var py = (int)Math.Round(dy);

                        ex = dx - px;
                        ey = dy - py;

                        if (px != 0 || py != 0)
                        {
                            injector.Move(px, py);
                        }
                    }
                }
                else
                {
                    ex = 0.0;
                    ey = 0.0;
                }
            }

            time = 0.0;
        }