public static IEnumerable <Obj_AI_Hero> GetTargets(float range,
                                                           DamageType damageType = DamageType.True,
                                                           bool ignoreShields    = true,
                                                           Vector3 from          = default(Vector3),
                                                           IEnumerable <Obj_AI_Hero> ignoredChampions = null)
        {
            try
            {
                Weights.Range = Math.Max(range, Weights.Range);

                var selectedTarget = Selected.GetTarget(range, damageType, ignoreShields, from);
                if (selectedTarget != null)
                {
                    return(new List <Obj_AI_Hero> {
                        selectedTarget
                    });
                }

                range = Mode == TargetSelectorModeType.Weights && ForceFocus ? Weights.Range : range;

                var targets =
                    Humanizer.FilterTargets(Targets.Items, from, range)
                    .Where(
                        h => ignoredChampions == null || ignoredChampions.All(i => i.NetworkId != h.Hero.NetworkId))
                    .Where(h => IsValidTarget(h.Hero, range, damageType, ignoreShields, from))
                    .ToList();

                if (targets.Count > 0)
                {
                    var t = GetOrderedChampions(targets).ToList();
                    if (t.Count > 0)
                    {
                        if (Selected.Target != null && Focus && t.Count > 1)
                        {
                            t = t.OrderByDescending(x => x.Hero.NetworkId.Equals(Selected.Target.NetworkId)).ToList();
                        }
                        return(t.Select(h => h.Hero).ToList());
                    }
                }
            }
            catch (Exception ex)
            {
                Global.Logger.AddItem(new LogItem(ex));
            }
            return(new List <Obj_AI_Hero>());
        }
 public static Obj_AI_Hero GetTarget(float range,
                                     DamageType damageType = DamageType.True,
                                     bool ignoreShields    = true,
                                     Vector3 from          = default(Vector3),
                                     IEnumerable <Obj_AI_Hero> ignoredChampions = null)
 {
     try
     {
         var targets = GetTargets(range, damageType, ignoreShields, from, ignoredChampions);
         return(targets != null?targets.FirstOrDefault() : null);
     }
     catch (Exception ex)
     {
         Global.Logger.AddItem(new LogItem(ex));
     }
     return(null);
 }
 internal static bool IsValidTarget(Obj_AI_Hero target,
                                    float range,
                                    DamageType damageType,
                                    bool ignoreShields = true,
                                    Vector3 from       = default(Vector3))
 {
     try
     {
         return(target.IsValidTarget() &&
                target.Distance(
                    (from.Equals(default(Vector3)) ? ObjectManager.Player.ServerPosition : from), true) <
                Math.Pow((range <= 0 ? Orbwalking.GetRealAutoAttackRange(target) : range), 2) &&
                !Invulnerable.Check(target, damageType, ignoreShields));
     }
     catch (Exception ex)
     {
         Global.Logger.AddItem(new LogItem(ex));
     }
     return(false);
 }
 internal static bool IsValidTarget(Obj_AI_Hero target,
     float range,
     DamageType damageType,
     bool ignoreShields = true,
     Vector3 from = default(Vector3))
 {
     try
     {
         return target.IsValidTarget() &&
                target.Distance(
                    (from.Equals(default(Vector3)) ? ObjectManager.Player.ServerPosition : from), true) <
                Math.Pow((range <= 0 ? Orbwalking.GetRealAutoAttackRange(target) : range), 2) &&
                !Invulnerable.Check(target, damageType, ignoreShields);
     }
     catch (Exception ex)
     {
         Global.Logger.AddItem(new LogItem(ex));
     }
     return false;
 }
        public static IEnumerable<Obj_AI_Hero> GetTargets(float range,
            DamageType damageType = DamageType.True,
            bool ignoreShields = true,
            Vector3 from = default(Vector3),
            IEnumerable<Obj_AI_Hero> ignoredChampions = null)
        {
            try
            {
                Weights.Range = Math.Max(range, Weights.Range);

                var selectedTarget = Selected.GetTarget(range, damageType, ignoreShields, from);
                if (selectedTarget != null)
                {
                    return new List<Obj_AI_Hero> { selectedTarget };
                }

                range = Mode == TargetSelectorModeType.Weights && ForceFocus ? Weights.Range : range;

                var targets =
                    Humanizer.FilterTargets(Targets.Items, from, range)
                        .Where(
                            h => ignoredChampions == null || ignoredChampions.All(i => i.NetworkId != h.Hero.NetworkId))
                        .Where(h => IsValidTarget(h.Hero, range, damageType, ignoreShields, from))
                        .ToList();

                if (targets.Count > 0)
                {
                    var t = GetOrderedChampions(targets).ToList();
                    if (t.Count > 0)
                    {
                        if (Selected.Target != null && Focus && t.Count > 1)
                        {
                            t = t.OrderByDescending(x => x.Hero.NetworkId.Equals(Selected.Target.NetworkId)).ToList();
                        }
                        return t.Select(h => h.Hero).ToList();
                    }
                }
            }
            catch (Exception ex)
            {
                Global.Logger.AddItem(new LogItem(ex));
            }
            return new List<Obj_AI_Hero>();
        }
 public static Obj_AI_Hero GetTarget(float range,
     DamageType damageType = DamageType.True,
     bool ignoreShields = true,
     Vector3 from = default(Vector3),
     IEnumerable<Obj_AI_Hero> ignoredChampions = null)
 {
     try
     {
         var targets = GetTargets(range, damageType, ignoreShields, from, ignoredChampions);
         return targets != null ? targets.FirstOrDefault() : null;
     }
     catch (Exception ex)
     {
         Global.Logger.AddItem(new LogItem(ex));
     }
     return null;
 }
 public static IEnumerable<Targets.Item> FilterTargets(IEnumerable<Targets.Item> targets,
     float range,
     DamageType damageType,
     bool ignoreShields,
     Vector3 from)
 {
     var target = targets.FirstOrDefault();
     if (target != null &&
         TargetSelector.IsValidTarget(target.Hero, ForceFocus ? Range : range, damageType, ignoreShields, from))
     {
         return new List<Targets.Item> { target };
     }
     return new List<Targets.Item>();
 }