public static List <Obj_AI_Hero> GetTargets(float range,
                                                    DamageType damageType = DamageType.True,
                                                    bool ignoreShields    = true,
                                                    Vector3 from          = default(Vector3),
                                                    IEnumerable <Obj_AI_Hero> ignoredChampions = null)
        {
            try
            {
                var assassin = _menu != null && _menu.Item(_menu.Name + ".assassin-mode.enabled").GetValue <bool>();
                var aRange   = assassin ? _menu.Item(_menu.Name + ".assassin-mode.range").GetValue <Slider>().Value : range;
                _debugRange = aRange > _debugRange ? aRange : _debugRange;

                if (_menu != null && SelectedTarget != null &&
                    IsValidTarget(
                        SelectedTarget,
                        _menu.Item(_menu.Name + ".force-focus-selected").GetValue <bool>() ? float.MaxValue : aRange,
                        DamageType.True, ignoreShields, from))
                {
                    return(new List <Obj_AI_Hero> {
                        SelectedTarget
                    });
                }

                var targets =
                    GameObjects.EnemyHeroes.Where(
                        h => ignoredChampions == null || ignoredChampions.All(i => i.NetworkId != h.NetworkId))
                    .Where(h => IsValidTarget(h, aRange, damageType, ignoreShields, from))
                    .ToList();

                if (targets.Count > 0)
                {
                    if (assassin)
                    {
                        var assassinTargets =
                            targets.Where(h => _menu.Item(_menu.Name + ".assassin-mode").GetValue <bool>()).ToList();
                        if (assassinTargets.Any())
                        {
                            targets = assassinTargets;
                        }
                    }
                    var t = GetChampionsByMode(targets).ToList();
                    if (t.Any())
                    {
                        _lastTarget = t[0];
                    }
                    return(t);
                }
            }
            catch (Exception ex)
            {
                Global.Logger.AddItem(new LogItem(ex));
            }
            return(new List <Obj_AI_Hero>());
        }
 private static bool IsValidTarget(Obj_AI_Hero target,
                                   float range,
                                   DamageType damageType,
                                   bool ignoreShields = true,
                                   Vector3 from       = default(Vector3))
 {
     return(target.IsValidTarget() &&
            target.Distance((from.Equals(default(Vector3)) ? ObjectManager.Player.ServerPosition : from), true) <
            Math.Pow((range <= 0 ? Orbwalking.GetRealAutoAttackRange(target) : range), 2) &&
            !Invulnerable.HasBuff(target, damageType, ignoreShields));
 }
Exemple #3
0
        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>());
        }
Exemple #4
0
 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);
 }
Exemple #5
0
 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;
 }
 private static bool IsValidTarget(Obj_AI_Hero target,
     float range,
     DamageType damageType,
     bool ignoreShields = true,
     Vector3 from = default(Vector3))
 {
     return target.IsValidTarget() &&
            target.Distance((from.Equals(default(Vector3)) ? ObjectManager.Player.ServerPosition : from), true) <
            Math.Pow((range <= 0 ? Orbwalking.GetRealAutoAttackRange(target) : range), 2) &&
            !Invulnerable.HasBuff(target, damageType, ignoreShields);
 }
        public static List<Obj_AI_Hero> GetTargets(float range,
            DamageType damageType = DamageType.True,
            bool ignoreShields = true,
            Vector3 from = default(Vector3),
            IEnumerable<Obj_AI_Hero> ignoredChampions = null)
        {
            try
            {
                var assassin = _menu != null && _menu.Item(_menu.Name + ".assassin-mode.enabled").GetValue<bool>();
                var aRange = assassin ? _menu.Item(_menu.Name + ".assassin-mode.range").GetValue<Slider>().Value : range;
                _debugRange = aRange > _debugRange ? aRange : _debugRange;

                if (_menu != null && SelectedTarget != null &&
                    IsValidTarget(
                        SelectedTarget,
                        _menu.Item(_menu.Name + ".force-focus-selected").GetValue<bool>() ? float.MaxValue : aRange,
                        DamageType.True, ignoreShields, from))
                {
                    return new List<Obj_AI_Hero> { SelectedTarget };
                }

                var targets =
                    GameObjects.EnemyHeroes.Where(
                        h => ignoredChampions == null || ignoredChampions.All(i => i.NetworkId != h.NetworkId))
                        .Where(h => IsValidTarget(h, aRange, damageType, ignoreShields, from))
                        .ToList();

                if (targets.Count > 0)
                {
                    if (assassin)
                    {
                        var assassinTargets =
                            targets.Where(h => _menu.Item(_menu.Name + ".assassin-mode").GetValue<bool>()).ToList();
                        if (assassinTargets.Any())
                        {
                            targets = assassinTargets;
                        }
                    }
                    var t = GetChampionsByMode(targets).ToList();
                    if (t.Any())
                    {
                        _lastTarget = t[0];
                    }
                    return t;
                }
            }
            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<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 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>();
 }