示例#1
0
        private static bool WillbeHit(Obj_AI_Hero target)
        {
            if (target == null || !target.IsValidTarget())
            {
                return(false);
            }

            var minions =
                GameObjects.EnemyMinions.Where(x => x.IsValidTarget(E.Range) && (x.IsMinion() || x.IsMob())).ToArray();

            if (minions.Any())
            {
                var targetPosition = target.ServerPosition;
                var fromPosition   = ObjectManager.GetLocalPlayer().ServerPosition;
                var width          = 40 + target.BoundingRadius * 0.65f;
                var rect           = new MyPolygon.Rectangle(fromPosition, targetPosition, width);

                return
                    (minions.Select(
                         minion => new MyPolygon.Circle(minion.ServerPosition.To2D(), minion.BoundingRadius * 0.65f))
                     .All(circ => !circ.Points.Any(p => rect.IsInside(p))));
            }

            return(true);
        }
示例#2
0
        private static void QLogic(Obj_AI_Hero target, bool useExtendQ = true)
        {
            if (!Q.Ready || target == null || target.IsDead || target.IsUnKillable())
            {
                return;
            }

            if (target.IsValidTarget(Q.Range))
            {
                Q.CastOnUnit(target);
            }
            else if (target.IsValidTarget(Q2.Range) && useExtendQ)
            {
                var collisions =
                    GameObjects.EnemyMinions.Where(x => x.IsValidTarget(Q.Range) && (x.IsMinion() || x.IsMob()))
                    .ToArray();

                if (!collisions.Any())
                {
                    return;
                }

                foreach (var minion in collisions)
                {
                    var qPred    = Q2.GetPrediction(target);
                    var qPloygon = new MyPolygon.Rectangle(Me.ServerPosition, Me.ServerPosition.Extend(minion.Position, Q2.Range), Q2.Width);

                    if (qPloygon.IsInside(qPred.UnitPosition.To2D()) && minion.IsValidTarget(Q.Range))
                    {
                        Q.CastOnUnit(minion);
                        break;
                    }
                }
            }
        }
示例#3
0
 public static Result GetLineAoePrediction(this Spell spell, Obj_AI_Hero target, HitChance hitChance,
                                           bool boundingRadius = true, bool maxRange = true, Vector3?sourcePosition = null)
 {
     try
     {
         if (spell == null || target == null)
         {
             return(new Result(Vector3.Zero, new List <Obj_AI_Hero>()));
         }
         var fromPosition = sourcePosition ?? ObjectManager.GetLocalPlayer().ServerPosition;
         var range        = (spell.IsChargedSpell && maxRange ? spell.ChargedMaxRange : spell.Range) +
                            spell.Width * 0.9f +
                            (boundingRadius ? target.BoundingRadius * BoundingRadiusMultiplicator : 0);
         var positions = (from t in GameObjects.EnemyHeroes
                          where t.IsValidTarget(range, false, false, fromPosition)
                          let prediction = spell.GetPrediction(t)
                                           where prediction.HitChance >= hitChance
                                           select new Position(t, prediction.UnitPosition)).ToList();
         if (positions.Any())
         {
             var hits = new List <Obj_AI_Hero>();
             var pred = spell.GetPrediction(target);
             if (pred.HitChance >= hitChance)
             {
                 hits.Add(target);
                 var rect = new MyPolygon.Rectangle(
                     spell.From, spell.From.Extend(pred.CastPosition, range), spell.Width);
                 if (boundingRadius)
                 {
                     hits.AddRange(
                         from point in positions.Where(p => p.Hero.NetworkId != target.NetworkId)
                         let circle =
                             new MyPolygon.Circle(
                                 point.UnitPosition, point.Hero.BoundingRadius * BoundingRadiusMultiplicator)
                             where circle.Points.Any(p => rect.IsInside(p))
                             select point.Hero);
                 }
                 else
                 {
                     hits.AddRange(
                         from position in positions
                         where rect.IsInside(position.UnitPosition)
                         select position.Hero);
                 }
                 return(new Result(pred.CastPosition, hits));
             }
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex);
     }
     return(new Result(Vector3.Zero, new List <Obj_AI_Hero>()));
 }
示例#4
0
        public static bool GetLineAoeCanHit(float spellrange, float spellwidth, Obj_AI_Base target, HitChance hitChance, Vector3 endRange,
                                            bool boundingRadius = true)
        {
            if (target == null || target.IsDashing())
            {
                return(false);
            }

            var targetPosition = target.ServerPosition.To2D();
            var fromPosition   = ObjectManager.GetLocalPlayer().ServerPosition;
            var width          = spellwidth + (boundingRadius ? target.BoundingRadius * BoundingRadiusMultiplicator : 0);
            var boundradius    = (boundingRadius
                ? target.BoundingRadius * BoundingRadiusMultiplicator
                : target.BoundingRadius);

            var rect = new MyPolygon.Rectangle(fromPosition, endRange, width);
            var circ = new MyPolygon.Circle(targetPosition, boundradius);

            return(circ.Points.Select(point => rect.IsInside(point)).FirstOrDefault());
        }