Esempio n. 1
0
        private static Vector3 GetMovementPos(AttackableUnit Gtarget, bool IsSafe)
        {
            Vector3 pos           = Vector3.Zero;
            Vector3 predictionPos = Vector3.Zero;

            try
            {
                predictionPos = Prediction.GetPrediction((Obj_AI_Base)Gtarget, 2).UnitPosition;
            }
            catch (Exception)
            {
                predictionPos = Gtarget.Position;
            }

            if (!Pet.IsMelee)
            {
                if (Pet.AttackRange < player.Distance(Gtarget) && !IsSafe)
                {
                    pos = Gtarget.Position.Extend(player.Position, Pet.AttackRange);
                }
                else
                {
                    var safePos =
                        CombatHelper.PointsAroundTheTargetOuterRing(
                            Gtarget.Position, Pet.AttackRange + Gtarget.BoundingRadius)
                        .Where(p => !p.IsWall() && p.IsValid())
                        .OrderByDescending(p => !p.UnderTurret(true))
                        .ThenBy(p => p.CountEnemiesInRange(700))
                        .FirstOrDefault();
                    pos = Gtarget.Position.Extend(safePos, Pet.AttackRange);
                }
            }
            else
            {
                if (IsSafe)
                {
                    pos = Gtarget.Position.Extend(predictionPos, Pet.AttackRange);
                }
                else
                {
                    pos = Gtarget.Position.Extend(player.Position, Pet.AttackRange);
                }
            }
            return(pos);
        }