public static bool IsSamePosInfo(this PositionInfo posInfo1, PositionInfo posInfo2)
 {
     return new HashSet<int>(posInfo1.SpellList).SetEquals(posInfo2.SpellList);
 }
Example #2
0
        public static PositionInfo GetBestPositionTargetedDash(EvadeSpellData spell)
        {
            /*if (spell.spellDelay > 0)
            {
                if (CheckWindupTime(spell.spellDelay))
                {
                    return null;
                }
            }*/

            var extraDelayBuffer = Config.Properties.GetInt(ConfigValue.ExtraPingBuffer);
            var extraDist = ConfigValue.ExtraCpaDistance.GetInt();

            Vector2 heroPoint = GameData.HeroInfo.ServerPos2DPing;
            Vector2 lastMovePos = Game.CursorPos.To2D();

            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.IsValidTarget(spell.Range)))
                {
                    if (obj.GetType() == typeof(Obj_AI_Turret) && ((Obj_AI_Turret)obj).IsValid())
                    {
                        collisionCandidates.Add(obj);
                    }
                }
            }
            else
            {
                List<AIHeroClient> heroList = new List<AIHeroClient>();

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


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

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

                if (spell.SpellTargets.Contains(SpellTargets.EnemyMinions)
                    && spell.SpellTargets.Contains(SpellTargets.AllyMinions))
                {
                    minionList = EntityManager.MinionsAndMonsters.GetLaneMinions(EntityManager.UnitTeam.Both, Player.Instance.ServerPosition, spell.Range).ToList();
                }
                else if (spell.SpellTargets.Contains(SpellTargets.EnemyMinions))
                {
                    minionList = EntityManager.MinionsAndMonsters.GetLaneMinions(EntityManager.UnitTeam.Enemy, Player.Instance.ServerPosition, spell.Range).ToList();
                }
                else if (spell.SpellTargets.Contains(SpellTargets.AllyMinions))
                {
                    minionList = EntityManager.MinionsAndMonsters.GetLaneMinions(EntityManager.UnitTeam.Ally, Player.Instance.ServerPosition, spell.Range).ToList();
                }

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

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

                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).Normalized();
                    pos = pos + dir * (candidate.BoundingRadius + GameData.HeroInfo.BoundingRadius);
                }

                if (spell.InfrontTarget)
                {
                    var dir = (pos - heroPoint).Normalized();
                    pos = pos - dir * (candidate.BoundingRadius + GameData.HeroInfo.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 + Game.Ping, 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 && AdEvade.LastPosInfo != null && first.IsDangerousPos == false
                    && AdEvade.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;

        }
Example #3
0
 public static bool PositionInfoStillValid(PositionInfo posInfo, float moveSpeed = 0)
 {
     return true; //too buggy
 }
Example #4
0
        public static PositionInfo GetBestPositionBlink()
        {
            int posChecked = 0;
            int maxPosToCheck = 100;
            int posRadius = 50;
            int radiusIndex = 0;

            var extraEvadeDistance = ConfigValue.ExtraSpellRadius.GetInt();

            Vector2 heroPoint = GameData.HeroInfo.ServerPos2DPing;
            Vector2 lastMovePos = Game.CursorPos.To2D();

            int minComfortZone = ConfigValue.MinimumComfortZone.GetInt();

            List<PositionInfo> posTable = new List<PositionInfo>();

            while (posChecked < maxPosToCheck)
            {
                radiusIndex++;

                int curRadius = radiusIndex * (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)));

                    bool isDangerousPos = pos.CheckDangerousPos(6);
                    var dist = pos.GetPositionValue();

                    var posInfo = new PositionInfo(pos, isDangerousPos, dist);
                    posInfo.HasExtraDistance = extraEvadeDistance > 0 ? pos.CheckDangerousPos(extraEvadeDistance) : false;

                    posInfo.PosDistToChamps = pos.GetDistanceToChampions();

                    if (minComfortZone < posInfo.PosDistToChamps)
                    {
                        posTable.Add(posInfo);
                    }
                }
            }

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

            foreach (var posInfo in sortedPosTable)
            {
                if (CheckPointCollision(MyHero, posInfo.Position) == false)
                    return posInfo;
            }

            return null;
        }