예제 #1
0
        public static PositionInfo GetBestPositionDash(EvadeSpellData spell)
        {
            var       posChecked    = 0;
            const int maxPosToCheck = 100;
            const int posRadius     = 50;
            var       radiusIndex   = 0;

            var extraDelayBuffer   = ObjectCache.MenuCache.Cache["ExtraPingBuffer"].As <MenuSlider>().Value;
            var extraEvadeDistance = Math.Max(100, ObjectCache.MenuCache.Cache["ExtraEvadeDistance"].As <MenuSlider>().Value);
            var extraDist          = ObjectCache.MenuCache.Cache["ExtraCPADistance"].As <MenuSlider>().Value;

            var heroPoint = ObjectCache.MyHeroCache.ServerPos2DPing;

            var posTable  = new List <PositionInfo>();
            var spellList = SpellDetector.GetSpellList();

            var minDistance = 50; //Math.Min(spell.range, minDistance)
            var maxDistance = int.MaxValue;

            if (spell.FixedRange)
            {
                minDistance = maxDistance = (int)spell.Range;
            }

            while (posChecked < maxPosToCheck)
            {
                radiusIndex++;

                var curRadius       = radiusIndex * 2 * posRadius + (minDistance - 2 * posRadius);
                var curCircleChecks = (int)Math.Ceiling(2 * Math.PI * curRadius / (2 * (double)posRadius));

                for (var i = 1; i < curCircleChecks; i++)
                {
                    posChecked++;
                    var cRadians = 2 * Math.PI / (curCircleChecks - 1) * i; //check decimals
                    var pos      = new Vector2((float)Math.Floor(heroPoint.X + curRadius * Math.Cos(cRadians)), (float)Math.Floor(heroPoint.Y + curRadius * Math.Sin(cRadians)));

                    var posInfo = CanHeroWalkToPos(pos, spell.Speed, extraDelayBuffer + ObjectCache.GamePing, extraDist);
                    posInfo.IsDangerousPos   = pos.CheckDangerousPos(6);
                    posInfo.HasExtraDistance = extraEvadeDistance > 0 && pos.CheckDangerousPos(extraEvadeDistance); // ? 1 : 0;
                    posInfo.DistanceToMouse  = pos.GetPositionValue();
                    posInfo.SpellList        = spellList;

                    posInfo.PosDistToChamps = pos.GetDistanceToChampions();

                    posTable.Add(posInfo);
                }

                if (curRadius >= maxDistance)
                {
                    break;
                }
            }

            var sortedPosTable = posTable.OrderBy(p => p.IsDangerousPos).ThenBy(p => p.PosDangerLevel).ThenBy(p => p.PosDangerCount).ThenBy(p => p.HasExtraDistance).ThenBy(p => p.DistanceToMouse);

            return(sortedPosTable.Where(posInfo => CheckPathCollision(MyHero, posInfo.Position) == false).FirstOrDefault(posInfo => PositionInfoStillValid(posInfo, spell.Speed)));
        }
