示例#1
0
        public static bool inSkillShot(Spell spell, Vector2 position, float radius)
        {
            if (spell.info.spellType == SpellType.Line)
            {
                Vector2 spellPos = SpellDetector.GetCurrentSpellPosition(spell); //leave little space at back of skillshot

                if (spell.info.projectileSpeed == float.MaxValue &&
                    Evade.GetTickCount() - spell.startTime > spell.info.spellDelay)
                {
                    return(false);
                }

                var projection = position.ProjectOn(spellPos, spell.endPos);

                if (projection.SegmentPoint.Distance(spell.endPos) < 100) //Check Skillshot endpoints
                {
                    //unfinished
                }

                return(projection.SegmentPoint.Distance(position) <= GetSpellRadius(spell) + radius);
            }
            else if (spell.info.spellType == SpellType.Circular)
            {
                return(position.Distance(spell.endPos) <= GetSpellRadius(spell) + radius);
            }
            else if (spell.info.spellType == SpellType.Cone)
            {
            }
            return(false);
        }
示例#2
0
        public static bool LineIntersectLinearSpell(Vector2 a, Vector2 b, Spell spell)
        {
            var myBoundingRadius = myHero.BoundingRadius;
            var spellDir         = spell.direction;
            var pSpellDir        = spell.direction.Perpendicular();
            var spellRadius      = GetSpellRadius(spell);
            var spellPos         = SpellDetector.GetCurrentSpellPosition(spell) - spellDir * myBoundingRadius; //leave some space at back of spell
            var endPos           = spell.endPos + spellDir * myBoundingRadius;                                 //leave some space at the front of spell

            var startRightPos = spellPos + pSpellDir * (spellRadius + myBoundingRadius);
            var startLeftPos  = spellPos - pSpellDir * (spellRadius + myBoundingRadius);
            var endRightPos   = endPos + pSpellDir * (spellRadius + myBoundingRadius);
            var endLeftPos    = endPos - pSpellDir * (spellRadius + myBoundingRadius);

            bool int1 = MathUtils.CheckLineIntersection(a, b, startRightPos, startLeftPos);
            bool int2 = MathUtils.CheckLineIntersection(a, b, endRightPos, endLeftPos);
            bool int3 = MathUtils.CheckLineIntersection(a, b, startRightPos, endRightPos);
            bool int4 = MathUtils.CheckLineIntersection(a, b, startLeftPos, endLeftPos);

            if (int1 || int2 || int3 || int4)
            {
                return(true);
            }

            return(false);
        }
