コード例 #1
0
ファイル: Skillshot.cs プロジェクト: wade1990/PortAIO
        public Skillshot(DetectionType detectionType, SpellData spellData, int startT, Vector2 start, Vector2 end, Obj_AI_Base unit)
        {
            DetectionType   = detectionType;
            SpellData       = spellData;
            StartTick       = startT;
            Start           = start;
            End             = end;
            MissilePosition = start;
            Direction       = (end - start).Normalized();
            Unit            = unit;

            switch (spellData.Type)
            {
            case SkillShotType.SkillshotCircle:
                Circle = new Geometry.Circle(CollisionEnd, spellData.Radius);
                break;

            case SkillShotType.SkillshotLine:
                Rectangle = new Geometry.Rectangle(Start, CollisionEnd, spellData.Radius);
                break;

            case SkillShotType.SkillshotMissileLine:
                Rectangle = new Geometry.Rectangle(Start, CollisionEnd, spellData.Radius);
                break;

            case SkillShotType.SkillshotCone:
                Sector = new Geometry.Sector(start, CollisionEnd - start, spellData.Radius * (float)Math.PI / 180, spellData.Range);
                break;

            case SkillShotType.SkillshotRing:
                Ring = new Geometry.Ring(CollisionEnd, spellData.Radius, spellData.RingRadius);
                break;

            case SkillShotType.SkillshotArc:
                Arc = new Geometry.Arc(start, end, Config.SkillShotsExtraRadius + (int)GameObjects.Player.BoundingRadius);
                break;
            }

            UpdatePolygon();
        }
コード例 #2
0
ファイル: Collision.cs プロジェクト: wade1990/PortAIO
        public static Vector2 GetCollisionPoint(Skillshot skillshot)
        {
            var collisions = new List <DetectedCollision>();
            var from       = skillshot.GetMissilePosition(0);

            skillshot.ForceDisabled = false;
            foreach (var cObject in skillshot.SpellData.CollisionObjects)
            {
                switch (cObject)
                {
                case CollisionObjectTypes.Minion:

                    if (!Config.Menu["Collision"]["MinionCollision"])
                    {
                        break;
                    }

                    var minions = new List <Obj_AI_Minion>();

                    minions.AddRange(
                        GameObjects.Minions.Where(x =>
                                                  x.IsValidTarget(1200f, false, from.ToVector3()) && (
                                                      skillshot.Unit.Team == GameObjects.Player.Team ?
                                                      x.Team != GameObjects.Player.Team :
                                                      x.Team == GameObjects.Player.Team)));

                    minions.AddRange(
                        GameObjects.Jungle.Where(x =>
                                                 x.IsValidTarget(1200f, false, from.ToVector3())));

                    foreach (var minion in minions)
                    {
                        var pred = FastPrediction(
                            from, minion,
                            Math.Max(0, skillshot.SpellData.Delay - (Utils.TickCount - skillshot.StartTick)),
                            skillshot.SpellData.MissileSpeed);
                        var pos = pred.PredictedPos;
                        var w   = skillshot.SpellData.RawRadius + (!pred.IsMoving ? (minion.BoundingRadius - 15) : 0) -
                                  pos.Distance(from, skillshot.End, true);
                        if (w > 0)
                        {
                            collisions.Add(
                                new DetectedCollision
                            {
                                Position =
                                    pos.ProjectOn(skillshot.End, skillshot.Start).LinePoint +
                                    skillshot.Direction * 30,
                                Unit     = minion,
                                Type     = CollisionObjectTypes.Minion,
                                Distance = pos.Distance(from),
                                Diff     = w,
                            });
                        }
                    }

                    break;

                case CollisionObjectTypes.Champions:
                    if (!Config.Menu["Collision"]["HeroCollision"])
                    {
                        break;
                    }
                    foreach (var hero in ObjectManager.Get <AIHeroClient>().Where(h => (h.IsValidTarget(1200, false) && h.Team == GameObjects.Player.Team && !h.IsMe && h.Team != GameObjects.Player.Team)))
                    {
                        var pred = FastPrediction(
                            from, hero,
                            Math.Max(0, skillshot.SpellData.Delay - (Utils.TickCount - skillshot.StartTick)),
                            skillshot.SpellData.MissileSpeed);
                        var pos = pred.PredictedPos;

                        var w = skillshot.SpellData.RawRadius + 30 - pos.Distance(from, skillshot.End, true);
                        if (w > 0)
                        {
                            collisions.Add(
                                new DetectedCollision
                            {
                                Position =
                                    pos.ProjectOn(skillshot.End, skillshot.Start).LinePoint +
                                    skillshot.Direction * 30,
                                Unit     = hero,
                                Type     = CollisionObjectTypes.Minion,
                                Distance = pos.Distance(from),
                                Diff     = w,
                            });
                        }
                    }
                    break;

                case CollisionObjectTypes.YasuoWall:
                    if (!Config.Menu["Collision"]["YasuoCollision"])
                    {
                        break;
                    }

                    if (!ObjectManager.Get <AIHeroClient>().Any(hero => hero.IsValidTarget(float.MaxValue, false) &&
                                                                hero.Team == GameObjects.Player.Team && hero.ChampionName == "Yasuo"))
                    {
                        break;
                    }
                    GameObject wall = null;
                    foreach (var gameObject in ObjectManager.Get <GameObject>())
                    {
                        if (gameObject.IsValid &&
                            System.Text.RegularExpressions.Regex.IsMatch(
                                gameObject.Name, "_w_windwall.\\.troy",
                                System.Text.RegularExpressions.RegexOptions.IgnoreCase))
                        {
                            wall = gameObject;
                        }
                    }
                    if (wall == null)
                    {
                        break;
                    }
                    var level     = wall.Name.Substring(wall.Name.Length - 6, 1);
                    var wallWidth = (300 + 50 * Convert.ToInt32(level));


                    var wallDirection = (wall.Position.ToVector2() - YasuoWallCastedPos).Normalized().Perpendicular();
                    var wallStart     = wall.Position.ToVector2() + wallWidth / 2 * wallDirection;
                    var wallEnd       = wallStart - wallWidth * wallDirection;
                    var wallPolygon   = new Geometry.Rectangle(wallStart, wallEnd, 75).ToPolygon();
                    var intersection  = new Vector2();
                    var intersections = new List <Vector2>();

                    for (var i = 0; i < wallPolygon.Points.Count; i++)
                    {
                        var inter =
                            wallPolygon.Points[i].Intersection(
                                wallPolygon.Points[i != wallPolygon.Points.Count - 1 ? i + 1 : 0], from,
                                skillshot.End);
                        if (inter.Intersects)
                        {
                            intersections.Add(inter.Point);
                        }
                    }

                    if (intersections.Count > 0)
                    {
                        intersection = intersections.OrderBy(item => item.Distance(from)).ToList()[0];
                        var collisionT = Utils.TickCount +
                                         Math.Max(
                            0,
                            skillshot.SpellData.Delay -
                            (Utils.TickCount - skillshot.StartTick)) + 100 +
                                         (1000 * intersection.Distance(from)) / skillshot.SpellData.MissileSpeed;
                        if (collisionT - WallCastT < 4000)
                        {
                            if (skillshot.SpellData.Type != SkillShotType.SkillshotMissileLine)
                            {
                                skillshot.ForceDisabled = true;
                            }
                            return(intersection);
                        }
                    }

                    break;
                }
            }

            Vector2 result;

            if (collisions.Count > 0)
            {
                result = collisions.OrderBy(c => c.Distance).ToList()[0].Position;
            }
            else
            {
                result = new Vector2();
            }

            return(result);
        }
