Esempio n. 1
0
        private void BounceQ()
        {
            var minions = MinionManager.GetMinions(Spells[Q].Range, MinionTypes.All, MinionTeam.NotAlly).Where(p => !p.IsMoving);
            List <Obj_AI_Base> nonKillableMinions = new List <Obj_AI_Base>();

            foreach (var minion in minions)
            {
                if (Spells[Q].IsKillable(minion)) //prio killable minions to deal more dmg
                {
                    var hitbox1 = ClipperWrapper.DefineSector(minion.ServerPosition.To2D(), (minion.ServerPosition.To2D() - ObjectManager.Player.ServerPosition.To2D()).Normalized(), 40, 500f);
                    var hitbox2 = ClipperWrapper.DefineSector(minion.ServerPosition.To2D(), (minion.ServerPosition.To2D() - ObjectManager.Player.ServerPosition.To2D()).Normalized(), 20, 500f);
                    //var hitbox3 = ClipperWrapper.DefineSector(minion.ServerPosition.To2D(), (minion.ServerPosition.To2D() - ObjectManager.Player.ServerPosition.To2D()).Normalized(), 110, 300f);
                    //var hitbox4 = ClipperWrapper.DefineSector(minion.ServerPosition.To2D(), (minion.ServerPosition.To2D() - ObjectManager.Player.ServerPosition.To2D()).Normalized(), 160, 150f);

                    if (HeroManager.Enemies.Any(p => minion.Distance(ObjectManager.Player.ServerPosition.To2D()) < 500f && p.NetworkId == m_lastTarget.NetworkId && !hitbox1.IsOutside(SCommon.Prediction.Prediction.GetFastUnitPosition(p, 0.3f))))
                    {
                        Spells[Q].CastOnUnit(minion);
                        return;
                    }
                    else if (!ObjectManager.Get <Obj_AI_Base>().Any(p => p.IsValidTarget(1200f) && p.IsEnemy && !p.IsChampion() && !hitbox2.IsOutside(p.ServerPosition.To2D())) &&
                             HeroManager.Enemies.Any(p => minion.Distance(ObjectManager.Player.ServerPosition.To2D()) < 500f && (TargetSelector.SelectedTarget == null || TargetSelector.SelectedTarget.NetworkId == p.NetworkId) && !hitbox2.IsOutside(SCommon.Prediction.Prediction.GetFastUnitPosition(p, 0.3f))))
                    {
                        Spells[Q].CastOnUnit(minion);
                        return;
                    }
                    else if (!ObjectManager.Get <Obj_AI_Base>().Any(p => p.IsValidTarget(1200f) && p.IsEnemy && !p.IsChampion() && !hitbox1.IsOutside(p.ServerPosition.To2D())) &&
                             HeroManager.Enemies.Any(p => minion.Distance(ObjectManager.Player.ServerPosition.To2D()) < 500f && (TargetSelector.SelectedTarget == null || TargetSelector.SelectedTarget.NetworkId == p.NetworkId) && !hitbox1.IsOutside(SCommon.Prediction.Prediction.GetFastUnitPosition(p, 0.3f))))
                    {
                        Spells[Q].CastOnUnit(minion);
                        return;
                    }
                }
                else
                {
                    nonKillableMinions.Add(minion);
                }
            }

            foreach (var minion in nonKillableMinions)
            {
                var hitbox1 = ClipperWrapper.DefineSector(minion.ServerPosition.To2D(), (minion.ServerPosition.To2D() - ObjectManager.Player.ServerPosition.To2D()).Normalized(), 40, 500f);
                var hitbox2 = ClipperWrapper.DefineSector(minion.ServerPosition.To2D(), (minion.ServerPosition.To2D() - ObjectManager.Player.ServerPosition.To2D()).Normalized(), 20, 500f);
                //var hitbox3 = ClipperWrapper.DefineSector(minion.ServerPosition.To2D(), (minion.ServerPosition.To2D() - ObjectManager.Player.ServerPosition.To2D()).Normalized(), 110, 300f);
                //var hitbox4 = ClipperWrapper.DefineSector(minion.ServerPosition.To2D(), (minion.ServerPosition.To2D() - ObjectManager.Player.ServerPosition.To2D()).Normalized(), 160, 150f);

                if (HeroManager.Enemies.Any(p => minion.Distance(ObjectManager.Player.ServerPosition.To2D()) < 300 && p.NetworkId == m_lastTarget.NetworkId && !hitbox1.IsOutside(SCommon.Prediction.Prediction.GetFastUnitPosition(p, 0.3f))))
                {
                    Spells[Q].CastOnUnit(minion);
                    return;
                }
                else if (!ObjectManager.Get <Obj_AI_Base>().Any(p => p.IsValidTarget(1200f) && p.IsEnemy && !p.IsChampion() && !hitbox2.IsOutside(p.ServerPosition.To2D())) &&
                         HeroManager.Enemies.Any(p => minion.Distance(ObjectManager.Player.ServerPosition.To2D()) < 500f && (TargetSelector.SelectedTarget == null || TargetSelector.SelectedTarget.NetworkId == p.NetworkId) && !hitbox2.IsOutside(SCommon.Prediction.Prediction.GetFastUnitPosition(p, 0.3f))))
                {
                    Spells[Q].CastOnUnit(minion);
                    return;
                }
                else if (!ObjectManager.Get <Obj_AI_Base>().Any(p => p.IsValidTarget(1200f) && p.IsEnemy && !p.IsChampion() && !hitbox1.IsOutside(p.ServerPosition.To2D())) &&
                         HeroManager.Enemies.Any(p => minion.Distance(ObjectManager.Player.ServerPosition.To2D()) < 500f && (TargetSelector.SelectedTarget == null || TargetSelector.SelectedTarget.NetworkId == p.NetworkId) && !hitbox1.IsOutside(SCommon.Prediction.Prediction.GetFastUnitPosition(p, 0.3f))))
                {
                    Spells[Q].CastOnUnit(minion);
                    return;
                }
            }
        }