示例#3
0
        private void Drawing_OnDraw(EventArgs args)
        {
            if (menu.SubMenu("Draw").Item("DrawSkillShots").GetValue <bool>() == false)
            {
                return;
            }

            if (menu.SubMenu("Draw").Item("DrawEvadePosition").GetValue <bool>())
            {
                if (Evade.lastPosInfo != null)
                {
                    var pos = Evade.lastPosInfo.position;
                    Render.Circle.DrawCircle(new Vector3(pos.X, pos.Y, myHero.Position.Z), 65, Color.Red, 10);
                }
            }

            DrawEvadeStatus();

            foreach (KeyValuePair <int, Spell> entry in SpellDetector.drawSpells)
            {
                Spell spell = entry.Value;

                var dangerStr          = EvadeHelper.GetSpellDangerString(spell);
                var spellDrawingConfig = Evade.menu.SubMenu("Draw").SubMenu("DangerLevelDrawings")
                                         .SubMenu(dangerStr + "Drawing").Item(dangerStr + "Color").GetValue <Circle>();
                var spellDrawingWidth = Evade.menu.SubMenu("Draw").SubMenu("DangerLevelDrawings")
                                        .SubMenu(dangerStr + "Drawing").Item(dangerStr + "Width").GetValue <Slider>().Value;

                if (Evade.menu.SubMenu("Spells").SubMenu(spell.info.charName + spell.info.spellName + "Settings")
                    .Item(spell.info.spellName + "DrawSpell").GetValue <bool>() &&
                    spellDrawingConfig.Active)
                {
                    if (spell.info.spellType == SpellType.Line)
                    {
                        Vector2 spellPos = SpellDetector.GetCurrentSpellPosition(spell);
                        DrawLineRectangle(spellPos, spell.endPos, (int)EvadeHelper.GetSpellRadius(spell), spellDrawingWidth, spellDrawingConfig.Color);

                        if (menu.SubMenu("Draw").Item("DrawSpellPos").GetValue <bool>())
                        {
                            /*if (true)
                             * {
                             *  var spellPos2 = spell.startPos + spell.direction * spell.info.projectileSpeed * (Evade.GetTickCount() - spell.startTime - spell.info.spellDelay) / 1000 + spell.direction * spell.info.projectileSpeed * ((float)Game.Ping / 1000);
                             *  Render.Circle.DrawCircle(new Vector3(spellPos2.X, spellPos2.Y, myHero.Position.Z), (int)EvadeHelper.GetSpellRadius(spell), Color.Red, 8);
                             * }*/

                            Render.Circle.DrawCircle(new Vector3(spellPos.X, spellPos.Y, myHero.Position.Z), (int)EvadeHelper.GetSpellRadius(spell), spellDrawingConfig.Color, spellDrawingWidth);
                        }
                    }
                    else if (spell.info.spellType == SpellType.Circular)
                    {
                        Render.Circle.DrawCircle(new Vector3(spell.endPos.X, spell.endPos.Y, myHero.Position.Z), (int)EvadeHelper.GetSpellRadius(spell), spellDrawingConfig.Color, spellDrawingWidth);
                    }
                    else if (spell.info.spellType == SpellType.Cone)
                    {
                    }
                }
            }
        }
示例#4
0
        private void CompareSpellLocation(Spell spell, Vector2 pos, float time)
        {
            var pos2 = SpellDetector.GetCurrentSpellPosition(spell);

            if (spell.spellObject != null)
            {
                Game.PrintChat("Compare: " + (pos2.Distance(pos)) / (Evade.GetTickCount() - time));
            }
        }
示例#5
0
        private void CompareSpellLocation2(Spell spell)
        {
            var pos1    = SpellDetector.GetCurrentSpellPosition(spell);
            var timeNow = Evade.GetTickCount();

            if (spell.spellObject != null)
            {
                Game.PrintChat("start distance: " + (spell.startPos.Distance(pos1)));
            }

            Utility.DelayAction.Add(250, () => CompareSpellLocation(spell, pos1, timeNow));
        }
示例#6
0
        public static float GetSpellHitTime(Spell spell, Vector2 pos)
        {
            if (spell.info.spellType == SpellType.Line)
            {
                var spellPos = SpellDetector.GetCurrentSpellPosition(spell, true, Game.Ping);
                return(1000 * spellPos.Distance(pos) / spell.info.projectileSpeed);
            }
            else if (spell.info.spellType == SpellType.Circular)
            {
                return(Math.Max(0, spell.endTime - Evade.GetTickCount() - Game.Ping));
            }

            return(float.MaxValue);
        }
示例#7
0
        public static BoundingBox GetLinearSpellBoundingBox(Spell spell)
        {
            var myBoundingRadius = myHero.BoundingRadius;
            var spellDir         = spell.direction;
            var pSpellDir        = spell.direction.Perpendicular();
            var spellRadius      = GetSpellRadius(spell);
            var spellPos         = SpellDetector.GetCurrentSpellPosition(spell) - spellDir * myBoundingRadius; //leave some space at back of spell
            var endPos           = spell.endPos + spellDir * myBoundingRadius;                                 //leave some space at the front of spell

            var startRightPos = spellPos + pSpellDir * (spellRadius + myBoundingRadius);
            var endLeftPos    = endPos - pSpellDir * (spellRadius + myBoundingRadius);


            return(new BoundingBox(new Vector3(endLeftPos.X, endLeftPos.Y, -1), new Vector3(startRightPos.X, startRightPos.Y, 1)));
        }