コード例 #3
0
ファイル: Skillshot.cs プロジェクト: wade1990/PortAIO
        public void Game_OnGameUpdate()
        {
            if (SpellData.CollisionObjects.Count() > 0 && SpellData.CollisionObjects != null && Utils.TickCount - _lastCollisionCalc > 50 && Config.Menu["Collision"]["EnableCollision"])
            {
                _lastCollisionCalc = Utils.TickCount;
                _collisionEnd      = Collision.GetCollisionPoint(this);
            }

            if (SpellData.Type == SkillShotType.SkillshotMissileLine)
            {
                Rectangle = new Geometry.Rectangle(GetMissilePosition(0), CollisionEnd, SpellData.Radius);
                UpdatePolygon();
            }

            if (SpellData.MissileFollowsUnit)
            {
                if (Unit.IsVisible)
                {
                    End       = Unit.ServerPosition.ToVector2();
                    Direction = (End - Start).Normalized();
                    UpdatePolygon();
                }
            }

            if (SpellData.SpellName == "TaricE")
            {
                Start     = Unit.ServerPosition.ToVector2();
                End       = Start + Direction * this.SpellData.Range;
                Rectangle = new Geometry.Rectangle(Start, End, SpellData.Radius);
                UpdatePolygon();
            }

            if (SpellData.SpellName == "SionR")
            {
                if (_helperTick == 0)
                {
                    _helperTick = StartTick;
                }

                SpellData.MissileSpeed = (int)Unit.MoveSpeed;

                if (Unit.IsValidTarget(float.MaxValue, false))
                {
                    if (!Unit.HasBuff("SionR") && Utils.TickCount - _helperTick > 600)
                    {
                        StartTick = 0;
                    }
                    else
                    {
                        StartTick = Utils.TickCount - SpellData.Delay;
                        Start     = Unit.ServerPosition.ToVector2();
                        End       = Unit.ServerPosition.ToVector2() + 1000 * Unit.Direction.ToVector2().Perpendicular();
                        Direction = (End - Start).Normalized();
                        UpdatePolygon();
                    }
                }
                else
                {
                    StartTick = 0;
                }
            }

            if (SpellData.FollowCaster)
            {
                Circle.Center = Unit.ServerPosition.ToVector2();
                UpdatePolygon();
            }
        }