示例#1
0
        public static void Pulse()
        {
            if (_GeneratedPath == null)
                return;

            if (_GeneratedPath.Count == 0)
            {
                IsCorpseRunning = false;
                Destination = Location.Zero;
                _GeneratedPath = null;
                stuckCheckTimer = DateTime.MinValue;
                return;
            }

            if (SleepTime >= DateTime.Now)
                return;

            SleepTime = DateTime.Now + TimeSpan.FromMilliseconds(100);

            var nextLocation = _GeneratedPath.Peek();
            if (nextLocation != null && nextLocation != default(Location))
            {
                if (Unstuck == null)
                    Unstuck = new AutoStuckHandler(loc => Manager.LocalPlayer.Location.DistanceTo(nextLocation) <= 3f, nextLocation);

                MoveTo(nextLocation);

                if (Manager.LocalPlayer.Location.DistanceTo(nextLocation) < 3f)
                {
                    // We have a new location, dequeue
                    // and reset the unstucker
                    nextLocation = _GeneratedPath.Dequeue();
                    Unstuck = new AutoStuckHandler((loc) => Manager.LocalPlayer.Location.DistanceTo(nextLocation) <= 3f, nextLocation);
                }
            }

            if (Manager.LocalPlayer.Location.Distance2D(_lastLocation) >= .20) //.19???
            {
                Status = MovementStatus.Moving;
                _lastLocation = Manager.LocalPlayer.Location;
                stuckCheckTimer = DateTime.Now + TimeSpan.FromMilliseconds(1500);
                Manager.LocalPlayer.StopMoving(); // TODO: Implement MovementFlags (SetControlBits and that shit)
                return;
            }
            else
            {
                if (stuckCheckTimer <= DateTime.Now)
                {
                    Status = MovementStatus.Stuck;
                    if (Unstuck != null && Unstuck.Remaining > 0)
                    {
                        Log.WriteLine("Trying to unstuck (#{0}).", ((Unstuck.Total - Unstuck.Remaining)+1));
                        StopMoving();
                        Unstuck.Next();
                        stuckCheckTimer = DateTime.Now + TimeSpan.FromMilliseconds(1500);
                    }
                    else
                    {
                        Manager.LocalPlayer.StopCTM();
                        StopMoving();
                        Log.WriteLine("Unable to unstuck, stopping all movement!");
                    }
                }
            }
            _lastLocation = Manager.LocalPlayer.Location;
        }
示例#2
0
        public static void Pulse()
        {
            if (_GeneratedPath == null)
            {
                return;
            }

            if (_GeneratedPath.Count == 0)
            {
                IsCorpseRunning = false;
                Destination     = Location.Zero;
                _GeneratedPath  = null;
                stuckCheckTimer = DateTime.MinValue;
                return;
            }

            if (SleepTime >= DateTime.Now)
            {
                return;
            }

            SleepTime = DateTime.Now + TimeSpan.FromMilliseconds(100);

            var nextLocation = _GeneratedPath.Peek();

            if (nextLocation != null && nextLocation != default(Location))
            {
                if (Unstuck == null)
                {
                    Unstuck = new AutoStuckHandler(loc => Manager.LocalPlayer.Location.DistanceTo(nextLocation) <= 3f, nextLocation);
                }

                MoveTo(nextLocation);

                if (Manager.LocalPlayer.Location.DistanceTo(nextLocation) < 3f)
                {
                    // We have a new location, dequeue
                    // and reset the unstucker
                    nextLocation = _GeneratedPath.Dequeue();
                    Unstuck      = new AutoStuckHandler((loc) => Manager.LocalPlayer.Location.DistanceTo(nextLocation) <= 3f, nextLocation);
                }
            }

            if (Manager.LocalPlayer.Location.Distance2D(_lastLocation) >= .20) //.19???
            {
                Status          = MovementStatus.Moving;
                _lastLocation   = Manager.LocalPlayer.Location;
                stuckCheckTimer = DateTime.Now + TimeSpan.FromMilliseconds(1500);
                Manager.LocalPlayer.StopMoving(); // TODO: Implement MovementFlags (SetControlBits and that shit)
                return;
            }
            else
            {
                if (stuckCheckTimer <= DateTime.Now)
                {
                    Status = MovementStatus.Stuck;
                    if (Unstuck != null && Unstuck.Remaining > 0)
                    {
                        Log.WriteLine("Trying to unstuck (#{0}).", ((Unstuck.Total - Unstuck.Remaining) + 1));
                        StopMoving();
                        Unstuck.Next();
                        stuckCheckTimer = DateTime.Now + TimeSpan.FromMilliseconds(1500);
                    }
                    else
                    {
                        Manager.LocalPlayer.StopCTM();
                        StopMoving();
                        Log.WriteLine("Unable to unstuck, stopping all movement!");
                    }
                }
            }
            _lastLocation = Manager.LocalPlayer.Location;
        }