Ejemplo n.º 1
0
        private static void DrawBestLine(Spell spell, Spell spell2, int midPointRange, float extraPrerange = 1, bool wallCheck = true)
        {
            //---------------------------------MEC----------------------------
            int     maxHit = 0;
            Vector3 start  = Vector3.Zero;
            Vector3 end    = Vector3.Zero;

            //loop one
            foreach (var target in ObjectManager.Get <AIHeroClient>().Where(x => x.IsValidTarget(spell.Range)))
            {
                //loop 2
                var target1 = target;
                var target2 = target;
                foreach (var enemy in ObjectManager.Get <AIHeroClient>().Where(x => x.IsValidTarget(spell.Range + spell2.Range) && x.NetworkId != target1.NetworkId &&
                                                                               x.Distance(target1.Position) < spell2.Range - 100).OrderByDescending(x => x.Distance(target2.Position)))
                {
                    int hit = 2;

                    var targetPred = spell.GetPrediction(target);
                    var enemyPred  = spell.GetPrediction(enemy);

                    var midpoint = (enemyPred.CastPosition + targetPred.CastPosition) / 2;

                    var startpos = midpoint + Vector3.Normalize(enemyPred.CastPosition - targetPred.CastPosition) * midPointRange;
                    var endPos   = midpoint - Vector3.Normalize(enemyPred.CastPosition - targetPred.CastPosition) * midPointRange;

                    Geometry.Rectangle rec1 = new Geometry.Rectangle(startpos, endPos, spell.Width);

                    if (!rec1.Points.Exists(IsWall) && Player.CountEnemiesInRange(spell.Range + spell2.Range) > 2)
                    {
                        //loop 3
                        var target3 = target;
                        var enemy1  = enemy;
                        foreach (var enemy2 in ObjectManager.Get <AIHeroClient>().Where(x => x.IsValidTarget(spell.Range + spell2.Range) && x.NetworkId != target3.NetworkId && x.NetworkId != enemy1.NetworkId && x.Distance(target3.Position) < spell2.Range))
                        {
                            var      enemy2Pred = spell.GetPrediction(enemy2);
                            Object[] obj        = Util.VectorPointProjectionOnLineSegment(startpos.ToVector2(), endPos.ToVector2(), enemy2Pred.CastPosition.ToVector2());
                            var      isOnseg    = (bool)obj[2];
                            var      pointLine  = (Vector2)obj[1];

                            if (pointLine.Distance(enemy2Pred.CastPosition.ToVector2()) < spell.Width && isOnseg)
                            {
                                hit++;
                            }
                        }
                    }

                    if (hit > maxHit && hit > 1 && !rec1.Points.Exists(IsWall))
                    {
                        maxHit = hit;
                        start  = startpos;
                        end    = endPos;
                    }
                }
            }

            if (maxHit >= 2)
            {
                Vector2 wts = Drawing.WorldToScreen(Player.Position);
                Drawing.DrawText(wts[0], wts[1], Color.Wheat, "Hit: " + maxHit);

                Geometry.Rectangle rec1 = new Geometry.Rectangle(start, end, spell.Width);
                rec1.Draw(Color.Blue, 4);
            }
            else
            {
                //-------------------------------Single---------------------------
                var target = TargetSelector.GetTarget(spell.Range + spell2.Range);

                if (target == null)
                {
                    return;
                }

                var vector1 = Player.Position + Vector3.Normalize(target.Position - Player.Position) * (spell.Range * extraPrerange);

                var pred = spell.GetPrediction(target);
                Geometry.Rectangle rec1 = new Geometry.Rectangle(vector1, vector1.Extend(pred.CastPosition, spell2.Range), spell.Width);

                if (Player.Distance(target) < spell.Range)
                {
                    vector1 = pred.CastPosition.Extend(target.Position, spell2.Range * .3f);
                    Geometry.Rectangle rec2 = new Geometry.Rectangle(vector1, vector1.Extend(pred.CastPosition, spell2.Range), spell.Width);

                    if ((!rec2.Points.Exists(IsWall) || !wallCheck) && pred.Hitchance >= HitChance.Medium && target.IsMoving)
                    {
                        Vector2 wts = Drawing.WorldToScreen(Player.Position);
                        Drawing.DrawText(wts[0], wts[1], Color.Wheat, "Hit: " + 1);

                        rec2.Draw(Color.Blue, 4);
                    }
                }
                else if (!rec1.Points.Exists(IsWall) || !wallCheck)
                {
                    //wall check
                    if (pred.Hitchance >= HitChance.High)
                    {
                        Vector2 wts = Drawing.WorldToScreen(Player.Position);
                        Drawing.DrawText(wts[0], wts[1], Color.Wheat, "Hit: " + 1);

                        rec1.Draw(Color.Blue, 4);
                    }
                }
            }
        }
Ejemplo n.º 2
0
        private static void OnDraw(EventArgs args)
        {
            if (myhero.IsDead || check(draw, "nodraw"))
            {
                return;
            }

            if (check(draw, "drawQ") && Q.Level > 0 && Q.IsReady())
            {
                Render.Circle.DrawCircle(ObjectManager.Player.Position, Q.Range, Color.Yellow, 1);
            }

            if (check(draw, "drawR") && R.Level > 0 && R.IsReady())
            {
                Render.Circle.DrawCircle(ObjectManager.Player.Position, R.Range, Color.Yellow, 1);
            }

            AIHeroClient target = GetTarget();//TargetSelector.GetTarget(Q.Range, DamageType.Magical, myhero.Position);

            if (target != null)
            {
                if (Q.IsReady())
                {
                    var qpred = Q.GetPrediction(target);

                    if (check(draw, "DRAWPRED"))
                    {
                        Geometry.Rectangle Prediction = new Geometry.Rectangle(myhero.Position, qpred.CastPosition, Q.Width);
                        Prediction.Draw(Color.Yellow, 1);
                    }

                    if (check(draw, "DRAWHIT"))
                    {
                        Drawing.DrawText(Drawing.WorldToScreen(myhero.Position).X - 50,
                                         Drawing.WorldToScreen(myhero.Position).Y + 10,
                                         Color.Yellow,
                                         "Hitchance %: ");
                        Drawing.DrawText(Drawing.WorldToScreen(myhero.Position).X + 37,
                                         Drawing.WorldToScreen(myhero.Position).Y + 10,
                                         Color.Green,
                                         qpred.Hitchance.ToString());
                    }
                }

                if (check(draw, "DRAWTARGET"))
                {
                    Render.Circle.DrawCircle(target.Position, 50, Color.Yellow, 1);
                }

                if (check(draw, "DRAWWAY") && target.Path.Any())
                {
                    for (var i = 1; target.Path.Length > i; i++)
                    {
                        if (target.Path[i - 1].IsValid() && target.Path[i].IsValid() && (target.Path[i - 1].IsOnScreen() || target.Path[i].IsOnScreen()))
                        {
                            Drawing.DrawLine(Drawing.WorldToScreen(target.Position), Drawing.WorldToScreen(target.Path[i]), 3, Color.White);
                        }
                    }
                }
            }
        }