示例#8
0
        public static bool checkMoveToDirection(Vector2 from, Vector2 movePos)
        {
            var heroPoint = from;
            var dir       = (movePos - heroPoint).Normalized();

            foreach (KeyValuePair <int, Spell> entry in SpellDetector.spells)
            {
                Spell spell = entry.Value;

                if (!playerInSkillShot(spell))
                {
                    Vector2 spellPos = SpellDetector.GetCurrentSpellPosition(spell);

                    if (spellPos.Distance(heroPoint) > 500 + GetSpellRadius(spell))
                    {
                        return(PredictSpellCollision(spell, movePos, myHero.MoveSpeed, 0, myHero.ServerPosition.To2D(), 0));
                    }

                    if (spell.info.spellType == SpellType.Line)
                    {
                        if (LineIntersectLinearSpell(heroPoint, movePos, spell))
                        {
                            return(true);
                        }
                    }
                    else if (spell.info.spellType == SpellType.Circular)
                    {
                        bool isCollision   = false;
                        var  collisionTime = MathUtils.GetCollisionTime(heroPoint, spell.endPos, dir * myHero.MoveSpeed, new Vector2(0, 0), 1,
                                                                        GetSpellRadius(spell) + myHero.BoundingRadius, out isCollision);
                        if (collisionTime > 0)
                        {
                            if (!(collisionTime >= heroPoint.Distance(movePos) / myHero.MoveSpeed)) //collision occurs when hero is moving to the destination
                            {
                                return(true);
                            }
                        }
                    }
                    else if (spell.info.spellType == SpellType.Cone)
                    {
                    }
                }
            }

            return(false);
        }
示例#9
0
        public static bool LineIntersectLinearSpellEx(Vector2 a, Vector2 b, Spell spell, out Vector2 intersection)
        {
            var myBoundingRadius = myHero.BoundingRadius;
            var spellDir         = spell.direction;
            var pSpellDir        = spell.direction.Perpendicular();
            var spellRadius      = GetSpellRadius(spell);
            var spellPos         = SpellDetector.GetCurrentSpellPosition(spell) - spellDir * myBoundingRadius; //leave some space at back of spell
            var endPos           = spell.endPos + spellDir * myBoundingRadius;                                 //leave some space at the front of spell

            var startRightPos = spellPos + pSpellDir * (spellRadius + myBoundingRadius);
            var startLeftPos  = spellPos - pSpellDir * (spellRadius + myBoundingRadius);
            var endRightPos   = endPos + pSpellDir * (spellRadius + myBoundingRadius);
            var endLeftPos    = endPos - pSpellDir * (spellRadius + myBoundingRadius);

            var int1 = a.Intersection(b, startRightPos, startLeftPos);

            var int2 = a.Intersection(b, endRightPos, endLeftPos);
            var int3 = a.Intersection(b, startRightPos, endRightPos);
            var int4 = a.Intersection(b, startLeftPos, endLeftPos);

            if (int1.Intersects)
            {
                intersection = int1.Point;
                return(true);
            }
            else if (int2.Intersects)
            {
                intersection = int2.Point;
                return(true);
            }
            else if (int3.Intersects)
            {
                intersection = int3.Point;
                return(true);
            }
            else if (int4.Intersects)
            {
                intersection = int4.Point;
                return(true);
            }

            intersection = Vector2.Zero;

            return(false);
        }