Esempio n. 2
0
        /// <summary>
        ///     The thread which detects spell hits
        /// </summary>
        public void EvadeThread()
        {
            //TO DO: evade with targetted spells (jax, irelia, master etc..)
            DetectedSpellData dcspell;

            while (true)
            {
                try
                {
                    if (m_spell_queue.TryDequeue(out dcspell))
                    {
                        var my_pos     = ObjectManager.Player.ServerPosition.To2D();
                        var sender_pos = dcspell.StartPosition;
                        var end_pos    = dcspell.EndPosition;
                        var direction  = (end_pos - sender_pos).Normalized();
                        if (sender_pos.Distance(end_pos) > dcspell.Spell.Range)
                        {
                            end_pos = sender_pos + direction * dcspell.Spell.Range;
                        }

                        var my_hitbox = ClipperWrapper.DefineRectangle(my_pos - 60, my_pos + 60, 60);
                        Geometry.Polygon spell_hitbox = null;

                        if (dcspell.Spell.IsSkillshot)
                        {
                            if (dcspell.Spell.Type == SkillshotType.SkillshotLine)
                            {
                                spell_hitbox = ClipperWrapper.DefineRectangle(sender_pos, end_pos, dcspell.Spell.Radius);
                            }
                            else if (dcspell.Spell.Type == SkillshotType.SkillshotCircle)
                            {
                                spell_hitbox = ClipperWrapper.DefineCircle(end_pos, dcspell.Spell.Radius);
                            }
                            else if (dcspell.Spell.Type == SkillshotType.SkillshotCone)
                            {
                                spell_hitbox = ClipperWrapper.DefineSector(sender_pos, end_pos - sender_pos,
                                                                           dcspell.Spell.Radius * (float)Math.PI / 180, dcspell.Spell.Range);
                            }
                        }

                        //spells with arc
                        if (dcspell.Spell.IsArc)
                        {
                            var mul = end_pos.Distance(sender_pos) / (dcspell.Spell.Range - 20.0f);

                            spell_hitbox = new Geometry.Polygon(
                                ClipperWrapper.DefineArc(sender_pos - dcspell.Spell.ArcData.Pos, end_pos,
                                                         dcspell.Spell.ArcData.Angle * mul, dcspell.Spell.ArcData.Width,
                                                         dcspell.Spell.ArcData.Height * mul),
                                ClipperWrapper.DefineArc(sender_pos - dcspell.Spell.ArcData.Pos, end_pos,
                                                         dcspell.Spell.ArcData.Angle * mul, dcspell.Spell.ArcData.Width,
                                                         (dcspell.Spell.ArcData.Height + dcspell.Spell.ArcData.Radius) * mul),
                                spell_hitbox);
                        }

                        if (spell_hitbox != null)
                        {
                            if (ClipperWrapper.IsIntersects(ClipperWrapper.MakePaths(my_hitbox),
                                                            ClipperWrapper.MakePaths(spell_hitbox)))
                            {
                                OnSpellHitDetected(direction, ObjectManager.Player);
                            }
                            else
                            {
                                if (ObjectManager.Player.CharData.BaseSkinName == "Morgana" &&
                                    getCheckBoxItem("SHIELDENABLED"))
                                {
                                    var allies =
                                        ObjectManager.Player.GetAlliesInRange(EvadeSpell.Range)
                                        .Where(p => !p.IsMe && getCheckBoxItem("shield" + p.ChampionName));

                                    if (allies != null)
                                    {
                                        foreach (var ally in allies)
                                        {
                                            var ally_pos    = ally.ServerPosition.To2D();
                                            var ally_hitbox = ClipperWrapper.DefineRectangle(ally_pos, ally_pos + 60, 60);
                                            if (ClipperWrapper.IsIntersects(ClipperWrapper.MakePaths(ally_hitbox),
                                                                            ClipperWrapper.MakePaths(spell_hitbox)))
                                            {
                                                OnSpellHitDetected(direction, ally);
                                                break;
                                            }
                                        }
                                    }
                                }
                            }
                        }
                        m_spell_pool.PutObject(dcspell);
                    }
                }
                catch
                {
                }
                Thread.Sleep(1);
            }
        }