public static void TargetSkill(Obj_AI_Base target, Spell spell)
        {
            if (!spell.IsReady() || target == null)
            {
                return;
            }

            spell.CastOnUnit(target);
        }
示例#2
0
 public static Result Line(Spell spell,
                           Obj_AI_Hero target,
                           HitChance hitChance,
                           bool boundingRadius = true,
                           bool maxRange       = true)
 {
     try
     {
         if (spell == null || target == null)
         {
             return(new Result(Vector3.Zero, new List <Obj_AI_Hero>()));
         }
         var range = (spell.IsChargedSpell && maxRange ? spell.ChargedMaxRange : spell.Range) +
                     (spell.Width * 0.9f) +
                     (boundingRadius ? target.BoundingRadius * BoundingRadiusMultiplicator : 0);
         var positions = (from t in GameObjects.EnemyHeroes
                          where t.IsValidTarget(range, true, spell.RangeCheckFrom)
                          let prediction = spell.GetPrediction(t)
                                           where prediction.Hitchance >= hitChance
                                           select new Position(t, prediction.UnitPosition)).ToList();
         if (positions.Any())
         {
             var hits = new List <Obj_AI_Hero>();
             var pred = spell.GetPrediction(target);
             if (pred.Hitchance >= hitChance)
             {
                 hits.Add(target);
                 var rect = new Geometry.Polygon.Rectangle(
                     spell.From, spell.From.Extend(pred.CastPosition, range), spell.Width);
                 if (boundingRadius)
                 {
                     hits.AddRange(
                         from point in positions.Where(p => p.Hero.NetworkId != target.NetworkId)
                         let circle =
                             new Geometry.Polygon.Circle(
                                 point.UnitPosition, point.Hero.BoundingRadius * BoundingRadiusMultiplicator)
                             where circle.Points.Any(p => rect.IsInside(p))
                             select point.Hero);
                 }
                 else
                 {
                     hits.AddRange(
                         from position in positions
                         where rect.IsInside(position.UnitPosition)
                         select position.Hero);
                 }
                 return(new Result(pred.CastPosition, hits));
             }
         }
     }
     catch (Exception ex)
     {
         Global.Logger.AddItem(new LogItem(ex));
     }
     return(new Result(Vector3.Zero, new List <Obj_AI_Hero>()));
 }
示例#3
0
        private static void ConeFarm(Spell spell, List <Obj_AI_Base> minions, int min, float overrideWidth = -1f)
        {
            var spellWidth = overrideWidth > 0 ? overrideWidth : spell.Width;
            var pred       = spell.GetCircularFarmLocation(minions, spellWidth);

            if (pred.MinionsHit >= min)
            {
                spell.Cast(pred.Position);
            }
        }
 public static void FarmSelfAoe(Spell spell, List <Obj_AI_Base> minions, int minHit = 3, float overrideWidth = -1f)
 {
     if (!spell.IsReady() || minions.Count == 0)
     {
         return;
     }
     if (minions.Count >= minHit)
     {
         spell.Cast();
     }
 }
        protected override void SetupSpells()
        {
            Q = new Spell(SpellSlot.Q, 1450f, DamageType.Magical);
            Q.SetSkillshot(0.25f, 40f, 1000f, false, SkillshotType.SkillshotLine);

            W = new Spell(SpellSlot.W, 550f, DamageType.Magical);
            W.SetSkillshot(0.5f, 100f, Player.BasicAttack.MissileSpeed, false, SkillshotType.SkillshotCircle);

            E = new Spell(SpellSlot.E);

            R = new Spell(SpellSlot.R, 5500f);
        }
示例#6
0
        protected override void SetupSpells()
        {
            Q = new Spell(SpellSlot.Q, 1450f, DamageType.Magical);
            Q.SetSkillshot(0.25f, 40f, 1000f, false, SkillshotType.SkillshotLine);

            W = new Spell(SpellSlot.W, 785f, DamageType.Magical);
            W.SetSkillshot(0.5f, 100f, Player.BasicAttack.MissileSpeed, false, SkillshotType.SkillshotCircle);

            E = new Spell(SpellSlot.E);

            R = new Spell(SpellSlot.R, 5500f);
        }
 public static HitChance GetHitChance(this Spell spell, string uniqueId)
 {
     try
     {
         if (spell != null && spell.Slot != SpellSlot.Unknown)
         {
             return(Get(uniqueId, spell.Slot.ToString()));
         }
     }
     catch (Exception ex)
     {
         Global.Logger.AddItem(new LogItem(ex));
     }
     return(HitChance.High);
 }