示例#10
0
        public static float GetClosestDistanceApproach(Spell spell, Vector2 pos, float speed, float delay, Vector2 heroPos, float extraDist)
        {
            var walkDir = (pos - heroPos).Normalized();
            var zVector = new Vector2(0, 0);

            if (spell.info.spellType == SpellType.Line)
            {
                var spellPos = SpellDetector.GetCurrentSpellPosition(spell, true, delay);

                Vector2 cPos1, cPos2;

                var cpa = MathUtilsCPA.CPAPoints(heroPos, walkDir * speed, spellPos, spell.direction * spell.info.projectileSpeed, out cPos1, out cPos2);

                if (cpa < myHero.BoundingRadius + spell.info.radius + extraDist)
                {
                    if (cPos2.Distance(spell.startPos) > spell.info.range + myHero.BoundingRadius)
                    {
                        return(1); //500
                    }

                    return(0);
                }

                return(cpa - (myHero.BoundingRadius + GetSpellRadius(spell) + extraDist));
                //return MathUtils.ClosestTimeOfApproach(heroPos, walkDir * speed, spellPos, spell.direction * spell.info.projectileSpeed);
            }
            else if (spell.info.spellType == SpellType.Circular)
            {
                /*var spellHitTime = Math.Max(0, spell.endTime - Evade.GetTickCount());  //extraDelay
                 * var walkRange = heroPos.Distance(pos);
                 * var predictedRange = speed * (spellHitTime / 1000);
                 * var tHeroPos = heroPos + walkDir * Math.Min(predictedRange, walkRange); //Hero predicted pos
                 *
                 * return Math.Max(0,tHeroPos.Distance(spell.endPos) - (GetSpellRadius(spell) + myHero.BoundingRadius + extraDist)); //+ dodgeBuffer
                 */
            }

            return(1);
        }
示例#11
0
        public static bool PredictSpellCollision(Spell spell, Vector2 pos, float speed, float delay, Vector2 heroPos, float extraDist)
        {
            var walkDir = (pos - heroPos).Normalized();
            var zVector = new Vector2(0, 0);

            /*
             * if (Evade.menu.SubMenu("MiscSettings").Item("CalculateHeroPos").GetValue<bool>())
             *  heroPos = GetRealHeroPos(); //testing*/

            /*if (!myHero.IsMoving)
             *  walkDir = zVector;*/

            if (spell.info.spellType == SpellType.Line)
            {
                //zVector


                if (spell.info.projectileSpeed == float.MaxValue)
                {
                }

                var spellPos = SpellDetector.GetCurrentSpellPosition(spell, true);

                //Using triple checks
                //Check if skillshot will hit pos if hero is standing still
                bool isCollision = false;

                float standingCollisionTime = MathUtils.GetCollisionTime(pos, spellPos, zVector, spell.direction * spell.info.projectileSpeed, myHero.BoundingRadius, GetSpellRadius(spell), out isCollision);
                if (isCollision && standingCollisionTime > 0)
                {
                    if (spellPos.Distance(spell.endPos) / spell.info.projectileSpeed > standingCollisionTime)
                    {
                        return(true); //if collision happens when the skillshot is in flight
                    }
                }

                return(GetClosestDistanceApproach(spell, pos, speed, delay, heroPos, extraDist) == 0);

                /*
                 * //Check if skillshot will hit hero if hero is moving
                 * float movingCollisionTime = MathUtils.GetCollisionTime(heroPos, spellPos, walkDir * speed, spell.direction * spell.info.projectileSpeed, myHero.BoundingRadius, GetSpellRadius(spell) + 5, out isCollision);
                 * if (isCollision && movingCollisionTime > 0)
                 * {
                 *  if (spellPos.Distance(spell.endPos) / spell.info.projectileSpeed > movingCollisionTime)
                 *      return true; //if collision happens when the skillshot is in flight
                 * }
                 *
                 *
                 * //Check if skillshot will hit hero if hero is moving and the skillshot is moved forwards by 50 units
                 *
                 * spellPos = spellPos + spell.direction * spell.info.projectileSpeed * (delay / 1000); //move the spellPos by 50 miliseconds forwards
                 * spellPos = spellPos + spell.direction * 50; //move the spellPos by 50 units forwards
                 *
                 * var finalExtraDelay = (50 / spell.info.projectileSpeed) + (delay / 1000);
                 *
                 * float extraCollisionTime = MathUtils.GetCollisionTime(heroPos, spellPos, walkDir * speed, spell.direction * spell.info.projectileSpeed, myHero.BoundingRadius, GetSpellRadius(spell) + 5, out isCollision);
                 * if (isCollision && extraCollisionTime > -finalExtraDelay)
                 * {
                 *  if (spellPos.Distance(spell.endPos) / spell.info.projectileSpeed > extraCollisionTime)
                 *      return true; //if collision happens when the skillshot is in flight
                 *  else
                 *      return false;
                 * }*/
            }
            else if (spell.info.spellType == SpellType.Circular)
            {
                var spellHitTime   = Math.Max(0, spell.endTime - Evade.GetTickCount()); //extraDelay
                var walkRange      = heroPos.Distance(pos);
                var predictedRange = speed * (spellHitTime / 1000);
                var tHeroPos       = heroPos + walkDir * Math.Min(predictedRange, walkRange);             //Hero predicted pos

                return(tHeroPos.Distance(spell.endPos) <= GetSpellRadius(spell) + myHero.BoundingRadius); //+ dodgeBuffer
            }
            else if (spell.info.spellType == SpellType.Cone)
            {
                var spellHitTime = Math.Max(0, spell.endTime - Evade.GetTickCount());  //extraDelay
                var tHeroPos     = heroPos + walkDir * speed * (spellHitTime / 1000);

                return(inSkillShot(spell, tHeroPos, myHero.BoundingRadius));
            }

            return(false);
        }
