Esempio n. 1
0
 private static void AntiGapcloser_OnEnemyGapcloser(
     AIHeroClient sender,
     Gapcloser.GapcloserArgs args
     )
 {
     if (sender.IsAlly)
     {
         return;
     }
     if (boolLinks["miscGapcloser"].GetValue <MenuBool>() && W.IsInRange(args.EndPosition) && sender.IsEnemy && args.EndPosition.DistanceToPlayer() < 200)
     {
         GapCloserPos = args.EndPosition;
         if (args.StartPosition.Distance(args.EndPosition) > sender.Spellbook.GetSpell(args.Slot).SData.CastRangeDisplayOverride&& sender.Spellbook.GetSpell(args.Slot).SData.CastRangeDisplayOverride > 100)
         {
             GapCloserPos = args.StartPosition.Extend(args.EndPosition, sender.Spellbook.GetSpell(args.Slot).SData.CastRangeDisplayOverride);
         }
         W.Cast(GapCloserPos.ToVector2(), true);
     }
 }
Esempio n. 2
0
        // private void HandleR(AIBaseClient target, bool manual = false)
        //{
        //    if
        //    {
        //        var targE = R.GetPrediction(target);
        //        if ((mainMenu["Combo"].GetValue<MenuBool>("Ruse2").Enabled && GameObjects.Player.CountEnemiesInRange(R.Range + 175) <= 1 &&
        //             )
        //        {
        //            if (target.IsMoving)
        //            {
        //                var pos = targE.CastPosition;
        //                if (pos.IsValid() && pos.Distance(player.Position) < R.Range + 1000 &&
        //                    targE.Hitchance >= HitChance.High)
        //                {
        //                    R.Cast(target.Position.Extend(pos, -500), pos);
        //                }
        //            }
        //            else
        //            {
        //                R.Cast(target.Position.Extend(player.Position, 500), target.Position);
        //            }
        //        }
        //        else if (targE.Hitchance >= HitChance.High )
        //        {
        //            var pred = getBestRVector3(target, targE);
        //            if (pred != Vector3.Zero &&
        //                CombatHelper.GetCollisionCount(
        //                    target, target.Position.Extend(pred, 1000), R.Width, new[] { CollisionableObjects.Heroes, }) >=
        //                config.Item("Rmin", true).GetValue<Slider>().Value)
        //            {
        //                R.Cast(target.Position.Extend(pred, -target.MoveSpeed), pred);
        //            }
        //        }
        //    }
        //}

        //private Vector3 getBestRVector3(Obj_AI_Base target, PredictionOutput targE)
        //{
        //    var otherHeroes =
        //        HeroManager.Enemies.Where(
        //            e => e.IsValidTarget() && e.NetworkId != target.NetworkId && player.Distance(e) < 1000)
        //            .Select(e => R.GetPrediction(e))
        //            .Where(o => o.Hitchance > HitChance.High && o.CastPosition.Distance(targE.UnitPosition) < 1000);
        //    if (otherHeroes.Any())
        //    {
        //        var best =
        //            otherHeroes.OrderByDescending(
        //                hero =>
        //                    CombatHelper.GetCollisionCount(
        //                        target, target.Position.Extend(hero.CastPosition, 1000), R.Width,
        //                        new[] { CollisionableObjects.Heroes, })).FirstOrDefault();
        //        if (best != null)
        //        {
        //            return best.CastPosition;
        //        }
        //    }
        //    return Vector3.Zero;
        //}

        //private IEnumerable<Vector3> GetRpoints(Obj_AI_Base target)
        //{
        //    var targetPos = R.GetPrediction(target);
        //    return
        //        CombatHelper.PointsAroundTheTargetOuterRing(targetPos.CastPosition, 345, 16)
        //            .Where(p => player.Distance(p) < R.Range);
        //}
        private static void PredictCastR(AIHeroClient target)
        {
            var inRange = SharpDX.Vector2.DistanceSquared(target.Position.ToVector2(), ObjectManager.Player.Position.ToVector2()) < R.Range * R.Range;
            PredictionOutput prediction;
            var     spellCasted = false;
            Vector3 pos1, pos2;

            var nearChamps  = (from champ in ObjectManager.Get <AIHeroClient>() where champ.IsValidTarget(maxRangeR) && target != champ select champ).ToList();
            var innerChamps = new List <AIHeroClient>();
            var outerChamps = new List <AIHeroClient>();

            foreach (var champ in nearChamps)
            {
                if (SharpDX.Vector2.DistanceSquared(champ.Position.ToVector2(), ObjectManager.Player.Position.ToVector2()) < R.Range * R.Range)
                {
                    innerChamps.Add(champ);
                }
                else
                {
                    outerChamps.Add(champ);
                }
            }

            var nearMinions  = GameObjects.GetMinions(ObjectManager.Player.Position, maxRangeR);
            var innerMinions = new List <AIBaseClient>();
            var outerMinions = new List <AIBaseClient>();

            foreach (var minion in nearMinions)
            {
                if (SharpDX.Vector2.DistanceSquared(minion.Position.ToVector2(), ObjectManager.Player.Position.ToVector2()) < R.Range * R.Range)
                {
                    innerMinions.Add(minion);
                }
                else
                {
                    outerMinions.Add(minion);
                }
            }

            if (inRange)
            {
                R.Speed    = speedR * 0.9f;
                R.From     = target.Position + (SharpDX.Vector3.Normalize(ObjectManager.Player.Position - target.Position) * (lengthR * 0.1f));
                prediction = R.GetPrediction(target);
                R.From     = ObjectManager.Player.Position;

                if (prediction.CastPosition.Distance(ObjectManager.Player.Position) < R.Range)
                {
                    pos1 = prediction.CastPosition;
                }
                else
                {
                    pos1    = target.Position;
                    R.Speed = speedR;
                }

                R.From           = pos1;
                R.RangeCheckFrom = pos1;
                R.Range          = lengthR;

                if (nearChamps.Count > 0)
                {
                    var closeToPrediction = new List <AIHeroClient>();
                    foreach (var enemy in nearChamps)
                    {
                        prediction = R.GetPrediction(enemy);

                        if (prediction.Hitchance >= HitChance.High && SharpDX.Vector2.DistanceSquared(pos1.ToVector2(), prediction.CastPosition.ToVector2()) < (R.Range * R.Range) * 0.8)
                        {
                            closeToPrediction.Add(enemy);
                        }
                    }

                    if (closeToPrediction.Count > 0)
                    {
                        if (closeToPrediction.Count > 1)
                        {
                            closeToPrediction.Sort((enemy1, enemy2) => enemy2.Health.CompareTo(enemy1.Health));
                        }

                        prediction = R.GetPrediction(closeToPrediction[0]);
                        pos2       = prediction.CastPosition;

                        CastR(pos1, pos2);
                        spellCasted = true;
                    }
                }

                if (!spellCasted)
                {
                    CastR(pos1, R.GetPrediction(target).CastPosition);
                }

                R.Speed          = speedR;
                R.Range          = rangeR;
                R.From           = ObjectManager.Player.Position;
                R.RangeCheckFrom = ObjectManager.Player.Position;
            }
            else
            {
                float startPointRadius = 150;

                SharpDX.Vector3 startPoint = ObjectManager.Player.Position + SharpDX.Vector3.Normalize(target.Position - ObjectManager.Player.Position) * rangeR;

                var targets = (from champ in nearChamps where SharpDX.Vector2.DistanceSquared(champ.Position.ToVector2(), startPoint.ToVector2()) < startPointRadius * startPointRadius && SharpDX.Vector2.DistanceSquared(ObjectManager.Player.Position.ToVector2(), champ.Position.ToVector2()) < rangeR * rangeR select champ).ToList();
                if (targets.Count > 0)
                {
                    if (targets.Count > 1)
                    {
                        targets.Sort((enemy1, enemy2) => enemy2.Health.CompareTo(enemy1.Health));
                    }

                    pos1 = targets[0].Position;
                }
                else
                {
                    var minionTargets = (from minion in nearMinions where SharpDX.Vector2.DistanceSquared(minion.Position.ToVector2(), startPoint.ToVector2()) < startPointRadius * startPointRadius && SharpDX.Vector2.DistanceSquared(ObjectManager.Player.Position.ToVector2(), minion.Position.ToVector2()) < rangeR * rangeR select minion).ToList();
                    if (minionTargets.Count > 0)
                    {
                        if (minionTargets.Count > 1)
                        {
                            minionTargets.Sort((enemy1, enemy2) => enemy2.Health.CompareTo(enemy1.Health));
                        }

                        pos1 = minionTargets[0].Position;
                    }
                    else
                    {
                        pos1 = startPoint;
                    }
                }

                R.From           = pos1;
                R.Range          = lengthR;
                R.RangeCheckFrom = pos1;
                prediction       = R.GetPrediction(target);

                if (prediction.Hitchance >= HitChance.High)
                {
                    CastR(pos1, prediction.CastPosition);
                }

                R.Range          = rangeR;
                R.From           = ObjectManager.Player.Position;
                R.RangeCheckFrom = ObjectManager.Player.Position;
            }
        }