예제 #2
0
        public static PositionInfo GetBestPositionTargetedDash(EvadeSpellData spell)
        {
            var extraDelayBuffer   = ObjectCache.MenuCache.Cache["ExtraPingBuffer"].As <MenuSlider>().Value;
            var extraEvadeDistance = Math.Max(100, ObjectCache.MenuCache.Cache["ExtraEvadeDistance"].As <MenuSlider>().Value);
            var extraDist          = ObjectCache.MenuCache.Cache["ExtraCPADistance"].As <MenuSlider>().Value;

            var heroPoint = ObjectCache.MyHeroCache.ServerPos2DPing;

            var posTable  = new List <PositionInfo>();
            var spellList = SpellDetector.GetSpellList();

            var collisionCandidates = new List <Obj_AI_Base>();

            if (spell.SpellTargets.Contains(SpellTargets.Targetables))
            {
                collisionCandidates.AddRange(ObjectManager.Get <Obj_AI_Base>().Where(h => !h.IsMe && h.IsValidTarget(spell.Range)).Where(obj => obj.Type != GameObjectType.obj_AI_Turret));
            }
            else
            {
                var heroList = new List <Obj_AI_Hero>(); // Maybe change to IEnumerable

                if (spell.SpellTargets.Contains(SpellTargets.EnemyChampions) && spell.SpellTargets.Contains(SpellTargets.AllyChampions))
                {
                    heroList = GameObjects.Heroes.ToList();
                }
                else if (spell.SpellTargets.Contains(SpellTargets.EnemyChampions))
                {
                    heroList = GameObjects.EnemyHeroes.ToList();
                }
                else if (spell.SpellTargets.Contains(SpellTargets.AllyChampions))
                {
                    heroList = GameObjects.AllyHeroes.ToList();
                }

                collisionCandidates.AddRange(heroList.Where(h => !h.IsMe && h.IsValidTarget(spell.Range)).Cast <Obj_AI_Base>());

                var minionList = new List <Obj_AI_Minion>();

                if (spell.SpellTargets.Contains(SpellTargets.EnemyMinions) && spell.SpellTargets.Contains(SpellTargets.AllyMinions))
                {
                    minionList = GameObjects.Minions.Where(m => m.Distance(MyHero.ServerPosition) <= spell.Range).ToList();
                }
                else if (spell.SpellTargets.Contains(SpellTargets.EnemyMinions))
                {
                    minionList = GameObjects.EnemyMinions.Where(m => m.Distance(MyHero.ServerPosition) <= spell.Range).ToList();
                }
                else if (spell.SpellTargets.Contains(SpellTargets.AllyMinions))
                {
                    minionList = GameObjects.AllyMinions.Where(m => m.Distance(MyHero.ServerPosition) <= spell.Range).ToList();
                }

                collisionCandidates.AddRange(minionList.Where(h => h.IsValidTarget(spell.Range)).Cast <Obj_AI_Base>());
            }

            foreach (var candidate in collisionCandidates)
            {
                var pos = candidate.ServerPosition.To2D();

                PositionInfo posInfo;

                if (spell.SpellName == "YasuoDashWrapper")
                {
                    var hasDashBuff = candidate.Buffs.Any(buff => buff.Name == "YasuoDashWrapper");

                    if (hasDashBuff)
                    {
                        continue;
                    }
                }

                if (spell.BehindTarget)
                {
                    var dir = (pos - heroPoint).Normalized();
                    pos = pos + dir * (candidate.BoundingRadius + ObjectCache.MyHeroCache.BoundingRadius);
                }

                if (spell.InfrontTarget)
                {
                    var dir = (pos - heroPoint).Normalized();
                    pos = pos - dir * (candidate.BoundingRadius + ObjectCache.MyHeroCache.BoundingRadius);
                }

                if (spell.FixedRange)
                {
                    var dir = (pos - heroPoint).Normalized();
                    pos = heroPoint + dir * spell.Range;
                }

                if (spell.EvadeType == EvadeType.Dash)
                {
                    posInfo = CanHeroWalkToPos(pos, spell.Speed, extraDelayBuffer + ObjectCache.GamePing, extraDist);
                    posInfo.IsDangerousPos  = pos.CheckDangerousPos(6);
                    posInfo.DistanceToMouse = pos.GetPositionValue();
                    posInfo.SpellList       = spellList;
                }
                else
                {
                    var isDangerousPos = pos.CheckDangerousPos(6);
                    var dist           = pos.GetPositionValue();

                    posInfo = new PositionInfo(pos, isDangerousPos, dist);
                }

                posInfo.Target = candidate;
                posTable.Add(posInfo);
            }

            if (spell.EvadeType == EvadeType.Dash)
            {
                var sortedPosTable = posTable.OrderBy(p => p.IsDangerousPos).ThenBy(p => p.PosDangerLevel).ThenBy(p => p.PosDangerCount).ThenBy(p => p.DistanceToMouse);

                var first = sortedPosTable.FirstOrDefault();
                if (first != null && Evade.LastPosInfo != null && first.IsDangerousPos == false && Evade.LastPosInfo.PosDangerLevel > first.PosDangerLevel)
                {
                    return(first);
                }
            }
            else
            {
                var sortedPosTable = posTable.OrderBy(p => p.IsDangerousPos).ThenBy(p => p.DistanceToMouse);

                var first = sortedPosTable.FirstOrDefault();

                return(first);
            }

            return(null);
        }