示例#12
0
        private void Drawing_OnDraw(EventArgs args)
        {
            //PrintTimers();

            //EvadeHelper.GetBestPositionTest();

            var path = myHero.Path;

            if (path.Length > 0)
            {
                var heroPos2 = path[path.Length - 1].To2D();//EvadeHelper.GetRealHeroPos();

                Render.Circle.DrawCircle(new Vector3(heroPos2.X, heroPos2.Y, myHero.ServerPosition.Z), myHero.BoundingRadius, Color.White, 3);
                //Render.Circle.DrawCircle(new Vector3(myHero.ServerPosition.X, myHero.ServerPosition.Y, myHero.ServerPosition.Z), myHero.BoundingRadius, Color.White, 3);
                Render.Circle.DrawCircle(new Vector3(circleRenderPos.X, circleRenderPos.Y, myHero.ServerPosition.Z), 10, Color.Red, 3);
            }

            foreach (KeyValuePair <int, Spell> entry in SpellDetector.drawSpells)
            {
                Spell spell = entry.Value;

                if (spell.info.spellType == SpellType.Line)
                {
                    Vector2 spellPos = SpellDetector.GetCurrentSpellPosition(spell);

                    Render.Circle.DrawCircle(new Vector3(spellPos.X, spellPos.Y, myHero.Position.Z), spell.info.radius, Color.White, 3);

                    /*spellPos = spellPos + spell.direction * spell.info.projectileSpeed * (60 / 1000); //move the spellPos by 50 miliseconds forwards
                     * spellPos = spellPos + spell.direction * 200; //move the spellPos by 50 units forwards
                     *
                     * Render.Circle.DrawCircle(new Vector3(spellPos.X, spellPos.Y, myHero.Position.Z), spell.info.radius, Color.White, 3);*/
                }
            }

            if (testMenu.Item("DrawHeroPos").GetValue <bool>())
            {
                Render.Circle.DrawCircle(new Vector3(myHero.ServerPosition.X, myHero.ServerPosition.Y, myHero.ServerPosition.Z), myHero.BoundingRadius, Color.White, 3);
            }

            if (testMenu.Item("TestPath").GetValue <bool>())
            {
                var     tPath     = myHero.GetPath(Game.CursorPos);
                Vector2 lastPoint = Vector2.Zero;

                foreach (Vector3 point in tPath)
                {
                    var point2D = point.To2D();
                    Render.Circle.DrawCircle(new Vector3(point.X, point.Y, point.Z), myHero.BoundingRadius, Color.Violet, 3);

                    lastPoint = point2D;
                }
            }

            if (testMenu.Item("TestPath").GetValue <bool>())
            {
                var     tPath     = myHero.GetPath(Game.CursorPos);
                Vector2 lastPoint = Vector2.Zero;

                foreach (Vector3 point in tPath)
                {
                    var point2D = point.To2D();
                    Render.Circle.DrawCircle(new Vector3(point.X, point.Y, point.Z), myHero.BoundingRadius, Color.Violet, 3);

                    lastPoint = point2D;
                }
            }

            if (testMenu.Item("TestWall").GetValue <bool>())
            {
                foreach (var posInfo in sortedBestPos)
                {
                    var posOnScreen = Drawing.WorldToScreen(posInfo.position.To3D());
                    //Drawing.DrawText(posOnScreen.X, posOnScreen.Y, Color.Aqua, "" + (int)posInfo.closestDistance);

                    if (!posInfo.rejectPosition)
                    {
                        Drawing.DrawText(posOnScreen.X, posOnScreen.Y, Color.Aqua, "" + (int)posInfo.closestDistance);
                    }

                    /*if (posInfo.posDangerCount <= 0)
                     * {
                     *  var pos = posInfo.position;
                     *  Render.Circle.DrawCircle(new Vector3(pos.X, pos.Y, myHero.Position.Z), (float)25, Color.White, 3);
                     * }*/
                }
            }
        }
