Beispiel #1
0
        private void SpellDetector_OnProcessDetectedSpells()
        {
            GameData.HeroInfo.UpdateInfo();
            if (!ConfigValue.DodgeSkillShots.GetBool())
            {
                LastPosInfo = PositionInfo.SetAllUndodgeable();
                EvadeSpell.UseEvadeSpell();
                return;
            }
            if (GameData.HeroInfo.ServerPos2D.CheckDangerousPos(0) || GameData.HeroInfo.ServerPos2DExtra.CheckDangerousPos(0))
            {
                if (EvadeSpell.PreferEvadeSpell())
                {
                    LastPosInfo = PositionInfo.SetAllUndodgeable();
                }
                else
                {
                    var calculationTimer = EvadeUtils.TickCount;

                    var posInfo = EvadeHelper.GetBestPosition();

                    var caculationTime = EvadeUtils.TickCount - calculationTimer;

                    if (NumCalculationTime > 0)
                    {
                        SumCalculationTime += caculationTime;
                        AvgCalculationTime  = SumCalculationTime / NumCalculationTime;
                    }
                    NumCalculationTime += 1;

                    //ConsoleDebug.WriteLine("CalculationTime: " + caculationTime);

                    /*if (EvadeHelper.GetHighestDetectedSpellID() > EvadeHelper.GetHighestSpellID(posInfo))
                     * {
                     *  return;
                     * }*/
                    if (posInfo != null)
                    {
                        LastPosInfo = posInfo.CompareLastMovePos();

                        var travelTime = GameData.HeroInfo.ServerPos2DPing.Distance(LastPosInfo.Position) / GameData.MyHero.MoveSpeed;

                        LastPosInfo.EndTime = EvadeUtils.TickCount + travelTime * 1000 - 100;
                    }

                    CheckHeroInDanger();
                    DodgeSkillShots();          //walking
                    CheckLastMoveTo();
                    EvadeSpell.UseEvadeSpell(); //using spells
                }
            }
            else
            {
                LastPosInfo = PositionInfo.SetAllDodgeable();
                CheckLastMoveTo();
            }


            //ConsoleDebug.WriteLine("SkillsDodged: " + lastPosInfo.dodgeableSpells.Count + " DangerLevel: " + lastPosInfo.undodgeableSpells.Count);
        }
