示例#1
0
 /// <summary>
 ///     The <see cref="OnAction" /> invocator.
 /// </summary>
 /// <param name="e">
 ///     The event data.
 /// </param>
 internal void InvokeAction(OrbwalkingActionArgs e)
 {
     this.OnAction?.Invoke(MethodBase.GetCurrentMethod().DeclaringType, e);
 }
示例#2
0
        /// <inheritdoc />
        public override void Move(Vector3 position)
        {
            if (this.BlockOrdersUntilTick - Variables.TickCount > 0)
            {
                return;
            }

            if (!position.IsValid())
            {
                return;
            }

            if (Variables.TickCount - this.LastMovementOrderTick
                < this.Menu["advanced"]["delayMovement"].GetValue <MenuSlider>().Value)
            {
                return;
            }

            if (this.Menu["advanced"]["miscAttackSpeed"].GetValue <MenuBool>().Value &&
                (GameObjects.Player.AttackDelay < 1 / 2.6f) && this.TotalAutoAttacks % 3 != 0 &&
                !this.CanMove(500, true) && !this.MovementState)
            {
                return;
            }

            if (position.Distance(GameObjects.Player.Position)
                < GameObjects.Player.BoundingRadius
                + this.Menu["advanced"]["movementExtraHold"].GetValue <MenuSlider>().Value)
            {
                if (GameObjects.Player.Path.Length > 0)
                {
                    var eventStopArgs = new OrbwalkingActionArgs
                    {
                        Position = GameObjects.Player.ServerPosition, Process = true,
                        Type     = OrbwalkingType.StopMovement
                    };
                    this.InvokeAction(eventStopArgs);
                    if (eventStopArgs.Process)
                    {
                        GameObjects.Player.IssueOrder(GameObjectOrder.Stop, eventStopArgs.Position);
                        this.LastMovementOrderTick = Variables.TickCount - 70;
                    }
                }

                return;
            }

            if (position.Distance(GameObjects.Player.ServerPosition) < GameObjects.Player.BoundingRadius)
            {
                position = GameObjects.Player.ServerPosition.Extend(
                    position,
                    GameObjects.Player.BoundingRadius + this.random.Next(0, 51));
            }

            var maximumDistance = this.Menu["advanced"]["movementMaximumDistance"].GetValue <MenuSlider>().Value;

            if (position.Distance(GameObjects.Player.ServerPosition) > maximumDistance)
            {
                position = GameObjects.Player.ServerPosition.Extend(
                    position,
                    maximumDistance + 25 - this.random.Next(0, 51));
            }

            if (this.Menu["advanced"]["movementRandomize"].GetValue <MenuBool>().Value &&
                GameObjects.Player.Distance(position) > 350f)
            {
                var rAngle = 2D * Math.PI * this.random.NextDouble();
                var radius = GameObjects.Player.BoundingRadius / 2f;
                var x      = (float)(position.X + (radius * Math.Cos(rAngle)));
                var y      = (float)(position.Y + (radius * Math.Sin(rAngle)));
                position = new Vector3(x, y, NavMesh.GetHeightForPosition(x, y));
            }

            var angle       = 0f;
            var currentPath = GameObjects.Player.GetWaypoints();

            if (currentPath.Count > 1 && currentPath.PathLength() > 100)
            {
                var movePath = GameObjects.Player.GetPath(position);
                if (movePath.Length > 1)
                {
                    var v1 = currentPath[1] - currentPath[0];
                    var v2 = movePath[1] - movePath[0];
                    angle = v1.AngleBetween(v2);
                    var distance = movePath.Last().DistanceSquared(currentPath.Last());
                    if ((angle < 10 && distance < 500 * 500) || distance < 50 * 50)
                    {
                        return;
                    }
                }
            }

            if (Variables.TickCount - this.LastMovementOrderTick < 70 + Math.Min(60, Game.Ping) && angle < 60)
            {
                return;
            }

            if (angle >= 60 && Variables.TickCount - this.LastMovementOrderTick < 60)
            {
                return;
            }

            var eventArgs = new OrbwalkingActionArgs
            {
                Position = position, Process = true, Type = OrbwalkingType.Movement
            };

            this.InvokeAction(eventArgs);

            if (eventArgs.Process)
            {
                GameObjects.Player.IssueOrder(GameObjectOrder.MoveTo, eventArgs.Position);
                this.LastMovementOrderTick = Variables.TickCount;
            }
        }