示例#8
0
        public static void Farm(Spell spell,
                                int minHit                 = 3,
                                float overrideWidth        = -1f,
                                bool chargeMax             = true,
                                List <Obj_AI_Base> minions = null)
        {
            if (!spell.IsReady())
            {
                return;
            }
            var spellWidth = overrideWidth > 0 ? overrideWidth : spell.Width;

            if (minions == null)
            {
                minions =
                    MinionManager.GetMinions(
                        (((chargeMax && spell.IsChargedSpell ? spell.ChargedMaxRange : spell.Range) + spellWidth) * 1.5f),
                        MinionTypes.All, MinionTeam.NotAlly, MinionOrderTypes.MaxHealth);
            }

            if (minions.Count == 0)
            {
                return;
            }

            if (minHit > 1)
            {
                var nearest = minions.OrderBy(m => m.Distance(ObjectManager.Player)).FirstOrDefault();
                if (nearest != null && nearest.Team == GameObjectTeam.Neutral)
                {
                    minHit = 1;
                }
            }

            if (spell.Type == SkillshotType.SkillshotCircle)
            {
                CircleFarm(spell, minions, minHit, overrideWidth);
            }
            else if (spell.Type == SkillshotType.SkillshotLine)
            {
                LineFarm(spell, minions, minHit, overrideWidth);
            }
            else if (spell.Type == SkillshotType.SkillshotCone)
            {
                ConeFarm(spell, minions, minHit, overrideWidth);
            }
        }
