Ejemplo n.º 1
0
        private async void Arrow(Particle particle, Vector3 position, string id)
        {
            var endPosition = position.Extend(position + particle.GetControlPoint(1), 3000);

            var color = Color;

            DrawRange($"ArrowStart_{id}", position, 100, color, 170);
            DrawRange($"ArrowEnd_{id}", endPosition, 100, color, 170);
            DrawLine($"Arrow_{id}", position, endPosition, 115, 185, Color.DarkRed);

            var rawGameTime = GameManager.RawGameTime;

            do
            {
                var distance = (GameManager.RawGameTime - rawGameTime) * 900;
                if (distance > 3000)
                {
                    break;
                }

                DrawRange($"ArrowMove_{id}", position.Extend(endPosition, distance), 100, color, 170);
                await Task.Delay(20);
            }while (particle.IsValid);

            DrawRangeRemove($"ArrowStart_{id}");
            DrawRangeRemove($"ArrowEnd_{id}");
            DrawRangeRemove($"ArrowMove_{id}");
            DrawLineRemove($"Arrow_{id}");
        }
Ejemplo n.º 2
0
 private Vector3 CalculateEndPos(Vector3 start, Vector3 end, float maxRange)
 {
     try
     {
         var dist   = start.Distance(end);
         var endPos = end;
         if (dist > maxRange)
         {
             endPos = start.Extend(end, maxRange);
         }
         if (endPos.IsWall())
         {
             for (var i = 0; i < 200; i = i + 10)
             {
                 var pos = start.Extend(endPos, dist + i);
                 if (!pos.IsWall())
                 {
                     return(pos);
                 }
             }
         }
         return(endPos);
     }
     catch (Exception ex)
     {
         //Global.Logger.AddItem(new LogItem(ex));
     }
     return(end);
 }
Ejemplo n.º 3
0
        public static Vector3 Away(this Vector3 myPos, Vector3 threatPos, float range, float add = 200,
                                   float resolution = 40)
        {
            Vector3 r  = threatPos.Extend(myPos, range).To3D();
            Vector3 re = threatPos.Extend(myPos, range + add).To3D();

            if (!NavMesh.GetCollisionFlags(re).HasFlag(CollisionFlags.Wall))
            {
                return(r);
            }
            for (int i = 1; i < resolution; i++)
            {
                if (
                    !NavMesh.GetCollisionFlags(re.RotatedAround(threatPos, 3.14f / resolution * i))
                    .HasFlag(CollisionFlags.Wall))
                {
                    return(r.RotatedAround(threatPos, 3.14f / resolution * i));
                }
                if (
                    !NavMesh.GetCollisionFlags(re.RotatedAround(threatPos, 3.14f / resolution * i * -1f))
                    .HasFlag(CollisionFlags.Wall))
                {
                    return(r.RotatedAround(threatPos, 3.14f / resolution * i * -1f));
                }
            }
            return(r);
        }
Ejemplo n.º 4
0
        private void Between()
        {
            AutoWalker.SetMode(Orbwalker.ActiveModes.LaneClear);
            Vector3 p = AvgPos(_currentWave);

            if (p.Distance(AutoWalker.MyNexus) > MyTurret.Distance(AutoWalker.MyNexus))
            {
                AIHeroClient ally =
                    EntityManager.Heroes.Allies.Where(
                        al => !al.IsMe &&
                        AutoWalker.P.Distance(al) < 1500 &&
                        al.Distance(EnemyTurret) < p.Distance(EnemyTurret) + 100 &&
                        _currentLogic.LocalAwareness.LocalDomination(al) < -10000)
                    .OrderBy(l => l.Distance(AutoWalker.P))
                    .FirstOrDefault();
                if (ally != null &&
                    Math.Abs(p.Distance(AutoWalker.EnemyNexus) - AutoWalker.P.Distance(AutoWalker.EnemyNexus)) < 200)
                {
                    p = ally.Position.Extend(MyTurret, 160).To3DWorld() + _randomVector;
                }
                p =
                    p.Extend(p.Extend(
                                 AutoWalker.P.Distance(MyTurret) < AutoWalker.P.Distance(EnemyTurret)
                            ? MyTurret
                            : EnemyTurret,
                                 400).To3D().RotatedAround(p, 1.57f), _randomExtend).To3DWorld();
                AutoWalker.WalkTo(p);
            }
            else
            {
                UnderMyTurret();
            }
        }
