Ejemplo n.º 1
0
        public static PositionInfo GetBestPositionTargetedDash(EvadeSpellData spell)
        {
            /*if (spell.spellDelay > 0)
             * {
             *  if (CheckWindupTime(spell.spellDelay))
             *  {
             *      return null;
             *  }
             * }*/

            var extraDelayBuffer = ObjectCache.menuCache.cache["ExtraPingBuffer"].Cast <Slider>().CurrentValue;
            var extraDist        = ObjectCache.menuCache.cache["ExtraCPADistance"].Cast <Slider>().CurrentValue;

            Vector2 heroPoint   = ObjectCache.myHeroCache.serverPos2DPing;
            Vector2 lastMovePos = Game.CursorPos.LSTo2D();

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

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

            if (spell.fixedRange)
            {
                minDistance = maxDistance = (int)spell.range;
            }

            List <Obj_AI_Base> collisionCandidates = new List <Obj_AI_Base>();

            if (spell.spellTargets.Contains(SpellTargets.Targetables))
            {
                foreach (var obj in ObjectManager.Get <Obj_AI_Base>()
                         .Where(h => !h.IsMe && h.LSIsValidTarget(spell.range, false)))
                {
                    if (!obj.IsValid <Obj_AI_Turret>())
                    {
                        collisionCandidates.Add(obj);
                    }
                }
            }
            else
            {
                List <AIHeroClient> heroList = new List <AIHeroClient>();

                if (spell.spellTargets.Contains(SpellTargets.EnemyChampions) &&
                    spell.spellTargets.Contains(SpellTargets.AllyChampions))
                {
                    heroList = HeroManager.AllHeroes;
                }
                else if (spell.spellTargets.Contains(SpellTargets.EnemyChampions))
                {
                    heroList = HeroManager.Enemies;
                }
                else if (spell.spellTargets.Contains(SpellTargets.AllyChampions))
                {
                    heroList = HeroManager.Allies;
                }


                foreach (var hero in heroList.Where(h => !h.IsMe && h.LSIsValidTarget(spell.range)))
                {
                    collisionCandidates.Add(hero);
                }

                List <Obj_AI_Base> minionList = new List <Obj_AI_Base>();

                if (spell.spellTargets.Contains(SpellTargets.EnemyMinions) &&
                    spell.spellTargets.Contains(SpellTargets.AllyMinions))
                {
                    minionList = MinionManager.GetMinions(spell.range, MinionTypes.All, MinionTeam.All);
                }
                else if (spell.spellTargets.Contains(SpellTargets.EnemyMinions))
                {
                    minionList = MinionManager.GetMinions(spell.range, MinionTypes.All, MinionTeam.Enemy);
                }
                else if (spell.spellTargets.Contains(SpellTargets.AllyMinions))
                {
                    minionList = MinionManager.GetMinions(spell.range, MinionTypes.All, MinionTeam.Ally);
                }

                foreach (var minion in minionList.Where(h => h.LSIsValidTarget(spell.range)))
                {
                    collisionCandidates.Add(minion);
                }
            }

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

                PositionInfo posInfo;

                if (spell.spellName == "YasuoDashWrapper")
                {
                    bool hasDashBuff = false;

                    foreach (var buff in candidate.Buffs)
                    {
                        if (buff.Name == "YasuoDashWrapper")
                        {
                            hasDashBuff = true;
                            break;
                        }
                    }

                    if (hasDashBuff)
                    {
                        continue;
                    }
                }

                if (spell.behindTarget)
                {
                    var dir = (pos - heroPoint).LSNormalized();
                    pos = pos + dir * (candidate.BoundingRadius + ObjectCache.myHeroCache.boundingRadius);
                }

                if (spell.infrontTarget)
                {
                    var dir = (pos - heroPoint).LSNormalized();
                    pos = pos - dir * (candidate.BoundingRadius + ObjectCache.myHeroCache.boundingRadius);
                }

                if (spell.fixedRange)
                {
                    var dir = (pos - heroPoint).LSNormalized();
                    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
                {
                    bool 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)
                    //.ThenByDescending(p => p.hasComfortZone)
                    //.ThenBy(p => p.hasExtraDistance)
                    .ThenBy(p => p.distanceToMouse);

                var first = sortedPosTable.FirstOrDefault();

                return(first);
            }

            return(null);
        }
Ejemplo n.º 2
0
        public static PositionInfo GetBestPositionDash(EvadeSpellData spell)
        {
            int posChecked    = 0;
            int maxPosToCheck = 100;
            int posRadius     = 50;
            int radiusIndex   = 0;

            var extraDelayBuffer   = ObjectCache.menuCache.cache["ExtraPingBuffer"].Cast <Slider>().CurrentValue;
            var extraEvadeDistance = 100;// Evade.menu.SubMenu("MiscSettings").SubMenu("ExtraBuffers").Item("ExtraEvadeDistance").GetValue<Slider>().Value;
            var extraDist          = ObjectCache.menuCache.cache["ExtraCPADistance"].Cast <Slider>().CurrentValue;

            Vector2 heroPoint   = ObjectCache.myHeroCache.serverPos2DPing;
            Vector2 lastMovePos = Game.CursorPos.LSTo2D();

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

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

            if (spell.fixedRange)
            {
                minDistance = maxDistance = (int)spell.range;
            }

            while (posChecked < maxPosToCheck)
            {
                radiusIndex++;

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

                for (int 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) : false;// ? 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);

            foreach (var posInfo in sortedPosTable)
            {
                if (CheckPathCollision(myHero, posInfo.position) == false)
                {
                    if (PositionInfoStillValid(posInfo, spell.speed))
                    {
                        return(posInfo);
                    }
                }
            }

            return(null);
        }