示例#9
0
        public static void Farm(Spell spell,
            int minHit = 3,
            float overrideWidth = -1f,
            bool chargeMax = true,
            List<Obj_AI_Base> minions = null)
        {
            if (!spell.IsReady())
            {
                return;
            }
            var spellWidth = overrideWidth > 0 ? overrideWidth : spell.Width;

            if (minions == null)
            {
                minions =
                    MinionManager.GetMinions(
                        (((chargeMax && spell.IsChargedSpell ? spell.ChargedMaxRange : spell.Range) + spellWidth) * 1.5f),
                        MinionTypes.All, MinionTeam.NotAlly, MinionOrderTypes.MaxHealth);
            }

            if (minions.Count == 0)
            {
                return;
            }

            if (minHit > 1)
            {
                var nearest = minions.OrderBy(m => m.Distance(ObjectManager.Player)).FirstOrDefault();
                if (nearest != null && nearest.Team == GameObjectTeam.Neutral)
                {
                    minHit = 1;
                }
            }

            if (spell.Type == SkillshotType.SkillshotCircle)
            {
                CircleFarm(spell, minions, minHit, overrideWidth);
            }
            else if (spell.Type == SkillshotType.SkillshotLine)
            {
                LineFarm(spell, minions, minHit, overrideWidth);
            }
            else if (spell.Type == SkillshotType.SkillshotCone)
            {
                ConeFarm(spell, minions, minHit, overrideWidth);
            }
        }
 public static Obj_AI_Hero GetTargetNoCollision(Spell spell,
                                                bool ignoreShields = true,
                                                Vector3 from       = default(Vector3),
                                                IEnumerable <Obj_AI_Hero> ignoredChampions = null)
 {
     try
     {
         return
             (GetTargets(spell.Range, spell.DamageType, ignoreShields, from, ignoredChampions)
              .FirstOrDefault(t => spell.GetPrediction(t).Hitchance != HitChance.Collision));
     }
     catch (Exception ex)
     {
         Global.Logger.AddItem(new LogItem(ex));
     }
     return(null);
 }
 public static Obj_AI_Hero GetTarget(Spell spell,
                                     bool ignoreShields = true,
                                     Vector3 from       = default(Vector3),
                                     IEnumerable <Obj_AI_Hero> ignoredChampions = null)
 {
     try
     {
         return
             (GetTarget(
                  (spell.Range + spell.Width +
                   Targets.Items.Select(e => e.Hero.BoundingRadius).DefaultIfEmpty(50).Max()) * 1.1f,
                  spell.DamageType, ignoreShields, from, ignoredChampions));
     }
     catch (Exception ex)
     {
         Global.Logger.AddItem(new LogItem(ex));
     }
     return(null);
 }
 public static void Farm(Spell spell,
                         List <Obj_AI_Base> minions,
                         int minHit          = 3,
                         float overrideWidth = -1f,
                         bool chargeMax      = true)
 {
     if (!spell.IsReady() || minions.Count == 0)
     {
         return;
     }
     if (spell.IsSkillshot)
     {
         if (spell.Collision)
         {
             minHit = 1;
         }
         if (spell.Type == SkillshotType.SkillshotCircle)
         {
             CircleFarm(spell, minions, minHit, overrideWidth);
         }
         else if (spell.Type == SkillshotType.SkillshotLine)
         {
             LineFarm(spell, minions, minHit, overrideWidth);
         }
         else if (spell.Type == SkillshotType.SkillshotCone)
         {
             ConeFarm(spell, minions, minHit, overrideWidth);
         }
     }
     else
     {
         var minion =
             minions.OrderBy(m => spell.IsKillable(m))
             .FirstOrDefault(
                 m =>
                 spell.IsInRange(m) && spell.GetDamage(m) > m.Health ||
                 m.Health - spell.GetDamage(m) > m.MaxHealth * 0.25f);
         if (minion != null)
         {
             spell.CastOnUnit(minion);
         }
     }
 }
        private static void LineFarm(Spell spell, List <Obj_AI_Base> minions, int min, float overrideWidth = -1f)
        {
            if (!spell.IsReady() || minions.Count == 0)
            {
                return;
            }
            var spellWidth = overrideWidth > 0 ? overrideWidth : spell.Width;
            var totalHits  = 0;
            var castPos    = Vector3.Zero;

            var positions = (from minion in minions
                             let pred = spell.GetPrediction(minion)
                                        where pred.Hitchance >= HitChance.Medium
                                        select new Tuple <Obj_AI_Base, Vector3>(minion, pred.UnitPosition)).ToList();

            if (positions.Any())
            {
                foreach (var position in positions)
                {
                    var rect = new Geometry.Polygon.Rectangle(
                        ObjectManager.Player.Position, ObjectManager.Player.Position.Extend(position.Item2, spell.Range),
                        spellWidth);
                    var count =
                        positions.Select(
                            position2 =>
                            new Geometry.Polygon.Circle(position2.Item2, position2.Item1.BoundingRadius * 0.9f))
                        .Count(circle => circle.Points.Any(p => rect.IsInside(p)));
                    if (count > totalHits)
                    {
                        totalHits = count;
                        castPos   = position.Item2;
                    }
                    if (totalHits == minions.Count)
                    {
                        break;
                    }
                }
                if (!castPos.Equals(Vector3.Zero) && totalHits >= min)
                {
                    spell.Cast(castPos);
                }
            }
        }
