Exemplo n.º 1
0
        internal static void Flee()
        {
            if (!ES.CatForm() && ES.Spells["Aspect"].IsReady() && ES.SpellTimer["Pounce"].IsReady())
            {
                ES.Spells["Aspect"].Cast();
            }

            var wallCheck = ES.GetFirstWallPoint(ES.Player.Position, Game.CursorPos);

            if (wallCheck != null)
            {
                wallCheck = ES.GetFirstWallPoint((Vector3)wallCheck, Game.CursorPos, 5);
            }

            var movePosition = wallCheck != null ? (Vector3)wallCheck : Game.CursorPos;

            var tempGrid           = NavMesh.WorldToGrid(movePosition.X, movePosition.Y);
            var fleeTargetPosition = NavMesh.GridToWorld((short)tempGrid.X, (short)tempGrid.Y);

            Obj_AI_Base target = null;

            var wallJumpPossible = false;

            if (ES.CatForm() && ES.SpellTimer["Pounce"].IsReady() && wallCheck != null)
            {
                var wallPosition = movePosition;

                var   direction     = (Game.CursorPos.To2D() - wallPosition.To2D()).Normalized();
                float maxAngle      = 80f;
                float step          = maxAngle / 20;
                float currentAngle  = 0;
                float currentStep   = 0;
                bool  jumpTriggered = false;

                while (true)
                {
                    if (currentStep > maxAngle && currentAngle < 0)
                    {
                        break;
                    }

                    if ((currentAngle == 0 || currentAngle < 0) && currentStep != 0)
                    {
                        currentAngle = (currentStep) * (float)Math.PI / 180;
                        currentStep += step;
                    }

                    else if (currentAngle > 0)
                    {
                        currentAngle = -currentAngle;
                    }

                    Vector3 checkPoint;

                    if (currentStep == 0)
                    {
                        currentStep = step;
                        checkPoint  = wallPosition + ES.Spells["Pounce"].Range * direction.To3D();
                    }

                    else
                    {
                        checkPoint = wallPosition + ES.Spells["Pounce"].Range * direction.Rotated(currentAngle).To3D();
                    }

                    if (checkPoint.IsWall())
                    {
                        continue;
                    }

                    wallCheck = ES.GetFirstWallPoint(checkPoint, wallPosition);

                    if (wallCheck == null)
                    {
                        continue;
                    }

                    var wallPositionOpposite = (Vector3)ES.GetFirstWallPoint((Vector3)wallCheck, wallPosition, 5);

                    if (ES.Player.GetPath(wallPositionOpposite).ToList().To2D().PathLength() -
                        ES.Player.Distance(wallPositionOpposite) > 200)
                    {
                        if (ES.Player.Distance(wallPositionOpposite) < ES.Spells["Pounce"].Range - ES.Player.BoundingRadius / 2)
                        {
                            ES.Spells["Pounce"].Cast(wallPositionOpposite);
                            jumpTriggered = true;
                            break;
                        }

                        else
                        {
                            wallJumpPossible = true;
                        }
                    }

                    else
                    {
                        Render.Circle.DrawCircle(Game.CursorPos, 35, Color.Red, 2);
                    }
                }

                if (!jumpTriggered)
                {
                    Orbwalking.Orbwalk(target, Game.CursorPos, 90f, 0f, false, false);
                }
            }

            else
            {
                Orbwalking.Orbwalk(target, Game.CursorPos, 90f, 0f, false, false);
                if (ES.CatForm() && ES.SpellTimer["Pounce"].IsReady())
                {
                    ES.Spells["Pounce"].Cast(Game.CursorPos);
                }
            }
        }