Esempio n. 3
0
        private static void PredictCastE(AIHeroClient target)
        {
            // Helpers
            bool inRange = SharpDX.Vector2.DistanceSquared(target.Position.ToVector2(), player.Position.ToVector2()) < E.Range * E.Range;

            SpellPrediction.PredictionOutput prediction;
            bool spellCasted = false;

            // Positions
            SharpDX.Vector3 pos1, pos2;

            // Champs
            var nearChamps  = (from champ in ObjectManager.Get <AIHeroClient>() where champ.IsValidTarget(maxRangeE) && target != champ select champ).ToList();
            var innerChamps = new List <AIHeroClient>();
            var outerChamps = new List <AIHeroClient>();

            foreach (var champ in nearChamps)
            {
                if (SharpDX.Vector2.DistanceSquared(champ.Position.ToVector2(), player.Position.ToVector2()) < E.Range * E.Range)
                {
                    innerChamps.Add(champ);
                }
                else
                {
                    outerChamps.Add(champ);
                }
            }

            // Minions
            var nearMinions  = GameObjects.GetMinions(player.Position, maxRangeE);
            var innerMinions = new List <AIBaseClient>();
            var outerMinions = new List <AIBaseClient>();

            foreach (var minion in nearMinions)
            {
                if (SharpDX.Vector2.DistanceSquared(minion.Position.ToVector2(), player.Position.ToVector2()) < E.Range * E.Range)
                {
                    innerMinions.Add(minion);
                }
                else
                {
                    outerMinions.Add(minion);
                }
            }

            // Main target in close range
            if (inRange)
            {
                // Get prediction reduced speed, adjusted sourcePosition
                E.Speed    = speedE * 0.9f;
                E.From     = target.Position + (SharpDX.Vector3.Normalize(player.Position - target.Position) * (lengthE * 0.1f));
                prediction = E.GetPrediction(target);
                E.From     = player.Position;

                // Prediction in range, go on
                if (prediction.CastPosition.Distance(player.Position) < E.Range)
                {
                    pos1 = prediction.CastPosition;
                }
                // Prediction not in range, use exact position
                else
                {
                    pos1    = target.Position;
                    E.Speed = speedE;
                }

                // Set new sourcePosition
                E.From           = pos1;
                E.RangeCheckFrom = pos1;

                // Set new range
                E.Range = lengthE;

                // Get next target
                if (nearChamps.Count > 0)
                {
                    // Get best champion around
                    var closeToPrediction = new List <AIHeroClient>();
                    foreach (var enemy in nearChamps)
                    {
                        // Get prediction
                        prediction = E.GetPrediction(enemy);
                        // Validate target
                        if (prediction.Hitchance >= HitChance.High && SharpDX.Vector2.DistanceSquared(pos1.ToVector2(), prediction.CastPosition.ToVector2()) < (E.Range * E.Range) * 0.8)
                        {
                            closeToPrediction.Add(enemy);
                        }
                    }

                    // Champ found
                    if (closeToPrediction.Count > 0)
                    {
                        // Sort table by health DEC
                        if (closeToPrediction.Count > 1)
                        {
                            closeToPrediction.Sort((enemy1, enemy2) => enemy2.Health.CompareTo(enemy1.Health));
                        }

                        // Set destination
                        prediction = E.GetPrediction(closeToPrediction[0]);
                        pos2       = prediction.CastPosition;

                        // Cast spell
                        CastE(pos1, pos2);
                        spellCasted = true;
                    }
                }

                // Spell not casted
                if (!spellCasted)
                {
                    CastE(pos1, E.GetPrediction(target).CastPosition);
                }

                // Reset spell
                E.Speed          = speedE;
                E.Range          = rangeE;
                E.From           = player.Position;
                E.RangeCheckFrom = player.Position;
            }

            // Main target in extended range
            else
            {
                // Radius of the start point to search enemies in
                float startPointRadius = 150;

                // Get initial start point at the border of cast radius
                SharpDX.Vector3 startPoint = player.Position + SharpDX.Vector3.Normalize(target.Position - player.Position) * rangeE;

                // Potential start from postitions
                var targets = (from champ in nearChamps where SharpDX.Vector2.DistanceSquared(champ.Position.ToVector2(), startPoint.ToVector2()) < startPointRadius * startPointRadius && SharpDX.Vector2.DistanceSquared(player.Position.ToVector2(), champ.Position.ToVector2()) < rangeE * rangeE select champ).ToList();
                if (targets.Count > 0)
                {
                    // Sort table by health DEC
                    if (targets.Count > 1)
                    {
                        targets.Sort((enemy1, enemy2) => enemy2.Health.CompareTo(enemy1.Health));
                    }

                    // Set target
                    pos1 = targets[0].Position;
                }
                else
                {
                    var minionTargets = (from minion in nearMinions where SharpDX.Vector2.DistanceSquared(minion.Position.ToVector2(), startPoint.ToVector2()) < startPointRadius * startPointRadius && SharpDX.Vector2.DistanceSquared(player.Position.ToVector2(), minion.Position.ToVector2()) < rangeE * rangeE select minion).ToList();
                    if (minionTargets.Count > 0)
                    {
                        // Sort table by health DEC
                        if (minionTargets.Count > 1)
                        {
                            minionTargets.Sort((enemy1, enemy2) => enemy2.Health.CompareTo(enemy1.Health));
                        }

                        // Set target
                        pos1 = minionTargets[0].Position;
                    }
                    else
                    {
                        // Just the regular, calculated start pos
                        pos1 = startPoint;
                    }
                }

                // Predict target position
                E.From           = pos1;
                E.Range          = lengthE;
                E.RangeCheckFrom = pos1;
                prediction       = E.GetPrediction(target);

                // Cast the E
                if (prediction.Hitchance >= HitChance.High)
                {
                    CastE(pos1, prediction.CastPosition);
                }

                // Reset spell
                E.Range          = rangeE;
                E.From           = player.Position;
                E.RangeCheckFrom = player.Position;
            }
        }