示例#14
0
 public static bool Check(string uniqueId, Spell spell, Obj_AI_Hero hero)
 {
     try
     {
         if (hero == null || !Enabled(uniqueId))
         {
             return(true);
         }
         var bestTarget = TargetSelector.GetTarget(spell);
         if (bestTarget == null || hero.NetworkId.Equals(bestTarget.NetworkId))
         {
             return(true);
         }
     }
     catch (Exception ex)
     {
         Global.Logger.AddItem(new LogItem(ex));
     }
     return(false);
 }
 public static bool Check(string uniqueId, Spell spell, Obj_AI_Hero hero)
 {
     try
     {
         if (hero == null || !Enabled(uniqueId))
         {
             return true;
         }
         var bestTarget = TargetSelector.GetTarget(spell);
         if (bestTarget == null || hero.NetworkId.Equals(bestTarget.NetworkId))
         {
             return true;
         }
     }
     catch (Exception ex)
     {
         Global.Logger.AddItem(new LogItem(ex));
     }
     return false;
 }
        private static void CircleFarm(Spell spell, List <Obj_AI_Base> minions, int min, float overrideWidth = -1f)
        {
            if (!spell.IsReady() || minions.Count == 0)
            {
                return;
            }
            var spellWidth = (overrideWidth > 0 ? overrideWidth : spell.Width) + minions.Average(m => m.BoundingRadius);
            var points     = (from minion in minions
                              select spell.GetPrediction(minion)
                              into pred
                              where pred.Hitchance >= HitChance.Medium
                              select pred.UnitPosition.To2D()).ToList();

            if (points.Any())
            {
                var possibilities = ListExtensions.ProduceEnumeration(points).Where(p => p.Count >= min).ToList();
                if (possibilities.Any())
                {
                    var hits   = 0;
                    var radius = float.MaxValue;
                    var pos    = Vector3.Zero;
                    foreach (var possibility in possibilities)
                    {
                        var mec = MEC.GetMec(possibility);
                        if (mec.Radius < spellWidth)
                        {
                            if (possibility.Count > hits || possibility.Count == hits && radius > mec.Radius)
                            {
                                hits   = possibility.Count;
                                radius = mec.Radius;
                                pos    = mec.Center.To3D();
                            }
                        }
                    }
                    if (hits >= min && !pos.Equals(Vector3.Zero))
                    {
                        spell.Cast(pos);
                    }
                }
            }
        }
 public static void Add(Spell spell, bool readyCheck = true, bool enabled = true)
 {
     try
     {
         if (_menu == null)
         {
             return;
         }
         _menu.AddItem(
             new MenuItem(_menu.Name + "." + spell.Slot, spell.Slot.ToString().ToUpper()).SetValue(enabled));
         if (readyCheck)
         {
             Functions.Add(spell.Slot.ToString(), hero => spell.IsReady() ? spell.GetDamage(hero) : 0);
         }
         else
         {
             Functions.Add(spell.Slot.ToString(), hero => spell.GetDamage(hero));
         }
     }
     catch (Exception ex)
     {
         Global.Logger.AddItem(new LogItem(ex));
     }
 }
示例#18
0
        public static void SkillShot(Obj_AI_Hero target,
            Spell spell,
            HitChance hitChance,
            bool boundingRadius = true,
            bool maxRange = true)
        {
            if (!spell.IsReady() || target == null)
            {
                return;
            }

            if (spell.Type == SkillshotType.SkillshotLine)
            {
                var prediction = CPrediction.Line(spell, target, hitChance, boundingRadius, maxRange);
                if (prediction.TotalHits >= 1)
                {
                    spell.Cast(prediction.CastPosition);
                }
            }
            else if (spell.Type == SkillshotType.SkillshotCircle)
            {
                var prediction = CPrediction.Circle(spell, target, hitChance);
                if (prediction.TotalHits >= 1)
                {
                    spell.Cast(prediction.CastPosition);
                }
            }
            else
            {
                var prediction = spell.GetPrediction(target);
                if (prediction.Hitchance >= hitChance)
                {
                    spell.Cast(prediction.CastPosition);
                }
            }
        }
 public static void Add(Spell spell, bool readyCheck = true, bool enabled = true)
 {
     try
     {
         if (_menu == null)
         {
             return;
         }
         _menu.AddItem(
             new MenuItem(_menu.Name + "." + spell.Slot, spell.Slot.ToString().ToUpper()).SetValue(enabled));
         if (readyCheck)
         {
             Functions.Add(spell.Slot.ToString(), hero => spell.IsReady() ? spell.GetDamage(hero) : 0);
         }
         else
         {
             Functions.Add(spell.Slot.ToString(), hero => spell.GetDamage(hero));
         }
     }
     catch (Exception ex)
     {
         Global.Logger.AddItem(new LogItem(ex));
     }
 }
        public static void SkillShot(Obj_AI_Hero target,
                                     Spell spell,
                                     HitChance hitChance,
                                     bool boundingRadius = true,
                                     bool maxRange       = true)
        {
            if (!spell.IsReady() || target == null)
            {
                return;
            }

            if (spell.Type == SkillshotType.SkillshotLine)
            {
                var prediction = CPrediction.Line(spell, target, hitChance, boundingRadius, maxRange);
                if (prediction.TotalHits >= 1)
                {
                    spell.Cast(prediction.CastPosition);
                }
            }
            else if (spell.Type == SkillshotType.SkillshotCircle)
            {
                var prediction = CPrediction.Circle(spell, target, hitChance);
                if (prediction.TotalHits >= 1)
                {
                    spell.Cast(prediction.CastPosition);
                }
            }
            else
            {
                var prediction = spell.GetPrediction(target);
                if (prediction.Hitchance >= hitChance)
                {
                    spell.Cast(prediction.CastPosition);
                }
            }
        }
 public static void TargetSkill(Spell spell)
 {
     TargetSkill(TargetSelector.GetTarget(spell), spell);
 }
 public static void SkillShot(Spell spell, HitChance hitChance, bool boundingRadius = true, bool maxRange = true)
 {
     SkillShot(TargetSelector.GetTarget(spell), spell, hitChance);
 }