示例#13
0
        private void Game_OnIssueOrder(Obj_AI_Base hero, GameObjectIssueOrderEventArgs args)
        {
            if (!hero.IsMe)
            {
                return;
            }

            if (args.Order == GameObjectOrder.HoldPosition)
            {
                var path      = myHero.Path;
                var heroPoint = myHero.ServerPosition.To2D();


                if (path.Length > 0)
                {
                    var movePos = path[path.Length - 1].To2D();
                    var walkDir = (movePos - heroPoint).Normalized();

                    //circleRenderPos = EvadeHelper.GetRealHeroPos();
                    //heroPoint;// +walkDir * myHero.MoveSpeed * (((float)Game.Ping) / 1000);
                }
            }

            /*
             * if (args.Order == GameObjectOrder.MoveTo)
             * {
             *  if (testingCollision)
             *  {
             *      if (args.TargetPosition.To2D().Distance(testCollisionPos) < 3)
             *      {
             *          //var path = myHero.GetPath();
             *          //circleRenderPos
             *
             *          args.Process = false;
             *      }
             *  }
             * }*/

            if (args.Order == GameObjectOrder.MoveTo)
            {
                Vector2 heroPos = myHero.ServerPosition.To2D();
                Vector2 pos     = args.TargetPosition.To2D();
                float   speed   = myHero.MoveSpeed;

                startWalkPos  = heroPos;
                startWalkTime = Evade.GetTickCount();

                foreach (KeyValuePair <int, Spell> entry in SpellDetector.spells)
                {
                    Spell spell    = entry.Value;
                    var   spellPos = SpellDetector.GetCurrentSpellPosition(spell);
                    var   walkDir  = (pos - heroPos).Normalized();


                    float spellTime = (Evade.GetTickCount() - spell.startTime) - spell.info.spellDelay;
                    spellPos = spell.startPos + spell.direction * spell.info.projectileSpeed * (spellTime / 1000);
                    //Game.PrintChat("aaaa" + spellTime);


                    bool  isCollision         = false;
                    float movingCollisionTime = MathUtils.GetCollisionTime(heroPos, spellPos, walkDir * (speed - 25), spell.direction * (spell.info.projectileSpeed - 200), myHero.BoundingRadius, EvadeHelper.GetSpellRadius(spell), out isCollision);
                    if (isCollision)
                    {
                        //Game.PrintChat("aaaa" + spellPos.Distance(spell.endPos) / spell.info.projectileSpeed);
                        if (true)//spellPos.Distance(spell.endPos) / spell.info.projectileSpeed > movingCollisionTime)
                        {
                            Game.PrintChat("movingCollisionTime: " + movingCollisionTime);
                            //circleRenderPos = heroPos + walkDir * speed * movingCollisionTime;
                        }
                    }
                }
            }
        }