Beispiel #2
0
        private void RecalculatePath()
        {
            if (ConfigValue.RecalculatePath.GetBool() && IsDodging) //recheck path
            {
                if (LastPosInfo != null && !LastPosInfo.RecalculatedPath)
                {
                    var path = GameData.MyHero.Path;
                    if (path.Length > 0)
                    {
                        var movePos = path.Last().To2D();

                        if (movePos.Distance(LastPosInfo.Position) < 5) //more strict checking
                        {
                            var posInfo = EvadeHelper.CanHeroWalkToPos(movePos, GameData.HeroInfo.MoveSpeed, 0, 0, false);
                            if (posInfo.PosDangerCount > LastPosInfo.PosDangerCount)
                            {
                                LastPosInfo.RecalculatedPath = true;

                                if (EvadeSpell.PreferEvadeSpell())
                                {
                                    LastPosInfo = PositionInfo.SetAllUndodgeable();
                                }
                                else
                                {
                                    var newPosInfo = EvadeHelper.GetBestPosition();
                                    if (newPosInfo.PosDangerCount < posInfo.PosDangerCount)
                                    {
                                        LastPosInfo = newPosInfo;
                                        CheckHeroInDanger();
                                        DodgeSkillShots();
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
Beispiel #3
0
 public static bool IsSamePosInfo(this PositionInfo posInfo1, PositionInfo posInfo2)
 {
     return new HashSet<int>(posInfo1.SpellList).SetEquals(posInfo2.SpellList);
 }
Beispiel #4
0
 public static void SetAllUndodgeable()
 {
     LastPosInfo = PositionInfo.SetAllUndodgeable();
 }
Beispiel #5
0
        private void Game_OnCastSpell(Spellbook spellbook, SpellbookCastSpellEventArgs args)
        {
            if (!spellbook.Owner.IsMe)
            {
                return;
            }

            var    sData = spellbook.GetSpell(args.Slot);
            string name;

            if (SpellDetector.ChanneledSpells.TryGetValue(sData.Name, out name))
            {
                //Evade.isChanneling = true;
                //Evade.channelPosition = GameData.HeroInfo.serverPos2D;
                LastStopEvadeTime = EvadeUtils.TickCount + Game.Ping + 100;
            }

            if (EvadeSpell.LastSpellEvadeCommand != null &&
                EvadeSpell.LastSpellEvadeCommand.Timestamp + Game.Ping + 150 > EvadeUtils.TickCount)
            {
                args.Process = false;
            }

            LastSpellCast     = args.Slot;
            LastSpellCastTime = EvadeUtils.TickCount;

            //moved from processPacket

            /*if (args.Slot == SpellSlot.Recall)
             * {
             *  lastStopPosition = GameData.MyHero.ServerPosition.To2D();
             * }*/

            if (Situation.ShouldDodge())
            {
                if (IsDodging && SpellDetector.Spells.Count() > 0)
                {
                    foreach (KeyValuePair <String, SpellData> entry in SpellDetector.WindupSpells)
                    {
                        SpellData spellData = entry.Value;

                        if (spellData.SpellKey == args.Slot) //check if it's a spell that we should block
                        {
                            args.Process = false;
                            return;
                        }
                    }
                }
            }

            foreach (var evadeSpell in EvadeSpell.EvadeSpells)
            {
                if (evadeSpell.IsItem == false && evadeSpell.SpellKey == args.Slot)
                {
                    if (evadeSpell.EvadeType == EvadeType.Blink ||
                        evadeSpell.EvadeType == EvadeType.Dash)
                    {
                        //Block spell cast if flashing/blinking into spells
                        if (args.EndPosition.To2D().CheckDangerousPos(6, true)) //for blink + dash
                        {
                            args.Process = false;
                            return;
                        }

                        if (evadeSpell.EvadeType == EvadeType.Dash)
                        {
                            var extraDelayBuffer = Config.Properties.GetInt(ConfigValue.ExtraPingBuffer);
                            var extraDist        = Config.Properties.GetInt(ConfigValue.ExtraCpaDistance);

                            var dashPos = Game.CursorPos.To2D(); //real pos?

                            if (evadeSpell.FixedRange)
                            {
                                var dir = (dashPos - GameData.MyHero.ServerPosition.To2D()).Normalized();
                                dashPos = GameData.MyHero.ServerPosition.To2D() + dir * evadeSpell.Range;
                            }

                            //Draw.RenderObjects.Add(new Draw.RenderPosition(dashPos, 1000));

                            var posInfo = EvadeHelper.CanHeroWalkToPos(dashPos, evadeSpell.Speed,
                                                                       extraDelayBuffer + Game.Ping, extraDist);

                            if (posInfo.PosDangerLevel > 0)
                            {
                                args.Process = false;
                                return;
                            }
                        }

                        LastPosInfo = PositionInfo.SetAllUndodgeable(); //really?

                        if (IsDodging || EvadeUtils.TickCount < LastDodgingEndTime + 500)
                        {
                            EvadeCommand.MoveTo(Game.CursorPos.To2D()); //block moveto
                            LastStopEvadeTime = EvadeUtils.TickCount + Game.Ping + 100;
                        }
                    }
                    return;
                }
            }
        }
Beispiel #6
0
 public static bool IsSamePosInfo(this PositionInfo posInfo1, PositionInfo posInfo2)
 {
     return(new HashSet <int>(posInfo1.SpellList).SetEquals(posInfo2.SpellList));
 }
Beispiel #7
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 && 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;
        }
Beispiel #8
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;
        }
Beispiel #9
0
 public static bool PositionInfoStillValid(PositionInfo posInfo, float moveSpeed = 0)
 {
     return true; //too buggy
 }