示例#23
0
 public static void TargetSkill(Spell spell)
 {
     TargetSkill(TargetSelector.GetTarget(spell), spell);
 }
示例#24
0
        public static void TargetSkill(Obj_AI_Base target, Spell spell)
        {
            if (!spell.IsReady() || target == null)
            {
                return;
            }

            spell.CastOnUnit(target);
        }
示例#25
0
 private static void CircleFarm(Spell spell, List<Obj_AI_Base> minions, int min, float overrideWidth = -1f)
 {
     var spellWidth = (overrideWidth > 0 ? overrideWidth : spell.Width) + minions.Average(m => m.BoundingRadius);
     var points = (from minion in minions
         select spell.GetPrediction(minion)
         into pred
         where pred.Hitchance >= HitChance.Medium
         select pred.UnitPosition.To2D()).ToList();
     if (points.Any())
     {
         var possibilities = ListExtensions.ProduceEnumeration(points).Where(p => p.Count >= min).ToList();
         if (possibilities.Any())
         {
             var hits = 0;
             var radius = float.MaxValue;
             var pos = Vector3.Zero;
             foreach (var possibility in possibilities)
             {
                 var mec = MEC.GetMec(possibility);
                 if (mec.Radius < spellWidth)
                 {
                     if (possibility.Count > hits || possibility.Count == hits && radius > mec.Radius)
                     {
                         hits = possibility.Count;
                         radius = mec.Radius;
                         pos = mec.Center.To3D();
                     }
                 }
             }
             if (hits >= min && !pos.Equals(Vector3.Zero))
             {
                 spell.Cast(pos);
             }
         }
     }
 }
示例#26
0
 public static void Farm(Spell spell,
     List<Obj_AI_Base> minions,
     int minHit = 3,
     float overrideWidth = -1f,
     bool chargeMax = true)
 {
     if (!spell.IsReady() || minions.Count == 0)
     {
         return;
     }
     if (spell.IsSkillshot)
     {
         if (spell.Type == SkillshotType.SkillshotCircle)
         {
             CircleFarm(spell, minions, minHit, overrideWidth);
         }
         else if (spell.Type == SkillshotType.SkillshotLine)
         {
             LineFarm(spell, minions, minHit, overrideWidth);
         }
         else if (spell.Type == SkillshotType.SkillshotCone)
         {
             ConeFarm(spell, minions, minHit, overrideWidth);
         }
     }
     else
     {
         var minion =
             minions.OrderBy(m => spell.IsKillable(m))
                 .FirstOrDefault(
                     m =>
                         spell.IsInRange(m) && spell.GetDamage(m) > m.Health ||
                         m.Health - spell.GetDamage(m) > m.MaxHealth * 0.25f);
         if (minion != null)
         {
             spell.CastOnUnit(minion);
         }
     }
 }
 public static Obj_AI_Hero GetTarget(Spell spell,
     bool ignoreShields = true,
     Vector3 from = default(Vector3),
     IEnumerable<Obj_AI_Hero> ignoredChampions = null)
 {
     try
     {
         return
             GetTarget(
                 (spell.Range + spell.Width +
                  Targets.Items.Select(e => e.Hero.BoundingRadius).DefaultIfEmpty(50).Max()) * 1.1f,
                 spell.DamageType, ignoreShields, from, ignoredChampions);
     }
     catch (Exception ex)
     {
         Global.Logger.AddItem(new LogItem(ex));
     }
     return null;
 }