Ejemplo n.º 5
0
        private static void DrawLineIfWallBetween(Vector3 startPos, Obj_AI_Base target)
        {
            Vector3 endPos = YasuoCalcs.GetDashingEnd(target);

            List <Vector3> inbetweenPoints   = new List <Vector3>();
            Vector2        wallStartPosition = Vector2.Zero;
            Vector2        wallEndPosition   = Vector2.Zero;

            //get every point between yasuo's position and the end position of the dash extended to a range of 1000.
            //1 point is every 1/100 of total length
            for (int i = 0; i <= 100; i++)
            {
                inbetweenPoints.Add(startPos.Extend(startPos.Extend(endPos, 1000), i * (startPos.Distance(startPos.Extend(endPos, 1000)) / 100)).To3D());
            }

            //for every point in the list of points, find the beginning and the end of the wal
            foreach (Vector2 vec in inbetweenPoints)
            {
                if (vec.IsWall())
                {
                    if (wallStartPosition == Vector2.Zero)
                    {
                        wallStartPosition = vec;
                    }
                }
                else if (wallEndPosition == Vector2.Zero && wallStartPosition != Vector2.Zero)
                {
                    wallEndPosition = vec;
                }
            }

            //draw the wall in the color blue
            if (wallStartPosition != Vector2.Zero && wallEndPosition != Vector2.Zero)
            {
                double wallWidth      = Math.Round(wallStartPosition.Distance(wallEndPosition)),
                       distanceToWall = Math.Round(startPos.Distance(wallStartPosition)),
                       totalDistance  = Math.Round(wallStartPosition.Distance(wallEndPosition) + startPos.Distance(wallStartPosition)),
                       monsterDist    = Math.Round(target.Position.Distance(wallStartPosition));

                Drawing.DrawLine(wallStartPosition.To3D().WorldToScreen(), wallEndPosition.To3D().WorldToScreen(), 10, System.Drawing.Color.Black);

                //if the end point of yasuos dash brings him at least halfway between the two points (closer to the wall end than to the walls beginning)
                //and the wall has to be thinner than yasuo's total dash range. TESTED THIS TO CONFIRM IT WORKS
                //if (endPos.Distance(wallEndPosition) < endPos.Distance(wallStartPosition) && wallStartPosition.Distance(wallEndPosition) <= Program.E.Range)
                if (totalDistance <= 630)
                {
                    Drawing.DrawLine(startPos.WorldToScreen(), startPos.Extend(endPos, 1000).To3D().WorldToScreen(), 3, System.Drawing.Color.Green);
                }
                else
                {
                    Drawing.DrawLine(startPos.WorldToScreen(), startPos.Extend(endPos, 1000).To3D().WorldToScreen(), 3, System.Drawing.Color.Red);
                }
                Drawing.DrawText(wallStartPosition.To3D().WorldToScreen(), System.Drawing.Color.Purple, wallStartPosition.Distance(wallEndPosition).ToString(), 15);
                Drawing.DrawText(startPos.Extend(endPos, 1000).To3D().WorldToScreen(), System.Drawing.Color.Purple, (wallStartPosition.Distance(wallEndPosition) + startPos.Distance(wallStartPosition)).ToString(), 15);
                Drawing.DrawCircle(endPos, 50, System.Drawing.Color.White);
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        ///     The Ultimate Cone.
        /// </summary>
        public Vector2Geometry.Sector UltimateCone()
        {
            var targetPos = End;
            var range     = SpellClass.R.Range - UtilityClass.Player.BoundingRadius;
            var dir       = (targetPos - UtilityClass.Player.ServerPosition).Normalized();
            var spot      = targetPos + dir * range;

            return(new Vector2Geometry.Sector((Vector2)End.Extend(UtilityClass.Player.ServerPosition, End.Distance(UtilityClass.Player) + UtilityClass.Player.BoundingRadius * 3), (Vector2)spot, SpellClass.R2.Width, range));
        }
Ejemplo n.º 7
0
        public static Vector3[] Symmetry(this Vector3 center, Vector3 direction, float Range = 0)
        {
            if (Range.Equals(0))
            {
                Range = center.Distance(direction);
            }
            Vector3 pos1 = center.Extend(direction, Range).To3DWorld();
            Vector3 pos2 = center.Extend(direction, -Range).To3DWorld();

            return(new Vector3[] { pos1, pos2 });
        }
Ejemplo n.º 8
0
        public static Vector3 GetBestConeAndLinearCastPosition(this Spell.Skillshot cone, Spell.Skillshot linearSpell, List <Obj_AI_Base> enemies, Vector3 sourcePosition, out int bestHitNumber)
        {
            int radius = (int)cone.Range;

            enemies = enemies.Where(a => a.MeetsCriteria() && a.Position(linearSpell.CastDelay).IsInRange(sourcePosition, radius)).ToList();

            bestHitNumber = 0;
            Vector3 castPosition = Vector3.Zero;

            //if there is nothing that meets the criteria
            if (enemies.Count() == 0)
            {
                return(castPosition);
            }

            List <Tuple <Geometry.Polygon.Sector, Vector3> > conePositions = new List <Tuple <Geometry.Polygon.Sector, Vector3> >();

            Vector3 extendingPosition = sourcePosition + new Vector3(0, radius, 0);

            //checks every 15 degrees
            for (int i = 0; i < 24; i++)
            {
                Vector3 endPosition            = extendingPosition.To2D().RotateAroundPoint(sourcePosition.To2D(), (float)((i * 15) * Math.PI / 180)).To3D((int)sourcePosition.Z);
                Geometry.Polygon.Sector sector = new Geometry.Polygon.Sector(sourcePosition,
                                                                             endPosition, (float)(cone.ConeAngleDegrees * Math.PI / 180), radius);

                conePositions.Add(Tuple.Create(sector, endPosition));
            }

            //order list by most hit by Q1 and Q2
            conePositions = conePositions.OrderByDescending(a => a.Item1.EnemiesHitInSectorAndRectangle(new Geometry.Polygon.Rectangle(sourcePosition, a.Item2, linearSpell.Width), enemies, linearSpell.CastDelay)).ToList();
            //only leave the ones with the highest amount
            conePositions = conePositions.Where(a => a.Item1.EnemiesHitInSectorAndRectangle(new Geometry.Polygon.Rectangle(sourcePosition, a.Item2, linearSpell.Width), enemies, linearSpell.CastDelay) == conePositions[0].Item1.EnemiesHitInSectorAndRectangle(new Geometry.Polygon.Rectangle(sourcePosition, a.Item2, linearSpell.Width), enemies, linearSpell.CastDelay)).ToList();
            //from the ones with the most Sector/Line enemies hit, find the one with the most in the rectangle
            conePositions = conePositions.OrderByDescending(a => new Geometry.Polygon.Rectangle(sourcePosition, a.Item2, linearSpell.Width).EnemiesHitInRectangle(enemies, linearSpell.CastDelay)).ToList();
            //only take the ones with the most enemies
            conePositions = conePositions.Where(a => new Geometry.Polygon.Rectangle(sourcePosition, a.Item2, linearSpell.Width).EnemiesHitInRectangle(enemies, linearSpell.CastDelay) == new Geometry.Polygon.Rectangle(sourcePosition, conePositions[0].Item2, linearSpell.Width).EnemiesHitInRectangle(enemies, linearSpell.CastDelay)).ToList();
            //from the ones with the most sector/line enemies hit AND the most line enemies hit, find the ones with the most sector area
            conePositions = conePositions.OrderByDescending(a => a.Item1.EnemiesHitInSector(enemies, cone.CastDelay)).ToList();

            Tuple <Geometry.Polygon.Sector, Vector3> bestCone = conePositions.First();

            Geometry.Polygon.Rectangle spellRectangle = new Geometry.Polygon.Rectangle(sourcePosition, bestCone.Item2, linearSpell.Width);
            bestHitNumber = bestCone.Item1.EnemiesHitInSectorAndRectangle(spellRectangle, enemies, linearSpell.CastDelay);

            if (bestHitNumber == 1)
            {
                return(sourcePosition.Extend(bestCone.Item1.GetEnemiesHitInSectorAndRectangle(spellRectangle, enemies, linearSpell.CastDelay).FirstOrDefault().Position, radius - 1).To3D((int)sourcePosition.Z));
            }

            return(sourcePosition.Extend(bestCone.Item2, radius - 1).To3D((int)sourcePosition.Z));
        }
Ejemplo n.º 9
0
            public static Vector3 ClosestWall(Vector3 startPos, Vector3 endPos)
            {
                var distance = startPos.Distance(endPos);

                for (int i = 1; i < 6; i++)
                {
                    if (startPos.Extend(endPos, distance + 70 * i).IsWall())
                    {
                        return(startPos.Extend(endPos, distance + 70 * i));
                    }
                }
                return(endPos);
            }
Ejemplo n.º 10
0
            public static Vector3 ClosestWall(Vector3 StartPos, Vector3 EndPos)
            {
                var distance = StartPos.Distance(EndPos);

                for (int i = 1; i < 8; i++)
                {
                    if (StartPos.Extend(EndPos, distance + 55 * i).IsWall())
                    {
                        return(StartPos.Extend(EndPos, distance + 55 * i));
                    }
                }
                return(EndPos);
            }
Ejemplo n.º 11
0
        /// <summary>
        /// Checking Collision
        /// </summary>
        /// <param name="start">Start Position</param>
        /// <param name="end">End Position</param>
        /// <param name="range">Range</param>
        /// <param name="width">Width of spell</param>
        /// <param name="speed">Speed of spell</param>
        /// <param name="castdelay">Delay of spell</param>
        /// <returns></returns>
        public static Vector2 Linear_Collision_Point(Vector3 start, Vector3 end, uint range, int width, int speed, int castdelay)
        {
            var possiblecolldies = EntityManager.Enemies.Where(x => x.IsValidTarget(range));
            var spellpolygon     = new Geometry.Polygon.Rectangle(start, start.Extend(end, range).To3D(), width);
            var time             = start.Distance(end) / speed * 1000 + castdelay;
            var collidetarget    = possiblecolldies.OrderBy(x => x.Distance(start)).FirstOrDefault(x => spellpolygon.IsInside(Prediction.Position.PredictUnitPosition(x, (int)time + 1)));

            if (collidetarget != null)
            {
                return(start.Extend(end, start.Distance(collidetarget)));
            }
            return(Vector2.Zero);
        }
Ejemplo n.º 12
0
        public static Vector3 GetFirstNonWallPos(Vector3 startPos, Vector3 endPos)
        {
            int distance = 0;

            for (int i = 0; i < Vayne.emenu.Item("PushDistance").GetValue <Slider>().Value; i += 20)
            {
                var cell = startPos.Extend(endPos, endPos.Distance(startPos) + i);
                if (NavMesh.GetCollisionFlags(cell).HasFlag(CollisionFlags.Wall) ||
                    NavMesh.GetCollisionFlags(cell).HasFlag(CollisionFlags.Building))
                {
                    distance = i - 20;
                }
            }
            return(startPos.Extend(endPos, distance + endPos.Distance(startPos)));
        }
Ejemplo n.º 13
0
        public override bool UseAbility(Vector3 position)
        {
            var distance      = Math.Max(this.Owner.AttackRange(), this.Owner.Distance2D(position) - this.CastRange);
            var startPosition = position.Extend(this.Owner.Position, distance);

            return(this.UseAbility(startPosition, position));
        }
Ejemplo n.º 14
0
        public void SetLane()
        {
            if (MainMenu.GetMenu("AB").Get <Slider>("lane").CurrentValue != 1)
            {
                switch (MainMenu.GetMenu("AB").Get <Slider>("lane").CurrentValue)
                {
                case 2:
                    ChangeLane(Lane.Top);
                    break;

                case 3:
                    ChangeLane(Lane.Mid);
                    break;

                case 4:
                    ChangeLane(Lane.Bot);
                    break;
                }
            }
            else if (ObjectManager.Get <Obj_AI_Turret>().Count() == 24)
            {
                waiting = true;
                Vector3 p = GetAllyTurret("R_03_A").Position;
                Core.DelayAction(() => SafeFunctions.Ping(PingCategory.OnMyWay, p.Randomized()), RandGen.r.Next(1500, 3000));
                AutoWalker.SetMode(Orbwalker.ActiveModes.Combo);
                AutoWalker.WalkTo(p.Extend(AutoWalker.MyNexus, 200 + RandGen.r.NextFloat(0, 100)).To3DWorld().Randomized());

                EarlySelectLane();
            }
            else
            {
                SelectMostPushedLane();
            }
        }
Ejemplo n.º 15
0
        public static Vector3 GetBestWallHopPos(Vector3 start, float range)
        {
            var   spots     = new Dictionary <Vector3, float>();
            float thickness = 0f;

            for (int i = 0; i < range; i += 1)
            {
                var end = start.Extend(Game.CursorPos, i);
                if (IsWallAt(end))
                {
                    thickness += 10;
                    continue;
                }

                if (!spots.ContainsKey(end))
                {
                    spots.Add(end, thickness);
                }
            }

            var spot = spots.OrderBy(x => x.Key.Distance(Game.CursorPos)).ThenBy(x => x.Value).FirstOrDefault(x => x.Value > 50 && x.Value < range);

            DebugConsole.WriteLine($"THICK: {spot.Value}", MessageState.Warn);
            return(spot.Key);
        }
        private async void IceBlast(Particle particle, Vector3 startPosition)
        {
            var rotation    = particle.GetControlPoint(1);
            var endPosition = startPosition + (particle.GetControlPoint(5).X *rotation);
            var radius      = startPosition.Distance(endPosition) / 20;

            DrawRange("IceBlastStart", startPosition, 100, Color.DarkRed, 180);
            DrawRange("IceBlastEnd", endPosition, 275 + radius, Color, 180);
            DrawLine("IceBlast", startPosition, endPosition, 150, 185, Color.DarkRed);

            var rawGameTime = GameManager.RawGameTime;
            var speed       = startPosition.Distance(startPosition + rotation) * 1.04f;

            finish = false;
            do
            {
                var position = startPosition.Extend(endPosition, (GameManager.RawGameTime - rawGameTime) * speed);
                DrawRange("IceBlastPosition", position, 100, Color.Red, 180);

                await Task.Delay(10);
            }while (!finish);

            DrawRangeRemove("IceBlastStart");
            DrawRangeRemove("IceBlastEnd");
            DrawLineRemove("IceBlast");
            DrawRangeRemove("IceBlastPosition");
        }
Ejemplo n.º 17
0
        /// <summary>
        /// Transforms a three-dimensional point represented by a specified vector by this
        /// transformation matrix.
        /// </summary>
        /// <param name="v">The vector to transform.</param>
        /// <returns>The transformed vector.</returns>
        public Vector3 TransformPoint(Vector3 v)
        {
            var factor = this * v.Extend(1);

            factor *= 1 / factor.W;
            return(factor.Truncate());
        }
Ejemplo n.º 18
0
        private static bool CheckPosStun(Vector3 pos)
        {
            if (pos.IsWall())
            {
                return(true);
            }
            if (pos.Extend(Player.Position, -120).IsWall())
            {
                return(true);
            }
            var result = GetRockObject(200, pos);

            if (result != null)
            {
                return(true);
            }
            else
            {
                result = GetGrassObject(50, pos);

                if (result != null)
                {
                    return(true);
                }
                else
                {
                    return(IsWater(pos));
                }
            }
        }
Ejemplo n.º 19
0
        private static void SpellsDetector_OnSkillShotDetected(Obj_AI_Base sender, GameObjectProcessSpellCastEventArgs args, Database.SkillShotSpells.SSpell spell, Vector3 Start, Vector3 End, float Range, float Width, MissileClient missile)
        {
            var caster = sender as AIHeroClient;

            if (caster == null)
            {
                return;
            }
            var spellrange = Range;
            var endpos     = spell.IsFixedRange ? Start.Extend(End, spellrange).To3D() : End;

            if (spell.type == Database.SkillShotSpells.Type.CircleMissile && End.Distance(Start) < Range)
            {
                endpos = End;
            }

            var newactive = new ActiveSpells
            {
                Start = Start, End = endpos, Range = spellrange, Width = Width, spell = spell, EndTime = (endpos.Distance(Start) / spell.Speed) + (spell.CastDelay / 1000) + Game.Time, Caster = caster, Missile = missile, ArriveTime = (Start.Distance(Player.Instance) / spell.Speed) - (spell.CastDelay / 1000)
            };

            if (!DetectedSpells.Contains(newactive))
            {
                DetectedSpells.Add(newactive);
            }
        }
Ejemplo n.º 20
0
        private void Move(Vector3 pos)
        {
            if (!m_attackInProgress && (!CanAttack(60) || CanAttack()))
            {
                if (!m_Configuration.DontMoveMouseOver || ObjectManager.Player.Distance(Game.CursorPos, true) > ObjectManager.Player.BoundingRadius * ObjectManager.Player.BoundingRadius * 4)
                {
                    Vector3 playerPos = ObjectManager.Player.ServerPosition;
                    if (playerPos.Distance(pos, true) < m_Configuration.HoldAreaRadius * m_Configuration.HoldAreaRadius)
                    {
                        ObjectManager.Player.IssueOrder(GameObjectOrder.Stop, playerPos);
                        m_lastMoveTick = Utils.TickCount + m_rnd.Next(1, 70);
                        return;
                    }

                    if (ObjectManager.Player.Distance(pos, true) < 22500)
                    {
                        pos = playerPos.Extend(pos, (m_rnd.NextFloat(0.6f, 1) + 0.2f) * 400);
                    }


                    if (m_lastMoveTick + Math.Min(10, Game.Ping) < Utils.TickCount)
                    {
                        ObjectManager.Player.IssueOrder(GameObjectOrder.MoveTo, pos);
                        m_lastMoveTick = Utils.TickCount + m_rnd.Next(1, 70);
                    }
                }
            }
        }
Ejemplo n.º 21
0
        /// <summary>
        ///     Determines whether dash is wall-jump.
        /// </summary>
        /// <param name="start">start</param>
        /// <param name="direction">The direction.</param>
        /// <param name="dashRange">The dash range.</param>
        public bool IsWallDash(Vector3 start, Vector3 direction, float dashRange)
        {
            var dashEndPos     = start.Extend(direction, dashRange);
            var firstWallPoint = this.GetFirstWallPoint(start, dashEndPos);

            if (firstWallPoint.Equals(Vector3.Zero))
            {
                // No Wall
                return(false);
            }

            if (dashEndPos.IsWall())
            // End Position is in Wall
            {
                var wallWidth = this.GetWallWidth(firstWallPoint, dashEndPos);

                if (wallWidth > this.Menu.Item("MinWallWidth").GetValue <Slider>().Value &&
                    wallWidth - firstWallPoint.Distance(dashEndPos) < wallWidth * 0.6f)
                {
                    return(true);
                }
            }
            else
            // End Position is not a Wall
            {
                return(true);
            }

            return(false);
        }
Ejemplo n.º 22
0
        private static IEnumerable <Vector3> GetPossibleJumpPositions(Vector3 pos)
        {
            var pointList = new List <Vector3>();

            for (var j = 680; j >= 50; j -= 50)
            {
                var offset = (int)(2 * Math.PI * j / 50);

                for (var i = 0; i <= offset; i++)
                {
                    var angle = i * Math.PI * 2 / offset;
                    var point = new Vector3((float)(pos.X + j * Math.Cos(angle)),
                                            (float)(pos.Y - j * Math.Sin(angle)),
                                            pos.Z);

                    if (!NavMesh.GetCollisionFlags(point).HasFlag(CollisionFlags.Wall) && point.Distance(_player.Position) < pos.Distance(_player.Position) - 400 &&
                        point.Distance(pos.Extend(_player.Position, 600)) <= 250)
                    {
                        pointList.Add(point);
                    }
                }
            }

            return(pointList);
        }
Ejemplo n.º 23
0
        private void SetActPos()
        {
            if (_actPosition == _newPosition)
            {
                _newPosition = Game.CursorPos;
                return;
            }
            if (_actPosition.Distance(_newPosition) > 3000)
            {
                _newPosition = Game.CursorPos;
                _actPosition = Game.CursorPos;
                return;
            }
            var l      = _actPosition.Distance(_newPosition);
            var dSpeed = _speed;

            if (l < dSpeed)
            {
                dSpeed = l / 2;
            }
            if (l < 70)
            {
                _actPosition = _newPosition;
                return;
            }
            _actPosition = _actPosition.Extend(_offsetPosition.IsValid() ? _offsetPosition : _newPosition, dSpeed);
        }
Ejemplo n.º 24
0
        public void DrawArcRectangle(Vector3 startPosition, Vector3 endPosition, float startRadius, float endRadius = 0)
        {
            if (rectangle[0] != null)
            {
                return;
            }

            if (endRadius <= 0)
            {
                endRadius = startRadius;
            }

            var difference = startPosition - endPosition;
            var rotation   = difference.Rotated(MathUtil.DegreesToRadians(90));

            rotation.Normalize();

            var start = rotation * startRadius;
            var end   = rotation * endRadius;

            var correctedEnd = startPosition.Extend(
                endPosition,
                startPosition.Distance2D(endPosition) - endRadius * 0.45f);

            var rightStartPosition = startPosition + start;
            var leftStartPosition  = startPosition - start;
            var rightEndPosition   = correctedEnd + end;
            var leftEndPosition    = correctedEnd - end;

            rectangle[0] = DrawLine(rightStartPosition, rightEndPosition);
            rectangle[1] = DrawLine(rightStartPosition, leftStartPosition);
            rectangle[2] = DrawLine(leftStartPosition, leftEndPosition);
            rectangle[3] = DrawArc(endPosition, startPosition, endRadius);
        }
Ejemplo n.º 25
0
        /// <summary>
        /// Orders move hero to given position
        /// </summary>
        /// <param name="pos"></param>
        private void Move(Vector3 pos)
        {
            if (!m_attackInProgress && CanMove() && (!CanAttack(60) || CanAttack()))
            {
                Vector3 playerPos = ObjectManager.Player.ServerPosition;

                bool holdzone          = m_Configuration.DontMoveMouseOver || m_Configuration.HoldAreaRadius != 0;
                var  holdzoneRadiusSqr = Math.Max(m_Configuration.HoldAreaRadius * m_Configuration.HoldAreaRadius, ObjectManager.Player.BoundingRadius * ObjectManager.Player.BoundingRadius * 4);
                if (holdzone && playerPos.Distance(pos, true) < holdzoneRadiusSqr)
                {
                    if ((Utils.TickCount + Game.Ping / 2 - m_lastAATick) * 0.6f >= 1000f / (ObjectManager.Player.GetAttackSpeed() * m_baseWindUp))
                    {
                        ObjectManager.Player.IssueOrder(GameObjectOrder.Stop, playerPos);
                    }
                    m_lastMoveTick = Utils.TickCount + m_rnd.Next(1, 20);
                    return;
                }

                if (ObjectManager.Player.Distance(pos, true) < 22500)
                {
                    pos = playerPos.Extend(pos, (m_rnd.NextFloat(0.6f, 1.01f) + 0.2f) * 400);
                }


                if (m_lastMoveTick + 50 + Math.Min(60, Game.Ping) < Utils.TickCount)
                {
                    ObjectManager.Player.IssueOrder(GameObjectOrder.MoveTo, pos);
                    m_lastMoveTick = Utils.TickCount + m_rnd.Next(1, 20);
                }
            }
        }
Ejemplo n.º 26
0
        public static Vector3 GetBestLinearPredictionPos(this Spell.Skillshot self, List <Obj_AI_Base> enemies, Vector3 sourcePosition, out int enemiesHit)
        {
            enemiesHit = 0;

            enemies = enemies.Where(a => a.MeetsCriteria() && a.Position(self.CastDelay).IsInRange(sourcePosition, self.Range)).ToList();
            Vector3 castPosition = Vector3.Zero;

            //if there is nothing that meets the criteria
            if (enemies.Count() == 0)
            {
                return(castPosition);
            }

            List <Tuple <Geometry.Polygon.Rectangle, Vector3> > rectPositions = new List <Tuple <Geometry.Polygon.Rectangle, Vector3> >();

            Vector3 extendingPosition = sourcePosition + new Vector3(0, self.Range, 0);

            //checks every 15 degrees
            for (int i = 0; i < 24; i++)
            {
                Vector3 endPosition             = extendingPosition.To2D().RotateAroundPoint(sourcePosition.To2D(), (float)((i * 15) * Math.PI / 180)).To3D((int)sourcePosition.Z);
                Geometry.Polygon.Rectangle rect = new Geometry.Polygon.Rectangle(sourcePosition, endPosition, self.Width);

                rectPositions.Add(Tuple.Create(rect, endPosition));
            }

            Tuple <Geometry.Polygon.Rectangle, Vector3> bestPos = null;

            if (self.AllowedCollisionCount == 1)
            {
                bestPos = rectPositions.Where(a =>
                                              enemies.Where(enemy => a.Item1.IsInside(enemy)).OrderBy(enemy => enemy.Position(self.CastDelay).Distance(sourcePosition)).FirstOrDefault() != null
                                              ).FirstOrDefault();
                if (bestPos != null)
                {
                    enemiesHit = 1;
                }
            }
            else
            {
                bestPos = rectPositions.OrderByDescending(a =>
                                                          enemies.Where(enemy => a.Item1.IsInside(enemy.Position(self.CastDelay))).Count()
                                                          ).FirstOrDefault();

                if (bestPos != null)
                {
                    enemiesHit = enemies.Where(enemy => bestPos.Item1.IsInside(enemy.Position(self.CastDelay))).Count();
                }
            }

            if (bestPos != null)
            {
                return(sourcePosition.Extend(bestPos.Item2, self.Range / 2).To3D((int)sourcePosition.Z));
            }
            else
            {
                return(Vector3.Zero);
            }
        }
Ejemplo n.º 27
0
 public static Vector3 GetBestDaggerPoint(Vector3 position, Obj_AI_Base target)
 {
     if (target.Position.IsInRange(position, 150))
     {
         return(position);
     }
     return(position.Extend(target, 150).To3D());
 }
Ejemplo n.º 28
0
        public override bool UseAbility(Vector3 position)
        {
            // simple position to get as close as possible to target
            var distance      = Math.Max(this.Owner.AttackRange(), this.Owner.Distance2D(position) - this.CastRange);
            var startPosition = position.Extend(this.Owner.Position, distance);

            return(this.UseAbility(startPosition, position));
        }
Ejemplo n.º 29
0
 public static Vector3 GetPlayerPosition(int timeModMs = 0)
 {
     if (Player.Instance.IsDashing() && _dashEndTime < Environment.TickCount + timeModMs)
     {
         return(_startPos.Extend(_endPos, 475 * ((_dashEndTime - (Environment.TickCount + timeModMs)) / ((_dashStartTime - _dashEndTime) == 0 ? 1 : (_dashStartTime - _dashEndTime)))).To3D());
     }
     return(Player.Instance.Position);
 }
Ejemplo n.º 30
0
 private static Vector3 ExtendWallpos(Obj_AI_Base ts, Vector3 point)
 {
     if (ts == null)
     {
         throw new ArgumentNullException("ts");
     }
     return(point.Extend(ts.Position, point.Distance(ts.Position) + 25));
 }
Ejemplo n.º 31
0
        private static float GetWallWidth(Vector3 start, Vector3 direction, int maxWallWidth = 350, int step = 1)
        {
            var thickness = 0f;

            if (!start.IsValid() || !direction.IsValid())
            {
                return thickness;
            }

            for (var i = 0; i < maxWallWidth; i = i + step)
            {
                if (NavMesh.GetCollisionFlags(start.Extend(direction, i)) == CollisionFlags.Wall || start.Extend(direction, i).IsWall())
                {
                    thickness += step;
                }
            }
            return thickness;
        }
Ejemplo n.º 32
0
        public static Obj_AI_Base GetTarget(Vector3 fromPosition)
        {
            var targetList =
                EntityManager.Heroes.Enemies.Where(
                    h =>
                    h.IsValidTarget(SpellManager.E.Range) && !h.HasBuffOfType(BuffType.SpellShield)
                    && !h.HasBuffOfType(BuffType.SpellImmunity)
                    && h.Health > ObjectManager.Player.GetAutoAttackDamage(h, true) * 2).ToList();

            if (!targetList.Any())
            {
                return null;
            }

            foreach (var enemy in targetList)
            {
                var prediction = SpellManager.E.GetPrediction(enemy);

                var predictionsList = new List<Vector3>
                                          {
                                              enemy.ServerPosition,
                                              enemy.Position,
                                              prediction.CastPosition,
                                              prediction.UnitPosition
                                          };

                var wallsFound = 0;

                foreach (var position in predictionsList)
                {
                    var distance = fromPosition.Distance(position);

                    for (var i = 0; i < Config.Settings.Condemn.PushDistance; i += (int)enemy.BoundingRadius)
                    {
                        var finalPosition = fromPosition.Extend(position, distance + i).To3D();
                        if (NavMesh.GetCollisionFlags(finalPosition).HasFlag(CollisionFlags.Wall)
                            || NavMesh.GetCollisionFlags(finalPosition).HasFlag(CollisionFlags.Building))
                        {
                            wallsFound++;
                            break;
                        }
                    }
                }

                if (wallsFound >= Config.Settings.Condemn.Accuracy)
                {
                    return enemy;
                }
            }

            return null;
        }
Ejemplo n.º 33
0
        public static float GetWallWidth(Vector3 start, Vector3 direction, int maxWallWidth = 350, int step = 1)
        {
            var thickness = 0f;

            if (start.IsValid() && direction.IsValid())
            {
                for (var i = 0; i < maxWallWidth; i = i + step)
                {
                    if (NavMesh.GetCollisionFlags(start.Extend(direction, i)) == CollisionFlags.Wall
                        || start.Extend(direction, i).IsWall())
                    {
                        // Console.WriteLine("Thickness: " + thickness);
                        thickness += step;
                    }
                    else
                    {
                        return thickness;
                    }
                }
            }
            return thickness;
        }
Ejemplo n.º 34
0
        public static Vector3 GetFirstWallPoint(Vector3 start, Vector3 end, int step = 1)
        {
            if (start.IsValid() && end.IsValid())
            {
                var distance = start.Distance(end);
                for (var i = 0; i < distance; i = i + step)
                {
                    var newPoint = start.Extend(end, i);

                    if (NavMesh.GetCollisionFlags(newPoint) == CollisionFlags.Wall || newPoint.IsWall())
                    {
                        return newPoint;
                    }
                }
            }
            return Vector3.Zero;
        }
Ejemplo n.º 35
0
       /// <summary>
       /// Gets the first wall point/node, w/e. 
       /// </summary>
       /// <param name="playerPosition"></param>
       /// <param name="endPosition"></param>
       /// <param name="step"></param>
       /// <returns></returns>
        public Vector3 FirstWallPoint(Vector3 playerPosition, Vector3 endPosition, int step = 1)
        {
            if (!playerPosition.IsValid() || !endPosition.IsValid())
            {
                return Vector3.Zero;
            }

            var distance = playerPosition.Distance(endPosition);

            for (var i = 0; i < distance; i = i + step)
            {
                var newPoint = playerPosition.Extend(endPosition, i);

                if (NavMesh.GetCollisionFlags(newPoint) == CollisionFlags.Wall || newPoint.IsWall())
                {
                    return newPoint;
                }
            }

            return Vector3.Zero;
        }
Ejemplo n.º 36
0
 /// <summary>
 ///     Returns true if there is a Wall between X pos and Y pos.
 /// </summary>
 public static bool AnyWallInBetween(Vector3 startPos, Vector3 endPos)
 {
     for (var i = 0; i < startPos.Distance(endPos); i++)
     {
         if (NavMesh.GetCollisionFlags(startPos.Extend(endPos, i)) == CollisionFlags.Wall)
         {
             return true;
         }
     }
     return false;
 }
Ejemplo n.º 37
0
        static Vector3 getPos(AIHeroClient target, int c)
        {
            AIHeroClient ally1 = EntityManager.Heroes.Allies.FirstOrDefault(ally => ally.HealthPercent > Settings.InsecToHP && Player.Instance.Distance(ally) <= Settings.InsecToRange && ally.Name != Player.Instance.Name);
            Vector3 moveTo = new Vector3();
            Vector3 allyPos = new Vector3();
            Vector3 point = new Vector3();
            if (ally1 != null)
                point = ally1.Position;
            else
                point = Vector3.Zero;
            allyPos = point;
            if (allyPos == Vector3.Zero) return Vector3.Zero;
            Vector3 targetPos = target.Position;
            //From the Ally position we extended (the distance between both + 100) units in the target direction THANKS @WUJU!
            if (c == 3) { moveTo = allyPos.Extend(target, ally1.Distance(target) - Settings.Dist).To3DWorld(); }
            if (c == 1) { moveTo = allyPos.Extend(target, ally1.Distance(target) + Settings.Dist).To3DWorld(); }

            if (NavMesh.GetCollisionFlags(moveTo) == CollisionFlags.Building || NavMesh.GetCollisionFlags(moveTo) == CollisionFlags.Wall)
            {
                return Vector3.Zero;
            }
            _moveTo = moveTo;
            return moveTo;
        }
Ejemplo n.º 38
0
        private static void WardBush(Vector3 from, Vector3 endPosition)
        {
            if (!MenuExtensions.GetItemValue<bool>("iseriesr.vayne.misc.condemn.wardbush"))
            {
                return;
            }

            var wardSlot = Items.GetWardSlot();
            if (wardSlot != null)
            {
                var wardPos = from.Extend(endPosition, from.Distance(endPosition) - 65f);
                if (NavMesh.IsWallOfGrass(wardPos, 65))
                {
                    if (Items.CanUseItem(wardSlot.Slot))
                    {
                        Items.UseItem(wardSlot.Slot, wardPos);
                    }
                }
            }
        }
Ejemplo n.º 39
0
        /// <summary>
        /// Wall Lentgh
        /// </summary>
        /// <param name="start"></param>
        /// <param name="end"></param>
        /// <returns></returns>
        public static float GetWallLength(Vector3 start, Vector3 end)
        {
            double distance = Vector3.Distance(start, end);
               var firstPosition = Vector3.Zero;
               var lastPosition = Vector3.Zero;

               for (uint i = 0; i < distance; i += 10)
               {
               var tempPosition = start.Extend(end, i);
               if (tempPosition.IsWall() && firstPosition == Vector3.Zero)
               {
                   firstPosition = tempPosition;
               }
               lastPosition = tempPosition;
               if (!lastPosition.IsWall() && firstPosition != Vector3.Zero)
               {
                   break;
               }
               }

               return Vector3.Distance(firstPosition, lastPosition);
        }
Ejemplo n.º 40
0
 /// <summary>
 /// Checks For Wall
 /// </summary>
 /// <param name="start"></param>
 /// <param name="end"></param>
 /// <returns></returns>
 public static bool IsOverWall(Vector3 start, Vector3 end)
 {
     double distance = Vector3.Distance(start, end);
        for (uint i = 0; i < distance; i += 10)
        {
        var tempPosition = start.Extend(end, i).To2D();
        if (tempPosition.IsWall())
        {
            return true;
        }
        }
        return false;
 }
Ejemplo n.º 41
0
 public static Vector3 Extend(Vector3 from, Vector3 to, float x)
 {
     return from.Extend(to, x);
 }
Ejemplo n.º 42
0
        /// <summary>
        /// First wall Point
        /// </summary>
        /// <param name="start"></param>
        /// <param name="end"></param>
        /// <returns></returns>
        public static Vector3 GetFirstWallPoint(Vector3 start, Vector3 end)
        {
            double distance = Vector3.Distance(start, end);
               for (uint i = 0; i < distance; i += 10)
               {
               var tempPosition = start.Extend(end, i);
               if (!tempPosition.IsWall())
               {
                   return tempPosition.Extend(start, -35);
               }
               }

               return Vector3.Zero;
        }