Ejemplo n.º 1
0
        private static void OnCorePreUpdate(EventArgs args)
        {
            try
            {
                if (_mainMenu == null || TargetSelector.Mode != TargetSelectorModeType.Weights)
                {
                    return;
                }

                var highestEnabled =
                    _mainMenu.Item(_mainMenu.Name + ".drawing.weights.highest-target.enabled").GetValue<bool>();
                var weightsSimple = _mainMenu.Item(_mainMenu.Name + ".drawing.weights.simple").GetValue<bool>();
                if (highestEnabled || weightsSimple)
                {
                    var enemies = Targets.Items.Where(h => h.Hero.IsValidTarget(Range)).ToList();
                    foreach (var weight in Items.Where(w => w.Weight > 0))
                    {
                        UpdateMaxMinValue(weight, enemies, true);
                    }
                    foreach (var target in enemies)
                    {
                        var totalWeight = 0f;
                        foreach (var weight in Items.Where(w => w.Weight > 0))
                        {
                            var lastWeight = CalculatedWeight(weight, target, true);
                            if (lastWeight > 0)
                            {
                                if (_mainMenu != null)
                                {
                                    var heroMultiplicator =
                                        _mainMenu.Item(_mainMenu.Name + ".weights.heroes." + target.Hero.ChampionName)
                                            .GetValue<Slider>()
                                            .Value;
                                    if (heroMultiplicator > 1)
                                    {
                                        lastWeight += Average * heroMultiplicator;
                                    }
                                }
                                totalWeight += lastWeight;
                            }
                        }
                        target.SimulatedWeight = totalWeight;
                    }
                    _drawingTargets = enemies.OrderByDescending(t => t.SimulatedWeight).ToList();
                    if (Game.Time - _lastBestTargetSwitch >= BestTargetSwitchDelay)
                    {
                        _bestTarget = _drawingTargets.FirstOrDefault();
                        _lastBestTargetSwitch = Game.Time;
                    }
                }
            }
            catch (Exception ex)
            {
                Global.Logger.AddItem(new LogItem(ex));
            }
        }
        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 };
                }

                var targets =
                    Humanizer.FilterTargets(Targets.Items)
                        .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 (Mode == TargetSelectorModeType.Weights && Weights.ForceFocus)
                    {
                        t = Weights.FilterTargets(t, range, damageType, ignoreShields, from).ToList();
                    }
                    if (t.Count > 0)
                    {
                        if (Selected.Target != null && Selected.Focus && t.Count > 1)
                        {
                            t = t.OrderByDescending(x => x.Hero.NetworkId.Equals(Selected.Target.NetworkId)).ToList();
                        }
                        _lastTarget = t.First();
                        _lastTarget.LastTargetSwitch = Game.Time;
                        return t.Select(h => h.Hero).ToList();
                    }
                }
            }
            catch (Exception ex)
            {
                Global.Logger.AddItem(new LogItem(ex));
            }
            return new List<Obj_AI_Hero>();
        }