示例#28
0
        private static void LineFarm(Spell spell, List<Obj_AI_Base> minions, int min, float overrideWidth = -1f)
        {
            var spellWidth = overrideWidth > 0 ? overrideWidth : spell.Width;
            var totalHits = 0;
            var castPos = Vector3.Zero;

            var positions = (from minion in minions
                let pred = spell.GetPrediction(minion)
                where pred.Hitchance >= HitChance.Medium
                select new Tuple<Obj_AI_Base, Vector3>(minion, pred.UnitPosition)).ToList();

            if (positions.Any())
            {
                foreach (var position in positions)
                {
                    var rect = new Geometry.Polygon.Rectangle(
                        ObjectManager.Player.Position, ObjectManager.Player.Position.Extend(position.Item2, spell.Range),
                        spellWidth);
                    var count =
                        positions.Select(
                            position2 =>
                                new Geometry.Polygon.Circle(position2.Item2, position2.Item1.BoundingRadius * 0.9f))
                            .Count(circle => circle.Points.Any(p => rect.IsInside(p)));
                    if (count > totalHits)
                    {
                        totalHits = count;
                        castPos = position.Item2;
                    }
                    if (totalHits == minions.Count)
                    {
                        break;
                    }
                }
                if (!castPos.Equals(Vector3.Zero) && totalHits >= min)
                {
                    spell.Cast(castPos);
                }
            }
        }
示例#29
0
 private static void ConeFarm(Spell spell, List<Obj_AI_Base> minions, int min, float overrideWidth = -1f)
 {
     var spellWidth = overrideWidth > 0 ? overrideWidth : spell.Width;
     var pred = spell.GetCircularFarmLocation(minions, spellWidth);
     if (pred.MinionsHit >= min)
     {
         spell.Cast(pred.Position);
     }
 }
示例#30
0
 public static void SkillShot(Spell spell, HitChance hitChance, bool boundingRadius = true, bool maxRange = true)
 {
     SkillShot(TargetSelector.GetTarget(spell), spell, hitChance);
 }
        public static Result Circle(Spell spell, Obj_AI_Hero target, HitChance hitChance, bool boundingRadius = true)
        {
            try
            {
                if (spell == null || target == null)
                {
                    return new Result(Vector3.Zero, new List<Obj_AI_Hero>());
                }
                var hits = new List<Obj_AI_Hero>();
                var center = Vector3.Zero;
                var radius = float.MaxValue;
                var range = spell.Range + (spell.Width * 0.85f) +
                            (boundingRadius ? target.BoundingRadius * BoundingRadiusMultiplicator : 0);
                var positions = (from t in GameObjects.EnemyHeroes
                    where t.IsValidTarget(range * 1.5f, true, spell.RangeCheckFrom)
                    let prediction = spell.GetPrediction(t)
                    where prediction.Hitchance >= hitChance
                    select new Position(t, prediction.UnitPosition)).ToList();
                var spellWidth = spell.Width;
                //+ (boundingRadius ? positions.Select(p => p.Hero).Min(p => p.BoundingRadius) : 0);
                if (positions.Any())
                {
                    var mainTarget = positions.FirstOrDefault(p => p.Hero.NetworkId == target.NetworkId);
                    var possibilities =
                        ListExtensions.ProduceEnumeration(
                            positions.Where(
                                p => p.UnitPosition.Distance(mainTarget.UnitPosition) <= spell.Width * 0.85f).ToList())
                            .Where(p => p.Count > 0 && p.Any(t => t.Hero.NetworkId == mainTarget.Hero.NetworkId))
                            .ToList();
                    foreach (var possibility in possibilities)
                    {
                        var mec = MEC.GetMec(possibility.Select(p => p.UnitPosition.To2D()).ToList());
                        var distance = spell.From.Distance(mec.Center.To3D());
                        if (mec.Radius < spellWidth && distance < range)
                        {
                            var lHits = new List<Obj_AI_Hero>();
                            var circle =
                                new Geometry.Polygon.Circle(
                                    spell.From.Extend(
                                        mec.Center.To3D(), spell.Range > distance ? distance : spell.Range), spell.Width);

                            if (boundingRadius)
                            {
                                lHits.AddRange(
                                    (from position in positions
                                        where
                                            new Geometry.Polygon.Circle(
                                                position.UnitPosition,
                                                (position.Hero.BoundingRadius * BoundingRadiusMultiplicator)).Points.Any
                                                (p => circle.IsInside(p))
                                        select position.Hero));
                            }
                            else
                            {
                                lHits.AddRange(
                                    from position in positions
                                    where circle.IsInside(position.UnitPosition)
                                    select position.Hero);
                            }

                            if ((lHits.Count > hits.Count || lHits.Count == hits.Count && mec.Radius < radius ||
                                 lHits.Count == hits.Count &&
                                 spell.From.Distance(circle.Center.To3D()) < spell.From.Distance(center)) &&
                                lHits.Any(p => p.NetworkId == target.NetworkId))
                            {
                                center = circle.Center.To3D2();
                                radius = mec.Radius;
                                hits.Clear();
                                hits.AddRange(lHits);
                            }
                        }
                    }
                    if (!center.Equals(Vector3.Zero))
                    {
                        return new Result(center, hits);
                    }
                }
            }
            catch (Exception ex)
            {
                Global.Logger.AddItem(new LogItem(ex));
            }
            return new Result(Vector3.Zero, new List<Obj_AI_Hero>());
        }
示例#32
0
 public static void FarmSelfAoe(Spell spell, List<Obj_AI_Base> minions, int minHit = 3, float overrideWidth = -1f)
 {
     if (!spell.IsReady() || minions.Count == 0)
     {
         return;
     }
     if (minions.Count >= minHit)
     {
         spell.Cast();
     }
 }
 public static Obj_AI_Hero GetTargetNoCollision(Spell spell,
     bool ignoreShields = true,
     Vector3 from = default(Vector3),
     IEnumerable<Obj_AI_Hero> ignoredChampions = null)
 {
     try
     {
         return
             GetTargets(spell.Range, spell.DamageType, ignoreShields, from, ignoredChampions)
                 .FirstOrDefault(t => spell.GetPrediction(t).Hitchance != HitChance.Collision);
     }
     catch (Exception ex)
     {
         Global.Logger.AddItem(new LogItem(ex));
     }
     return null;
 }
示例#34
0
        public static Result Circle(Spell spell, Obj_AI_Hero target, HitChance hitChance, bool boundingRadius = true)
        {
            try
            {
                if (spell == null || target == null)
                {
                    return(new Result(Vector3.Zero, new List <Obj_AI_Hero>()));
                }
                var hits   = new List <Obj_AI_Hero>();
                var center = Vector3.Zero;
                var radius = float.MaxValue;
                var range  = spell.Range + (spell.Width * 0.85f) +
                             (boundingRadius ? target.BoundingRadius * BoundingRadiusMultiplicator : 0);
                var positions = (from t in GameObjects.EnemyHeroes
                                 where t.IsValidTarget(range * 1.5f, true, spell.RangeCheckFrom)
                                 let prediction = spell.GetPrediction(t)
                                                  where prediction.Hitchance >= hitChance
                                                  select new Position(t, prediction.UnitPosition)).ToList();
                var spellWidth = spell.Width;
                //+ (boundingRadius ? positions.Select(p => p.Hero).Min(p => p.BoundingRadius) : 0);
                if (positions.Any())
                {
                    var mainTarget    = positions.FirstOrDefault(p => p.Hero.NetworkId == target.NetworkId);
                    var possibilities =
                        ListExtensions.ProduceEnumeration(
                            positions.Where(
                                p => p.UnitPosition.Distance(mainTarget.UnitPosition) <= spell.Width * 0.85f).ToList())
                        .Where(p => p.Count > 0 && p.Any(t => t.Hero.NetworkId == mainTarget.Hero.NetworkId))
                        .ToList();
                    foreach (var possibility in possibilities)
                    {
                        var mec      = MEC.GetMec(possibility.Select(p => p.UnitPosition.To2D()).ToList());
                        var distance = spell.From.Distance(mec.Center.To3D());
                        if (mec.Radius < spellWidth && distance < range)
                        {
                            var lHits  = new List <Obj_AI_Hero>();
                            var circle =
                                new Geometry.Polygon.Circle(
                                    spell.From.Extend(
                                        mec.Center.To3D(), spell.Range > distance ? distance : spell.Range), spell.Width);

                            if (boundingRadius)
                            {
                                lHits.AddRange(
                                    (from position in positions
                                     where
                                     new Geometry.Polygon.Circle(
                                         position.UnitPosition,
                                         (position.Hero.BoundingRadius * BoundingRadiusMultiplicator)).Points.Any
                                         (p => circle.IsInside(p))
                                     select position.Hero));
                            }
                            else
                            {
                                lHits.AddRange(
                                    from position in positions
                                    where circle.IsInside(position.UnitPosition)
                                    select position.Hero);
                            }

                            if ((lHits.Count > hits.Count || lHits.Count == hits.Count && mec.Radius < radius ||
                                 lHits.Count == hits.Count &&
                                 spell.From.Distance(circle.Center.To3D()) < spell.From.Distance(center)) &&
                                lHits.Any(p => p.NetworkId == target.NetworkId))
                            {
                                center = circle.Center.To3D2();
                                radius = mec.Radius;
                                hits.Clear();
                                hits.AddRange(lHits);
                            }
                        }
                    }
                    if (!center.Equals(Vector3.Zero))
                    {
                        return(new Result(center, hits));
                    }
                }
            }
            catch (Exception ex)
            {
                Global.Logger.AddItem(new LogItem(ex));
            }
            return(new Result(Vector3.Zero, new List <Obj_AI_Hero>()));
        }
 public static Result Line(Spell spell,
     Obj_AI_Hero target,
     HitChance hitChance,
     bool boundingRadius = true,
     bool maxRange = true)
 {
     try
     {
         if (spell == null || target == null)
         {
             return new Result(Vector3.Zero, new List<Obj_AI_Hero>());
         }
         var range = (spell.IsChargedSpell && maxRange ? spell.ChargedMaxRange : spell.Range) +
                     (spell.Width * 0.9f) +
                     (boundingRadius ? target.BoundingRadius * BoundingRadiusMultiplicator : 0);
         var positions = (from t in GameObjects.EnemyHeroes
             where t.IsValidTarget(range, true, spell.RangeCheckFrom)
             let prediction = spell.GetPrediction(t)
             where prediction.Hitchance >= hitChance
             select new Position(t, prediction.UnitPosition)).ToList();
         if (positions.Any())
         {
             var hits = new List<Obj_AI_Hero>();
             var pred = spell.GetPrediction(target);
             if (pred.Hitchance >= hitChance)
             {
                 hits.Add(target);
                 var rect = new Geometry.Polygon.Rectangle(
                     spell.From, spell.From.Extend(pred.CastPosition, range), spell.Width);
                 if (boundingRadius)
                 {
                     hits.AddRange(
                         from point in positions.Where(p => p.Hero.NetworkId != target.NetworkId)
                         let circle =
                             new Geometry.Polygon.Circle(
                                 point.UnitPosition, point.Hero.BoundingRadius * BoundingRadiusMultiplicator)
                         where circle.Points.Any(p => rect.IsInside(p))
                         select point.Hero);
                 }
                 else
                 {
                     hits.AddRange(
                         from position in positions
                         where rect.IsInside(position.UnitPosition)
                         select position.Hero);
                 }
                 return new Result(pred.CastPosition, hits);
             }
         }
     }
     catch (Exception ex)
     {
         Global.Logger.AddItem(new LogItem(ex));
     }
     return new Result(Vector3.Zero, new List<Obj_AI_Hero>());
 }
        public static void FarmSelfAoe(Spell spell,
            int minHit = 3,
            float overrideWidth = -1f,
            List<Obj_AI_Base> minions = null)
        {
            if (!spell.IsReady())
            {
                return;
            }
            var spellWidth = overrideWidth > 0 ? overrideWidth : (spell.Width > 25f ? spell.Width : spell.Range);

            if (minions == null)
            {
                minions = MinionManager.GetMinions(
                    spellWidth, MinionTypes.All, MinionTeam.NotAlly, MinionOrderTypes.MaxHealth);
            }

            if (minions.Count == 0)
            {
                return;
            }

            if (minHit > 1)
            {
                var nearest = minions.OrderBy(m => m.Distance(ObjectManager.Player)).FirstOrDefault();
                if (nearest != null && nearest.Team == GameObjectTeam.Neutral)
                {
                    minHit = 1;
                }
            }
            if (minions.Count >= minHit)
            {
                spell.Cast();
            }
        }